- Joined
- Dec 9, 2007
- Messages
- 3,096
JASS:
scope FireBolt initializer Init
globals
private constant integer AbilityID = 'A001'
private constant integer FireBoltUnitTypeID = 'u000'
private constant real FireBoltSpawnDistance = 15
endglobals
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == AbilityID
endfunction
function Actions takes nothing returns nothing
local player owner = GetOwningPlayer(GetSpellAbilityUnit())
local location p1 = GetUnitLoc(GetSpellAbilityUnit())
local location p2 = GetSpellTargetLoc()
local real angle = Atan2(GetLocationY(p2) - GetLocationY(p1), GetLocationX(p2) - GetLocationX(p1))
local real x = GetLocationX(p1) + FireBoltSpawnDistance * Cos(angle)
local real y = GetLocationX(p1) + FireBoltSpawnDistance * Sin(angle)
local unit firebolt
local integer damage = GetHeroInt(GetSpellAbilityUnit(), true) * GetUnitAbilityLevel(GetSpellAbilityUnit(), 'A001')
//Done with variables xD
set firebolt = CreateUnitAtLoc(owner, FireBoltUnitTypeID, Location(x,y), angle)
call GroupAddUnit(udg_FireBolts, firebolt)
call SetUnitUserData( firebolt, damage )
//Leak?
call RemoveLocation(p1)
call RemoveLocation(p2)
set owner = null
set firebolt = null
endfunction
//===========================================================================
//Initialization
private constant function AntiLeak takes nothing returns boolean
return true
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
local filterfunc f = Filter(function AntiLeak)
local integer i = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, f)
set i = i + 1
exitwhen i >= 16
endloop
call TriggerAddCondition(t, Condition( function Conditions ) )
call TriggerAddAction(t, function Actions )
call DestroyFilter(f)
set f = null
endfunction
endscope
What's wrong with this code?
What makes it not work?
The hero casts the ability but the unit just doesn't spawn!