• 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.

[Spell] Auto-Rebirth Ability

Status
Not open for further replies.
Level 2
Joined
Sep 5, 2012
Messages
17
(Updated)

Hi. I'm new but I'm trying to learn the play-around corners of World Editor, Triggers, and JASS. I really have no experience in World Editing but I have a little programming background. Very little that it can't be considered a knowledge.

So, I want to start atleast making one spell (or understanding how it was made).

Here is the spell:

Auto-Rebirth (Innate - Passive) - Automatically heals himself by consuming his mana before his health completely depletes. Each point of mana recovers hitpoints based on his strength healing at full health or until all mana are consumed. Using magic as an esper-magician hybrid will cost him health instead of mana.

Current progress:
- [Done] Being able to detect a unit's pre-death, or the event upon receiving a fatal damage (damage that will cause death).
- [Done] Being able to detect unit's current STR/Max health.
- [Done] Being able to create a self-heal trigger.
- [Done] Overall mechanics (full credits to WaterKnight)
- [Done] Fixing flaw: Only first attacked unit will trigger the spell if more than one unit has spell.

Revised/Final version: http://www.hiveworkshop.com/forums/attachment.php?attachmentid=117723&stc=1&d=1347003315

So the first step I am trying to figure out that I cannot determine is the event of the unit's pre-death, or the event upon receiving a fatal damage (damage that will cause death).

So how could I create this even since obviously 'Unit Dies' doesn't work.

So this time, I am trying to detect a unit's current STR and max health and how to duplicate a self-heal spell. But I can't seem to find the right functions for it.

Anyone could lend a hand again?

Thanks. After this, I will try to proceed on the next steps and if there are something I couldn't find, I will try to ask here again.

Any help is gladly appreciated.

Currently working to fix the ability's balance (well, that's nothing to do with coding). But the main problem is the flaw where only the first attacked unit triggers the effect if more than one unit has the ability.

Map done: http://www.hiveworkshop.com/forums/...to-rebirth-ability-project-index-test-map.w3x

Would using an 'array' fix this?


FIXED! I don't know how to explain on how did I fix it. Just check the code. Also, please tell me could be the problem that may arise or what could leak from the codes D:

Revised/Final version: http://www.hiveworkshop.com/forums/attachment.php?attachmentid=117738&stc=1&d=1347093644

Uploaded for iChaos.
 

Attachments

  • Project-Index Test Map.w3x
    19.9 KB · Views: 154
  • Updated for iChaos (Auto-Rebirth).w3x
    21.4 KB · Views: 106
Last edited:
Level 2
Joined
Sep 5, 2012
Messages
17
Will try it and give back a response. Thanks.

EDIT: I'm trying it but I can't seem to find the proper events. Only got to 'Unit Takes damage'
 
Level 2
Joined
Sep 5, 2012
Messages
17
Okay then. But how could I create the condition 'if damage taken equal to current life?'

Btw, I already set the action 'Set life of Unit to 100.00%.'
 
Level 2
Joined
Sep 5, 2012
Messages
17
YES! After lots of testing, it worked! Thanks.

Now, how can I [detect the triggering unit's current STR/Max health] and how does heal spell work like [healing unit at max health]? 'Set life of Unit to 100.00%/99999.00.' doesn't seem to work and I don't know what kind of function is that :v
 
Level 4
Joined
Aug 26, 2012
Messages
123
You can use variables to it... or using Conditions to detecting...
(If you set an Integer variable, there's something like:
  • Set STRvar_Int = Strength of (Hero) Excluding bonuses
and on real:
  • Set Max_Health_real = (max life) of (unit)
)

And I always use "Set life of (unit) to 100%" to heal her totally...
(for me, it works...)
 
Level 2
Joined
Sep 5, 2012
Messages
17
Thanks. I will try it now right away. Will come back with a response after testing. But btw, what 'Base Ability' can I use for this? Reincarnation doesn't seem to fit actually.
 
Level 4
Joined
Aug 26, 2012
Messages
123
Personally, I think you can use any of Passive abilities, and use conditions that asks whether a unit has the ability...
(example:
  • Events
    • Unit - A unit Is About_to_die
  • Conditions
    • Level of ability for (Triggering unit) not equal to 0
  • Actions
    • ----- Do Whatever You Want To Do -----
)
 
Level 2
Joined
Sep 5, 2012
Messages
17
Now I'm confused. If I were to use a generic unit event, then how can I determine if it was about to die since Takes damage is only an event for a specific unit.
 
Level 4
Joined
Aug 26, 2012
Messages
123
How if:
  • Events
    • Unit - A unit is attacked
  • Conditions
    • (Attacked unit)'s life lesser than or equal to (very low percent health)
    • Level of (ability) for (Attacked unit) not equal to 0
  • Actions
    • -------- blah blah --------
(Blah blah blah...)
 
Level 2
Joined
Sep 5, 2012
Messages
17
Will try that right away. Btw, I already made the healing hahaha! I'll just need the part where it will consume each point of mana to heal HP.

Will come back for results of testing.

EDIT: The problem with that is the unit dies. It is much more accurate to use 'Takes damage' For example unit has 1000/1100 health and took 1000 damage, the unit will die without being healed unless I specified I higher value for it to trigger.

Any other way though?
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Unit is attacked has nothing to do with damage/life. It triggers already when the attacker is about to strike/start a missile.

Events can be created ingame via Trigger - Add New Event To Trigger if you need to register new units for the unit takes damage event.

Strength can be asked for with integer function Hero - Hero Attribute. Max life is under real function Unit - Property too.

The unit won't be healed completely if you have that life-setting action in the unit takes damage event because the event fires before the damage is dealt.
 
Level 2
Joined
Sep 5, 2012
Messages
17
The unit won't be healed completely if you have that life-setting action in the unit takes damage event because the event fires before the damage is dealt.

Yes, this is the one I'm having a problem right now as well aside from the generic unit event.

If triggering unit has 500/2000 HP left and attacked with 1000 damage, unit will be healed at max health then will receive 1000 damage leaving it with 1000/2000 current HP.

How can I make it so the triggering damage will be reduced by the triggering unit's current health?
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
You cannot change the already calculated damage, maybe still can render the unit invulnerable but okay. A common method is to boost max health as well for an over-heal and reset it after a 0-second timer. This has been explained in a lot of other threads.

If you can make the unit invu, you may also do so and postpone the damage (with your own value). Might be worse though because the unit would be invu for an instance and this might break targeting commands and stuff.
 
Level 2
Joined
Sep 5, 2012
Messages
17
Hmmm how about creating a dummy unit to absorb the said damage? Would that be possible?

If not, how can I max that overheal effect? Links to thread please or tell me where and how to find them (aka keyword in searching).
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
You cannot redirect the damage to another unit either.

The max hp of a unit can be modified with the Item: Life Bonus ability (AIlf). Just take a very high value there to simplify the process.

So you add it on damage event, remove it after 0 seconds and adjust the current life to your desired value.
 
Level 2
Joined
Sep 5, 2012
Messages
17
Cool. Where exactly should I add it?

  • Events
    • Unit - (Specific unit) Takes damage
  • Conditions
    • (Damage taken) Greater than or equal to (Life of (Triggering unit))
  • Actions
    • Unit - Set life of (Triggering unit) to 100.00%
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Set max life and current to 100%, the order does not matter because when modifying max life, the unit keeps the ratio between current and max.

Save the value the unit is supposed to have in the end, start a 0-timer, upon expriation reset first the max life, then apply your value.
 
Level 6
Joined
May 4, 2012
Messages
187
I need more info about the spell.

> How much mana should be depleted per HP missing?

> What is the minimum life to regenerate back to higher value?

> What is the main objective of the spell?

Note: Sorry If I really didn't understand your spell description and goals, because my native language is not english and I am only in cellphone.
 
Level 2
Joined
Sep 5, 2012
Messages
17
Lol I'm very sorry but pardon my stupidity, I don't know how to do that lol.

I need more info about the spell.

> How much mana should be depleted per HP missing?

> What is the minimum life to regenerate back to higher value?

> What is the main objective of the spell?

Note: Sorry If I really didn't understand your spell description and goals, because my native language is not english and I am only in cellphone.

Auto-Rebirth (Innate - Passive) - Automatically heals himself by consuming his mana before his health completely depletes. Each point of mana recovers hitpoints based on his strength healing at full health or until all mana are consumed.

Level 0 - Recovers HP by 2.5% of strength per point of mana
Level 1 - Recovers HP by 3% of strength per point of mana
Level 2 - Recovers HP by 3.5% of strength per point of mana
Level 3 - Recovers HP by 4% of strength per point of mana
Level 4 - Recovers HP by 4.5% of strength per point of mana
Level 5 - Recovers HP by 5% of strength per point of mana
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
t is a timer variable, g a unit group variable, curLife, healPerMana, manaUsed and heal are reals. You would ideally have a way to assign data to native objects like units, I guess you do not and also want to avoid clearing up, so I use the custom value of the unit here and cut off the value to an integer.

  • Events
    • Unit - <unit> takes damage
  • Conditions
    • (Damage taken) Greater than ((Life of (Triggering unit)) - (0.81 / 2.00)) //as indicated, units die below 0.405 hp, GUI only lets you write 2 decimal places
  • Actions
    • Unit - Add Life Bonus to (Triggering unit) //Unit - Add ability
    • Unit - Set life of (Triggering unit) to 100.00%
    • -------- --- --------
    • Set curLife = (Life of (Triggering unit))
    • Set healPerMana = (2.00 + ((Real((Level of <ability> for (Triggering unit)))) x 0.50)) //there is no "0" level, you probably meant the first //function Unit - Level Of Ability For Unit, use function Arithmetic for +,-,*,/ operations
    • Set healPerMana = (healPerMana x (Real((Strength of (Triggering unit) (Include bonuses))))) //function Conversion - Convert Integer To Real
    • Set healPerMana = (healPerMana / 100.00)
    • Set manaUsed = ((Max. Life of (Triggering unit)) / healPerMana)
    • Set manaUsed = (Min(manaUsed, (Mana of (Triggering unit)))) //function Math - Min
    • Set heal = (manaUsed x healPerMana)
    • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) - manaUsed)
    • -------- --- --------
    • Unit - Set the custom value of (Triggering unit) to (Integer(heal)) //Unit - Set Custom Value, function Conversion - Convert Real To Integer
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • 'IF'-Bedingungen
        • (g is empty) Equal to True //function Unit Group - Group Is Empty
      • 'THEN'-Aktionen
        • Countdown-Timer - Start t as a One-shot timer that will expire in 0.00 seconds //Countdown-Timer - Start, collect all units in a single timer expiration, so we do not need to allocate new timer objects and the timer won't be restarted if another unit dies meanwhile
      • 'ELSE'-Aktionen
    • Unit Group - Add (Triggering unit) to g //Unit Group - Add Unit
  • Events
    • Time - t expires //Time - Timer expires
  • Conditions
  • Actions
    • Unit Group - Pick every unit in g and do (Actions) //Unit Group - Pick Every Unit in Unit Group And Do Multiple Actions
      • Loop - Actions
        • Unit - Remove Life Bonus from (Picked unit) //Unit - Remove ability
        • Unit - Set life of (Picked unit) to (Real((Custom value of (Picked unit)))) //do not need to manually clean up the custom value as it's overwritten next time and vanishes with the unit when it disappears from the game
    • Unit Group - Remove all units from g //Unit Group - Clear
 
Last edited:
Level 2
Joined
Sep 5, 2012
Messages
17
Aw pro. You already did everything man :v Now I have nothing to do lol. Thanks a lot. I understood everything except the second trigger. What was that for? I assume it is the generic unit takes damage event?

EDIT: Ohh I got it. It's the trigger for removing the life bonus. Very well done sir.

EDIT2: Here is the map. The flaw I found is that if there are two units having the same ability, only the first attacked unit will trigger the spell.

http://www.hiveworkshop.com/forums/attachment.php?attachmentid=117722&stc=1&d=1346994006

EDIT3: Everything is fixed. Although I'm not sure if it will arise any problem in the future.
 

Attachments

  • Project-Index Test Map.w3x
    18.6 KB · Views: 118
Last edited:
Status
Not open for further replies.
Top