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

damage dealing technical logical problem

Discussion in 'World Editor Help Zone' started by best_player_88, Sep 10, 2020.

  1. best_player_88

    best_player_88

    Joined:
    Dec 19, 2007
    Messages:
    1,180
    Resources:
    2
    Maps:
    2
    Resources:
    2
    I tried to create a map that does extra damage whenever a hero is attacking
    But there is a technical logical error - that does not cause a game crash and does work, but is laggy because of the technicalities


    Trigger = Unit is being damaged
    Action =
    Deal damage using a dummy unit to that unit based on the damaging unit's intelligance.
    now do other actions


    Problem:
    Damage is dealt => damage is then dealt by dummy unit => that active the same trigger a second time before finishing the first trigger

    This is not a loop, but it is technically a massive error since I am forcing the same trigger (damage is being dealt) to work twice midway of activation. There is a noticable lag and it might cause the gpu to run harder because of the technical "loop" Ive been thinking about it for a week now but I don't know how to avoid it.

    Has anyone ever done something like this in the past? I mean, the extra damage must come from some ability or come as a raw damage bonus to avoid this kind of error am I wrong?
     
  2. Whitewolf8

    Whitewolf8

    Joined:
    Aug 31, 2011
    Messages:
    289
    Resources:
    6
    Models:
    1
    Maps:
    4
    Tutorials:
    1
    Resources:
    6
    Turning the trigger off before it actually runs, then turning it back on after it finishes should fix it I think.
     
  3. DoomBlade

    DoomBlade

    Joined:
    Feb 5, 2018
    Messages:
    264
    Resources:
    0
    Resources:
    0
    Events - Whatever
    Conditions - Whatever
    Actions

    Trigger (turn off this trigger)
    --do actions--
    Trigger (turn on this trigger)

    EDIT: This is needed to avoid infinite loops :)
     
  4. HerlySQR

    HerlySQR

    Joined:
    Jun 26, 2020
    Messages:
    551
    Resources:
    0
    Resources:
    0
    Or you can make the trigger only works for certain type of units or not work for the dummy.
     
  5. best_player_88

    best_player_88

    Joined:
    Dec 19, 2007
    Messages:
    1,180
    Resources:
    2
    Maps:
    2
    Resources:
    2
    Technically still a logical error since you ask something from the trigger midway execution
    Amazing way to solve it

    My way to solve it was = I replaced the damage with actual hp removal and made a hashtable to each unit with "last owner of damager unit" then when the unit is dead and the killing unit is no unit , the actual last damager is getting rawarded.

    Yours was way better tho xD
     
  6. HerlySQR

    HerlySQR

    Joined:
    Jun 26, 2020
    Messages:
    551
    Resources:
    0
    Resources:
    0
    Triggers don't execute two times at the same time, if it runs again it would take it as a separate action, thats the reason why exists local variables.
    But, anyway, I think is better the trigger doesn't run to run and check (less actions), but it will be difficult determine the exact time to turn on the trigger again.

    Edit: Nah, Its a better solution, you don't need to add a wait.
     
    Last edited: Sep 11, 2020