Spell Death Coil

Carnerox

The one and only.
Reaction score
84
2h5jnex.jpg

PHP:
The Death Knight tethers a target unit to a demonic obelisk.
If the target unit exceeds a set distance from the obelisk, 
the link will snap dealing damage and instantly moveing 
the target unit back to the obelisk.

Level 1 - Deals 75 damage. 500 max distance. Last for 15 seconds.
Level 2 - Deals 125 damage. 600 max distance. Last for 20 seconds.
Level 3 - Deals 175 damage. 700 max distance. Last for 25 seconds.
Level 4 - Deals 225 damage. 800 max distance. Last for 30 seconds.

Mana Cost: 100
Cooldown: 26 / 24 / 22 / 20

  • MUI: Yes
  • MPI: Yes
  • Lagless: Yes
  • Leakless: Hopefully

Requirements:
GTrigger
JNGP

Optional
Damage
AIDS
Event

JASS:

///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
           // Death Coil \\
          // by: Carnerox \\
         //   credits to:  \\
//Jesus4Lyf for  Damage, AIDS, Event, and GTrigger\\
//Vexorian for TimerUtils\\

// How to use import this spell:
// 1) Copy this trigger
// 2) Open your map, create a new trigger with the name "Death Coil".
// 3) Click Edit, and convert the trigger to custom text.
// 4) Copy the trigger, and paste it into the trigger.
// 5) Add all the systems that the spell uses.
// 6) Change the ABIL_ID, and DUMMY_ID to the correct rawcodes, and customize the spell to what you want.
////////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

scope DeathCoil  
    ////////////////////////////////CONFIGURATION DATA!\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    globals
        private constant integer    ABIL_ID         = 'A000'
        private constant integer    DUMMY_ID        = 'h000'
        private constant real       PERIODIC        = 0.04
        private constant real       COLOR_R         = 100.00 
        private constant real       COLOR_G         = 0.00  
        private constant real       COLOR_B         = 0.00 
        private constant real       COLOR_A         = 1.00
        private constant real       FLOAT           = 45.00
        private constant string     LIGHTNING_ID    = "MFPB"
        private constant string     EFFECT_ID       = "Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl"
        private constant attacktype ATTACK_TYPE     = ATTACK_TYPE_NORMAL
        private constant damagetype DAMAGE_TYPE     = DAMAGE_TYPE_MAGIC
        private constant weapontype WEAPON_TYPE     = null
        private constant boolean    SHARED_VISION   = true
    endglobals
    
    constant native UnitAlive takes unit whichUnit returns boolean
    
    private function Damage takes integer level returns real
        return 50.00*level+25.00
    endfunction
    
    private function Distance takes integer level returns real
        return 100*level+400.00
    endfunction
    
    private function Duration takes integer level returns real
        return 5.00*level+10.00
    endfunction
    
    private function GetUnitZ takes unit whichUnit returns real
        local location Point=Location(GetUnitX(whichUnit),GetUnitY(whichUnit))
        local real Real=GetLocationZ(Point)+GetUnitFlyHeight(whichUnit)
        call RemoveLocation(Point)
        set Point=null
        return Real
    endfunction
    
    ///////////////////////////END OF CONFIGURATION DATA!\\\\\\\\\\\\\\\\\\\\\\\
    private struct DeathCoil
        unit caster
        unit target
        unit dummy
        player owner
        lightning light
        integer level
        real x1
        real x2
        real y1
        real y2
        real z1
        real z2
        
        private static method onLoop takes nothing returns nothing
            local timer t = GetExpiredTimer()
            local thistype this = GetTimerData(t)
            local real x
            local real y
            set this.x2=GetUnitX(this.target)
            set this.y2=GetUnitY(this.target)
            set this.z2=GetUnitZ(this.target)+FLOAT
            set x=this.x2-this.x1
            set y=this.y2-this.y1
            call MoveLightningEx(this.light,true,this.x1,this.y1,this.z1,this.x2,this.y2,this.z2)
            if (SquareRoot(x*x+y*y)>=Distance(this.level)) then
                call ReleaseTimer(t)
                call DestroyLightning(this.light)
                call DestroyEffect(AddSpecialEffect(EFFECT_ID,this.x1,this.y1))
                call DestroyEffect(AddSpecialEffect(EFFECT_ID,this.x2,this.y2))
                call RemoveUnit(this.dummy)
                call SetUnitX(this.target,this.x1)
                call SetUnitY(this.target,this.y1)
                static if (LIBRARY_Damage) then
                    call Damage_Spell(this.dummy,this.target,Damage(this.level))
                else
                    call UnitDamageTarget(this.dummy,this.target,Damage(this.level),true,false,ATTACK_TYPE,DAMAGE_TYPE,WEAPON_TYPE)
                endif
                if (SHARED_VISION) then
                    call UnitShareVision(this.target,this.owner,false)
                endif
                set this.caster=null
                set this.target=null
                set this.dummy=null
                set this.light=null
                set t=null
            elseif not (UnitAlive(this.dummy)) or not (UnitAlive(this.target)) then
                call ReleaseTimer(t)
                call DestroyLightning(this.light)
                call DestroyEffect(AddSpecialEffect(EFFECT_ID,this.x1,this.y1))
                call RemoveUnit(this.dummy)
                if (SHARED_VISION==true) then
                    call UnitShareVision(this.target,this.owner,false)
                endif
                set this.caster=null
                set this.target=null
                set this.dummy=null
                set this.light=null
                set t=null
            endif
        endmethod

        private static method onEffect takes nothing returns boolean
            local thistype this = thistype.allocate()
            local timer t = NewTimer()
            set this.caster=GetTriggerUnit()
            set this.target=GetSpellTargetUnit()
            set this.owner=GetTriggerPlayer()
            set this.level=GetUnitAbilityLevel(this.caster,ABIL_ID)
            set this.x2=GetUnitX(this.target)
            set this.y2=GetUnitY(this.target)
            set this.z2=GetUnitZ(this.target)+FLOAT
            set this.dummy=CreateUnit(this.owner,DUMMY_ID,this.x2,this.y2,0.00)
            set this.x1=GetUnitX(this.dummy)
            set this.y1=GetUnitY(this.dummy)
            set this.z1=GetUnitZ(this.dummy)+FLOAT
            set this.light=AddLightningEx(LIGHTNING_ID,true,this.x1,this.y1,this.z1,this.x2,this.y2,this.z2)
            call UnitApplyTimedLife(this.dummy,'BTLF',Duration(this.level))
            call SetLightningColor(this.light,COLOR_R,COLOR_G,COLOR_B,COLOR_A)
            if (SHARED_VISION==true) then
                call UnitShareVision(this.target,this.owner,true)
            endif
            call SetTimerData(t,this)
            call TimerStart(t,PERIODIC,true,function thistype.onLoop)
            return false
        endmethod
        
        private static method onInit takes nothing returns nothing
            local trigger trig = CreateTrigger()
            call TriggerAddCondition(GT_RegisterStartsEffectEvent(trig,ABIL_ID),Condition(function thistype.onEffect))
        endmethod
    endstruct
endscope


JASS:

////////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
           // Death Coil \\
          // by: Carnerox \\
         //   credits to:  \\
//Jesus4Lyf for  Damage, AIDS, Event, and GTrigger\\
//Vexorian for TimerUtils\\

// How to use import this spell:
// 1) Copy this trigger
// 2) Open your map, create a new trigger with the name "Death Coil".
// 3) Click Edit, and convert the trigger to custom text.
// 4) Copy the trigger, and paste it into the trigger.
// 5) Add all the systems that the spell uses.
// 6) Change the ABIL_ID, and DUMMY_ID to the correct rawcodes, and customize the spell to what you want.
////////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//! zinc
library DeathCoil requires Damage,GT,TimerUtils
{
    ////////////////////////////////CONFIGURATION DATA!\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    private constant integer    ABIL_ID         = 'A000';
    private constant integer    DUMMY_ID        = 'h000';
    private constant real       PERIODIC        = 0.04;
    private constant real       COLOR_R         = 100.00; 
    private constant real       COLOR_G         = 0.00;
    private constant real       COLOR_B         = 0.00;
    private constant real       COLOR_A         = 1.00;
    private constant real       FLOAT           = 45.00;
    private constant string     LIGHTNING_ID    = "MFPB";
    private constant string     EFFECT_ID       = "Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl";
    private constant attacktype ATTACK_TYPE     = ATTACK_TYPE_NORMAL;
    private constant damagetype DAMAGE_TYPE     = DAMAGE_TYPE_MAGIC;
    private constant weapontype WEAPON_TYPE     = null;
    private constant boolean    SHARED_VISION   = true;
    
    function Damage(integer level) -> real
    {
        return 50.00*level+25.00;
    }
    
    function Distance(integer level) -> real
    {
        return 100.00*level+400.00;
    }
    
    function Duration(integer level) -> real
    {
        return 5.00*level+10.00;
    }
    
    function GetUnitZ(unit whichUnit) -> real
    {
        location l = Location(GetUnitX(whichUnit),GetUnitY(whichUnit));
        real r = GetLocationZ(l)+GetUnitFlyHeight(whichUnit);
        RemoveLocation(l);
        l=null;
        return r;
    }
    
    ///////////////////////////END OF CONFIGURATION DATA!\\\\\\\\\\\\\\\\\\\\\\\
    
    struct data
    {
        unit u; //Caster
        unit t; //Target
        unit d; //Dummy
        player p; // Owner of Caster.
        integer i;
        real x1;
        real x2;
        real y1;
        real y2;
        real z1;
        real z2;
        lightning l;
    }
      
    function GetDistance(real x,real y) -> real
    {
        return SquareRoot(x*x+y*y);
    }
    
    function onTimer()
    {
        timer t = GetExpiredTimer();
        data this = GetTimerData(t);
        real x; real y;
        this.x2=GetUnitX(this.t);
        this.y2=GetUnitY(this.t);
        this.z2=GetUnitZ(this.t)+FLOAT;
        x=this.x2-this.x1; y=this.y2-this.y1;
        MoveLightningEx(this.l,true,this.x1,this.y1,this.z1,this.x2,this.y2,this.z2);
        if (GetDistance(x,y)>=Distance(this.i))
        {
            ReleaseTimer(t);
            DestroyLightning(this.l);
            DestroyEffect(AddSpecialEffect(EFFECT_ID,this.x1,this.y1));
            DestroyEffect(AddSpecialEffect(EFFECT_ID,this.x2,this.y2));                
            RemoveUnit(this.d);
            SetUnitX(this.t,this.x1);
            SetUnitY(this.t,this.y1);
            static if (LIBRARY_Damage){ Damage_Spell(this.d,this.t,Damage(this.i)); }
            else{ UnitDamageTarget(this.d,this.t,Damage(this.i),true,false,ATTACK_TYPE,DAMAGE_TYPE,WEAPON_TYPE); }
            if (SHARED_VISION){ UnitShareVision(this.t,this.p,false); }
            this.u=null;
            this.t=null;
            this.d=null;
            this.p=null; 
            this.l=null;
            t=null;
        }
        else if (GetWidgetLife(this.d)<=0.405 || GetWidgetLife(this.t)<=0.405)
        {
            ReleaseTimer(t);
            DestroyLightning(this.l);
            DestroyEffect(AddSpecialEffect(EFFECT_ID,this.x1,this.y1));
            RemoveUnit(this.d);
            if (SHARED_VISION==true){ UnitShareVision(this.t,this.p,false); }
            this.u=null;
            this.t=null;
            this.d=null;
            this.p=null; 
            this.l=null;
            t=null;
        }
    }

    function onEffect() -> boolean
    {
        data this = data.create();
        timer t = NewTimer();
        this.u=GetTriggerUnit();
        this.t=GetSpellTargetUnit();
        this.p=GetTriggerPlayer();
        this.i=GetUnitAbilityLevel(this.u,ABIL_ID);
        this.x2=GetUnitX(this.t);
        this.y2=GetUnitY(this.t);
        this.z2=GetUnitZ(this.t)+FLOAT;
        this.d=CreateUnit(this.p,DUMMY_ID,this.x2,this.y2,0.00);
        this.x1=GetUnitX(this.d);
        this.y1=GetUnitY(this.d);
        this.z1=GetUnitZ(this.d)+FLOAT;
        this.l=AddLightningEx(LIGHTNING_ID,true,this.x1,this.y1,this.z1,this.x2,this.y2,this.z2);
        UnitApplyTimedLife(this.d,'BTLF',Duration(this.i));
        SetLightningColor(this.l,COLOR_R,COLOR_G,COLOR_B,COLOR_A);
        if (SHARED_VISION==true){ UnitShareVision(this.t,this.p,true); }
        SetTimerData(t,integer(this));
        TimerStart(t,PERIODIC,true,function onTimer);
        t=null;
        return false;
    }
        
    function onInit()
    {
        trigger t = CreateTrigger();
        TriggerAddCondition(GT_RegisterStartsEffectEvent(t,ABIL_ID),Filter(function onEffect));
        t=null;
    }
}
//! endzinc


Change Log:

v1.0b
  • Changed the model of the link.
  • Now gives vision over the target
v1.0c
  • Made the spell more customizable.
  • Changed the model of the Link.
  • Removed Jesus4Lyf Damage, AIDS, and Event system till I figure how I'll add the optional Damage system.
v1.0d
  • Allowed an option to use the Damage system.
  • Improved some parts of the code.
v1.0e
  • Made it so Damage/Distance/Duration can be set with a function, instead of being constant.
  • An effect is created at the target's x/y before it is moved to the obelisk.
  • Improved the documentation.
v1.1a
  • Raised the height of the link so it doesn't look like it's on the ground.
  • The link now works correctly with flying units so it's on attached to their x/y on the ground.
  • Created a constant for the floating height for the link.
  • Improved the documentation again.
v1.1b
  • Created a version that doesn't use the SpellStruct.
  • Slightly improved the documentation.
v1.1c
  • Fixed the z location with help of Laiev.
  • Improved the documentation.
  • Added a constant boolean to check if target shares vision.
  • Changed the DUMMY/LIGHTNING/etc.. to Dummy/Lightning/etc..
  • Changed the trigger from a Library to a Scope.
v1.2a
  • Removed Spellstruct/version.
  • Made it MUI/MPI.
  • Cleaned the spell up a little.
  • Added GTrigger.
v1.2b
  • Added a zinc version.
 

Whoareyou.

New Member
Reaction score
24
If you are an Alliance Hero do not read below.

I'd rate it 4/5, the name it sounds and looks, Death Coil isn't a really good name since its a name for another spell but like Death Latch or Death Leash because it chains them and connects them.

Looks like a really evil trap for the team of Alliance heroes!
Now all we need is a map with this spell.
 

Carnerox

The one and only.
Reaction score
84
There is a map. o.o

Also, the reason I named it Death Coil is this.

Coil: series of loops - A series of connected loops into which something has been wound or gathered
 

Whoareyou.

New Member
Reaction score
24
I mean like a map that uses this spell for the actual gameplay isn't that map just the spell? True about the Coil just people might get it mixed up with the normal Wc3 Death Coil if there noobs and don't read [No offense noobs].
 

Carnerox

The one and only.
Reaction score
84
Oh.. Confused me for a second. :rolleyes:
I thought you meant there were no test map.

If you tested the map, did you find any problems, or things that can be improved?
 

Whoareyou.

New Member
Reaction score
24
Well... I have to say the chain looks really hurtful as its the Finger of Death spell model repeated after time limit is up, I might find a different chain because well I would say black [notracist] is better.
Edit: Its kind of like finger of death***
 

Carnerox

The one and only.
Reaction score
84
In a bit, I'll see what it looks like as black, also it uses the Healing Wave model.
 

Carnerox

The one and only.
Reaction score
84
I just updated the map, with a new model to and link, and made it give temporary vision till the link is broken, or the duration is over.
 

BlackRose

Forum User
Reaction score
239
The ability reminds me of a dog leash, the target is held on by the obelisk then pulled back if he tries to escape, also reminds me of my other spell Restrain :)

However, your ability says the target is pulled back. The visual shows anything but that, the target is teleported straight back to the obelisk. I think you should either make it be pulled back or change the description :)

Coding

I like how you use Jesus4Lyf's resources, I haven't seen a spell submitted with them in use :O However, there are numerous things you can improve in this ability:

  1. Configuration: The ability has all the number figures hardcoded into the ability, this is bad. It is bad because you force users to go through your code themselves if they want to change any figures. The solution is to create a list of globals / functions that allow the user to easily modify spell values.

    Your ability should have these figures configurable:
    • Snap distance ([ljass]if (SquareRoot(.x*.x+.y*.y)>=800.00) then[/ljass]
    • Teleport effect ([ljass]call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl",.x1,.y1))[/ljass]
    • Damage dealt ([ljass]call Damage_Spell(.caster,.targetUnit,50*.level+25)[/ljass])
    • Dummy rawcode ([ljass]set .d=CreateUnit(.owner,'h000',.x2,.y2,0.00)[/ljass])
    • Lightning type ([ljass]set .l=AddLightning("MFPB",true,.x1,.y1,.x2,.y2)[/ljass])
    • Spell duration ([ljass]call UnitApplyTimedLife(.d,'BTLF',15.00)[/ljass])
    • Lightning colour ([ljass]call SetLightningColor(.l,100.00,0.00,0.00,10)[/ljass])
    • Timer period ([ljass]call .startTimer(.periodic,0.01)[/ljass])
    • Ability rawcode ([ljass]set thistype.abil='A000'[/ljass])

    The globals, being [ljass]constant[/ljass], will inline into the ability code so it'll be the same as what you are doing presently.
    .
  2. Encapsulation: Your struct is this: [ljass]struct DeathCoil extends SpellStruct[/ljass], someone else could name a struct [ljass]DeathCoil[/ljass] as well, this leads to the names conflicting. The solution is to place the struct inside a [ljass]scope[/ljass] or [ljass]library[/ljass], and then adding [ljass]private[/ljass] at the front of the struct.
    .
  3. Variable Naming:

    JASS:
    .
        unit d
        real x
        real y
        real x1
        real x2 
        real y1
        real y2
        lightning l


    It'd be nice to assist other users checking your code by commenting your code. Variable names such as [ljass]d[/ljass], and [ljass]l[/ljass] don't really tell me much (ignoring the fact they stand for dummy and lightning) either, but in bigger code, you'll definitely want to name things better. I'd suggest something like [ljass]dummy[/ljass] and [ljass]lightning[/ljass].
    .
  4. Damage isn't particularly needed for this ability, it's a commonly used system and is actually quite nice, but I'd just leave it to the user to make the ability run off Damage themselves, besides, you can always make Damage optional.
    .
  5. [ljass]if (SquareRoot(.x*.x+.y*.y)>=800.00) then[/ljass]
    You can remove the square root of this by squaring both sides of the equation. [ljass]( .x * .x + .y * .y ) >= (800.00 * 800.00)[/ljass] --> [ljass]( .x * .x + .y * .y ) >= (640000.00)[/ljass]. However, the value should be configurable as well.
 

Crazy_Dead

New Member
Reaction score
24
BlackRose, you know what?
You gief the most awsome critics ever. +rep on that one, even though i havent made this resource. :p
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Looks nice. :)
JASS:
        unit DUMMY
        lightning LIGHTNING
        real DAMAGE=50.00*.level+25.00

CAPITAL LETTERS are for constants.
For Damage, you can make it a function, allowing users to modify themselves.
 

Carnerox

The one and only.
Reaction score
84
Just updated it, and I also made Damage a function as you said. :thup:

You can also use, or not use the Damage System now.
 

Laiev

Hey Listen!!
Reaction score
188
wow :O people really accept it with SpellStruct o.o never thing it will happen |:

the only thing i suggest you is to comment wheres and wheres not people can edit the code (the config part)

EDIT: 'thanks Vexorian for JNGP' ?
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • 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

      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