- Joined
- Aug 9, 2006
- Messages
- 2,384
This Spell bugs sometimes, the laser never appears and the distance (if i put it out) is always 1500. Dunno whats the problem on it.
JASS:
scope Laser1
public struct Laser1
unit caster
player casterowner
real X
real Y
real X2
real Y2
real destX
real destY
unit dummy
real dist
real face
group Damaged
unit p
real damage
endstruct
globals
private Laser1 array Br
private integer Total = 0
private timer t = CreateTimer()
private integer SPELL_ID = 'A000' //change this to your lasers spells ID
endglobals
function Trig_Laser_1_Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
function Trig_Laser1 takes nothing returns nothing
local Laser1 kb
local integer i = 0
loop
exitwhen i >= Total
set kb = Br[i]
set kb.dist = kb.dist + 6
set kb.X2 = kb.X + kb.dist * Cos(kb.face)
set kb.Y2 = kb.Y + kb.dist * Sin(kb.face)
call SetUnitPosition(kb.dummy, kb.X2, kb.Y2)
set kb.Damaged = CreateGroup()
call GroupEnumUnitsInRange(kb.Damaged, kb.X2, kb.Y2, 250.00, null)
loop
set kb.p = FirstOfGroup(kb.Damaged)
exitwhen kb.p == null
call GroupRemoveUnit(kb.Damaged, kb.p)
if not IsUnitType(kb.p,UNIT_TYPE_MAGIC_IMMUNE) and not IsUnitType(kb.p,UNIT_TYPE_FLYING) and not IsUnitAlly(kb.p, kb.casterowner) and not (GetUnitState(kb.p, UNIT_STATE_LIFE) <= 0.405) then
call UnitDamageTarget(kb.caster, kb.p, (kb.damage*0.03)*GetUnitAbilityLevel(kb.caster, SPELL_ID), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
endif
endloop
call DestroyGroup(kb.Damaged)
if kb.dist >= 1500 then
set kb.caster = null
call UnitApplyTimedLife(kb.dummy, 'BTLF', 0.02)
set Br[i] = Br[Total - 1]
set Total = Total - 1
call kb.destroy()
endif
set i = i + 1
endloop
if Total == 0 then
call PauseTimer(t)
endif
endfunction
function Trig_Laser_1_Init takes nothing returns nothing
local Laser1 kb = Laser1.create()
local location l = GetSpellTargetLoc()
set kb.caster = GetTriggerUnit()
set kb.casterowner = GetOwningPlayer(kb.caster)
set kb.destX = GetLocationX(l)
set kb.destY = GetLocationY(l)
call RemoveLocation(l)
set kb.X = GetUnitX(kb.caster)
set kb.Y = GetUnitY(kb.caster)
set kb.face = Atan2(kb.destY - kb.Y, kb.destX - kb.X)
set kb.X2 = kb.X + 100 * Cos(kb.face)
set kb.Y2 = kb.Y + 100 * Sin(kb.face)
set kb.dummy = CreateUnit(kb.casterowner, 'h000', kb.X, kb.Y, kb.face*bj_RADTODEG)
set kb.damage = GetHeroInt(kb.caster, true)*10
call SetUnitTimeScale(kb.dummy, 1000 * 0.01)
if Total == 0 then
call TimerStart(t, 0.03, true, function Trig_Laser1)
endif
set Total = Total + 1
set Br[Total-1] = kb
endfunction
//===========================================================================
function InitTrig_Laser1 takes nothing returns nothing
local integer index = 0
set gg_trg_Laser1 = CreateTrigger( )
loop
call TriggerRegisterPlayerUnitEvent(gg_trg_Laser1, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition( gg_trg_Laser1, Condition( function Trig_Laser_1_Conditions ) )
call TriggerAddAction( gg_trg_Laser1, function Trig_Laser_1_Init )
endfunction
endscope