- Joined
- Aug 2, 2008
- Messages
- 442
Hello. Can some one help me out here; the timer in this code doesn't start. Also,
can someone tell me if i coded this properly to have the unit "data.u" follow the targeted unit "data.target" in the same way a projectile spell would? (ex: deathcoil, stormbolt,etc)
never gets called
PS: I am pretty sure that location l is useless but i am lost here.
can someone tell me if i coded this properly to have the unit "data.u" follow the targeted unit "data.target" in the same way a projectile spell would? (ex: deathcoil, stormbolt,etc)
JASS:
scope GreenShield initializer Init
private struct GreenShield
unit u
integer level
real cos
real sin
unit target
endstruct
globals
private constant integer ID = 'A0C7'
private constant integer DummyID = 'h017'
private constant string Explosion = "Abilities\\Spells\\Undead\\Darksummoning\\DarkSummonTarget.mdl"
private constant real Interval = 0.02
private constant real Speed = 700
private constant real Distance = Speed * Interval
private constant attacktype AT = ATTACK_TYPE_NORMAL
private constant damagetype DT = DAMAGE_TYPE_FIRE
private constant weapontype WT = WEAPON_TYPE_WHOKNOWS
private boolexpr filter
private group Group = CreateGroup()
private timer Tim = CreateTimer()
private GreenShield array queue
private integer total = 0
private player GSOwner
endglobals
private constant function Damage takes integer level returns real
return level * 60. + 100.
endfunction
private function Timer takes nothing returns nothing
local integer i = 0
local GreenShield data
local unit f
local real damage
local real x2 = GetUnitX(data.target)
local real y2 = GetUnitY(data.target)
local real x = GetUnitX(data.u)
local real y = GetUnitY(data.u)
local real dx = x2 - x
local real dy = y2 - y
local real atan2 = Atan2(dy, dx)
set data.cos = Distance * Cos(atan2)
set data.sin = Distance * Sin(atan2)
call DisplayTextToForce( GetPlayersAll(), "Made it here" )
loop
exitwhen i >= total
call DisplayTextToForce( GetPlayersAll(), "Looping" )
set data = queue[i]
call SetUnitX(data.u, GetUnitX(data.u) + data.cos)
call SetUnitY(data.u, GetUnitY(data.u) + data.sin)
call SetUnitFacing(data.u, atan2 * bj_RADTODEG)
set GSOwner = GetOwningPlayer(data.u)
call GroupClear(Group)
call GroupEnumUnitsInRange(Group, GetUnitX(data.u), GetUnitY(data.u), 150, filter)
if (FirstOfGroup(Group) == data.target) then
call DestroyEffect(AddSpecialEffect(Explosion, GetUnitX(data.u), GetUnitY(data.u)))
call KillUnit(data.u)
set damage = Damage(data.level)
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Undead\\UCancelDeath\\UCancelDeath.mdl",f,"origin"))
call UnitDamageTarget(data.u, data.target, damage, true, false, AT, DT, WT)
call data.destroy()
set total = total - 1
set queue[i] = queue[total]
set i = i - 1
endif
set i = i + 1
endloop
if total == 0 then
call DisplayTextToForce( GetPlayersAll(), "Paused" )
call PauseTimer(Tim)
endif
set f = null
endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == ID
endfunction
private function Fireball_Filter takes nothing returns boolean
return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.405 and IsUnitEnemy(GetFilterUnit(), GSOwner) == true and not IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING) == true
endfunction
private function Actions takes nothing returns nothing
local GreenShield data = GreenShield.create()
local unit u = GetTriggerUnit()
local unit t = GetSpellTargetUnit()
local location l = GetUnitLoc(t)
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real dx = GetLocationX(l) - x
local real dy = GetLocationY(l) - y
local real atan2 = Atan2(dy, dx)
set data.target = GetSpellTargetUnit()
set data.level = GetUnitAbilityLevel(u, ID)
set data.u = CreateUnit(GetOwningPlayer(u), DummyID, x, y, atan2*bj_RADTODEG)
set data.cos = Distance * Cos(atan2)
set data.sin = Distance * Sin(atan2)
call SetUnitPathing(data.u, false)
call PauseUnit(data.u, true)
call RemoveLocation(l)
if total == 0 then
call TimerStart(Tim, Interval, true, function Timer)
call DisplayTextToForce( GetPlayersAll(), "Timer Started" )
endif
set queue[total] = data
set total = total + 1
set u = null
set t = null
set l = null
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function Conditions))
call TriggerAddAction(t, function Actions)
call Preload(Explosion)
set filter = Filter(function Fireball_Filter)
endfunction
endscope
JASS:
call DisplayTextToForce( GetPlayersAll(), "Made it here" )
PS: I am pretty sure that location l is useless but i am lost here.