//TESH.scrollpos=0
//TESH.alwaysfold=0
function ErrorMessage takes string error, player whichPlayer returns nothing
if udg_ErrorSound == null then
set udg_ErrorSound = CreateSoundFromLabel("InterfaceError",false,false,false,10,10)
endif
set error = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+error+"|r"
if GetLocalPlayer()==whichPlayer then
call ClearTextMessages()
call DisplayTimedTextToPlayer(whichPlayer,0.52,0.96,2,error)
call StartSound(udg_ErrorSound)
endif
endfunction
Name | Type | is_array | initial_value |
Alpha_Strike_Base_Pos | location | Yes | |
Alpha_Strike_Base_Target | unit | Yes | |
Alpha_Strike_Base_Target_Pos | location | No | |
Alpha_Strike_Blade | effect | Yes | |
Alpha_Strike_Group | group | No | |
Alpha_Strike_Mui_Integer | integer | No | |
Alpha_Strike_Mui_Loop | integer | No | |
Alpha_Strike_Mui_Turnoff | integer | No | |
Alpha_Strike_Off | boolean | Yes | |
Alpha_Strike_Pos | location | No | |
Alpha_Strike_Pos_Off | location | No | |
Alpha_Strike_Striker | unit | Yes | |
Alpha_Strike_Target | unit | Yes | |
Alpha_Strike_Target_Pos | location | No | |
Alpha_Strike_Targeted_Group | group | Yes | |
Bleed_Bleeded | unit | Yes | |
Bleed_Bleeder | unit | Yes | |
Bleed_Mui_Integer | integer | No | |
Bleed_Mui_Loop | integer | No | |
Bleed_Mui_Turnoff | integer | No | |
Bleed_Off | boolean | Yes | |
Bleed_Pos | location | No | |
Bleed_Previous_Pos | location | Yes | |
Bleed_Time | integer | Yes | 8 |
Borrowed_Cooldown | boolean | No | |
Borrowed_Effect | effect | No | |
Borrowed_Time | integer | No | |
Borrowed_Time_Cast_Integer | integer | No | |
Borrowed_Time_Cast_Loop | integer | No | |
Borrowed_Time_Cast_Off | boolean | Yes | |
Borrowed_Time_Cast_Time | integer | Yes | |
Borrowed_Time_Cast_Turnoff | integer | No | |
Borrowed_Time_Checking_Loop | integer | No | |
Borrowed_Time_Cooldown | boolean | Yes | |
Borrowed_Time_Damage_Loop | integer | No | |
Borrowed_Time_Loop | integer | No | |
Borrowed_Time_Mui_Integer | integer | No | |
Borrowed_Time_Mui_Turnoff | integer | No | |
Borrowed_Time_Off | boolean | Yes | |
Borrowed_Time_Sfx | effect | Yes | |
Borrowed_Time_Spell_Integer | integer | No | |
Borrowed_Time_Spell_Loop | integer | No | |
Borrowed_Time_Spell_Time | integer | Yes | |
Borrowed_Time_Spell_Turnoff | integer | No | |
Borrowed_Time_Unit | unit | Yes | |
Borrower | unit | No | |
Boss_Spell_Cooldown | boolean | Yes | |
Boss_Spell_Integer | integer | No | 2 |
Burnout_Burning | boolean | No | |
Burnout_Casts | integer | No | |
Burnout_Mana | real | No | |
Burnout_Sfx | effect | No | |
Burnouter | unit | No | |
Chain_Distance | real | Yes | |
Chain_Link_Mui_Integer | integer | No | |
Chain_Link_Mui_Loop | integer | No | |
Chain_Link_Mui_Turnoff | integer | No | |
Chain_Link_Off | boolean | Yes | |
Chain_Link_Unit | unit | Yes | |
Chain_Linked_Unit | unit | Yes | |
Chain_Pos | location | No | |
Chain_Time | integer | Yes | |
Chained_Chain | lightning | Yes | |
Chained_Pos | location | No | |
Creation_Points | location | Yes | |
Devastating_Check | integer | Yes | |
Devastating_Check_Mui_Integer | integer | No | |
Devastating_Check_Mui_Loop | integer | No | |
Devastating_Check_Mui_Turnoff | integer | No | |
Devastating_Check_Off | boolean | Yes | |
Devastating_Health_Mui_Integer | integer | No | |
Devastating_Health_Mui_Loop | integer | No | |
Devastating_Health_Mui_Turnoff | integer | No | |
Devastating_Health_Off | boolean | Yes | |
Devastating_Mui_Integer | integer | No | |
Devastating_Mui_Loop | integer | No | |
Devastating_Mui_Turnoff | integer | No | |
Devastating_Off | boolean | Yes | |
Devastation_Group | group | Yes | |
Devastation_Time | integer | Yes | |
Devastator | unit | Yes | |
Devastator_Facing | real | Yes | |
Devastator_Health_Time | integer | Yes | |
Devastator_Height | real | Yes | |
Devastator_Pos | location | No | |
Devastator_Pos_Off | location | No | |
Devastator_Target | unit | Yes | |
Devastator_Target_Pos | location | No | |
Devastator_Target_Pos_Off | location | No | |
Dual_Weapon_Mui_Integer | integer | No | |
Dual_Weapon_Mui_Loop | integer | No | |
Dual_Weapon_Mui_Turnoff | integer | No | |
Dual_Weapon_Off | boolean | Yes | |
Dual_Weapon_Sfx | effect | Yes | |
Dual_Weapon_Time | integer | Yes | |
Duelist | unit | Yes | |
Empathic_Warp | lightning | No | |
Empathic_Warp_Dmg_Amount | real | No | |
Empathic_Warp_Group | group | No | |
Empathic_Warp_Sfx | effect | No | |
Empathic_Warp_Time | integer | No | |
Empathic_Warpee | unit | No | |
Empathic_Warpee_Pos | location | No | |
Empathic_Warper | unit | No | |
Empathic_Warper_Life | real | No | |
Empathic_Warper_Pos | location | No | |
ErrorMessage | string | No | |
ErrorPlayer | player | No | |
ErrorSound | sound | No | |
Essence_Shift_Percentage | real | No | |
Eye_Tornado_Caster | unit | Yes | |
Eye_Tornado_Checking | integer | No | |
Eye_Tornado_Dummies | unit | Yes | |
Eye_Tornado_Group | group | No | |
Eye_Tornado_Group_2 | group | Yes | |
Eye_Tornado_Group_Pos | location | No | |
Eye_Tornado_Inside_Loop | integer | No | |
Eye_Tornado_Mui_Integer | integer | No | |
Eye_Tornado_Mui_Loop | integer | No | |
Eye_Tornado_Mui_Turnoff | integer | No | |
Eye_Tornado_Off | boolean | Yes | |
Eye_Tornado_Pos | location | No | |
Eye_Tornado_Pos_Off | location | No | |
Eye_Tornado_Pos_Tornados | location | No | |
Fifth_Unit_Type | integer | Yes | |
First_Unit_Type | integer | Yes | |
Force_Pos | location | No | |
Force_Pos_Off | location | No | |
Force_Staff_Distance | real | Yes | |
Force_Staff_Facing | real | Yes | |
Force_Staff_Mui_Integer | integer | No | |
Force_Staff_Mui_Loop | integer | No | |
Force_Staff_Mui_Turnoff | integer | No | |
Force_Staff_Off | boolean | Yes | |
Force_Staff_Unit | unit | Yes | |
Fortune_Reversal_Health | real | No | |
Fortune_Reversal_Mana | real | No | |
Fortune_Reversed | unit | No | |
Fourth_Unit_Type | integer | Yes | |
Frost_Aura_Loop | integer | No | |
Frost_Aura_Mui_Integer | integer | No | |
Frosty | unit | Yes | |
Frosty_Effect | effect | No | |
Frosty_Group | group | No | |
Frosty_Groupie_Two | group | No | |
Frosty_Pos | location | No | |
GDD__Integers | integer | Yes | |
GDD__LeftMapGroup | group | No | |
GDD__TriggerArray | trigger | Yes | |
GDD__UnitArray | unit | Yes | |
GDD_Damage | real | No | |
GDD_DamagedUnit | unit | No | |
GDD_DamageSource | unit | No | |
GDD_Event | real | No | |
Highlander_Group | group | No | |
Highlander_Mui_Integer | integer | No | |
Highlander_Mui_Loop | integer | No | |
Highlander_Mui_Turnoff | integer | No | |
Highlander_Off | boolean | Yes | |
Highlander_Pos | location | No | |
Highlander_Time | integer | Yes | |
Highlander_Unit | unit | Yes | |
Meditate_Mui_Integer | integer | No | |
Meditate_Mui_Loop | integer | No | |
Meditate_Mui_Turnoff | integer | No | |
Meditate_Off | boolean | Yes | |
Meditate_Sfx | effect | No | |
Meditate_Stop_Loop | integer | No | |
Meditate_Time | integer | Yes | |
Meditator | unit | Yes | |
Mind_Explosion_Death | group | No | |
Mind_Explosion_Death_Pos | location | No | |
Mind_Explosion_Group | group | No | |
Mind_Explosion_Pos | location | No | |
Multi_Shot_Angles | integer | Yes | |
Multi_Shot_Distance | real | Yes | |
Multi_Shot_Dummies | unit | Yes | |
Multi_Shot_Facing | real | Yes | |
Multi_Shot_Group | group | No | |
Multi_Shot_Group_2 | group | Yes | |
Multi_Shot_Inside_Loop | integer | No | |
Multi_Shot_Mui_Integer | integer | No | |
Multi_Shot_Mui_Loop | integer | No | |
Multi_Shot_Mui_Turnoff | integer | No | |
Multi_Shot_Off | boolean | Yes | |
Multi_Shot_Pos | location | No | |
Multi_Shot_Pos_Off | location | No | |
Multi_Shot_Unit | unit | Yes | |
Penitence_Mui_Integer | integer | No | |
Penitence_Mui_Loop | integer | No | |
Penitence_Mui_Turnoff | integer | No | |
Penitence_Off | boolean | Yes | |
Penitence_Stop_Loop | integer | No | |
Penitence_Time | integer | Yes | |
Penitenced_Pos | location | No | |
Penitencer | unit | Yes | |
Penitencer_Facing | real | Yes | |
Penitencer_Target | unit | Yes | |
Preload_Point | location | No | |
Random_Area | real | No | |
Random_Group | group | No | |
Random_Group_Random_People | group | No | |
Random_Position | location | No | |
Reverse_Polarity_Group | group | No | |
Reverse_Polarity_Pos_Off | location | No | |
Reverse_Polarity_Position | location | No | |
Revive_Pos | location | No | |
Second_Unit_Type | integer | Yes | |
Sneaky_Floatin | texttag | No | |
Sneaky_Kill_Count | real | Yes | |
Sneaky_Kill_Loop | integer | No | |
Sneaky_Mui_Integer | integer | No | |
Sneaky_Mui_Loop | integer | No | |
Sneaky_Pos | location | No | |
Sneaky_Previous_Pos | location | Yes | |
Sneaky_Ranger | unit | Yes | |
Snipe_Shot_Dummies | unit | Yes | |
Snipe_Shot_Group | group | No | |
Snipe_Shot_Mui_Integer | integer | No | |
Snipe_Shot_Mui_Loop | integer | No | |
Snipe_Shot_Mui_Turnoff | integer | No | |
Snipe_Shot_Off | boolean | Yes | |
Snipe_Shot_Pos | location | No | |
Snipe_Shot_Pos_Off | location | No | |
Snipe_Shot_Sniper | unit | Yes | |
Snipe_Shot_Target | unit | Yes | |
Snipe_Shot_Target_Pos | location | No | |
Sonic_Blaster_Blaster | unit | Yes | |
Sonic_Blaster_Damage | real | Yes | |
Sonic_Blaster_Dummy | unit | Yes | |
Sonic_Blaster_Group | group | No | |
Sonic_Blaster_Mui_Integer | integer | No | |
Sonic_Blaster_Mui_Loop | integer | No | |
Sonic_Blaster_Mui_Turnoff | integer | No | |
Sonic_Blaster_Off | boolean | Yes | |
Sonic_Blaster_Pos | location | No | |
Sonic_Blaster_Pos_Off | location | No | |
Sonic_Blaster_Target | unit | Yes | |
Sonic_Blaster_Target_Pos | location | No | |
Sonic_Rush_Damage | real | Yes | |
Sonic_Rush_Distance | integer | Yes | |
Sonic_Rush_Facing | real | Yes | |
Sonic_Rush_Group | group | No | |
Sonic_Rush_Group_2 | group | Yes | |
Sonic_Rush_Mui_Integer | integer | No | |
Sonic_Rush_Mui_Loop | integer | No | |
Sonic_Rush_Mui_Turnoff | integer | No | |
Sonic_Rush_Off | boolean | Yes | |
Sonic_Rush_Pos | location | No | |
Sonic_Rush_Pos_Off | location | No | |
Sonic_Rush_Rusher | unit | Yes | |
Soul_Catch_Distance | real | Yes | |
Soul_Catch_Dummy | unit | Yes | |
Soul_Catch_Facing | real | Yes | |
Soul_Catch_Group | group | No | |
Soul_Catch_Group_2 | group | Yes | |
Soul_Catch_Hero | unit | Yes | |
Soul_Catch_Mui_Integer | integer | No | |
Soul_Catch_Mui_Loop | integer | No | |
Soul_Catch_Mui_Turnoff | integer | No | |
Soul_Catch_Off | boolean | Yes | |
Soul_Catch_Pos | location | No | |
Soul_Catch_Pos_Off | location | No | |
Soul_Mastery_Hero | unit | Yes | |
Soul_Mastery_Integer | integer | No | |
Soul_Movement_Group | group | No | |
Soul_Movement_Hero | unit | Yes | |
Soul_Movement_Hero_Face | location | No | |
Soul_Movement_Integer | integer | No | |
Soul_Movement_Loop | integer | No | |
Soul_Movement_Off | boolean | Yes | |
Soul_Movement_Pos | location | No | |
Soul_Movement_Pos_Off | location | No | |
Soul_Movement_Turnoff | integer | No | |
Soul_Movement_Unit | unit | Yes | |
Soul_Vortex_Caster | unit | Yes | |
Soul_Vortex_Centre_Unit | unit | Yes | |
Soul_Vortex_Creation | real | No | |
Soul_Vortex_Dummy | unit | Yes | |
Soul_Vortex_Extinction_Group | group | No | |
Soul_Vortex_Extinction_Loop | integer | No | |
Soul_Vortex_Extinction_Sfx | integer | No | |
Soul_Vortex_Group | group | No | |
Soul_Vortex_Group_2 | group | Yes | |
Soul_Vortex_Inside_Loop | integer | No | |
Soul_Vortex_Moving_Caster | unit | Yes | |
Soul_Vortex_Moving_Dummies | unit | Yes | |
Soul_Vortex_Moving_Facing | real | Yes | |
Soul_Vortex_Moving_Mui_Integer | integer | No | |
Soul_Vortex_Moving_Mui_Loop | integer | No | |
Soul_Vortex_Moving_Mui_Turnoff | integer | No | |
Soul_Vortex_Moving_Off | boolean | Yes | |
Soul_Vortex_Moving_Point | location | Yes | |
Soul_Vortex_Moving_Pos | location | No | |
Soul_Vortex_Moving_Pos_Off | location | No | |
Soul_Vortex_Moving_Sfx | effect | Yes | |
Soul_Vortex_Mui_Integer | integer | No | |
Soul_Vortex_Mui_Loop | integer | No | |
Soul_Vortex_Mui_Turnoff | integer | No | |
Soul_Vortex_Off | boolean | Yes | |
Soul_Vortex_Point | location | No | |
Soul_Vortex_Point_Off | location | No | |
Soul_Vortex_Time | integer | Yes | |
Spinning_Caster | unit | Yes | |
Spinning_Degrees | real | Yes | |
Spinning_Degrees_Two | real | Yes | |
Spinning_Dist_Check_Loop | integer | No | |
Spinning_Dist_Loop | integer | No | |
Spinning_Dist_Off | boolean | Yes | |
Spinning_Distance | real | Yes | |
Spinning_Distance_Integer | integer | No | |
Spinning_Distance_Turnoff | integer | No | |
Spinning_Dummy | unit | Yes | |
Spinning_Facing | real | Yes | |
Spinning_Group | group | No | |
Spinning_Group_Pick | group | Yes | |
Spinning_Mui_Integer | integer | No | |
Spinning_Mui_Loop | integer | No | |
Spinning_Mui_Turnoff | integer | No | |
Spinning_Off | boolean | Yes | |
Spinning_Pos | location | No | |
Spinning_Pos_Off | location | No | |
Spinning_Spinning_Caster | unit | Yes | |
Spinning_Spinning_Mui_Integer | integer | No | |
Spinning_Spinning_Mui_Loop | integer | No | |
Spinning_Spinning_Mui_Turnoff | integer | No | |
Spinning_Spinning_Off | boolean | Yes | |
Spinning_Spinning_Unit | unit | Yes | |
Spinning_Time | integer | Yes | |
Split_Mana_Amount | real | No | |
Split_Mana_Caster | unit | No | |
Split_Mana_Divided | real | No | |
Split_Mana_Group | group | No | |
Split_Mana_Group_Pos | location | No | |
Split_Mana_Integer | integer | No | |
Split_Mana_Pos | location | No | |
Starting_Group | group | No | |
Third_Unit_Type | integer | Yes | |
Tornado_Jump_Group | group | No | |
Tornado_Jump_Mui_Integer | integer | No | |
Tornado_Jump_Mui_Loop | integer | No | |
Tornado_Jump_Mui_Turnoff | integer | No | |
Tornado_Jump_Off | boolean | Yes | |
Tornado_Jump_Pos | location | No | |
Tornado_Jump_Target_Point | location | Yes | |
Tornado_Jump_Time | integer | Yes | |
Tornado_Jump_Unit | unit | Yes | |
Traceless_Mui_Integer | integer | No | |
Traceless_Mui_Loop | integer | No | |
Traceless_Mui_Turnoff | integer | No | |
Traceless_New_Check | integer | No | |
Traceless_Off | boolean | Yes | |
Traceless_Stop_Sneaky | boolean | Yes | |
Traceless_Time | integer | Yes | |
Traceless_Tracer | unit | Yes | |
Triple_Sonic_Damage | real | No | |
Unholy_Plats_Allie_Pos | location | No | |
Unholy_Plats_Caster | unit | Yes | |
Unholy_Plats_Dummies | unit | Yes | |
Unholy_Plats_Group | group | No | |
Unholy_Plats_Mui_Integer | integer | No | |
Unholy_Plats_Mui_Loop | integer | No | |
Unholy_Plats_Mui_Turnoff | integer | No | |
Unholy_Plats_Off | boolean | Yes | |
Unholy_Plats_Pos | location | No | |
Unholy_Plats_Pos_Off | location | No | |
Unholy_Plats_Target | unit | Yes | |
Unholy_Plats_Target_Pos | location | No | |
Unit_Cannon_AoE | real | No | |
Unit_Cannon_Caster | unit | Yes | |
Unit_Cannon_Distance | real | Yes | |
Unit_Cannon_Distance_Time | real | Yes | |
Unit_Cannon_Dummy | unit | Yes | |
Unit_Cannon_Dummy_D_Time | real | Yes | |
Unit_Cannon_End_Height | real | Yes | |
Unit_Cannon_Group | group | No | |
Unit_Cannon_Group_2 | group | Yes | |
Unit_Cannon_Group_Pos | location | No | |
Unit_Cannon_Max_Distance | real | Yes | |
Unit_Cannon_Max_Height | real | Yes | |
Unit_Cannon_Mui_Integer | integer | No | |
Unit_Cannon_Mui_Loop | integer | No | |
Unit_Cannon_Mui_Turnoff | integer | No | |
Unit_Cannon_Off | boolean | Yes | |
Unit_Cannon_Pos | location | No | |
Unit_Cannon_Pos_Off | location | No | |
Unit_Cannon_Sfx | effect | No | |
Unit_Cannon_Starting_Height | real | Yes | |
Unit_Cannon_Starting_Point | location | Yes | |
Unit_Cannon_Target | location | Yes | |
Unit_Cannon_Terrain_Height | real | Yes | |
Unit_Cannon_Time | integer | Yes | |
Unit_Cannon_Towards | boolean | Yes | |
Unit_Cannon_Units | unit | Yes | |
Unit_Types | unitcode | Yes | |
Warp_Distance | real | Yes | |
Warp_Facing | real | Yes | |
Warp_Group_1 | group | No | |
Warp_Group_2 | group | No | |
Warp_Group_Pos | location | No | |
Warp_Integer | integer | No | |
Warp_Knock_Point | location | No | |
Warp_Loop | integer | No | |
Warp_Off | boolean | Yes | |
Warp_Pos | location | No | |
Warp_Pos_Off | location | No | |
Warp_Sfx | effect | No | |
Warp_Turnoff | integer | No | |
Warped_Unit | unit | Yes | |
Wuju_Style_Inside_Check | integer | No | |
Wuju_Style_Inside_Loop | integer | No | |
Wuju_Style_Mui_Integer | integer | No | 0 |
Wuju_Style_Mui_Loop | integer | No | |
Wuju_Style_Mui_Turnoff | integer | No | 0 |
Wuju_Style_Off | boolean | Yes | |
Wuju_Style_Sfx_1 | effect | Yes | |
Wuju_Style_Sfx_2 | effect | Yes | |
Wuju_Style_Time | integer | Yes | |
Wuju_Style_Unit | unit | Yes |
//TESH.scrollpos=171
//TESH.alwaysfold=0
// GUI-Friendly Damage Detection -- v1.2.1 -- by Weep
// http:// www.thehelper.net/forums/showthread.php?t=137957
//
// Requires: only this trigger and its variables.
//
// -- What? --
// This snippet provides a leak-free, GUI-friendly implementation of an "any unit takes
// damage" event. It requires no JASS knowledge to use.
//
// It uses the Game - Value Of Real Variable event as its method of activating other
// triggers, and passes the event responses through a few globals.
//
// -- Why? --
// The traditional GUI method of setting up a trigger than runs when any unit is damaged
// leaks trigger events. This snippet is easy to implement and removes the need to do
// you own GUI damage detection setup.
//
// -- How To Implement --
// 0. Before you copy triggers that use GDD into a new map, you need to copy over GDD
// with its GDD Variable Creator trigger, or there will be a problem: the variables
// won't be automatically created correctly.
//
// 1. Be sure "Automatically create unknown variables while pasting trigger data" is
// enabled in the World Editor general preferences.
// 2. Copy this trigger category ("GDD") and paste it into your map.
// (Alternately: create the variables listed in the globals block below, create a
// trigger named "GUI Friendly Damage Detection", and paste in this entire text.)
// 3. Create your damage triggers using Game - Value Of Real Variable as the event,
// select GDD_Event as the variable, and leave the rest of the settings to the default
// "becomes Equal to 0.00".
// The event responses are the following variables:
// GDD_Damage is the amount of damage, replacing Event Response - Damage Taken.
// GDD_DamagedUnit is the damaged unit, replacing Event Response - Triggering Unit.
// Triggering Unit can still be used, if you need to use waits.
// Read the -- Notes -- section below for more info.
// GDD_DamageSource is the damaging unit, replacing Event Response - Damage Source.
//
// -- Notes --
// GDD's event response variables are not wait-safe; you can't use them after a wait in
// a trigger. If you need to use waits, Triggering Unit (a.k.a. GetTriggerUnit()) can
// be used in place of GDD_DamageSource. There is no usable wait-safe equivalent to
// Event Damage or Damage Source; you'll need to save the values yourself.
//
// Don't write any values to the variables used as the event responses, or it will mess
// up any other triggers using this snippet for their triggering. Only use their values.
//
// This uses arrays, so can detect damage for a maximum of 8190 units at a time, and
// cleans up data at a rate of 33.33 per second, by default. This should be enough for
// most maps, but if you want to change the rate, change the value returned in the
// GDD_RecycleRate function at the top of the code, below.
//
// By default, GDD will not register units that have Locust at the moment of their
// entering the game, and will not recognize when they take damage (which can only
// happen if the Locust ability is later removed from the unit.) To allow a unit to have
// Locust yet still cause GDD damage events if Locust is removed, you can either design
// the unit to not have Locust by default and add it via triggers after creation, or
// edit the GDD_Filter function at the top of the code, below.
//
// -- Credits --
// Captain Griffin on wc3c.net for the research and concept of GroupRefresh.
//
// Credit in your map not needed, but please include this README.
//
// -- Version History --
// 1.2.1: Minor code cleaning. Added configuration functions. Updated documentation.
// 1.2.0: Made this snippet work properly with recursive damage.
// 1.1.1: Added a check in order to not index units with the Locust ability (dummy units).
// If you wish to check for damage taken by a unit that is unselectable, do not
// give the unit-type Locust in the object editor; instead, add the Locust ability
// 'Aloc' via a trigger after its creation, then remove it.
// 1.1.0: Added a check in case a unit gets moved out of the map and back.
// 1.0.0: First release.
//===================================================================
// Configurables.
function GDD_RecycleRate takes nothing returns real //The rate at which the system checks units to see if they've been removed from the game
return 0.03
endfunction
function GDD_Filter takes unit u returns boolean //The condition a unit has to pass to have it registered for damage detection
return GetUnitAbilityLevel(u, 'Aloc') == 0 //By default, the system ignores Locust units, because they normally can't take damage anyway
endfunction
//===================================================================
// This is just for reference.
// If you use JassHelper, you could uncomment this section instead of creating the variables in the trigger editor.
// globals
// real udg_GDD_Event = 0.
// real udg_GDD_Damage = 0.
// unit udg_GDD_DamagedUnit
// unit udg_GDD_DamageSource
// trigger array udg_GDD__TriggerArray
// integer array udg_GDD__Integers
// unit array udg_GDD__UnitArray
// group udg_GDD__LeftMapGroup = CreateGroup()
// endglobals
//===================================================================
// System code follows. Don't touch!
function GDD_Event takes nothing returns boolean
local unit damagedcache = udg_GDD_DamagedUnit
local unit damagingcache = udg_GDD_DamageSource
local real damagecache = udg_GDD_Damage
set udg_GDD_DamagedUnit = GetTriggerUnit()
set udg_GDD_DamageSource = GetEventDamageSource()
set udg_GDD_Damage = GetEventDamage()
set udg_GDD_Event = 1.
set udg_GDD_Event = 0.
set udg_GDD_DamagedUnit = damagedcache
set udg_GDD_DamageSource = damagingcache
set udg_GDD_Damage = damagecache
set damagedcache = null
set damagingcache = null
return false
endfunction
function GDD_AddDetection takes nothing returns boolean
// if(udg_GDD__Integers[0] > 8190) then
// call BJDebugMsg("GDD: Too many damage events! Decrease number of units present in the map or increase recycle rate.")
// ***Recycle rate is specified in the GDD_RecycleRate function at the top of the code. Smaller is faster.***
// return
// endif
if(IsUnitInGroup(GetFilterUnit(), udg_GDD__LeftMapGroup)) then
call GroupRemoveUnit(udg_GDD__LeftMapGroup, GetFilterUnit())
elseif(GDD_Filter(GetFilterUnit())) then
set udg_GDD__Integers[0] = udg_GDD__Integers[0]+1
set udg_GDD__UnitArray[udg_GDD__Integers[0]] = GetFilterUnit()
set udg_GDD__TriggerArray[udg_GDD__Integers[0]] = CreateTrigger()
call TriggerRegisterUnitEvent(udg_GDD__TriggerArray[udg_GDD__Integers[0]], udg_GDD__UnitArray[udg_GDD__Integers[0]], EVENT_UNIT_DAMAGED)
call TriggerAddCondition(udg_GDD__TriggerArray[udg_GDD__Integers[0]], Condition(function GDD_Event))
endif
return false
endfunction
function GDD_PreplacedDetection takes nothing returns nothing
local group g = CreateGroup()
local integer i = 0
loop
call GroupEnumUnitsOfPlayer(g, Player(i), Condition(function GDD_AddDetection))
set i = i+1
exitwhen i == bj_MAX_PLAYER_SLOTS
endloop
call DestroyGroup(g)
set g = null
endfunction
function GDD_GroupRefresh takes nothing returns nothing
// Based on GroupRefresh by Captain Griffen on wc3c.net
if (bj_slotControlUsed[5063] == true) then
call GroupClear(udg_GDD__LeftMapGroup)
set bj_slotControlUsed[5063] = false
endif
call GroupAddUnit(udg_GDD__LeftMapGroup, GetEnumUnit())
endfunction
function GDD_Recycle takes nothing returns nothing
if(udg_GDD__Integers[0] <= 0) then
return
elseif(udg_GDD__Integers[1] <= 0) then
set udg_GDD__Integers[1] = udg_GDD__Integers[0]
endif
if(GetUnitTypeId(udg_GDD__UnitArray[udg_GDD__Integers[1]]) == 0) then
call DestroyTrigger(udg_GDD__TriggerArray[udg_GDD__Integers[1]])
set udg_GDD__TriggerArray[udg_GDD__Integers[1]] = null
set udg_GDD__TriggerArray[udg_GDD__Integers[1]] = udg_GDD__TriggerArray[udg_GDD__Integers[0]]
set udg_GDD__UnitArray[udg_GDD__Integers[1]] = udg_GDD__UnitArray[udg_GDD__Integers[0]]
set udg_GDD__UnitArray[udg_GDD__Integers[0]] = null
set udg_GDD__Integers[0] = udg_GDD__Integers[0]-1
endif
set udg_GDD__Integers[1] = udg_GDD__Integers[1]-1
endfunction
function GDD_LeaveMap takes nothing returns boolean
local boolean cached = bj_slotControlUsed[5063]
if(udg_GDD__Integers[2] < 64) then
set udg_GDD__Integers[2] = udg_GDD__Integers[2]+1
else
set bj_slotControlUsed[5063] = true
call ForGroup(udg_GDD__LeftMapGroup, function GDD_GroupRefresh)
set udg_GDD__Integers[2] = 0
endif
call GroupAddUnit(udg_GDD__LeftMapGroup, GetFilterUnit())
set bj_slotControlUsed[5063] = cached
return false
endfunction
// ===========================================================================
function InitTrig_GUI_Friendly_Damage_Detection takes nothing returns nothing
local region r = CreateRegion()
call RegionAddRect(r, GetWorldBounds())
call TriggerRegisterEnterRegion(CreateTrigger(), r, Condition(function GDD_AddDetection))
call TriggerRegisterLeaveRegion(CreateTrigger(), r, Condition(function GDD_LeaveMap))
call GDD_PreplacedDetection()
call TimerStart(CreateTimer(), GDD_RecycleRate(), true, function GDD_Recycle)
set r = null
endfunction