• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Spell] Using HP to restore mana

Do you want it to be % or flat, can the Hero die from sacrifing life for mana? Level scaling? LUA, JASScode, GUI?
Some extra details would be for sure helpful :infl_thumbs_up: the good news is this should be fairly easy to make.

EDIT:
Here is a simple spell using flat values, since it runs instantly there is no need for any fancier things.

  • Spell Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Set up values in map ini or any of your "Start" triggers --------
      • -------- Should do this for all spells which uses a constant value --------
      • Set VariableSet ManaGain[1] = 75.00
      • Set VariableSet ManaGain[2] = 100.00
      • Set VariableSet ManaGain[3] = 125.00

  • Mana for Life
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mana Gain
    • Actions
      • -------- Get the level --------
      • Set VariableSet Level = (Level of Mana Gain for (Triggering unit))
      • -------- Prevent unit from dying from cast --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Life of (Triggering unit)) Less than ManaGain[Level]
        • Then - Actions
          • Unit - Order (Triggering unit) to Stop.
          • Game - Display to (All players) the text: Not enough life to ...
        • Else - Actions
          • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - ManaGain[Level])
          • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + ManaGain[Level])
 
Last edited:
I need to create a custom spell to use HP to restore mana, TY.
DoomBlade's way will work but here's how I implemented it in one of my maps. I based it off the Channel ability and I called it Life Burn. Burns 10% health to generate equal points in mana. Casting below 10% health can kill the hero. Higher ranks decrease cooldown and mana cost. I used this icon and added this sfx as Art - Caster in Object Editor. Currently the only benefit of going up in rank is a slower cooldown. Not sure this is the most fun way of doing it for players.

  • Life Burn Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Life Burn (E)
    • Actions
      • Set VariableSet pyro_burnt_PN = (Player number of (Owner of (Casting unit)))
      • Set VariableSet pyro_burnt_hp[pyro_burnt_PN] = ((Max life of Knight_Hero_Var[pyro_burnt_PN]) x 0.10)
      • Unit - Set life of Knight_Hero_Var[pyro_burnt_PN] to ((Life of Knight_Hero_Var[pyro_burnt_PN]) - pyro_burnt_hp[pyro_burnt_PN])
      • Unit - Set mana of Knight_Hero_Var[pyro_burnt_PN] to ((Mana of Knight_Hero_Var[pyro_burnt_PN]) + pyro_burnt_hp[pyro_burnt_PN])
 
I basically do the same thing for my "Cup of Blood" item in my map (but I have jass functions to show mana-text (my heal-text function does not work with negative values when I did this, so need to do it manually)).
AND I allow the hero to die and spawn a demon if that happens...

  • CupOfBloodOnUse
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Cup of Blood
    • Actions
      • Set temp_unit = (Hero manipulating item)
      • Set temp_point = (Position of temp_unit)
      • -------- +hp --------
      • Unit - Set life of temp_unit to ((Life of temp_unit) - 125.00)
      • Floating Text - Create floating text that reads -125 at temp_point with Z offset 80.00, using font size 8.00, color (50.00%, 75.00%, 25.00%), and 25.00% transparency
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 0.65 seconds
      • Floating Text - Change the fading age of (Last created floating text) to 0.50 seconds
      • Floating Text - Set the velocity of (Last created floating text) to (128.00 + (Random real number between 0.00 and 32.00)) towards (75.00 + (Random real number between 0.00 and 30.00)) degrees
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Life of temp_unit) Less than or equal to 0.00
        • Then - Actions
          • Unit - Create 1 Clicky Daemon [Boss 4 Summoned] for Player 9 (Gray) at temp_point facing Default building facing degrees
        • Else - Actions
          • -------- +mana --------
          • Custom script: call RestoreManaWithText(GetTriggerUnit(), 225.0, 1.2)
      • Custom script: call RemoveLocation(udg_temp_point)
 
Do you want it to be % or flat, can the Hero die from sacrifing life for mana? Level scaling? LUA, JASScode, GUI?
Some extra details would be for sure helpful :infl_thumbs_up: the good news is this should be fairly easy to make.

EDIT:
Here is a simple spell using flat values, since it runs instantly there is no need for any fancier things.

  • Spell Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Set up values in map ini or any of your "Start" triggers --------
      • -------- Should do this for all spells which uses a constant value --------
      • Set VariableSet ManaGain[1] = 75.00
      • Set VariableSet ManaGain[2] = 100.00
      • Set VariableSet ManaGain[3] = 125.00

  • Mana for Life
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mana Gain
    • Actions
      • -------- Get the level --------
      • Set VariableSet Level = (Level of Mana Gain for (Triggering unit))
      • -------- Prevent unit from dying from cast --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Life of (Triggering unit)) Less than ManaGain[Level]
        • Then - Actions
          • Unit - Order (Triggering unit) to Stop.
          • Game - Display to (All players) the text: Not enough life to ...
        • Else - Actions
          • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - ManaGain[Level])
          • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + ManaGain[Level])
Is it Real, Integer, or Boolean?
 
Back
Top