Page 6 of 6 FirstFirst ... 4 5 6
Results 51 to 57 of 57

Thread: SUMMARY OF ISSUES

  1. #51
    Basic Member
    Join Date
    Sep 2017
    Posts
    56
    That's not what I mean with atanim. And yes I understand how the attack point and backswing works, I've been canceling it since 2009 :P.
    'Atanim' here just a name I gave to the base duration in seconds that the entire attack animation takes. This is not the same across heroes. It's always a part of the BAT, but generally not the full BAT. BAT cycles have three parts, the attack animation, the backswing animation and a rest period. No animation plays in the rest period and heroes will be able to move during this rest period without requiring a stop command (but they cannot start a new attack cycle until the rest period is over). Both the BAT and the 'Atanim' value here are base values, with a second corresponding actual value after adjustment for attack speed. The corresponding value for the BAT is just the seconds per attack, the corresponding value for Atanim is the time in seconds it takes to get to the rest period.
    GetAnimcycle returns a value between 0 and 1, this is proportional to the duration of the animation. And yes, this is always between 0 and 1. But it's not the same as the value I called 'Atanim' here. If you look at the table here https://dota2.gamepedia.com/Attack_animation you'll see that there's many heroes for which attack point + attack backswing > 1.

    The awkwardness here is because GetAnimCycle returns something from 0 to 1 regardless of the duration, while basically all other available data on attacking is in terms of time.

  2. #52
    Basic Member
    Join Date
    Sep 2017
    Posts
    56
    Ok, I've got an updated formula for swing time calculation. This seems both highly accurate and it makes sense

    swingtimeremaining = ( ( unit:GetAttackPoint() / magicnr) - unit:GetAnimCycle() ) / (unit:GetAttackSpeed() / magicnr )) + 0.0333;

    or if the unit isn't already attacking (because animcycle can report on idle/running/casting animations):

    swingtimeremaining = ( unit:GetAttackPoint() / unit:GetAttackSpeed() ) + 0.0333;

    Magicnr here is unique per unit and remains constant throughout the game, and almost certainly represents the duration of the attack animation, magicnr = attack point + the backswing. However, the data found here https://dota2.gamepedia.com/Attack_animation seems to be the dota 1 values and is incorrect on many units. You can use it as a starting base though.
    Unfortunately, it seems some heroes actually have 2 different Magicnrs, so it isn't perfect. I'm guessing this is just because of two different attack animations with different durations. I haven't found a way to predict which of the two it is.

    To calculate the magicnr manually -which needs to be done for every unit- you can do this:
    magicnr = 1 / ( ( deltaAnimCycle / deltaTime) / unit:GetAttackSpeed())

    Theoretically you could just use this as part of the calculation to be able to handle all animations for all units, though be careful, since deltaAnimCycle obviously requires at least 2 frames of the attack animation, so you won't be able to use that before starting a swing, nor on its first frame.
    Last edited by Siesta Guru; 11-10-2017 at 05:53 AM.

  3. #53
    Basic Member
    Join Date
    Mar 2012
    Posts
    2,019
    Are you saying the difference between animation cycles is different than the delta between frames?

    Normally, the difference between frames should be RealTime() - LastRealTime (where LastRealTime is the cached value). It shouldn't be. A smooth animation should update by the frame deltatime. What is your deltaTime calculus?
    Explanations on the normal, high and very high brackets in replays: here, here & here
    Why maphacks won't work in D2: here

  4. #54
    Basic Member
    Join Date
    Sep 2017
    Posts
    56
    Every animation runs from 0 to 1. Getanimcycle always returns a value between 0 to 1. Since some animations are shorter than one second, and some are longer, the deltaAnimationCycle is not the same as deltaTime. If an animation takes 2 seconds, and half of it is complete, GetAnimcycle now returns 0.5 it doesn't return 1, even though that's the elapsed time since the animation started.
    My deltatime is just GameTime() - LastGameTime or Dotatime() - LastDotaTime. I'm not using RealTime here since it can change in the middle of a bots 'turn', while GetAnimCycle can't.

  5. #55
    Basic Member
    Join Date
    Mar 2012
    Posts
    2,019
    Ah, didn't think of short animations
    Good point with those.
    Explanations on the normal, high and very high brackets in replays: here, here & here
    Why maphacks won't work in D2: here

  6. #56
    Basic Member
    Join Date
    Dec 2016
    Posts
    732
    Do you guys have code you are willing to share for calculating the time_to_turn give that our hero is facing some direction and wants to face some vectorLocation?

  7. #57
    Basic Member
    Join Date
    Dec 2016
    Posts
    732
    Nevermind, worked it out I think, this Python code should do it (assume my two locations are proper Location objects with x,y,z members). GetTurnRate provides the float turn rate of the hero from the npc_heroes.txt.

    NOTE: the code below does not account for buffs/debuffs to turn speed (like Batrider's Sticky Napalm) affecting it (yet...)
    Code:
        def get_location(self):
            return loc.Location.build(self.udata.location)
        
        def time_to_face_location(self, location):
            loc_delta = loc.Location.build(location) - self.get_location()
            desired_facing = math.degrees(math.atan2(loc_delta.y, loc_delta.x))
            current_facing = self.udata.facing
            # we want a facing differential between 180 and -180 degrees
            # since we will always turn in the direction of smaller angle,
            # never more than a 180 degree turn
            facing_delta = math.fabs(desired_facing - current_facing - 180.0)
            return facing_delta/math.degrees(getTurnRate(self.hero_id))

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •