Tinki3
Special Member
- Reaction score
- 418
The function "Meat_Shield_Run" (right at the bottom), does not
seem to be working properly - its loop only loops once, when it should
clearly be looping more than once, if I may say.
The function is called once from another library.
Have I missed something here?
Here is the other library trigger:
The line that calls the Meat_Shield_Run function is inside the function Drop_Hostiles, in one of the "If" blocks.
seem to be working properly - its loop only loops once, when it should
clearly be looping more than once, if I may say.
The function is called once from another library.
Have I missed something here?
JASS:
library MeatShield uses QuickFunctions
globals
private constant integer Toxic_Sheep_Projec_ID = 039;o005039;
private constant integer Toxicness_Projec_ID = 039;o006039;
private constant real Sheep_Speed = 15
private constant real Toxicness_Speed = 25
private constant real Max_Range = 600
private constant real AoE = 90
private constant string SFX = "Objects\\Spawnmodels\\NightElf\\EntBirthTarget\\EntBirthTarget.mdl"
private constant string SFX2 = "Objects\\Spawnmodels\\Demon\\DemonLargeDeathExplode\\DemonLargeDeathExplode.mdl"
private constant integer Toxic_No = 10
private integer index
private integer Chance_Sheep
private real Dmg
endglobals
private struct Toxic_dat
unit array Toxics[Toxic_No]
real array cos[Toxic_No]
real array sin[Toxic_No]
trigger array trig[Toxic_No]
triggeraction array ta[Toxic_No]
real dist = 0
integer i = 0
method onDestroy takes nothing returns nothing
set .i = 1
loop
exitwhen .i > Toxic_No
call KillUnit(.Toxics[.i])
call TriggerRemoveAction(.trig[.i], .ta[.i])
call FlushHandleLocals(.trig[.i])
call DestroyTrigger(.trig[.i])
set .i = .i + 1
endloop
endmethod
endstruct
private struct Sheep_dat
unit sheep
unit toxic
real dist = 0
real cos
real sin
method onDestroy takes nothing returns nothing
call DestroyEffect(AddSpecialEffect(SFX, GetUnitX(.sheep), GetUnitY(.sheep)))
call DestroyEffect(AddSpecialEffect(SFX2, GetUnitX(.sheep), GetUnitY(.sheep)))
call KillUnit(.sheep)
call KillUnit(.toxic)
endmethod
endstruct
private function Trigger_Callback takes nothing returns nothing
local trigger t = GetTriggeringTrigger()
local Toxic_dat D = Toxic_dat(GetHandleInt(t, "D"))
local unit x = GetTriggerUnit()
local integer i = 1
loop
exitwhen i > Toxic_No
if AreTheyEnemies(x, D.Toxics<i>) then
call UnitDamageTarget(D.Toxics<i>, x, Dmg, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, null)
endif
set i = i + 1
endloop
set t = null
set x = null
endfunction
private function Spit_Toxics takes nothing returns nothing
local timer T = GetExpiredTimer()
local Toxic_dat D = Toxic_dat(GetHandleInt(T, "D"))
local integer i = 1
local real X
local real Y
local real PX
local real PY
if D.dist > 0 then
set D.dist = D.dist - Toxicness_Speed
loop
exitwhen i > Toxic_No
set X = GetUnitX(D.Toxics<i>)
set Y = GetUnitY(D.Toxics<i>)
set PX = X + Toxicness_Speed * D.cos<i>
set PY = Y + Toxicness_Speed * D.sin<i>
call SetUnitPosition(D.Toxics<i>, PX, PY)
endloop
else
call D.destroy()
call FlushHandleLocals(T)
call PauseTimer(T)
call DestroyTimer(T)
endif
set T = null
endfunction
private function Throw_Toxic_Sheep_Periodic takes nothing returns nothing
local timer t = GetExpiredTimer()
local Sheep_dat d = Sheep_dat(GetHandleInt(t, "d"))
local real X = GetUnitX(d.sheep)
local real Y = GetUnitY(d.sheep)
local real PX = X + Sheep_Speed * d.cos
local real PY = Y + Sheep_Speed * d.sin
local integer i = 1
local real ang = 0
local Toxic_dat D
local timer T
if d.dist > 0 then
set d.dist = d.dist - Sheep_Speed
call SetUnitPosition(d.sheep, PX, PY)
call SetUnitPosition(d.toxic, PX, PY)
else
set D = Toxic_dat.create()
set T = CreateTimer()
set D.dist = 475
loop
exitwhen i > Toxic_No
set ang = (360/Toxic_No * i) * bj_DEGTORAD
set D.cos<i> = Cos(ang)
set D.sin<i> = Sin(ang)
set D.Toxics<i> = CreateUnit(Player(11), Toxicness_Projec_ID, X + 150 * D.cos<i>, Y + 150 * D.sin<i>, ang * bj_RADTODEG)
set D.trig<i> = CreateTrigger()
call TriggerRegisterUnitInRange(D.trig<i>, D.Toxics<i>, AoE, null)
set D.ta<i> = TriggerAddAction(D.trig<i>, function Trigger_Callback)
set i = i + 1
endloop
set i = 1
loop
exitwhen i > Toxic_No
call SetHandleInt(D.trig<i>, "D", D)
set i = i + 1
endloop
call SetHandleInt(T, "D", D)
call TimerStart(T, 0.03, true, function Spit_Toxics)
call d.destroy()
call FlushHandleLocals(t)
call PauseTimer(t)
call DestroyTimer(t)
set T = null
endif
set t = null
endfunction
private function Throw_Toxic_Sheep takes nothing returns nothing
local Sheep_dat d = Sheep_dat.create()
local real X = GetUnitX(b)
local real Y = GetUnitY(b)
local real r = GetRandomReal(235, 335) * bj_DEGTORAD
local timer t = CreateTimer()
call IssueImmediateOrder(b, "stop")
call SetUnitAnimation(b, "attack")
call SetUnitFacing(b, r * bj_RADTODEG)
set d.sheep = CreateUnit(Player(11), Toxic_Sheep_Projec_ID, X, Y, r * bj_RADTODEG)
set d.toxic = CreateUnit(Player(11), Toxicness_Projec_ID, X, Y, r * bj_RADTODEG)
set d.cos = Cos(r)
set d.sin = Sin(r)
set d.dist = Max_Range
call SetHandleInt(t, "d", d)
call TimerStart(t, 0.03, true, function Throw_Toxic_Sheep_Periodic)
call TriggerSleepAction(1.3)
if RectContainsCoords(gg_rct_Boss_Check_1, X, Y) then
call IssuePointOrder(b, "move", GetRectCenterX(gg_rct_Run_Point_1), GetRectCenterY(gg_rct_Run_Point_1))
elseif RectContainsCoords(gg_rct_Boss_Check_2, X, Y) then
call IssuePointOrder(b, "move", GetRectCenterX(gg_rct_End_of_Path), GetRectCenterY(gg_rct_End_of_Path))
endif
set t = null
endfunction
function Meat_Shield_Run takes nothing returns nothing
set Finished_Boss_Level = false
set index = 0
set Chance_Sheep = udg_Difficulty_Level * 13
set Dmg = (udg_Difficulty_Level * 30) / Toxic_No
loop
exitwhen index > 1000
if GetWidgetLife(b) < 0.405 or b == null then
set Finished_Boss_Level = true
set index = 1001
endif
if GetRandomInt(1, 100) <= Chance_Sheep and GetWidgetLife(b) > 0.405 then
call Throw_Toxic_Sheep()
endif
call TriggerSleepAction(1.5)
set index = index + 1
endloop
endfunction
endlibrary</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>
Here is the other library trigger:
The line that calls the Meat_Shield_Run function is inside the function Drop_Hostiles, in one of the "If" blocks.
JASS:
library MainSpawn uses MeatShield
globals
private constant real Interval = 10
private constant integer Boss_Spawn_Amount = 1
private constant real Fly_Decrease = 21
private constant real Timer_Interval = 0.03
private constant real Wave_Interval = 33
private constant real Level_Interval = 45
private constant integer Wave_Amount = 3
private constant string SFX = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl"
private constant string SFX2 = "Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl"
unit b
private unit array u
private boolean done = false
private boolean Boss_Lvl = false
private boolean Run_Trigger = true
private timer t = CreateTimer()
boolean Finished_Boss_Level = false
endglobals
private function Drop_Hostiles takes nothing returns nothing
local integer index = 1
local real fh
local location l
if done == false then
if Boss_Lvl == false then
loop
exitwhen index > udg_Spawn_Amount
set fh = GetUnitFlyHeight(u[index])
if fh > Fly_Decrease then
call SetUnitFlyHeight(u[index], fh - Fly_Decrease, 99999)
else
if GetUnitUserData(u[index]) != 1 then
call SetUnitUserData(u[index], 1)
set l = Location(GetRandomReal(GetRectMinX(gg_rct_Run_Point_1), GetRectMaxX(gg_rct_Run_Point_1)), GetRandomReal(GetRectMinY(gg_rct_Run_Point_1), GetRectMaxY(gg_rct_Run_Point_1)))
call PauseUnit(u[index], false)
call SetUnitInvulnerable(u[index], false)
call IssuePointOrderLoc(u[index], "move", l)
call SetUnitFlyHeight(u[index], 0, 99999)
call DestroyEffect(AddSpecialEffect(SFX, GetUnitX(u[index]), GetUnitY(u[index])))
call DestroyEffect(AddSpecialEffect(SFX2, GetUnitX(u[index]), GetUnitY(u[index])))
call RemoveLocation(l)
endif
endif
set index = index + 1
endloop
else
set fh = GetUnitFlyHeight(b)
if fh >= Fly_Decrease then
call SetUnitFlyHeight(b, fh - Fly_Decrease, 99999)
else
call PauseTimer(t)
call PauseUnit(b, false)
call SetUnitInvulnerable(b, false)
call DestroyEffect(AddSpecialEffect(SFX, GetUnitX(b), GetUnitY(b)))
call DestroyEffect(AddSpecialEffect(SFX2, GetUnitX(b), GetUnitY(b)))
call SetUnitFlyHeight(b, 0, 99999)
call IssuePointOrder(b, "move", GetRectCenterX(gg_rct_Run_Point_1), GetRectCenterY(gg_rct_Run_Point_1))
if udg_Current_Level == 4 then
call Meat_Shield_Run()
elseif udg_Current_Level == 8 then
elseif udg_Current_Level == 12 then
elseif udg_Current_Level == 16 then
elseif udg_Current_Level == 20 then
endif
set udg_Current_Level = udg_Current_Level + 1
loop
exitwhen Finished_Boss_Level == true
call TriggerSleepAction(1)
endloop
set Boss_Lvl = false
set Finished_Boss_Level = false
call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS, 15, "Level " + "|cff32cd32" + I2S(R2I(udg_Current_Level))+ "|r" + " starting in approximately " + I2S(R2I(Level_Interval)) + " seconds.")
call TriggerSleepAction(Level_Interval)
set Run_Trigger = true
endif
endif
else
set done = false
call TriggerSleepAction(udg_Creation_Interval / 2)
call PauseTimer(t)
endif
set l = null
endfunction
private function Start_Spawn takes nothing returns nothing
local integer index = 1
local integer index2 = 1
local location l
if Run_Trigger == true then
set Run_Trigger = false
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 15, "|cff32cd32Level " + I2S(R2I(udg_Current_Level))+ "|r" + ": " + udg_Level_String[udg_Current_Level])
if udg_Current_Level != 4 and udg_Current_Level != 8 and udg_Current_Level != 12 and udg_Current_Level != 16 and udg_Current_Level != 20 then
loop
exitwhen index2 > Wave_Amount
loop
exitwhen index > udg_Spawn_Amount
set l = Location(GetRandomReal(GetRectMinX(gg_rct_Spawn), GetRectMaxX(gg_rct_Spawn)), GetRandomReal(GetRectMinY(gg_rct_Spawn), GetRectMaxY(gg_rct_Spawn)))
set u[index] = CreateUnitAtLoc(Player(11), udg_Hostiles[udg_Current_Level], l, 270)
call PauseUnit(u[index], true)
call SetUnitInvulnerable(u[index], true)
call TimerStart(t, Timer_Interval, true, function Drop_Hostiles)
set index = index + 1
if index > udg_Spawn_Amount then
set done = true
endif
call RemoveLocation(l)
call TriggerSleepAction(udg_Creation_Interval)
endloop
set index = 1
call TriggerSleepAction(Wave_Interval)
set index2 = index2 + 1
endloop
else
set Boss_Lvl = true
set l = Location(GetRandomReal(GetRectMinX(gg_rct_Spawn), GetRectMaxX(gg_rct_Spawn)), GetRandomReal(GetRectMinY(gg_rct_Spawn), GetRectMaxY(gg_rct_Spawn)))
set b = CreateUnitAtLoc(Player(11), udg_Hostiles[udg_Current_Level], l, 270)
call PauseUnit(b, true)
call SetUnitInvulnerable(b, true)
call TimerStart(t, Timer_Interval, true, function Drop_Hostiles)
call RemoveLocation(l)
endif
endif
if index2 > Wave_Amount then
set index2 = 1
set udg_Current_Level = udg_Current_Level + 1
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 15, "Level " + "|cff32cd32" + I2S(R2I(udg_Current_Level))+ "|r" + " starting in approximately " + I2S(R2I(Level_Interval)) + " seconds.")
call TriggerSleepAction(Level_Interval)
set Run_Trigger = true
endif
set l = null
endfunction
function InitTrig_Main_Spawn takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, Interval, true)
call TriggerAddAction(t, function Start_Spawn)
set t = null
endfunction
endscope