Spell Gift of Life

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
JASS / MUI / No leaks
And coding-wise I think it's JESP?

Implementation: very easy
Requires: vJASS (e.g.: NewGen) and ABC (included within)

Code:
JASS:
library GiftOfLife initializer Init requires ABC

//////////////////////////////////////////////////////////////////////////////
//                                                                          //
//  Gift of Life, by Magentix                                               //
//  =========================                                               //
//    - Requires vJASS                                                      //
//    - Requires Cohadar's ABC Struct Attachment System                     //
//                                                                          //
//  Configure spell IDs here:                                               //
//  -------------------------                                               //
//                                                                          //
    globals                                                                 //
        private constant integer SPELL_ID = 'A000' // The spell itself      //
        private constant integer BUFF_ID = 'B001'  // The buff it places    //
    endglobals                                                              //
//                                                                          //
//////////////////////////////////////////////////////////////////////////////
//                                                                          //
//                     PLEASE GIVE CREDIT WHEN USING                        //
//                                                                          //
//////////////////////////////////////////////////////////////////////////////


    private struct GOLData
        unit Caster
        unit Target
        real Damage
        real Duration
        trigger T
    endstruct

    private function CheckForBuff takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local GOLData dat = GetTimerStructA(t)
        
        call UnitDamageTarget(dat.Caster,dat.Target,0.00-(GetUnitState(dat.Target, UNIT_STATE_MAX_LIFE)/25.00),false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)        
        set dat.Duration = dat.Duration - 0.04
        
        if (GetUnitAbilityLevel(dat.Target,BUFF_ID) <= 0 or dat.Duration <= 0) then
            call UnitDamageTarget(dat.Caster,dat.Target,dat.Damage,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)
            
            call ClearTriggerStructA(dat.T)
            call DestroyTrigger(dat.T)
            
            call ClearTimerStructA(t)
            call dat.destroy()
            call PauseTimer(t)
            call DestroyTimer(t)
        endif
        
        set t = null
    endfunction
       
    private function AddDamageConditions takes nothing returns boolean
        local trigger T = GetTriggeringTrigger()
        local unit u = GetEventDamageSource()
        local GOLData dat = GetTriggerStructA(T)
        local boolean b = true
        
        if (dat.Caster == u) then
            set b = false
        endif
        
        set u = null
        set T = null
        return b
    endfunction
    
    private function AddDamage takes nothing returns nothing
        local trigger T = GetTriggeringTrigger()
        local GOLData dat = GetTriggerStructA(T)

        set dat.Damage = dat.Damage + GetEventDamage()

        set T = null
    endfunction

    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == SPELL_ID
    endfunction

    private function Actions takes nothing returns nothing
        local timer t = CreateTimer()
        local unit u = GetTriggerUnit()
        local unit v = GetSpellTargetUnit()
        local integer i = GetUnitAbilityLevel(u,SPELL_ID)
        local GOLData dat = GOLData.create()
        
        set dat.Caster = u
        set dat.Target = v
        set dat.Damage = 0.00
        set dat.Duration = 3.00 + (i * 2.00)
        
        set dat.T = CreateTrigger()
        call TriggerRegisterUnitEvent(dat.T,dat.Target,EVENT_UNIT_DAMAGED)
        call TriggerAddCondition(dat.T,Condition(function AddDamageConditions))
        call TriggerAddAction(dat.T,function AddDamage)
        call SetTriggerStructA(dat.T,dat)
        
        call SetTimerStructA(t,dat)
        call TimerStart(t,0.04,true,function CheckForBuff)

        set t = null
        set u = null
        set v = null
    endfunction

    //===========================================================================
    private function Init takes nothing returns nothing
        local trigger T = CreateTrigger()
        
        call TriggerRegisterAnyUnitEventBJ(T, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(T,Condition(function Conditions))
        call TriggerAddAction(T,function Actions)
        
        set T = null
    endfunction
endlibrary


Tooltip:

Infuses someone with the gift of life,
increasing their dexterity for a split second
and giving them near-immortality for a short while.

However, as every upside has its downside:
The unit will receive full damage afterwards for
any harm done to him while under the enchantment.

Level 1 - 100% MS/IAS, 5 second duration.
Level 2 - 200% MS/IAS, 7 second duration.
Level 3 - 300% MS/IAS, 9 second duration.


Motive:

Basically, it's an ultimate that fully heals someone and give great regen, but if the unit takes an amount of damage that would kill him, he'll still die after the effect wears off. So it kinda prolongues someone's life during a group fight.

This ability can do a few things:
- Help an ally escape: fast movement speed + full heal ftw
- Make a temporary tank out of someone, for example a low-hp nuker can actually survive a group fight now
- Heal someone

Upsides:
- Full heal
- Temporarily be near-immortal
- Great escape ability
- If a unit should die afterwards, it counts as a deny made by the caster.

Downsides:
- Long cooldown, high manacost
- You'll still die afterwards if you took a lot of damage during the gang.
- You can still be oneshotted
- Little eyecandy


NOTE: requires to have "allow negative real values in object editor" to be enabled in Preferences
 

Attachments

  • Spell - Gift of Life.w3x
    77.2 KB · Views: 203

Quauhtli

I have the right to remain silent.
Reaction score
62
The people and their eyecandy these days:rolleyes:

Just personally think it's a little overpowered :)
Full heal + Extreme attack speed + Extreme movement speed hehe

GJ on the spell though, it's very original.
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
Yeah, you'd say it's overpowered, but the MS/IAS only lasts a little less than a second.

In other words, just enough time to help get someone out of melee range from someone with like a 50% bash skill :)

The heal/regen is the biggest part of the spell, the speed is only a nice little sideperk due to its extremely short duration.
 

Sim

Forum Administrator
Staff member
Reaction score
534
> And coding-wise I think it's JESP?

JESP implies that the more customizable options, the better.

Such as duration(s), damage, number of targets, etc.
 

Tom Jones

N/A
Reaction score
437
Avoid adding actions to a trigger you'll later destroy, since DestroyTrigger() doesn't clean triggeractions, so they'll leak. I would personally integrate the AddDamage function with the AddDamageCondition. I would also filter away damage that deals 0 damage:
JASS:
    private function AddDamageConditions takes nothing returns boolean
        local trigger T = GetTriggeringTrigger()
        local unit u = GetEventDamageSource()
        local GOLData dat = GetTriggerStructA(T)
        //local boolean b = true
        
        if (dat.Caster == u) and GetEventDamage() != 0 then
            set dat.Damage = dat.Damage + GetEventDamage()
            //set b = false
        endif
        
        set u = null
        set T = null
        return false
    endfunction
Furthermore if the target takes lethal damage during cast, then the killer is the caster and not the unit that deals the damage. That makes no sense at all.
 

Tinki3

Special Member
Reaction score
418
> Avoid adding actions to a trigger you'll later destroy, since DestroyTrigger() doesn't clean triggeractions, so they'll leak

Good point.
Though, as an alternative, a triggeraction variable as a member
of that struct can be used as the trigger's action itself, and can
then be used as logical reference to be cleaned/destroyed.

Just simply set the triggeraction variable to "add" the action to the trigger.
I would say to go with merging the actions function into the conditions function, as Tom said, anyway.
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
> I would also filter away damage that deals 0 damage
That wouldn't affect the spell in any way I suppose?
I currently filter out the caster, since the initial heal counts as negative damage and would thus make the spell fail.


> Furthermore if the target takes lethal damage during cast, then the killer is the caster and not the unit that deals the damage. That makes no sense at all.

This is false: if a target takes lethal damage (extreme damage or one-shot kill) during the enchantment, the killer will still be the one who delivered the fatal blow.
It's only after the buff ended, that the enchanted unit dying counts as a deny.


As for trigger actions leaking: I've never heard of this, please elaborate on how to effectively avoid this.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top