• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Moving drains Mana

Status
Not open for further replies.
Level 5
Joined
Dec 11, 2010
Messages
101
Hello, I've been working on a small project of mine, and i should first off say i'm not too great with triggers. It has to do with turn-based combat and there are multiple units on both teams, but I may need a little help getting started on this trigger.

What i'm looking for this trigger to do, is that for example

Unit 1 has 200 mana total. When Unit 1 is moving or attacking, he loses mana based on how much he has walked or attacked.

Example,
Moving 50 distance = 1 mana drain.
Attacking = 40 mana drain per attack.

Sorry if i didnt explain very well, I can elaborate more if needed

Thanks!
 
For the moving reduction.

Use a periodic trigger. Every 0.03 seconds should be close enough.
Use a point variable to store last location.
Use a real variable to store the amount moved.

Now for actions check unit a new location and see if it is the same as the location you have saved in the variable.
If it is not the same then the unit has moved.
So check how much the unit moved by using
  • Set realVaraible = (realVariable + distance from locationOld to locationNew)
Then remove the old loaction to clean leaks and then
  • Set locationOld = locationNew
Then use another ITE to check if the realVariable is greater than 50
If it is then you need to reduce mana by that amount and then reduce realVariable by the amount taken off. Example realVariable = 120. You need to reduce 2 mana. So to find the amount to reduce you do.
  • Set modulus = (realVariable Mod 50)
  • Set manaToReduce = (realVariable - modulus ) / 50
  • Set realVariable = modulus
Then set the units mana to unit mana - manaToReduce


For the attacking reduction.

Use a unit is attacked trigger.
Get the attacking unit and set their mana to mana - 40
 
You can use this system to check if unit starts moving, stops moving or is moving. When a unit starts moving, you can add them to a group. In the "is unit moving" trigger, you should pick every unit in the group and reduce their mana. Remove the unit from the group when the unit stops moving. Instructions on how to use the system is given in the system
 
Status
Not open for further replies.
Top