• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[Trigger] Movement = Mana Loss

Status
Not open for further replies.
Level 1
Joined
Jan 23, 2015
Messages
160
Hey gang.

I'm working with the latest update editor and Bribe's movement system to try and make a trigger that will cause a unit to lose mana while it travels. This is similar to a DOTA/DOTA 2 spell called "Mana Leak" by Keeper of the Light.

Trying to use mana as "stamina" in my map so players have to rest their units. Can't get past losing just 1 mana any time they move any distance by initiating movement.

GUI user, sorry fellas. Here is what I've tried so far

  • On Move Mana Loss Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • UnitMovingEvent Equal to 1.00
    • Actions
      • Unit - Set mana of UDexUnits[UDex] to ((Mana of UDexUnits[UDex]) - 1.00)
  • On Move Copy
    • Events
      • Game - UnitMovingEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • Trigger - Run On Move Mana Loss Loop2 <gen> (checking conditions)
  • On Move Mana Loss Loop2
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit - Set mana of UDexUnits[UDex] to ((Mana of UDexUnits[UDex]) - 1.00)
  • On Stop Copy
    • Events
      • Game - UnitMovingEvent becomes Equal to 2.00
    • Conditions
    • Actions
      • Trigger - Turn off On Move Mana Loss Loop2 <gen>
Should I be using a timer or something? I really thought this would be simple to do, is there way more math involved than I'm thinking? Thanks
 
Level 6
Joined
Jan 9, 2019
Messages
102
GUI user, sorry fellas.
I'm a vJASS writer, but I still prefer using GUI. It's just about understanding how things work mate.
---

  • ManaLoss Register
    • Events
      • Game - UnitMovingEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • -------- Registers a unit that just moved --------
      • Unit Group - Add UDexUnits[UDex] to ManaLoss_Group
      • -------- Saves its current position, to be compared to its future location --------
      • Set ManaLoss_Locations[UDex] = (Position of UDexUnits[UDex])
  • ManaLoss Unregister
    • Events
      • Game - UnitMovingEvent becomes Equal to 2.00
    • Conditions
    • Actions
      • -------- Unregisters a unit when it stops moving --------
      • Unit Group - Remove UDexUnits[UDex] from ManaLoss_Group
      • -------- Removes the stored location to prevent memory leaks --------
      • Custom script: call RemoveLocation(udg_ManaLoss_Locations[udg_UDex])
  • ManaLoss
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • -------- Loops through registered units --------
      • Unit Group - Pick every unit in ManaLoss_Group and do (Actions)
        • Loop - Actions
          • -------- Gets a unit's updated location and stores it inside a variable --------
          • Set Location = (Position of (Picked unit))
          • -------- Reduces the unit's mana by (ManaLoss_Factor * DISPLACEMENT) --------
          • Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - (ManaLoss_Factor x (Distance between ManaLoss_Locations[(Custom value of (Picked unit))] and Location)))
          • -------- Removes the unit's past location --------
          • Custom script: call RemoveLocation(udg_ManaLoss_Locations[GetUnitUserData(GetFilterUnit())])
          • -------- Replaces it with the updated location, to be re-compared again with another future location --------
          • Set ManaLoss_Locations[(Custom value of (Picked unit))] = Location
Go ahead and test that. Make sure that ManaLoss_Factor doesn't have 0 initial value.
 
Last edited:
Overfrost you forgot:
set UDex = Custom value of (PickedUnit)​
as first action of the group loop inside Trigger ManaLoss.

I would suggest a lower frequency, 33.3 times a second is a bit overkill for that.
6 to 12.5 executions per second (Every 0.17s to 0.08s) should be more than enough. Although warcraft 3 per se is crazy with regeneration (200 times a second).
Edit: Frequenzy was changed from 4 to 10 -> 6 to 12.5

If you only need a fixed mana lose regardless of distance traveled and like object Editor abilities: You could add a mana lose ability on movement start (Event == 1) and on movement stop (Event == 2) you remove the ability again. Then you do not need to do any periodic action.

Suited are proably briliance aura, somewhere I read permanent immolation (but I never tested that).
create a briliance aura skill only affecting yourself (allowed targets: invul, vul, self) and set bonus to -1 or whatever you like.
When using briliance you also need to remove the buff, after removing the aura ability.​
There is also this debuff spell destroying mana over time: "mindrot" (non hero creep spell) might also be nice here (might be unsuited if your map has dispells, invuls but I am unsure about mindrots dispell mechanics right now etc.).
 
Last edited:
Level 1
Joined
Jan 23, 2015
Messages
160
Hey tried implementing this last night, got stuck at work all day today. Just wanted to ask why kind of variable ManaLoss_Locations is to bring up the[UDex] bit? I can't seem to replicate that. Thanks guys!
 
I suggested a lower frequenzy to make the trigger lighter.
Lets list how far an unit would walk in normal circumstances (no knockback, nor teleport)

0.03s
200 speed = 6 px
300 speed = 9 px
500 speed = 15 px​
0.10s
200 speed = 20 px
300 speed = 30 px
500 speed = 50 px​
0.25s
200 speed = 50 px
300 speed = 75 px
500 speed = 125 px​

Using trigo math to check for a change of 9 px upto 15 px and also 33 mana changes per second. Sure it is correct but so much cacling power into so less mana change.
Although I have to correct my suggestion. A frequenz of 4 would be to low, 75 px are significant, also could fail to detect turning and could be exploited by fastly moving and stop although that per se is stupid and let you lose time and speed.
 
Level 1
Joined
Jan 23, 2015
Messages
160
Found out that ManaLoss_Locations had to be an array for the [UDex] part. So I have this trigger exactly as you've instructed and am not seeing any mana loss upon movement, my Mana loss factor is not at zero. If you try this in a map, does it work for you?
 
Status
Not open for further replies.
Top