Spell Bond ( tell me if you have a better name for this )

Viikuna

No Marlo no game.
Reaction score
265
Bond

New spell by me.

It is an AoE spell
Description: Links 3 to 5 units from target are together with a magical chain. Units linked like this, cannot go too far from eachother. If any of these Units dies, the link is broken, if not, the link will last up to 15 seconds.

It uses TimerUtils ( made by Vexorian )
here is the code:
JASS:
scope Bond initializer init

globals
     // spells Ability ID
     private constant integer ABILITY_ID = 'A000'
    // timer period, the smaller period, the smoother movement + greater lagg
     private constant real TIMER_PERIOD = 0.025
     // number of targets is calculated like this: MAX_TARGETS_LEVEL * AbilityLevel + MAX_TARGETS_BASE
     private constant integer MAX_TARGETS_BASE = 5
     private constant integer MAX_TARGETS_LEVEL = 0
     // Maximum number of targets in last spell level level, this is kinda important, because I use iot to set up array members
     // note that minimum number of targets is allways 3
     private constant integer MAX_TARGETS_MAX = 5
     // Spell AoE
     private constant real RADIUS_LEVEL = 150
     private constant real RADIUS_BASE = 20
     // spell Duration
     private constant real DURATION_BASE = 15.0 / TIMER_PERIOD
     private constant real DURATION_LEVEL = 0.0 / TIMER_PERIOD
     // effect path for that nice buff effect
      private constant string EFFECT_PATH = "Abilities\\Spells\\Orc\\StasisTrap\\StasisTotemTarget.mdl"
      private constant string ATTACH_PATH = "origin"
      private constant string LIGHTNING_CODE = "SPLK"
      // the length of magical chain
      private constant real LENGTH = 2000.0
endglobals
// here is the filter
private function Filtterinpaska takes nothing returns boolean
    return GetWidgetLife(GetFilterUnit()) > 0.0451 and GetUnitFlyHeight(GetFilterUnit()) == 0 and IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false
endfunction

globals
     private filterfunc True 
     private filterfunc F
     private integer TempI = 0
     private group TempG = CreateGroup()
endglobals

private struct Data
     unit array u[MAX_TARGETS_MAX]
     real array x[MAX_TARGETS_MAX]
     real array y[MAX_TARGETS_MAX]
     real array oldx[MAX_TARGETS_MAX]
     real array oldy[MAX_TARGETS_MAX]
     effect array e[MAX_TARGETS_MAX]
     lightning array l[MAX_TARGETS_MAX]
     integer count = 0
     integer duration
     integer iL = 0
     integer iU = 0
     timer t
     
     method lightningStart takes real dur returns nothing
         local integer i = this.iU
         local real x
         local real y
         local real x2
         local real y2
         local boolean b = false
         set this.iL = R2I(dur / TIMER_PERIOD)
         loop
            set y = this.y<i>
            set x = this.x<i>
            set x2 = this.x[i - 1]
            set y2 = this.y[i - 1]
            call MoveLightning(this.l<i>,true,x,y,x2,y2)
            call SetLightningColor(this.l<i>,1.0,1.0,1.0,1.0)
            set i = i - 1
            exitwhen i == 1
        endloop
        set y = this.y[1]
        set x = this.x[1]
        set x2 = this.x[this.iU]
        set y2 = this.y[this.iU]
        call MoveLightning(this.l[1],true,x,y,x2,y2)
        call SetLightningColor(this.l<i>,1.0,1.0,1.0,1.0)
     endmethod
     
     method lightningEnd takes nothing returns nothing
         local integer i = this.iU
         loop
             exitwhen i == 0
             call SetLightningColor(this.l<i>,1.0,1.0,1.0,0.0)
             set i = i - 1
         endloop
     endmethod
     
     method alive takes nothing returns boolean
          local integer i = 1
          local boolean b = false
          loop
              if GetWidgetLife(this.u<i>) &lt;= 0.0451 then
                  set b = true
              endif
              exitwhen i == this.iU or b == true
              set i = i + 1
          endloop
          return b
     endmethod
     
     method bondLength takes nothing returns boolean
        local integer i = this.iU
        local real dx
        local real dy
        local real d = 0.0
        loop
            set dx = this.x<i>- this.x[i - 1]
            set dy = this.y<i>- this.y[i - 1]
            set d = d + SquareRoot(dx * dx + dy * dy)
            set i = i - 1
            exitwhen i == 1
        endloop
        set dx = this.x[1] - this.x[this.iU]
        set dy = this.y[1] - this.y[this.iU]
        set d = d + SquareRoot(dx * dx + dy * dy)
        if d &gt; LENGTH then
            return true
        endif
        return false
     endmethod
     
     method onDestroy takes nothing returns nothing
         local integer i = this.iU
         call ReleaseTimer(this.t)
         loop
             exitwhen i == 0
             call DestroyEffect(this.e<i>)
             call DestroyLightning(this.l<i>)
             set i = i - 1
         endloop
     endmethod
endstruct

private function CountUnits takes nothing returns nothing
     set TempI = TempI + 1
endfunction

private function ItIsTrue takes nothing returns boolean
    return true
endfunction

private function Poot takes nothing returns nothing
    local Data d = GetTimerData(GetExpiredTimer())
    local integer i = d.iU
    local boolean lb = false
    set d.duration = d.duration - 1
    if d.duration &lt; 0 or d.alive() == true then
        call d.destroy()
    else
        loop
            set d.x<i> = GetUnitX(d.u<i>)
            set d.y<i> = GetUnitY(d.u<i>)
            if d.oldx<i> != d.x<i> or d.oldy<i> != d.y<i> then
                if d.bondLength() == true then
                    call SetUnitX(d.u<i>,d.oldx<i>)
                    call SetUnitY(d.u<i>,d.oldy<i>)
                    set lb = true
                else
                    set d.oldx<i> = d.x<i>
                    set d.oldy<i> = d.y<i>
                endif
            endif
            set i = i - 1
            exitwhen i == 0
        endloop
        if lb == true then
            call d.lightningStart(0.025)
        endif
        if d.iL == 0 then
            call d.lightningEnd()
        else
            set d.iL = d.iL - 1
        endif
    endif
endfunction

private function A takes nothing returns nothing
     local location loc = GetSpellTargetLoc()
     local unit u = GetTriggerUnit()
     local real x = GetLocationX(loc)
     local real y = GetLocationY(loc)
     local integer level = GetUnitAbilityLevel(u,ABILITY_ID)
     local integer i = 1
     local integer w = MAX_TARGETS_LEVEL * level + MAX_TARGETS_BASE 
     local integer dur = R2I(DURATION_LEVEL * level + DURATION_BASE)
     local Data d
     call GroupEnumUnitsInRange(TempG,x,y,RADIUS_LEVEL * level + RADIUS_BASE,F)
     call ForGroup(TempG,function CountUnits)
     if TempI &gt;= 3 then
         set d = Data.create() 
         loop
             set u = FirstOfGroup(TempG)
             exitwhen u == null or i &gt; w
             set d.u<i> = u
             set d.x<i> = GetUnitX(d.u<i>)
             set d.y<i> = GetUnitY(d.u<i>)
             set d.oldx<i> = d.x<i>
             set d.oldy<i> = d.y<i>
             set d.duration = dur
             set d.e<i> = AddSpecialEffectTarget(EFFECT_PATH,d.u<i>,ATTACH_PATH)
             set d.l<i> = AddLightning(LIGHTNING_CODE,false,10.0,10.0,0.0,0.0)
             call SetLightningColor(d.l<i>,1.0,1.0,1.0,0.0)
             set i = i + 1
             call GroupRemoveUnit(TempG,u)
         endloop
         set d.iU = i - 1
         set d.t = NewTimer()
         call SetTimerData(d.t,d)
         call TimerStart(d.t,TIMER_PERIOD,true,function Poot)
         call d.lightningStart(1.0)
     else
         call GroupClear(TempG)
         set u = null
     endif
     set TempI = 0
     call RemoveLocation(loc)
     set loc = null
endfunction

private function B takes nothing returns boolean
    return GetSpellAbilityId() == ABILITY_ID
endfunction

private function init takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    set True = Filter(function ItIsTrue)
    set F = Filter(function Filtterinpaska)
    loop
        call TriggerRegisterPlayerUnitEvent(t,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,True)
        set i = i + 1
        exitwhen i == bj_MAX_PLAYER_SLOTS
    endloop
    call TriggerAddCondition(t,Condition(function B))
    call TriggerAddAction(t,function A)
endfunction

endscope</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>


map: View attachment Bond.w3x

I havent tested it too much, so tell me if there is something, that needs fixing.

Screenshots: none. It looks allmost exactly like spirit link, it uses same lightning effect and everything. You see it, when you test it.
 

Tyman2007

Ya Rly >.
Reaction score
74
Umm, so what exactly does it do? you only said it links them together, does it like even out health orr... like transfer damage... orr..... what...
 

Viikuna

No Marlo no game.
Reaction score
265
Really minor 2 line update, which actually maters quite a lot.

And I need someone to test it, and give me some comments too.
 

Bloodcount

Starcraft II Moderator
Reaction score
297
Hm... looks cool.Why don't you make the chain to stay for as long as the spell is active?Anyway, good spell. +rep,
 

Viikuna

No Marlo no game.
Reaction score
265
Thanks, I too think it turned up to be a really nice spell.

I just think it looks better this way. If there be lightnings all the time, I would get bored.

Thats why there are those thunderclap effects on units; they show if your unit is linked or not.
This was mostly inspired by spirit link ofc. It has lightning only on cast, but effects remain trought the whole duration.
 

Viikuna

No Marlo no game.
Reaction score
265
It uses only one group, that is true, but the spell is MUI. ( This means that you can cast it multiple times and it works. )
 

bananaHUNT

You can change this now in User CP
Reaction score
55
I had the same idea for a spell contest here, i did it in GUI but i cant code for shit lol. nice spell though, i called it Bonds of Decay :)
 

Romek

Super Moderator
Reaction score
963
This needs a screenshot.
You could also make it use 1 timer. :)
 

Viikuna

No Marlo no game.
Reaction score
265
Oh, someone is bumping my spells.

Hm, I think this needs complete remake. Now this kinda sucks IMO.
 

Romek

Super Moderator
Reaction score
963
If you consider this abandoned, I'll graveyard it.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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