Name | Type | is_array | initial_value |
damagecache | real | No | |
damagedcache | real | No | |
damagingcache | unit | No | |
g | group | 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 | |
i | integer | No | |
PlayerColors | string | Yes | |
r | rect | No | |
tempGroup | group | No | |
Text_Duration | real | No | |
TextSize_dmg | real | No | |
TextSize_spells | real | No |
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
// 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
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
function Trig_Floating_Spell_Name_Conditions takes nothing returns boolean
if ( not ( GetUnitTypeId(GetTriggerUnit()) != 'hpea' ) ) then
return false
endif
return true
endfunction
function Trig_Floating_Spell_Name_Actions takes nothing returns nothing
call CreateTextTagUnitBJ( ( udg_PlayerColors[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))] + GetAbilityName(GetSpellAbilityId()) ), GetTriggerUnit(), 0.00, udg_TextSize_spells, 100.00, 100.00, 100.00, 0 )
call SetTextTagVelocityBJ( GetLastCreatedTextTag(), 100.00, 90.00 )
call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
call SetTextTagLifespanBJ( GetLastCreatedTextTag(), udg_Text_Duration )
call SetTextTagFadepointBJ( GetLastCreatedTextTag(), 0.65 )
endfunction
//===========================================================================
function InitTrig_Floating_Spell_Name takes nothing returns nothing
set gg_trg_Floating_Spell_Name = CreateTrigger( )
call TriggerAddCondition( gg_trg_Floating_Spell_Name, Condition( function Trig_Floating_Spell_Name_Conditions ) )
call TriggerAddAction( gg_trg_Floating_Spell_Name, function Trig_Floating_Spell_Name_Actions )
endfunction
function Trig_Floating_Damage_Taken_Conditions takes nothing returns boolean
if ( not ( udg_GDD_Damage > 1.00 ) ) then
return false
endif
return true
endfunction
function Trig_Floating_Damage_Taken_Actions takes nothing returns nothing
call CreateTextTagUnitBJ( ( udg_PlayerColors[GetConvertedPlayerId(GetOwningPlayer(udg_GDD_DamageSource))] + I2S(R2I(udg_GDD_Damage)) ), udg_GDD_DamagedUnit, 0.00, udg_TextSize_dmg, 100.00, 15.00, 0.00, 0 )
call SetTextTagVelocityBJ( GetLastCreatedTextTag(), 100.00, 90.00 )
call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
call SetTextTagLifespanBJ( GetLastCreatedTextTag(), udg_Text_Duration )
call SetTextTagFadepointBJ( GetLastCreatedTextTag(), 0.65 )
endfunction
//===========================================================================
function InitTrig_Floating_Damage_Taken takes nothing returns nothing
set gg_trg_Floating_Damage_Taken = CreateTrigger( )
call TriggerRegisterVariableEvent( gg_trg_Floating_Damage_Taken, "udg_GDD_Event", EQUAL, 0 )
call TriggerAddCondition( gg_trg_Floating_Damage_Taken, Condition( function Trig_Floating_Damage_Taken_Conditions ) )
call TriggerAddAction( gg_trg_Floating_Damage_Taken, function Trig_Floating_Damage_Taken_Actions )
endfunction
function Trig_Configuration_Func002002 takes nothing returns nothing
call TriggerRegisterUnitEvent( gg_trg_Floating_Spell_Name, GetEnumUnit(), EVENT_UNIT_SPELL_EFFECT )
endfunction
function Trig_Configuration_Actions takes nothing returns nothing
set udg_tempGroup = GetUnitsInRectAll(GetPlayableMapRect())
call ForGroupBJ( udg_tempGroup, function Trig_Configuration_Func002002 )
call DestroyGroup(udg_tempGroup)
// Configure the duration and size of the floating texts
set udg_Text_Duration = 2.00
set udg_TextSize_dmg = 7.50
set udg_TextSize_spells = 10.00
// -
// These are strings to make the floating texts use the matching players colors
// Neutral Hostile will be using white
set udg_PlayerColors[1] = "|cffffcc00"
set udg_PlayerColors[2] = "|c000042FF"
set udg_PlayerColors[3] = "|c001CE6B9"
set udg_PlayerColors[4] = "|c00540081"
set udg_PlayerColors[5] = "|c00FFFC01"
set udg_PlayerColors[6] = "|c00fEBA0E"
set udg_PlayerColors[7] = "|c0020C000"
set udg_PlayerColors[8] = "|c00E55BB0"
set udg_PlayerColors[9] = "|c00959697"
set udg_PlayerColors[10] = "|c007EBFF1"
set udg_PlayerColors[11] = "|c00106246"
set udg_PlayerColors[12] = "|c004E2A04"
endfunction
//===========================================================================
function InitTrig_Configuration takes nothing returns nothing
set gg_trg_Configuration = CreateTrigger( )
call TriggerAddAction( gg_trg_Configuration, function Trig_Configuration_Actions )
endfunction
function Trig_Configuration2_Actions takes nothing returns nothing
call TriggerRegisterUnitEvent( gg_trg_Floating_Spell_Name, GetTriggerUnit(), EVENT_UNIT_SPELL_EFFECT )
endfunction
//===========================================================================
function InitTrig_Configuration2 takes nothing returns nothing
set gg_trg_Configuration2 = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_Configuration2, GetPlayableMapRect() )
call TriggerAddAction( gg_trg_Configuration2, function Trig_Configuration2_Actions )
endfunction