mana cause hit point reduced

Status
Not open for further replies.

+swi_gen#noz+

Level 1
I had been making a map that some survivor need to survive in a snowing forest. Mana = heat. And when mana = 0 , then hit point will be reduce.
How to make the commend like : when mana =0 ,then reduce hit point.
I had try a lot of way , but still can't do it.
Is there anyone know how to do ?

MasterBlaster

Level 20
Use this along with a periodic event, don't forget to set <UnitVariable> to match your "survivor" unit:

• Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions) -- If/Then/Else, Multiple Functions action
• If - Conditions
• (Mana of <UnitVariable>) Equal to 0.00 -- Real Comparison condition; Unit - Property function to get mana/life of a unit
• Then - Actions
• Unit - Set life of <UnitVariable> to ((Life of <UnitVariable>) - <Amount>) -- Unit - Set Life (To Value) action, use Arithmetic function for math
• Else - Actions

Last edited:

+swi_gen#noz+

Level 1
I had done the trigger but lo
Use this along with a periodic event, don't forget to set <UnitVariable> to match your "survivor" unit:

• Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions) -- If/Then/Else, Multiple Functions action
• If - Conditions
• (Mana of <UnitVariable>) Equal to 0.00 -- Real Comparison condition; Unit - Property function to get mana/life of a unit
• Then - Actions
• Unit - Set life of <UnitVariable> to ((Life of <UnitVariable>) - <Amount>) -- Unit - Set Life (To Value) action, use Arithmetic function for math
• Else - Actions
I had done the trigger ,but it doesn't work at all ??

Last edited:

Uncle

Warcraft Moderator
Level 62
The Event you used only happens WHEN the unit's mana drops below 1.00. In other words it's not really a continuous effect like you think it is.
The wording of the Event makes this clear -> "unit's mana BECOMES Less than...".
The unit's mana would only BECOME less than 1.00 once in a while since the unit would go from let's say 1 mana to 0 mana.
After that the mana is already less than 1.00 so it can't BECOME less than 1.00 again.

However, the Event can happen again if the unit manages to go above 1.00 mana and then drop down below it again.
Although I doubt this is how it'd work in your map, I assume once the unit's mana reaches 0 it stays that way for a while.

Note that all of the Events trigger "When" and not "While", it's important to understand these two concepts.
Examples of When: When a unit dies, When a unit gains a level, When a unit enters a Region, When a Timer expires.

If you want a While effect, which means you want the Actions to repeat WHILE something is true/false, you need to use Periodic Intervals or Timers and then use Conditions to confirm whether or not the the thing is happening -> Your unit's Mana is Equal to 0.00.

• Events:
• Time - Every 1.00 second of game time
• Conditions:
• Mana of (survivor 0005 <gen>) is Equal to 0.00
• Actions:
• Subtract life, etc.
^ Adding the rest of your Actions to this would subtract 15.00 life from the survivor every 1.00 second as long as their Mana is Equal to 0.00.

Also, what's with the red crossed out names? It's hard to tell if you made other mistakes with those.

Last edited:

MasterBlaster

Level 20
What @Uncle said, though I'd like to add one thing - be mindful of mana regeneration.

The condition above requires the target to be at exactly 0.00 mana. If you're going to check for it every second and the target has any mana regeneration, you'll have a hard time hitting the condition requirement, because the target will regenerate some mana in the meantime.

This is because mana regeneration happens in small time intervals, i.e.if a unit has 5 mana per second regeneration rate, that doesn't mean that it will gain exactly 5 mana once every second. Quite the opposite, in fact - it will recover a little bit of mana every fraction (not sure how small) of a second, which will add up to 5 mana regenerated over a full second. In other words, the unit will have 0.5 mana after 0.1 seconds, 1.0 mana after 0.2 seconds and so on.

If even one of these regeneration ticks happens between the target's mana being reduced to 0.00 and checking the condition, the unit will be above 0.00 mana and thus it will not meet the condition. One more thing to note here, the UI only displays full mana points that a unit has, so if a unit has, say, 0.67 mana, the UI will still display that as the unit having 0 mana. Only when the unit has at least 1.00 mana will it display as having 1 mana.

This will create a dissonance between what the player feels should be happening, i.e. "the unit has 0 mana, it should be taking damage" and what actually happens, i.e. "the unit has 1 > mana > 0, so the condition isn't passed and it doesn't take damage".

---

The easiest way to counter both of these issues is to simply remove any mana regeneration from the target unit and restore mana via triggers. That way you can control how much mana and in what time intervals your unit will regenerate. Alternatively, you could also try changing the condition to "less than 1.00 mana", so that it's based on the mana value displayed to the user, rather than the actual amount of mana the unit has.

Another option is to go for a simple system that deals damage proportionally to the amount of missing mana. In other words, if your unit is meant to lose 10 mana or 20 life per second, but only has 5 mana - 5 mana is 50% of the intended penalty, the othe 50% will be covered by losing life, i.e. the unit will lose all of its remaining mana (5 points) and 0.5 * base_life_penalty, i.e. 0.5 * 20 = 10 life. Here's how to do this:

• Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (Mana of Target_Unit) Greater than or equal to Mana_Penalty -- first you check if the target has enough mana to "pay" the penalty
• Then - Actions
• Unit - Set mana of Target_Unit to ((Mana of Target_Unit) - Mana_Penalty) -- if it has, then you simply reduce it's mana by the intended amount
• Else - Actions
• Set Life_Penalty_Value = (((Mana_Penalty - (Mana of Target_Unit)) / Mana_Penalty) x Life_Penalty_Base) -- use this equation to calculate how much life needs to be deducted
• Unit - Set life of Target_Unit to ((Life of Target_Unit) - Life_Penalty_Value) -- Reduce the target's life by the calculated amount
• Unit - Set mana of Target_Unit to 0.00 -- set the target's mana to 0, because all mana the target had was removed by the penalty
Let's do some numbers, just to be sure. You want the target to lose 10 mana or 20 life and the target has 9 mana remaining, so:

Mana_Penalty = 10.0 ; Life_Penalty_Base = 20.0 ; Mana of Target_Unit = 9.0
Life_Penalty_Value = (10.0-9.0)/10.0 * 20.0 = 1.0/10.0 * 20.0 = 0.1 * 20.0 = 2.0

Thus, the target will go from 9.0 mana to 0.0 mana and also lose 2.0 life to compensate for the fact that it didn't have enough mana.

The main advantage of that last option is that it's the most fluid way of transitioning between losing mana and health, which allows you to completely ignore any mana regeration issues as the system is built to account for them. It should also be pretty easy to explain to the user, e.g. "while outside, the unit loses 10 mana every second. If the unit doesn't have enough mana, it will take up to 20 damage per second".

Ultimately though, it's your choice how you choose to handle this Good luck!

Last edited:
Status
Not open for further replies.

Replies
5
Views
863
Replies
10
Views
597
Replies
9
Views
2K
Replies
1
Views
1K
Replies
7
Views
1K