1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Trigger] Trigger adding too much movement speed?

Discussion in 'Triggers & Scripts' started by Gratian, Nov 9, 2019.

  1. Gratian

    Gratian

    Joined:
    Nov 9, 2019
    Messages:
    3
    Resources:
    0
    Resources:
    0
    Hey guys,

    I need some help solving this, the idea is that when a Unit wearing a specific kind of boots enters a region, the effect of the Bonus Speed will be doubled. So the boots add 40, but when in [Region], they will add 80.

    The trigger looks like this, and currently it's working as intended, but the values are all wrong. In other words, when my hero enters the region AND is wearing the boots, he gains movement speed. When he leaves, he loses some. Except, the values are all wrong. It's not adding 40 like I intend, but 60 for some reason, and when he leaves, it's not removing anything, it's just staying the same.

    The way I did this was to create a global variable (call it Real.Movespeed) with initial value of 40, and then when entering region ++ wearing [boots], set myUnit Movement Speed to myUnit.CurrentMovementSpeed + Real.Movespeed. When leaving region ++ wearing boots, set myUnit Movement Speed to myUnit.CurrentMovementSpeed - Real.Movespeed.

    I created a quick trigger to return the Movespeed values, and here's what they are:

    Default: 270
    With Boots: 310
    With Boots in region (should be 350): 390
    With Boots off region (should be 310 again): 390 still

    Entering the Region again just keeps adding 80 movement speed every time. I don't understand why, it's supposed to just add 40.
     
  2. Cespie

    Cespie

    Joined:
    May 21, 2019
    Messages:
    350
    Resources:
    0
    Resources:
    0
    It'd be nice if you posted the triggers.
    It kinda seems like the adding movement speed trigger fires its event twice instead of once.
    Why the movement speed subtraction doesn't work. No clue. Again, I'd love to see the actual triggers.

    By the way, I just wanted to point out, that even if these triggers were "fixed", it'd still be quite easy to abuse this system by entering the area wearing the boots, unequip them, and then leaving.

    Here's a much easier approach.
    You make a hashtable, and every time a unit picks up the item, you store their movement speed in the hashtable, using the unit as a key.
    Whenever a unit enters the region holding the item, you set their movement speed to the hashtable value + 40.
    Whenever a unit exits the region, you set their movement speed to the hashtable value.
    Whenever a unit drops the item, you set their movement speed to the hashtable value.

    Voila, abuse-free system that doesn't bug out.
    Be aware that the movement speed stat on the boots may have some weird interactions. If you can't make it get the right values, you may want to just do the whole movement speed bonus in triggers instead, and then add an extra 40 movement speed to the above "set movement speed" values, and add an event when the item is picked up, which ads 40 movement speed.
     
  3. Gratian

    Gratian

    Joined:
    Nov 9, 2019
    Messages:
    3
    Resources:
    0
    Resources:
    0
    Hey Cespie, thanks so much for your response.

    I actually ended up fixing the problem by creating a 7% Endurance Aura Item Ability, then adding the ability to the Item once a unit enters the area and wears the boots. Then I created a "Global Drop Protection" Trigger that fires whenever <A Unit Loses an Item>, conditional to the <Manipulated Item> being equal to <The Boots>, which then has the function of "<Remove EnduranceAuraAbility from Boots>, immediately removing the buff from the item, so you can't really abuse the system- I tried breaking it, but couldn't.

    So I used to be a modder way back in the day in 2004-2007, but was much younger back then. I'm getting back into it now with Reforged, and would like to know what the generally acceptable format is for posting Triggers in here. In other words, how do I post triggers for people to see them properly? Stupid question, but this platform has really not aged well, with the utmost respect.
     
  4. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,056
    Resources:
    1
    Spells:
    1
    Resources:
    1
    How To Post Your Trigger
     
  5. Gratian

    Gratian

    Joined:
    Nov 9, 2019
    Messages:
    3
    Resources:
    0
    Resources:
    0