Author Topic: OP2 Scenario Project for C#  (Read 75981 times)

Offline lordpalandus

  • Banned
  • Hero Member
  • *****
  • Posts: 825
Re: OP2 Scenario Project for C#
« Reply #125 on: September 22, 2019, 02:28:37 PM »
A few questions:

1. How does it decide to focus on building a specific combat unit. Ie should I build a laser lynx, a railgun lynx, or a starflare lynx? Each are similarly priced but each serves a different combat role. Or maybe decide to save up for a Laser Tiger instead?

2. What happens when no one focuses on military? Does no AI become proactive and start building a military or do they all stay in colony mode?

3. Do the AIs suffer from morale and thus from blowing up an enemy's Nursery and the massive morale penalty that follows? Or Morale in general, and thus the need to keep a food surplus, sufficient residences, or an active nursery/university?

4. Do the AIs spend any time on preparing for disasters? ie if an AI had resources for lava walls, would they build them to protect their base from getting melted?

5. Can the AI's people die? Either from starvation, or natural causes or unnatural causes such as a starflare blowing up their workplace?
Currently working on Cataclysm of Chaos, Remade.
Link to OPU page = http://forum.outpost2.net/index.php/topic,6073.0.html

Offline TechCor

  • Full Member
  • ***
  • Posts: 141
Re: OP2 Scenario Project for C#
« Reply #126 on: September 22, 2019, 03:50:14 PM »
1. How does it decide to focus on building a specific combat unit. Ie should I build a laser lynx, a railgun lynx, or a starflare lynx? Each are similarly priced but each serves a different combat role. Or maybe decide to save up for a Laser Tiger instead?

The combat manager creates a bunch of Threat Zones that contain priority targets. Each zone has an empty combat group assigned to it. The combat group's type (bomb squad, assault group, etc) is based on the type of zone (defend base, attack building, etc). The combat group's "desired strength" is set to something above the total enemy strength in that zone. The combat group then generates a list of unit slots base on the group type and desired strength. Each slot contains a list of "supported unit types" (panther laser, lynx supernova, etc).

The combat manager goes through the list of zones, assigns units that are already in a zone to that group's slots, if it fits. Then it assigns the remaining units to zone groups based on zone priority and whether the unit fits in the slot. Finally, the remaining empty slots are placed into a list (based on zone priority). This is grabbed by base manager when it starts its update and is processed by MaintainArmyGoal.

Right now, it picks the most important empty slot and randomly picks a supported unit type to build. If it can't build it, it will randomly pick a different type. This method has some issues such as not saving metal for more powerful units, and will need to be adjusted.

NOTE: All things combat related are not final!

2. What happens when no one focuses on military? Does no AI become proactive and start building a military or do they all stay in colony mode?

I want to tweak this formula, but the way it currently works, is that it checks all enemy players for combat units. It assigns an importance based on perceived threat. So for example, if all enemies have no combat units, it assigns a importance of about 0.5. If its combat strength is above the strength of each individual enemy, the importance drops lower than 0.5. If its combat strength is less than each enemy, its importance rises. I would like to add Advanced Lab and Vehicle Factory as bonus importance so that it doesn't wait until it's practically being whacked before starting.

When does it pursue building combat units? It depends on where the goal is in the priority list, and if it is being blocked by a higher priority goal. In a previous video, it built weapons right away because it did not need to research anything, and had plenty of metal. In the current one, MaintainPopulation blocked up the labs, preventing weapons research from getting done. It didn't start building combat units until MaintainPop finished all of its optional research. MaintainPopulationGoal is too aggressively important right now and needs to be tweaked.


3. Do the AIs suffer from morale and thus from blowing up an enemy's Nursery and the massive morale penalty that follows? Or Morale in general, and thus the need to keep a food surplus, sufficient residences, or an active nursery/university?
5. Can the AI's people die? Either from starvation, or natural causes or unnatural causes such as a starflare blowing up their workplace?

The AI runs as a human player, including all the pros and cons that provides. Disasters lower morale, people are needed to activate structures, food to prevent starvation, morale/nurseries/universities to grow population, training scientists to fill labs, etc.

4. Do the AIs spend any time on preparing for disasters? ie if an AI had resources for lava walls, would they build them to protect their base from getting melted?

AIs have no knowledge of disasters at the moment and would build in a lava flow if the mission developer put them in a poor location. They will attempt to recover from any disasters that don't kill them.
« Last Edit: September 22, 2019, 03:53:19 PM by TechCor »

Offline lordpalandus

  • Banned
  • Hero Member
  • *****
  • Posts: 825
Re: OP2 Scenario Project for C#
« Reply #127 on: September 23, 2019, 01:48:25 AM »
Ok cool. Thanks for the indepth replies. Here are some other questions:

1. Does the AI use group tactics, or just sends individual units to a spot? From watching the video, it seems each individual unit is sent to a spot.

2. Where on the list of priorities, does repairing damage fall in? ie a meteor hits a residence; does the AI prioritize resources to building lynxes to fight the enemy pounding on their turrets or do they spend their resources repairing the residence?

3. Similarly, will units use a Garage when damaged?

4. Or a better question, will units retreat after taking X damage, so that they might survive to return to repair?

5. How does the Ai handle earning enemy units via spider hacking? As the unit wasn't built, and its allegiance used to be another player...
Currently working on Cataclysm of Chaos, Remade.
Link to OPU page = http://forum.outpost2.net/index.php/topic,6073.0.html

Offline TechCor

  • Full Member
  • ***
  • Posts: 141
Re: OP2 Scenario Project for C#
« Reply #128 on: September 23, 2019, 02:28:44 AM »
1. Does the AI use group tactics, or just sends individual units to a spot? From watching the video, it seems each individual unit is sent to a spot.
Combat is not finished yet, but it will have group and individual tactics. Currently, groups stage outside a Threat Zone before entering, but it does not work properly at all. Group tactics are essentially "send this group of units to this zone through this path", individual tactics will be "ESG does not shoot structures", "starflares attack between groups of units", and "stay just out of range of enemy fire, if possible".

Quote
2. Where on the list of priorities, does repairing damage fall in? ie a meteor hits a residence; does the AI prioritize resources to building lynxes to fight the enemy pounding on their turrets or do they spend their resources repairing the residence?
AI prioritizes repairs to structures that have been critically damaged / disabled if it is required to complete another task. For example, if the task is to build a laser lynx, but the vehicle factory is crippled, it will prioritize repairing the factory. Same deal with tubing. If the residence was destroyed, cutting off tube access to the factory, it will prioritize reconnecting the factory. What gets repaired/reconnected/rebuilt first, if more than one building is crippled/disconnected/destroyed, is based on relative goal priority/importance.

There is a general purpose repair goal that does non-critical repairs. If repair units are not busy doing something else, and there is enough spare metal that other, higher priority tasks are not blocked, they will repair structures.

Quote
3. Similarly, will units use a Garage when damaged?
Garages have not been added to the task tree yet. They are not like other structures and need very special handling. It will likely end up as a separate goal.

Quote
4. Or a better question, will units retreat after taking X damage, so that they might survive to return to repair?
Combat is very rudimentary right now. I'd like to get them attacking properly before worrying about retreat/repair behavior. I think I have assault groups set up to take a repair unit for every 10th unit so they can repair during the assault, but individual tactics haven't been worked on yet.

Quote
5. How does the Ai handle earning enemy units via spider hacking? As the unit wasn't built, and its allegiance used to be another player...
No individual tactics yet. Spiders can't reprogram. Captured units, or combat units created by the mission developer, are processed by the combat manager like any other combat unit. Supported unit types for slots include both colonies. Cargo trucks, convecs, etc, are used by the base manager if it can find a use for them.

Generally speaking, any unit or structure that an AI gains possession of will be taken into account. A mission could spawn units and buildings out of thin air, and it will start using them.

Offline Crow!

  • Jr. Member
  • **
  • Posts: 74
Re: OP2 Scenario Project for C#
« Reply #129 on: September 23, 2019, 02:29:28 PM »
A bit off topic here, but someone should totally make a map based on that idea. Disable all weapons except for starflares, so the player is forced to defend with them. Then an AI can send wave after wave of their own tanks at the player's base.  ;)
Commander:
Our situation is dire.  We have spotted a fleet of what can only be described as bombs on wheels headed from Eden's base to ours.  Though we assigned our top scientists to defense projects months ago, they have squandered our resources on flights of fancy like "invisible lasers", "self-cleaning glue", and perhaps dumbest of all, a system that appears to simply be a joy buzzer dispenser.

Useless researchers notwithstanding, our vehicle factory workers can create a rough facsimile of the explosive weapons headed our way.  They may be the most awkward type of weapon imaginable for defense, but at this point we have no choice.

Remember, extinction is not an option.
« Last Edit: September 23, 2019, 02:32:20 PM by Crow! »
Speedruns, my FFIV game randomizer, and more can be found at my twitch page:
https://twitch.tv/iicrowii

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Re: OP2 Scenario Project for C#
« Reply #130 on: September 24, 2019, 06:01:53 AM »
Lol


Well, I like that the AI can take control of any units that happen to get added to the game. It definitely sounds like this is going to have some pretty robust results.

Offline lordpalandus

  • Banned
  • Hero Member
  • *****
  • Posts: 825
Re: OP2 Scenario Project for C#
« Reply #131 on: October 29, 2019, 10:16:33 PM »
Any new progress / new videos for this very interesting project?
Currently working on Cataclysm of Chaos, Remade.
Link to OPU page = http://forum.outpost2.net/index.php/topic,6073.0.html

Offline TechCor

  • Full Member
  • ***
  • Posts: 141
Re: OP2 Scenario Project for C#
« Reply #132 on: October 30, 2019, 06:55:18 PM »
Haven't gotten back to this yet as I am working 7 days a week currently. Should have my weekends back in a couple weeks or so. Holidays will help, too.

When I get back, I am going to focus on the combat system and overhauling its design. Replacing "staging areas" with moving as close as possible in a threat-free area, CombatZone/ThreatZone importance sorting, disbanding when controlling a zone is a lost cause, and combat targeting for individual units (reprogram, repair, attack cluster, attack non-stickied, attack at max distance, etc).

Offline lordpalandus

  • Banned
  • Hero Member
  • *****
  • Posts: 825
Re: OP2 Scenario Project for C#
« Reply #133 on: December 31, 2019, 05:43:18 PM »
Been a few months, any progress on this?
Currently working on Cataclysm of Chaos, Remade.
Link to OPU page = http://forum.outpost2.net/index.php/topic,6073.0.html

Offline TechCor

  • Full Member
  • ***
  • Posts: 141
Re: OP2 Scenario Project for C#
« Reply #134 on: December 31, 2019, 09:58:12 PM »
If you are talking about the AI, it has not been worked on yet. However, you can now play against it without messing with code:

https://forum.outpost2.net/index.php/topic,6318.msg88882.html#msg88882

There are some minor changes to the DotNetMissionSDK project itself in regards to how it handles JSON data to support the mission editor.

Everything is still prerelease.

Offline TechCor

  • Full Member
  • ***
  • Posts: 141
Re: OP2 Scenario Project for C#
« Reply #135 on: April 05, 2020, 06:55:48 AM »
This thread hasn't gotten any love lately.

Most of the work in the past few months has been improving the JSON mission support to work with the mission editor.

However, I have now changed how the native plugin interfaces with the interop DLL to support versioned common libraries.

In the native plugin LevelMain.cpp, instead of specifying a boolean for using a custom library, you now must specify the file name of the DotNet SDK library you want to load. This could be your own custom DotNet library, or one of the versioned common libraries (e.g. "DotNetMissionSDK_v0.dll").

The new setup will help maintain backwards compatibility with missions developed in the editor or from source while substantial enhancements to the SDK can still be made for newer missions.

The mission editor will start using the versioned SDK in its next release. It will export the plugin with the SDK version it uses.


As a side note - If you prefer writing your missions in C++, you can still hook the DotNet library into it to use its features, including the mission editor. In other words, you could do your setup in the mission editor, and hook into the DotNet library to read the .opm, while still writing your usual trigger code in C++. Sky is the limit.

Offline lordpalandus

  • Banned
  • Hero Member
  • *****
  • Posts: 825
Re: OP2 Scenario Project for C#
« Reply #136 on: July 16, 2020, 01:00:15 PM »
Been a few months since last update. Any progress?
Currently working on Cataclysm of Chaos, Remade.
Link to OPU page = http://forum.outpost2.net/index.php/topic,6073.0.html

Offline TechCor

  • Full Member
  • ***
  • Posts: 141
Re: OP2 Scenario Project for C#
« Reply #137 on: July 17, 2020, 02:54:29 PM »
Hi,

There are quite a few OP2 projects at this point, so they aren't all getting attention. I will just give a general status update for my "ecosystem".

AI and mission triggers require hundreds of hours of investment with little reward / motivation, so these are on hold indefinitely while I have only weekends available.

The Mission Hub is on indefinite hold due to a lack of community interest in it. Technically, it is fully functional sans minimaps. Maybe someday I will put in that extra weekend to finish it.

Last few weeks:
OP2UtilityDotNet is now a pure C# project. I've extended the sprite and animation support so that they can be loaded into a renderer. I don't think I need to add anything else to this project.

I've created a new sandbox Unity project (Code Name: Terra Nova) on my GitHub for recreating OP2 functionality. Currently, it loads all the game animations and can play them back correctly. I've rebuilt the OP2 main menu to have the same look and feel as the original, including music playback and the "opening" animation of dialog boxes, but Preferences, Load Game, New Campaign, and Multiplayer dialog boxes are not present or functional.

Upcoming:
This weekend, I want to release a new version of OP2UtilityDotNet. The Mission Editor will be switched to use this version, which eliminates its native dependencies which some people have had issues with.

Then, I will continue working on the sandbox project.

Current focus for the next few months in the sandbox:
- Game Frame
- Class structure for statistical information such as population and morale.
- Class structure for different unit types.
- Reading data from "Sheets".
- Panel layouts (The right side of the screen during missions)
- Rendering the Tile Map
- Loading mission data with DotNetMissionSDK (.opm support only).
- Ability to create specific instances of unit types (abstract, non-functional - "Factory design pattern").
- Assigning animations to unit types.
- Rendering vehicles and structures at their starting locations.


Disclaimer:
This is just a hobby I do for fun. I make no promises about anything. :)