Jump to content

3 detailed facts about unit attack behaviour


stevenlau
 Share

Recommended Posts

While developing stevenlauBot, I read a whole lot of 0AD source code.  I got a closer look on the behaviour of attacks, which isn't available in user guides / manuals.  Advanced players might find this useful.

Dodge CC arrows with 5 cps

Consider the simple case in which some enemy units are constantly running under a defensive building.  The building is angry, and would shoot all arrows evenly in the first quarter of repeat time, i.e. 4s / 4 = 1s for CC.  During that 1s, the arrows are shot evenly in 5 batches.  As a result, to dodge under CC, you do 5 clicks per second, then you have 3s of free time.  For stone tower the repeat time is shorter, so you have to click a little bit faster.  In addition, the arrows are shot to the same target until it dies, so you only need to dodge one unit, which is by default the closest one.

Reference:

https://gitea.wildfiregames.com/0ad/0ad/src/branch/main/binaries/data/mods/public/simulation/components/BuildingAI.js#L292

Snipe a formation by enclosing them

When attacking an enemy formation, you can't choose to snipe an arbitrary formation member.  The member closest to your unit will always be attacked.  You could theoretically surround the enemy formation with snipers, so each sniper will see different "closest member", and achieve certain extent of sniping.  To attack you just have to right-click the whole formation and the closest member will be chosen automatically.

Reference:

https://gitea.wildfiregames.com/0ad/0ad/src/branch/main/binaries/data/mods/public/simulation/components/UnitAI.js#L5407

Shoot farther on turret or mountain

Suppose the maximum attack range of a unit (CC, archer, jav etc) is said to be 60m.  The actual maximum distance is different when the unit is on mountain or turret.  It is calculated using the formula: actual_max_distance = sqrt(max_distance^2 + height * max_distance * 2).  While this formula produces plausible numbers, I don't think it is physically realistic.  It is parabolic but it doesn't represent an actual projectile curve.  Anyway, what it means is, if you stand higher, you shoot farther (with larger spread though; and spread considers horizontal distance only).  If you stand so low, like 30m below enemy, then you can't shoot them at all.  The max height (30m) is half the max distance (60m), which is arbitrarily fixed by the 0AD team.

All units and buildings are considered equally on ground level (0m) except that outpost is 8m, sentry tower 9m, stone tower 15m, and Han great tower 20m.  So stone tower actually shoots as far as sqrt(60^2 + 15 * 60 * 2) =  73.48m.  An archer turreted on wall (roughly 10m tall, different with civs) will shoot at sqrt(60^2 + 10 * 60 * 2) = 69.28m.  What about fortress?  Although we see fortress shoots arrows at a height, it is still considered to be on ground level (0m), so the max distance is still 60m.  This might have to be fixed.

Reference:

https://gitea.wildfiregames.com/0ad/0ad/src/branch/main/source/simulation2/components/CCmpRangeManager.cpp#L1387

 

Edited by stevenlau
  • Like 2
Link to comment
Share on other sites

  • stevenlau changed the title to 3 detailed facts about unit attack behaviour

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...