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: 783
  • 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
963
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

      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