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: 519

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 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

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top