• 🏆 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!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[Trigger] Help with system to prevent life/mana going below 1.

Status
Not open for further replies.
Level 2
Joined
Apr 5, 2009
Messages
18
I've been thinking on how to achieve a system like this but all ive been able to come up with is a trigger to deal 1 damage per every 0.01 seconds of game time and then another trigger to detect if the life has reached 1 or below.
The most obvious problem is that it wouldn't work with damage upwards of 100 and possibly contains many other errors/leaks >__<

[Edit]:Mana drain would probably use a similar solution. I think. ><

Anyway, pl0x halp. :thumbs_up:

 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I don't really get it...
You have a DPS-system that deals 1 damage every 0.01 sec and you have a trigger that checks when the life of the unit is 1 or higer, then what is the problem?
If you want it to work with 100+ damage, then just check when the unit has 100+ HP ><
(Maybe set a variable for the damage dealt and check if the unit has more HP than that variable?)

I probably just don't get it... :p
could you show me the trigger (with hidden-tags, please) and explain it a little bit more? :cute:
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,233
Use the event that fires whenever a unit takes damage, set its HP to max then run a timer which will expire in 0.00 seconds. As part of that timer's executed functions, set the units HP to 1. If damage is often larger than unit HP, add a huge life item ability for the timer duration to make sure that its HP will not fall bellow 0 and die. Ofcourse this may not be exactly what you want but it should be close enough for you to modify it to suit your needs.

You can see this method in action in my Spell Pack 1 in the spells section (needs 1.23b+) which uses the new hashtables. It has a damage shield system which prevents HP loss from damage by using a trigger based shield to abosrb it in a hopefully leakless and efficent way. It works even if the unit is inflicted with 1000s of damage at 1 HP, as long as the shield can absorb that ammount.

I have no idea how you can do such a thing for mana, however it is obviously a hell of a lot more simple as the unit does not die when its mana reaches 0 but does if its life drops below 0.405. The unit mana drops below a certain value event may be the solution however I need to conduct tests on it inorder to tell you exactly what it is capable of.

A more clear description of your problem may help people come up with solutions.
 
Level 2
Joined
Apr 5, 2009
Messages
18
@ap0calypse: I didn't actually make those triggers, i meant theoretically thats how i thought of doing it.

@Dr Super Good: I see. But a shield effect wasn't what i was aiming for... thanks for the reply though.

To clarify, i want a system prevent your hp from dropping below 1 hp, when 1hp is reached by taking damage from whatever source, be it spell damage, attacks, etc. It's to go along with my DOT spell which i posted about in a thread in this forum (should be on page 2 at the top 'Help with my Loop').

 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Allright, thanks for explaining that.

This is just an idea, I don't know if it will work, or if it is what you need.

If it is for the DOT-trigger (it's an ability, so it's easier to add I think...):
In the trigger where the ability activates, set a real variable to the damage that needs to be dealt over time.

You probably have a DOT-trigger, the trigger that deals the actual damage, you need to add 1 if/then/else construction in it: if the variable is greater than or equal to the HP of the targetted unit, then set the life to 1 and skip the remaining actions.


If you really want that the unit can take no damage from any source if it would kill him:

Create an initially off trigger with the actions "if (Damage Taken) is greater than or equal to (Life of unit), set life of unit = (life of unit + (Damage Taken))".

Then, at map init (or when you choose the hero, or when the unit is bought, I don't know what it's for...), create an action that's something like "create event for
  • - Unit takes damage"[/I].
  • Whenever you want that unit to be "invincible" (just so he doesn't die, he can still take damage), activate the trigger (be it through an ability event, when entering a region or whatever).
  • If it's for MUI, you can give the unit an array and create a boolean (array) that says when the unit needs to be invincible.
  • If the boolean is true, he will gain his HP back, otherwise he will die.
  • This is actually not a really good trigger, there are probably better ones, since this checks 1 step ahead:
  • If the unit with 60HP left is attacked for 30 damage, he will gain the 30HP back (because after the attack he has only 29HP left, which is equal to the damage dealt).
 
Status
Not open for further replies.
Top