Author Topic: 3.11-beta2.0: attack_stopped targets are different from normal attack targets  (Read 1261 times)

ctz

  • Summoner
  • **
  • Posts: 46
  • aka cathaur, formerly lyra
    • View Profile
Normal attacks basically target the closest unit with an attack skill, or if none exist, the leftmost in-range enemy unit (with no attack skill of course).  The target is chosen in the function attackableOnRange in source/glest_game/world/unit_updater.cpp.

The attack_stopped skill (hold_position, towers), however, only attacks the leftmost unit, regardless of whether it has an attack skill.  This often results in a single unit drawing fire from all towers that can fire at it, often resulting in a waste of shots.  Also, it causes tower performance to vary depending on the direction of the attack--players attacking from the left will have their ranged units attacked first by towers.

This is because the function updateAttackStopped finds its target using unitBeingAttacked, which just gives the leftmost unit.  It also has a use of attackableOnRange like the normal attack does, but only if unitBeingAttacked fails, and I don't think that branch is ever followed when there is actually anything to attack.

Thus, applying
Code: [Select]
[url=http://pastebin.com/imfv9kcK]this diff[/url] results in the same behavior for attack_stopped as normal attack.

Code: [Select]
[url=http://s000.tinyupload.com/index.php?file_id=05647447169642467245]This scenario[/url] may demonstrate the inefficiency of the leftmost-first targeting in the case of anti-air towers.  Leftmost-first targeting also means that towers with reduced range (e.g. 12 instead of 15) can be more effective than those with greater range, since they will have different targets and thus waste fewer shots.

Leftmost-first doesn't matter as much when there are only units that can't attack, since players are usually in the "destroy the helpless base" stage of the game when that happens.
« Last Edit: 3 April 2016, 16:29:38 by filux »

titi_son

  • Draco Rider
  • *****
  • Posts: 284
  • titi_son
    • View Profile
I think it may be better to fix the unitBeingAttacked thing because this is often used as hold position. And in that case it would be better to have a functional unitBeingAttacked function.
My first Tilseset: SPRING :) (included in Megaglest )

Secret Hint: To play online join the IRC #megaglest-lobby on freenode which is the lobby chat ingame. So you can chat with or wait for people in the lobby without running megaglest all the time.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
:) this will not be changed because:

What you describe is true and it can be implemented much more efficient, but thats exactly not what I want. I want to encourage people to manage their fights manually because this is an important part of having fun playing the game. The CPU generally acts dumb, but you maybe saw, that the CPU-Mega acts different and fights a bit better  ;) . This can maybe be improved in the future if people think the ultra or mega CPU plays too bad but I don't want the default fighting strategy to be better, because this would kill the advantage of manual  fight micromanagement. 
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

 

anything