function GetNumberOfItemsFromUnit takes unit u, integer searchitem returns integer
local integer i2 = 0
local integer count=0
loop
exitwhen i2 == 5
if GetItemTypeId(UnitItemInSlot(u,i2)) == searchitem then
set count = count+1
endif
set i2 = i2+1
endloop
return count
endfunction
Name | Type | is_array | initial_value |
ActiveBoss | integer | No | |
ActiveMagic1 | integer | No | |
ActiveMagic2 | integer | No | |
ActiveMagic3 | integer | No | |
ActiveMagic4 | integer | No | |
ActivePet | unit | No | |
ActiveRift | integer | No | |
AltEndingUnlocked | integer | No | |
Ambushers | location | Yes | |
AMSCaster | unit | No | |
AMSDummy | unit | No | |
AMSDummy2 | unit | No | |
AscC | unit | No | |
AscChance | integer | No | |
AscDummy | unit | No | |
AscFireSpit | integer | No | |
AscPos | location | No | |
AscSFX1 | effect | No | |
AscSFX2 | effect | No | |
AscSFX3 | effect | No | |
AscSFX4 | effect | No | |
AscSpell1 | abilcode | No | |
AscSpell2 | abilcode | No | |
AscSpell3 | abilcode | No | |
AscTimer | timer | No | |
bDoors | boolean | Yes | |
BlademasterTactic | integer | No | |
BossBusy | integer | No | |
BossMusicA | timer | No | |
BossMusicB | timer | No | |
BossMusicTimer | timer | Yes | |
BossQuest | quest | Yes | |
BP | unit | No | |
BP2 | unit | No | |
BP2Slot | item | Yes | |
BP3 | unit | No | |
BP3Slot | item | Yes | |
BP4 | unit | No | |
BP4Slot | item | Yes | |
bPlayerDead | boolean | Yes | |
BPSlot | item | Yes | |
BubblePoint | location | No | |
ButtonBeam1 | lightning | No | |
ButtonBeam2 | lightning | No | |
ButtonBeam3 | lightning | No | |
ButtonBeam4 | lightning | No | |
ButtonBeamSound1 | sound | No | |
ButtonBeamSound2 | sound | No | |
ButtonBeamSound3 | sound | No | |
ButtonBeamSound4 | sound | No | |
ButtonBeamType1 | lightningtype | No | |
ButtonBeamType2 | lightningtype | No | |
ButtonBeamType3 | lightningtype | No | |
ButtonBeamType4 | lightningtype | No | |
CageCounter | integer | No | |
CalamityCrit | integer | No | |
CalamityCritPos | location | No | |
CameraChoice | trigger | Yes | |
CameraZoom_Choice | trigger | Yes | |
Caster_Group | group | No | |
Caster_Loc | location | No | |
CastPos | location | No | |
CBlazeDummy | unit | Yes | |
CCBoard | multiboard | No | |
CCBoard1 | multiboard | No | |
CCBoard2 | multiboard | No | |
CCBoard3 | multiboard | No | |
CCBoard4 | multiboard | No | |
CCBord | multiboard | Yes | |
ChainFrost | abilcode | No | |
ChaoticRiftDummy | unit | Yes | |
Charm | integer | No | |
CharmAngle | real | No | |
CharmCharge | integer | No | |
CharmPoint | location | Yes | |
CharmSFX | effect | No | |
CharmUsePos | location | No | |
CharmUser | unit | No | |
CharredVictims | group | No | |
CheatsActivated | integer | No | |
CheckpointLocation | rect | No | |
Choice1 | integer | No | |
CImpale | location | No | |
CImpale2 | location | No | |
CImpale3 | location | No | |
CImpale4 | location | No | |
CL_AbilityLevel | integer | Yes | |
CL_AOE | real | Yes | |
CL_Caster | unit | Yes | |
CL_Count | integer | Yes | |
CL_Damage | integer | Yes | |
CL_FirstTarget | boolean | Yes | |
CL_Group | group | Yes | |
CL_Loc | location | Yes | |
CL_Player | player | Yes | |
CL_Slashes | integer | Yes | |
CL_Special | effect | Yes | |
CL_Target | unit | Yes | |
CL_Victim | unit | Yes | |
CLCaster | unit | No | |
CLCount | integer | No | |
CLDummy | unit | No | |
CLDummyCaster | unit | No | |
CLFacing | real | No | |
CLGroup | group | No | |
CLLevel | integer | No | |
CLMaxCount | integer | No | |
CLOwner | player | No | |
CLPosition | location | No | |
CLTable | hashtable | No | |
CLTempPoint1 | location | No | |
CLTempPoint2 | location | No | |
CoinToss | integer | No | |
Corpse | unit | No | |
CorpseArea | group | No | |
CorpsePos | location | No | |
CorpsePos2 | location | No | |
Count | integer | No | |
CP | integer | No | |
CPScroll | item | No | |
CPScrollClock | timer | No | |
CRiftDummy | unit | Yes | UnitNull |
CRiftKillCounter | integer | No | |
CRiftKillCountText | texttag | No | |
CRiftTimer | timer | No | |
CRiftTimerWindow | timerdialog | No | |
Crow | unit | No | |
CrystalImpaler | unit | Yes | |
CrystalImpalerSFX | unit | Yes | |
CSkeletonsKillCounter | integer | No | |
CSoulSpawn | location | No | |
CurrentMonsters | integer | Yes | |
CycloneLoc | location | No | |
DAC | unit | No | |
DAlvl | integer | No | |
Damage | integer | Yes | |
DamageArea | group | No | |
DamageDone | real | No | |
DApos | location | No | |
DDeal | location | No | |
DDealer | location | No | |
DDealInteger | integer | No | |
DDRewardX | integer | No | |
DeathCounter | integer | No | |
DeathCounter1 | integer | No | |
DeathCounter2 | integer | No | |
DeathCounter3 | integer | No | |
DeathCounter4 | integer | No | |
DeathPoint1 | location | No | |
DeathPoint2 | location | No | |
DeathPoint3 | location | No | |
DeathPoint4 | location | No | |
DepartedKnowledge | integer | Yes | |
DG_Caster | unit | No | |
DG_HandleInt | integer | No | |
DG_HashTable | hashtable | No | |
DG_LeakPoint | location | Yes | |
DG_TempGroup | group | No | |
DG_TempInt | integervar | No | |
DG_TempLightning | lightning | No | |
DG_TempReal | real | Yes | |
DG_Units | group | No | |
DiceRoll1 | integer | No | |
DiceRoll2 | integer | No | |
DiceRoll3 | integer | No | |
DiceRoll4 | integer | No | |
DifficultyOption | integer | No | |
DivineIntervener | integer | No | |
DKPos | location | No | |
DragonBreath | timer | No | |
DragonCaster | unit | No | |
DragonClawSFX | effect | No | |
DragonDie | location | No | |
DragonHSpawn | location | No | |
DragonHSpawnL | effect | No | |
DragonHSpawnU | unit | No | |
DragonPoint | rect | No | |
DragonPos | location | No | |
DragonRandomizer | integer | No | |
DragonTimer | timer | No | |
EnableSpawners | boolean | Yes | |
Ending | integer | No | |
EndMordred | unit | No | |
EndWisp | unit | Yes | |
EoDPos | location | No | |
EoDSE | effect | No | |
EXPTimer | timer | No | |
EyeBeamAngle | real | No | |
EyeBeamer | unit | No | |
EyeBeamer2 | unit | No | |
EyeBeamer3 | unit | No | |
EyeBeamer4 | unit | No | |
EyeBeamer5 | unit | No | |
EyeDown | timer | No | |
EyeEntryP | location | No | |
EyeExitP | location | No | |
EyeFlarePos | location | Yes | |
EyeRandomizer | integer | No | |
EyeRitual | integer | No | |
EyeRitualEnter | unit | No | |
EyeSCP | location | No | |
EyeSkellies | hashtable | No | |
EyeSkellieSpawn | location | Yes | |
EyeSummonSFX | effect | No | |
EyeUp | timer | No | |
FailSafeGate | timer | No | |
FinalBossPart | integer | No | |
FireSpiderSplosionPoint | location | No | |
FireSpitPos | location | No | |
FireSpitTarget | unit | No | |
Frequencies | integer | Yes | |
FrostFlashDamage | group | No | |
GBPatP | location | Yes | |
GBPats | integer | 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 | |
GiftCount | integer | No | |
GiftPurchased1 | integer | No | |
GiftPurchased2 | integer | No | |
GiftPurchased3 | integer | No | |
GiftPurchased4 | integer | No | |
GoldPoint | location | No | |
GoldRandomizer | integer | No | |
GoldRandomizerD | integer | No | |
GoldSpawn | location | No | |
GoldSpawnC | location | Yes | |
GoldSpawnD | location | No | |
GResonanceSplash | location | No | |
GuardianAttunement | integer | No | |
GuardianDie | location | No | |
GuardianTimer | timer | No | |
Gutsy | unit | No | |
Gutsy_Dummy | unit | No | |
GWDummy | unit | No | |
GWPos | location | No | |
HealthStone | item | Yes | |
HeavenGroup | group | No | |
HeavenTimer | timer | No | |
HeavenTimerWindow | timerdialog | No | |
HellGroup | group | No | |
HELLTIME | timer | No | |
HellTimeWindow | timerdialog | No | |
HeroIcon | integer | No | |
HeroItem | location | No | |
HeroPosBHH | location | No | |
HeroPosBP | location | No | |
HeroPosBP2 | location | No | |
HeroPosBP3 | location | No | |
HeroPosBP4 | location | No | |
HeroPosTI1 | location | No | |
HeroPosTI2 | location | No | |
HeroPosTI3 | location | No | |
HeroPosTI4 | location | No | |
HeroRollPos | location | No | |
HiddenAcolytes | group | Yes | |
HoDDummy | unit | No | |
Hogger | unit | No | |
HoggerPos | location | No | |
HoggerRandomizer | integer | No | |
HoggerSE | effect | No | |
HoggerSpawn | location | No | |
HoggerTimer | timer | No | |
HSCount | integer | No | |
IceShatterDD | unit | No | |
IceShatterPos | location | No | |
IceShatterTarget | unit | No | |
iChainFrostIndex | integer | No | |
iChainFrostJumps | integer | Yes | |
iJumps | integer | No | |
iLevelJumps | integer | No | |
iLvlJumps | integer | No | |
ImpurityLoot | location | No | |
InfernalKillCount | integer | No | |
InitialFrequencies | integer | Yes | |
ItemLegendaryDrop | location | No | |
ItemLegendaryDrop2 | location | No | |
ItemLegendaryDrop3 | location | No | |
ItemLegendaryDropChance | integer | No | |
ItemLegendaryDropChance2 | integer | No | |
ItemLegendaryDropChance3 | integer | No | |
ItemPurpleDrop1 | location | No | |
ItemPurpleDrop2 | location | No | |
ItemPurpleDropChance1 | integer | No | |
ItemPurpleDropChance2 | integer | No | |
KB_Angle | real | Yes | |
KB_Casters | unit | Yes | |
KB_CountBuffs | integer | No | |
KB_DestroyTrees | boolean | Yes | |
KB_EffectCounter | integer | Yes | |
KB_EffectCounter2 | integer | Yes | |
KB_Effects_1 | string | Yes | |
KB_Effects_2 | string | Yes | |
KB_GeneralIntegers | integervar | Yes | |
KB_KnockbackedUnits | group | No | |
KB_Levels | integer | Yes | |
KB_MaxDistance | real | Yes | |
KB_ReachedDistance | real | Yes | |
KB_ReducedReal | real | No | |
KB_ReduceSpeedReal | real | Yes | |
KB_SpecificSpeed | real | Yes | |
KB_StartPositions | location | Yes | |
KB_TempPoint | location | Yes | |
KB_TempReal | real | No | |
KB_TotalKnockUnits | integer | No | |
KB_Units | unit | Yes | |
KBA_Caster | unit | No | |
KBA_DestroyTrees | boolean | No | |
KBA_DistancePerLevel | real | No | |
KBA_Level | integer | No | |
KBA_SpecialEffects | string | Yes | |
KBA_Speed | real | No | |
KBA_StartingPosition | location | No | |
KBA_TargetUnit | unit | No | |
KeyUsed | location | No | |
KillCount | integer | No | |
KillCountP1 | integer | No | |
KillCountP2 | integer | No | |
KillCountP3 | integer | No | |
KillCountP4 | integer | No | |
Kills | integer | Yes | |
KnockbackTable | hashtable | No | |
KorBladeFollower | unit | No | |
KorMirrorDoomSFX | effect | No | |
KorMirrorImage | unit | Yes | |
KorMirrorPosX | location | Yes | |
KorMirrorRandomizer | integer | No | |
Lazor | integer | No | |
Level | integer | No | |
LivesCounter | integer | No | |
LivesCounter1 | integer | No | |
LivesCounter2 | integer | No | |
LivesCounter3 | integer | No | |
LivesCounter4 | integer | No | |
LocalPlayer | player | No | |
LootBonus | integer | No | |
LWPos | location | No | |
LWSE | effect | No | |
MA1 | abilcode | No | |
MA2 | abilcode | No | |
MA3 | abilcode | No | |
MA4 | abilcode | No | |
ManaRegainUnitGroupMage | group | No | |
ManaRegainUnitGroupSham | group | No | |
Max_Index | integer | No | |
MaxMonsters | integer | Yes | |
MBBomb | location | No | |
MBBombP | location | Yes | |
MBCentre | location | No | |
MBDancers | integer | No | |
MC1 | integer | No | |
MC2 | integer | No | |
MC3 | integer | No | |
MC4 | integer | No | |
MCMax1 | integer | No | |
MCMax2 | integer | No | |
MCMax3 | integer | No | |
MCMax4 | integer | No | |
Melianova | unit | No | |
MeliaPetPos | location | No | |
MHandsP | location | Yes | |
MiniBoss1 | unit | No | |
MiniBoss2 | unit | No | |
MonsterGroups | group | Yes | |
MonsterPoint | location | No | |
MonsterSpawners | unit | Yes | |
MoonFlare1 | location | No | |
MoonFlare2 | location | No | |
MoonFlare3 | location | No | |
MorbChanneling | integer | No | |
MorbDancerOpening | unit | No | |
MorbFirstTime | string | No | |
MorbiuthFlyingPos | location | No | |
MorbiuthFlyingSFX | effect | No | |
MorbiuthFlyingShield | effect | No | |
MorBladedancer | unit | Yes | |
MorbMusicPhase | integer | No | |
MorbRandomizer | integer | No | |
MorbSpawn | location | No | |
MorbTactcs | timer | No | |
MorMirrorSFX | effect | Yes | |
MorPos | location | No | |
MorVic | integer | No | |
MScythesRandomizer | integer | No | |
MSpawn | location | No | |
MUI_1 | integer | No | |
MUI_2 | integer | Yes | |
MUI_3 | integervar | No | |
Music | integer | No | |
NightWarPoint | location | No | |
NumSpawners | integer | No | |
NWC | unit | No | |
NWEffect | effect | No | |
NWTimer | timer | No | |
P1Class | string | No | |
P2Class | string | No | |
P3Class | string | No | |
P4Class | string | No | |
PDefeated | integer | Yes | |
PhoenixDD | unit | No | |
PIcon | image | Yes | |
Pitlord | unit | No | |
PKBlessing | integer | No | |
PKBlessingArmor | integer | No | |
PKBlessingC | unit | No | |
PKBlessingChance | integer | No | |
PKBlessingPos | location | No | |
PKBlessingTimer | timer | No | |
PKBoomGRP | group | No | |
PKFireCPos | location | No | |
PKFirePos | location | No | |
Player1 | unit | No | |
Player2 | unit | No | |
Player3 | unit | No | |
Player4 | unit | No | |
PlayerBadges | integer | Yes | |
PlayerCount | integer | No | |
PlayerGold | integer | Yes | |
PlayerGroup | group | No | |
PlayerHero | unit | No | |
Playersgroup | force | No | |
PlayerStatus | integer | Yes | |
PlayerSurroundings | rect | No | |
PLeavePos | location | Yes | |
RampageEffect | effect | No | |
RampageSFX | location | No | |
RampartUnits | group | No | |
Randomizer | integer | No | |
RandomizerMusic | integer | No | |
RandomVoice | integer | No | |
RareSpawner | integer | No | |
RareUnits | unit | Yes | |
RasCrit | integer | No | |
RasCritPos | location | No | |
rDamage | real | No | |
RE_Knocktable | hashtable | No | |
RF | integervar | No | |
RF_AbilityLevel | integer | Yes | |
RF_Amount | real | Yes | |
RF_Angle | real | Yes | |
RF_AoE | real | Yes | |
RF_Caster | unit | Yes | |
RF_CastNumber | integer | No | |
RF_Distance | real | Yes | |
RF_EffectString | string | Yes | |
RF_Group | group | No | |
RF_Missile1 | unit | Yes | |
RF_Missile2 | unit | Yes | |
RF_Off | boolean | Yes | |
RF_Point | location | Yes | |
RF_Spam | integer | Yes | |
RF_Switch | integer | No | |
RF_Time | real | Yes | |
RF_Units | unit | Yes | |
rFinalDamage | real | Yes | |
RiftEntries | unit | Yes | |
RiftSpawnPos | location | No | |
RiftSpawnPosB | location | No | |
RiftSpawnReg | rect | No | |
RiftSpawnsA | unitcode | No | |
RiftSpawnsB | unitcode | No | |
rLvlDamage | real | No | |
rSpeed | real | No | |
RumbleRumble | effect | Yes | |
Sample_Group | group | No | |
Sample_Point | location | No | |
Sappers1 | group | No | |
sChainFrostE | string | No | |
SChestRandomizer | integer | No | |
SCPos | location | No | |
SCSFX | effect | No | |
SCShop | unit | No | |
SCshopDanger | group | No | |
SCShopSFX | effect | No | |
SCTarget | unit | No | |
SCTime | real | No | |
SCTimer | timer | No | |
SE | effect | No | |
SentinelBow | effect | No | |
SentinelsC | unit | No | |
SentinelsDummy | unit | No | |
SentinelSFX | effect | No | |
SentinelsLevel | integer | No | |
SentinelsPos | location | No | |
SentinelsTime | timer | No | |
SFX | effect | No | |
SFXDummies | location | Yes | |
SFXFlames | unit | Yes | |
ShamanCircle | effect | No | |
ShamanCyclone | effect | No | |
ShammyRando | integer | No | |
SilverGate | location | Yes | |
SilverItem | item | No | |
SilverItemType | itemcode | No | |
SilverKeyRing | integer | No | |
SilverKeyRing1 | integer | No | |
SilverKeyRing2 | integer | No | |
SilverKeyRing3 | integer | No | |
SilverKeyRing4 | integer | No | |
SkelliesGroup | group | No | |
SkelliesGroupP2 | group | No | |
Skin1 | unitcode | No | |
SkinSelection | group | No | |
Sky | weathereffect | No | |
SkyInteger | integer | No | |
SkyStyle | integer | No | |
Soul1 | unit | No | |
Soul2 | unit | No | |
Soul3 | unit | No | |
Soul4 | unit | No | |
SoulArmor | effect | No | |
SoulBoss | unit | No | |
SoulEyesGroup | group | No | |
SoulRainPoint | location | No | |
SoulSFX | effect | Yes | |
SoulShatterSFX | effect | No | |
SoulStage | integer | No | |
SoulStoneCounter | integer | No | |
SpawnFXString | string | No | |
SpawnTypes | unitcode | Yes | |
SpeechRandomizer | integer | No | |
SpiderBoss | unit | No | |
SpiderBossHP | real | No | |
SpiderBurrowTime | timer | No | |
SpiderBurrowTime2 | timer | No | |
SpiderBurstPoint | location | No | |
SpiderClawSFX | effect | No | |
SpiderComet | unit | No | |
SpiderCometImpact | timer | No | |
SpiderDoom | effect | No | |
SpiderEggDrops | integer | No | |
SpiderEggSpawn | location | No | |
SpiderEnflameTimer | timer | No | |
SpiderFlarePos | location | Yes | |
SpiderImpale | location | Yes | |
SpiderIsBurrow | integer | No | |
SpiderMusicPhase | integer | No | |
SpiderPhase | integer | No | |
SpiderPoint | location | No | |
SPIDERS | group | No | |
SpiderSpikes | location | Yes | |
SpiderSpikesRegion | rect | No | |
SpiderTactics | integer | No | |
SpiderWebTarget | unit | No | |
SSCaster | unit | No | |
SSCount | integer | No | |
SSGroup | group | No | |
SummonGroup | group | No | |
SummonGroup1 | group | No | |
SummonGroup2 | group | No | |
SummonGroup3 | group | No | |
SummonGroup4 | group | No | |
SunFlarePoint | location | No | |
table | hashtable | No | |
Tank1 | unit | No | |
Tank2 | unit | No | |
Tank3 | unit | No | |
Tank4 | unit | No | |
TankChestsCount | integer | No | |
TankSFX | effect | Yes | |
Target_Group | group | No | |
Target_Loc | location | No | |
Target_Loc_Temp | location | No | |
Temp | integer | No | |
Temp_Boolean | boolean | No | |
Temp_Group | group | No | |
Temp_Int | integer | No | |
Temp_Point | location | No | |
Temp_Point2 | location | No | |
Temp_Point3 | location | No | |
Temp_unit | unit | No | |
TempG | location | No | |
TempGroup | group | Yes | |
TempI | location | Yes | |
TempInteger | integervar | No | |
TempK | location | Yes | |
TempPlayer | player | No | |
TempPlayer1 | unit | No | |
TempPlayer2 | unit | No | |
TempPlayer3 | unit | No | |
TempPlayer4 | unit | No | |
TempPoint | location | No | |
TempR | location | No | |
TempS | location | Yes | |
TempSFX | effect | No | |
TempSoulBody1 | unit | No | |
TempSoulBody2 | unit | No | |
TempSoulBody3 | unit | No | |
TempSoulBody4 | unit | No | |
TempString | string | No | |
TempUnit | unit | No | |
TentaclePoint | location | No | |
TentacleSFX | effect | No | |
TheLeaderBoard | leaderboard | No | |
ThunderCrit | integer | No | |
ThunderCritPos | location | No | |
TimmySpawn | location | No | |
tmp_point | location | No | |
ToD_Ability | integer | No | |
ToD_Area_of_Effect | real | No | |
ToD_Base_Chance | integer | No | |
ToD_Base_Heal | real | No | |
ToD_Caster | unit | No | |
ToD_Dummy_Ability | abilcode | No | |
ToD_Dummy_Ability_Frenzy | abilcode | No | |
ToD_Heal_Group | group | No | |
ToD_Owner | player | No | |
ToD_Position | location | No | |
ToD_Target_Location | location | No | |
ToD_Unit_Counter | integer | No | |
ToI1 | unit | No | |
ToI2 | unit | No | |
ToI3 | unit | No | |
ToI4 | unit | No | |
Tombstone1 | unit | No | |
Tombstone2 | unit | No | |
Tombstone3 | unit | No | |
Tombstone4 | unit | No | |
TombstoneFFA1 | unit | No | |
TombstoneFFA2 | unit | No | |
TombstoneFFA3 | unit | No | |
TombstoneFFA4 | unit | No | |
TombStoneP | location | Yes | |
TombStoneSparkle | effect | Yes | |
TransmuteVictims | group | No | |
TreasurerSFX | effect | No | |
uChainFrostC | unit | Yes | |
uChainFrostD | unit | Yes | |
uChainFrostT | unit | Yes | |
UpheavalLevel | integer | No | |
UpheavalPos | location | No | |
VictorySpeaker | unit | No | |
VStalker | unit | Yes | |
WaterBubbleTarget | unit | No | |
WildSeedPoint | location | No | |
WWR | integer | No | |
WWRP | location | No | |
XPRate | real | No | |
ZombieGroup | group | Yes |
// 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