Tyman2007
Ya Rly >.
- Reaction score
- 74
Well.. I have this issue here. I'm trying to make a spell and am in the process of making it, but for some reason whenever I use the ability, the missle spawns, but does not move an inch. I added in a debug message to keep checking the location of the unit and the location of the unit is changing, but the appearant location is not.
Here's the trigger I'm using. I'm not too good w/ vJass so please bear with me.
Here's the trigger I'm using. I'm not too good w/ vJass so please bear with me.
JASS:
library MagicExplosion initializer Init requires TimerUtils
////////////////////////////////////////////////////////////////////////////////////
// Start of Configuration //
////////////////////////////////////////////////////////////////////////////////////
globals
private constant boolean DMG_ALL = false //Set to true to damage allies AND enemies
private constant integer ABIL_CODE = 039;Axpl039; //Rawcode of the ability
private constant integer DUMM_CODE = 039;h000039; //Rawcode of the missle dummy
private constant real DUMM_OFFSET = 200 //Offset of the missle dummy
private constant string EXPL_STR = "War3Imported\\MagicExplosion.mdl" //Path to the Explosion
private constant real RADIANS = 0.01745 //Real value of 1 radian
private constant real SPD = 0.03125 //Speed of the missle. Change not recommended
private constant boolean ROD = true //Cancels the spell if the caster dies while casting
private constant real MOVE_DIST = 30 //Distance between each move tick of the missle
private constant real RADIUS = 350 //Radius of the blast
private constant real DAMAGE = 100 //+Damage per level
private constant real WAIT_TIME = .5 //Time before the missle is sent
private constant string CAST_ANIM = "Spell" //Animation name of the casting animation
private constant string CHAN_ANIM = "Stand Channel" //Animation name of the channeling animation. Set to "" for no channel animation
endglobals
////////////////////////////////////////////////////////////////////////////////////
// End of Configuration //
////////////////////////////////////////////////////////////////////////////////////
//Function to square a real. I feel it's a bit easier to do Sq(r) than Pow(r, 2)
private function Sq takes real x returns real
return x * x
endfunction
//My distance function. Added to take up space
private function Distance takes real x1, real x2, real y1, real y2 returns real
local real r
set r = SquareRoot(Sq(x2 - x1) + Sq(y2 - y1))
return r
endfunction
private struct Data
unit u
real x
real y
real x2
real y2
real ox
real oy
real angle
real dist
player p
unit dummy
static method create takes unit u, real x2, real y2 returns Data
local Data d = Data.allocate()
local real angle = GetUnitFacing(u)
local real x = GetUnitX(u)
local real y = GetUnitY(u)
set d.x2 = x2
set d.y2 = y2
set d.angle = angle
set d.u = u
set d.dist = Distance(x, x2, y, y2)
set d.x = x
set d.y = y
set d.ox = x + DUMM_OFFSET * Cos(angle * RADIANS)
set d.oy = y + DUMM_OFFSET * Sin(angle * RADIANS)
set d.p = GetOwningPlayer(u)
call PauseUnit(u, true)
call SetUnitAnimation(u, CAST_ANIM)
return d
endmethod
endstruct
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == ABIL_CODE
endfunction
private function Check takes nothing returns boolean
if DMG_ALL == true then
return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0
endif
return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0 and IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetSpellAbilityUnit())) == true
endfunction
private function CallBack takes nothing returns nothing
local Data d = GetTimerData(GetExpiredTimer())
local timer t = GetExpiredTimer()
local real x = GetUnitX(d.dummy)
local real y = GetUnitY(d.dummy)
call BJDebugMsg(R2S(x))
if d.dist > MOVE_DIST then
set d.ox = x + MOVE_DIST * Cos(d.angle * RADIANS)
set d.oy = y + MOVE_DIST * Sin(d.angle * RADIANS)
set d.dist = d.dist - 30
call SetUnitX(d.dummy, d.ox)
call SetUnitY(d.dummy, d.oy)
else
call ReleaseTimer(t)
call SetUnitAnimation(d.u, "Stand")
call PauseUnit(d.u, false)
endif
endfunction
private function Actions takes nothing returns nothing
local location l = GetSpellTargetLoc()
local unit u = GetSpellAbilityUnit()
local real x = GetLocationX(l)
local real y = GetLocationY(l)
local Data d = Data.create(u, x, y)
local timer t = NewTimer()
call RemoveLocation(l)
set d.dummy = CreateUnit(d.p, DUMM_CODE, d.ox, d.oy, d.angle)
call TriggerSleepAction(WAIT_TIME)
if CHAN_ANIM == "" then
call SetUnitAnimation(u, CAST_ANIM)
else
call SetUnitAnimation(u, CHAN_ANIM)
endif
call SetTimerData(t, d)
call TimerStart(t, SPD, true, function CallBack)
endfunction
private function Init takes nothing returns nothing
local trigger trig = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( trig, Condition( function Conditions ) )
call TriggerAddAction( trig, function Actions )
endfunction
endlibrary