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:
Screenshot(looks better ingame):
Code( you wont like it...):
Before i forget, please post comments (and if you want, you can also +rep me )
And, finally, the map:
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
* Its a remake of the DotA spell
Screenshot(looks better ingame):
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 = 039;h000039; // Dummy Axe raw code
private constant integer SPELLRAW = 039;A000039; // 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
And, finally, the map: