AI Info
From CryWiki
Contents |
AI Info for Modders
info from Morten Sandholt/Sandhesten or other info from Crytek
- (use AIExecute to get them to do something else while in combat mode)
- The AI can usually only do one action at a time.
- However there is a way to get an AI dude to fight while moving to a certain location. He might not move extremely fast, but he will get there eventually.
- -Place a tag point (RollUpBar --> AI button --> TagPoint) where you want the AI dude to go to.
- -In your flow graph add an AI:AIExecute node and an Entity:EntityID node.
- -Assign the AI dude to the AI:AIExecute node and the tag point to the Entity:EntityID node.
- -Connect the Entity:EntityID node to the ObjectID port on the AI:AIExecute node.
- -Select the action set_defend_pos in the AI:AIExecute node.
- Trigger the action however you want.
- A few things to keep in mind:
- What this actually does is change the AI dude's behavior to Camper and set a specific position for him to defend. If he isn't at that position yet he will try to get there as soon as combat starts. Remember that this will make all members of that group do this action so keep an eye on his and other AI dudes' groupID.
- Ideally there should be 12-15 meters between covers. The AI will not consider cover that is used by another AI or cover that is more than 20 meters away. The only thing we can do from a design stand point is decide between normal and secondary hide points, the rest is controlled in the AI behavior.
- Two criteria must be met for the AI to form groups: Same GroupID and same AI Character (Cover2, Camper, Flanker).
- "We have 3 basic (and a few special) characters in Crysis: Cover2, Camper and Flanker.
- Cover2 - Basic combat infantry. They will tend to work their way from cover to cover towards the player´s position.
- Camper - Defensive infantry. They will tend to stay in a specific area. Good for defending objectives.
- Flanker (sneaker) - They will tend to go from cover to cover in a circle around the player and flank."
- The ReinforcementSpot will just make the AI run there when he is alerted and play the specified animation. Anything that you want to happen afterwards will have to be set up in flow graph.
AI Paths
- other:
- "Black links in AINavModifiers are links that only become valid when the object in the way is moved. So say for instance a barrel is in the way of two AI points, the link will be black, and the AI won't use it. However, if the barrel is picked up and moved, the link becomes valid and AI can move there."
- sandhesten:
- "With big flat non-terrain areas like a parking lot you could get away with using forbidden areas."
- (in regards to not using the blue ai path pointers)
- "Try turning on AI_debugdraw 85 (set it to 0 to turn off). This is what we use for placing the forbidden areas on slopes. Red = too steep for AI, green = AI can navigate here but there may be problems."
- "For vegetation objects like trees, bushes and rocks you should set the AIRadius so that the purple circle encompasses the whole object. Again, check the vegetation in the demo level to see how it should be set up."
- "you have to regenerate AI triangulation every time you edit exisiting forbidden areas or add new ones"
- crydoc:
- Even on a flat terrain, make sure to generate new AI navigation at least once after creating the map and also after any modification to the terrain.
- The AI navigation can be generated by clicking on the Generate All Navigation item of the AI menu.
- "The AI hides at the hide anchor if an enemy is in the cone. The more AI guys you have the more hide anchors you have to place. Do not place hide anchors for just one direction. Place them for all possible directions. "
- "Hidepoints are also part of the navigation. Merge hidepoints and waypoints if they are too close to each other. "
- "The red lines show bad links: Either the links go through/close to geometry, or they are too close to other links. It is okay if the AI first has to take 1-2m step(s) before walking in the right direction. That is better than AI getting stuck. "
- "For two rooms it is enough to place these two waypoints. From every corner of the rooms the AI can reach the closest waypoint. The link gives the AI the possibility to switch rooms. "
- "The AI in this example is at the wall and is looking for the closest waypoint. Accidently the closest waypoint is behind an obstacle. In the new engine the AI would still find the correct one but it costs more performance. Instead place the waypoints with the same distance next to thin objects. "
Perception
- if you need an LTV driver to ignore you and continue whatever he is doing, while still allowing the LTV gunner to shoot at you, then you must apply an AI:AIIgnore flowgraph node to both the driver and the LTV vehicle itself.
- (cryhuss) In the field sightrange you can see the value.
- For example the ai guy Camper\Camp.Heavy_Rifle has a sightrange from 70 meter.
- Now if you put the PerceptionScale to 0.5 he will just see you in a radius of 35m.
- If you put the PerceptionScale to 2 he will spot you from 140m.
- But beware, the Perception will reset when AI goes into combat mode (to the default value, 70m, as per what their Archetype profile is set to).
- If you want the increased perception/attack range to stick, even while the AI goes into combat, then you must modify the 'attackrange' parameter for each AI dude listed under the Asian_new entity archetype library.
- ai_SOM - The two ai_SOM variables determine the speed with which your 'Stealth-O-Meter' (SOM) rises. Basically higher values for these variables cause the enemy to detect you and react faster during combat or relaxed mode (i.e prior to combat) respectively.
- ai_RODStanceInc deals with how hard it is for the AI to see you while crouched or prone.
- make it harder for yourself, type in ai_RODStanceInc=0.15
- and much harder use ai_RODStanceInc=0
- ai_WaterOcclusion [value]
- Determines by how much being in water will hide you from the enemy. The higher the value, the more likely the enemy will not see you while you're in the water/submerged (system).
Tanks
- Important! Always make sure that the behavior matches the character of the tank. So:
- Tank --> TankIdle
- TankFixed --> TankFixedIdle
- TankClose --> TankCloseIdle
- TankFixed:
- This is for fixed tank positions. A good example is "AB1_defense_tank2" in the level Tank. As you can see in the flow ::graph DisableMovement is triggered after it has been enabled and driver and gunner has entered. This will make sure the ::Tank doesn't go anywhere.
- TankClose:
- This makes the tank always stay on a specific AIPath drawn by the designer. The tank will try to adjust to the best ::position on the path to fight its target. This will minimize the risk of the tank getting stuck in geometry. A good ::example is "Asian_tank_close_8" in the Tank level. For the AIPath untick "Road" and select PathNavType "Road". Then copy ::the name of the AIPath into the sValue field of the AI:AISignal node with Signal=TANKCLOSE_PATHNAME.
- The TANKCLOSE_PATHNAME AI:AISignal node tells the tank to stay on the AIPath that is specified in sValue. The tank will ::never deviate from this path while moving around and fighting.
- Tank:
- This is unused in Crysis and therefore may not work. We only used TankFixed and TankClose.
- Tip: We use the TankClose character/behavior for boats and LTVs as well.
- Ordering TankClose to switch to a different patrol path during combat
- note: They may continue shooting at you but in the wrong direction if you have moved away. They will resume operating normally when they reach the other path.
- you must use AI:AIExecute and select tank_close_1_switch_path_1, or similar.
- Unless you modify these flowgraphs (tank_close_1_switch_path_1, etc), you must name your paths like US_tank_close_1_P1 or whatever the flowgraph is using - just click edit and you will know.
- So now you will be able to command them to patrol different paths at any time during combat.
- why are my tanks crashing into trees?
- You have to add an Ai radius to your trees and then triangulate ai.
- - Select a tree (you have to be in the vegetation mode)
- - Go to the AiRadius
- - Set a value (most case it will be 0.5) where the pink circle is around the tree trunk.
Debugging
- sandhesten: The best way to debug your flow graphs is to use the debug message nodes in the HUD folder to print small ::messages on the screen when certain nodes in the flow graph have triggered.
- Add a HUD: DisplayTimedDebugMessage and type something into the Message field.
- Now try to hook the HUD: DisplayTimedDebugMessage up to different nodes in your flow graph and test your level to find out where the problem lies. Place the HUD: DisplayTimedDebugMessage node before and after important actions such as the AI:AIGoto nodes and see if the message appears or not. Repeat until you have nailed down exactly what part of the flow graph that isn't triggering.
- ai_DebugDraw 1
- ai_DebugDrawHidespotRange 50
- You will see that most of the objects in the map will have autogenerated hidespots.
- sandhesten: To be honest I don't know all the intricacies of the AI system, so what exactly makes the AI do something specific I can't answer. But try playing the level in the editor with the following console variables to see how things work:
- ai_DebugDraw 1
- ai_DrawGroup -1
- ai_DrawGroupTactic 2
- This will draw some debug information for group tactics. It should give you a nice idea of how it works.
- sys_AI [0,1] - If set to 0, disables AI updates, which in effect makes AI unresponsive to anything. Unlike the ai_IgnorePlayer setting, the difference is that the AI are not ignoring the player, ai processing has been turned off altogether.
- ai_IgnorePlayer=0 (0=off) (this is notarget)
- to get NPC/etc debug info: while in editor and in game switch to weapon #7 ("DebugGun") (press 7) (cmd=debug)
- While it is on, left clicking while aiming at an AI will display even more info.
- Aim away from the AI and left click to turn the display off.
- ag_debug=OldPier11 and ai_StatsTarget=OldPier11
- to turn debug info off:
- ai_StatsTarget=0
- ag_debug=0
- v_debugVehicle=0
Categories: AI | Lua
