- Joined
- Jul 9, 2008
- Messages
- 253
Hey all, I have someone problems with my spell. It doesn't work.
Here is the code,
Thanks in advance, Quetzalcotl
Here is the code,
JASS:
function Trig_Shoot_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
function Trig_Shoot_Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local location loc = GetSpellTargetLoc()
local integer power = GetHeroAgi( caster , true )
local integer mana = GetUnitState( caster , UNIT_STATE_MANA )
local real x = GetUnitX( caster )
local real y = GetUnitY( caster )
local real X = GetLocationX( loc )
local real Y = GetLocationY( loc )
local real dx = X - x
local real dy = Y - y
local real speed = 1000
local real distance = SquareRoot( dx * dx + dy * dy )
local real time = ( distance / speed ) - 0.1
local string sfx = "Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl"
local real damage = ( power / 100 ) * mana
local unit u
local group g
local player p = GetOwningPlayer( caster )
//Actions//
call SetUnitState( caster , UNIT_STATE_MANA , mana - 15 )
call TriggerSleepAction( time )
call DestroyEffect( AddSpecialEffect( sfx , X , Y ) )
set g = GetUnitsInRangeOfLocAll( 100 , loc )
loop
set u = FirstOfGroup( g )
exitwhen u == null
if IsUnitEnemy( u , p ) then
if IsUnitAliveBJ( u ) then
call UnitDamageTarget( caster , u , damage , true , false , ATTACK_TYPE_CHAOS , DAMAGE_TYPE_NORMAL , WEAPON_TYPE_WHOKNOWS )
endif
endif
call GroupRemoveUnit( g , u )
set u = null
endloop
call DestroyGroup( g )
call RemoveLocation( loc )
//Actions//
set caster = null
set p = null
set sfx = null
set loc = null
set g = null
endfunction
//===========================================================================
function InitTrig_Shoot takes nothing returns nothing
set gg_trg_Shoot = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Shoot, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Shoot, Condition( function Trig_Shoot_Conditions ) )
call TriggerAddAction( gg_trg_Shoot, function Trig_Shoot_Actions )
endfunction
Thanks in advance, Quetzalcotl