• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Mystery of 36 agility

Status
Not open for further replies.
Level 2
Joined
Jul 24, 2007
Messages
199
On my map, I use gamecache to save a hero in single player. Recently, when I restored a Hero saved in such way, it lost 36 attack speed and 36 movespeed. I tested everything, that's not items, not abilities, not hero skills, and my own function GetAttackSpeed returns the value that must be true, but the real test with timers shows that my hero has 64% attack speed by default instead of 100%, and that's his basic movespeed is 204 instead of 240 (1 agility on my map gives 1 attack speed and 1 movespeed). I dropped all items and locked all skills (SetPlayerAbilityAvailable) for that tests. I created that hero once again, he was ok, his attack speed was 100%. I tried to load and overwrite the save, but it didn't help. It looks like my saved hero's agility (it's value is 45) is somehow decreased by 36: I see 45 of it, but really it is 9. I even tried to change his agility by triggers, but when his visible agility was 46, the real was 10, so that's not agility. Did anyone encounter such a bug?
 
Level 2
Joined
Jul 24, 2007
Messages
199
em... it's about 500 kb... I did nothing, just this:
JASS:
    call StoreUnit(cache, name, "hero", udg_Hero[i])
...
    set hero = RestoreUnit(cache, name, "hero", plr, GetRandomReal(GetRectMinX(gg_rct_Start), GetRectMaxX(gg_rct_Start)), GetRandomReal(GetRectMinY(gg_rct_Start), GetRectMaxY(gg_rct_Start)), GetRandomDirectionDeg())
and inserted immediate return after the restore line.
Thought I need some cache viewer.
 
Level 2
Joined
Jul 24, 2007
Messages
199
Thanks for clarification.
I set an armor bonus for agility, and it showed that it is 45 of it really. (armor increased by 51=45+6 bonus agility form items, which is basically a attribute mod skill added to hero (i use custom artifact system)).
I think it's something with Endurance Aura which is one of his skills. It gives 35% movespeed and 25 attack speed. I encountered a problem that cache saved his basic HP, and when he loaded and received his passive ability that gives him more health, the bonus stacked to itself, so I made that ability-levelup trigger check whether the game is loaded.

UPDATE: The difference increased to 44 (hm, I definitely increased his level - and agility - during the test). I overcame the movespeed bug by calling SetUnitMoveSpeed(hero, 240+GetHeroAgi(hero, true)) after loading and before the items abilities affect the hero (240 is default ms for all heroes on my map, and if it will change, i could write GetUnitDefaultMoveSpeed anyway), but how can I change attack speed?
 
Last edited:
Level 6
Joined
Mar 20, 2008
Messages
208
Endurance aura would be the problem. You need to get his state without the bonuses.

I do believe theres a boolean input for that
Here it is:

GetHeroAgi takes unit whichHero, boolean includeBonuses returns integer
GetHeroInt takes unit whichHero, boolean includeBonuses returns integer
GetHeroStr takes unit whichHero, boolean includeBonuses returns integer

The problem would be within the code used to save the hero. Its saving too much. You just need to save the basic stats listed (Level too of course) above and return them as they were. The bonuses from those stats will return the hero to his prior attackspeed, max health, etc.

What the inner code is doing would be taking the actual game data....rather than letting the stats do the calculating.

IE: Your attack speed is 5, agility is 30, and endurance aura gives 10%. Lets say the agility bonus is 5, from 30. Thats 10 + 1, which makes 11.

The inner code is saving 11, it just needs to save the 30 agility.
 
Level 2
Joined
Jul 24, 2007
Messages
199
Thank you, now I should make a list of everything that must be copied from the original hero... I thought of this solution but was too lazy to do this.

EDIT: but I have to store hero skill ids somewhere. Is there a way to get a list of hero skill ids form a hero or its unit type id? Moreover, I use skills like tech upgrade, so I have to keep some order of skill levelup (first increase basic skill, then tech upgrade, or first tech upgrade, then the skill which it changes the basic to).
 
Status
Not open for further replies.
Top