Spell Mystic Snake

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
This spell is from DotA v6.60 that released yesterday...

A mystic snake made of energy jumps from target to target dealing damage and stealing some energy. After it reaches its last target, it jumps back to Medusa to replenish her mana. The snake deals more damage and steals more mana per jump. The snake power increased by 20% per jump.
Level 1 - 60 base damage, 20 base mana, 3 Jumps
Level 2 - 100 base damage, 30 base mana, 4 Jumps
Level 3 - 140 base damage, 40 base mana. 5 Jumps
Level 4 - 180 base damage, 50 base mana, 6 Jumps

JASS:

/////////////////////////////////////////////////////////////////////////////////////////////
//                              ~~~~~Mystic Snake~~~~~~~                                   //
//                                  ~~by kingking~~                                        //
//                                                                                         //
//      Things needed for this spell :                                                     //
//      1) Missle Dummy                                                                    //
//      2) This script                                                                     //
//      3) Key Timers 2                                                                    //
//      4) Jass NewGen Pack v5b or newer to compile                                        //
//                                                                                         //
//      Original Created by : IceFrog, the one who make DotA..                             //
/////////////////////////////////////////////////////////////////////////////////////////////
scope MysticSnake initializer Init

globals
    private constant integer ABIL_ID = 'A000'                     //Ability's ID
    private constant real PERCENT_INCREASE_PER_JUMP = 20.         //Damage and Mana loss factor
    private constant real AOE = 475.                              //Pick Unit AoE
    private constant integer MISSLE_DUMMY_ID = 'h003'             //Missle Dummy's ID
    private constant real MISSLE_SPEED = 20.                      //Speed of Missle Slide
    private constant real TIMER_INTERVAL = .03125                 //Timer Callback Interval
    private constant attacktype ATTACK_TYPE = ATTACK_TYPE_MAGIC   //Damage's attack type
    private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_MAGIC   //Damage's damage type
    private integer TempIndex
endglobals

/////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////Restricted area for newbies//////////////////////////////////////////
private struct Data
    unit cs
    integer lv
    real dmg
    real mana
    group damaged
    integer jumptimes
    unit target1
    unit target2
    boolean nullz
    group temp
    player p
    unit missle
    real x
    real y
    boolean complete_jump
    
    method onDestroy takes nothing returns nothing
        call KillUnit(.missle)
        call GroupClear(.damaged)
        call DestroyGroup(.damaged)
    endmethod
endstruct

private function JumpCount takes integer i returns integer
    return 2 + i
endfunction

private function DamageCount takes real r returns real
    return (40. * r + 20.) * .8
endfunction

private function ManaCount takes real r returns real
    return (10. * r + 10.) * .8
endfunction

private function Cond takes nothing returns boolean
    return GetSpellAbilityId() == ABIL_ID
endfunction

private function Move takes nothing returns boolean
    local Data d = KT_GetData()
    local real x = GetUnitX(d.missle)
    local real y = GetUnitY(d.missle)
    local real tx = GetUnitX(d.target2)
    local real ty = GetUnitY(d.target2)
    local real dx = x - tx
    local real dy = y - ty
    local real angle = 57.296 * Atan2(dy,dx) - 180.
    
    if (dx * dx + dy * dy) > 100. and GetWidgetLife(d.target2) > .405 then
        call SetUnitFacing(d.missle,angle)
        call SetUnitPosition(d.missle,x + MISSLE_SPEED * Cos(angle * bj_DEGTORAD),y + MISSLE_SPEED * Sin(angle * bj_DEGTORAD))
        return false
    else
        set d.dmg = d.dmg * (1. + (0.01 * PERCENT_INCREASE_PER_JUMP))
        set d.mana = d.mana * (1. + (0.01 * PERCENT_INCREASE_PER_JUMP))
        call UnitDamageTarget(d.cs,d.target2,d.dmg,FALSE,FALSE,ATTACK_TYPE,DAMAGE_TYPE,null)
        call SetUnitState(d.target2,UNIT_STATE_MANA,GetUnitState(d.target2,UNIT_STATE_MANA) - d.mana)
        set d.complete_jump = true
        return true
    endif
endfunction

private function MoveBack takes nothing returns boolean
    local Data d = KT_GetData()
    local real x = GetUnitX(d.missle)
    local real y = GetUnitY(d.missle)
    local real tx = GetUnitX(d.cs)
    local real ty = GetUnitY(d.cs)
    local real dx = x - tx
    local real dy = y - ty
    local real angle = 57.296 * Atan2(dy,dx) - 180.
    
    if (dx * dx + dy * dy) > 100. then
        call SetUnitPosition(d.missle, x + MISSLE_SPEED * Cos(angle * bj_DEGTORAD), y + MISSLE_SPEED * Sin(angle * bj_DEGTORAD))
        return false
    else
        call SetWidgetLife(d.cs,GetWidgetLife(d.cs) + d.dmg)
        call SetUnitState(d.cs,UNIT_STATE_MANA,GetUnitState(d.cs,UNIT_STATE_MANA) + d.mana)
        set d.complete_jump = true
        return true
    endif
endfunction

private function Pick takes nothing returns boolean
    local Data d = TempIndex
    return GetWidgetLife(GetFilterUnit()) > .405 and not IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) and not IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE) and IsUnitEnemy(GetFilterUnit(),d.p) and not IsUnitInGroup(GetFilterUnit(),d.damaged)
endfunction

private function Act takes nothing returns nothing
    local Data d = Data.create()
    local unit u
    set d.cs = GetTriggerUnit()
    set d.target1 = GetTriggerUnit()
    set d.target2 = GetSpellTargetUnit()
    set d.lv = GetUnitAbilityLevel(d.cs,ABIL_ID)
    set d.dmg = DamageCount(d.lv)
    set d.mana = ManaCount(d.lv)
    set d.jumptimes = JumpCount(d.lv) - 1
    set d.p = GetOwningPlayer(d.cs)
    set d.missle = CreateUnit(d.p,MISSLE_DUMMY_ID,GetUnitX(d.cs),GetUnitY(d.cs),0.)
    set d.nullz = false
    set d.complete_jump = false
    set d.damaged = CreateGroup()
    call KT_Add(function Move,d,TIMER_INTERVAL)
    loop
    exitwhen d.complete_jump == true
        call TriggerSleepAction(.3)
    endloop
    set d.target1 = d.target2
    
    loop
    exitwhen d.jumptimes == 0 or d.nullz == true
        set d.temp = CreateGroup()
        set d.x = GetUnitX(d.target1)
        set d.y = GetUnitY(d.target1)
        set TempIndex = d
        call GroupEnumUnitsInRangeCounted(d.temp,d.x,d.y,AOE,Condition(function Pick),1)
        set u = FirstOfGroup(d.temp)
        
        if d.target2 != null then
            set d.target2 = u
            call SetUnitX(d.missle,GetUnitX(d.target1))
            call SetUnitY(d.missle,GetUnitY(d.target1))
            call KT_Add(function Move,d,TIMER_INTERVAL)
            
            loop
            exitwhen d.complete_jump == true
                call TriggerSleepAction(.3)
            endloop
            
            call GroupAddUnit(d.damaged,d.target2)
            set d.complete_jump = false
            set d.target1 = d.target2
            call GroupClear(d.temp)
            call DestroyGroup(d.temp)
        else
            set d.nullz = true
        endif
        
        set d.jumptimes = d.jumptimes - 1
    endloop
    
    call KT_Add(function MoveBack,d,TIMER_INTERVAL)
    
    set d.complete_jump = false
    
    loop
    exitwhen d.complete_jump == true
        call TriggerSleepAction(.3)
    endloop
    
    call d.destroy()
    set u = 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 Cond))
    call TriggerAddAction(t,function Act)
    set t = null
endfunction

endscope


Screenshot! :
attachment.php


Hope you like it. :p
 

Attachments

  • Mystic Snake.JPG
    Mystic Snake.JPG
    40.1 KB · Views: 786
  • DotA_Spell_Pack_13.w3x
    65 KB · Views: 308

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
Nice spell, but there's just little things that are not like the real spell.

First cast is maybe bugged because I casted on a guy that had 300 life and killed him 1 shot.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
No, not bug. Heavy armor takes 2 x bonus damage from magic attack.

Magic Damage -> 180 damage
Heavy Armor -> 2 x Magic Damage
Caster will deal -> 360 damage
Creep HP-> 300hp

360 > 300, the guy sure die lol.
 

T.s.e

Wish I was old and a little sentimental
Reaction score
133
It should be spell-type damage, yes. But Kingking used magic damage type.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Attack and damage type now configurable.
Fixed a bug : The "snake" not return to caster when the snake pass through a unit only.
 

Romek

Super Moderator
Reaction score
964
JASS:
/
    static method create takes nothing returns Data
        return Data.allocate()
    endmethod

Why?

There's no need to convert to degrees, then back to radians.

Comment the configurables.

JASS:
local Data d = TempIndex

Why not use TempIndex directly?

JASS:
    loop
    exitwhen d.complete_jump == true
        call TriggerSleepAction(.0)
    endloop

Why not destroy it when d.complete_jump is set to true, instead of doing this..?

JASS:
set t = null

Why?
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
OMG, I only have the word "why" in my brain after reading your reply :S

Most of them I can't find solution, so....
 

mordocai

New Member
Reaction score
17
what does this spell do? put a description, i have no world editor atm, and dont play dota so i need a description
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Comments on the globals?
It should be user friendly.
-----
IMO, make "TempIndex" in another loop below a "DONT TOUCH PAST HERE" line.
Actually, there's no 'DTPH' line.
How are GUI kids supposed to know where to stop editing?
-----
All those configurable functions should go above the struct;
And above a 'DTPH' line.
-----
In "Move" you do this:
JASS:
local real angle = bj_RADTODEG * Atan2(y-ty,x-tx) - 180.
local real dx = x - tx
local real dy = y - ty

Put the dx/dy above the angle?
JASS:
local real dx = x - tx
local real dy = y - ty
local real angle = bj_RADTODEG * Atan2(dy, dx) - 180.

-----
You do the same thing as mentioned above in "MoveBack".
-----
In "Pick" instead of:
JASS:
IsUnitEnemy(GetFilterUnit(),d.p) == true and IsUnitInGroup(GetFilterUnit(),d.damaged) == false

You could do:
JASS:

Remove the "== true" as it's not needed for that function.
And replace "== false" with a "not" in front of the function.
-----
JASS:
set d.cs = GetTriggerUnit()
set d.target1 = GetTriggerUnit()

Is there a point to having this set twice?
-----
JASS:
set d.target2 = u

JASS:
set u = FirstOfGroup(d.temp)

After the second run it'll always be d.target2 who is the FirstOfGroup(d.temp)?
-----
JASS:
loop
exitwhen d.complete_jump == true
    call TriggerSleepAction(.0)
endloop

I don't like the looks of a TSA.
And don't .0 TSA's actually take .0 seconds to complete?
Either way, it's inaccurate.
-----
You never set "d.complete_jump" to false again after doing the first loop checking until it's true.
That above loop won't ever run since it's still true.
-----
JASS:
call GroupClear(d.temp)
call DestroyGroup(d.temp)

I don't believe you have to clear it before destroying it?
-----
JASS:
loop
exitwhen d.complete_jump == true
    call TriggerSleepAction(.0)
endloop

Same as above.
-----
If you took out those TSA's (And assuming KT2 supports it) you could do this whole spell in it's Conditions.
Also, you don't need to null 't'.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
It is no need to destroy since I will reuse it later...

Never mind, I am going to recode it.
 

FhelZone

Have a drink of a nice cold mellowberry juice!
Reaction score
103
Nice spell, though why would a watery creature enjoy a fiery snake spell hahahaha.....
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
If you took out those TSA's (And assuming KT2 supports it) you could do this whole spell in it's Conditions.

Does not matter.

loop
exitwhen d.complete_jump == true
call TriggerSleepAction(.0)
endloop

I can't find any solution to overcome it.

Update : Changed a bit in code.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
As previously mentioned:
JASS:
private function JumpCount takes integer i returns integer
    return 2 + i
endfunction

private function DamageCount takes real r returns real
    return (40. * r + 20.) * .8
endfunction

private function ManaCount takes real r returns real
    return (10. * r + 10.) * .8
endfunction

Should all be above the 'DTPH' line.
Also, these could be functions:
JASS:
private constant real PERCENT_INCREASE_PER_JUMP = 20.
private constant real AOE = 475.
private constant real MISSLE_SPEED = 20.

-----
Ahh;
Should've said that this can (Supposedly) cause bugs:
JASS:

You have to use a "== true/false" for "IsUnitType()".
-----
Still didn't explain this:
JASS:
set d.cs = GetTriggerUnit()
set d.target1 = GetTriggerUnit()

-----
You still null 't' which isn't needed.


I didn't actually read through the whole code like last time;
I just responded based off my last comments and found all those things still.
And doing your whole spell in Conditions is faster and safer (But can't have TSA's) .
 
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