Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Mystery of 36 agility

Discussion in 'Triggers & Scripts' started by ANdROnIQ, Apr 11, 2009.

  1. ANdROnIQ

    ANdROnIQ

    Joined:
    Jul 24, 2007
    Messages:
    205
    Resources:
    3
    Icons:
    1
    Maps:
    2
    Resources:
    3
    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?
     
  2. XPQJ

    XPQJ

    Joined:
    Mar 16, 2009
    Messages:
    336
    Resources:
    2
    Maps:
    2
    Resources:
    2
    can we see your trigger/script?
     
  3. ANdROnIQ

    ANdROnIQ

    Joined:
    Jul 24, 2007
    Messages:
    205
    Resources:
    3
    Icons:
    1
    Maps:
    2
    Resources:
    3
    em... it's about 500 kb... I did nothing, just this:
    Code (vJASS):
        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.
     
  4. Rui

    Rui

    Joined:
    Jan 7, 2005
    Messages:
    8,529
    Resources:
    8
    Maps:
    8
    Resources:
    8
    Maybe in the Triggers & Scripts forum you'll get help from experienced users.
    ~Thread moved
     
  5. ANdROnIQ

    ANdROnIQ

    Joined:
    Jul 24, 2007
    Messages:
    205
    Resources:
    3
    Icons:
    1
    Maps:
    2
    Resources:
    3
    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: Apr 15, 2009
  6. Shyhalu

    Shyhalu

    Joined:
    Mar 20, 2008
    Messages:
    207
    Resources:
    0
    Resources:
    0
    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.
     
  7. ANdROnIQ

    ANdROnIQ

    Joined:
    Jul 24, 2007
    Messages:
    205
    Resources:
    3
    Icons:
    1
    Maps:
    2
    Resources:
    3
    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).