Spell Webshot

Reaction score
456
Webshot

Spider Queen shoots out web and pulls itself to
the target point using it, damaging all enemy
ground units on it's way.

Level 1: Deals 75 damage.
Level 2: Deals 125 damage.
Level 3: Deals 175 damage.


Requires NewGen

Code:
JASS:
scope Webshot initializer Init

    globals
        private constant integer    SPELL_ID            = 'A000'
        
        //The caster moves MAX_DISTANCE in MAX_DURATION. So, if the distance
        //to the target point is half MAX_DISTANCE, the duration will be half
        //too.
        private constant real       MAX_DISTANCE        = 1200.00
        private constant real       MAX_DURATION        = 1.20
        
        //String path for lightning effect, and some colour configuration.
        private constant string     LIGHTNING_PATH      = "LEAS"
        private constant real       LIGHTNING_A         = 0.82
        private constant real       LIGHTNING_R         = 0.15
        private constant real       LIGHTNING_G         = 1.00
        private constant real       LIGHTNING_B         = 0.10
        //Distance from the center of the caster to the angle direction.
        //The root of the webs are placed on those positions. If you don't
        //get it, test it.
        private constant real       LIGHTNING_DISTANCE  = 75.00
        private constant real       LIGHTNING_ANGLE     = bj_PI / 4

        private constant real       DAMAGE_RADIUS       = 112.00
        private constant attacktype DAMAGE_ATTACK_TYPE  = ATTACK_TYPE_NORMAL
        private constant damagetype DAMAGE_DAMAGE_TYPE  = DAMAGE_TYPE_UNIVERSAL
        private constant weapontype DAMAGE_WEAPON_TYPE  = WEAPON_TYPE_WHOKNOWS
        private constant string     DAMAGE_EFFECT       = "Abilities\\Weapons\\PoisonArrow\\PoisonArrowMissile.mdl"
        private constant string     DAMAGE_EFFECT_POINT = "chest"

        private constant real       INTERVAL            = 0.03
    endglobals

    private constant function DamageFilter takes unit caster, unit target returns boolean
        return IsUnitEnemy(target, GetOwningPlayer(caster)) and IsUnitType(target, UNIT_TYPE_GROUND) == true
    endfunction

    private constant function DamageAmount takes integer level returns real
        return 25.00 + level * 50.00
    endfunction

    private struct Data
        private static timer Timer = CreateTimer()
        private static Data array Array
        private static integer Counter = 0

        private unit caster
        private real angle
        private real xInc
        private real yInc
        private real damage

        private lightning web1
        private lightning web2
        private real targetX
        private real targetY

        private integer ticks

        private group currentGroup = CreateGroup()
        private group damagedGroup = CreateGroup()

        private static method ReturnTrue takes nothing returns boolean
            return true
        endmethod

        private method actions takes nothing returns nothing
            local real casterX = GetUnitX(.caster)
            local real casterY = GetUnitY(.caster)
            local unit f

            call SetUnitPathing(.caster, false)
            call SetUnitPosition(.caster, casterX + .xInc, casterY + .yInc)
            call SetUnitFacing(.caster, .angle * bj_RADTODEG)
            call MoveLightning(.web1, true, casterX + LIGHTNING_DISTANCE * Cos(.angle + LIGHTNING_ANGLE), casterY + LIGHTNING_DISTANCE * Sin(.angle + LIGHTNING_ANGLE), .targetX, .targetY)
            call MoveLightning(.web2, true, casterX + LIGHTNING_DISTANCE * Cos(.angle - LIGHTNING_ANGLE), casterY + LIGHTNING_DISTANCE * Sin(.angle - LIGHTNING_ANGLE), .targetX, .targetY)

            call GroupEnumUnitsInRange(.currentGroup, GetUnitX(.caster), GetUnitY(.caster), DAMAGE_RADIUS, Condition(function Data.ReturnTrue))
            loop
                set f = FirstOfGroup(.currentGroup)
                exitwhen f == null
                call GroupRemoveUnit(.currentGroup, f)
                if not IsUnitInGroup(f, .damagedGroup) and DamageFilter(.caster, f) then
                    call GroupAddUnit(.damagedGroup, f)
                    call UnitDamageTarget(.caster, f, .damage, true, false, DAMAGE_ATTACK_TYPE, DAMAGE_DAMAGE_TYPE, DAMAGE_WEAPON_TYPE)
                    call DestroyEffect(AddSpecialEffectTarget(DAMAGE_EFFECT, f, DAMAGE_EFFECT_POINT))
                endif
            endloop
        endmethod

        private static method Handler takes nothing returns nothing
            local integer i = 0

            loop
                exitwhen i == .Counter
                if .Array<i>.ticks == 0 or GetUnitState(.Array<i>.caster, UNIT_STATE_LIFE) &lt; 0.405 then
                    call .Array<i>.destroy()
                    set .Array<i> = .Array[.Counter - 1]
                    set .Counter = .Counter - 1
                    set i = i - 1
                else
                    call .Array<i>.actions()
                    set .Array<i>.ticks = .Array<i>.ticks - 1
                endif
                set i = i + 1
            endloop

            if .Counter == 0 then
                call PauseTimer(.Timer)
            endif
        endmethod

        static method create takes unit caster, real targetX, real targetY returns Data
            local Data dat = .allocate()

            local real casterX = GetUnitX(caster)
            local real casterY = GetUnitY(caster)
            local real dx = targetX - casterX
            local real dy = targetY - casterY
            local real distance = SquareRoot(dx * dx + dy * dy)
            local real angle = Atan2(dy, dx)

            local real web1x = casterX + LIGHTNING_DISTANCE * Cos(angle + LIGHTNING_ANGLE)
            local real web1y = casterY + LIGHTNING_DISTANCE * Sin(angle + LIGHTNING_ANGLE)
            local real web2x = casterX + LIGHTNING_DISTANCE * Cos(angle - LIGHTNING_ANGLE)
            local real web2y = casterY + LIGHTNING_DISTANCE * Sin(angle - LIGHTNING_ANGLE)

            local real duration = distance / MAX_DISTANCE * MAX_DURATION

            set dat.caster = caster
            set dat.xInc = (distance / duration * INTERVAL) * Cos(angle)
            set dat.yInc = (distance / duration * INTERVAL) * Sin(angle)
            set dat.angle = angle
            set dat.damage = DamageAmount(GetUnitAbilityLevel(caster, SPELL_ID))

            set dat.web1 = AddLightning(LIGHTNING_PATH, true, web1x, web1y, targetX, targetY)
            call SetLightningColor(dat.web1, LIGHTNING_R, LIGHTNING_G, LIGHTNING_B, LIGHTNING_A)
            set dat.web2 = AddLightning(LIGHTNING_PATH, true, web2x, web2y, targetX, targetY)
            call SetLightningColor(dat.web2, LIGHTNING_R, LIGHTNING_G, LIGHTNING_B, LIGHTNING_A)
            set dat.targetX = targetX
            set dat.targetY = targetY

            set dat.ticks = R2I(duration / INTERVAL)

            set .Array[.Counter] = dat
            set .Counter = .Counter + 1
            if .Counter == 1 then
                call TimerStart(.Timer, INTERVAL, true, function Data.Handler)
            endif

            return dat
        endmethod

        private method onDestroy takes nothing returns nothing
            call SetUnitPathing(.caster, true)
            call DestroyLightning(.web1)
            call DestroyLightning(.web2)
            call DestroyGroup(.damagedGroup)
            call DestroyGroup(.currentGroup)
        endmethod
    endstruct

    private function Actions takes nothing returns nothing
        local location targetLoc = GetSpellTargetLoc()

        call Data.create(GetTriggerUnit(), GetLocationX(targetLoc), GetLocationY(targetLoc))

        call RemoveLocation(targetLoc)
        set targetLoc = null
    endfunction

    //==========================================================

    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == SPELL_ID
    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)
    endfunction

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


Screen:
___________________________________________________________
webshotscreen2.png

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
 

Attachments

  • [Spell] - Webshot.w3x
    17.7 KB · Views: 511

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
Uh, too cool... ;) +rep if I can, really original as said above
 

Cohadar

master of fugue
Reaction score
209
Just a general note:
I never asked credit for any of my systems so you do not have to write my name every time you make a spell ffs.

It is written in the system header so no need to bother.

PS: try experimenting with some other lightnings and with SetLightningColor() function to make it look more "weby"
 
Reaction score
456
>I never asked credit for any of my systems so you do not have to write my name every time you make a spell ffs.
"Sorry", usually people just ask to give credit if their systems are used.

>PS: try experimenting with some other lightnings and with SetLightningColor() function to make it look more "weby"
I shall look into it.
 

Cohadar

master of fugue
Reaction score
209
Oh I forgot:
Webs are kind of transparent so when using SetLightningColor() setting alpha to 128 (50% transparency) would give it a nice touch.
 

Cohadar

master of fugue
Reaction score
209
It looks totally cool now.

Damn it looks uber-cool.
I think I will make spider creep wave just so I have a reason to use this in my map :banghead:
 
Reaction score
456
I'm glad that people like this spell. This was supposed to be used in Pyramidal Defence..

>I think I will make spider creep wave just so I have a reason to use this in my map
So it might be used in the map then? :p
 

Arcane

You can change this now in User CP.
Reaction score
87
I just tested this, it's awesome.
I can't really think of any uses for it currently, since I can't have spiders randomly popping into my map, but if I had a spider hero, this ability would definitely be one of my top choices - think of the strategy in casting this! <3

Can't rep you again. :p
 

emjlr3

Change can be a good thing
Reaction score
395
Why not just leave angle in radians?
You could use a global group in Webshot_Handler and remove the need to create and destroy a group every time spidey is moved, in which case pause the unit so the user cannot move him during the pull
SetUnitX/Y is faster, especially since you are doing no pathing or map boundary check
What happens if spidey dies in mid pull?

GJ
 
Reaction score
456
>Why not just leave angle in radians?
I don't understand the difference between radians and degrees... :p

>You could use a global group in Webshot_Handler and remove the need to create and destroy a group every time spidey is moved
Thanks, I'm going to update this.

>What happens if spidey dies in mid pull?
If the caster dies, I move the web strings perodically back to the caster?

Thanks for feedback people!
 

Arkan

Nobody rides for free
Reaction score
92
If you use radians you use bj_Pi as 180 degrees and 2*bj_Pi as 360 degrees. I think most people prefer degrees anyway.
 
Reaction score
456
Improved the code.. and made other few changes to it.

>If you use radians you use bj_Pi as 180 degrees and 2*bj_Pi as 360 degrees. I think most people prefer degrees anyway.
Still I don't understand, but it does not matter.
 

emjlr3

Change can be a good thing
Reaction score
395
you get your angle in degrees, and convert it to radians using bj_DEGTORAD

then, u use this angle, convert it back to degrees using bj_RADTODEG, and use it that way
 

Cohadar

master of fugue
Reaction score
209
I have a small modification request (in order to use this in Pyramidal Defence)

Spider shots a web on target unit and draws the victim into his mouth,
but if spider misses his target web sticks to the ground and spider is dragged to target location.

How to miss?
Shoot Web at starting X,Y location of target unit.
When web reaches location X,Y if targer moved from there by more than 128 distance web will miss and stick to the ground.

I do not want the web to be able to grab any other units except the unit that was fired on, even if they are on the path of web.

So it is simple either you grab the right victim or you pull yourself to it's location.

Maybe you should make it a separate spell if it sounds like too much of a modification. (you do not even have to publish it as far as I am concerned, just make it so I can use it in Pyramidal.)
 
Reaction score
456
>I have a small modification request (in order to use this in Pyramidal Defence)
I shall make it as another spell then :p. But it can wait till tomorrow, as I am going to Narwy's tonight.

Oh.. and I couldn't fix those radian/degree things..
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top