Author Topic: Why is the rate of fire is determined by anim-speed, not speed?  (Read 1689 times)

ctz

  • Summoner
  • **
  • Posts: 46
  • aka cathaur, formerly lyra
    • View Profile
In the xml for units, there are lines like this:

From tech's battle_machine.xml:
Code: [Select]
                <skill>
                        <type value="attack"/>
                        <name value="attack_arrow_skill"/>             
                        <ep-cost value="0"/>
                        <speed value="52"/>
                        <anim-speed value="65"/>
[...]

In the game, the "attack speed" displayed when one hovers the cursor over the attack icon is the speed value.  One would expect that this is the rate of fire--normally it is, and the units are centishots per second (also, I recommend changing the game text to "attack rate" or something like that, since "attack speed" could also be interpreted as how fast the shots move).  For most combat units, speed and anim-speed for attacking are the same, but for some, like the Battle Machine's attack arrow, they differ.

The actual rate of fire is not controlled by speed as one would expect, but by anim-speed.  To confirm this, change anim-speed to something very different without changing speed.  Or change speed without changing anim-speed.  Notice that changing speed doesn't do anything but change the displayed attack speed, but changing anim-speed has an effect on the rate of fire.

I suppose fixing this will likely affect game balance.  The Indian Thunderbird, for example, has for its ground attack
Code: [Select]
                        <speed value="40"/>
                        <anim-speed value="70"/>
Fixing this would result in a rate of fire reduction by a factor of 1.75.  Of course, I expect that attack speed 40 was the intended speed in the beginning, especially when the stats are compared with Magic's Dragon.



Edit (tomreyn): No [bug] tag, please, this forum is already called "bug reports". Thanks.
« Last Edit: 7 February 2013, 21:57:57 by tomreyn »

Coldfusionstorm

  • Golem
  • ******
  • Posts: 868
    • View Profile
Re: 3.7.1: rate of fire is determined by anim-speed, not speed
« Reply #1 on: 8 February 2013, 19:30:20 »
This is true, this is something i also found out a long time ago, and it's quite annoying.(not to mention counter intuitive).
WiP Game developer.
I do danish translations.
"i break stuff"

Manric

  • Guest
Re: 3.7.1: rate of fire is determined by anim-speed, not speed
« Reply #2 on: 9 February 2013, 16:17:39 »
Quite true, but that does not mean that the attack speed is meaningless. Apparently, it is used in a formula to determine the time length of the attack. If its value is set lower than the animation speed, the unit keeps attacking after the enemy is dead. Carried to the extreme, with an attack speed of zero, the enemy dies just as quickly, but the unit goes on and on with its attack, forever, I would think: (I quitted after a few minutes). So the right proposition seems to be setting both speeds the same, or, in any case, the animation just a little lower.

Now then, it is arguable that this is a proper bug. It may be a feature of the game intended from start, surely not documented, but, once it is well known, it should not be a cause of problems any more.

ctz

  • Summoner
  • **
  • Posts: 46
  • aka cathaur, formerly lyra
    • View Profile
Re: 3.7.1: rate of fire is determined by anim-speed, not speed
« Reply #3 on: 9 February 2013, 18:09:27 »
speed affects the rate of EP usage; I tried it with an archmage.  With speed 30, the archmage spent EP slower than its rate of fire; with speed 0, the archmage spent no EP after the initial 300.  It also affects how long the unit continues to attack after its target is dead.  If the rate of fire was determined by speed instead of anim-speed, I think this would mean that the unit would fire at most once at a dead target before quitting.  I am guessing that each unit has a check for "is my target dead" only once every attack cycle (as determined by attack speed), and continuing to attack after the target is dead is unintended behavior.  Also, you might notice that other units like catapults will also attack dead targets for a short time; I think this has to do with attack-start-time offsetting the time of the attack cycle.  I suppose it is acceptable to attack at most once after the target is dead, justified by something like the catapult-operator thinking, "my catapult was in the middle of firing; I can't stop it once it starts because I'll get hurt."

I don't think it was intended that attack speed be controlled by anim-speed, considering the listed attack speed in the game is the speed value, and EP usage rate is controlled by speed.

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: 3.7.1: rate of fire is determined by anim-speed, not speed
« Reply #4 on: 9 February 2013, 19:54:14 »
I had a detailed post regarding anim speed versus speed in the past, but I can't find it now. At any rate, I don't think this is a bug, just a bit unintuitive. It does have uses, though. It's possible to make units attack twice in one skill cycle, etc.

Some possibly useful (if a bit vague) excerpts from the wiki:

Note that the anim-speed should generally be a lower number than the speed, otherwise the skill cycle will be repeated multiple times for a single animation.

The speed that skill cycles at. Higher numbers make the skill go faster. The time it takes to perform a standard skill cycle can be found via the skill cycle formula.

The speed specified in the skill denotes how long it will take, in world frames, to do the full skill. By default, the world frames run at a constant 40 frames per second on the regular speed, but can be increased in game by making the game speed faster or slower (default hotkeys: + and -). The following formula is used to figure out the time to do a skill cycle:

« Last Edit: 18 June 2016, 14:01:40 by filux »
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

ctz

  • Summoner
  • **
  • Posts: 46
  • aka cathaur, formerly lyra
    • View Profile
Re: 3.7.1: rate of fire is determined by anim-speed, not speed
« Reply #5 on: 9 February 2013, 20:50:23 »
If it's not a bug and attack rate is supposed to be based on anim-speed, then the attack speed listed in the game should at least show the anim-speed value.

I would think that anim-speed should only control the speed of animation however, to make it possible to have, say, multiple attacks per animation cycle (possibly useful for a rapid attack if you still want a relatively slow animation, e.g. flapping wings).

Why would it be useful to attack twice per skill cycle, vs. just having two skill cycles in the same time?

MoLAoS

  • Ornithopter
  • *****
  • Posts: 433
    • View Profile
Re: 3.7.1: rate of fire is determined by anim-speed, not speed
« Reply #6 on: 9 February 2013, 22:02:57 »
When I was writing the new AI code for my game I noticed that a unit would repeatedly attack a tile even if nothing was there. It had something to do with how the targeting functions worked. I eventually fixed it. But the reason why something weird is happening isn't always intuitively obvious.

Not that damage is dealt whenever a projectile hits the target iirc, that is why arrows that miss the target don't deal damage and the same for other stuff like mage attacks and splash stuff and that attacks do not track after the initial position is calculated.

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: 3.7.1: rate of fire is determined by anim-speed, not speed
« Reply #7 on: 10 February 2013, 02:00:27 »
If it's not a bug and attack rate is supposed to be based on anim-speed, then the attack speed listed in the game should at least show the anim-speed value.
Perhaps, but I worry that would be too complex. It is indeed the attack speed (well, skill speed in general) that actually matters, though. The animation speed basically could allow the unit to perform what is recognized as multiple actions with a single action *cycle*, which is what is (supposed to) really matter.

Why would it be useful to attack twice per skill cycle, vs. just having two skill cycles in the same time?
Well, you could have a machine gun skill where five attacks are executed for the cost of 1 EP. It's not normally possible to use fractions of EP, but this would technically trick the engine into that. It's rather messy, as the attack wouldn't end when the target died, but rather when the skill cycle completed.

The main issue is that it'd be very difficult to make a backwards compatible change to our current behaviour.
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

Ishmaru

  • Behemoth
  • *******
  • Posts: 1,071
  • um wat??
    • View Profile
    • DelphaDesign
Re: 3.7.1: rate of fire is determined by anim-speed, not speed
« Reply #8 on: 10 February 2013, 04:11:10 »
Well, you could have a machine gun skill where five attacks are executed for the cost of 1 EP. It's not normally possible to use fractions of EP, but this would technically trick the engine into that. It's rather messy, as the attack wouldn't end when the target died, but rather when the skill cycle completed.

Annex has quite a few units that use this effectively, MRLS, Pod Rockets, WASPs, Harriers, and Gunships' rocket skill. While the units will continue to to fire till the end of the cycle I have not found found it anymore problematic than any standard 1 attack per cycle ranged unit. Anyways please don't remove this feature as removing such a feature will be devastating to the Annex project.
Annex: Conquer the World Release 4 For Pc Mac + Linux
https://forum.megaglest.org/index.php?topic=9570.0
Annex is now on Facebook!
https://www.facebook.com/AnnexConquer