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

[Trigger] Mass heal spell

Status
Not open for further replies.
Level 3
Joined
Aug 20, 2008
Messages
40
anybody knows how make spell that will heals allied unit in 400/450/500 area for int*4/5/6 (int of casting unit)
i already tried to make that but on cast healed only casting unit
 
Level 6
Joined
Sep 5, 2007
Messages
264
I rather using triggers...

I rather use triggers and just alter the target unit(s) hp. This is merely because I like having more direct control over what is going on.

But your way could work, but it'd be a pain to get the intelligence*3/4/5 thing to work exactly right, you'd need different levels to allow. Trigger based would be the simpler way to go.
 
Level 3
Joined
Aug 20, 2008
Messages
40
Pick them and use this:
  • Actions - Unit set life of picked unit to (life of picked unit + (Hero inteligence of casting unit x3/4/5))
That will heal them.
Sorry if you think i said the same thing xD.Schruke but you left out that part.

thanks ^_^
 
Level 14
Joined
Jul 26, 2008
Messages
1,009
If the skill has more than one level I HIGHLY suggest including the Level of Ability Being Cast to the formula, doing something like this: Set Life of Picked Unit to (Life of Picked Unit + (Intelligence of Casting Hero * 4 + (25 * Level of Ability Being Cast)

Mess with the formula how you see fit, but that should work. Most people have hero skills that level, so I thought I'd toss that in.

BTW, what trigger picks all units in range? I can't seem to locate that trigger on the GUI :\
 
Level 12
Joined
Mar 16, 2006
Messages
992
Use a typical spell being cast trigger.
Unit group, units within X range of caster matching condition belongs to allied player.
Set Life = Current life + integer(hero int*4/6/8/whatever)
 
Level 6
Joined
Sep 5, 2007
Messages
264
Something I whipped up...

JASS:
constant function MassHeal_AbilityID takes nothing returns integer
    // The rawcode of the ability being casted, probably just a dummy ability
    return 'Ahea'
endfunction

constant function MassHeal_CasterFX takes nothing returns string
    // The effect created on a casting unit

    // NOTE: Effect strings MUST double slash:
    // "Abilities\\Spells\\Human\\Heal\\HealTarget.mdl"     =   GOOD
    // "Abilities\Spells\Human\Heal\HealTarget.mdl"         =   EDITOR WILL CRASH ON SAVE!
    return "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl"
endfunction
constant function MassHeal_EffectFX takes nothing returns string
    // The effect created on a healed unit

    // NOTE: Effect strings MUST double slash:
    // "Abilities\\Spells\\Human\\Heal\\HealTarget.mdl"     =   GOOD
    // "Abilities\Spells\Human\Heal\HealTarget.mdl"         =   EDITOR WILL CRASH ON SAVE!
    return "Abilities\\Spells\\Undead\\VampiricAura\\VampiricAuraTarget.mdl"
endfunction

constant function MassHeal_Caster_Bonus takes nothing returns real
    // The fraction of healing that the caster gets 0-1
    // More than 1 means that the caster gets bonus heal
    // Less than 1 means that the caster gets less healing than everyone else
    return 2.0
endfunction

constant function MassHeal_HealAmount takes nothing returns integer
    // The beginning amount healed irrelevant of intelligence
    return 100
endfunction
constant function MassHeal_HealAmount_Increment takes nothing returns integer
    // The amount healed gained per level
    return 100
endfunction

constant function MassHeal_HealAmount_Intelligence takes nothing returns integer
    // The beginning amount healed per point of intelligence
    return 3
endfunction
constant function MassHeal_HealAmount_Intelligence_Increment takes nothing returns integer
    // The amount healed gained per level
    return 1
endfunction

constant function MassHeal_Radius takes nothing returns integer
    // The beginning radius of effect
    return 500
endfunction
constant function MassHeal_Radius_Increment takes nothing returns integer
    // The radius of effect gained per level
    return 0
endfunction

function Trig_Mass_Heal_Conditions takes nothing returns boolean
    return (GetSpellAbilityId() == MassHeal_AbilityID())
endfunction

function Trig_Mass_Heal_Actions takes nothing returns nothing
    // Get the caster
    local unit caster = GetSpellAbilityUnit()
    // Get the caster's intellegence
    local integer intelligence = GetHeroInt(caster, true)

    // The Ability being casted
    local integer abil_id = GetSpellAbilityId()
    // The Level of THAT ability
    local integer abil_lvl = GetUnitAbilityLevel(caster, abil_id) - 1

    // The player that owns the caster (for filtering friendly units)
    local player player_caster = GetOwningPlayer(caster)

    // Group var, contain ALL units possibly effected
    local group unitgroup = CreateGroup()
    // The current unit selected from the group
    local unit iterator

    // Caster's position in world co-ordinates
    local real x = GetUnitX(caster)
    local real y = GetUnitY(caster)
    // The AoE of the spell
    local real radius = MassHeal_Radius() + (MassHeal_Radius_Increment() * abil_lvl)

    // Current HP of the iterator
    local real life
    // Maximum HP of the iterator
    local real max_life

    // Special Effect Variable
    local effect sfx

    // The maximum amount healed (broken up onto 3 lines for readability)
    local real heal_amount = MassHeal_HealAmount_Intelligence()
    set heal_amount = heal_amount + (MassHeal_HealAmount_Intelligence_Increment() * abil_lvl)
    set heal_amount = heal_amount * intelligence

    set heal_amount = heal_amount + MassHeal_HealAmount()
    set heal_amount = heal_amount + (MassHeal_HealAmount_Increment() * abil_lvl)
    
    // The actual healing part (caster only)
    set life = GetUnitState(caster, UNIT_STATE_LIFE)
    set max_life = GetUnitState(caster, UNIT_STATE_MAX_LIFE)
    set life = life + (heal_amount * MassHeal_Caster_Bonus())
    call SetUnitState(caster, UNIT_STATE_LIFE, life)

    // Create SFX where the target is
    set sfx = AddSpecialEffectTarget(MassHeal_CasterFX(), caster, "origin")
    call DestroyEffect(sfx)
    set sfx = null

    call GroupEnumUnitsInRange(unitgroup, x,y, radius, null)
    loop
        set iterator = FirstOfGroup(unitgroup)
        exitwhen (iterator == null)

        if (IsUnitAlly(iterator, player_caster) and iterator != caster) then
            // The actual healing part
            set life = GetUnitState(iterator, UNIT_STATE_LIFE)
            set max_life = GetUnitState(iterator, UNIT_STATE_MAX_LIFE)
            if (life > 0 and life < max_life) then
                set life = life + heal_amount
                call SetUnitState(iterator, UNIT_STATE_LIFE, life)

                // Create SFX where the target is
                set sfx = AddSpecialEffectTarget(MassHeal_EffectFX(), iterator, "origin")
                call DestroyEffect(sfx)
                set sfx = null
            endif
        endif

        call GroupRemoveUnit(unitgroup, iterator)
        set iterator = null
    endloop

    // Var cleanup
    call DestroyGroup(unitgroup)
    set unitgroup = null

    set player_caster = null
    set caster = null
endfunction

//===========================================================================
function InitTrig_Mass_Heal takes nothing returns nothing
    set gg_trg_Mass_Heal = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Mass_Heal, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Mass_Heal, Condition(function Trig_Mass_Heal_Conditions))
    call TriggerAddAction(gg_trg_Mass_Heal, function Trig_Mass_Heal_Actions)
endfunction

EDIT 1: Forgot a couple of things... IE: Special FX.

EDIT 2: Reworked healing code to heal alive units only, and only ones below their maximum HP. Also, the caster gets twice the heal from this (can be easily removed, if undesirable).

EDIT 3: Realised that I'd used a custom effect, so I altered it. That, and there was a small syntax error...
 
Last edited:
Level 3
Joined
Aug 20, 2008
Messages
40
If the skill has more than one level I HIGHLY suggest including the Level of Ability Being Cast to the formula, doing something like this: Set Life of Picked Unit to (Life of Picked Unit + (Intelligence of Casting Hero * 4 + (25 * Level of Ability Being Cast)

Mess with the formula how you see fit, but that should work. Most people have hero skills that level, so I thought I'd toss that in.

BTW, what trigger picks all units in range? I can't seem to locate that trigger on the GUI :\

my ability has 3 lvl (ultimate skill) heals 100/200/300+4/5/6*int of casting hero in 350+50*abilitylvl radius

trigger that pick all unit is : Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)

Use a typical spell being cast trigger.
Unit group, units within X range of caster matching condition belongs to allied player.
Set Life = Current life + integer(hero int*4/6/8/whatever)

when set mathing conditions units in range of spell dont healed even caster =/
 
Last edited:
Level 25
Joined
Jun 5, 2008
Messages
2,573
First off all, that is an double post, delete that and edit your previous post.
Now use this trigger:
  • Events - Unit starts the effect of an ability
  • Conditions - Ability being cast equal to *ability*
  • Actions
    • - Set variable *Unit_group* = units in within *x* range of casting unit matching condition (matching unit owner equal to ally of owner of casting unit)
    • - Set variable *heal integer* = unit level of *ability* for casting unit x100
    • - Unit group - Pick every unit in *Unit_group* and do actions
      • - Unit - Unit set life of picked unit to (unit life of picked unit + ( *heal integer* x (hero inteligence of casting unit x *y*)))
    • - Custom script: call DestroyGroup(udg_*Unit_group*)
*x* = 335 + (15 x (unit level of *ability* for casting unit x 15))
*y* = inteligence modifier
 
Level 3
Joined
Aug 20, 2008
Messages
40
First off all, that is an double post, delete that and edit your previous post.
Now use this trigger:
  • Events - Unit starts the effect of an ability
  • Conditions - Ability being cast equal to *ability*
  • Actions
    • - Set variable *Unit_group* = units in within *x* range of casting unit matching condition (matching unit owner equal to ally of owner of casting unit)
    • - Set variable *heal integer* = unit level of *ability* for casting unit x100
    • - Unit group - Pick every unit in *Unit_group* and do actions
      • - Unit - Unit set life of picked unit to (unit life of picked unit + ( *heal integer* x (hero inteligence of casting unit x *y*)))
    • - Custom script: call DestroyGroup(udg_*Unit_group*)
*x* = 335 + (15 x (unit level of *ability* for casting unit x 15))
*y* = inteligence modifier

you checked this trigger?
because i have little problem witj it... it heals only caster onwer units and not all units within range...
 
Level 6
Joined
Sep 5, 2007
Messages
264
You can use my code if you want.

You can use the code I entered above...
Just create a trigger called "Mass_Heal", convert it to custom text, replace the entire code with the code above, and edit the "constant function" return values at the top...

EG:
To make the radius 400/450/500 like you wanted:
JASS:
constant function MassHeal_Radius takes nothing returns integer
    // The beginning radius of effect
    return 400
endfunction
constant function MassHeal_Radius_Increment takes nothing returns integer
    // The radius of effect gained per level
    return 50
endfunction

I've update the code above and included the 100/200/300 + intelligence * 4/5/6 that you were after, all you have to do is change the ability rawcode to your ability & use it.

I use "Thunder Clap" as a dummy spell (just to test the code) and I realised that you can get it to damage/stun enemy units and heal allied ones.

Look, I created that code in about 5-10 minutes tops. You don't have to credit ME for it. It was easy, and as far as I can tell, I doesn't leak at all, yours most likely will if you use the GUI (unless you spend a bit of time cleaning it up).
 
Status
Not open for further replies.
Top