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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top