Rusty
  • Rusty
  • 50.25% (Neutral)
  • Private Topic Starter
13 years ago
I've tried to search for this via google, but I'm picking up a lot of dud results (references to maps and levels built rather than any scripting explanations).

I'm curious about how I would set up a script condition so the AI can check how much money it's got. I notice it's can check the player's income (but I assume that's the human player... unless it means the player using the script...), but I can't find anything for the AI itself?

The reason I ask is completely different tactics apply depending on it's starting resources, and this is a level where supply docks won't be available as it's a capture map. It's possible for a base to be self-sufficient from it's starting resources - but how fast the base can be built depends on it's available money.
Sponsor
i^love^mixery
13 years ago
*** IF ***
0  is Less Than the number of credits possessed by Player '<This Player>'

is what you need when scripting the AI. if you are scripting SkirmishGLA and you put a script with into the script folder for SkirmishGLA then all skirmishGLA comps with use this script set and will refer to the SkirmishGLA comps itself.
Rusty
  • Rusty
  • 50.25% (Neutral)
  • Private Topic Starter
13 years ago
Okay, I set the condition at 5000 etc. Although I'm having trouble getting the intended behaviour:

1) How do I permanently disable the script, say, after a space of 2-3 seconds has passed? (So it doesn't run any of the other scripts during mid-game). Is there an 'and not' or similar feature for the conditions?

2) Presently, the script has a list of buildings the AI is expected to build in a specific order (reactor, dozer, supply centre, airfield, strategy centre, supply drop), however on constructing the reactor, the dozer just sits there and nothing happens (note the script doesn't yet spawn a dozer, so it should just build the supply centre). Why is this occurring, and how to I prevent it?

3) I attempted to find a way to make the AI build units, but I can only find either 'build' for buildings, or 'spawn' - which seems like it would just make the units magically appear at a waypoint (I tried it and it seemed to crash the map). What command do I use to get it to build units legitimately?

4) How can I get it to build units (rather than buildings) and set them to a specific place? IE a comanche that hovers in a particular spot?
DecliningAtom52
13 years ago
Hi

1) This is way too complicated and unneccesary, but you would need two scripts, one to set a timer to 2 seconds, and one to detect when the timer expired, and use the action Disable Script.

2) Are you using the Skirmish Only > Build a building? If so this does not work in Single Player maps, you need to click the icon in the control bar (at the top) which says BUILD LIST. This will allow you to place buildings. If you are doing this already, make sure the AI has enough cash to continue building. You may also have set to build buildings of a different faction, eg Air force dozer trying to build Lazer turret.

You should also note that Build List is fairly unreliable for building in the order you set, the AI will try to build a structure every 0.5 seconds, so it will just spam reactors until the next level of the tech tree is completed.

3) Click the icon next to scripts (three little people) choose your AI player on the left click 'Add New Team'. Choose how many units you wish to train and what you wish to train in the main section, you will need to create a script which has the Subroutine ticked and the Disable on completion not checked. If this condition is true, the team will be built.

4) In the team menu, set home position to a waypoint.

If you need more help just say.
'As always, Have nice day.' - FPSRussia
Rusty
  • Rusty
  • 50.25% (Neutral)
  • Private Topic Starter
13 years ago
1) I've found an alternative (if one of the four scripts runs, it disables the others).

2) Yeah, it's skirmish mode, and I'm using the build a building option. The dozer builds either one reactor (if the start-up reactor script is enabled), or numerous reactors (if the low power (?) script is enabled), but it doesn't build a supply centre or similar - although I've checked the conditions. I wasn't aware of a build list.

2.1) The conditions (for building a supply center) are:
SkirmishAmerica has Greater Than or Equal To 1 unit or structure with kind is 'FS_POWER' in the area [Skirmish]MyInnerPerimeter
SkirmishAmerica has Less Than or Equal To 1 unit or structure with kind is 'FS_SUPPLY_CENTER' in the area [Skirmish]MyInnerPerimeter
1200 is Less Than the number of credits possessed by Player 'SkirmishAmerica'

Both spots have an InnerPerimter (InnerPerimeter1, InnerPerimeter2). So I can't suss why it wouldn't build anything (I included a supply dock in-case that was the reason why).

3) I added a dozer team, which it then created. The dozer didn't do anything, so I assume that is where the sub-routine thing is used?

4) That works.


5) I'm having issues with the viewing area of the map. Although I modified the boundary which shows practically all of the map, there seems to be a dark outer layer that can't be seen (although units can travel on it and units can build on it), as if it was out of bounds. How do I fix that? Modifying the boundary has no noticeable effect.
DecliningAtom52
13 years ago
Ok, if your using skirmish mode then thats fine, ignore the build list.

In skirmish mode you cannot use 'Build a build of type: AmericaSupplyCenter' you must goto Player > AI > Build 'AmericaSupplyCenter' near a supply src with at least:(10000 is a good number). You should also do this for building defences near the supply. The second dozer you made requires no extra scripts, the dozer will do something when there is work for it to do. I also think that the skirmish AI automatically handles building extra power plants if power is low, but leave it there for now.

Why don't you use the script Map > Shroud or Reveal > Reveal the world permanantly for player: SkirmishGLA (or any others), instead of using borders.
'As always, Have nice day.' - FPSRussia
Rusty
  • Rusty
  • 50.25% (Neutral)
  • Private Topic Starter
13 years ago
I just want it to build a supply centre. It doesn't need to be near a specific source because it's possible for a base to turn self-sufficient (even if relatively defenceless) with 10,000 credits. I'm basically trying to form an economic powerhouse AI (that builds supply drops) - in short, it echoes my style. I'll try the other way of building a supply center though.
DecliningAtom52
13 years ago

I just want it to build a supply centre. It doesn't need to be near a specific source because it's possible for a base to turn self-sufficient (even if relatively defenceless) with 10,000 credits. I'm basically trying to form an economic powerhouse AI (that builds supply drops) - in short, it echoes my style. I'll try the other way of building a supply center though.

Originally Posted by: Rusty 



If you want the computer to build the supply center inside the base, you will need to use an INI file to modify the build position of Supply Centers, I could send you an INI file to do this, but only if you need it.
'As always, Have nice day.' - FPSRussia
Rusty
  • Rusty
  • 50.25% (Neutral)
  • Private Topic Starter
13 years ago

If you want the computer to build the supply center inside the base, you will need to use an INI file to modify the build position of Supply Centers, I could send you an INI file to do this, but only if you need it.

Originally Posted by: DecliningAtom52 



That's more the sort of thing I'm after. Your suggestion with the near a supply source worked - but now the dozer just keeps building a supply center (I added in an audio effect to the script - and the audio is silent after it starts building the first supply center... so I don't know why it keeps building other supply centers). Argh... this AI has a mind of it's own!
DecliningAtom52
13 years ago
Ok, I'll upload an INI file tommorrow (sorry), in the meantime you could use Build of type "AmericaSupplyCenter" on the flank, make sure that Deactivate on Success is ticked on the build Supply Center Script.
'As always, Have nice day.' - FPSRussia
Rusty
  • Rusty
  • 50.25% (Neutral)
  • Private Topic Starter
13 years ago

Ok, I'll upload an INI file tommorrow (sorry), in the meantime you could use Build of type "AmericaSupplyCenter" on the flank, make sure that Deactivate on Success is ticked on the build Supply Center Script.

Originally Posted by: DecliningAtom52 



Don't worry, take your time! You've helped me get this far, and I think I understand how the scripting works - it seems to 'backlog' the scripts.

If I enable 'deactivate on success', can the script then be re-enabled using the enable script command, or does it only run the once?

Edit:

I'd also ask: how do you create a flag? This would help solve a lot of the problems.
i^love^mixery
13 years ago
Scripting -> Flags -> Create

*** IF ***
True.
*** THEN ***
Set Flag named 'Flag001' to FALSE

as simple as that. you dont have to initialize them or anything.

i also have noticed the AI to build as it sees fit regardless of my script orders. it seems to be buggy.
Rusty
  • Rusty
  • 50.25% (Neutral)
  • Private Topic Starter
13 years ago

i also have noticed the AI to build as it sees fit regardless of my script orders. it seems to be buggy.

Originally Posted by: i^love^mixery 



I've noticed the AI is acting as if the build orders are more 'suggestions' - although I've managed to successfully get it to build the intended base in close enough the right order (reactor, supply center, airfield, strategy center, supply drop, additional reactors).

Noted bugs though include: unwanted additional supply choppers, refusal to build additional reactors despite insufficient power supply script (and insufficient power - preventing the other scripts kicking in), dozer teams working in serial (rather than parallel IE two dozers, one will often wait for the other despite being able to build), refusal to build firebases (which are permitted as they don't take power so power conditions don't apply), refusal to build supply center unless there is a supply dock (it's possible to survive without a dock with 10,000 or more - supply drops).


Despite this, as a computer games programmer personally speaking, the system works counter-intuitively - if I destroy a building, rather than the AI not doing anything (which it should - as I haven't set up any events for it), it attempts to rebuild the lost building as if it remembers where it is. Given I've not set anything to enable this and it's implicit, I find to be surprising.

Individuals might argue that replacing any building is the correct course of action, but if I lose a reactor in my base, I often upgrade the non-upgraded (I always have a few un-upgraded for this purpose) reactors instead to compensate - so the dozers can repair other structures first (unless it's low power, then building a reactor is faster than an upgrade).

Actually, I find a lot of it's behaviour is surprising. For example, if it builds a supply center, it will automatically assign additional choppers (regardless as to whether or not the supply source is valid for it, IE has sufficient funds to validate purchase), but if it builds anything else, it doesn't build any other additional units unless commanded to do so.

This is terribly inconsistent behaviour. Either the AI should be fuzzy in it's interpretation of all things, or literal - but not both (as you lose the advantages of either) - better yet, there should be an option for literal versus fuzzy commands (enable fuzzy interpretation... or something).


I want to build an economic powerhouse AI so I actually have a challenge. But at the moment it's proving difficult.
DecliningAtom52
13 years ago
Haven't got round to the ini file yet, but the file can also solve the too many choppers issue, I am currently building a boss general AI, and I would agree that skirmish ai is hard to script, the ai moves buildings so that the base fits within the InnerPerimeter. But I don't know why your dozers refuse to work in paralell, would you be able to PM an .scb of your skirmish scripts? (I won't steal)
'As always, Have nice day.' - FPSRussia
DecliningAtom52
13 years ago
Here is the INI (I don't know if it could be smaller) Paste this into a file called map.ini in the map folder (My Documents/Cnc Generals Zero Hour Data/Maps/MyMap/map.ini

AIData

StructureSeconds = 0.0 ; Ai tries to build a new structure every N seconds.
TeamSeconds = 10 ;Ai tries to build a new team every N seconds.
Wealthy = 7000 ; Number of resources for the AI to consider itself wealthy
Poor = 2000 ; Number of resources for the AI to consider itself poor
StructuresWealthyRate = 2.0 ; (2=twice as fast) Rate modifier for structure building when wealthy.
StructuresPoorRate = 0.6 ; (0.5=half as fast) Rate modifier for structures when poor.
TeamsWealthyRate = 2.0 ; (2=twice as fast) Rate modifier for teams building when wealthy.
TeamsPoorRate = 0.6 ; (0.5=half as fast) Rate modifier for teams when poor.
TeamResourcesToStart = 0.1 ; (1.0=100%) Amount of resources required to start building a team.
GuardInnerModifierAI = 1.1 ;The radius modifier to vision which a guarding (AI Controlled) unit will agressively attack
GuardOuterModifierAI = 1.333 ;The radius modifier to vision which a guarding (AI Controlled) unit will chase after
GuardInnerModifierHuman = 1.8 ;1.1 ;The radius modifier to vision which a guarding (Human Controlled) unit will agressively attack
GuardOuterModifierHuman = 2.2 ;1.333 ;The radius modifier to vision which a guarding (Human Controlled) unit will chase after
GuardChaseUnitsDuration = 10000 ;The number of msec for which a guarding unit will chase attackers before giving up
GuardEnemyScanRate = 500 ; when actively guarding, how often to scan for enemies (msec)
GuardEnemyReturnScanRate = 1000 ; when returning to "active" guarding (from pursuing someone), how often to scan for enemies (msec)
AlertRangeModifier = 1.1 ;The adjustment applied when a unit is alert and doing various scans for enemies (AI units only)
AggressiveRangeModifier = 1.5 ;The adjustment applied when a unit is aggressive and doing various scans for enemies (AI units only)
AttackPriorityDistanceModifier = 100.0 ;The distance required to reduce attack priority by 1.
MaxRecruitRadius = 500.0 ;The maximum distance a unit will be from a unit that recruits it.
SkirmishBaseDefenseExtraDistance = 150.0 ; Instead of placing base defenses on the template edge, bump it this much farther out
ForceIdleMSEC = 67 ;The number of milisec a unit must be idle before looking for an enemy, 2 frames.
ForceSkirmishAI = No ; Use skirmish instead of solo ai. For development till the skirmish ui is finished. jba.
RotateSkirmishBases = No ; If yes, rotate base layout so same side of base faces center of map.
AttackUsesLineOfSight = Yes ; If yes, attack for ALL UNITS (player and ai) uses line of sight.

EnableRepulsors = Yes ; If yes, KINDOF_CAN_BE_REPULSED will run from enemies & repulsors.
RepulsedDistance = 150.0 ; How far beyond vision range a repulsed civilian will run before stopping.
; so if vision range is 120.0, he will move to a point at least 270.0 away from the enemy, and then stop running.

WallHeight = 43 ; Height of the "Wall", made of KIND WALK_ON_TOP pieces.

AttackIgnoreInsignificantBuildings = Yes ; If yes, units will ignore enemy-owned buildings that are not faction buildings

; SkirmishGroupFudgeDistance is the distance that is multiplied by the number of units in a group to
; determine if they are close enough to the waypoint to consider themselves AT the waypoint. This is
; only used for "Follow Waypoint Path as a Team."
SkirmishGroupFudgeDistance = 5.0

; Group pathfinding parameters.
MinInfantryForGroup = 3 ; Have to have 3 infantry to do group movement.
MinVehiclesForGroup = 3 ; Have to have 3 vehicles to do group movement.
MinDistanceForGroup = 100.0 ; Have to be moving at least this far for group movement.
DistanceRequiresGroup = 500.0 ; Force group movement if moving at least this far.

; Note that these group pathfind parameters are inter-related, and modifying them may produce really
; ugly results & require code changes. jba.
InfantryPathfindDiameter = 6 ; Number of pathfind cells wide group path is for infantry.
VehiclePathfindDiameter = 6 ; Number of pathfind cells wide group path is for vehicles.

SupplyCenterSafeRadius = 300.0 ; Radius to scan for enemies to determine if a supply center is safe.
RebuildDelayTimeSeconds = 30 ; Delay this many seconds when a base building is destroyed or captured before attempting rebuild.

AIDozerBoredRadiusModifier = 2.0 ; Multiplier to dozer scan radius for repair & mine clearing. 2.0 means ai uses twice the radius as human dozers.
AICrushesInfantry = Yes ; If yes, ai will attempt to crush infantry with vehicles.

; Retaliation parameters.
MaxRetaliationDistance = 200.0 ; If the attacker is more than this far away, won't chase. Keeps from chasing artillery.
RetaliationFriendsRadius = 120.0 ; Retaliator gathers allies within this distance & attacks.

SideInfo America
ResourceGatherersEasy = 1
ResourceGatherersNormal = 1
ResourceGatherersHard = 1
BaseDefenseStructure1 = AmericaPatriotBattery

SkillSet1
Science = SCIENCE_PaladinTank
Science = SCIENCE_StealthFighter
Science = SCIENCE_A10ThunderboltMissileStrike1
Science = SCIENCE_A10ThunderboltMissileStrike2
Science = SCIENCE_A10ThunderboltMissileStrike3
Science = SCIENCE_SpectreGunshipSolo
Science = SCIENCE_DaisyCutter
End

SkillSet2
Science = SCIENCE_PaladinTank
Science = SCIENCE_StealthFighter
Science = SCIENCE_Pathfinder
Science = SCIENCE_Paradrop1
Science = SCIENCE_Paradrop2
Science = SCIENCE_Paradrop3
Science = SCIENCE_DaisyCutter
End

End

;Skirmish AI Build List
SkirmishBuildList America
Structure AmericaCommandCenter
Location = X:501.22 Y:546.25
Rebuilds = 0
Angle = -135.00
InitiallyBuilt = No
AutomaticallyBuild = Yes
END ;Structure AmericaCommandCenter
Structure AmericaPowerPlant
Location = X:770.43 Y:727.79
Rebuilds = 0
Angle = -45.00
InitiallyBuilt = No
AutomaticallyBuild = No
END ;Structure AmericaPowerPlant
Structure AmericaPowerPlant
Location = X:759.90 Y:555.84
Rebuilds = 0
Angle = -45.00
InitiallyBuilt = No
AutomaticallyBuild = No
END ;Structure AmericaPowerPlant
Structure AmericaPowerPlant
Location = X:374.82 Y:371.69
Rebuilds = 0
Angle = -45.00
InitiallyBuilt = No
AutomaticallyBuild = No
END ;Structure AmericaPowerPlant
Structure AmericaPowerPlant
Location = X:477.11 Y:174.62
Rebuilds = 0
Angle = -45.00
InitiallyBuilt = No
AutomaticallyBuild = No
END ;Structure AmericaPowerPlant
Structure AmericaPowerPlant
Location = X:189.19 Y:522.00
Rebuilds = 0
Angle = -45.00
InitiallyBuilt = No
AutomaticallyBuild = No
END ;Structure AmericaSupplyCenter
Structure AmericaPowerPlant
Location = X:418.35 Y:827.10
Rebuilds = 0
Angle = -45.00
InitiallyBuilt = No
AutomaticallyBuild = No
END ;Structure AmericaPowerPlant
Structure AmericaAirfield
Location = X:767.04 Y:376.40
Rebuilds = 0
Angle = -135.00
InitiallyBuilt = No
AutomaticallyBuild = No
END ;Structure AmericaAirfield
Structure AmericaBarracks
Location = X:247.52 Y:734.59
Rebuilds = 0
Angle = 45.00
InitiallyBuilt = No
AutomaticallyBuild = No
END ;Structure AmericaBarracks
Structure AmericaParticleCannonUplink
Location = X:594.59 Y:635.72
Rebuilds = 0
Angle = -45.00
InitiallyBuilt = No
AutomaticallyBuild = No
END ;Structure AmericaParticleCannonUplink
Structure AmericaStrategyCenter
Location = X:384.36 Y:652.24
Rebuilds = 0
Angle = 45.00
InitiallyBuilt = No
AutomaticallyBuild = No
END ;Structure AmericaStrategyCenter
Structure AmericaSupplyDropZone
Location = X:515.66 Y:347.88
Rebuilds = 0
Angle = 45.00
InitiallyBuilt = No
AutomaticallyBuild = No
END ;Structure AmericaSupplyDropZone
Structure AmericaSupplyDropZone
Location = X:637.41 Y:490.20
Rebuilds = 0
Angle = 45.00
InitiallyBuilt = No
AutomaticallyBuild = No
END ;Structure AmericaSupplyDropZone
Structure AmericaSupplyDropZone
Location = X:488.83 Y:760.27
Rebuilds = 0
Angle = 45.00
InitiallyBuilt = No
AutomaticallyBuild = No
END ;Structure AmericaSupplyDropZone
Structure AmericaSupplyDropZone
Location = X:322.39 Y:502.03
Rebuilds = 0
Angle = 45.00
InitiallyBuilt = No
AutomaticallyBuild = No
END ;Structure AmericaSupplyDropZone
Structure AmericaWarFactory
Location = X:650.93 Y:843.45
Rebuilds = 0
Angle = 45.00
InitiallyBuilt = No
AutomaticallyBuild = No
END ;Structure AmericaWarFactory
Structure AmericaWarFactory
Location = X:259.56 Y:289.71
Rebuilds = 0
Angle = -135.00
InitiallyBuilt = No
AutomaticallyBuild = No
END ;Structure AmericaWarFactory
Structure AmericaPatriotBattery
Location = X:676.07 Y:670.51
Rebuilds = 0
Angle = 45.00
InitiallyBuilt = No
AutomaticallyBuild = No
END ;Structure AmericaPatriotBattery
END ;SkirmishBuildList FactionAmerica

End


'As always, Have nice day.' - FPSRussia
i^love^mixery
13 years ago

This is terribly inconsistent behaviour. Either the AI should be fuzzy in it's interpretation of all things, or literal - but not both (as you lose the advantages of either) - better yet, there should be an option for literal versus fuzzy commands (enable fuzzy interpretation... or something).


I want to build an economic powerhouse AI so I actually have a challenge. But at the moment it's proving difficult.

Originally Posted by: Rusty 



thats exactly what i am thinking too. you are just better in finding the correct words than me😁

and thats exactly the reason why i have given up on scripting my own AI.

all i tried was to make a AI use humvee rush tactic. i got it to work but it was such a "slapped together" thing that i gave up really fast.

the chinook thing annoyed my also because the AI always built 2 additional chinooks AUTOMATICALLY yet 1 additional chinook is really all you need.

also i couldnt tell him to sell his command center for a very "pro-like" rush properly..
DecliningAtom52
13 years ago
@i^love^mixery: You can use the ini file above to create only one extra chinook, If you wanted to sell your command center at the beginning, you could use Team Uses Command Button , however you may need to delay the building of the first building for a frame.
'As always, Have nice day.' - FPSRussia
i^love^mixery
13 years ago
i know that too but the comp automatically sold his power plant after it was finished too when i told him to sell everything.

so i had to wait until 2nd dozer was built, then sell command center, then start building 1st power plant. and that took far too long.
Rusty
  • Rusty
  • 50.25% (Neutral)
  • Private Topic Starter
13 years ago

Haven't got round to the ini file yet, but the file can also solve the too many choppers issue, I am currently building a boss general AI, and I would agree that skirmish ai is hard to script, the ai moves buildings so that the base fits within the InnerPerimeter. But I don't know why your dozers refuse to work in paralell, would you be able to PM an .scb of your skirmish scripts? (I won't steal)

Originally Posted by: DecliningAtom52 



Don't worry about using anything I give you, I consider all work I do open use (with the exception of commercial usage). I think I know why - initial start-up buildings can't be built before others, and often only one can be built before another (so it can only work in series between the dozers).

The newest issue is it reaches an in-cap of 4 supply drops before it stops building them (it can only stop building them temporarily when there's too little money, or if it exceeds 100000) - even when a supply of money is apparent. I would give it more space but I'm afraid it might build the supply drops in stupid places, like half-way across the map or something.


I just want to build an AI that mimicks my tactics (but does it better than I can) so it can challenge me to invent new tactics - I'm a turtle defender who uses economic roll-over to mass produce super-weapons and depending on the general, ground units. I want an AI that will just continuously spam defences, supply drops, reactors and super-weapons pretty much everywhere.

Rusty
  • Rusty
  • 50.25% (Neutral)
  • Private Topic Starter
13 years ago

Here is the INI (I don't know if it could be smaller) Paste this into a file called map.ini in the map folder (My Documents/Cnc Generals Zero Hour Data/Maps/MyMap/map.ini

Originally Posted by: DecliningAtom52 



Does map.ini have to be renamed to be the same name as the map? For example, mine is called 'City.map', so would the .ini be renamed to City.ini?

Could you explain to me how the .ini works? I vaguely remember something about .ini files (I am sure I've done something like this before in a deja vu esque feeling but... I don't think I've done AI programming for generals before...).

If I 'recall' correctly, the X and Y co-ordinates are relative to the command center? Angle is obviously which direction it faces when built. Rebuilds, if 0, is infinite rebuilds, correct? Or does that mean it doesn't attempt to rebuild it?

Would it be possible for me to specify numerous supply drops etc next to each other using this?