|This page documents a couple AI awareness fixes in hex edit form, but these mods are now available in user-friendly ways. Installing the AE will give you the Daodan DLL in Windows or a newer build of Oni in macOS which will correct the engine's projectile awareness code, and the AE will fix the Mad Bomber particle as part of its core mods.|
A page to document fixes to the awareness system
Particles spawned with Dodge and alert radii (one without the other won't work so well), gain danger spheres, which can be seen with "ai_showprojectiles = 1". While inside the red sphere (alert), nothing really happens, except that the AI is alerted. When it inside the blue sphere, the AI will attempt to escape outside of the sphere, if the sphere was configured properly. To see if everything is working properly, turn on "ai_showpaths = 1". There should be two blue lines that project out of all AIs who are on the sphere's border or inside the sphere, toward the sphere, no matter where the AI or the sphere goes. (GIF screenshot coming soon)
Things that need to be done to avoid breaking AI danger awareness and dodging:
- Danger sphere particles should not be attached to a character, wall, or anything else.
- Danger sphere particles should not rapidly move and change direction.
- Danger sphere particles must be moving (very slow moving works).
- Danger sphere particles must have a dodge radius.
Fixing the Engine
All but the last one should be in the latest EXE.
Fixing AI Logic
Every ONCC has set of parameters which adjust how this ONCC will react on firingspread (ai2_showfiringspreads=1) and projectile dodge sphere (ai2_showprojectiles=1, it is blue sphere). Some of them are already known, some are not. Help please, user:Neo ^_^?
0x128 : General AI2 options:, those bits which interest us are:
- 0x02 - firingspread/projectile dodge enabled for melee, with weapon AI2 does NOT dodge
- 0x04 - requires 0x02 to be set; firingspread/projectile dodge enabled for weapons; if AI2 is armed, it tries to face shooter and fire back while dodging.
- 0x08 - requires 0x02 to be set, overrides 0x04 if both are set; firingspread/projectile dodge enabled for weapons; if AI2 is armed, it doesn't shoot back, just tends to run away, not facing shooter (maybe behavior for case when civillians pick up weapon?)
- 0x10 - unknown; only "advanced" classes (Konoko, Muro, Mukade, red Furies, red Elites and some more) have this bit set, I have feeling it does something with gunfire dodging, Neo help please?
Next, when bits are properly set, we can set these parameters:
|0x134||int16||0F 00||15||minimal count of frames spent in "danger" zone (firingspread/projectile) after which AI2 will start reacting on it. I can catch why it is here, but let's take into account fact that player can react on sight of armed enemy. AI2 can react only on firingspread/projectile. So in case of AE AI2, I reccomend this field to be 4x nice big ZERO ^_^|
|0x136||int16||00 00||0||maximal count of frames for AI2 to realize it is in "danger" zone; again I reccomend to set it zero.|
|0x138||float||00 00 80 3F||1.000000||dodge timer; for how long should AI2 maintain dodge vector when it was created. From what I have seen, AI2 cannot create more than ONE dodge vector. So beware with this value and set it low (but not too much low or character will not react on dodge vector). If you set it high, you will see dodge wall bug pretty often.|
|0x13C||float||00 00 80 3F||1.000000||dodge vector size; how much is AI2 forced to dodge from its original path; again be cautious, if you set it high, you will see dodge wall bug pretty often.|
|0x140||float||00 00 00 3F||0.500000||unknown; always the same|
|0x144||float||00 00 C8 41||25.000000||unknown; always the same|
|0x148||float||00 00 80 3F||1.000000||unknown|
|0x14C||int32||00 00 00 00||0||unknown, affects only AI2 with weapon; if you set it, armed AI2 tends to predict its target's movement, experiment with it and see weird results. Try setting it small value (like 14 00 00 00), then try big value (like 80 00 00 00). With small value I got something like semi-random-AI2-movement.|
|0x150||int32||05 00 00 00||5||unknown|
|0x154||int32||0F 00 00 00||15||unknown|
|0x158||int32||3C 00 00 00||60||unknown|
Rest of fileds ("unknown") can be affecting gunfire dodging, but up to this day I haven't figured how. If somebody can, I would be grateful.
Nightmare of AI2 modder: dodge wall bug
- When AI2 is trying to dodge and it collides with certain types of tiles in pathfinding grid, it tries to slide along and continue dodging. However, if vector aims directly into line of stop-dodge tiles (90°), then AI2 stops at the line and "waits" until vector disappears. Which results in stupid-looking bahavior X_X.
- Stop-dodge tiles:
- IMPASSABLE (red)
- DANGER (orange)
- DARK GREEN (stairs)
- DARK BLUE & BLUE (Border4, Border3)
How to minimize appearance of dodge wall bug : correctly set dodge timer and dodge vector size to small values, so you have high chance that when near stop-dodge tiles, AI2 will compute next vector that will point along wall, not inside wall. But even then it still happens. Anybody has source for fix ^_^ ?
Enemy awarerness and firingspread/projectile dodging:
- In order to be able to dodge, AI2 has to be in definite mode with attacker. That is state when either this AI2 sees attacker with his central vision field (see ONCC) or it was told about enemy via script(ai2_attack "attacker" "victim" for example). Definite mode lasts from last central vision field contact until hostilethreat timer (see ONCC) runs out. During this period, AI2 is given exact location of the enemy it has definite mode with as a flag where it should move.
- I don't know why it is that way, but let's accept it until Neo finds it and sees what can be done. If dodging procedure needs coordinates of some enemy in order to work, we can make workaround that it is given some default values (0,0,0 ^_^) if there are currently not any other valid values. And if it is that way that dodging is simply allowed only for "definite mode" AI2s, then we (Neo ^_^) could redirect it so it is avilable for strong awareness mode as well. Since any damage or projectile's red (alert ^_^) sphere put AI2 into "strong mode", it would be enough.
For info about awareness modes, pursuit etc. see CHAR. Maybe you will learn here something abut weird behavior you can sometimes see from AI2s ^_♦.
Fixing the Mad Bomber
Even if you have a fixed Engine and AI, characters will not avoid the Mad Bomber properly. While they may dodge, it will only be in one direction. This is because the sphere is completely static. Luckily for us, this is fixable.
You need to export the particle named "BINA3RAPmad_p04" to an XML file (back it up before making any changes).
Make sure the following lines are set properly:
<Properties> <HasVelocity>true</HasVelocity> <HasOrientation>true</HasOrientation> <HasPositionOffset>false</HasPositionOffset> <HasAttachmentMatrix>false</HasAttachmentMatrix> <HasAttractor>true</HasAttractor> </Properties>
Now change <Events /> to:
<Events> <Update> <AttractHoming> <TurnSpeed>1000</TurnSpeed> <PredictPos>0</PredictPos> <HorizOnly>0</HorizOnly> </AttractHoming> <SetVelocity> <Speed>10</Speed> <Space>1</Space> <NoSideways>0</NoSideways> </SetVelocity> </Update> </Events>
Finally, change the <Attractor> tags to read:
<Attractor> <Target>Characters</Target> <Selector>Distance</Selector> <Class /> <MaxDistance>100</MaxDistance> <MaxAngle>60</MaxAngle> <AngleSelectMin>0</AngleSelectMin> <AngleSelectMax>360</AngleSelectMax> <AngleSelectWeight>3</AngleSelectWeight> </Attractor>
Replace the old BINA3RAPmad_p04.oni with this one, recombine your level0, and enjoy your new and improved bomber.