Moving Strikes( New Big Update Help )

Chaos_Knight

New Member
Reaction score
39
Okay, ive started to make a BIG update to my spell.
JASS:
library MovingStrike initializer Init requires Damage
// +-------------------------------------------------------------------------------+
// |     Moving Strikes - Created by Chaos_Knight.  Requires a vJass preprocessor! |   
// +-------------------------------------------------------------------------------+
// | Gives a chance to move the attacker behind the unit which is attacked,        |
// | and deal damage.                                                              |
// +-------------------------------------------------------------------------------+
// | How to Import:                                                                |
// |  - Create a new trigger                                                       |
// |  - Convert it to Custom text (Edit > Convert to Custom Text)                  |
// |  - Replace everything there with this code                                    |
// |  - Change the constants to suit yourself                                      |
// |  - Enjoy!                                                                     |
// +-------------------------------------------------------------------------------+

// |-------------|
// | Constants:  |
// |-------------|
    globals
        /*Model*/
        //----------------------------------------------------------------------------------------------+
        private constant string EFFECT = "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl" 
        //----------------------------------------------------------------------------------------------+
        private constant string EFFECT2 = "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl"     
        //----------------------------------------------------------------------------------------------+
        private constant string EFFECT3 = "Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl"
        //----------------------------------------------------------------------------------------------+
        private constant string EFFECT4 = "Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl"               
        //----------------------------------------------------------------------------------------------+
        private constant string EFFECT6 = "Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl"    
        /*End of Model Editing*/
        /*Attached To? */
        //----------------------------------------------------------------------------------------------+
        private constant string EFFECT_POSITION = "weapon,left"                                         
        //----------------------------------------------------------------------------------------------+
        private constant string EFFECTPOSITION = "hand,right"                                           
        //----------------------------------------------------------------------------------------------+
        private constant string EFFECTPOS = "origin"                                                    
        //----------------------------------------------------------------------------------------------+
        /* End Of Attachments*/                                                      
        //----------------------------------------------------------------------------------------------+
        private constant boolean IS_RANGED = true                                                       
        //----------------------------------------------------------------------------------------------+
        private constant boolean IS_MEELE = true
        private constant real DELAYTIME = 0.
        //----------------------------------------------------------------------------------------------+
        /* Color Red of The TextTag*/
        private constant integer RED = 255                                                               
        //----------------------------------------------------------------------------------------------+
        /* Color Green of the TextTag*/
        private constant integer GREEN = 0
        //----------------------------------------------------------------------------------------------+
        /* Color Blue of the TextTag*/
        private constant integer BLUE = 0                                                             
        //----------------------------------------------------------------------------------------------+
        /* Visibilty of the TextTag*/
        private constant integer ALPHA = 255                                                            
        //----------------------------------------------------------------------------------------------+
        /* If true, shows the texttag*/
        private constant boolean SHOWDAMAGE = true                                                      
        //----------------------------------------------------------------------------------------------+
        /*Damage dealt * The unit ability lvl*/
        private constant integer DAMAGE = 35                                                            
        //----------------------------------------------------------------------------------------------+
        /* Chance of triggering this trigger*/
        private constant integer CHANCE = 100
        /* 100% chance is for testing purposes. If you dont want this to be imba, have it on 2.*/
        //----------------------------------------------------------------------------------------------+
        /* How Long Moving */
        private constant integer FROMTARGET = 128                                                       
        //----------------------------------------------------------------------------------------------+
        /* Attack Type */
        private constant attacktype AtkType = ATTACK_TYPE_CHAOS                                         
        //----------------------------------------------------------------------------------------------+
        /* Damage Type */
        private constant damagetype DmgType = DAMAGE_TYPE_FIRE                                          
        //----------------------------------------------------------------------------------------------+
        /* Weapon Type */
        private constant weapontype WepType = WEAPON_TYPE_WHOKNOWS                                      
        //----------------------------------------------------------------------------------------------+
        /* Your spells ID */
        private constant integer ID = 'A002'
        private constant integer SPELLID = 'A003'
        private constant integer ADDIDSPELLBOOK = 'A001'
        //----------------------------------------------------------------------------------------------+
            //| E N D |
            //| O F |
            //| C O N I F I G U R A B L E S|
            unit u = GetEventDamageSource()
            unit t = GetTriggerUnit()
            player playcast = GetOwningPlayer( u )
    endglobals
    
    private constant function DELAY takes integer LvL returns real
        return 0.5 * LvL * LvL + 4.5 * LvL + 7
    endfunction
    
    private constant function CHANC takes integer level returns integer
        return CHANCE * level
    endfunction
    
    private constant function DMG takes integer Lvl returns integer
        return DAMAGE * Lvl
    endfunction
// |------------------|
// | End of Constants |
// |------------------|

// DO NOT EDIT BELOW THIS LINE!
    
    private function Cons takes nothing returns boolean
        return IsUnitEnemy(u , playcast) /*
        */and GetRandomInt(0, 100) <= CHANC(GetUnitAbilityLevel(u, ID)) /*
        */and not IsUnitType(t, UNIT_TYPE_HERO) /*
        */and GetUnitAbilityLevel(u , ID) > 0 /*
        */and Damage_IsAttack() == TRUE
    endfunction

    
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A003'
    endfunction
    
    private function ActionsAddSpell takes nothing returns nothing
        call UnitAddAbility( u , ADDIDSPELLBOOK )
        call BJDebugMsg("Ability Added")
        call SetUnitAbilityLevel( u , SPELLID , GetUnitAbilityLevel( u , ID ))
        call SetPlayerAbilityAvailable( playcast , ADDIDSPELLBOOK , false )
        call TriggerSleepAction(DELAY(GetUnitAbilityLevel(u , ID )))
        call UnitRemoveAbility( u , ADDIDSPELLBOOK)
    endfunction
    
        private function Moving takes nothing returns nothing
            local real CasterX = GetUnitX( u )
            local real CasterY = GetUnitY( u )
            local real TargetX = GetUnitX( t )
            local real TargetY = GetUnitY( t )
            local real angle = Atan2(TargetY - TargetY, CasterX - CasterY)
            local texttag TT
            
                call DestroyEffect(AddSpecialEffectTarget(EFFECT, u, EFFECT_POSITION))
                call DestroyEffect(AddSpecialEffectTarget(EFFECT2, u, EFFECTPOSITION))
                call DestroyEffect(AddSpecialEffectTarget(EFFECT3, t, EFFECTPOS))
                call DestroyEffect(AddSpecialEffectTarget(EFFECT4, t, EFFECTPOS))
                call DestroyEffect(AddSpecialEffectTarget(EFFECT6, t, EFFECTPOS))
                
                static if SHOWDAMAGE then
                    set TT = CreateTextTag()
                    call SetTextTagText (TT,R2S(DMG(GetUnitAbilityLevel(u, ID))) + "!", 0.023)
                    call SetTextTagPosUnit (TT, u, 10 )
                    call SetTextTagColor (TT, RED, GREEN, BLUE, 255 )
                    call SetTextTagVelocity (TT, 0.0355 * Cos(90. * bj_DEGTORAD), 0.0355 * Sin(90. * bj_DEGTORAD))
                    call SetTextTagVisibility (TT, true)
                    call SetTextTagFadepoint (TT, 2.00)
                    call SetTextTagLifespan (TT, 2.00)
                    call SetTextTagPermanent (TT, false)
                endif
            call SetUnitX( u , CasterX + FROMTARGET * Cos(angle))
            call SetUnitY( u , CasterY + FROMTARGET * Sin(angle))
            call Damage_EnableEvent(false)
            call UnitDamageTargetEx( u , t , DMG(GetUnitAbilityLevel(u, ID))  , IS_RANGED , IS_MEELE , AtkType , DmgType , WepType )
            call Damage_EnableEvent(true)
        set u = null
        set TT = null
        set t = null
    endfunction
  
  
//------------------------------------------------------------------  
private function Init takes nothing returns nothing
    local trigger tr = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( tr , EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition( tr , Condition( function Conditions))
    call TriggerAddAction( tr , function ActionsAddSpell)
    
    call Damage_RegisterEvent(tr)
    call TriggerAddCondition( tr , Condition(function Cons))
    call TriggerAddAction( tr , function Moving)
    set tr = null
endfunction

//----------------------+
//END OF MOVING STRIKES |
//----------------------+
endlibrary


It's now active, and it dont work. The ActionsAddSpell, can also be the problem. I also have checked up all id IDs of the spells. They are right.
Thanks for your help.

//Chaos_Knight

PS: Laiev and BlackRose, this is just the start...
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
JASS:
library MovingStrike initializer Init requires Damage
// +-------------------------------------------------------------------------------+
// |     Moving Strikes - Created by Chaos_Knight.  Requires a vJass preprocessor! |   
// +-------------------------------------------------------------------------------+
// | Gives a chance to move the attacker behind the unit which is attacked,        |
// | and deal damage.                                                              |
// +-------------------------------------------------------------------------------+
// | How to Import:                                                                |
// |  - Create a new trigger                                                       |
// |  - Convert it to Custom text (Edit > Convert to Custom Text)                  |
// |  - Replace everything there with this code                                    |
// |  - Change the constants to suit yourself                                      |
// |  - Enjoy!                                                                     |
// +-------------------------------------------------------------------------------+

// |-------------|
// | Constants:  |
// |-------------|
    globals
        //----------------------------------------------------------------------------------------------+
        /* Your spells ID */
        private constant integer ID = 'A000'
        //----------------------------------------------------------------------------------------------+
        /*Model*/   
        //----------------------------------------------------------------------------------------------+
        private constant string EFFECT = "Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl"    
        //----------------------------------------------------------------------------------------------+   
        private constant string CASTER_EFFECT = "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageCaster.mdl"
        /*Attached To? */
        //----------------------------------------------------------------------------------------------+
        private constant string EFFECTPOS = "origin"                                                    
        //----------------------------------------------------------------------------------------------+
        /* Color Red of The TextTag*/
        private constant integer RED = 0                                                            
        //----------------------------------------------------------------------------------------------+
        /* Color Green of the TextTag*/
        private constant integer GREEN = 0
        //----------------------------------------------------------------------------------------------+
        /* Color Blue of the TextTag*/
        private constant integer BLUE = 255                                                         
        //----------------------------------------------------------------------------------------------+
        /* Visibilty of the TextTag*/
        private constant integer ALPHA = 255                                                            
        //----------------------------------------------------------------------------------------------+
        /* If true, shows the texttag*/
        private constant boolean SHOW_DAMAGE = true                                                                                                          
        //----------------------------------------------------------------------------------------------+
        private constant boolean CASTER_ANIMATION = true
        /* Attack Type */
        private constant attacktype ATTACK_TYPE = ATTACK_TYPE_NORMAL                                        
        //----------------------------------------------------------------------------------------------+
    endglobals
    
    private constant function Chance takes integer lvl returns integer
        return 10 * lvl
    endfunction
    
    private constant function Damage takes integer lvl returns real
        return 50. * lvl
    endfunction
    
// |------------------|
// | End of Constants |
// |------------------|

// DO NOT EDIT BELOW THIS LINE!
    
    private function Actions takes nothing returns nothing
        local unit caster = GetEventDamageSource()
        local unit target = GetTriggerUnit()
        local real cx = GetUnitX(caster)
        local real cy = GetUnitY(caster)
        local real tx = GetUnitX(target)
        local real ty = GetUnitY(target)
        local real dx = tx - cx
        local real dy = ty - cy
        local real angle = Atan2(dy,dx)
        local texttag text
        local real damage = Damage(GetUnitAbilityLevel(caster, ID))
        local real offset = SquareRoot(dx * dx + dy * dy)
        
        call DestroyEffect(AddSpecialEffect(CASTER_EFFECT,cx,cy))
        call SetUnitX(caster, tx + offset * Cos(angle))
        call SetUnitY(caster, ty + offset * Sin(angle))
        
        if Damage_Physical(caster,target,Damage,ATTACK_TYPE,false,false) then
            call DestroyEffect(AddSpecialEffectTarget(EFFECT, target, EFFECTPOS))
            
            static if CASTER_ANIMATION then
                call IssueTargetOrder(caster,"attack",target)
                call SetUnitAnimation(caster,"Attack Slam")
            endif
            
            
            static if SHOW_DAMAGE then
                set text = CreateTextTag()
                call SetTextTagText(text,R2S(Damage) + "!", 0.023)
                call SetTextTagPosUnit(text, target, 100.)
                call SetTextTagColor(text, RED, GREEN, BLUE, ALPHA )
                call SetTextTagVelocity(text, 0.0355 * Cos(1.571), 0.0355 * Sin(1.571))
                call SetTextTagVisibility(text, true)
                call SetTextTagFadepoint(text, 2.00)
                call SetTextTagLifespan(text, 2.00)
                call SetTextTagPermanent(text, false)
                set text = null
            endif
        endif
            
        set caster = null
        set target = null
    endfunction
  
  
    private function Cond takes nothing returns boolean
        local unit victim = GetTriggerUnit()
        local unit attacker = GetEventDamageSource()
        if IsUnitEnemy(victim,GetOwningPlayer(attacker)) /*
        */ and GetRandomInt(0, 100) <= Chance(GetUnitAbilityLevel(attacker, ID)) /*
        */ and not IsUnitType(victim, UNIT_TYPE_HERO) /*
        */ and Damage_IsAttack() then
            call Actions()
        endif
        set victim = null
        set attacker = null
        return false
    endfunction
    
//------------------------------------------------------------------  
    private function Init takes nothing returns nothing
        local trigger trig = CreateTrigger()
        call Damage_RegisterEvent(trig)
        call TriggerAddCondition( trig , Condition(function Cond))
    endfunction

//----------------------+
//END OF MOVING STRIKES |
//----------------------+
endlibrary

Revised version for you. :)

For you last post :
1) Stuffs that bring from callback requires you to get them in callback, but not in initialization.
2) (I managed to make your version to work) The effect is overspammed.
3) You didn't put those constants into callback, that's why it is failed.
4) Why you add spellbook for it?
5) Follow naming convention. CONSTANT_GLOBALS, Globals, localVariables.
 

Laiev

Hey Listen!!
Reaction score
188
@kingking
he want it to be active


JASS:
library MovingStrike initializer Init requires Damage
// +-------------------------------------------------------------------------------+
// |     Moving Strikes - Created by Chaos_Knight.  Requires a vJass preprocessor! |   
// +-------------------------------------------------------------------------------+
// | Gives a chance to move the attacker behind the unit which is attacked,        |
// | and deal damage.                                                              |
// +-------------------------------------------------------------------------------+
// | How to Import:                                                                |
// |  - Create a new trigger                                                       |
// |  - Convert it to Custom text (Edit > Convert to Custom Text)                  |
// |  - Replace everything there with this code                                    |
// |  - Change the constants to suit yourself                                      |
// |  - Enjoy!                                                                     |
// +-------------------------------------------------------------------------------+

// |-------------|
// | Constants:  |
// |-------------|
globals

        //Spells ID's ----------------------------------------------------------------------------------+
        private constant integer ID = 'A002'
        private constant integer SPELLID = 'A003' 
        private constant integer ADDIDSPELLBOOK = 'A001' 
        //----------------------------------------------------------------------------------------------+

        //Model ----------------------------------------------------------------------------------------+
        private constant string EFFECT = "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl" 
        private constant string EFFECT2 = "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl"     
        private constant string EFFECT3 = "Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl"
        private constant string EFFECT4 = "Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl"               
        private constant string EFFECT6 = "Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl"    
        //End of Model Editing -------------------------------------------------------------------------+

        //Attached To? ---------------------------------------------------------------------------------+
        private constant string EFFECT_POSITION = "weapon,left"                                         
        private constant string EFFECTPOSITION = "hand,right"                                           
        private constant string EFFECTPOS = "origin"                                                    
        //End Of Attachments ---------------------------------------------------------------------------+
        
        //----------------------------------------------------------------------------------------------+
        private constant boolean IS_RANGED = true //Ranged?
        private constant boolean IS_MELEE = true //Melee?
        private constant real DELAYTIME = 0.
        //----------------------------------------------------------------------------------------------+
        
        //Color of The TextTag -------------------------------------------------------------------------+
        private constant integer RED = 255 //Red Color
        private constant integer GREEN = 0 //Green Color
        private constant integer BLUE = 0 //Blue Color
        //End of Colors --------------------------------------------------------------------------------+
        
        //TextTag Options ------------------------------------------------------------------------------+
        private constant integer ALPHA = 255 //Visibility of the TextTag        
        private constant boolean SHOWDAMAGE = true //Shor the TextTag?
        //----------------------------------------------------------------------------------------------+
        
        private constant integer FROMTARGET = 128 //Maximum distance to 'jump'
        
        //Damage Configuration -------------------------------------------------------------------------+
        private constant integer DAMAGE = 35 //Damage Dealt based on ability level
        private constant attacktype AtkType = ATTACK_TYPE_CHAOS //Attack Type
        private constant damagetype DmgType = DAMAGE_TYPE_FIRE //Damage Type
        private constant weapontype WepType = WEAPON_TYPE_WHOKNOWS //Weapon Type
        
        private constant integer CHANCE = 100 //Chance to trigger
        /* 100% chance is for testing purposes. If you dont want this to be imba, have it on 2.*/
        //----------------------------------------------------------------------------------------------+
        

    //-- Don't Touch This ---------------------------//
        private unit u = GetEventDamageSource()      //
        private unit t = GetTriggerUnit()            //
        private player playcast = GetOwningPlayer(u) //
    //-----------------------------------------------//
endglobals

//----------------------------------------------------------------------//
    private constant function DELAY takes integer LvL returns real      //
        return 0.5 * LvL * LvL + 4.5 * LvL + 7                          //
    endfunction                                                         //
                                                                        //    
    private constant function CHANC takes integer level returns integer //
        return CHANCE * level                                           //
    endfunction                                                         //
                                                                        //
    private constant function DMG takes integer Lvl returns integer     //
        return DAMAGE * Lvl                                             //
    endfunction                                                         //
//----------------------------------------------------------------------//

//------------------------------------------------------------------------------------------------\\
//---------------------------------- DO NOT EDIT BELOW THIS LINE! --------------------------------\\
//------------------------------------------------------------------------------------------------\\

private function Cons takes nothing returns boolean
    return    IsUnitEnemy        (u, playcast      )     /*
    */and     GetRandomInt       (0, 100           ) <= CHANC(GetUnitAbilityLevel(u, ID)) /*
    */and not IsUnitType         (t, UNIT_TYPE_HERO)     /*
    */and     GetUnitAbilityLevel(u, ID            ) > 0 /*Think this should be ADDIDSPELLBOOK instead ID
    */and     Damage_IsAttack    (                 )
endfunction

    
private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == SPELLID
endfunction
    
private function Actions takes nothing returns nothing
    call UnitAddAbility           (u, ADDIDSPELLBOOK)
    call SetUnitAbilityLevel      (u, SPELLID, GetUnitAbilityLevel(u , ID))
    call SetPlayerAbilityAvailable(playcast, ADDIDSPELLBOOK, false)
    call TriggerSleepAction       (DELAY(GetUnitAbilityLevel(u , ID)))
    call UnitRemoveAbility        (u, ADDIDSPELLBOOK)
endfunction
    
private function Moving takes nothing returns nothing
    local real    CasterX = GetUnitX(u)
    local real    CasterY = GetUnitY(u)
    local real    TargetX = GetUnitX(t)
    local real    TargetY = GetUnitY(t)
    local real    angle   = Atan2(TargetY - TargetY, CasterX - CasterY)
    local texttag TT
    
//----------------------------------- Effect -----------------------------------//
    call DestroyEffect(AddSpecialEffectTarget(EFFECT , u, EFFECT_POSITION))     //
    call DestroyEffect(AddSpecialEffectTarget(EFFECT2, u, EFFECTPOSITION))      //
    call DestroyEffect(AddSpecialEffectTarget(EFFECT3, t, EFFECTPOS))           //
    call DestroyEffect(AddSpecialEffectTarget(EFFECT4, t, EFFECTPOS))           //
    call DestroyEffect(AddSpecialEffectTarget(EFFECT6, t, EFFECTPOS))           //
//--------------------------------- End Effect ---------------------------------//
    
//----------------------------------------------- TxtTag -----------------------------------------------//
    static if SHOWDAMAGE then                                                                           //
        set TT = CreateTextTag()                                                                        //
        call SetTextTagText      (TT, R2S(DMG(GetUnitAbilityLevel(u, ID))) + "!", 0.023)                //
        call SetTextTagPosUnit   (TT, u, 10 )                                                           //
        call SetTextTagColor     (TT, RED, GREEN, BLUE, 255 )                                           //
        call SetTextTagVelocity  (TT, 0.0355 * Cos(90. * bj_DEGTORAD), 0.0355 * Sin(90. * bj_DEGTORAD)) //
        call SetTextTagVisibility(TT, true)                                                             //
        call SetTextTagFadepoint (TT, 2.00)                                                             //
        call SetTextTagLifespan  (TT, 2.00)                                                             //
        call SetTextTagPermanent (TT, false)                                                            //
    endif                                                                                               //
//--------------------------------------------- End TextTag --------------------------------------------//
    
    call SetUnitX( u , CasterX + FROMTARGET * Cos(angle))
    call SetUnitY( u , CasterY + FROMTARGET * Sin(angle))
    call Damage_EnableEvent(false)
    call UnitDamageTargetEx(u, t, DMG(GetUnitAbilityLevel(u, ID)), IS_RANGED, IS_MEELE, AtkType, DmgType, WepType)
    call Damage_EnableEvent(true)
    
    set u = null
    set TT = null
    set t = null
endfunction

private function Init takes nothing returns nothing
    local trigger tr = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(tr, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(tr, Condition(function Conditions))
    call TriggerAddAction(tr, function Actions)
    
    set tr = CreateTrigger()
    call Damage_RegisterEvent(tr)
    call TriggerAddCondition(tr, Condition(function Cons))
    call TriggerAddAction(tr, function Moving)
endfunction
endlibrary


bit change, bit fix, bit more order
 

Chaos_Knight

New Member
Reaction score
39
Oh my god. Laiev. I. Like. You. This is awsome, but, now it will become your spell. Thats not really fair.. Sadface :(
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
Q: How many times can you re-write a blink-strike-reminiscent spell?
A: As many times as CK wants, apparently =/
 

Laiev

Hey Listen!!
Reaction score
188
Q: How many times can you re-write a blink-strike-reminiscent spell?
A: As many times as CK wants, apparently =/

omg lol he's learning :(


@Chaos_Knight

o.õ' this work? <don't test... too lazy to create units/abilities>

also i change it to be more beaut and to you see what change and etc :p

OT: CK, waiting for u at skype :rolleyes:
 
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