- Joined
- Jun 20, 2017
- Messages
- 380
Asking for help to fixing triggers...+Rep
Just see the latest post in the thread to solve the problem.
Just see the latest post in the thread to solve the problem.
Last edited:
Because you don't have an upgrade, but an ability that does it, the event should be "a unit starts an effect of ability" and then have a condition to detect which ability was used.
Could you create new threads for new problems, and possibly attach a demo with what your exact goal is?
globals
constant integer Base_x_Index = 0
constant integer Base_y_Index = 1
constant integer Main_Timer_Index = 2
constant integer Player_Index = 3
constant integer Unit_1_Index = 4
constant integer Unit_Phase_1_Index = 5
constant integer Unit_2_Index = 6
constant integer Unit_Phase_2_Index = 7
constant integer Unit_3_Index = 8
constant integer Unit_Phase_3_Index = 9
constant integer Unit_4_Index = 10
constant integer Unit_Phase_4_Index = 11
constant integer Unit_5_Index = 12
constant integer Unit_Phase_5_Index = 13
constant integer Unit_6_Index = 14
constant integer Unit_Phase_6_Index = 15
constant integer Unit_7_Index = 16
constant integer Unit_Phase_7_Index = 17
constant integer Unit_8_Index = 18
constant integer Unit_Phase_8_Index = 19
constant integer Unit_Range_Index = 20
constant integer Unit_Slow_T_Index = 21
constant integer Unit_Phase_9_Index = 22
constant integer Unit_9_Index = 23
constant integer Unit_Phase_10_Index = 24
constant integer Unit_10_Index = 25
constant integer Unit_Phase_11_Index = 26
constant integer Unit_11_Index = 27
constant integer Unit_Phase_12_Index = 28
constant integer Unit_12_Index = 29
constant integer MAX_RC_ALLOWED = 3
integer array StartedRC
real MapMinX = 0.
real MapMinY = 0.
real MapMaxX = 0.
real MapMaxY = 0.
endglobals
struct CheckerPoint {
integer Base_X
integer Base_Y
}
function SafeX takes real x returns real
if MapMinX < x && x < MapMaxX
return x
elseif MapMinX > x
return MapMinX
elseif x > MapMaxX
return MapMaxX
endif
return x
endfunction
function SafeY takes real y returns real
if MapMinY < y && y < MapMaxY
return y
elseif MapMinY > y
return MapMinY
elseif y > MapMaxY
return MapMaxY
endif
return y
endfunction
function Trig_RangeChecker_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A034'
endfunction
function Move1stStage takes nothing returns nothing
local timer tm = GetExpiredTimer()
local integer Handle = LoadInteger(Main_Hash, GetHandleId(tm), 0)
local real Range = LoadReal(Main_Hash, Handle, Unit_Range_Index)
local real x0 = LoadReal(Main_Hash, Handle, Base_x_Index)
local real y0 = LoadReal(Main_Hash, Handle, Base_y_Index)
local real Timer = LoadReal(Main_Hash, Handle, Main_Timer_Index)
local real Slow_T = LoadReal(Main_Hash, Handle, Unit_Slow_T_Index)
local real x_temp = 0.
local real y_temp = 0.
local real Length = 0.
local unit u = LoadUnitHandle(Main_Hash, Handle, Unit_1_Index)
local real Phase = LoadReal(Main_Hash, Handle, Unit_Phase_1_Index)
local real PhaseForSin = Timer*360./4 + Phase // ____________ ________ __ _______ ___ 360 ________
Length = Timer*Range/4 // _____ __ ____ __ _______ _______
if Length >= Range
Length = Range
endif
x_temp = x0 + Length * Cos(bj_DEGTORAD*PhaseForSin)
y_temp = y0 + Length * Sin(bj_DEGTORAD*PhaseForSin)
SetUnitX(u, SafeX(x_temp))
SetUnitY(u, SafeY(y_temp))
SetUnitFacing(u, GetUnitFacing(u) - 5)
u = LoadUnitHandle(Main_Hash, Handle, Unit_2_Index)
Phase = LoadReal(Main_Hash, Handle, Unit_Phase_2_Index)
PhaseForSin = Timer*360./4 + Phase // ____________ ________ __ _______ ___ 360 ________
x_temp = x0 + Length * Cos(bj_DEGTORAD*PhaseForSin)
y_temp = y0 + Length * Sin(bj_DEGTORAD*PhaseForSin)
SetUnitX(u, SafeX(x_temp))
SetUnitY(u, SafeY(y_temp))
SetUnitFacing(u, GetUnitFacing(u) + 5)
u = LoadUnitHandle(Main_Hash, Handle, Unit_3_Index)
Phase = LoadReal(Main_Hash, Handle, Unit_Phase_3_Index)
PhaseForSin = Timer*360./4 + Phase // ____________ ________ __ _______ ___ 360 ________
x_temp = x0 + Length * Cos(bj_DEGTORAD*PhaseForSin)
y_temp = y0 + Length * Sin(bj_DEGTORAD*PhaseForSin)
SetUnitX(u, SafeX(x_temp))
SetUnitY(u, SafeY(y_temp))
SetUnitFacing(u, GetUnitFacing(u) - 5)
u = LoadUnitHandle(Main_Hash, Handle, Unit_4_Index)
Phase = LoadReal(Main_Hash, Handle, Unit_Phase_4_Index)
PhaseForSin = Timer*360./4 + Phase // ____________ ________ __ _______ ___ 360 ________
x_temp = x0 + Length * Cos(bj_DEGTORAD*PhaseForSin)
y_temp = y0 + Length * Sin(bj_DEGTORAD*PhaseForSin)
SetUnitX(u, SafeX(x_temp))
SetUnitY(u, SafeY(y_temp))
SetUnitFacing(u, GetUnitFacing(u) + 5)
u = LoadUnitHandle(Main_Hash, Handle, Unit_5_Index)
Phase = LoadReal(Main_Hash, Handle, Unit_Phase_5_Index)
PhaseForSin = Timer*360./4 + Phase // ____________ ________ __ _______ ___ 360 ________
x_temp = x0 + Length * Cos(bj_DEGTORAD*PhaseForSin)
y_temp = y0 + Length * Sin(bj_DEGTORAD*PhaseForSin)
SetUnitX(u, SafeX(x_temp))
SetUnitY(u, SafeY(y_temp))
SetUnitFacing(u, GetUnitFacing(u) - 5)
u = LoadUnitHandle(Main_Hash, Handle, Unit_6_Index)
Phase = LoadReal(Main_Hash, Handle, Unit_Phase_6_Index)
PhaseForSin = Timer*360./4 + Phase // ____________ ________ __ _______ ___ 360 ________
x_temp = x0 + Length * Cos(bj_DEGTORAD*PhaseForSin)
y_temp = y0 + Length * Sin(bj_DEGTORAD*PhaseForSin)
SetUnitX(u, SafeX(x_temp))
SetUnitY(u, SafeY(y_temp))
SetUnitFacing(u, GetUnitFacing(u) + 5)
u = LoadUnitHandle(Main_Hash, Handle, Unit_7_Index)
Phase = LoadReal(Main_Hash, Handle, Unit_Phase_7_Index)
PhaseForSin = Timer*360./4 + Phase // ____________ ________ __ _______ ___ 360 ________
x_temp = x0 + Length * Cos(bj_DEGTORAD*PhaseForSin)
y_temp = y0 + Length * Sin(bj_DEGTORAD*PhaseForSin)
SetUnitX(u, SafeX(x_temp))
SetUnitY(u, SafeY(y_temp))
SetUnitFacing(u, GetUnitFacing(u) - 5)
u = LoadUnitHandle(Main_Hash, Handle, Unit_8_Index)
Phase = LoadReal(Main_Hash, Handle, Unit_Phase_8_Index)
PhaseForSin = Timer*360./4 + Phase // ____________ ________ __ _______ ___ 360 ________
x_temp = x0 + Length * Cos(bj_DEGTORAD*PhaseForSin)
y_temp = y0 + Length * Sin(bj_DEGTORAD*PhaseForSin)
SetUnitX(u, SafeX(x_temp))
SetUnitY(u, SafeY(y_temp))
SetUnitFacing(u, GetUnitFacing(u) + 5)
u = LoadUnitHandle(Main_Hash, Handle, Unit_9_Index)
Phase = LoadReal(Main_Hash, Handle, Unit_Phase_9_Index)
PhaseForSin = Timer*360./8 + Phase // ____________ ________ __ _______ ___ 360 ________
x_temp = x0 + Length * Cos(bj_DEGTORAD*PhaseForSin)
//y_temp = y0 + Length * Sin(bj_DEGTORAD*PhaseForSin)
y_temp = y0
SetUnitX(u, SafeX(x_temp))
SetUnitY(u, SafeY(y_temp))
SetUnitFacing(u, GetUnitFacing(u) + 5)
u = LoadUnitHandle(Main_Hash, Handle, Unit_10_Index)
Phase = LoadReal(Main_Hash, Handle, Unit_Phase_10_Index)
PhaseForSin = Timer*360./8 + Phase // ____________ ________ __ _______ ___ 360 ________
x_temp = x0 + Length * Cos(bj_DEGTORAD*PhaseForSin)
//y_temp = y0 + Length * Sin(bj_DEGTORAD*PhaseForSin)
y_temp = y0
SetUnitX(u, SafeX(x_temp))
SetUnitY(u, SafeY(y_temp))
SetUnitFacing(u, GetUnitFacing(u) + 5)
u = LoadUnitHandle(Main_Hash, Handle, Unit_11_Index)
Phase = LoadReal(Main_Hash, Handle, Unit_Phase_11_Index)
PhaseForSin = Timer*360./8 + Phase // ____________ ________ __ _______ ___ 360 ________
//x_temp = x0 + Length * Cos(bj_DEGTORAD*PhaseForSin)
x_temp = x0
y_temp = y0 + Length * Sin(bj_DEGTORAD*PhaseForSin)
SetUnitX(u, SafeX(x_temp))
SetUnitY(u, SafeY(y_temp))
SetUnitFacing(u, GetUnitFacing(u) + 5)
u = LoadUnitHandle(Main_Hash, Handle, Unit_12_Index)
Phase = LoadReal(Main_Hash, Handle, Unit_Phase_12_Index)
PhaseForSin = Timer*360./8 + Phase // ____________ ________ __ _______ ___ 360 ________
//x_temp = x0 + Length * Cos(bj_DEGTORAD*PhaseForSin)
x_temp = x0
y_temp = y0 + Length * Sin(bj_DEGTORAD*PhaseForSin)
SetUnitX(u, SafeX(x_temp))
SetUnitY(u, SafeY(y_temp))
SetUnitFacing(u, GetUnitFacing(u) + 5)
if Timer <= 8.00
Timer = Timer + 0.02
TimerStart(tm, 0.02, false, function Move1stStage)
elseif Timer <= 12.00
Slow_T = Slow_T - 0.0001
if Slow_T >= 0
Timer = Timer + Slow_T
TimerStart(tm, 0.02, false, function Move1stStage)
else
if HaveSavedHandle(Main_Hash, Handle, Unit_1_Index) // ____ ________ ____________ -1
StartedRC[GetPlayerId(GetOwningPlayer(LoadUnitHandle(Main_Hash, Handle, Unit_1_Index)))] = StartedRC[GetPlayerId(GetOwningPlayer(LoadUnitHandle(Main_Hash, Handle, Unit_1_Index)))] - 1
endif
KillUnit(LoadUnitHandle(Main_Hash, Handle, Unit_1_Index))
KillUnit(LoadUnitHandle(Main_Hash, Handle, Unit_2_Index))
KillUnit(LoadUnitHandle(Main_Hash, Handle, Unit_3_Index))
KillUnit(LoadUnitHandle(Main_Hash, Handle, Unit_4_Index))
KillUnit(LoadUnitHandle(Main_Hash, Handle, Unit_5_Index))
KillUnit(LoadUnitHandle(Main_Hash, Handle, Unit_6_Index))
KillUnit(LoadUnitHandle(Main_Hash, Handle, Unit_7_Index))
KillUnit(LoadUnitHandle(Main_Hash, Handle, Unit_8_Index))
KillUnit(LoadUnitHandle(Main_Hash, Handle, Unit_9_Index))
KillUnit(LoadUnitHandle(Main_Hash, Handle, Unit_10_Index))
KillUnit(LoadUnitHandle(Main_Hash, Handle, Unit_11_Index))
KillUnit(LoadUnitHandle(Main_Hash, Handle, Unit_12_Index))
FlushChildHashtable(Main_Hash, Handle)
FlushChildHashtable(Main_Hash, GetHandleId(tm))
DestroyTimer(tm)
tm = null
endif
endif
SaveReal(Main_Hash, Handle, Main_Timer_Index,Timer)
SaveReal(Main_Hash, Handle, Unit_Slow_T_Index,Slow_T)
u = null
endfunction
function MoveChecker takes integer Handle returns nothing
local real x0 = LoadReal(Main_Hash, Handle, Base_x_Index)
local real y0 = LoadReal(Main_Hash, Handle, Base_y_Index)
local real Timer = LoadReal(Main_Hash, Handle, Main_Timer_Index)
local integer PId = LoadInteger(Main_Hash, Handle, Player_Index)
local timer tm = CreateTimer()
Timer = Timer + 0.02
SaveReal(Main_Hash, Handle, Main_Timer_Index,Timer)
if Timer <= 0.01 // ______ _______ _______
SaveUnitHandle(Main_Hash, Handle, Unit_1_Index, CreateUnit(Player(PId), 'h01J', x0, y0, 0.))
SaveReal(Main_Hash, Handle, Unit_Phase_1_Index, 0.)
//SetUnitVertexColor(LoadUnitHandle(Main_Hash, Handle, Unit_1_Index), GetRandomInt(0,255), GetRandomInt(0,255), GetRandomInt(0,255), 255)
SaveUnitHandle(Main_Hash, Handle, Unit_2_Index, CreateUnit(Player(PId), 'h01K', x0, y0, 0.))
SaveReal(Main_Hash, Handle, Unit_Phase_2_Index, 45.)
//SetUnitVertexColor(LoadUnitHandle(Main_Hash, Handle, Unit_2_Index), GetRandomInt(0,255), GetRandomInt(0,255), GetRandomInt(0,255), 255)
SaveUnitHandle(Main_Hash, Handle, Unit_3_Index, CreateUnit(Player(PId), 'h01L', x0, y0, 0.))
SaveReal(Main_Hash, Handle, Unit_Phase_3_Index, 90.)
//SetUnitVertexColor(LoadUnitHandle(Main_Hash, Handle, Unit_3_Index), GetRandomInt(0,255), GetRandomInt(0,255), GetRandomInt(0,255), 255)
SaveUnitHandle(Main_Hash, Handle, Unit_4_Index, CreateUnit(Player(PId), 'h01M', x0, y0, 0.))
SaveReal(Main_Hash, Handle, Unit_Phase_4_Index, 135.)
//SetUnitVertexColor(LoadUnitHandle(Main_Hash, Handle, Unit_4_Index), GetRandomInt(0,255), GetRandomInt(0,255), GetRandomInt(0,255), 255)
SaveUnitHandle(Main_Hash, Handle, Unit_5_Index, CreateUnit(Player(PId), 'h01N', x0, y0, 0.))
SaveReal(Main_Hash, Handle, Unit_Phase_5_Index, 180.)
//SetUnitVertexColor(LoadUnitHandle(Main_Hash, Handle, Unit_5_Index), GetRandomInt(0,255), GetRandomInt(0,255), GetRandomInt(0,255), 255)
SaveUnitHandle(Main_Hash, Handle, Unit_6_Index, CreateUnit(Player(PId), 'h01O', x0, y0, 0.))
SaveReal(Main_Hash, Handle, Unit_Phase_6_Index, 225.)
//SetUnitVertexColor(LoadUnitHandle(Main_Hash, Handle, Unit_6_Index), GetRandomInt(0,255), GetRandomInt(0,255), GetRandomInt(0,255), 255)
SaveUnitHandle(Main_Hash, Handle, Unit_7_Index, CreateUnit(Player(PId), 'h01Q', x0, y0, 0.))
SaveReal(Main_Hash, Handle, Unit_Phase_7_Index, 270.)
//SetUnitVertexColor(LoadUnitHandle(Main_Hash, Handle, Unit_7_Index), GetRandomInt(0,255), GetRandomInt(0,255), GetRandomInt(0,255), 255)
SaveUnitHandle(Main_Hash, Handle, Unit_8_Index, CreateUnit(Player(PId), 'h01P', x0, y0, 0.))
SaveReal(Main_Hash, Handle, Unit_Phase_8_Index, 315.)
//SetUnitVertexColor(LoadUnitHandle(Main_Hash, Handle, Unit_8_Index), GetRandomInt(0,255), GetRandomInt(0,255), GetRandomInt(0,255), 255)
SaveUnitHandle(Main_Hash, Handle, Unit_9_Index, CreateUnit(Player(PId), 'h01N', x0, y0, 0.))
SaveReal(Main_Hash, Handle, Unit_Phase_9_Index, 0.)
//SetUnitVertexColor(LoadUnitHandle(Main_Hash, Handle, Unit_9_Index), GetRandomInt(0,255), GetRandomInt(0,255), GetRandomInt(0,255), 255)
SaveUnitHandle(Main_Hash, Handle, Unit_10_Index, CreateUnit(Player(PId), 'h01N', x0, y0, 0.))
SaveReal(Main_Hash, Handle, Unit_Phase_10_Index, 180.)
//SetUnitVertexColor(LoadUnitHandle(Main_Hash, Handle, Unit_10_Index), GetRandomInt(0,255), GetRandomInt(0,255), GetRandomInt(0,255), 255)
SaveUnitHandle(Main_Hash, Handle, Unit_11_Index, CreateUnit(Player(PId), 'h01N', x0, y0, 0.))
SaveReal(Main_Hash, Handle, Unit_Phase_11_Index, 90.)
//SetUnitVertexColor(LoadUnitHandle(Main_Hash, Handle, Unit_11_Index), GetRandomInt(0,255), GetRandomInt(0,255), GetRandomInt(0,255), 255)
SaveUnitHandle(Main_Hash, Handle, Unit_12_Index, CreateUnit(Player(PId), 'h01N', x0, y0, 0.))
SaveReal(Main_Hash, Handle, Unit_Phase_12_Index, 270.)
//SetUnitVertexColor(LoadUnitHandle(Main_Hash, Handle, Unit_12_Index), GetRandomInt(0,255), GetRandomInt(0,255), GetRandomInt(0,255), 255)
MoveChecker(Handle)
endif
SaveInteger(Main_Hash, GetHandleId(tm), 0, Handle)
TimerStart(tm, 0.02, false, function Move1stStage)
tm = null
endfunction
function Trig_RangeChecker_Actions takes nothing returns nothing
local unit u = GetSpellAbilityUnit()
local real x0 = GetUnitX(u)
local real y0 = GetUnitY(u)
local integer Handle = GetHandleId(u)
local integer PId = GetPlayerId(GetOwningPlayer(u))
if StartedRC[PId] < MAX_RC_ALLOWED
StartedRC[PId] = StartedRC[PId] + 1
SaveReal(Main_Hash, Handle, Base_x_Index, x0)
SaveReal(Main_Hash, Handle, Base_y_Index, y0)
SaveReal(Main_Hash, Handle, Main_Timer_Index, -0.02)
SaveReal(Main_Hash, Handle, Unit_Slow_T_Index, 0.02)
SaveInteger(Main_Hash, Handle, Player_Index, PId)
SaveReal(Main_Hash, Handle, Unit_Range_Index, GetUnitAcquireRange(u))
MoveChecker(Handle)
else
EchoPlayer(PId, "Only " + I2S(MAX_RC_ALLOWED) + " rangecheckers allowed at once.")
endif
u = null
endfunction
function InitTrig_RangeChecker takes nothing returns nothing
set gg_trg_RangeChecker = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_RangeChecker, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_RangeChecker, Condition( function Trig_RangeChecker_Conditions ) )
call TriggerAddAction( gg_trg_RangeChecker, function Trig_RangeChecker_Actions )
endfunction
library C
function ParserCalc takes string s returns real
if s == "A" or s == "a" then
return 0.8
elseif s == "B" or s == "b" then
return 0.3
elseif s == "C" or s == "c" then
return 0.7
elseif s == "D" or s == "d" then
return 0.8
elseif s == "E" or s == "e" then
return 0.9
elseif s == "F" or s == "f" then
return 0.3
elseif s == "G" or s == "g" then
return 0.4
elseif s == "H" or s == "h" then
return 0.8
elseif s == "I" or s == "i" then
return 0.9
elseif s == "J" or s == "j" then
return 1.
elseif s == "K" or s == "k" then
return 1.1
elseif s == "L" or s == "l" then
return 1.2
elseif s == "M" or s == "m" then
return 1.3
elseif s == "N" or s == "n" then
return 1.4
elseif s == "O" or s == "o" then
return 1.5
elseif s == "P" or s == "p" then
return 1.6
elseif s == "Q" or s == "q" then
return 1.7
elseif s == "R" or s == "r" then
return 1.8
elseif s == "S" or s == "s" then
return 1.9
elseif s == "T" or s == "t" then
return 2.0
elseif s == "U" or s == "u" then
return 2.1
elseif s == "V" or s == "v" then
return 2.2
elseif s == "W" or s == "w" then
return 2.3
elseif s == "X" or s == "x" then
return 2.4
elseif s == "Y" or s == "y" then
return 2.5
elseif s == "Z" or s == "z" then
return 2.6
else
return 0.3
endif
return 0.0
endfunction
function GetPlayerColoredName takes integer i returns string
if i == 0 then
return ("|c00ff0202" + (GetPlayerName(Player(0)) + "|r"))
elseif i == 1 then
return ("|c000041ff" + (GetPlayerName(Player(1)) + "|r" ))
elseif i == 2 then
return ("|c001be5b8" + (GetPlayerName(Player(2)) + "|r" ))
elseif i == 3 then
return ("|c00530080" + (GetPlayerName(Player(3)) + "|r" ))
elseif i == 4 then
return ("|c00fffc00" + (GetPlayerName(Player(4)) + "|r" ))
elseif i == 5 then
return ("|c00fe890d" + (GetPlayerName(Player(5)) + "|r" ))
elseif i == 6 then
return ("|c001fbf00" + (GetPlayerName(Player(6)) + "|r" ))
elseif i == 7 then
return ("|c00e45aaf" + (GetPlayerName(Player(7)) + "|r" ))
elseif i == 10 then
return ("|c000f6145" + (GetPlayerName(Player(10)) + "|r" ))
elseif i == 11 then
return ("|c004d2903" + (GetPlayerName(Player(11)) + "|r" ))
endif
return null
endfunction
function EchoForce takes force toForce, real duration, string message returns nothing
if (IsPlayerInForce(GetLocalPlayer(), toForce)) then
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, duration, message)
endif
endfunction
function EchoAllPlayers takes real duration, string message returns nothing
if (IsPlayerInForce(GetLocalPlayer(), bj_FORCE_ALL_PLAYERS)) then
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, duration, message)
endif
endfunction
function EchoPlayer takes integer PId, string text returns nothing
DisplayTextToPlayer(Player(PId),0,0, text)
endfunction
function EchoPlayerM takes integer PId, string text returns nothing // minute edition
DisplayTimedTextToPlayer(Player(PId),0,0, 60., text)
endfunction
function ClearPlayerTextMessages takes integer PId returns nothing
if GetLocalPlayer() == Player(PId)
ClearTextMessages()
endif
endfunction
endlibrary
call
s, and I see { ... } syntax in the struct definition in the code you posted? I for the life of me have no idea if Zinc needs something special installed in the WE to work or if WEX supports it naturally. At any rate, try importing library C into your map and seeing if that gets rid of the EchoPlayer errors. If you can't, then add this into your map:function EchoPlayer takes integer PId, string text returns nothing
call DisplayTextToPlayer(Player(PId),0,0, text)
endfunction
library HashLibraryWorkaround initializer init
globals
hashtable Main_Hash
endglobals
private function init takes nothing returns nothing
set Main_Hash = InitHashTable()
endfunction
endlibrary
call TriggerAddCondition( gg_trg_RangeChecker, Condition( function Trig_RangeChecker_Conditions ) )
since I don't see that condition function anywhere in your code. If you do get that error, just put // in that line just before the "call" to comment it out.Please do this.Could you create new threads for new problems