WolfieeifloW
WEHZ Helper
- Reaction score
- 372
TSA And Spawn Testing
By: Wolfie[NoCT]
By: Wolfie[NoCT]
I've been playing around the past few days;
Just practicing things.
It started off with making a test for TriggerSleepAction().
I hated having to exit WC3, change stuff, then test again so I added a function to allow me to change things in-game.
This turned into me making everything customizable in-game.
I then made a cool little spawn/kill testing map.
I decided to post these for people to play around with.
Trigger Forewarning said:This is not meant to be a "serious" project or anything;
It's just for fun to play around with.
Anyways, here they are...
TSA Testing
Spawn Testing
I had to split it into two posts because it was too long as one.
TSA Testing
JASS:
// +------------------------------------------------------------+
// | |
// | -=-=- TSA Test [v1.0] -=-=- |
// | -=-=- By Wolfie[NoCT] -=-=- |
// | Requires Jass NewGen and ColorIt |
// | |
// +------------------------------------------------------------+
// | |
// | A TSA test; Well...That's what this started out as. It |
// | quickly turned into a map with a thousand different |
// | in-game customizable things. Either way; It's a |
// | fun little map to play around with; Try it out! |
// | |
// +------------------------------------------------------------+
// | -=-=- Things To Fix -=-=- |
// | -Telling user there's a loop in progress |
// +------------------------------------------------------------+
// | -=-=- Version History -=-=- |
// | |
// | Version 1.0 |
// | - Initial release |
// | |
// +------------------------------------------------------------+
scope TSATest initializer TTInit
// +---------------------------------+
// | -=-=- MODIFY HERE -=-=- |
// | -=-=- MODIFY HERE -=-=- |
// | -=-=- MODIFY HERE -=-=- |
// +---------------------------------+
globals
private real INTERVAL = 0.01 //Initial TSA interval
private integer LOOPS = 25 //Initial amount of loops
private integer DOTNUM = 15 //Initial amount of dots before reset
private string LOOPMSG = "Running loop" //Message to display while loop is running
private string XCOL = "gold" //Initial 'X' color
private string CCOL = "red" //Initial command color
private string MAPCOL = "cyan" //Initial map name color
private string NAMESCOL = "gold" //Initial name color
private string NUMCOL = "green" //Initial number color
private constant integer COLORSNUM = 10 //Number of colors in COLORS array
//Don't touch this!
private string array COLORS//Don't touch this!
//Don't touch this!
endglobals
// +------------------------------+
// | Initiation of colors |
// +------------------------------+
private function COLORInit takes nothing returns nothing
set COLORS[0] = "red"
set COLORS[1] = "gold"
set COLORS[2] = "cyan"
set COLORS[3] = "blue"
set COLORS[4] = "brown"
set COLORS[5] = "grey"
set COLORS[6] = "gray"
set COLORS[7] = "green"
set COLORS[8] = "orange"
set COLORS[9] = "pink"
//set COLORS[10] = ""
//Make sure to change "COLORSNUM" to the amount of array slots used
endfunction
// +------------------------------------------+
// | -=-=- NO TOUCHIE PAST HERE -=-=- |
// | -=-=- NO TOUCHIE PAST HERE -=-=- |
// | -=-=- NO TOUCHIE PAST HERE -=-=- |
// +------------------------------------------+
globals
private real array BIG
private real array SMALL
private real array OFFSET
private real array INT
private boolean array ABORTED
private integer array LOOPARRAY
private integer RT = 0
private integer I = 0
private boolean STOPPED = false
endglobals
//==========================================================
//========== "Useful" Functions ==========
//==========================================================
// +---------------------------------+
// | Check if color is valid |
// +---------------------------------+
private function CheckColor takes string Col returns boolean
local integer i = 0
local boolean cc = false
loop
exitwhen i == COLORSNUM
if (Col != COLORS<i>) then //If the current looped color doesn't equal a known one
set cc = false //Keep boolean false
else //If it is known
return true //Return true
endif
set i = i + 1
endloop
return cc //Will only occur if input color is not known; AKA will return false
endfunction
//=========================================================================================================
//========== The "Real" Code -=-=- The "Real" Code -=-=- The "Real" Code -=-=- ==========
//========== The "Real" Code -=-=- The "Real" Code -=-=- The "Real" Code -=-=- ==========
//========== The "Real" Code -=-=- The "Real" Code -=-=- The "Real" Code -=-=- ==========
//=========================================================================================================
//=========================================================
//========== TSA Test Function ==========
//=========================================================
private function TTActions takes nothing returns nothing
local real array gt
local real big = 0
local real small = 0
local real array offset
local string loopmsg = LOOPMSG
if (I == 0) then //Check if loop is currently running already or not
loop
exitwhen I == LOOPS
set gt<i> = GetFloatGameState(GAME_STATE_TIME_OF_DAY) //Get current time
call TriggerSleepAction(INTERVAL)
set gt<i> = GetFloatGameState(GAME_STATE_TIME_OF_DAY) - gt<i> //Get time after wait
if (gt<i> > gt[I - 1]) then //Setting of big to the largest wait
set big = gt<i>
elseif (gt<i> < gt[I - 1]) then //Setting of small to the smallest wait
set small = gt<i>
endif
if (ModuloInteger(I, DOTNUM + 1) == 0) then
set loopmsg = LOOPMSG //Making the string telling the
else //User the loop is running reset the
set loopmsg = loopmsg + "." //Dots if it gets to the specified amount
endif
call ClearTextMessages()
call BJDebugMsg(loopmsg) //Shows the loop message
set I = I + 1
endloop
set offset[0] = INTERVAL - small //
set offset[1] = big - INTERVAL //
if (offset[0] > offset[1]) then //Setting of the largest
set offset[3] = offset[0] //Offset that occured
elseif (offset[0] < offset[1]) then //Throughout the entire
set offset[3] = offset[1] //Looping
else //
set offset[3] = offset[0] //
endif
set BIG[RT] = big //Set BIG at the current results
set SMALL[RT] = small //Set SMALL at the current results
set OFFSET[RT] = offset[3] //Set OFFSET at the current results
set INT[RT] = INTERVAL //Set INT(erval) at the current results
set LOOPARRAY[RT] = LOOPS //Set LOOPARRAY at the current results
if (RT < 8190) then //
set RT = RT + 1 //
else //Recycling of RT
set RT = 0 //
endif //
if (STOPPED == false) then //If the test was completed
call ClearTextMessages()
call BJDebugMsg("Results for test " + ColorIt(NUMCOL, I2S(RT - 1)) + " at interval " + ColorIt(NUMCOL, R2S(INTERVAL)) + " looped " + ColorIt(NUMCOL, I2S(LOOPS)) + " times:")
call BJDebugMsg("The biggest wait was " + ColorIt(NUMCOL, R2S(big)) + ".")
call BJDebugMsg("The smallest wait was " + ColorIt(NUMCOL, R2S(small)) + ".")
call BJDebugMsg("The largest offset was " + ColorIt(NUMCOL, R2S(offset[3])) + ".")
//Displays all the information to the user
set I = 0
elseif (STOPPED == true) then //If test was stopped
call ClearTextMessages()
call BJDebugMsg("Test aborted!") //Tell user
set I = 0
set ABORTED[RT - 1] = true //Set ABORTED to true for that test
set STOPPED = false
endif
else //If there's already a loop going
call BJDebugMsg("There039;s another loop already in progress!") //Tell user so
endif
endfunction
//=======================================================
//========== Loops Functions ==========
//=======================================================
// +-----------------------+
// | Setting Loops |
// +-----------------------+
private function LoopSetActions takes nothing returns nothing
if (I == 0) then //If there's not a loop already going
if (GetEventPlayerChatString() == "-loop") then //If the string is just "-loop"
call BJDebugMsg("Please enter a number after " + ColorIt(CCOL, "-loop") + "!") //Tell user to enter a value
return
endif
if (LOOPS >= 1) then //Check to make sure it's greater then 0
set LOOPS = S2I(SubString(GetEventPlayerChatString(), 6, StringLength(GetEventPlayerChatString()))) //Set it to entered value
endif
if (LOOPS <= 0) then //If the input is less then 0
call BJDebugMsg("Please enter a number after " + ColorIt(CCOL, "-loop") + "!") //Tell user to enter a valid number
return
endif
call BJDebugMsg("=========================")
call BJDebugMsg("Number of loops is now set to " + ColorIt(NUMCOL, I2S(LOOPS)) + "!")
endif
endfunction
// +------------------------+
// | Checking Loops |
// +------------------------+
private function LoopActions takes nothing returns nothing
if (I == 0) then //Make sure there's a not a loop already running
call BJDebugMsg("=========================")
call BJDebugMsg("Number of loops is currently: " + ColorIt(NUMCOL, I2S(LOOPS)) + "!")
endif
endfunction
//==========================================================
//========== Interval Functions ==========
//==========================================================
// +--------------------------+
// | Setting Interval |
// +--------------------------+
private function SetActions takes nothing returns nothing
local real int = S2R(SubString(GetEventPlayerChatString(), 5, StringLength(GetEventPlayerChatString())))
if (I == 0) then //If there's no loop running
if (GetEventPlayerChatString() == "-int") then //Check if string is just "-int"
call BJDebugMsg("Please enter a number after " + ColorIt(CCOL, "-int") + "!") //Tell user to enter a number
return
endif
if (int < 0.01) then //If the input is lower then 0.01
call BJDebugMsg("Please enter a number larger then " + ColorIt(NAMESCOL, "0.009") + "!") //Tell user to enter a higher number
return
elseif (int >= 0.01) then //If it's high enough
set INTERVAL = int
endif
call BJDebugMsg("=========================")
call BJDebugMsg("INTERVAL is now: " + ColorIt(NUMCOL, R2S(INTERVAL)) + ".")
endif
endfunction
// +---------------------------+
// | Checking Interval |
// +---------------------------+
private function IntActions takes nothing returns nothing
if (I == 0) then //Check if a loop is currently running
call BJDebugMsg("=========================")
call BJDebugMsg("INTERVAL is currently: " + ColorIt(NUMCOL, R2S(INTERVAL)) + "!")
endif
endfunction
//=====================================================
//========== Dot Functions ==========
//=====================================================
// +---------------------+
// | Dot Setting |
// +---------------------+
private function DotsActions takes nothing returns nothing
if (I == 0) then //If there's no loop running
if (GetEventPlayerChatString() == "-dots") then //Check if just "-dots" was input
call BJDebugMsg("Please enter a number after " + ColorIt(CCOL, "-dots") + "!") //Tell user to enter a number
return
endif
if (DOTNUM >= 1) then //If input is greater then 0
set DOTNUM = S2I(SubString(GetEventPlayerChatString(), 6, StringLength(GetEventPlayerChatString())))
endif
if (DOTNUM <= 0) then //If it's 0 or lower
call BJDebugMsg("Please enter a number after " + ColorIt(CCOL, "-dots") + "!") //Tell user to enter a valid number
return
endif
call BJDebugMsg("=========================")
call BJDebugMsg("DOTNUM is now: " + ColorIt(NUMCOL, I2S(DOTNUM)) + "!")
endif
endfunction
// +----------------------+
// | Dot Checking |
// +----------------------+
private function DotCheckActions takes nothing returns nothing
if (I == 0) then //If there's no loop currently running
call BJDebugMsg("=========================")
call BJDebugMsg("DOTNUM is currently: " + ColorIt(NUMCOL, I2S(DOTNUM)) + "!")
endif
endfunction
//========================================================
//========== Results Function ==========
//========================================================
private function ResultsActions takes nothing returns nothing
local string rtnum = SubString(GetEventPlayerChatString(), 5, StringLength(GetEventPlayerChatString()))
local integer rtt = S2I(rtnum)
if (I == 0) then //If there's no loop currently running
if (GetEventPlayerChatString() == "/res") then //If string is solely "/res"
call BJDebugMsg("Please enter a number after " + ColorIt(CCOL, "/res") + "!") //Tell user to enter a number
return
endif
if (BIG[rtt] == 0 or SMALL[rtt] == 0) then //If the results for BIG or SMALL are 0 for input results
call ClearTextMessages()
call BJDebugMsg("No results for [" + ColorIt(NUMCOL, I2S(rtt)) + "]!") //Tell user there's no results for that test
elseif (ABORTED[rtt] == true) then //If input test was aborted
call ClearTextMessages()
call BJDebugMsg("Test " + ColorIt(NUMCOL, I2S(rtt)) + " was aborted!") //Tell user so
else
call ClearTextMessages()
call BJDebugMsg("Results for test " + ColorIt(NUMCOL, I2S(rtt)) + " at " + ColorIt(NUMCOL, R2S(INT[rtt])) + " looped " + ColorIt(NUMCOL, I2S(LOOPARRAY[rtt])) + " times:")
call BJDebugMsg("The biggest wait was: " + ColorIt(NUMCOL, R2S(BIG[rtt])) + ".")
call BJDebugMsg("The smallest wait was: " + ColorIt(NUMCOL, R2S(SMALL[rtt])) + ".")
call BJDebugMsg("The largest offset was: " + ColorIt(NUMCOL, R2S(OFFSET[rtt])) + ".")
//Else show the results for input test
endif
endif
endfunction
//=============================================================
//========== Command List Function ==========
//=============================================================
private function CommandsActions takes nothing returns nothing
if (I == 0) then //If there's not a loop runnning
call ClearTextMessages()
//Show the command list to the user
call BJDebugMsg("Commands for " + ColorIt(MAPCOL, "TSA Test") + " by " + ColorIt(NAMESCOL, "Wolfie[NoCT]") + ":")
call BJDebugMsg("Press " + ColorIt(CCOL, "ESC") + " to run the test.")
call BJDebugMsg("Type " + ColorIt(CCOL, "-stop") + " at anytime to stop a test.")
call BJDebugMsg("Type " + ColorIt(CCOL, "-loop") + " " + ColorIt(XCOL, "X") + " to set the number of loops to " + ColorIt(XCOL, "X") + ".")
call BJDebugMsg("Type " + ColorIt(CCOL, "/loop") + " to check the current number of loops.")
call BJDebugMsg("Type " + ColorIt(CCOL, "-int") + " " + ColorIt(XCOL, "X") + " to set the TSA time to " + ColorIt(XCOL, "X") + ".")
call BJDebugMsg("Type " + ColorIt(CCOL, "/int") + " to check the current TSA time.")
call BJDebugMsg("Type " + ColorIt(CCOL, "/res") + " " + ColorIt(XCOL, "X") + " to check the results for " + ColorIt(XCOL, "X") + " test.")
call BJDebugMsg("Type " + ColorIt(CCOL, "-ncol") + " " + ColorIt(XCOL, "X") + " to set the color of names.")
call BJDebugMsg("Type " + ColorIt(CCOL, "-mcol") + " " + ColorIt(XCOL, "X") + " to set the color of the map name.")
call BJDebugMsg("Type " + ColorIt(CCOL, "-ccol") + " " + ColorIt(XCOL, "X") + " to set the color of commands.")
call BJDebugMsg("Type " + ColorIt(CCOL, "-xcol") + " " + ColorIt(XCOL, "X") + " to set the color of X039;s.")
call BJDebugMsg("Type " + ColorIt(CCOL, "-numcol") + " " + ColorIt(XCOL, "X") + " to set the color of numbers.")
call BJDebugMsg("Type " + ColorIt(CCOL, "-dots") + " " + ColorIt(XCOL, "X") + " to set the number of dots.")
call BJDebugMsg("Type " + ColorIt(CCOL, "/dots") + " to check the current number of dots.")
call BJDebugMsg("Type " + ColorIt(CCOL, "/clist") + " to see a list of colors!")
endif
endfunction
//==========================================================
//========== Coloring Functions ==========
//==========================================================
// +-----------------------+
// | Name Coloring |
// +-----------------------+
private function NameActions takes nothing returns nothing
local string name = SubString(GetEventPlayerChatString(), 6, StringLength(GetEventPlayerChatString()))
if (I == 0) then //If there's no loop running
if (GetEventPlayerChatString() == "-ncol") then //Check if just "-ncol" was input
call BJDebugMsg("Please enter a color after " + ColorIt(CCOL, "-ncol") + "!") //Tell the user to put in a color
return
elseif (CheckColor(name) == false) then //If input color is invalid
call BJDebugMsg("Invalid color, type " + ColorIt(CCOL, "/clist") + " to view the colors list!") //Tell user so
elseif (CheckColor(name) == true)then //Elseif input color is valid
set NAMESCOL = name
call BJDebugMsg("=========================")
call BJDebugMsg("Names will now be colored " + ColorIt(NAMESCOL, NAMESCOL) + "!")
endif
endif
endfunction
// +---------------------------+
// | Map Name Coloring |
// +---------------------------+
private function MapNameActions takes nothing returns nothing
local string map = SubString(GetEventPlayerChatString(), 6, StringLength(GetEventPlayerChatString()))
if (I == 0) then //If there's no loop running
if (GetEventPlayerChatString() == "-mcol") then //Check if just "-mcol" was input
call BJDebugMsg("Please enter a color after " + ColorIt(CCOL, "-mcol") + "!") //Tell the user to put in a color
return
elseif (CheckColor(map) == false) then //If input color is invalid
call BJDebugMsg("Invalid color, type " + ColorIt(CCOL, "/clist") + " to view the colors list!") //Tell user so
elseif (CheckColor(map) == true)then //Elseif input color is valid
set MAPCOL = map
call BJDebugMsg("=========================")
call BJDebugMsg("The map names will now be colored " + ColorIt(MAPCOL, MAPCOL) + "!")
endif
endif
endfunction
// +--------------------------+
// | Command Coloring |
// +--------------------------+
private function ComColActions takes nothing returns nothing
local string comcol = SubString(GetEventPlayerChatString(), 6, StringLength(GetEventPlayerChatString()))
if (I == 0) then //If there's no loop running
if (GetEventPlayerChatString() == "-ccol") then //Check if just "-ccol" was input
call BJDebugMsg("Please enter a color after " + ColorIt(CCOL, "-ccol") + "!") //Tell the user to put in a color
return
elseif (CheckColor(comcol) == false) then //If input color is invalid
call BJDebugMsg("Invalid color, type " + ColorIt(CCOL, "/clist") + " to view the colors list!") //Tell user so
elseif (CheckColor(comcol) == true)then //Elseif input color is valid
set CCOL = comcol
call BJDebugMsg("=========================")
call BJDebugMsg("Commands will now be colored " + ColorIt(CCOL, CCOL) + "!")
endif
endif
endfunction
// +----------------------+
// | 'X' Coloring |
// +----------------------+
private function XColActions takes nothing returns nothing
local string xcol = SubString(GetEventPlayerChatString(), 6, StringLength(GetEventPlayerChatString()))
if (I == 0) then //If there's no loop running
if (GetEventPlayerChatString() == "-xcol") then //Check if just "-xcol" was input
call BJDebugMsg("Please enter a color after " + ColorIt(CCOL, "-xcol") + "!") //Tell the user to put in a color
return
elseif (CheckColor(xcol) == false) then //If input color is invalid
call BJDebugMsg("Invalid color, type " + ColorIt(CCOL, "/clist") + " to view the colors list!") //Tell user so
elseif (CheckColor(xcol) == true)then //Elseif input color is valid
set XCOL = xcol
call BJDebugMsg("=========================")
call BJDebugMsg("X039;s will now be colored " + ColorIt(XCOL, XCOL) + "!")
endif
endif
endfunction
//===========================================================
//========== Color List Function ==========
//===========================================================
private function ColListActions takes nothing returns nothing
if (I == 0) then //If there's no loop running
call ClearTextMessages()
//Show user a list of colors
call BJDebugMsg("List of colors:")
call BJDebugMsg(ColorIt("red", "red"))
call BJDebugMsg(ColorIt("gold", "gold"))
call BJDebugMsg(ColorIt("cyan", "cyan"))
call BJDebugMsg(ColorIt("blue", "blue"))
call BJDebugMsg(ColorIt("brown", "brown"))
call BJDebugMsg(ColorIt("grey", "grey"))
call BJDebugMsg(ColorIt("green", "green"))
call BJDebugMsg(ColorIt("orange", "orange"))
call BJDebugMsg(ColorIt("pink", "pink"))
endif
endfunction
//=====================================================
//========== Stop Function ==========
//=====================================================
private function StopActions takes nothing returns nothing
if (I != 0) then //If there IS a loop running
set I = LOOPS - 1 //Set I to the input number of LOOPS - 1 (To stop the loop)
set STOPPED = true
endif
endfunction
//============================================================
//========== Initializer Function ==========
//============================================================
private function TTInit takes nothing returns nothing
local trigger t = CreateTrigger()
//Spawn function
call TriggerRegisterPlayerEvent(t, Player(0), EVENT_PLAYER_END_CINEMATIC)
call TriggerAddAction(t, function TTActions)
//Set loop
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, Player(0), "-loop", false)
call TriggerAddAction(t, function LoopSetActions)
//Check loop
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, Player(0), "/loop", true)
call TriggerAddAction(t, function LoopActions)
//Set interval
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, Player(0), "-int", false)
call TriggerAddAction(t, function SetActions)
//Check interval
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, Player(0), "/int", true)
call TriggerAddAction(t, function IntActions)
//Set dots
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, Player(0), "-dots", false)
call TriggerAddAction(t, function DotsActions)
//Check dots
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, Player(0), "/dots", true)
call TriggerAddAction(t, function DotCheckActions)
//Check results
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, Player(0), "/res", false)
call TriggerAddAction(t, function ResultsActions)
//Command list
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, Player(0), "/com", true)
call TriggerAddAction(t, function CommandsActions)
//Set name color
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, Player(0), "-ncol", false)
call TriggerAddAction(t, function NameActions)
//Set map name color
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, Player(0), "-mcol", false)
call TriggerAddAction(t, function MapNameActions)
//Set command colod
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, Player(0), "-ccol", false)
call TriggerAddAction(t, function ComColActions)
//Set 'X' color
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, Player(0), "-xcol", false)
call TriggerAddAction(t, function XColActions)
//Color list
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, Player(0), "/clist", true)
call TriggerAddAction(t, function ColListActions)
//Stop loop
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, Player(0), "-stop", true)
call TriggerAddAction(t, function StopActions)
//Color initialization
set t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 0.01, false)
call TriggerAddAction(t, function COLORInit)
endfunction
endscope</i></i></i></i></i></i></i></i>