• 🏆 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!

[Trigger] Trigger adding too much movement speed?

Status
Not open for further replies.
Level 1
Joined
Nov 9, 2019
Messages
3
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.
 
Level 8
Joined
May 21, 2019
Messages
435
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.
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.
 
Level 1
Joined
Nov 9, 2019
Messages
3
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.

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.
 
Status
Not open for further replies.
Top