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

[Spell] How can i Revive my hero with 25% hit points

Status
Not open for further replies.
Level 7
Joined
Nov 13, 2011
Messages
127
Ok guys I have 1 custom unit called Tauren Chieften that guy have a ability named Reincarnation which revives you instantly after death with full hp and mp this is the problem how can i make Reincarnation revives me at level 1 25% hit points level 2 50% and level 3 75% hit points any suggestion will be really helpfull also if there is already this thread plz post a link and tell me to close this thread :)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I think there's no way to detect Reincarnation since it's a passive and not a castable ability. You can try though to check if reincarnation is detected by triggers, in that case it would be easy, but I doubt so.

If it's not possible to detect reincarnation or a unit is revived event or something, you can just start a local timer and set hero hp = 25% when the timer reaches 0, which would have the same duration than the reincarnation time to revive.

-------------------------------------
Another way is
Trigger 1: "A unit dies -> Unit has reincarnation -> Add unit to DeadGroup" / "Start Trigger 2

Trigger 2: Every 0.5 seconds -> Pick every unit in DeadGroup and (If Unit is alive) set Hp Percentage of unit to (Integer to Real conversion(Reincarnation lvl x 25.00)) / Remove unit from group. / Stop trigger if group is empty
-------------------------------------

Doing what Death-Blade says is leakless, MUI and "Unbugable"... Unless you make it bug somehow :)
 
Level 4
Joined
Oct 20, 2011
Messages
129
Just use:
Hero - Revive (instantly)
Unit - Set Life (To Percentage)

That's all!

I think there's no way to detect Reincarnation since it's a passive and not a castable ability. You can try though to check if reincarnation is detected by triggers, in that case it would be easy, but I doubt so.

If it's not possible to detect reincarnation or a unit is revived event or something, you can just start a local timer and set hero hp = 25% when the timer reaches 0, which would have the same duration than the reincarnation time to revive.

-------------------------------------
Another way is
Trigger 1: "A unit dies -> Unit has reincarnation -> Add unit to DeadGroup" / "Start Trigger 2

Trigger 2: Every 0.5 seconds -> Pick every unit in DeadGroup and (If Unit is alive) set Hp Percentage of unit to (Integer to Real conversion(Reincarnation lvl x 25.00)) / Remove unit from group. / Stop trigger if group is empty
-------------------------------------

Doing what Death-Blade says is leakless, MUI and "Unbugable"... Unless you make it bug somehow :)

The only problem when using these easy ways to make this spell is: CAN YOU MAKE A PASSIVE SPELL COOLDOWN WITH TRIGGER?
 
Level 9
Joined
Apr 23, 2011
Messages
460
The only problem when using these easy ways to make this spell is: CAN YOU MAKE A PASSIVE SPELL COOLDOWN WITH TRIGGER?

Sure, just dynamically index the unit when it is revived and have a third trigger determine whether or not the spell is on cooldown, once the unit's ability timer expires, destroy it and set a global boolean for if the unit can use reincarnation to true.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Yeah, you can with a triggered cooldown. With a periodic trigger set AbilityCooldown = 30 and reduce it by 1 every second. Revive the unit only if the AbilityCooldown <= 0.

Have you seen Leoric revive in DOTA? When Leoric dies, it checks the time to revive, and when it revives it slams the ground. You have to do the same but setting the unit HP.
 
Level 7
Joined
Nov 13, 2011
Messages
127
Doing what Death-Blade says is leakless, MUI and "Unbugable"... Unless you make it bug somehow :)

thanks for the help guys now about what death-blade said is totally us i said.. cause if your unit dies the enemy player will get gold + when the hero revive and kill him again he will take again gold.. that's one thing i have more but i think you have get my point :)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
We're thinking too much something that's pretty simple.

If the unit has reincarnation it won't give gold when it dies since the unit actually never dies, but uses an skill. If the ability is in cooldown, it will die and give gold.

You just need to detect when the unit with this ability dies and add it to the group. Then Every 0.03 seg check if the unit is alive, and if it's alive, set the HP% = Level of Ability x 25.00 and remove it from the group. If group is empty, turn off trigger.

If the unit dies definitely (having the ability in cooldown) remove it from the ReincarnationGroup and it will revive as expected.
 
Level 7
Joined
Nov 13, 2011
Messages
127
We're thinking too much something that's pretty simple.

If the unit has reincarnation it won't give gold when it dies since the unit actually never dies, but uses an skill. If the ability is in cooldown, it will die and give gold.

You just need to detect when the unit with this ability dies and add it to the group. Then Every 0.03 seg check if the unit is alive, and if it's alive, set the HP% = Level of Ability x 25.00 and remove it from the group. If group is empty, turn off trigger.

If the unit dies definitely (having the ability in cooldown) remove it from the ReincarnationGroup and it will revive as expected.

:O i never thought this way i mean i make a lot ways like this
  • Reincarnation
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Unit-type of (Dying unit)) Equal to Tauren Chieftain) and (((Dying unit) has buff Devotion Aura) Equal to True)
    • Actions
      • Wait 2.00 seconds
      • Hero - Instantly revive (Dying unit) at (Position of (Dying unit)), Hide revival graphics
      • Unit - Set life of (Dying unit) to 25.00%
      • Wait 3.00 seconds
      • Trigger - Turn off (This trigger)
      • Wait 240.00 seconds
      • Trigger - Turn on (This trigger)
but the unit never revived in the dying place :D can you make what you just told me ?? so i can just copy paste it ? :) it's really late and i can't really think right now xD
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Hehe, it's harder than I tough. You can't detect when the unit dies with reincarnation because the unit never dies. So, the whole effect has to be triggered. But not with waits as you're doing xD

I'll think about this later.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Also using waits will make your spell not MUI...
Using Waits or TriggerSleepAction does not make your spell un-MUI if you know how to use it in a proper way such as using local variable instead of global
Also, using (Triggering unit) without local variable will also make the trigger MUI because (Triggering unit) is a special native function that will always be MUI with/without local variable
 
Level 7
Joined
Nov 13, 2011
Messages
127
can someone tell me why this is not working??
  • Reincarnation
    • Events
      • Unit - A unit Finishes reviving
    • Conditions
      • ((Unit-type of (Reviving Hero)) Equal to Tauren Chieftain) and (((Reviving Hero) has buff Reincarnation (Effect)) Equal to True)
    • Actions
      • Unit - Set life of (Triggering unit) to 25.00%
i had put it and this way
  • Reincarnation
    • Events
      • Unit - A unit Finishes reviving
    • Conditions
      • ((Unit-type of (Reviving Hero)) Equal to Tauren Chieftain) and (((Reviving Hero) has buff Reincarnation (Effect)) Equal to True)
    • Actions
      • Unit - Set life of (Reviving unit) to 25.00%
but still it didn't work :/ with this complicating spell i have jizz in my pants.. :D
 
Level 7
Joined
Nov 13, 2011
Messages
127
Jesus ok guys i find a much more easier way well it will not be with % but it will give for ex. level 1 - 300 hit points , level 2 - 600 hit points , level 3 - 900 hit points i can make it with the item named "item reincarnation" :D so simple xD
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
It can be done with % using a boolean and a Real Variable, and a Periodic Trigger that Sets Real = Unit HP. If Unit HP = 0, set ReincarnationUsed = True and with a timer, set the ReincarnationUsed = False after the ability CD is finished.

A lot harder and complex, but allows "detecting" reincarnation.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I can do it but...

What kind of map is yours? 1 Hero per player? RPG? Multi Hero? Multiple Players can have the same hero? etc...

I need to know because this can be done with Unit Groups and Hashtables (if there's more than 1 unit with this skill per player) It can also be done with UnitArray... It can even be done with just a Real Variable and a self-created trigger.
 
Level 7
Joined
Nov 13, 2011
Messages
127
I can do it but...

What kind of map is yours? 1 Hero per player? RPG? Multi Hero? Multiple Players can have the same hero? etc...

I need to know because this can be done with Unit Groups and Hashtables (if there's more than 1 unit with this skill per player) It can also be done with UnitArray... It can even be done with just a Real Variable and a self-created trigger.

It's a hero arena you can pick 1 time that hero no more times
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Ok. Here's something. It can be improved but I'm not sure about how your map works yet.

The Obvious
  • Map Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Hash = (Last created hashtable)
This event should be "A unit enters playable map area" and Unit Type of your unit is TheOneThatRevives (You know what I mean).

  • Reincarnation Set
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Set u = Tauren Chieftain 0000 <gen>
      • Unit Group - Add u to ReincarnationGroup
      • Custom script: set udg_i = GetHandleId(udg_u)
      • -------- Cooldown will be in Slot 0 of unit ID --------
      • Custom script: call SaveInteger(udg_Hash,udg_ i, 0, 0)
Here comes the fun. Every 1 sec the Trigger checks the unit Hp. If it's greater than 0 and the cooldown is = 0 it means it revives, so, the unit is added to the CooldownGroup and the CD starts going down. I changed the "Ability Delay" to 1 second, so, the unit dies (CD = 60), the ability waits 1 second (CD = 59) The unit revives (CD = 58)... Here I set the HP = 25% (This is where you have to set Lvl of Ability x 25.00). Works. The unit revives instantly with 25% (or almost). You just have to adjust the delay time of the ability with the Integer Cooldown.

  • Reincarnation Loop
  • Reincarnation Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in ReincarnationGroup) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in ReincarnationGroup and do (Actions)
            • Loop - Actions
              • Set u = (Picked unit)
              • Set HeroHP = (Life of u)
              • Game - Display to (All players) the text: (|cffff0000Hero Hp|r: + (String(HeroHP)))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • HeroHP Equal to 0.00
                  • Cooldown Equal to 0
                • Then - Actions
                  • Unit Group - Remove u from ReincarnationGroup
                  • Custom script: set udg_i = GetHandleId(udg_u)
                  • Custom script: call SaveInteger(udg_Hash, udg_i, 0, 60)
                  • Unit Group - Add u to CooldownGroup
                • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in CooldownGroup) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in CooldownGroup and do (Actions)
            • Loop - Actions
              • Set u = (Picked unit)
              • Custom script: set udg_i = GetHandleId(udg_u)
              • Custom script: set udg_Cooldown = (LoadInteger(udg_Hash, udg_i, 0) -1)
              • Custom script: call SaveInteger(udg_Hash, udg_i, 0, udg_Cooldown)
              • Game - Display to (All players) the text: (|cffff0000Reincarnation CD|r: + (String((Load 0 of i from Hash))))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Cooldown Equal to 58
                • Then - Actions
                  • Unit - Set life of u to 25.00%
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Cooldown Equal to 0
                    • Then - Actions
                      • Custom script: call SaveInteger(udg_Hash, udg_i, 0, 60)
                      • Unit Group - Remove u from CooldownGroup
                      • Unit Group - Add u to ReincarnationGroup
                    • Else - Actions
        • Else - Actions
Be aware that this is NEARLY precise, not ABSOLUTELY precise. You have to adjust manually the delay time, and be sure that the Triggered Cooldown reaches to 0 the exact same moment the ability cooldown reaches 0. You can test this by killing the unit when the Cooldown reaches 0, and the unit should reincarnate again.

This is just a way to do it. If you adjust it to make it work the way you definitely want it to work (adjust the cooldown duration, Level of Ability x 25.00, etc.) then I can help you improving it with jass and stuff.

If you're definitely sure that this hero will be choosen just once in the whole game by just one player, then it becomes a bit easier.
 

Attachments

  • asdf.w3x
    17.1 KB · Views: 41
Level 20
Joined
Jul 14, 2011
Messages
3,213
As said..

This event should be "A unit enters playable map area" and Unit Type of your unit is TheOneThatRevives (You know what I mean).

With that event, and that condition, just set u = Triggering Unit. Since it will happen just once, you can then turn off and even destroy that trigger.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Convert the logic between the Ability Level and the Percentage HP to numbers

Set Unit Life Percentage to (Ability Level * 20) + 5.

Lvl 1: ((1 * 20) + 5) = 25%
Lvl 2: ((2 * 20) + 5) = 45%
Lvl 3: ((3 * 20) + 5) = 65%

Ability Level is an Integer, and Life% is a Real. So you'll have to use "Convert Integer 2 Real (Ability Level)"
 
Level 7
Joined
Nov 13, 2011
Messages
127
Convert the logic between the Ability Level and the Percentage HP to numbers

Set Unit Life Percentage to (Ability Level * 20) + 5.

Lvl 1: ((1 * 20) + 5) = 25%
Lvl 2: ((2 * 20) + 5) = 45%
Lvl 3: ((3 * 20) + 5) = 65%

Ability Level is an Integer, and Life% is a Real. So you'll have to use "Convert Integer 2 Real (Ability Level)"

can you make it in a trigger code?? xD i am really bad in triggering :/
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
You have values

A = Level of Ability
B = 20
C = 5

Formula is ((A*B) + C)

Unit - Set life of u to ((Real(Level of Reincarnation for u) * 20) + 5)

  • Unit - Set life of u to ((Real(Level of Reincarnation for u) * 20) + 5)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Ok. Good to know if you have it working. Now i'd like to optimize it.

Are you going to keep track of any other unit cooldown simultaneously? Are you absolutely sure that the only unit with this skill in the entire game is this, and it will only enter the playable map are just once in the whole life of the known universe?
 
Level 7
Joined
Nov 13, 2011
Messages
127
Ok. Good to know if you have it working. Now i'd like to optimize it.

Are you going to keep track of any other unit cooldown simultaneously? Are you absolutely sure that the only unit with this skill in the entire game is this, and it will only enter the playable map are just once in the whole life of the known universe?

yes yes this will be the only hero with this ability...now for the "will enter the playable map are just once in the whole life" what you mean? my map is about killing and killing some more example >> I have make a trigger when a hero dies he will revive automatically in 10 seconds. So now if my hero with the reincarnation ability dies once and makes the ability go to cooldown and then he dies again he will revive at the base. will this cause problems?? sorry for bad english :/
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
1- Whats your native language?

2- Yeah, the unit will enter the playable map area, but it's the only Unit of that type that will enter in the playable map area. If it's the only unit of that kind that will be able to enter the playable map area (x number of times) then you can turn off and destroy the trigger, since there's abolutely no need to change the value of the Unit variable.

In the example I used a temp variable (u) but if this is the only unit, you can create an specific one "ReincarnationUnit" that will remain the same for the whole duration of the game.
 
Level 7
Joined
Nov 13, 2011
Messages
127
1- Whats your native language?

2- Yeah, the unit will enter the playable map area, but it's the only Unit of that type that will enter in the playable map area. If it's the only unit of that kind that will be able to enter the playable map area (x number of times) then you can turn off and destroy the trigger, since there's abolutely no need to change the value of the Unit variable.

In the example I used a temp variable (u) but if this is the only unit, you can create an specific one "ReincarnationUnit" that will remain the same for the whole duration of the game.

1. my native language is Greek, i don't know where this stuck but whatever

2. so it's fine?? or i must do something specific about it? i mean Chieftain is the only unit with this ability so it's fine right??
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Yeah, it's right. But if you're only having one unit of that type per game, there's no need to ue the Unit Groups and all that stuff.

But I need to be REALLY sure that there isn't anything like "same hero" in dota, or "death match" in dota, or any possible way to have more than one of that unit in the game.
 
Level 7
Joined
Nov 13, 2011
Messages
127
Yeah, it's right. But if you're only having one unit of that type per game, there's no need to ue the Unit Groups and all that stuff.

But I need to be REALLY sure that there isn't anything like "same hero" in dota, or "death match" in dota, or any possible way to have more than one of that unit in the game.

there is no "death match and same hero" modes , You pick that hero you stay with that hero until the game overs + there is no repick mode yet :D
 
Remeber to read my comments in the triggers

Here you go, should be easy enough to modify for yourself I hope, and yes to anyone else I know it leaks, but I am not sure if it is safe to clean a leak when using triggering unit with waits since the point isn't MUI if you use a variable with it without a index method/system.

Though Madietor the leaks this creates aren't even noticeable.
By the way I like your name =)

I didn't know if you wanted a way to visibly show the passive CD though... it wouldn't be difficult depending on how you want to show it, could use the third resource which is food.
 

Attachments

  • for you Madietor.w3x
    17.2 KB · Views: 49
Level 7
Joined
Nov 13, 2011
Messages
127
Here you go, should be easy enough to modify for yourself I hope, and yes to anyone else I know it leaks, but I am not sure if it is safe to clean a leak when using triggering unit with waits since the point isn't MUI if you use a variable with it without a index method/system.

Though Madietor the leaks this creates aren't even noticeable.
By the way I like your name =)

I didn't know if you wanted a way to visibly show the passive CD though... it wouldn't be difficult depending on how you want to show it, could use the third resource which is food.

ooohh for me?? thanks a lot thanks for the try but this way will bring a leak that i really don't want which is double gold bounty which is something that i have discust in the other pages :D btw +rep to you for trying to help me!!
 
Status
Not open for further replies.
Top