Name | Type | is_array | initial_value |
Cache | gamecache | No | |
Creep_1 | location | No | |
Creep_2 | location | No | |
Creep_3 | location | No | |
Creep_4 | location | No | |
Creep_Positions | location | Yes | |
Creep_Types | unitcode | Yes | |
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 | |
Hashtable | hashtable | No | |
Lifesteal | real | No | |
Loop_Int | integer | No | |
LoopCreep | integer | No | |
Open_Wounds_Grp | group | No | |
Picked_Unit_Point | location | No | |
Random_Start_Pos | location | No | |
Revive | location | No | |
Temp_Attacked_Index | unit | Yes | |
Temp_Attacker_Index | unit | Yes | |
Temp_U | unit | No | |
Temp_U2 | unit | No | |
Unit_Group | group | No |
function Revive_Creep takes nothing returns nothing
local integer i
set i = GetUnitUserData(GetTriggerUnit())
call TriggerSleepAction( 60.00 )
call CreateNUnitsAtLoc( 1, udg_Creep_Types[i], Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_Creep_Positions[i], bj_UNIT_FACING )
call SetUnitUserData( GetLastCreatedUnit(), i )
endfunction
//===========================================================================
function InitTrig_Creep_Revive takes nothing returns nothing
set gg_trg_Creep_Revive = CreateTrigger( )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Creep_Revive, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH )
call TriggerAddAction( gg_trg_Creep_Revive, function Revive_Creep )
endfunction
function Trig_Hero_Restore_Actions takes nothing returns nothing
local player p = GetTriggerPlayer()
local unit pu
local group g = GetUnitsInRectOfPlayer(GetPlayableMapRect(), p)
loop
set pu = FirstOfGroup(g)
exitwhen pu == null
call GroupRemoveUnit(g, pu)
call SetUnitLifePercentBJ( pu, 100 )
call SetUnitManaPercentBJ( pu, 100 )
call UnitResetCooldown( pu )
endloop
set p = null
call DestroyGroup (g)
set g = null
endfunction
//===========================================================================
function InitTrig_Hero_Restore takes nothing returns nothing
set gg_trg_Hero_Restore = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_Hero_Restore, Player(0), "restore", true )
call TriggerAddAction( gg_trg_Hero_Restore, function Trig_Hero_Restore_Actions )
endfunction
function Trig_Hero_Revive_Conditions takes nothing returns boolean
return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true
endfunction
function Trig_Hero_Revive_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local player p = GetOwningPlayer(u)
call TriggerSleepAction( 1.00 )
call ReviveHero( u, GetPlayerStartLocationX(p), GetPlayerStartLocationY(p), true )
if (GetLocalPlayer() == p) then
call PanCameraToTimed( GetPlayerStartLocationX(p), GetPlayerStartLocationY(p), 0.5)
endif
call SetUnitLifePercentBJ( u, 100 )
call SetUnitManaPercentBJ( u, 100 )
call UnitResetCooldown( u )
set u = null
set p = null
endfunction
//===========================================================================
function InitTrig_Hero_Revive takes nothing returns nothing
set gg_trg_Hero_Revive = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Hero_Revive, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_Hero_Revive, Condition( function Trig_Hero_Revive_Conditions ) )
call TriggerAddAction( gg_trg_Hero_Revive, function Trig_Hero_Revive_Actions )
endfunction
function Setup takes nothing returns nothing
call TriggerRegisterDeathEvent( gg_trg_Regrow_Trees, GetEnumDestructable() )
endfunction
function Trig_Regrow_Trees_Setup_Actions takes nothing returns nothing
call EnumDestructablesInRectAll( GetEntireMapRect(), function Setup )
call DestroyTrigger( GetTriggeringTrigger() )
endfunction
//===========================================================================
function InitTrig_Regrow_Trees_Setup takes nothing returns nothing
set gg_trg_Regrow_Trees_Setup = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Regrow_Trees_Setup, 1.00 )
call TriggerAddAction( gg_trg_Regrow_Trees_Setup, function Trig_Regrow_Trees_Setup_Actions )
endfunction
function Trig_RegrowTrees_Actions takes nothing returns nothing
local destructable DEADTREE = GetDyingDestructable()
call TriggerSleepAction( 45.00 )
call DestructableRestoreLife( DEADTREE, GetDestructableMaxLife(DEADTREE), true )
endfunction
//===========================================================================
function InitTrig_Regrow_Trees takes nothing returns nothing
set gg_trg_Regrow_Trees = CreateTrigger( )
call TriggerAddAction( gg_trg_Regrow_Trees, function Trig_RegrowTrees_Actions )
endfunction
function Trig_DestroyFX_Actions takes nothing returns nothing
local effect f=bj_lastCreatedEffect
call TriggerSleepAction( 1.00 )
call DestroyEffect(f)
set f=null
endfunction
//===========================================================================
function InitTrig_DestroyFX takes nothing returns nothing
set gg_trg_DestroyFX = CreateTrigger( )
call TriggerAddAction( gg_trg_DestroyFX, function Trig_DestroyFX_Actions )
endfunction
//*********************************************************************************************
//* GUI-Friendly Damage Detection -- v1.2.0 -- 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 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. *
//* GDD_DamageSource is the damaging unit, replacing Event Response - Damage Source. *
//* *
//* -- Notes -- *
//* 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 have a maximum of 8190 instances at a time, and cleans up *
//* data at a rate of 33.33 per second. This should be enough for most maps. *
//* *
//* -- 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.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. *
//* *
//*********************************************************************************************
//globals
// real udg_GDD_Event
// real udg_GDD_Damage
// 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
//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 the number used in the TimerStart line at the bottom of this trigger. Smaller is faster.***
// return
// endif
if(IsUnitInGroup(GetFilterUnit(), udg_GDD__LeftMapGroup)) then
call GroupRemoveUnit(udg_GDD__LeftMapGroup, GetFilterUnit())
else
if(GetUnitAbilityLevel(GetFilterUnit(), 'Aloc') == 0) 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
endif
return false
endfunction
function GDD_PresetDetection takes nothing returns nothing
local group g = CreateGroup()
local integer i = 0
set i = 0
loop
call GroupEnumUnitsOfPlayer(g, Player(i), Condition(function GDD_AddDetection))
call GroupClear(g)
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_PresetDetection()
call TimerStart(CreateTimer(), 0.03, true, function GDD_Recycle)
set r = null
endfunction