Spell Wild Axes

Trollvottel

never aging title
Reaction score
262
Well i haven't worked with the world editor for some time, so i'm a bit rusty. But here is the Wild Axes spell.

vJass: YES
MUI: Sure
Leakless: Yes, AFAIK
Lagless: Depends on what you do with my spell
Needs TT: Yes like each of my spells ^^.

Description:
Rexxar hurls his two axes outward, which then intersect and return to him. Each axe can only damage a unit twice.
* Its a remake of the DotA spell

Screenshot
(looks better ingame):
scr1cn7.jpg

Code( you wont like it...):
JASS:
scope WildAxes initializer InitTrig

//==========================================WILD AXES BY TROLLVOTTEL==========================================\\
// WHAT WILL IT DO:
//      * It will throw two axes to the target location, they will fly with a nice parabola and then come back.
//      * If they hit enemy units they will damage them, the axes can hit a unit twice.
//      * you can also knockback units if you have a knockback system, since the function to call on each unit
//        is below, its called DoStuff. So you can do many things with the units.
//
// IMPORT INSTRUCTIONS:
//      * Import the ability and the unit into your map.
//      * If you haven't it already, copy the TT trigger into your map.
//      * Copy in this trigger into your map.
//      * Change the constants below (the rawcodes will be different in different maps).
//=============================================================================================================\\
globals
    private constant integer DUMMYRAW = 'h000' // Dummy Axe raw code
    private constant integer SPELLRAW = 'A000' // Spell raw code
    private constant real DEGSPS = 128.        // degrees per second to fly by the axes
    private constant real RADIUS = 150.        // radius of the curve on the y-axis
    private constant real PICKRADIUS = 128.    // radius to pick and damage units
endglobals

// so you have the caster unit, with the name caster and the picked unit with the name victim
// do whatever want to do with them
private function DoStuff takes unit caster, unit victim returns nothing
    local real damage = 100 + GetUnitAbilityLevel(caster, SPELLRAW) * 50
    // put in you conditions here:
    if GetWidgetLife(victim) > .405 and IsUnitEnemy(caster, GetOwningPlayer(victim)) and IsUnitType(victim, UNIT_TYPE_STRUCTURE) != true then
        // put in your stuff here:
        // for example damage it:
        call UnitDamageTarget(caster, victim, damage, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
        // and add a blood effect to it:
        call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl", victim, "origin"))
    endif
endfunction

//--------------------------------------
//dont edit below//

private struct Axes
    unit Axe1
    unit Axe2
    unit caster
    real incr = 0
    real xrad
    real turnang
    real cenx
    real ceny
    real tx
    real ty
    group victims = CreateGroup()
        method onDestroy takes nothing returns nothing
            //remove leaks and remove units
            call DestroyGroup(.victims)
            call KillUnit(.Axe1)
            call KillUnit(.Axe2)
            call ShowUnit(.Axe1, false)
            call ShowUnit(.Axe2, false)
        endmethod
endstruct
                                                                                                                            
private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == SPELLRAW
endfunction

globals
    private unit CASTER
    private group TEMPGROUP
endglobals

private function FilterFunc takes nothing returns boolean
    local unit u = GetFilterUnit()
    
    // every unit can be only damaged twice
    if not IsUnitInGroup(u, TEMPGROUP) then
        call DoStuff(CASTER, u)
        call GroupAddUnit(TEMPGROUP, u)
    endif
    set u = null
    return false
endfunction


private function SendBack takes nothing returns boolean
    local Axes dat = TT_GetData()
    local real nx
    local real ny
    local real dx
    local real dy
    local real cx = GetUnitX(dat.caster)
    local real cy = GetUnitY(dat.caster)
    local real cenx
    local real ceny
    local real angle
    local real distance
    local real newangle
    local real radius
    local real turnang
    local group g 
    
    set dat.incr = dat.incr - DEGSPS*TT_PERIOD
    
    if dat.incr <= 0 then
        //after reaching the caster, the Axes disappear
        call dat.destroy()
        return true
    endif
    
    
    //since the axe is flying towards the caster, we cant use constants like below in the targetfly function
    
    //get center between spell-point and caster-position
    set cenx            = ( cx + dat.tx ) / 2
    set ceny            = ( cy + dat.ty ) / 2
    
    //delta
    set dx              = dat.tx - cx
    set dy              = dat.ty - cy
    
    //distance and angle
    set turnang         = Atan2     ( dy, dx )
    set distance        = SquareRoot( dx * dx + dy * dy )
    set radius          =        distance / 2
    
        //! textmacro MoveBack takes NUMBER, PLUSMIN
        set g = CreateGroup()
        //getting the normal position
        set newangle    = 180 $PLUSMIN$ dat.incr
        set nx          = cenx  + radius        * Cos(newangle * bj_DEGTORAD)
        set ny          = ceny  + RADIUS        * Sin(newangle * bj_DEGTORAD)
        set dx          = nx    - cenx
        set dy          = ny    - ceny
        
        set angle       = Atan2     ( dy, dx )      + turnang
        set distance    = SquareRoot( dx * dx + dy * dy )
        //turning point around the location(cenx,ceny)
        set nx          = cenx + distance       * Cos(angle)
        set ny          = ceny + distance       * Sin(angle)
        
        //moving unit
        call SetUnitX(dat.Axe$NUMBER$, nx)
        call SetUnitY(dat.Axe$NUMBER$, ny)
        call SetUnitFacing(dat.Axe$NUMBER$, angle*bj_RADTODEG $PLUSMIN$ 90.)
        // picking units
        set CASTER      = dat.caster
        set TEMPGROUP   = dat.victims
        call GroupEnumUnitsInRange  ( g, nx, ny, PICKRADIUS, Condition( function FilterFunc ) )
        call GroupAddGroup          ( g, dat.victims )
        call DestroyGroup           ( g )
        set g           = null
        //! endtextmacro
    
    //i put everything in a textmakro for better readability
    //! runtextmacro MoveBack("1", "+")
    //! runtextmacro MoveBack("2", "-")
    
    return false
endfunction

private function TargetFly takes nothing returns boolean
    local Axes dat = TT_GetData()
    local real nx
    local real ny
    local real dx
    local real dy
    local real angle
    local real distance
    local real newangle
    local group g 
    set dat.incr        = dat.incr + DEGSPS*TT_PERIOD
    
    if dat.incr >= 180. then
        //if the axes have reached their destination, they come back
        call TT_Start   ( function SendBack, dat )
        call GroupClear ( dat.victims )
        return true
    else
            set g = CreateGroup()
            
            //! textmacro Move takes NUMBER, PLUSMIN
            
            //getting the normal position
            set newangle    = 180       $PLUSMIN$ dat.incr
            set nx          = dat.cenx  + dat.xrad      * Cos(newangle * bj_DEGTORAD)
            set ny          = dat.ceny  + RADIUS        * Sin(newangle * bj_DEGTORAD)
            set dx          = nx        - dat.cenx
            set dy          = ny        - dat.ceny
            
            set angle       = Atan2     ( dy, dx )      + dat.turnang
            set distance    = SquareRoot( dx * dx + dy * dy )
            //turning point around the location(cenx,ceny)
            set nx          = dat.cenx + distance       * Cos(angle)
            set ny          = dat.ceny + distance       * Sin(angle)
            
            //moving unit
            call SetUnitX(dat.Axe$NUMBER$, nx)
            call SetUnitY(dat.Axe$NUMBER$, ny)
            call SetUnitFacing(dat.Axe$NUMBER$, angle*bj_RADTODEG $PLUSMIN$ 90.)
            
            // picking units
            set CASTER      = dat.caster
            set TEMPGROUP   = dat.victims
            call GroupEnumUnitsInRange  ( g, nx, ny, PICKRADIUS, Condition( function FilterFunc ) )
            call GroupAddGroup          ( g, dat.victims )
            call DestroyGroup           ( g )
            set g           = null
            //! endtextmacro
            
        //i put everything in a textmakro for better readability
        //! runtextmacro Move("1", "+")
        //! runtextmacro Move("2", "-")
        
    endif
    
    
    return false
endfunction                                                                                                                            
private function Actions takes nothing returns nothing
    local Axes dat      = Axes.create       (               )
    local unit ca       = GetTriggerUnit    (               )
    local real cx       = GetUnitX          ( ca            )
    local real cy       = GetUnitY          ( ca            )
    local location sp   = GetSpellTargetLoc (               )
    local real tx       = GetLocationX      ( sp            )
    local real ty       = GetLocationY      ( sp            )
    local real dy       = ty-cy
    local real dx       = tx-cx
    local real angle    = Atan2             ( dy, dx        )
    local real distance = SquareRoot        ((dx*dx)+(dy*dy))
    local player p      = GetOwningPlayer   ( ca            )
    
    // angle between the caster and the spell target point (in radians)
    set dat.turnang = angle
    
    // create the units
    set dat.Axe1    = CreateUnit( p, DUMMYRAW, cx, cy, angle * bj_RADTODEG )
    set dat.Axe2    = CreateUnit( p, DUMMYRAW, cx, cy, angle * bj_RADTODEG )
    
    // the radius (on the x-axis)
    set dat.xrad    = distance / 2.
    
    // get center point between caster and spell target point
    set dat.cenx    = (cx+tx)  / 2.
    set dat.ceny    = (cy+ty)  / 2.
    
    // pass some variables which are needed later
    set dat.tx      = tx
    set dat.ty      = ty
    set dat.caster  = ca
    
    // start the movement
    call TT_Start( function TargetFly, dat )
    
    call RemoveLocation(sp)
    
    set sp          = null
    set ca          = null
endfunction

//===========================================================================
private function InitTrig takes nothing returns nothing
    local trigger t  = CreateTrigger(  )
    call TriggerAddAction               ( t,            function Actions      )
    call TriggerAddCondition            ( t, Condition( function Conditions ) )
    call TriggerRegisterAnyUnitEventBJ  ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT   )
endfunction

endscope
Before i forget, please post comments :) (and if you want, you can also +rep me :p)

And, finally, the map:
 

Attachments

  • WildAxes.w3x
    50.3 KB · Views: 318

Trollvottel

never aging title
Reaction score
262
im glad that you like it :)

well, any other comments? any bugs found? any way to make the coding more efficent?
 
A

Andy

Guest
Wow. Been after something liket his for ages. Thanks!

By the way, in your ability tooltip for learning, it says "lear Wild Axes" instead of "Learn Wild Axes" :p
 

waaaks!

Zinctified
Reaction score
255
emjlr3 already made wild axes, black hole, and toss in one spellpack, but i think he didnt release it on public

gj with this
 

Arie

Cool Member
Reaction score
5
Hmm... Still confusing me.:confused:

Would you mind to give me another example ? if those enemies are hit by the axe, the enemies will get bloodlust.
 

Trollvottel

never aging title
Reaction score
262
oh weird >.< yeah... well it doesnt exist anymore and the code is removed..

@arie:

do you have any basic jass knowledge? it would make the things easier.
 

emjlr3

Change can be a good thing
Reaction score
395
i guess this boils down to whether there is a need for a 3rd one of these

this is really in no way better then mine(which isn't perfect by any means), therefore, especially considering they both use TT, I see no reason to approve this
 

Trollvottel

never aging title
Reaction score
262
actually its the second one since the GUI version is graveyarded and there isnt a map nor a code. And this Wild Axes spell is a bit more flexible since the user isnt restricted to let the axes damage hit units, they can also knockback, toss, etc..
But, if you dont want to you dont have to approve this and since you dont want to, you wont.
 

emjlr3

Change can be a good thing
Reaction score
395
its not easier to do so in your version then mine, aside from the location of your function in relation to the rest
 

Tukki

is Skeleton Pirate.
Reaction score
29
This one is 'better' as its parabola looks better eye-candy-wise.

You can also reduce the number of devisions by 2 (x/2) by multiplying with 0.5 instead. You wont notice it in-game, but its still good effiency-wise. Else good job on this!
 

emjlr3

Change can be a good thing
Reaction score
395
its the same bezier curve equation....which is completely configurable, as far as the arc is concerned
 

Tukki

is Skeleton Pirate.
Reaction score
29
yeah, if the user is interested in figuring out what looks best.
 

emjlr3

Change can be a good thing
Reaction score
395
thats sort of the point of configuration no?
 

Tukki

is Skeleton Pirate.
Reaction score
29
Yeah, changing values if they are wrong/not as you like them. But that doesn't mean they should be strange from the beginning, right?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top