Had to rush that G release out this morning before leaving for the thanksgiving festivities. I did not get to test the portal re-capturing section or let you know what changed. I normally run a few full games for release, but did not for g, so hopefully no major issues.
To detail the changes in G:
First I found very odd behavior trying to mod the capture action that comes with the game. Almost like the modded version wasn't overwritting the existing function. So i neutered it to never be chosen as an action, and re-made the capture anything action. It was called by the demigods as expected.
For the action I tried to simplify it down, so it has a fixed weight and the instant status check to confirm it can run this action only requires an enemy or neutral flag be available. Once we are performing the action, it selects a flag:
Code: asp.net
-
- if table.getn(aPortals) < table.getn(ePortals) then
- captureFlags = Utils.TableCat(nPortals, ePortals)
- captureFlags = SortEntitiesByDistanceXZ(unitPosition, captureFlags)
- if VDist3XZSq(unitPosition, captureFlags[1]) > VDist3XZSq(unitPosition, aiBrain:GetStronghold():GetPosition()) then
- captureFlags = SortEntitiesByDistanceXZ(aiBrain:GetStronghold():GetPosition(), captureFlags)
- end
- nearFlag = captureFlags[1]
- elseif table.getn(eflags) > 0 or table.getn(nflags) > 0 then
- captureFlags = Utils.TableCat(nflags, eflags)
- captureFlags = SortEntitiesByDistanceXZ(unitPosition, captureFlags)
- if table.getn(captureFlags) > 1 then
- nearFlag = captureFlags[math.random(1,2)]
- else
- nearFlag = captureFlags[1]
- end
- end
First we check if we own fewer portals than the enemy. If so, we check if we are closer to an enemy portal flag than our stronghold. My thought here was if the AI is on the other side of the map near an enemy portal flag and the enemy captures one of our flags on the other side of the map we might as well go for the flag near the unit. If we are closer to the stronghold, then we will find the portal flag closest to the stronghold and go re-capture it. This runs before selecting any other flag, so if the portal flags ever get out of balance it should be the first thing addressed by a healthy AI.
If the portal balance is in our favor or equal and there are enemy or neutral flags on the map it sorts for the flags closest to the unit. If there is more than one it randomly selects from the two closest flags. We can tinker with this, but in testing it split the AI's in a nice way, so they would go to different flags.
Some test items:
Are there any maps where the physical portal is far away from the flag? It was easier to get a list of physical portals than to loop over the flags and find the portal flags, so that part will actually send them to the portal rather than the flag near it, but finding the flag nearest a given portal shouldn't be too much effort if it is an issue on certain maps.
For this version i have the action set to 40 seconds. If the AI does not make it to the original flag selected in that time the function will run again and it may select a different flag based on the units current position. We may need a distance check on the closest flag and make sure we don't re-pick to the second closest flag when we are close to another flag.
Need to run some games to test artifact shopping. I think it will run to the health stone, shop locally, then if the team owns the artifact shop it will continue and shop for artifacts. Shopping could also come up as the master goal through the default goal picker anytime the demigod is less than full health (override action at full health), so artifacts may get purchases this way naturally. The weight for this is controlled by a sensor that checks item priority (very high for artifacts, 100+) and distance to shop.
miriyaka,
On flag defense. I wrote the custom action 'Teleport to Portal' in useitemsactions. It could be expanded to other flag types or maybe a new one that is walk based, so we save teleport flag defense for portals and maybe have a walking defense of other flags (probably should do a list of flags worth defending vs ones you can just let get captured and re-capture when you get near it).
On difficulty i believe that is stored directly with the brain as well.
I've only checked on levithan, but it successfully found a spot near the portal to capture the flag.