Spell Moving Strikes

Chaos_Knight

New Member
Reaction score
39
Moving Strikes

Description : The Blademaster is so quickly with his attack, so he can move incredibly fast behind the target, dealing damage.

Level 1 : Has a 2% Chance to move, And deal 35 damage.
Level 2 : Has a 4% Chance to move, And deal 70 damage.
Level 3 : Has a 6% Chance to move, And deal 105 damage.

MUI/MPI : I Think :p
Leakless : Cant see anything so, yes i suppose
Lagless : ... Of course

Tell me if there is any more bugs, or anythign else.

Code

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"                                           
        /* End Of Attachments*/
        //----------------------------------------------------------------------------------------------+
        private constant string EFFECTPOS = "origin"                                                    
        //----------------------------------------------------------------------------------------------+
        /* End Of Attachments*/
        /* This "SHOWEFFECT" should be true if you want to see the Special Effects */
        private constant boolean SHOWEFFECT = true                                                      
        //----------------------------------------------------------------------------------------------+
        private constant boolean IS_RANGED = true                                                       
        //----------------------------------------------------------------------------------------------+
        private constant boolean IS_MEELE = true                                                        
        //----------------------------------------------------------------------------------------------+
        /* Color Red of The TextTag*/
        private constant integer RED = 90                                                               
        //----------------------------------------------------------------------------------------------+
        /* Color Green of the TextTag*/
        private constant integer GREEN = 0
        //----------------------------------------------------------------------------------------------+
        /* Color Blue of the TextTag*/
        private constant integer BLUE = 110                                                             
        //----------------------------------------------------------------------------------------------+
        /* 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 1.*/
        //----------------------------------------------------------------------------------------------+
        /* 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 = 'A000'                                                            
        //----------------------------------------------------------------------------------------------+
            //| E N D |
            //| O F |
            //| C O N I F I G U R A B L E S|
    endglobals
        
    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(GetTriggerUnit() , GetOwningPlayer(GetEventDamageSource())) and GetRandomInt(0, 100) <= CHANC(GetUnitAbilityLevel(GetEventDamageSource(), ID)) and not IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and GetUnitAbilityLevel(GetEventDamageSource() , ID) > 0
    endfunction    

        
        private function Moving takes nothing returns nothing
            local unit u = GetEventDamageSource()
            local unit t = GetTriggerUnit()
            local real x1 = GetUnitX( u ) /* A Units X Position */
            local real y1 = GetUnitY( u ) /* A Units Y Position */
            local real x2 = GetUnitX( t ) /* A Units X Position */
            local real y2 = GetUnitY( t ) /* A Units Y Position */
            local real angle = Atan2(y2 - y1, x2 - x1)
            local texttag TT = CreateTextTag()
            
            if SHOWEFFECT then 
                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))
            endif
               if SHOWDAMAGE then
                    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 , x2 + FROMTARGET * Cos(angle))
            call SetUnitY( u , y2 + FROMTARGET * Sin(angle))
            call Damage_EnableEvent(false)
            call UnitDamageTarget( 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 Damage_RegisterEvent(tr)
    call TriggerAddCondition( tr , Condition(function Cons))
    call TriggerAddAction( tr , function Moving)
    set tr = null
endfunction

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

Screenies:

Very Bad Screenie. I dont know how to take a good screenie at a Istant spell.

Updates
Update 1.0 : Release
Update 1.1 : Much changing in the code. No callbacks. Nulled everything i think.. :p
New Terrain: Thanks Tinki3
Update 1.2 : New Code. Thanks to SineCosine
Update 1.3 : You can now change the Chance and Damage in the globals.
Update 1.4 : This update was from Laiev. If you are using this spell, give him credits.
Update 1.5 : Even more from Laiev. No need to give me credits.. :(. Laiev could have made this spell twice better. I delete it..
Update 1.6 : Changed the Texttag string.
Update 1.7 : Another if. SIX Sfxs. More globals.
BIG UPDATE: Maked this to use Damage. Now you cant abuse this anymore with the "Stop" action. As said, big update.
UPDATE 1.9 : MUCH MORE COMMENTS! Nulled Trigger, as Jedi told me. :D Yay!
//Chaos_Knight
 

Attachments

  • Moving Strikes NewVer.w3x
    75.2 KB · Views: 338

uberfoop

~=Admiral Stukov=~
Reaction score
177
-Damage amount is declared twice in code, once as 25*level and once as 25.21*level
-Furthermore, this damage value should probably be handled as a constant above the main code
-[ljass]private function True[/ljass] included in code and never used
-Boatloads of agent locals aren't being nulled in the Attack, TextTag, and Move functions
-The Attack, TextTag, Move, and Moving functions could probably all be the same function; it would be a long single run but certainly superior to extra function calls and all these variable redeclarations
-[ljass]EVENT_PLAYER_UNIT_ATTACKED[/ljass] is sometimes flawed for these sort of applications; it initiates on the begining of the attack animation rather than when the attack damages the target. It might not matter that much in this case because of the movement, but it's something to consider.
-Uses an overcomplicated chance structure for no apparant reason
-Arbitrarily excludes heroes from being targets in the condition function for no apparant reason
 

Laiev

Hey Listen!!
Reaction score
188
JASS:
 private function True takes nothing returns boolean
        return true
    endfunction

you don't need it... return leak don't exist anymore.. also you don't use it LOL


JASS:
private function TextTag takes nothing returns nothing
        local unit u = GetAttacker()
        local texttag TT = CreateTextTag()
endfunction


forget to null?


JASS:
private function Attack takes nothing returns nothing
        local unit u = GetAttacker()
        local unit t = GetTriggerUnit()
        local real dmg = 25.21 * GetUnitAbilityLevel( u ,ID )
        call UnitDamageTarget( u , t , dmg , true , true , ATTACK_TYPE_CHAOS , DAMAGE_TYPE_FIRE , WEAPON_TYPE_WHOKNOWS )
    endfunction


forget to null?[2]
and unconfigurable damage? bad... much bad :(



JASS:
private function Moving takes nothing returns nothing
        local unit u = GetAttacker()
        local unit t = GetTriggerUnit()
        local real dmg = 25 * GetUnitAbilityLevel( u , ID )
        call DestroyEffect(AddSpecialEffectTarget(EFFECT, u, EFFECT_POSITION))
        call DestroyEffect(AddSpecialEffectTarget(EFFECT2, u, EFFECTPOSITION))
        call Move()
        call TextTag()
        call Attack()
        set u = null
        set t = null
    endfunction


[ljass]local real dmg = 25 * GetUnitAbilityLevel( u , ID )[/ljass] for what?




Suggestions: use a boolean to check if the editor want the text slow or don't.. i really don't like it..

Use Damage by Jesus4Lyf, is REALLY easy and REALLY good...

your % chance is too confuse and unnecessarily

use a full function, instead 3 callbacks
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
JASS:
private constant function DMG takes integer Lvl returns integer
        return 50 * Lvl
endfunction

still unconfigurable damage

ATTACK_TYPE, DAMAGE_TYPE and offset from target are also unconfigurable

JASS:
private function Cons takes nothing returns boolean
      return IsPlayerEnemy(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetAttacker())) and GetRandomInt(0, 100) <= CHANCE(GetUnitAbilityLevel(GetAttacker(), ID)) and IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == false and GetUnitAbilityLevel(GetAttacker(), ID) > 0
endfunction

too many calls of the same function...

use this:
JASS:
private function Cons takes nothing returns boolean
      local unit caster = GetAttacker()
      local unit target = GetTriggerUnit()
      local player p = GetOwningPlayer(target)
      local real level = GetUnitAbilityLevel(caster, ID)
      local boolean b = false
      if IsUnitEnemy(caster, p) and GetRandomInt(0, 100) <= CHANCE(level) and IsUnitType(target, UNIT_TYPE_HERO) == false and level > 0 then
          set b = true
      endif
      set caster = null
      set target = null
      set p = null
      return b
endfunction


overall, I think the spell is too simple...
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
Okay, How do i make the Damage configurable?

JASS:
globals
      // The effect created on the target when it is being possessed:
      private constant string EFFECT = "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl"
      private constant string EFFECT2 = "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl"
      // Which is attached to the targets:
      private constant string EFFECT_POSITION = "weapon,left"
      private constant string EFFECTPOSITION = "hand,right"
      //Your Damage Dealt. Change To what you want
      // The Raw code of the ability
      private constant integer ID = 'A000'

      private constant DAMAGE = 50.
endglobals
   
private constant function DMG takes integer Lvl returns integer
        return DAMAGE * Lvl
endfunction


just replace all raw values with constant globals to make something "configurable"
 

Chaos_Knight

New Member
Reaction score
39
JASS:
globals
      // The effect created on the target when it is being possessed:
      private constant string EFFECT = "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl"
      private constant string EFFECT2 = "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl"
      // Which is attached to the targets:
      private constant string EFFECT_POSITION = "weapon,left"
      private constant string EFFECTPOSITION = "hand,right"
      //Your Damage Dealt. Change To what you want
      // The Raw code of the ability
      private constant integer ID = 'A000'

      private constant DAMAGE = 50.
endglobals
   
private constant function DMG takes integer Lvl returns integer
        return DAMAGE * Lvl
endfunction


just replace all raw values with constant globals to make something "configurable"


Thanks!
 

Laiev

Hey Listen!!
Reaction score
188
JASS:
private function Cons takes nothing returns boolean
      local unit u = GetAttacker()
      local unit t = GetTriggerUnit()
      local player p = GetOwningPlayer(u)
      local integer level = GetUnitAbilityLevel(u , ID)
      local boolean b = false
      if IsUnitEnemy( t , p ) and GetRandomInt(0, 100) <= CHANCE(level) and IsUnitType(t, UNIT_TYPE_HERO) == false and level > 0 then
        set b = true
      endif
      return b
endfunction


could be

JASS:
private function Cons takes nothing returns boolean
    return IsUnitEnemy(GetTriggerUnit() , GetOwningPlayer(GetAttacker())) and GetRandomInt(0, 100) <= CHANCE(GetUnitAbilityLevel(GetAttacker(), ID)) and not IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and GetUnitAbilityLevel(GetAttacker() , ID) > 0
endfunction


also you leak in that condition... don't null local variables = leaks


JASS:
private function Moving takes nothing returns nothing
        local unit u = GetAttacker()
        local unit t = GetTriggerUnit()
        local real x1 = GetUnitX( u )
        local real y1 = GetUnitY( u )
        local real x2 = GetUnitX( t )
        local real y2 = GetUnitY( t )
        local real angle = Atan2(y2 - y1, x2 - x1)
        local texttag TT = CreateTextTag()
        call DestroyEffect(AddSpecialEffectTarget(EFFECT, u, EFFECT_POSITION))
        call DestroyEffect(AddSpecialEffectTarget(EFFECT2, u, EFFECTPOSITION))
            call SetTextTagText (TT, "Damage Dealt = " + R2S(DMG(GetUnitAbilityLevel(u, ID))) + ".", 0.023)
            call SetTextTagPosUnit (TT, u, 10 )
            call SetTextTagColor (TT, 90, 0, 110, 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)
        call SetUnitX( u , x2 + 128 * Cos(angle))
        call SetUnitY( u , y2 + 128 * Sin(angle))
        call UnitDamageTarget( u , t , DMG(GetUnitAbilityLevel(u, ID))  , true , true , ATTACK_TYPE_CHAOS , DAMAGE_TYPE_FIRE , WEAPON_TYPE_WHOKNOWS )
        set u = null
        set TT = null
        set t = null
    endfunction


can be
JASS:
private function Moving takes nothing returns nothing
        local unit u = GetAttacker()
        local unit t = GetTriggerUnit()
        local real x1 = GetUnitX( u )
        local real y1 = GetUnitY( u )
        local real x2 = GetUnitX( t )
        local real y2 = GetUnitY( t )
        local real angle = Atan2(y2 - y1, x2 - x1)
        local texttag TT = CreateTextTag()

        call DestroyEffect(AddSpecialEffectTarget(EFFECT, u, EFFECT_POSITION))
        call DestroyEffect(AddSpecialEffectTarget(EFFECT2, u, EFFECTPOSITION))

        if SHOW_DAMAGE then
            call SetTextTagText (TT, "Damage Dealt = " + R2S(DMG(GetUnitAbilityLevel(u, ID))) + ".", 0.023)
            call SetTextTagPosUnit (TT, u, 10 )
            call SetTextTagColor (TT, 90, 0, 110, 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 , x2 + 128 * Cos(angle))
        call SetUnitY( u , y2 + 128 * Sin(angle))
        call UnitDamageTarget( u , t , DMG(GetUnitAbilityLevel(u, ID))  , true , true , ATTACK_TYPE, DAMAGE_TYPE , WEAPON_TYPE )

        set u = null
        set TT = null
        set t = null
    endfunction



new globals
JASS:
private constant boolean SHOW_DAMAGE = true //set false to don't show text
private constant attacktype  ATTACK_TYPE = ATTACK_TYPE_CHAOS 
private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_FIRE
private constant weapontype WEAPON_TYPE = WEAPON_TYPE_WHOKNOWS


if you want... configure the range option in the damage function :)
 

Chaos_Knight

New Member
Reaction score
39
@Laiev:

Thanks, im updating right now.

EDIT:

if you want... configure the range option in the damage function

Like a [ljass]private consant function[/ljass]

??
 

Nherwyziant

Be better than you were yesterday :D
Reaction score
96
How about a native for this part? Sorry I don't really like BJs.

[ljass]TriggerRegisterAnyUnitEventBJ[/ljass]

and

[lJASS]"Damage Dealt = " + R2S(DMG(GetUnitAbilityLevel(u, ID))) + "."[/lJASS]
That's kinda childish. Kinda annoying too.
I more like this line
[ljass]R2S(DMG(GetUnitAbilityLevel(u, ID))) + "!"[/ljass]
Anyways, nice simple spell.
 

tooltiperror

Super Moderator
Reaction score
231
No need for such a basic spell to be approved.

Sorry, but needs to be said.
 
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