Name | Type | is_array | initial_value |
a | real | No | |
Airstrike_Text | texttag | No | |
ang | real | No | |
Angle | real | No | |
AngleVar | real | No | |
ARArrows | integer | Yes | |
ARArrowsGroup | group | Yes | |
ARArrowsGroup2 | group | Yes | |
ARCaster | unit | Yes | |
ARCount | integer | No | |
ARDamage | real | Yes | |
ARDelay | real | Yes | |
ARHas | boolean | Yes | |
ARIndex | integer | No | |
ARInteger | integervar | No | |
ARLastRecycled | integer | No | |
ARMax | integer | No | |
ARRecycledList | integer | Yes | |
ARTargetPoint | location | Yes | |
AT_AddDistanceLoop | real | Yes | |
AT_AllowBuildings | boolean | Yes | |
AT_AllowBuildingsLoop | boolean | Yes | |
AT_AllowCliffs | boolean | Yes | |
AT_AllowCliffsLoop | boolean | Yes | |
AT_AllowWater | boolean | Yes | |
AT_AllowWaterLoop | boolean | Yes | |
AT_AngleMove | real | Yes | |
AT_AngleMoveLoop | real | Yes | |
AT_AoE1Axe | real | Yes | |
AT_AoE1AxeLoop | real | Yes | |
AT_AoE2Axe | real | Yes | |
AT_AoE2AxeLoop | real | Yes | |
AT_AoE3Axe | real | Yes | |
AT_AoE3AxeLoop | real | Yes | |
AT_AxeLoop | unit | Yes | |
AT_AxePointLoop | unit | Yes | |
AT_AxeSpeedCurrent | real | Yes | |
AT_AxeSpeedCurrentLoop | real | Yes | |
AT_AxeSpeedDecreasement | real | Yes | |
AT_AxeSpeedDecreasementLoop | real | Yes | |
AT_AxeSpeedDefault | real | Yes | |
AT_AxeSpeedDefaultLoop | real | Yes | |
AT_BloodEffect | string | Yes | |
AT_BloodEffectLoop | string | Yes | |
AT_BumpEffect | string | Yes | |
AT_BumpEffectLoop | string | Yes | |
AT_Caster | unit | Yes | |
AT_CasterLoop | unit | Yes | |
AT_Damages | real | Yes | |
AT_DamagesLoop | real | Yes | |
AT_DestroyTrees | boolean | Yes | |
AT_DestroyTreesLoop | boolean | Yes | |
AT_DistanceAxe | real | Yes | |
AT_DistanceAxeLoop | real | Yes | |
AT_Group | group | No | |
AT_GroupAxeLoop | group | No | |
AT_GroupLoop | group | Yes | |
AT_IntegerCasting1 | integer | No | |
AT_IntegerCasting2 | integer | No | |
AT_IntegerCasting3 | integervar | No | |
AT_IntegerThrowingLoop1 | integer | No | |
AT_IntegerThrowingLoop2 | integer | No | |
AT_IntegerThrowingLoop3 | integervar | No | |
AT_Level | integer | Yes | |
AT_NumberAxesRemaining | integer | Yes | |
AT_NumberAxesThrown | integer | Yes | |
AT_RandomIntegerForBlood | integer | No | |
AT_Return | boolean | Yes | |
AT_TempGroupLoop | group | No | |
AT_TempPoint | location | No | |
AT_TempPoint2 | location | No | |
AT_TempPoint3 | location | No | |
AT_TimerCasting | real | Yes | |
AT_TimerElapsedCasting | real | Yes | |
BM | unit | No | |
BunkerDummies | unitcode | Yes | |
BunkerDummy | unit | Yes | |
BunkerMaxUnits | integer | No | |
BunkerUnitGroup | group | Yes | |
BunkerUnits | unitcode | Yes | |
Cannibalize_Ability_Level | integer | No | |
Cannibalize_Caster | unit | No | |
Cannibalize_Dummy_Ability | abilcode | No | |
CannibalizeDummy | unit | No | |
CargoEvent | real | No | |
CargoTransportGroup | group | Yes | |
CargoTransportUnit | unit | Yes | |
Caster | unit | No | |
cdcUnitvar | unit | Yes | |
CEvBlock | boolean | Yes | |
CEvNext | integer | Yes | |
CEvPrev | integer | Yes | |
CEvSpecial | boolean | Yes | |
CEvUnloadTimer | timer | No | |
Chainsaw | location | No | |
ChainsawUnit | unit | No | |
CheckDeathList | integer | Yes | |
CheckDeathTimer | timer | No | |
Circle | real | No | |
CommanderText | texttag | No | |
Config | integer | Yes | |
CopCarText | texttag | No | |
Countdown | timer | No | |
Countdown2 | timer | No | |
Countdown3 | timer | No | |
Countdown4 | timer | No | |
Countdown5 | timer | No | |
Countdown6 | timer | No | |
Countdown_Antirush | timer | No | |
Countdown_Window | timerdialog | No | |
Countdown_Window_AntiRush | timerdialog | No | |
DeathEvent | real | No | |
Debug | integervar | No | |
DetectRemoveAbility | abilcode | No | |
DetectTransformAbility | abilcode | No | |
DEvAbility | abilcode | No | |
DEvBlock | boolean | Yes | |
DEvList | integer | Yes | |
DEvRemoved | boolean | Yes | |
DEvTimer | timer | No | |
dist | real | No | |
dum_u | unit | No | |
dummy_pt | location | No | |
DummyCaster | unit | No | |
Earth_Fury_Ability_Level | integer | No | |
Earth_Fury_AoE_Bouns | real | No | |
Earth_Fury_Base_Area_of_Effect | real | No | |
Earth_Fury_Base_Damage | real | No | |
Earth_Fury_Bonus_Damage | real | No | |
Earth_Fury_Caster | unit | No | |
Earth_Fury_Chance | real | No | |
Earth_Fury_Damage_Group | group | No | |
Earth_Fury_Dummy_Ability | abilcode | No | |
Earth_Fury_Dummy_Ability_2 | abilcode | No | |
Earth_Fury_Location | location | No | |
Earth_Fury_Owner | player | No | |
Earth_Fury_Total_Area_of_Effec | real | No | |
Earth_Fury_Total_Damage | real | No | |
effectKnockback | string | No | |
EvoPath1 | timer | No | |
EvoPath10 | timer | No | |
EvoPath3 | timer | No | |
EvoPath4 | timer | No | |
EvoPath5 | timer | No | |
EvoPath6 | timer | No | |
EvoPath7 | timer | No | |
EvoPath8 | timer | No | |
EvoPath9 | timer | No | |
EvoPathVar | timer | Yes | |
EvoPathWindow1 | timerdialog | No | |
EvoPathWindow10 | timerdialog | No | |
EvoPathWindow3 | timerdialog | No | |
EvoPathWindow4 | timerdialog | No | |
EvoPathWindow5 | timerdialog | No | |
EvoPathWindow6 | timerdialog | No | |
EvoPathWindow7 | timerdialog | No | |
EvoPathWindow8 | timerdialog | No | |
EvoPathWindow9 | timerdialog | No | |
EvoPathWindowVar | timerdialog | Yes | |
exp_r | real | No | |
F_Integers | integer | Yes | |
F_ReachedFading | real | Yes | |
F_Time | real | Yes | |
F_Unit | unit | Yes | |
FA_Time | real | No | |
FA_Unit | unit | No | |
FACaster | unit | Yes | |
FACount | integer | No | |
FADelay | real | Yes | |
FAHas | boolean | Yes | |
FAIndex | integer | No | |
FAInteger | integervar | No | |
FALastRecycled | integer | No | |
FAMax | integer | No | |
FARecycledList | integer | Yes | |
FATargetPoint | location | Yes | |
FATimer | real | Yes | |
FB_Ability | abilcode | No | |
FB_Attack_Type | attacktype | No | |
FB_Condition | boolean | Yes | |
FB_DAbility | abilcode | No | |
FB_Damage_Type | damagetype | No | |
FB_Dummy_Type | unitcode | No | |
FB_Fireball_AoE | real | Yes | |
FB_Fireball_Collision | real | Yes | |
FB_Fireball_Damage | real | Yes | |
FB_Fireball_Effect | string | No | |
FB_Fireball_Explosion_Type | integer | Yes | |
FB_Fireball_Height | real | Yes | |
FB_Fireball_Hit | boolean | No | |
FB_Fireball_Model | string | No | |
FB_Fireball_Scale | real | Yes | |
FB_Fireball_Speed | real | Yes | |
FB_Fireballs_AoE | real | Yes | |
FB_Fireballs_Collision | real | Yes | |
FB_Fireballs_Damage | real | Yes | |
FB_Fireballs_Distance | real | Yes | |
FB_Fireballs_Effect | string | No | |
FB_Fireballs_Explosion_Type | integer | Yes | |
FB_Fireballs_Height | real | Yes | |
FB_Fireballs_Hit | boolean | No | |
FB_Fireballs_Model | string | No | |
FB_Fireballs_Number | integer | Yes | |
FB_Fireballs_Scale | real | Yes | |
FB_Fireballs_Speed | real | Yes | |
FB_Group | group | No | |
FB_Handle_Id | integer | No | |
FB_Harvest_Order | string | No | |
FB_Harvester | unit | No | |
FB_Hashtable | hashtable | No | |
FB_Interval | real | No | |
FB_Kill_Trees | boolean | No | |
FB_Level | integer | No | |
FB_Loop | integervar | No | |
FB_Owner | player | No | |
FB_Real | real | Yes | |
FB_SFX | effect | No | |
FB_Spawn_Distance | real | No | |
FB_TempUnit | unit | Yes | |
FB_Tree | destructable | No | |
Fire_Wall_Ability_Level | integer | No | |
Fire_Wall_Caster | unit | No | |
Fire_Wall_Distance | real | No | |
Fire_Wall_Dummy_Ability | abilcode | No | |
Fire_Wall_Duration | real | No | |
Fire_Wall_Location | location | No | |
Fire_Wall_Loop_Location | location | No | |
Fire_Wall_Loop_Location_2 | location | No | |
Fire_Wall_Owner | player | No | |
Flamethrower_Burn1 | effect | No | |
Flamethrower_Burn10 | effect | No | |
Flamethrower_Burn3 | effect | No | |
Flamethrower_Burn4 | effect | No | |
Flamethrower_Burn5 | effect | No | |
Flamethrower_Burn6 | effect | No | |
Flamethrower_Burn7 | effect | No | |
Flamethrower_Burn8 | effect | No | |
Flamethrower_Burn9 | effect | No | |
FS_Angle | real | Yes | |
FS_AoE | real | No | |
FS_C_Point | location | Yes | |
FS_Caster | unit | Yes | |
FS_Counter | integer | Yes | |
FS_Damage | integer | No | |
FS_Distance | real | Yes | |
FS_Dummy | unit | Yes | |
FS_Effect | effect | Yes | |
FS_effects | string | Yes | |
FS_Group | group | Yes | |
FS_Index | integer | Yes | |
FS_Level | integer | Yes | |
FS_Loop_Integer | integervar | Yes | |
FS_Number_Units | integer | Yes | |
FS_Random | unit | Yes | |
FS_T_Point | location | Yes | |
FS_Total_Counter | integer | Yes | |
g | group | No | |
GraveyardUnit | unit | No | |
Grenade_Ability_Level | integer | No | |
Grenade_Base_AoE | real | No | |
Grenade_Base_Damage | real | No | |
Grenade_Caster | unit | No | |
Grenade_Damage_Group | group | No | |
Grenade_Location | location | No | |
Grenade_Loop_Location | location | No | |
Grenade_Loop_Number | integer | No | |
Grenade_Text | texttag | No | |
Grenade_Total_Aoe | real | No | |
Grenade_Total_Damage | real | No | |
GroupVar | group | No | |
Hero | unit | Yes | |
Hero1 | unit | No | |
Hero10 | unit | No | |
Hero3 | unit | No | |
Hero4 | unit | No | |
Hero5 | unit | No | |
Hero6 | unit | No | |
Hero7 | unit | No | |
Hero8 | unit | No | |
Hero9 | unit | No | |
HeroArray | unit | Yes | |
Hive | unit | No | |
HookMan | unit | No | |
HumanAlly | force | No | |
Humans | force | Yes | Force01 |
HumansAlive | group | No | |
i | integervar | No | |
i2 | integervar | No | |
IAAngle | real | Yes | |
IAArrow | unit | Yes | |
IACaster | unit | Yes | |
IACasterPoint | location | Yes | |
IACount | integer | No | |
IADamage | real | Yes | |
IADistance | real | Yes | |
IADMGGroup | group | Yes | |
IAHas | boolean | Yes | |
IAIndex | integer | No | |
IAInteger | integervar | No | |
IALastRecycled | integer | No | |
IAMax | integer | No | |
IAMaxDistance | real | Yes | |
IARecycledList | integer | Yes | |
IATargetPoint | location | Yes | |
infection | force | No | |
InfestedRadar | unit | No | |
Ion_Canon_Ability_Level | integer | No | |
Ion_Canon_AoE | real | No | |
Ion_Canon_Base_Damage | real | No | |
Ion_Canon_Base_Mana_Burn | real | No | |
Ion_Canon_Caster | unit | No | |
Ion_Canon_Damage_Group | group | No | |
Ion_Canon_Distance | real | No | |
Ion_Canon_Location | location | No | |
Ion_Canon_Loop_Location | location | No | |
Ion_Canon_Loop_Number | integer | No | |
Ion_Canon_Target_Location | location | No | |
Ion_Canon_Total_Damage | real | No | |
Ion_Canon_Total_Mana_Burn | real | No | |
IsUnitAlive | boolean | Yes | |
IsUnitBeingUnloaded | boolean | Yes | |
IsUnitNew | boolean | Yes | |
IsUnitPreplaced | boolean | Yes | |
IsUnitReincarnating | boolean | Yes | |
IsUnitRemoved | boolean | Yes | |
IsUnitTransforming | boolean | Yes | |
JD_Angle | real | Yes | |
JD_Animations | string | Yes | |
JD_Distances | real | Yes | |
JD_Effect | string | Yes | |
JD_Group | group | No | |
JD_HighSettings | real | Yes | |
JD_Integers | integer | Yes | |
JD_JumpHigh | real | Yes | |
JD_ReachedDistance | real | Yes | |
JD_RealTimer | real | Yes | |
JD_SpeedUnits | real | Yes | |
JD_TempPoint | location | Yes | |
JD_TreesDestroy | boolean | Yes | |
JD_Unit | unit | Yes | |
JDA_Animation | string | No | |
JDA_AnimationSpeed | real | No | |
JDA_Collusion | boolean | No | |
JDA_DestroyTrees_Dash | boolean | No | |
JDA_JumpHigh_Distance | real | No | |
JDA_SpecialEffect | string | No | |
JDA_Speed | real | No | |
JDA_TargetPoint | location | No | |
JDA_Unit | unit | No | |
K_Angle | real | Yes | |
K_Cast_Point | location | No | |
K_Caster | unit | Yes | |
K_Counter | integer | Yes | |
K_Damage | integer | No | |
K_Distance_Times | integer | No | |
K_effects | string | Yes | |
K_Index | integer | Yes | |
K_Level | integer | Yes | |
K_Move_Point | location | Yes | |
K_Speed_Distance | real | No | |
K_Target | unit | Yes | |
K_Target_Point | location | Yes | |
KillerOfUnit | unit | Yes | |
Knockback_Angle | real | Yes | |
Knockback_Distance | integer | Yes | |
Knockback_UnitTarget | unit | Yes | |
KO_ability | abilcode | No | |
KO_angle | real | Yes | |
KO_burnedMana | real | Yes | |
KO_caster | unit | Yes | |
KO_destroyTree | boolean | No | |
KO_destroyTreeRange | real | No | |
KO_distance | real | Yes | |
KO_distanceTravel | real | Yes | |
KO_dummy | unit | Yes | |
KO_dummyEffect | string | No | |
KO_duration | real | Yes | |
KO_effectCount | real | Yes | |
KO_effectCountDelay | real | No | |
KO_getNearbyHero | boolean | Yes | |
KO_height | real | No | |
KO_index1 | integer | Yes | |
KO_index2 | integer | No | |
KO_indexMax | integer | No | |
KO_indexSize | integer | No | |
KO_intervalEffect | string | No | |
KO_landDamage | real | Yes | |
KO_landDamageAoE | real | Yes | |
KO_lightning | lightning | Yes | |
KO_pullAoE | real | Yes | |
KO_pullDistance | real | Yes | |
KO_pullDistanceTravel | real | Yes | |
KO_pullDuration | real | Yes | |
KO_pulledEffect | string | No | |
KO_pullGroup | group | No | |
KO_spellEnd | boolean | Yes | |
KO_target | unit | Yes | |
loc | location | No | |
lvl | integer | No | |
Magnetic_Saw_Hash | hashtable | No | |
Magnetised_Group | group | No | |
MassInfected | group | No | |
maxIndexKnockback | integer | No | |
OwnerUnit | player | No | |
Parasite_Evolving | unit | No | |
PD_Angle | real | Yes | |
PD_Distances | real | Yes | |
PD_Integers | integer | Yes | |
PD_ReachedDistance | real | Yes | |
PD_RealTimer | real | Yes | |
PD_SpeedUnits | real | Yes | |
PD_TempPoint | location | Yes | |
PD_TestGroup | group | No | |
PD_TreesDestroy | boolean | Yes | |
PD_Unit | unit | Yes | |
PlayerVisibility | player | No | |
Point | location | No | |
Point2 | location | No | |
Point3 | location | No | |
Point4 | location | No | |
Point5 | location | No | |
Point6 | location | No | |
Point7 | location | No | |
Point8 | location | No | |
Point9 | location | No | |
PointArray | location | Yes | |
r | real | No | |
r2 | real | No | |
Radio | location | No | |
Radio2 | texttag | No | |
RadioP1 | location | No | |
RadioP10 | location | No | |
RadioP3 | location | No | |
RadioP4 | location | No | |
RadioP5 | location | No | |
RadioP6 | location | No | |
RadioP7 | location | No | |
RadioP8 | location | No | |
RadioP9 | location | No | |
RandomItemDrop | location | No | |
RB_Duration | real | Yes | |
RB_Effect | effect | Yes | |
RB_Group | group | No | |
RB_Max | integer | No | |
RB_Unit | unit | Yes | |
RBM_Data | real | Yes | |
RBM_Max | integer | No | |
RBM_Unit | unit | Yes | |
Reinforcements_Text | texttag | No | |
Revive1 | timer | No | |
Revive10 | timer | No | |
Revive12 | timer | No | |
Revive3 | timer | No | |
Revive4 | timer | No | |
Revive5 | timer | No | |
Revive6 | timer | No | |
Revive7 | timer | No | |
Revive8 | timer | No | |
Revive9 | timer | No | |
ReviveWindow1 | timerdialog | No | |
ReviveWindow10 | timerdialog | No | |
ReviveWindow12 | timerdialog | No | |
ReviveWindow2 | timerdialog | No | |
ReviveWindow3 | timerdialog | No | |
ReviveWindow4 | timerdialog | No | |
ReviveWindow5 | timerdialog | No | |
ReviveWindow6 | timerdialog | No | |
ReviveWindow7 | timerdialog | No | |
ReviveWindow8 | timerdialog | No | |
ReviveWindow9 | timerdialog | No | |
Rocket | effect | No | |
Rocket_Text | texttag | No | |
s | string | No | |
Saw_Creation | integer | No | |
Saws | group | No | |
SB_Angle | real | Yes | |
SB_AOE | real | Yes | |
SB_Caster | unit | No | |
SB_Casters | unit | Yes | |
SB_ConvertedDamage | real | Yes | |
SB_CountIntegers | integer | Yes | |
SB_Damage | real | No | |
SB_DestroyTrees | boolean | No | |
SB_Distances | real | Yes | |
SB_DmgAOE | real | No | |
SB_Group | group | No | |
SB_HighSettings | real | Yes | |
SB_Integers | integer | Yes | |
SB_JumpHigh | real | Yes | |
SB_Points | location | Yes | |
SB_ReachedDistance | real | Yes | |
SB_Reals | real | No | |
SB_RealTimer | real | Yes | |
SB_SpeedIncreasement | real | No | |
SB_SpeedUnits | real | Yes | |
SB_TempPoint | location | Yes | |
SB_TotalUnitGroup | group | No | |
SB_TreesDestroy | boolean | Yes | |
SB_Unit | unit | Yes | |
SBA_Integers | integer | No | |
SBA_JumpHigh_Distance | real | No | |
SBA_Speed | real | No | |
SBA_TargetPoint | location | No | |
SBA_Unit | unit | No | |
Shapeshifter | unit | No | |
ShapeshifterPoint | location | No | |
SpecialVar | unit | Yes | |
Speed | integer | No | |
spellIndex | integervar | No | |
SummonerOfUnit | unit | Yes | |
SupplyDrop_Text | texttag | No | |
SupplyDropText1 | texttag | No | |
SW_AbilityID | abilcode | Yes | |
SW_Index | integer | Yes | |
SW_LoopIsOn | boolean | Yes | |
SW_MiniStunID | abilcode | Yes | |
SW_Range | real | Yes | |
SW_RefreshRate | real | Yes | |
SW_StunnerID | unitcode | Yes | |
SW_TargPoint | location | Yes | |
SW_Timer | real | Yes | |
SW_TimerExpiry | real | Yes | |
SW_TrigUnit | unit | Yes | |
SW_UnitsInRange | group | Yes | |
SW_WardID | unitcode | Yes | |
Sweep_Caster | unit | Yes | |
Sweep_Data | real | Yes | |
Sweep_DataCount | integer | No | |
Sweep_Group | group | Yes | |
Sweep_Lightning | lightning | Yes | |
Sweep_Max | integer | No | |
tar_pt | location | No | |
tar_pt2 | location | No | |
tar_u | unit | No | |
Target | unit | No | |
Temp_Group | group | Yes | |
Temp_Point | location | Yes | |
Temp_Unit | handle | No | |
TempGroup | group | No | |
TempHero | unit | No | |
TempInt | integer | No | |
tempInt | integervar | No | |
TempInt2 | integer | No | |
TempInteger | integer | No | |
tempInteger | integer | No | |
TempInteger2 | integer | No | |
TempInteger3 | integervar | No | |
TempIntVar | integer | No | |
TempLoc | location | No | |
TempLoc2 | location | No | |
TempLoc3 | location | No | |
tempPlayerGroup | force | No | |
TempPoint | location | No | |
tempPoint | location | No | |
tempPoint1 | location | No | |
tempPoint2 | location | No | |
tempPoint3 | location | No | |
TempReal | real | No | |
tempReal | real | No | |
TempUnit | unit | No | |
tempUnit | unit | No | |
TempUnit2 | unit | No | |
tempunit3 | unit | No | |
TempUnitType | unitcode | No | |
TempUnitType2 | unitcode | No | |
TempX | real | No | |
TempY | real | No | |
tmppoint | location | Yes | |
tmppoint2 | location | Yes | |
tmppoint3 | location | Yes | |
TreeDestroyer | unit | No | |
u | unit | No | |
u2 | unit | No | |
UC_Counter | integer | Yes | |
UC_Groups | group | Yes | |
UC_Inv | boolean | Yes | |
UC_SETTINGS_AreaOfEffect | real | Yes | |
UC_SETTINGS_Collosion | boolean | No | |
UC_SETTINGS_DestroyTrees_Dash | boolean | No | |
UC_SETTINGS_Invulnerable | boolean | No | |
UC_SETTINGS_Speed | real | No | |
UC_Target | unit | No | |
UC_TempPoint | location | Yes | |
UDex | integer | No | |
UDexGen | integer | No | |
UDexLastRecycled | integer | No | |
UDexMax | integer | No | |
UDexNext | integer | Yes | |
UDexPrev | integer | Yes | |
UDexRecycle | integer | No | |
UDexUnits | unit | Yes | |
UDexWasted | integer | No | |
UnitIndexerEnabled | boolean | No | |
UnitIndexEvent | real | No | |
UnitIndexLock | integer | Yes | |
UnitTypeEvent | real | No | |
UnitTypeOf | unitcode | Yes | |
UnitVar | unit | No | |
VisionVar1 | fogmodifier | No | |
VisionVar10 | fogmodifier | No | |
VisionVar3 | fogmodifier | No | |
VisionVar4 | fogmodifier | No | |
VisionVar5 | fogmodifier | No | |
VisionVar6 | fogmodifier | No | |
VisionVar7 | fogmodifier | No | |
VisionVar8 | fogmodifier | No | |
VisionVar9 | fogmodifier | No | |
WarBearVar | unit | Yes | |
WorldMaxX | real | No | |
WorldMaxY | real | No | |
WoS | integervar | No | |
WoS2_Caster | unit | Yes | |
WoS2_Caster_Copy | unit | Yes | |
WoS2_Distance | real | Yes | |
WoS2_Off | boolean | Yes | |
WoS2_Skip | integer | No | |
WoS2_SpellLvl | integer | Yes | |
WoS2_Times | integer | No | |
WoS_Angle | real | Yes | |
WoS_AoE | real | No | |
WoS_BaseDamage | real | No | |
WoS_Caster | unit | Yes | |
WoS_DamagePerLevel | real | No | |
WoS_Dummy | unit | Yes | |
WoS_Loop | integer | Yes | |
WoS_Off | boolean | Yes | |
WoS_Point1 | location | No | |
WoS_Point2 | location | No | |
WoS_RangeMax | real | No | |
WoS_RangeMin | real | No | |
WoS_Skip | integer | No | |
WoS_SoulsAngle | real | No | |
WoS_Speed | real | No | |
WoS_SpellLvl | integer | Yes | |
WoS_Times | integer | No | |
wuerfel | integer | No | |
x | real | No | |
x2 | real | No | |
y | real | No | |
y2 | real | No | |
zLoc | location | No | |
Zombie | unitcode | No | h000 |
ZombieAlly | force | No | |
ZombieHealth | real | No | |
Zombies | group | Yes | |
Zombies2 | group | No | |
ZombieTeam | force | Yes | Force10 |
function Combine_Items_Conditions takes nothing returns boolean
return GetItemCharges(GetManipulatedItem()) > 0
endfunction
function Combine_Items_Actions takes nothing returns nothing
local item NEWITEM = GetManipulatedItem()
local unit OURUNIT = GetManipulatingUnit()
local integer MAXIMUM = 500 //The max no. of charges allowed
local integer ITEMCOUNT = 0
local integer ITEMLOOP = 0
local integer CHARGES = 0
loop
exitwhen ITEMLOOP > 6
if GetItemTypeId(NEWITEM) == GetItemTypeId(UnitItemInSlot(OURUNIT, ITEMLOOP)) then
if GetItemCharges(UnitItemInSlot(OURUNIT, ITEMLOOP)) + GetItemCharges(NEWITEM) <= MAXIMUM then
if not (UnitItemInSlot(OURUNIT, ITEMLOOP) == NEWITEM) then
set CHARGES = GetItemCharges(UnitItemInSlot(OURUNIT, ITEMLOOP)) + GetItemCharges(NEWITEM)
call SetItemCharges(UnitItemInSlot(OURUNIT, ITEMLOOP), CHARGES)
call RemoveItem(NEWITEM)
set ITEMLOOP = 7
endif
endif
endif
if (ITEMLOOP < 7) then
set ITEMLOOP = ITEMLOOP + 1
endif
endloop
set NEWITEM = null
set OURUNIT = null
endfunction
function InitTrig_Combine_Items takes nothing returns nothing
set gg_trg_Combine_Items = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Combine_Items, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddCondition( gg_trg_Combine_Items, Condition( function Combine_Items_Conditions ) )
call TriggerAddAction( gg_trg_Combine_Items, function Combine_Items_Actions )
endfunction
_______________________________________
__________Repelling Bubble_____________
__________by XAOS_WIZARD_______________
__________or D4RK_G4ND4LF______________
__________Inspired by Cedi_____________
_______________________________________
The Spell works like this:
The caster and the target unit is added to an array
to check if there is any enemy in range.
If this is the case the enemy will be knocked back.
If the enemy has reached the max knockback distance
he will be pulled back to the caster again.
How to add this spell to your Map:
Copy the ability "Repelling Bubble"
Enable File\Preferences\General\"automatically create unknown variables while pasting trigger data"
Copy the triggers in the following order:
0. Ini (or just initialize the location in your own ini trigger)
1. RepellingBubbleLoop
2. RepellingBubbleCast
Notes:
There might occure some bugs like units stuck in obstacles
if you are going to remove the caster from the game
while the spell is running so don't do that.
This spell uses 2D-Arrays.
There is a tutorial about it in the tutorial section.
Everything you are allowed to change has some comments above it
/*************************************
*
* AtomicBomb
* v3.1.0.1
* By Magtheridon96
*
* - Creates a bombing plane behind the caster
* that will drop an atomic bomb dealing damage
* to enemy units in an area of effect. Deals
* bonus damage to closer units.
*
* Requires:
* ---------
*
* - CTL by Nestharus
* - hiveworkshop.com/forums/jass-resources-412/snippet-constant-timer-loop-32-a-201381/
* - SpellEffectEvent by Bribe
* - hiveworkshop.com/forums/jass-resources-412/snippet-spelleffectevent-187193/
* - Particle by Nestharus
* - hiveworkshop.com/forums/submissions-414/snippet-needs-work-particle-206279/
*
* Optional:
* ---------
*
* - TimerUtils by Vexorian (This also caters to my version of TimerUtils in the Hive Jass section Graveyard)
* - wc3c.net/showthread.php?t=101322
*
* Importing:
* ----------
*
* - Copy this code to a new trigger.
* - Make sure you have all the requirements implemented too.
* - Go the object editor and copy/paste the objects to your map (1 ability, 2 dummy units).
* - There is also an object called Particle that you need which is part of the Particle library.
* - Import the special effect and dummy.mdl to your map.
* - Configure the data in the globals to your liking.
* - Done!
*
* Credits:
* --------
*
* - WILL THE ALMIGHTY (Explosion Effect)
* - Bribe (SpellEffectEvent, Table)
* - Nestharus (CTL, Particle)
* - Vexorian (TimerUtils)
*
*************************************/
library AtomicBomb requires CTL, SpellEffectEvent, Particle, optional TimerUtils
// Configuration
globals
// The ability raw code
private constant integer ABIL_CODE = 'A00K'
// The plane dummy unit raw code
private constant integer PLANE_CODE = 'h039'
// The bomb dummy unit raw code
private constant integer BOMB_CODE = 'h038'
// Explosion Effect
private constant string EXPLOSION_EFFECT = "war3mapImported\\NuclearExplosion.mdx"
// The effect that is created when the plane is created.
private constant string PLANE_IN_EFFECT = "Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl"
// The effect that is created when the plane is destroyed.
private constant string PLANE_OUT_EFFECT = "Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl"
// How much time should we wait before destroying the explosion effect?
private constant real DESTROY_EXPLOSION_AFTER = 15.
// How much time should we wait before destroying the effect created when the plane is created?
private constant real DESTROY_IN_EFFECT_PARTICLE_AFTER = 1.4
// How much time should we wait before destroying the effect created when the plane is destroyed?
private constant real DESTROY_OUT_EFFECT_PARTICLE_AFTER = 1.4
// Bomb and Plane height
private constant real BOMB_HEIGHT = 500.
// Bomb Drop Speed Base (It will accelerate starting from this base-speed)
private constant real BOMB_DROP_SPEED = 1.
// Bomb Drop Acceleration
private constant real BOMB_DROP_ACCEL = 1.
// The dummy owning player
private constant player DUMMY_OWNER = Player(13)
// Destroy trees around the explosion?
private constant boolean DESTROY_TREES = true
// The offset from the point from the target point for plane creation
private constant real PLANE_DISTANCE = 500.
// How long does the plane stay after it drops the bomb?
private constant real PLANE_AFTER_DROP = 2.
// Attack type
private constant attacktype ATTACK_TYPE = ATTACK_TYPE_NORMAL
// Damage type
private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_MAGIC
// The largest collision a unit has in your map
private constant real MAX_COLLISION = 197.
endglobals
// End Configuration
// The speed of the plane per 1/32th of a second
private function GetPlaneSpeedFactor takes integer level returns real
return 9.
endfunction
// The damage dealed to each unit
private function GetDamage takes integer level returns real
return 9000 + level * 75.
endfunction
// The damage radius
private function GetDamageRadius takes integer level returns real
return 350 + level * 75.
endfunction
// How close do units have to be for the spell to deal bonus damage?
private function GetBonusDamageRadius takes integer level returns real
return 125 + level * 50.
endfunction
// I want the spell to deal double the damage to units closer than the bonus damage radius.
private function GetBonusDamageFactor takes integer level returns real
return 1.3
endfunction
// This function will filter out some targets (Allied, dead, magic immune and structures)
private function TargetFilter takes player owner, unit caster, unit target returns boolean
return IsUnitEnemy(target, owner) and not (IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE) or IsUnitType(target, UNIT_TYPE_DEAD) or GetUnitTypeId(target) == 0)
endfunction
private struct Spell extends array
private static group enumGroup = CreateGroup()
private static unit array caster
private static unit array plane
private static unit array bomb
private static real array xDis
private static real array yDis
private static real array planeX
private static real array planeY
private static real array dropX
private static real array dropY
private static real array damage
private static real array radius
private static real array bonusDamage
private static real array bonusRadius
private static real array speed
private static real array height
private static integer array counter
private static integer array level
private static boolean array dropped
private static boolean array exploded
private static player array owner
static if DESTROY_TREES then
private static rect treeRect = null
private static unit treeDetector = null
private static real treesRadius = 0
private static real treesX = 0
private static real treesY = 0
private static method isTree takes destructable d returns boolean
return IssueTargetOrderById(treeDetector, 852018, d) and IssueImmediateOrderById(treeDetector, 851972)
endmethod
private static method destroyTree takes nothing returns nothing
local destructable d = GetEnumDestructable()
local real x = GetWidgetX(d) - treesX
local real y = GetWidgetY(d) - treesY
// If the destructable is a tree and it is in the circle, kill it
if x*x+y*y <= treesRadius and isTree(d) then
call KillDestructable(d)
endif
set d = null
endmethod
endif
// You don't need a Table or a hashtable if you have TimerUtils
static if not LIBRARY_TimerUtils then
private static Table timerData
endif
// I want to murder this function
private static method destroyParticle takes nothing returns nothing
static if LIBRARY_TimerUtilsEx then
call Particle(ReleaseTimer(GetExpiredTimer())).destroy()
elseif LIBRARY_TimerUtils then
call Particle(GetTimerData(GetExpiredTimer())).destroy()
call ReleaseTimer(GetExpiredTimer())
else
call Particle(timerData[GetHandleId(GetExpiredTimer())]).destroy()
call DestroyTimer(GetExpiredTimer())
endif
endmethod
implement CTL
local timer t
local unit u
local real x
local real y
implement CTLExpire
// Set the planeX and planeY coordinates
set planeX[this] = planeX[this] + xDis[this]
set planeY[this] = planeY[this] + yDis[this]
// Moving the plane out of the map bounds would crash the game, so we should make sure the coordinates are sound.
if planeX[this] <= WorldBounds.maxX or planeX[this] >= WorldBounds.minX or planeY[this] <= WorldBounds.maxY or planeY[this] >= WorldBounds.minY then
// Move the plane
call SetUnitX(plane[this], planeX[this])
call SetUnitY(plane[this], planeY[this])
endif
// If the bomb has been dropped
if dropped[this] then
// If the bomb exploded
if exploded[this] then
// Counter-based checking
set counter[this] = counter[this] - 1
if counter[this] == 0 then
// Destroy the current instance of the spell
call this.destroy()
// Remove the plane
call RemoveUnit(plane[this])
// Timer Utils is optional :3
// This is a pretty ugly way of creating a special effect with a Z-coordinate.
static if LIBRARY_TimerUtils then
call TimerStart(NewTimerEx(Particle.createEx(Player(13), planeX[this], planeY[this], BOMB_HEIGHT, 0, 0, 1, 255, 255, 255, 255, PLANE_OUT_EFFECT, 0)), DESTROY_OUT_EFFECT_PARTICLE_AFTER, false, function thistype.destroyParticle)
else
set t = CreateTimer()
set timerData[GetHandleId(t)] = Particle.createEx(Player(13), planeX[this], planeY[this], BOMB_HEIGHT, 0, 0, 1, 255, 255, 255, 255, PLANE_OUT_EFFECT, 0)
call TimerStart(t, DESTROY_OUT_EFFECT_PARTICLE_AFTER, false, function thistype.destroyParticle)
set t = null
endif
// Null variables
set caster[this] = null
set plane[this] = null
set bomb[this] = null
set owner[this] = null
endif
else
// If the height of the bomb is close to 0
if height[this] <= 5 then
// Destroy the bomb and create the explosion
call RemoveUnit(bomb[this])
static if LIBRARY_TimerUtils then
call TimerStart(NewTimerEx(Particle.createEx(Player(13), dropX[this], dropY[this], 0, 0, 0, 1, 255, 255, 255, 255, EXPLOSION_EFFECT, 0)), DESTROY_EXPLOSION_AFTER, false, function thistype.destroyParticle)
else
set t = CreateTimer()
set timerData[GetHandleId(t)] = Particle.createEx(Player(13), dropX[this], dropY[this], 0, 0, 0, 1, 255, 255, 255, 255, EXPLOSION_EFFECT, 0)
call TimerStart(t, DESTROY_EXPLOSION_AFTER, false, function thistype.destroyParticle)
set t = null
endif
// Loop through all units in the area
call GroupEnumUnitsInRange(enumGroup, dropX[this], dropY[this], radius[this] + MAX_COLLISION, null)
loop
set u = FirstOfGroup(enumGroup)
exitwhen u == null
call GroupRemoveUnit(enumGroup, u)
// Check if the target unit passes the filter and make sure he's in the blast radius.
if TargetFilter(owner[this], caster[this], u) and IsUnitInRangeXY(u, dropX[this], dropY[this], radius[this]) then
set x = GetUnitX(u) - dropX[this]
set y = GetUnitY(u) - dropY[this]
// If the unit is closer than the bonusRange
if x*x+y*y <= bonusRadius[this] then
// We deal the bonus damage
call UnitDamageTarget(caster[this], u, bonusDamage[this], false, false, ATTACK_TYPE, DAMAGE_TYPE, null)
else
// Else, we deal the normal damage
call UnitDamageTarget(caster[this], u, damage[this], false, false, ATTACK_TYPE, DAMAGE_TYPE, null)
endif
endif
endloop
static if DESTROY_TREES then
call SetRect(treeRect, dropX[this] - radius[this], dropY[this] - radius[this], dropX[this] + radius[this], dropY[this] + radius[this])
// Cache tree destroy data
set treesRadius = radius[this]*radius[this]
set treesX = dropX[this]
set treesY = dropY[this]
// Enumerate through all destructables in the rect
call EnumDestructablesInRect(treeRect, null, function thistype.destroyTree)
endif
// The counter is now going to be used to determine
// the number of iterations before the spell ends.
set counter[this] = R2I(PLANE_AFTER_DROP * 32)
set exploded[this] = true
else
// Decrease the bomb's height a bit
set height[this] = height[this] - speed[this]
call SetUnitFlyHeight(bomb[this], height[this], 0)
// Accelerate drop speed
set speed[this] = speed[this] + BOMB_DROP_ACCEL
endif
endif
else
// Decrease the counter by 1
set counter[this] = counter[this] - 1
// When the counter is 0, the plane has reached it's destination.
if counter[this] == 0 then
// Store the dropX and dropY coordinates
set dropX[this] = planeX[this]
set dropY[this] = planeY[this]
// Create the bomb under the plane
set bomb[this] = CreateUnit(DUMMY_OWNER, BOMB_CODE, dropX[this], dropY[this], 0)
// Set the bomb's height
call UnitAddAbility(bomb[this], 'Amrf')
call UnitRemoveAbility(bomb[this], 'Amrf')
call SetUnitFlyHeight(bomb[this], BOMB_HEIGHT, 0)
// We have dropped the bomb
set dropped[this] = true
// Set the bomb height and the bomb drop speed
set height[this] = BOMB_HEIGHT
set speed[this] = BOMB_DROP_SPEED
endif
endif
implement CTLNull
set u = null
implement CTLEnd
private static method run takes nothing returns nothing
local thistype this = create()
local real x = GetSpellTargetX()
local real y = GetSpellTargetY()
local real a
local real s
local real cos
local real sin
local timer t
// Set the caster and the owner and the level of the ability
set caster[this] = GetTriggerUnit()
set owner[this] = GetTriggerPlayer()
set level[this] = GetUnitAbilityLevel(caster[this], ABIL_CODE)
// Cache angle data
set a = Atan2(y - GetUnitY(caster[this]), x - GetUnitX(caster[this]))
set cos = Cos(a)
set sin = Sin(a)
// Set the plane coordinates
set planeX[this] = x - PLANE_DISTANCE * cos
set planeY[this] = y - PLANE_DISTANCE * sin
// Create the plane
set plane[this] = CreateUnit(DUMMY_OWNER, PLANE_CODE, planeX[this], planeY[this], a * bj_RADTODEG)
// Set the speed and x/yOffsets per timeout
set s = GetPlaneSpeedFactor(level[this])
set xDis[this] = cos * s
set yDis[this] = sin * s
// We haven't dropped or exploded the bomb
set dropped[this] = false
set exploded[this] = false
// Number of iterations before the bomb drops
set counter[this] = R2I(PLANE_DISTANCE / s)
// Set the plane's height
call UnitAddAbility(plane[this], 'Amrf')
call UnitRemoveAbility(plane[this], 'Amrf')
call SetUnitFlyHeight(plane[this], BOMB_HEIGHT, 0)
// TimerUtils is optional
// This is an ugly way of creating a special effect with Z
static if LIBRARY_TimerUtils then
call TimerStart(NewTimerEx(Particle.createEx(Player(13), planeX[this], planeY[this], BOMB_HEIGHT, 0, 0, 1, 255, 255, 255, 255, PLANE_IN_EFFECT, 0)), DESTROY_IN_EFFECT_PARTICLE_AFTER, false, function thistype.destroyParticle)
else
set t = CreateTimer()
set timerData[GetHandleId(t)] = Particle.createEx(Player(13), planeX[this], planeY[this], BOMB_HEIGHT, 0, 0, 1, 255, 255, 255, 255, PLANE_IN_EFFECT, 0)
call TimerStart(t, DESTROY_IN_EFFECT_PARTICLE_AFTER, false, function thistype.destroyParticle)
set t = null
endif
// Set the damage and the radius
set damage[this] = GetDamage(level[this])
set radius[this] = GetDamageRadius(level[this])
// Set the bonus damage and the bonus radius
set a = GetBonusDamageRadius(level[this])
set bonusRadius[this] = a*a
set bonusDamage[this] = GetBonusDamageFactor(level[this])*damage[this]
endmethod
private static method onInit takes nothing returns nothing
// Register the spell to SpellEffectEvent
call RegisterSpellEffectEvent(ABIL_CODE, function thistype.run)
static if DESTROY_TREES then
set treeDetector = CreateUnit(Player(15), 'hfoo', 0, 0, 0)
call UnitAddAbility(treeDetector, 'Ahrl')
call UnitAddAbility(treeDetector, 'Aloc')
call ShowUnit(treeDetector, false)
set treeRect = Rect(0,0,0,0)
endif
// If you don't have TimerUtils, you need a Table
static if not LIBRARY_TimerUtils then
set timerData = Table.create()
endif
endmethod
endstruct
endlibrary
library CTL /* v1.2.0.1
*************************************************************************************
*
* CTL or Constant Timer Loop provides a loop for constant merged timers of timeout .03125
*
* Similar to T32 but pauses timer when no structs have instances and removes structs
* from timer trigger when those structs have no instances.
*
* This can also create new timers after destroying a previous timer and generates less
* code in the module. It also generates no triggers so long as the module is implemented
* at the top of the struct.
*
************************************************************************************
*
* module CTL
*
* Allows creation/destruction of timers in a struct. Provides instancing of those timers.
*
* - static method create takes nothing returns thistype
* - method destroy takes nothing returns nothing
*
* CTL (optional)
* local variables, code before running any timers
* CTLExpire (not optional)
* timer code
* CTLNull (optional)
* null any locals, runs after all timers
* CTLEnd (not optional)
*
* module CT32
*
* Converts struct into a timer group. Allows the timer group to be started and stopped.
* Instancing and looping through active timers is up to the user.
*
* - static method start takes nothing returns nothing
* - static method stop takes nothing returns nothing
*
* CT32 (not optional)
* timer code
* CT32End (not optional)
*
* struct TimerGroup32 extends array
*
* Allows for the creation of timer groups. Timer instancing and looping is entirely up
* to the user.
*
* - static method create takes code func returns thistype
* - method destroy takes nothing returns nothing
* - method start takes nothing returns nothing
* - method stop takes nothing returns nothing
*
************************************************************************************/
globals
private integer tgc = 0 //timer group count
private integer array tgr //timer group recycler
private integer ic=0 //instance count
private integer tc=0 //timer count
private integer array rf //root first
private integer array n //next
private integer array p //previous
private integer array th //timer head
private integer array ns //next stack
private trigger t=CreateTrigger()
private timer m=CreateTimer()
private triggercondition array ct
private conditionfunc array rc
private boolean array e32 //enabled
private integer array i32r //ct32 recycler
private integer i32cr = 0 //ct32 count recycler
private boolean array ir32 //is recycling
private boolean array id32 //is destroying
endglobals
private function E takes nothing returns nothing
local integer i=ns[0]
set ns[0]=0
loop
exitwhen 0==i
if (0==p[i]) then
if (0==n[i]) then
call TriggerRemoveCondition(t,ct[th[i]])
set ct[th[i]]=null
set tc=tc-1
set rf[th[i]]=0
else
set rf[th[i]]=n[i]
set p[n[i]]=0
endif
else
set p[n[i]]=p[i]
set n[p[i]]=n[i]
endif
set n[i]=n[0]
set n[0]=i
set i=ns[i]
endloop
loop
exitwhen 0 == i32cr
set i32cr = i32cr - 1
set i = i32r[i32cr]
if (not e32[i]) then
call TriggerRemoveCondition(t,ct[i])
set ct[i] = null
if (id32[i]) then
set tgr[i] = tgr[0]
set tgr[0] = i
set id32[i] = false
set e32[i] = false
set ir32[i] = false
endif
endif
endloop
if (0==tc) then
call PauseTimer(m)
else
call TriggerEvaluate(t)
endif
endfunction
private function CT takes integer r returns integer
local integer i
local integer f
if (0==n[0]) then
set i=ic+1
set ic=i
else
set i=n[0]
set n[0]=n[i]
endif
set th[i]=r
set ns[i]=-1
set f=rf[r]
if (0==f) then
set n[i]=0
set p[i]=0
set rf[r]=i
set ct[r] = TriggerAddCondition(t,rc[r])
//set ct[r] = null
if (0==tc) then
call TimerStart(m,.031250000,true,function E)
endif
set tc=tc+1
else
set n[i]=f
set p[i]=0
set p[f]=i
set rf[r]=i
endif
return i
endfunction
private function DT takes integer t returns nothing
debug if (0>ns[t]) then
set ns[t]=ns[0]
set ns[0]=t
debug else
debug call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"TIMER LOOP ERROR: ATTEMPT TO DESTROY NULL TIMER")
debug endif
endfunction
private function A takes code c returns integer
local integer i = tgr[0]
if (0 == i) then
set i = tgc + 1
set tgc = i
else
set tgr[0] = tgr[i]
endif
set rc[i]=Condition(c)
return i
endfunction
private function A32 takes integer i returns nothing
if (not e32[i]) then
if (not ir32[i] and not id32[i]) then
set ct[i] = TriggerAddCondition(t, rc[i])
endif
if (0 == tc) then
call TimerStart(m,.031250000,true,function E)
endif
set tc = tc + 1
set e32[i] = true
endif
endfunction
private function SR32 takes integer i returns nothing
if (e32[i]) then
if (not ir32[i] and not id32[i]) then
set i32r[i32cr] = i
set i32cr = i32cr + 1
set ir32[i] = true
endif
set e32[i] = false
set tc = tc - 1
endif
endfunction
private function DT32 takes integer i returns nothing
if (not id32[i]) then
if (not ir32[i]) then
set ir32[i] = true
set tc = tc - 1
set i32r[i32cr] = i
set i32cr = i32cr + 1
set e32[i] = false
endif
set id32[i] = true
endif
endfunction
private keyword r
private keyword e
module CTL
static integer rctl32
static method create takes nothing returns thistype
return CT(rctl32)
endmethod
method destroy takes nothing returns nothing
call DT(this)
endmethod
static method ectl32 takes nothing returns boolean
local thistype this=rf[rctl32]
endmodule
module CTLExpire
implement CTL
loop
exitwhen 0==this
endmodule
module CTLNull
set this=n[this]
endloop
endmodule
module CTLEnd
implement CTLNull
return false
endmethod
private static method onInit takes nothing returns nothing
set rctl32 = A(function thistype.ectl32)
endmethod
endmodule
module CT32
static integer rctl32
static method ectl32 takes nothing returns boolean
endmodule
module CT32End
return false
endmethod
static method start takes nothing returns nothing
call A32(rctl32)
endmethod
static method stop takes nothing returns nothing
call SR32(rctl32)
endmethod
private static method onInit takes nothing returns nothing
set rctl32 = A(function thistype.ectl32)
endmethod
endmodule
struct TimerGroup32 extends array
static method create takes code c returns thistype
return A(c)
endmethod
method destroy takes nothing returns nothing
call DT32(this)
endmethod
method start takes nothing returns nothing
call A32(this)
endmethod
method stop takes nothing returns nothing
call SR32(this)
endmethod
endstruct
endlibrary
library Particle /* v2.0.2.2
*************************************************************************************
*
* Unit for spell effects
*
* Thanks to Vexorian for dummy.mdx
* Thanks to Magtheridon96 for updates
*
*************************************************************************************
*
* */uses/*
*
* */ UnitIndexer /* hiveworkshop.com/forums/jass-functions-413/unit-indexer-172090/
* */ GetUnitCollision /* hiveworkshop.com/forums/jass-resources-412/snippet-getunitcollision-180495/
*
************************************************************************************
*
* SETTINGS
*/
globals
constant integer PARTICLE_ID = 'n000'
endglobals
/*
************************************************************************************
*
* function GetUnitParticle takes UnitIndex whichUnit returns Particle
*
************************************************************************************
*
* struct Particle extends array
*
* real x
* real y
* real z
*
* real xyAngle
* real zAngle
*
* real scale
*
* player owner
*
* string model
*
* integer red
* integer green
* integer blue
* integer alpha
*
* boolean hidden
*
* readonly real collision
*
* readonly unit unit
*
* static method create takes player owner, real x, real y, real xyAngle, string model, real collision returns Particle
* static method createEx takes player owner, real x, real y, real z, real xyAngle, real zAngle, real scale, integer red, integer green, integer blue, integer alpha, string model, real collision returns Particle
* static method createFromUnit takes unit whichUnit returns Particle
* method destroy takes nothing returns nothing
*
* method setColor takes integer red, integer green, integer blue, integer alpha returns nothing
*
************************************************************************************/
globals
private integer array unitParticle
endglobals
struct Particle extends array
private static integer instanceCount = 0
private static integer array recycler
private unit particle
private unit trueParticle
private real scl
private real tlt
private integer red1
private integer blue1
private integer green1
private integer alpha1
private string mdl
private effect mdle
private real xp
private real yp
private real zp
private real ap
private real collision_p
private static location zloc = Location(0,0)
method operator unit takes nothing returns unit
return particle
endmethod
method operator collision takes nothing returns real
return collision_p
endmethod
method operator x takes nothing returns real
return xp
endmethod
method operator x= takes real v returns nothing
set xp = v
call SetUnitX(particle, v)
endmethod
method operator y takes nothing returns real
return yp
endmethod
method operator y= takes real v returns nothing
set yp = v
call SetUnitY(particle, v)
endmethod
method operator z takes nothing returns real
return zp
endmethod
method operator z= takes real v returns nothing
set zp = v
call MoveLocation(zloc, xp, yp)
call SetUnitFlyHeight(particle, v - GetLocationZ(zloc), 0)
endmethod
method operator xyAngle takes nothing returns real
return ap
endmethod
method operator xyAngle= takes real v returns nothing
set ap = v
call SetUnitFacing(particle,v*57.2957795)
endmethod
method operator zAngle takes nothing returns real
return tlt
endmethod
method operator zAngle= takes real v returns nothing
local integer i = R2I(v*57.2957795+90.5)
set tlt = v
if (179 < i) then
set i = 179
elseif (0 > i) then
set i = 0
endif
call SetUnitAnimationByIndex(particle, i)
endmethod
method operator hidden takes nothing returns boolean
return IsUnitHidden(particle)
endmethod
method operator hidden= takes boolean v returns nothing
call ShowUnit(particle, not v)
endmethod
method operator scale takes nothing returns real
return scl
endmethod
method operator scale= takes real v returns nothing
set scl = v
call SetUnitScale(particle, v, 0, 0)
endmethod
method operator owner takes nothing returns player
return GetOwningPlayer(particle)
endmethod
method operator owner= takes player v returns nothing
call SetUnitOwner(particle, v, true)
endmethod
method operator model takes nothing returns string
return mdl
endmethod
method operator model= takes string s returns nothing
call DestroyEffect(mdle)
if (null != s and "" != s) then
set mdle = AddSpecialEffectTarget(s, particle, "origin")
else
set mdle = null
endif
set mdl = s
endmethod
method setColor takes integer red, integer green, integer blue, integer alpha returns nothing
set this.red1 = red
set this.green1 = green
set this.blue1 = blue
set this.alpha1 = alpha
call SetUnitVertexColor(particle, red, green, blue, alpha)
endmethod
method operator red takes nothing returns integer
return red1
endmethod
method operator blue takes nothing returns integer
return blue1
endmethod
method operator green takes nothing returns integer
return green1
endmethod
method operator alpha takes nothing returns integer
return alpha1
endmethod
method operator red= takes integer v returns nothing
set red1 = v
call SetUnitVertexColor(particle, red1, green1, blue1, alpha1)
endmethod
method operator blue= takes integer v returns nothing
set blue1 = v
call SetUnitVertexColor(particle, red1, green1, blue1, alpha1)
endmethod
method operator green= takes integer v returns nothing
set green1 = v
call SetUnitVertexColor(particle, red1, green1, blue1, alpha1)
endmethod
method operator alpha= takes integer v returns nothing
set alpha1 = v
call SetUnitVertexColor(particle, red1, green1, blue1, alpha1)
endmethod
static method createEx takes player p, real x, real y, real z, real xyAngle, real zAngle, real scale, integer red, integer green, integer blue, integer alpha, string model, real collision returns thistype
local thistype this
local unit u
if (0 == recycler[0]) then
set this = instanceCount + 1
set instanceCount = this
else
set this = recycler[0]
set recycler[0] = recycler[this]
endif
if (null == trueParticle) then
set trueParticle = CreateUnit(p, PARTICLE_ID, x, y, xyAngle * 57.2957795)
set unitParticle[GetUnitUserData(trueParticle)] = this
else
call SetUnitX(trueParticle, x)
call SetUnitY(trueParticle, y)
call SetUnitFacing(trueParticle, xyAngle * 57.2957795)
call SetUnitOwner(trueParticle, p, false)
endif
set xp = x
set yp = y
set zp = z
set ap = xyAngle
set particle = trueParticle
call UnitRemoveAbility(trueParticle, 'Amov')
call UnitAddAbility(trueParticle, 'Amrf')
call UnitRemoveAbility(trueParticle, 'Amrf')
call SetUnitFlyHeight(trueParticle, z, 0)
set mdl = model
set mdle = AddSpecialEffectTarget(model, trueParticle, "origin")
set this.zAngle = zAngle
call setColor(red, green, blue, alpha)
set this.scale = scale
set collision_p = collision
return this
endmethod
static method create takes player p, real x, real y, real xyAngle, string model, real collision returns thistype
return createEx(p, x, y, 0, xyAngle, 0, 1, 255, 255, 255, 255, model, collision)
endmethod
static method createFromUnit takes unit u returns thistype
local thistype this
if (0 == recycler[0]) then
set this = instanceCount + 1
set instanceCount = this
else
set this = recycler[0]
set recycler[0] = recycler[this]
endif
set particle = u
set xp = GetUnitX(u)
set yp = GetUnitY(u)
set zp = GetUnitFlyHeight(u)
set ap = GetUnitFacing(u)*bj_DEGTORAD
set collision_p = GetUnitCollision(u)
set unitParticle[GetUnitUserData(u)] = this
return this
endmethod
method destroy takes nothing returns nothing
if (particle == trueParticle) then
set hidden = false
call DestroyEffect(mdle)
set mdle = null
call SetUnitX(trueParticle, WorldBounds.maxX)
call SetUnitY(trueParticle, WorldBounds.maxY)
else
set particle = null
endif
set recycler[this] = recycler[0]
set recycler[0] = this
endmethod
endstruct
function GetUnitParticle takes UnitIndex whichUnit returns Particle
return unitParticle[whichUnit]
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library GetUnitCollision /* v2.0.1.0
*************************************************************************************
*
* Retrieves collision size for a unit (different from pathing map)
*
* Assumes collision will always be an integer
*
* 100% accurate to 1 decimal for collision sizes >= 5.1
*
*************************************************************************************
*
* */uses/*
*
* */ Table /* hiveworkshop.com/forums/jass-functions-413/snippet-new-table-188084/
*
*************************************************************************************
*
* Functions
*
* function GetUnitCollision takes unit whichUnit returns real
*
************************************************************************************/
globals
private Table uc
endglobals
private function C takes unit u, real x, real y, integer i returns real
local real l = 0
local real h = 300
local real m = 150
local real nm
loop
if (IsUnitInRangeXY(u, x+m, y, 0)) then
set l = m
else
set h = m
endif
set nm = (l+h)/2
exitwhen nm+.001 > m and nm-.001 < m
set m = nm
endloop
set m = R2I(m*10)/10.
set uc.real[i] = m
return m
endfunction
function GetUnitCollision takes unit u returns real
local integer i = GetUnitTypeId(u)
if (uc.real.has(i)) then
return uc.real[i]
endif
return C(u, GetUnitX(u), GetUnitY(u), i)
endfunction
private struct init extends array
private static method onInit takes nothing returns nothing
set uc = Table.create()
endmethod
endstruct
endlibrary
//TESH.scrollpos=20
//TESH.alwaysfold=0
//============================================================================
// SpellEffectEvent
// - Version 1.1.0.0
//
// API
// ---
// RegisterSpellEffectEvent(integer abil, code onCast)
//
// Requires
// --------
// RegisterPlayerUnitEvent: hiveworkshop.com/forums/showthread.php?t=203338
//
// Optional
// --------
// Table: hiveworkshop.com/forums/showthread.php?t=188084
//
library SpellEffectEvent requires RegisterPlayerUnitEvent, optional Table
//============================================================================
private module M
static if LIBRARY_Table then
static Table tb
else
static hashtable ht = InitHashtable()
endif
static method onCast takes nothing returns nothing
static if LIBRARY_Table then
call TriggerEvaluate(.tb.trigger[GetSpellAbilityId()])
else
call TriggerEvaluate(LoadTriggerHandle(.ht, 0, GetSpellAbilityId()))
endif
endmethod
private static method onInit takes nothing returns nothing
static if LIBRARY_Table then
set .tb = Table.create()
endif
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_EFFECT, function thistype.onCast)
endmethod
endmodule
//============================================================================
private struct S extends array
implement M
endstruct
//============================================================================
function RegisterSpellEffectEvent takes integer abil, code onCast returns nothing
static if LIBRARY_Table then
if not S.tb.handle.has(abil) then
set S.tb.trigger[abil] = CreateTrigger()
endif
call TriggerAddCondition(S.tb.trigger[abil], Filter(onCast))
else
if not HaveSavedHandle(S.ht, 0, abil) then
call SaveTriggerHandle(S.ht, 0, abil, CreateTrigger())
endif
call TriggerAddCondition(LoadTriggerHandle(S.ht, 0, abil), Filter(onCast))
endif
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
/**************************************************************
*
* RegisterPlayerUnitEvent
* v5.1.0.0
* By Magtheridon96
*
* I would like to give a special thanks to Bribe, azlier
* and BBQ for improving this library. For modularity, it only
* supports player unit events.
*
* Functions passed to RegisterPlayerUnitEvent must either
* return a boolean (false) or nothing. (Which is a Pro)
*
* Warning:
* --------
*
* - Don't use TriggerSleepAction inside registered code.
* - Don't destroy a trigger unless you really know what you're doing.
*
* API:
* ----
*
* - function RegisterPlayerUnitEvent takes playerunitevent whichEvent, code whichFunction returns nothing
* - Registers code that will execute when an event fires.
* - function RegisterPlayerUnitEventForPlayer takes playerunitevent whichEvent, code whichFunction, player whichPlayer returns nothing
* - Registers code that will execute when an event fires for a certain player.
* - function GetPlayerUnitEventTrigger takes playerunitevent whichEvent returns trigger
* - Returns the trigger corresponding to ALL functions of a playerunitevent.
*
**************************************************************/
library RegisterPlayerUnitEvent // Special Thanks to Bribe and azlier
globals
private trigger array t
endglobals
function RegisterPlayerUnitEvent takes playerunitevent p, code c returns nothing
local integer i = GetHandleId(p)
local integer k = 15
if t[i] == null then
set t[i] = CreateTrigger()
loop
call TriggerRegisterPlayerUnitEvent(t[i], Player(k), p, null)
exitwhen k == 0
set k = k - 1
endloop
endif
call TriggerAddCondition(t[i], Filter(c))
endfunction
function RegisterPlayerUnitEventForPlayer takes playerunitevent p, code c, player pl returns nothing
local integer i = 260 + 16 * GetHandleId(p) + GetPlayerId(pl)
if t[i] == null then
set t[i] = CreateTrigger()
call TriggerRegisterPlayerUnitEvent(t[i], pl, p, null)
endif
call TriggerAddCondition(t[i], Filter(c))
endfunction
function GetPlayerUnitEventTrigger takes playerunitevent p returns trigger
return t[GetHandleId(p)]
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library Table /* made by Bribe, special thanks to Vexorian & Nestharus, version 3.1.0.1
One map, one hashtable. Welcome to NewTable 3.1
This library was originally called NewTable so it didn't conflict with
the API of Table by Vexorian. However, the damage is done and it's too
late to change the library name now. To help with damage control, I
have provided an extension library called TableBC, which bridges all
the functionality of Vexorian's Table except for 2-D string arrays &
the ".flush(integer)" method. I use ".flush()" to flush a child hash-
table, because I wanted the API in NewTable to reflect the API of real
hashtables (I thought this would be more intuitive).
API
------------
struct Table
| static method create takes nothing returns Table
| create a new Table
|
| method destroy takes nothing returns nothing
| destroy it
|
| method flush takes nothing returns nothing
| flush all stored values inside of it
|
| method remove takes integer key returns nothing
| remove the value at index "key"
|
| method operator []= takes integer key, $TYPE$ value returns nothing
| assign "value" to index "key"
|
| method operator [] takes integer key returns $TYPE$
| load the value at index "key"
|
| method has takes integer key returns boolean
| whether or not the key was assigned
|
----------------
struct TableArray
| static method operator [] takes integer array_size returns TableArray
| create a new array of Tables of size "array_size"
|
| method destroy takes nothing returns nothing
| destroy it
|
| method flush takes nothing returns nothing
| flush and destroy it
|
| method operator size takes nothing returns integer
| returns the size of the TableArray
|
| method operator [] takes integer key returns Table
| returns a Table accessible exclusively to index "key"
*/
globals
private integer less = 0 //Index generation for TableArrays (below 0).
private integer more = 8190 //Index generation for Tables.
//Configure it if you use more than 8190 "key" variables in your map (this will never happen though).
private hashtable ht = InitHashtable()
private key sizeK
private key listK
endglobals
private struct dex extends array
static method operator size takes nothing returns Table
return sizeK
endmethod
static method operator list takes nothing returns Table
return listK
endmethod
endstruct
private struct handles extends array
method has takes integer key returns boolean
return HaveSavedHandle(ht, this, key)
endmethod
method remove takes integer key returns nothing
call RemoveSavedHandle(ht, this, key)
endmethod
endstruct
private struct agents extends array
method operator []= takes integer key, agent value returns nothing
call SaveAgentHandle(ht, this, key, value)
endmethod
endstruct
//! textmacro NEW_ARRAY_BASIC takes SUPER, FUNC, TYPE
private struct $TYPE$s extends array
method operator [] takes integer key returns $TYPE$
return Load$FUNC$(ht, this, key)
endmethod
method operator []= takes integer key, $TYPE$ value returns nothing
call Save$FUNC$(ht, this, key, value)
endmethod
method has takes integer key returns boolean
return HaveSaved$SUPER$(ht, this, key)
endmethod
method remove takes integer key returns nothing
call RemoveSaved$SUPER$(ht, this, key)
endmethod
endstruct
private module $TYPE$m
method operator $TYPE$ takes nothing returns $TYPE$s
return this
endmethod
endmodule
//! endtextmacro
//! textmacro NEW_ARRAY takes FUNC, TYPE
private struct $TYPE$s extends array
method operator [] takes integer key returns $TYPE$
return Load$FUNC$Handle(ht, this, key)
endmethod
method operator []= takes integer key, $TYPE$ value returns nothing
call Save$FUNC$Handle(ht, this, key, value)
endmethod
endstruct
private module $TYPE$m
method operator $TYPE$ takes nothing returns $TYPE$s
return this
endmethod
endmodule
//! endtextmacro
//Run these textmacros to include the entire hashtable API as wrappers.
//Don't be intimidated by the number of macros - Vexorian's map optimizer is
//supposed to kill functions which inline (all of these functions inline).
//! runtextmacro NEW_ARRAY_BASIC("Real", "Real", "real")
//! runtextmacro NEW_ARRAY_BASIC("Boolean", "Boolean", "boolean")
//! runtextmacro NEW_ARRAY_BASIC("String", "Str", "string")
//! runtextmacro NEW_ARRAY("Player", "player")
//! runtextmacro NEW_ARRAY("Widget", "widget")
//! runtextmacro NEW_ARRAY("Destructable", "destructable")
//! runtextmacro NEW_ARRAY("Item", "item")
//! runtextmacro NEW_ARRAY("Unit", "unit")
//! runtextmacro NEW_ARRAY("Ability", "ability")
//! runtextmacro NEW_ARRAY("Timer", "timer")
//! runtextmacro NEW_ARRAY("Trigger", "trigger")
//! runtextmacro NEW_ARRAY("TriggerCondition", "triggercondition")
//! runtextmacro NEW_ARRAY("TriggerAction", "triggeraction")
//! runtextmacro NEW_ARRAY("TriggerEvent", "event")
//! runtextmacro NEW_ARRAY("Force", "force")
//! runtextmacro NEW_ARRAY("Group", "group")
//! runtextmacro NEW_ARRAY("Location", "location")
//! runtextmacro NEW_ARRAY("Rect", "rect")
//! runtextmacro NEW_ARRAY("BooleanExpr", "boolexpr")
//! runtextmacro NEW_ARRAY("Sound", "sound")
//! runtextmacro NEW_ARRAY("Effect", "effect")
//! runtextmacro NEW_ARRAY("UnitPool", "unitpool")
//! runtextmacro NEW_ARRAY("ItemPool", "itempool")
//! runtextmacro NEW_ARRAY("Quest", "quest")
//! runtextmacro NEW_ARRAY("QuestItem", "questitem")
//! runtextmacro NEW_ARRAY("DefeatCondition", "defeatcondition")
//! runtextmacro NEW_ARRAY("TimerDialog", "timerdialog")
//! runtextmacro NEW_ARRAY("Leaderboard", "leaderboard")
//! runtextmacro NEW_ARRAY("Multiboard", "multiboard")
//! runtextmacro NEW_ARRAY("MultiboardItem", "multiboarditem")
//! runtextmacro NEW_ARRAY("Trackable", "trackable")
//! runtextmacro NEW_ARRAY("Dialog", "dialog")
//! runtextmacro NEW_ARRAY("Button", "button")
//! runtextmacro NEW_ARRAY("TextTag", "texttag")
//! runtextmacro NEW_ARRAY("Lightning", "lightning")
//! runtextmacro NEW_ARRAY("Image", "image")
//! runtextmacro NEW_ARRAY("Ubersplat", "ubersplat")
//! runtextmacro NEW_ARRAY("Region", "region")
//! runtextmacro NEW_ARRAY("FogState", "fogstate")
//! runtextmacro NEW_ARRAY("FogModifier", "fogmodifier")
//! runtextmacro NEW_ARRAY("Hashtable", "hashtable")
struct Table extends array
// Implement modules for intuitive syntax (tb.handle; tb.unit; etc.)
implement realm
implement booleanm
implement stringm
implement playerm
implement widgetm
implement destructablem
implement itemm
implement unitm
implement abilitym
implement timerm
implement triggerm
implement triggerconditionm
implement triggeractionm
implement eventm
implement forcem
implement groupm
implement locationm
implement rectm
implement boolexprm
implement soundm
implement effectm
implement unitpoolm
implement itempoolm
implement questm
implement questitemm
implement defeatconditionm
implement timerdialogm
implement leaderboardm
implement multiboardm
implement multiboarditemm
implement trackablem
implement dialogm
implement buttonm
implement texttagm
implement lightningm
implement imagem
implement ubersplatm
implement regionm
implement fogstatem
implement fogmodifierm
implement hashtablem
method operator handle takes nothing returns handles
return this
endmethod
method operator agent takes nothing returns agents
return this
endmethod
//set this = tb[GetSpellAbilityId()]
method operator [] takes integer key returns Table
return LoadInteger(ht, this, key)
endmethod
//set tb[389034] = 8192
method operator []= takes integer key, Table tb returns nothing
call SaveInteger(ht, this, key, tb)
endmethod
//set b = tb.has(2493223)
method has takes integer key returns boolean
return HaveSavedInteger(ht, this, key)
endmethod
//call tb.remove(294080)
method remove takes integer key returns nothing
call RemoveSavedInteger(ht, this, key)
endmethod
//Remove all data from a Table instance
method flush takes nothing returns nothing
call FlushChildHashtable(ht, this)
endmethod
//local Table tb = Table.create()
static method create takes nothing returns Table
local Table this = dex.list[0]
if this == 0 then
set this = more + 1
set more = this
else
set dex.list[0] = dex.list[this]
call dex.list.remove(this) //Clear hashed memory
endif
debug set dex.list[this] = -1
return this
endmethod
// Removes all data from a Table instance and recycles its index.
//
// call tb.destroy()
//
method destroy takes nothing returns nothing
debug if dex.list[this] != -1 then
debug call BJDebugMsg("Table Error: Tried to double-free instance: " + I2S(this))
debug return
debug endif
call this.flush()
set dex.list[this] = dex.list[0]
set dex.list[0] = this
endmethod
//! runtextmacro optional TABLE_BC_METHODS()
endstruct
//! runtextmacro optional TABLE_BC_STRUCTS()
struct TableArray extends array
//Returns a new TableArray to do your bidding. Simply use:
//
// local TableArray ta = TableArray[array_size]
//
static method operator [] takes integer array_size returns TableArray
local Table tb = dex.size[array_size] //Get the unique recycle list for this array size
local TableArray this = tb[0] //The last-destroyed TableArray that had this array size
debug if array_size <= 0 then
debug call BJDebugMsg("TypeError: Invalid specified TableArray size: " + I2S(array_size))
debug return 0
debug endif
if this == 0 then
set this = less - array_size
set less = this
else
set tb[0] = tb[this] //Set the last destroyed to the last-last destroyed
call tb.remove(this) //Clear hashed memory
endif
set dex.size[this] = array_size //This remembers the array size
return this
endmethod
//Returns the size of the TableArray
method operator size takes nothing returns integer
return dex.size[this]
endmethod
//This magic method enables two-dimensional[array][syntax] for Tables,
//similar to the two-dimensional utility provided by hashtables them-
//selves.
//
//ta[integer a].unit[integer b] = unit u
//ta[integer a][integer c] = integer d
//
//Inline-friendly when not running in debug mode
//
method operator [] takes integer key returns Table
static if DEBUG_MODE then
local integer i = this.size
if i == 0 then
call BJDebugMsg("IndexError: Tried to get key from invalid TableArray instance: " + I2S(this))
return 0
elseif key < 0 or key >= i then
call BJDebugMsg("IndexError: Tried to get key [" + I2S(key) + "] from outside TableArray bounds: " + I2S(i))
return 0
endif
endif
return this + key
endmethod
//Destroys a TableArray without flushing it; I assume you call .flush()
//if you want it flushed too. This is a public method so that you don't
//have to loop through all TableArray indices to flush them if you don't
//need to (ie. if you were flushing all child-keys as you used them).
//
method destroy takes nothing returns nothing
local Table tb = dex.size[this.size]
debug if this.size == 0 then
debug call BJDebugMsg("TypeError: Tried to destroy an invalid TableArray: " + I2S(this))
debug return
debug endif
if tb == 0 then
//Create a Table to index recycled instances with their array size
set tb = Table.create()
set dex.size[this.size] = tb
endif
call dex.size.remove(this) //Clear the array size from hash memory
set tb[this] = tb[0]
set tb[0] = this
endmethod
private static Table tempTable
private static integer tempEnd
//Avoids hitting the op limit
private static method clean takes nothing returns nothing
local Table tb = .tempTable
local integer end = tb + 0x1000
if end < .tempEnd then
set .tempTable = end
call ForForce(bj_FORCE_PLAYER[0], function thistype.clean)
else
set end = .tempEnd
endif
loop
call tb.flush()
set tb = tb + 1
exitwhen tb == end
endloop
endmethod
//Flushes the TableArray and also destroys it. Doesn't get any more
//similar to the FlushParentHashtable native than this.
//
method flush takes nothing returns nothing
debug if this.size == 0 then
debug call BJDebugMsg("TypeError: Tried to flush an invalid TableArray instance: " + I2S(this))
debug return
debug endif
set .tempTable = this
set .tempEnd = this + this.size
call ForForce(bj_FORCE_PLAYER[0], function thistype.clean)
call this.destroy()
endmethod
endstruct
endlibrary
//TESH.scrollpos=90
//TESH.alwaysfold=0
library UnitIndexer /* v4.0.2.6
*************************************************************************************
*
* Assigns unique indexes to units via unit user data.
*
*************************************************************************************
*
* */uses/*
*
* */ WorldBounds /* hiveworkshop.com/forums/jass-functions-413/snippet-worldbounds-180494/
* */ Event /* hiveworkshop.com/forums/submissions-414/snippet-event-186555/
*
************************************************************************************
*
* Functions
*
* function RegisterUnitIndexEvent takes boolexpr codeToRegister, Event unitIndexEvent returns nothing
* function TriggerRegisterUnitIndexEvent takes trigger triggerToRegister, Event unitIndexEvent returns nothing
*
* function GetUnitById takes integer index returns unit
* - Returns unit given a unit index
* function GetUnitId takes unit u returns integer
* - Returns unit index given a unit
*
* function IsUnitIndexed takes unit u returns boolean
* function IsUnitDeindexing takes unit u returns boolean
*
* function GetIndexedUnitId takes nothing returns integer
* function GetIndexedUnit takes nothing returns unit
*
************************************************************************************
*
* module UnitIndexStructMethods
* static method operator [] takes unit u returns thistype
* - Return GetUnitUserData(u)
*
* readonly unit unit
* - The indexed unit of the struct
*
************************************************************************************
*
* module UnitIndexStruct extends UnitIndexStructMethods
*
* - A pseudo module interface that runs a set of methods if they exist and provides
* - a few fields and operators. Runs on static ifs to minimize code.
*
* readonly boolean allocated
* - Is unit allocated for the struct
*
* Interface:
*
* - These methods don't have to exist. If they don't exist, the code
* - that calls them won't even be in the module.
*
* private method index takes nothing returns nothing
* - called when a unit is indexed and passes the filter.
* -
* - thistype this: Unit's index
* private method deindex takes nothing returns nothing
* - called when a unit is deindexed and is allocated for struct
* -
* - thistype this: Unit's index
* private static method filter takes unit unitToIndex returns boolean
* - Determines whether or not to allocate struct for unit
* -
* - unit unitToIndex: Unit being filtered
*
************************************************************************************
*
* struct UnitIndexer extends array
*
* - Controls the unit indexer system.
*
* static constant Event UnitIndexer.INDEX
* static constant Event UnitIndexer.DEINDEX
* - Don't register functions and triggers directly to the events. Register them via
* - RegisterUnitIndexEvent and TriggerRegisterUnitIndexEvent.
*
* static boolean enabled
* - Enables and disables unit indexing. Useful for filtering out dummy units.
*
************************************************************************************
*
* struct UnitIndex extends UnitIndexStructMethods
*
* - Constrols specific unit indexes.
*
* method lock takes nothing returns nothing
* - Locks an index. When an index is locked, it will not be recycled
* - when the unit is deindexed until all locks are removed. Deindex
* - events still fire at the appropriate times, the index just doesn't
* - get thrown into the recycler.
* method unlock takes nothing returns nothing
* - Unlocks an index.
*
************************************************************************************/
globals
private constant integer ABILITIES_UNIT_INDEXER = 'A@!!'
private trigger q=CreateTrigger()
private trigger l=CreateTrigger()
private unit array e
private integer r=0
private integer y=0
private integer o=0
private boolean a=false
private integer array n
private integer array p
private integer array lc
endglobals
function GetIndexedUnitId takes nothing returns integer
return o
endfunction
function GetIndexedUnit takes nothing returns unit
return e[o]
endfunction
//! runtextmacro optional UNIT_LIST_LIB()
private struct PreLoader extends array
public static method run takes nothing returns nothing
call DestroyTimer(GetExpiredTimer())
set a=true
endmethod
public static method eval takes trigger t returns nothing
local integer f=n[0]
local integer d=o
loop
exitwhen 0==f
if (IsTriggerEnabled(t)) then
set o=f
if (TriggerEvaluate(t)) then
call TriggerExecute(t)
endif
else
exitwhen true
endif
set f=n[f]
endloop
set o=d
endmethod
public static method evalb takes boolexpr c returns nothing
local trigger t=CreateTrigger()
local thistype f=n[0]
local integer d=o
call TriggerAddCondition(t,c)
loop
exitwhen 0==f
set o=f
call TriggerEvaluate(t)
set f=n[f]
endloop
call DestroyTrigger(t)
set t=null
set o=d
endmethod
endstruct
//! runtextmacro optional UNIT_EVENT_MACRO()
private module UnitIndexerInit
private static method onInit takes nothing returns nothing
local integer i=15
local boolexpr bc=Condition(function thistype.onLeave)
local boolexpr bc2=Condition(function thistype.onEnter)
local group g=CreateGroup()
local player p
set INDEX=CreateEvent()
set DEINDEX=CreateEvent()
call TriggerRegisterEnterRegion(q,WorldBounds.worldRegion,bc2)
loop
set p=Player(i)
call TriggerRegisterPlayerUnitEvent(l,p,EVENT_PLAYER_UNIT_ISSUED_ORDER,bc)
call SetPlayerAbilityAvailable(p,ABILITIES_UNIT_INDEXER,false)
call GroupEnumUnitsOfPlayer(g,p,bc2)
exitwhen 0==i
set i=i-1
endloop
call DestroyGroup(g)
set bc=null
set g=null
set bc2=null
set p=null
call TimerStart(CreateTimer(),0,false,function PreLoader.run)
endmethod
endmodule
struct UnitIndex extends array
method lock takes nothing returns nothing
debug if (null!=e[this]) then
set lc[this]=lc[this]+1
debug else
debug call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"UNIT INDEXER ERROR: ATTEMPT TO LOCK NULL INDEX")
debug endif
endmethod
method unlock takes nothing returns nothing
debug if (0<lc[this]) then
set lc[this]=lc[this]-1
if (0==lc[this] and null==e[this]) then
set n[this]=y
set y=this
endif
debug else
debug call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"UNIT INDEXER ERROR: ATTEMPT TO UNLOCK UNLOCKED INDEX")
debug endif
endmethod
method operator unit takes nothing returns unit
return e[this]
endmethod
static method operator [] takes unit whichUnit returns thistype
return GetUnitUserData(whichUnit)
endmethod
endstruct
struct UnitIndexer extends array
readonly static Event INDEX
readonly static Event DEINDEX
static boolean enabled=true
private static method onEnter takes nothing returns boolean
local unit Q=GetFilterUnit()
local integer i
local integer d=o
if (enabled and Q!=e[GetUnitUserData(Q)]) then
if (0==y) then
set r=r+1
set i=r
else
set i=y
set y=n[y]
endif
call UnitAddAbility(Q,ABILITIES_UNIT_INDEXER)
call UnitMakeAbilityPermanent(Q,true,ABILITIES_UNIT_INDEXER)
call SetUnitUserData(Q,i)
set e[i]=Q
static if not LIBRARY_UnitList then
if (not a)then
set p[i]=p[0]
set n[p[0]]=i
set n[i]=0
set p[0]=i
endif
else
set p[i]=p[0]
set n[p[0]]=i
set n[i]=0
set p[0]=i
call GroupAddUnit(g,e[i])
endif
set o=i
call FireEvent(INDEX)
set o=d
endif
set Q=null
return false
endmethod
private static method onLeave takes nothing returns boolean
static if LIBRARY_UnitEvent then
implement optional UnitEventModule
else
local unit u=GetFilterUnit()
local integer i=GetUnitUserData(u)
local integer d=o
if (0==GetUnitAbilityLevel(u,ABILITIES_UNIT_INDEXER) and u==e[i]) then
static if not LIBRARY_UnitList then
if (not a)then
set n[p[i]]=n[i]
set p[n[i]]=p[i]
endif
else
set n[p[i]]=n[i]
set p[n[i]]=p[i]
call GroupRemoveUnit(g,e[i])
endif
set o=i
call FireEvent(DEINDEX)
set o=d
if (0==lc[i]) then
set n[i]=y
set y=i
endif
set e[i]=null
endif
set u=null
endif
return false
endmethod
implement UnitIndexerInit
endstruct
//! runtextmacro optional UNIT_EVENT_MACRO_2()
function RegisterUnitIndexEvent takes boolexpr c,integer ev returns nothing
call RegisterEvent(c, ev)
if (not a and ev==UnitIndexer.INDEX and 0!=n[0]) then
call PreLoader.evalb(c)
endif
endfunction
function TriggerRegisterUnitIndexEvent takes trigger t,integer ev returns nothing
call TriggerRegisterEvent(t,ev)
if (not a and ev == UnitIndexer.INDEX and 0!=n[0]) then
call PreLoader.eval(t)
endif
endfunction
function GetUnitById takes integer W returns unit
return e[W]
endfunction
function GetUnitId takes unit u returns integer
return GetUnitUserData(u)
endfunction
function IsUnitIndexed takes unit u returns boolean
return u==e[GetUnitUserData(u)]
endfunction
function IsUnitDeindexing takes unit u returns boolean
return IsUnitIndexed(u) and 0==GetUnitAbilityLevel(u,ABILITIES_UNIT_INDEXER)
endfunction
module UnitIndexStructMethods
static method operator [] takes unit u returns thistype
return GetUnitUserData(u)
endmethod
method operator unit takes nothing returns unit
return e[this]
endmethod
endmodule
module UnitIndexStruct
implement UnitIndexStructMethods
static if thistype.filter.exists then
static if thistype.index.exists then
static if thistype.deindex.exists then
readonly boolean allocated
else
method operator allocated takes nothing returns boolean
return filter(e[this])
endmethod
endif
else
method operator allocated takes nothing returns boolean
return filter(e[this])
endmethod
endif
elseif (thistype.index.exists) then
static if thistype.deindex.exists then
readonly boolean allocated
else
method operator allocated takes nothing returns boolean
return this==GetUnitUserData(e[this])
endmethod
endif
else
method operator allocated takes nothing returns boolean
return this==GetUnitUserData(e[this])
endmethod
endif
static if thistype.index.exists then
private static method onIndexEvent takes nothing returns boolean
static if thistype.filter.exists then
if (filter(e[o])) then
static if thistype.deindex.exists then
set thistype(o).allocated=true
endif
call thistype(o).index()
endif
else
static if thistype.deindex.exists then
set thistype(o).allocated=true
endif
call thistype(o).index()
endif
return false
endmethod
endif
static if thistype.deindex.exists then
private static method onDeindexEvent takes nothing returns boolean
static if thistype.filter.exists then
static if thistype.index.exists then
if (thistype(o).allocated) then
set thistype(o).allocated=false
call thistype(o).deindex()
endif
else
if (filter(e[o])) then
call thistype(o).deindex()
endif
endif
else
static if thistype.index.exists then
set thistype(o).allocated=false
endif
call thistype(o).deindex()
endif
return false
endmethod
endif
static if thistype.index.exists then
static if thistype.deindex.exists then
private static method onInit takes nothing returns nothing
call RegisterUnitIndexEvent(Condition(function thistype.onIndexEvent),UnitIndexer.INDEX)
call RegisterUnitIndexEvent(Condition(function thistype.onDeindexEvent),UnitIndexer.DEINDEX)
endmethod
else
private static method onInit takes nothing returns nothing
call RegisterUnitIndexEvent(Condition(function thistype.onIndexEvent),UnitIndexer.INDEX)
endmethod
endif
elseif thistype.deindex.exists then
private static method onInit takes nothing returns nothing
call RegisterUnitIndexEvent(Condition(function thistype.onDeindexEvent),UnitIndexer.DEINDEX)
endmethod
endif
endmodule
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library WorldBounds /* v2.0.0.0
************************************************************************************
*
* struct WorldBounds extends array
* readonly static integer maxX
* readonly static integer maxY
* readonly static integer minX
* readonly static integer minY
* readonly static integer centerX
* readonly static integer centerY
* readonly static rect world
* readonly static region worldRegion
*
************************************************************************************/
private module WorldBoundInit
private static method onInit takes nothing returns nothing
set world=GetWorldBounds()
set maxX=R2I(GetRectMaxX(world))
set maxY=R2I(GetRectMaxY(world))
set minX=R2I(GetRectMinX(world))
set minY=R2I(GetRectMinY(world))
set centerX=R2I((maxX+minX)/2)
set centerY=R2I((minY+maxY)/2)
set worldRegion=CreateRegion()
call RegionAddRect(worldRegion,world)
endmethod
endmodule
struct WorldBounds extends array
readonly static integer maxX
readonly static integer maxY
readonly static integer minX
readonly static integer minY
readonly static integer centerX
readonly static integer centerY
readonly static rect world
readonly static region worldRegion
implement WorldBoundInit
endstruct
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library Event /* v2.0.0.1
************************************************************************************
*
* Functions
*
* function CreateEvent takes nothing returns integer
* function TriggerRegisterEvent takes trigger t, integer ev returns nothing
*
************************************************************************************
*
* struct Event extends array
*
* static method create takes nothing returns thistype
* method registerTrigger takes trigger t returns nothing
* method register takes boolexpr c returns nothing
* method fire takes nothing returns nothing
*
************************************************************************************/
globals
private real q=0
endglobals
struct Event extends array
private static integer w=0
private static trigger array e
static method create takes nothing returns thistype
set w=w+1
set e[w]=CreateTrigger()
return w
endmethod
method registerTrigger takes trigger t returns nothing
call TriggerRegisterVariableEvent(t,SCOPE_PRIVATE+"q",EQUAL,this)
endmethod
method register takes boolexpr c returns nothing
call TriggerAddCondition(e[this],c)
endmethod
method fire takes nothing returns nothing
set q=0
set q=this
call TriggerEvaluate(e[this])
endmethod
endstruct
function CreateEvent takes nothing returns Event
return Event.create()
endfunction
function TriggerRegisterEvent takes trigger t,Event ev returns nothing
call ev.registerTrigger(t)
endfunction
function RegisterEvent takes boolexpr c,Event ev returns nothing
call ev.register(c)
endfunction
function FireEvent takes Event ev returns nothing
call ev.fire()
endfunction
endlibrary
library TimerUtils initializer init
//*********************************************************************
//* TimerUtils (red+blue+orange flavors for 1.24b+) 2.0
//* ----------
//*
//* To implement it , create a custom text trigger called TimerUtils
//* and paste the contents of this script there.
//*
//* To copy from a map to another, copy the trigger holding this
//* library to your map.
//*
//* (requires vJass) More scripts: htt://www.wc3c.net
//*
//* For your timer needs:
//* * Attaching
//* * Recycling (with double-free protection)
//*
//* set t=NewTimer() : Get a timer (alternative to CreateTimer)
//* set t=NewTimerEx(x) : Get a timer (alternative to CreateTimer), call
//* Initialize timer data as x, instead of 0.
//*
//* ReleaseTimer(t) : Relese a timer (alt to DestroyTimer)
//* SetTimerData(t,2) : Attach value 2 to timer
//* GetTimerData(t) : Get the timer's value.
//* You can assume a timer's value is 0
//* after NewTimer.
//*
//* Multi-flavor:
//* Set USE_HASH_TABLE to true if you don't want to complicate your life.
//*
//* If you like speed and giberish try learning about the other flavors.
//*
//********************************************************************
//================================================================
globals
//How to tweak timer utils:
// USE_HASH_TABLE = true (new blue)
// * SAFEST
// * SLOWEST (though hash tables are kind of fast)
//
// USE_HASH_TABLE = false, USE_FLEXIBLE_OFFSET = true (orange)
// * kinda safe (except there is a limit in the number of timers)
// * ALMOST FAST
//
// USE_HASH_TABLE = false, USE_FLEXIBLE_OFFSET = false (red)
// * THE FASTEST (though is only faster than the previous method
// after using the optimizer on the map)
// * THE LEAST SAFE ( you may have to tweak OFSSET manually for it to
// work)
//
private constant boolean USE_HASH_TABLE = true
private constant boolean USE_FLEXIBLE_OFFSET = false
private constant integer OFFSET = 0x100000
private integer VOFFSET = OFFSET
//Timers to preload at map init:
private constant integer QUANTITY = 256
//Changing this to something big will allow you to keep recycling
// timers even when there are already AN INCREDIBLE AMOUNT of timers in
// the stack. But it will make things far slower so that's probably a bad idea...
private constant integer ARRAY_SIZE = 8190
endglobals
//==================================================================================================
globals
private integer array data[ARRAY_SIZE]
private hashtable ht
endglobals
//It is dependent on jasshelper's recent inlining optimization in order to perform correctly.
function SetTimerData takes timer t, integer value returns nothing
static if(USE_HASH_TABLE) then
// new blue
call SaveInteger(ht,0,GetHandleId(t), value)
elseif (USE_FLEXIBLE_OFFSET) then
// orange
static if (DEBUG_MODE) then
if(GetHandleId(t)-VOFFSET<0) then
call BJDebugMsg("SetTimerData: Wrong handle id, only use SetTimerData on timers created by NewTimer")
endif
endif
set data[GetHandleId(t)-VOFFSET]=value
else
// new red
static if (DEBUG_MODE) then
if(GetHandleId(t)-OFFSET<0) then
call BJDebugMsg("SetTimerData: Wrong handle id, only use SetTimerData on timers created by NewTimer")
endif
endif
set data[GetHandleId(t)-OFFSET]=value
endif
endfunction
function GetTimerData takes timer t returns integer
static if(USE_HASH_TABLE) then
// new blue
return LoadInteger(ht,0,GetHandleId(t) )
elseif (USE_FLEXIBLE_OFFSET) then
// orange
static if (DEBUG_MODE) then
if(GetHandleId(t)-VOFFSET<0) then
call BJDebugMsg("SetTimerData: Wrong handle id, only use SetTimerData on timers created by NewTimer")
endif
endif
return data[GetHandleId(t)-VOFFSET]
else
// new red
static if (DEBUG_MODE) then
if(GetHandleId(t)-OFFSET<0) then
call BJDebugMsg("SetTimerData: Wrong handle id, only use SetTimerData on timers created by NewTimer")
endif
endif
return data[GetHandleId(t)-OFFSET]
endif
endfunction
//==========================================================================================
globals
private timer array tT[ARRAY_SIZE]
private integer tN = 0
private constant integer HELD=0x28829022
//use a totally random number here, the more improbable someone uses it, the better.
private boolean didinit = false
endglobals
private keyword init
//==========================================================================================
// I needed to decide between duplicating code ignoring the "Once and only once" rule
// and using the ugly textmacros. I guess textmacros won.
//
//! textmacro TIMERUTIS_PRIVATE_NewTimerCommon takes VALUE
// On second thought, no.
//! endtextmacro
function NewTimerEx takes integer value returns timer
if (tN==0) then
if (not didinit) then
//This extra if shouldn't represent a major performance drawback
//because QUANTITY rule is not supposed to be broken every day.
call init.evaluate()
set tN = tN - 1
else
//If this happens then the QUANTITY rule has already been broken, try to fix the
// issue, else fail.
debug call BJDebugMsg("NewTimer: Warning, Exceeding TimerUtils_QUANTITY, make sure all timers are getting recycled correctly")
set tT[0]=CreateTimer()
static if( not USE_HASH_TABLE) then
debug call BJDebugMsg("In case of errors, please increase it accordingly, or set TimerUtils_USE_HASH_TABLE to true")
static if( USE_FLEXIBLE_OFFSET) then
if (GetHandleId(tT[0])-VOFFSET<0) or (GetHandleId(tT[0])-VOFFSET>=ARRAY_SIZE) then
//all right, couldn't fix it
call BJDebugMsg("NewTimer: Unable to allocate a timer, you should probably set TimerUtils_USE_HASH_TABLE to true or fix timer leaks.")
return null
endif
else
if (GetHandleId(tT[0])-OFFSET<0) or (GetHandleId(tT[0])-OFFSET>=ARRAY_SIZE) then
//all right, couldn't fix it
call BJDebugMsg("NewTimer: Unable to allocate a timer, you should probably set TimerUtils_USE_HASH_TABLE to true or fix timer leaks.")
return null
endif
endif
endif
endif
else
set tN=tN-1
endif
call SetTimerData(tT[tN],value)
return tT[tN]
endfunction
function NewTimer takes nothing returns timer
return NewTimerEx(0)
endfunction
//==========================================================================================
function ReleaseTimer takes timer t returns nothing
if(t==null) then
debug call BJDebugMsg("Warning: attempt to release a null timer")
return
endif
if (tN==ARRAY_SIZE) then
debug call BJDebugMsg("Warning: Timer stack is full, destroying timer!!")
//stack is full, the map already has much more troubles than the chance of bug
call DestroyTimer(t)
else
call PauseTimer(t)
if(GetTimerData(t)==HELD) then
debug call BJDebugMsg("Warning: ReleaseTimer: Double free!")
return
endif
call SetTimerData(t,HELD)
set tT[tN]=t
set tN=tN+1
endif
endfunction
private function init takes nothing returns nothing
local integer i=0
local integer o=-1
local boolean oops = false
if ( didinit ) then
return
else
set didinit = true
endif
static if( USE_HASH_TABLE ) then
set ht = InitHashtable()
loop
exitwhen(i==QUANTITY)
set tT[i]=CreateTimer()
call SetTimerData(tT[i], HELD)
set i=i+1
endloop
set tN = QUANTITY
else
loop
set i=0
loop
exitwhen (i==QUANTITY)
set tT[i] = CreateTimer()
if(i==0) then
set VOFFSET = GetHandleId(tT[i])
static if(USE_FLEXIBLE_OFFSET) then
set o=VOFFSET
else
set o=OFFSET
endif
endif
if (GetHandleId(tT[i])-o>=ARRAY_SIZE) then
exitwhen true
endif
if (GetHandleId(tT[i])-o>=0) then
set i=i+1
endif
endloop
set tN = i
exitwhen(tN == QUANTITY)
set oops = true
exitwhen not USE_FLEXIBLE_OFFSET
debug call BJDebugMsg("TimerUtils_init: Failed a initialization attempt, will try again")
endloop
if(oops) then
static if ( USE_FLEXIBLE_OFFSET) then
debug call BJDebugMsg("The problem has been fixed.")
//If this message doesn't appear then there is so much
//handle id fragmentation that it was impossible to preload
//so many timers and the thread crashed! Therefore this
//debug message is useful.
elseif(DEBUG_MODE) then
call BJDebugMsg("There were problems and the new timer limit is "+I2S(i))
call BJDebugMsg("This is a rare ocurrence, if the timer limit is too low:")
call BJDebugMsg("a) Change USE_FLEXIBLE_OFFSET to true (reduces performance a little)")
call BJDebugMsg("b) or try changing OFFSET to "+I2S(VOFFSET) )
endif
endif
endif
endfunction
endlibrary
library TimerUtilsEx requires optional Table
/*************************************************
*
* TimerUtilsEx
* v2.1.0.2
* By Vexorian, Bribe & Magtheridon96
*
* Original version by Vexorian.
*
* Flavors:
* Hashtable:
* - RAM: Minimal
* - TimerData: Slow
*
* Array:
* - RAM: Maximal
* - TimerData: Fast
*
* All the functions have O(1) complexity.
* The Array version is the fastest, but the hashtable
* version is the safest. The Array version is still
* quite safe though, and I would recommend using it.
* The system is much slower in debug mode.
*
* Optional Requirement:
* - Table by Bribe
* - hiveworkshop.com/forums/showthread.php?t=188084
*
* API:
* ----
* - function NewTimer takes nothing returns timer
* - Returns a new timer from the stack.
* - function NewTimerEx takes integer i returns timer
* - Returns a new timer from the stack and attaches a value to it.
* - function ReleaseTimer takes timer t returns integer
* - Throws a timer back into the stack. Also returns timer data.
* - function SetTimerData takes timer t, integer value returns nothing
* - Attaches a value to a timer.
* - function GetTimerData takes timer t returns integer
* - Returns the attached value.
*
*************************************************/
// Configuration
globals
// Use hashtable, or fast array?
private constant boolean USE_HASH = false
// Max Number of Timers Held in Stack
private constant integer QUANTITY = 256
endglobals
globals
private timer array tT
private integer tN = 0
endglobals
private module Init
private static method onInit takes nothing returns nothing
static if not USE_HASH then
local integer i = QUANTITY
loop
set i = i - 1
set tT[i] = CreateTimer()
exitwhen i == 0
endloop
set tN = QUANTITY
elseif LIBRARY_Table then
set tb = Table.create()
endif
endmethod
endmodule
// JassHelper doesn't support static ifs for globals.
private struct Data extends array
static if not USE_HASH then
static integer array data
endif
static if LIBRARY_Table then
static Table tb = 0
else
static hashtable ht = InitHashtable()
endif
implement Init
endstruct
// Double free protection
private function ValidTimer takes integer i returns boolean
static if LIBRARY_Table then
return Data.tb.boolean[-i]
else
return LoadBoolean(Data.ht, i, 1)
endif
endfunction
private function Get takes integer id returns integer
debug if not ValidTimer(id) then
debug call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "[TimerUtils]Error: Tried to get data from invalid timer.")
debug endif
static if USE_HASH then
static if LIBRARY_Table then
return Data.tb[id]
else
return LoadInteger(Data.ht, id, 0)
endif
else
return Data.data[id - 0x100000]
endif
endfunction
private function Set takes integer id, integer data returns nothing
debug if not ValidTimer(id) then
debug call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "[TimerUtils]Error: Tried to attach data to invalid timer.")
debug endif
static if USE_HASH then
static if LIBRARY_Table then
set Data.tb[id] = data
else
call SaveInteger(Data.ht, id, 0, data)
endif
else
set Data.data[id - 0x100000] = data
endif
endfunction
function SetTimerData takes timer t, integer data returns nothing
call Set(GetHandleId(t), data)
endfunction
function GetTimerData takes timer t returns integer
return Get(GetHandleId(t))
endfunction
function NewTimerEx takes integer data returns timer
local integer id
if tN == 0 then
static if USE_HASH then
set tT[0] = CreateTimer()
else
debug call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "[TimerUtils]Error: No Timers In The Stack! You must increase 'QUANTITY'")
return null
endif
else
set tN = tN - 1
endif
set id = GetHandleId(tT[tN])
static if LIBRARY_Table then
set Data.tb.boolean[-id] = true
else
call SaveBoolean(Data.ht, id, 1, true)
endif
call Set(id, data)
return tT[tN]
endfunction
function NewTimer takes nothing returns timer
return NewTimerEx(0)
endfunction
function ReleaseTimer takes timer t returns integer
local integer id = GetHandleId(t)
local integer data = 0
// Pause the timer just in case.
call PauseTimer(t)
// Make sure the timer is valid.
if ValidTimer(id) then
// Get the timer's data.
set data = Get(id)
// Unmark handle id as a valid timer.
static if LIBRARY_Table then
call Data.tb.boolean.remove(-id)
else
call RemoveSavedBoolean(Data.ht, id, 1)
endif
//If it's not run in USE_HASH mode, this next block is useless.
static if USE_HASH then
//At least clear hash memory while it's in the recycle stack.
static if LIBRARY_Table then
call Data.tb.remove(id)
else
call RemoveSavedInteger(Data.ht, id, 0)
endif
// If the recycle limit is reached
if tN == QUANTITY then
// then we destroy the timer.
call DestroyTimer(t)
return data
endif
endif
//Recycle the timer.
set tT[tN] = t
set tN = tN + 1
//Tried to pass a bad timer.
debug else
debug call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "[TimerUtils]Error: Tried to release non-active timer!")
endif
//Return Timer Data.
return data
endfunction
endlibrary
library TimerUtils requires TimerUtilsEx
endlibrary
library SimError initializer init
//**************************************************************************************************
//*
//* SimError by Vexorian
//*
//* Mimic an interface error message
//* call SimError(ForPlayer, msg)
//* ForPlayer : The player to show the error
//* msg : The error
//*
//* To implement this function, copy this trigger and paste it in your map.
//* Unless of course you are actually reading the library from wc3c's scripts section, then just
//* paste the contents into some custom text trigger in your map.
//*
//**************************************************************************************************
//==================================================================================================
globals
private sound error
endglobals
//====================================================================================================
function SimError takes player ForPlayer, string msg returns nothing
set msg="\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+msg+"|r"
if (GetLocalPlayer() == ForPlayer) then
call ClearTextMessages()
call DisplayTimedTextToPlayer( ForPlayer, 0.52, 0.96, 2.00, msg )
call StartSound( error )
endif
endfunction
private function init takes nothing returns nothing
set error=CreateSoundFromLabel("InterfaceError",false,false,false,10,10)
//call StartSound( error ) //apparently the bug in which you play a sound for the first time
//and it doesn't work is not there anymore in patch 1.22
endfunction
endlibrary
/*****************************************************************************
*
* Get Closest Widget
* by Spinnaker v2.0.0.0
*
* Special thanks to Troll-Brain
*
******************************************************************************
*
* This snippet contains several functions which returns closest
* widget to given coordinates and passed filter.
*
******************************************************************************
*
* Requirements:
* Snippet optionaly requires IsDestructableTree,
* enabling user to choose if enumerated should be all destructables
* or only tree-type ones, therefore gives option to get closest tree.
*
******************************************************************************
*
* Important:
* Performance drop depends on amount of objects currently on the map
* Snippet functions are designed to reduce the search time as much as
* posible, although it's recommended to use non specific functions
* wisely, especialy if your map contains large numbers of widgets.
*
******************************************************************************
*
* Functions:
* function GetClosestItem takes real x, real y, boolexpr filter returns item
* - Gets single item, nearest passed coordinates
* function GetClosestItemInRange takes real x, real y, real radius, boolexpr filter returns item
* - Returns single item, closest to coordinates in given range
*
* function GetClosestDestructable takes real x, real y, boolean treeOnly, boolexpr filter returns destructable
* - Gets single destructable, nearest passed coordinates
* function GetClosestDestructableInRange takes real x, real y, real radius, boolean treeOnly, boolexpr filter returns destructable
* - Retrieves single destructable, closest to coordinates in given range
*
* function GetClosestUnit takes real x, real y, boolexpr filter returns unit
* - Returns closest unit matching specific filter
* function GetClosestUnitInRange takes real x, real y, real radius, boolexpr filter returns unit
* - Gets nearest unit in range matching specific filter
* function GetClosestUnitInGroup takes real x, real y, group g returns unit
* - Retrieves closest unit in given group
*
* function GetClosestNUnitsInRange takes real x, real y, real radius, integer n, group g, boolexpr filter returns nothing
* - Returns up to N nearest units in range of passed coordinates
* function GetClosestNUnitsInGroup takes real x, real y, integer n, group sourceGroup, group destGroup returns nothing
* - Retrieves up to N closest units in passed group
*
*****************************************************************************/
library GetClosestWidget uses optional IsDestructableTree
private keyword Init
globals
private unit array Q
private real array V
private integer C=0
endglobals
struct ClosestWidget extends array
readonly static destructable cDest=null
readonly static item cItem=null
readonly static real distance=0
readonly static real cX=0
readonly static real cY=0
readonly static unit cUnit=null
static boolean cTree=false
static rect initRect=null
static method resetData takes real x, real y returns nothing
set cDest=null
set distance=100000
set cItem=null
set cUnit=null
set cX=x
set cY=y
endmethod
static method enumItems takes nothing returns nothing
local item i=GetEnumItem()
local real dx=GetWidgetX(i)-cX
local real dy=GetWidgetY(i)-cY
set dx = (dx*dx+dy*dy)/10000.
if dx<distance then
set cItem=i
set distance=dx
endif
set i =null
endmethod
static method enumDestructables takes nothing returns nothing
local destructable d=GetEnumDestructable()
local real dx
local real dy
static if LIBRARY_IsDestructableTree then
if cTree and not IsDestructableTree(d) then
return
endif
endif
set dx=GetWidgetX(d)-cX
set dy=GetWidgetY(d)-cY
set dx=(dx*dx+dy*dy)/10000.
if dx<distance then
set cDest=d
set distance=dx
endif
set d=null
endmethod
static method enumUnits takes nothing returns nothing
local unit u=GetEnumUnit()
local real dx=GetUnitX(u)-cX
local real dy=GetUnitY(u)-cY
set dx=(dx*dx+dy*dy)/10000.
if dx<distance then
set cUnit=u
set distance=dx
endif
set u=null
endmethod
static method sortUnits takes integer l, integer r returns nothing
local integer i=l
local integer j=r
local real v=V[(l+r)/2]
loop
loop
exitwhen V[i]>=v
set i=i+1
endloop
loop
exitwhen V[j]<=v
set j=j-1
endloop
if i<=j then
set V[0]=V[i]
set V[i]=V[j]
set V[j]=V[0]
set Q[0]=Q[i]
set Q[i]=Q[j]
set Q[j]=Q[0]
set i=i+1
set j=j-1
endif
exitwhen i>j
endloop
if l<j then
call sortUnits(l,j)
endif
if r>i then
call sortUnits(i,r)
endif
endmethod
static method saveGroup takes nothing returns nothing
local real dx
local real dy
set C=C+1
set Q[C]=GetEnumUnit()
set dx=GetUnitX(Q[C])-cX
set dy=GetUnitY(Q[C])-cY
set V[C]=(dx*dx+dy*dy)/10000.
endmethod
implement Init
endstruct
private module Init
private static method onInit takes nothing returns nothing
set thistype.initRect=Rect(0,0,0,0)
endmethod
endmodule
function GetClosestItem takes real x, real y, boolexpr filter returns item
local real r=800.
call ClosestWidget.resetData(x,y)
loop
if r>3200. then
call EnumItemsInRect(bj_mapInitialPlayableArea, filter, function ClosestWidget.enumItems)
exitwhen true
else
call SetRect(ClosestWidget.initRect,x-r,y-r,x+r,y+r)
call EnumItemsInRect(ClosestWidget.initRect, filter, function ClosestWidget.enumItems)
exitwhen ClosestWidget.cItem!=null
endif
set r=2*r
endloop
return ClosestWidget.cItem
endfunction
function GetClosestItemInRange takes real x, real y, real radius, boolexpr filter returns item
call ClosestWidget.resetData(x,y)
if radius>=0 then
call SetRect(ClosestWidget.initRect,x-radius,y-radius,x+radius,y+radius)
call EnumItemsInRect(ClosestWidget.initRect, filter, function ClosestWidget.enumItems)
endif
return ClosestWidget.cItem
endfunction
function GetClosestDestructable takes real x, real y, boolean treeOnly, boolexpr filter returns destructable
local real r=800.
call ClosestWidget.resetData(x,y)
set ClosestWidget.cTree=treeOnly
loop
if r>3200. then
call EnumDestructablesInRect(bj_mapInitialPlayableArea, filter, function ClosestWidget.enumDestructables)
exitwhen true
else
call SetRect(ClosestWidget.initRect,x-r,y-r,x+r,y+r)
call EnumDestructablesInRect(ClosestWidget.initRect, filter, function ClosestWidget.enumDestructables)
exitwhen ClosestWidget.cDest!=null
endif
set r=2*r
endloop
return ClosestWidget.cDest
endfunction
function GetClosestDestructableInRange takes real x, real y, real radius, boolean treeOnly, boolexpr filter returns destructable
call ClosestWidget.resetData(x,y)
if radius>=0 then
set ClosestWidget.cTree=treeOnly
call SetRect(ClosestWidget.initRect,x-radius,y-radius,x+radius,y+radius)
call EnumDestructablesInRect(ClosestWidget.initRect, filter, function ClosestWidget.enumDestructables)
endif
return ClosestWidget.cDest
endfunction
function GetClosestUnit takes real x, real y, boolexpr filter returns unit
local real r=800.
call ClosestWidget.resetData(x,y)
loop
if r>3200. then
call GroupEnumUnitsInRect(bj_lastCreatedGroup, bj_mapInitialPlayableArea, filter)
exitwhen true
else
call GroupEnumUnitsInRange(bj_lastCreatedGroup, x, y, r, filter)
exitwhen FirstOfGroup(bj_lastCreatedGroup)!=null
endif
set r=2*r
endloop
call ForGroup(bj_lastCreatedGroup, function ClosestWidget.enumUnits)
return ClosestWidget.cUnit
endfunction
function GetClosestUnitInRange takes real x, real y, real radius, boolexpr filter returns unit
call ClosestWidget.resetData(x,y)
if radius>=0 then
call GroupEnumUnitsInRange(bj_lastCreatedGroup, x, y, radius, filter)
call ForGroup(bj_lastCreatedGroup, function ClosestWidget.enumUnits)
endif
return ClosestWidget.cUnit
endfunction
function GetClosestUnitInGroup takes real x, real y, group g returns unit
call ClosestWidget.resetData(x,y)
call ForGroup(g, function ClosestWidget.enumUnits)
return ClosestWidget.cUnit
endfunction
function GetClosestNUnitsInRange takes real x, real y, real radius, integer n, group g, boolexpr filter returns nothing
local integer q=n+1
call ClosestWidget.resetData(x,y)
if radius>=0 then
call GroupEnumUnitsInRange(bj_lastCreatedGroup, x, y, radius, filter)
call ForGroup(bj_lastCreatedGroup, function ClosestWidget.saveGroup)
call ClosestWidget.sortUnits(1,C)
loop
exitwhen n==0 or Q[-n+q]==null
call GroupAddUnit(g, Q[-n+q])
set n =n-1
endloop
endif
set C=0
endfunction
function GetClosestNUnitsInGroup takes real x, real y, integer n, group sourceGroup, group destGroup returns nothing
local integer q=n+1
call ClosestWidget.resetData(x,y)
call ForGroup(sourceGroup, function ClosestWidget.saveGroup)
call ClosestWidget.sortUnits(1,C)
loop
exitwhen n==0 or Q[-n+q]==null
call GroupAddUnit(destGroup, Q[-n+q])
set n=n-1
endloop
set C=0
endfunction
endlibrary
/*
===SummonedEscort v1.4
===By Mckill2009
Allows your summoned units to follow and guards the summoner, if summoner dies, the summoned unit
searches for a new master or returns to it's original location.
INSTALLATION:
Copy and paste the trigger "SummonedEscort" and "GetClosestWidget" to your map and do:
call SE.summoned(GetSummoningUnit(),GetTriggerUnit())
If AUTO is true, then it will do automatically for you.
API:
static method summoned takes unit summoningUnit, unit summonedUnit returns nothing
CREDITS:
- GetClosestWidget by Spinnaker [http://www.hiveworkshop.com/forums/jass-resources-412/snippet-getclosestwidget-204217/]
*/
library SummonedEscort uses GetClosestWidget
globals
//===CONFIGURABLES:
private constant boolean AUTO = true //auto registers ALL summoned units in map
private constant boolean ALLY_IN_RANGE = true //searches for ally hero if main hero is dead
private constant boolean FOLLOW_ONLY_HEROES = true
private constant real OFFSET = 200
private constant real CLOSEST_ALLY = 600 //ALLY_IN_RANGE must be true
private constant real CLOSEST_ENEMY = 400 //targets closest enemy in range of master
endglobals
struct SE
private unit master
private unit sum
private real xUnit
private real yUnit
private static integer DATA
private static constant integer ATTACK = 851983
private static timer t = CreateTimer()
private static integer instance = 0
private static integer array insAR
private static unit TempUnit = null
private static method UnitAlive takes unit u returns boolean
return not IsUnitType(u,UNIT_TYPE_DEAD) and u!=null
endmethod
private static method closestEnemy takes nothing returns boolean
local thistype this = DATA
set TempUnit = GetFilterUnit()
return UnitAlive(TempUnit) and IsUnitEnemy(TempUnit, GetOwningPlayer(.sum))
endmethod
private static method closestAlly takes nothing returns boolean
local thistype this = DATA
set TempUnit = GetFilterUnit()
if UnitAlive(TempUnit) and GetOwningPlayer(TempUnit)==GetOwningPlayer(.sum) and TempUnit!=.sum /*
*/ and not IsUnitType(TempUnit,UNIT_TYPE_STRUCTURE) and GetUnitMoveSpeed(TempUnit)>0 then
static if FOLLOW_ONLY_HEROES then
return IsUnitType(TempUnit, UNIT_TYPE_HERO)
endif
return true
endif
return false
endmethod
private method destroy takes nothing returns nothing
set .master = null
set .sum = null
call .deallocate()
endmethod
private static method looper takes nothing returns nothing
local thistype this
local unit target
local integer orderSum
local integer index = 0
local real angle
local real xMaster
local real yMaster
local real xSummoned
local real ySummoned
loop
set index = index+1
set this = insAR[index]
if UnitAlive(.sum) then
set angle = GetRandomReal(0,6.28)
set orderSum = GetUnitCurrentOrder(.sum)
if UnitAlive(.master) then
if orderSum==0 then
set xMaster = GetUnitX(.master)+OFFSET*Cos(angle)
set yMaster = GetUnitY(.master)+OFFSET*Sin(angle)
call IssuePointOrderById(.sum,ATTACK,xMaster,yMaster)
set DATA = this
set target = GetClosestUnitInRange(xMaster,yMaster,CLOSEST_ENEMY,Filter(function thistype.closestEnemy))
if target!=null then
if IsUnitType(target,UNIT_TYPE_SLEEPING) then
call IssueTargetOrderById(.sum,ATTACK,target)
else
call IssuePointOrderById(.sum,ATTACK,GetUnitX(target),GetUnitY(target))
endif
set target = null
endif
endif
else
set DATA = this
set xSummoned = GetUnitX(.sum)
set ySummoned = GetUnitY(.sum)
static if ALLY_IN_RANGE then
set .master = GetClosestUnitInRange(xSummoned,ySummoned,CLOSEST_ALLY,Filter(function thistype.closestAlly))
else
set .master = GetClosestUnit(xSummoned,ySummoned,Filter(function thistype.closestAlly))
endif
if .master==null and orderSum==0 then
call IssuePointOrderById(.sum,ATTACK,.xUnit+OFFSET*Cos(angle),.yUnit+OFFSET*Sin(angle))
endif
endif
else
call .destroy()
set insAR[index] = insAR[instance]
set insAR[instance] = this
set index = index - 1
set instance = instance - 1
if instance==0 then
call PauseTimer(t)
endif
endif
exitwhen index==instance
endloop
endmethod
private static method create takes unit summoningUnit, unit summonedUnit returns thistype
local thistype this
if instance==8190 then
call BJDebugMsg("summoned ERROR: Too many instances!")
else
set this = allocate()
set .master = summoningUnit
set .sum = summonedUnit
set .xUnit = GetUnitX(summonedUnit)
set .yUnit = GetUnitY(summonedUnit)
if instance==0 then
call TimerStart(t,1.0,true,function thistype.looper)
endif
set instance = instance + 1
set insAR[instance] = this
call RemoveGuardPosition(summonedUnit)
endif
return this
endmethod
private static method fire takes nothing returns boolean
call thistype.create(GetSummoningUnit(),GetTriggerUnit())
return false
endmethod
private static method onInit takes nothing returns nothing
static if AUTO then
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SUMMON)
call TriggerAddCondition(t,function thistype.fire)
set t = null
endif
endmethod
//API:======================================
static method summoned takes unit summoningUnit, unit summonedUnit returns nothing
call thistype.create(summoningUnit,summonedUnit)
endmethod
endstruct
endlibrary
/*
Spell Name: Twin Wolves
Made by: mckill2009
REQUIRES:
- Jass New Gen Pack (JNGP) by Vexorian
- RegisterPlayerUnitEvent by Magtheridon96
- Table by Bribe
- SimError by Vexorian
- SummonedEscort by mckill2009
*/
scope TwinWolves
globals
private constant integer SPELL_ID = 'A034'
private constant integer WOLF_ID = 'n00O'
private constant integer FOR_ALLY_SPELL_ID = 'A020' //rejuvenation
private constant integer FOR_ENEMY_SPELL_ID = 'A043' //chainlightning
private constant integer FOR_ALLY_OID = 852160 //this should match the FOR_ALLY_SPELL_ID
private constant integer FOR_ENEMY_OID = 852119 //this should match the FOR_ENEMY_SPELL_ID
private constant real AOE = 600.
private constant string SFX_APPEAR = "Abilities\\Spells\\Orc\\FeralSpirit\\feralspirittarget.mdl"
private constant real PERIOD = 5.0 //how fast the wolves will cast spells, affected by cooldowns
private constant real WOLF_LIFE = 60.
//===NON-CONFIGURABLE
private Table c
private unit FilterUnit
private unit TempUnit
endglobals
private function UnitAlive takes unit u returns boolean
return not IsUnitType(u, UNIT_TYPE_DEAD)
endfunction
private function UnitAllyInRange takes nothing returns boolean
set FilterUnit = GetFilterUnit()
return UnitAlive(FilterUnit) and not IsUnitEnemy(TempUnit, GetOwningPlayer(FilterUnit)) /*
*/ and not IsUnitType(FilterUnit, UNIT_TYPE_STRUCTURE) and not IsUnitType(FilterUnit, UNIT_TYPE_MECHANICAL) /*
*/ and not IsUnitType(FilterUnit, UNIT_TYPE_MAGIC_IMMUNE) and GetWidgetLife(FilterUnit) < GetUnitState(FilterUnit, UNIT_STATE_MAX_LIFE)
endfunction
private function UnitEnemyInRange takes nothing returns boolean
set FilterUnit = GetFilterUnit()
return UnitAlive(FilterUnit) and IsUnitEnemy(TempUnit, GetOwningPlayer(FilterUnit)) /*
*/ and not IsUnitType(FilterUnit, UNIT_TYPE_STRUCTURE) and not IsUnitType(FilterUnit, UNIT_TYPE_MECHANICAL) /*
*/ and not IsUnitType(FilterUnit, UNIT_TYPE_MAGIC_IMMUNE)
endfunction
struct TW
unit caster
unit healer
unit damager
real duration
private static integer index = 0
private static integer array indexAR
private static timer t = CreateTimer()
private static method periodic takes nothing returns nothing
local thistype this
local integer i = 0
local unit first
loop
set i = i+1
set this = indexAR[i]
if .duration > 0 and UnitAlive(.caster) then
set .duration = .duration - PERIOD
set TempUnit = .caster
if UnitAlive(.damager) then
set first = GetClosestUnitInRange(GetUnitX(.damager), GetUnitY(.damager), AOE, Filter(function UnitEnemyInRange))
if first!=null then
call IssueTargetOrderById(.damager, FOR_ENEMY_OID, first)
endif
endif
if UnitAlive(.healer) then
set first = GetClosestUnitInRange(GetUnitX(.healer), GetUnitY(.healer), AOE, Filter(function UnitAllyInRange))
if first!=null then
call IssueTargetOrderById(.healer, FOR_ALLY_OID, first)
endif
endif
else
call c.remove(GetHandleId(.caster))
call KillUnit(.damager)
call KillUnit(.healer)
set .caster = null
set .damager = null
set .healer = null
call .destroy()
set indexAR[i] = indexAR[index]
set indexAR[index] = this
set index = index - 1
set i = i-1
if index==0 then
call PauseTimer(t)
endif
endif
exitwhen i==index
endloop
set first = null
endmethod
private static method cast takes nothing returns nothing
local unit u
local integer level
local real facing
local real x
local real y
local thistype this
if GetSpellAbilityId()==SPELL_ID then
set u = GetTriggerUnit()
if c.has(GetHandleId(u)) then
call IssueImmediateOrder(u, "stop")
call SimError(GetTriggerPlayer(), "you cant use this spell yet")
else
set this = allocate()
set x = GetUnitX(u)
set y = GetUnitY(u)
set facing = GetUnitFacing(u)*0.017453333
set .caster = u
set level = GetUnitAbilityLevel(u, SPELL_ID)
//===Healer
set .healer = CreateUnit(GetTriggerPlayer(), WOLF_ID, x+150*Cos(facing+1.5708), y+150*Sin(facing+1.5708), GetUnitFacing(u))
call DestroyEffect(AddSpecialEffectTarget(SFX_APPEAR, .healer, "origin"))
call UnitAddAbility(.healer, FOR_ALLY_SPELL_ID)
call SetUnitAbilityLevel(.healer, FOR_ALLY_SPELL_ID, level)
call MakeUnitUnSelectable(.healer, 0)
call SE.summoned(.caster, .healer)
//===Damager
set .damager = CreateUnit(GetTriggerPlayer(), WOLF_ID, x+150*Cos(facing-1.5708), y+150*Sin(facing-1.5708), GetUnitFacing(u))
call DestroyEffect(AddSpecialEffectTarget(SFX_APPEAR, .damager, "origin"))
call UnitAddAbility(.damager, FOR_ENEMY_SPELL_ID)
call SetUnitAbilityLevel(.damager, FOR_ENEMY_SPELL_ID, level)
call MakeUnitUnSelectable(.damager, 0)
call SE.summoned(.caster, .damager)
set .duration = WOLF_LIFE
set c[GetHandleId(u)] = 0
if index==0 then
call TimerStart(t, PERIOD, true, function thistype.periodic)
endif
set index = index + 1
set indexAR[index] = this
endif
set u = null
endif
endmethod
private static method onInit takes nothing returns nothing
local unit u = CreateUnit(Player(15), WOLF_ID, 0,0,0)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_CAST, function thistype.cast)
set c = Table.create()
//Preloading
call UnitAddAbility(u, FOR_ENEMY_SPELL_ID)
call UnitAddAbility(u, FOR_ALLY_SPELL_ID)
call ShowUnit(u, false)
call RemoveUnit(u)
set u = null
endmethod
endstruct
endscope
//TESH.scrollpos=45
//TESH.alwaysfold=0
/*
===UnSelectableUnit v1.3
===by mckill2009
Simple to understand, makes any unit unselectable...
REQUIRES:
- JassNewGenPack by vexorian
API:
function MakeUnitSelectable takes unit u returns nothing
function MakeUnitUnSelectable takes unit u, real duration returns nothing
- put 0 for to the duration for permanent
KNOWN ISSUES:
- Unit can still be attacked, ordered and castable by spells
*/
library UnSelectableUnit
globals
private hashtable ht = InitHashtable()
endglobals
private struct US
unit u
boolean permanent
private static integer index = 0
private static integer array indexAR
private static timer t = CreateTimer()
private static method periodic takes nothing returns nothing
local thistype this
local integer i = 0
local integer id
loop
set i = i+1
set this = indexAR[i]
set id = GetHandleId(.u)
if LoadInteger(ht, id, 1)==2 or IsUnitType(.u, UNIT_TYPE_DEAD) then //reset
call FlushChildHashtable(ht, id)
set .u = null
call .destroy()
set indexAR[i] = indexAR[index]
set indexAR[index] = this
set index = index - 1
set i = i-1
if index==0 then
call PauseTimer(t)
endif
elseif LoadInteger(ht, id, 1)==1 then //permanent
call SelectUnit(.u, false)
else
if LoadReal(ht, id, 2) > 0 and not IsUnitType(.u, UNIT_TYPE_DEAD) then
call SaveReal(ht, id, 2, LoadReal(ht, id, 2)-0.03125)
call SelectUnit(.u, false)
else
call SaveInteger(ht, id, 1, 2)
endif
endif
exitwhen i==index
endloop
endmethod
static method startTimer takes unit u, real d, integer id returns nothing
local thistype this
if LoadBoolean(ht, id, 0) then
if d==0 then
debug call DisplayTimedTextToPlayer(GetOwningPlayer(u), 0, 0, 10, "[UnSelectableUnit][MakeUnitUnSelectable] ERROR: Zero duration is not possible!")
else
call SaveReal(ht, id, 2, LoadReal(ht, id, 2)+d)
endif
else
set this = allocate()
set .u = u
if d==0 then
call SaveInteger(ht, id, 1, 1) //making permanent
endif
call SaveReal(ht, id, 2, d)
call SaveBoolean(ht, id, 0, true)
if index==0 then
call TimerStart(t, 0.03125, true, function thistype.periodic)
endif
set index = index + 1
set indexAR[index] = this
endif
endmethod
endstruct
//API:
function MakeUnitSelectable takes unit u returns nothing
call SaveInteger(ht, GetHandleId(u), 1, 2) //resetting
endfunction
function MakeUnitUnSelectable takes unit u, real duration returns nothing
call US.startTimer(u, duration, GetHandleId(u))
endfunction
endlibrary
//===========================================================================
function UnitEventDestroyGroup takes integer i returns nothing
if udg_CargoTransportGroup[i] != null then
call DestroyGroup(udg_CargoTransportGroup[i])
set udg_CargoTransportGroup[i] = null
endif
endfunction
function UnitEventCheckAfter takes nothing returns nothing
local integer i = udg_CheckDeathList[0]
set udg_CheckDeathList[0] = 0
loop
exitwhen i == 0
if udg_IsUnitNew[i] then
//The unit was just created.
set udg_IsUnitNew[i] = false
elseif udg_IsUnitTransforming[i] then
//Added 21 July 2017 to fix the issue re-adding this ability in the same instant
set udg_UDex = i
set udg_UnitTypeEvent = 0.00
set udg_UnitTypeEvent = 1.00
set udg_UnitTypeOf[i] = GetUnitTypeId(udg_UDexUnits[i]) //Set this afterward to give the user extra reference
set udg_IsUnitTransforming[i] = false
call UnitAddAbility(udg_UDexUnits[i], udg_DetectTransformAbility)
elseif udg_IsUnitAlive[i] then
//The unit has started reincarnating.
set udg_IsUnitReincarnating[i] = true
set udg_IsUnitAlive[i] = false
set udg_UDex = i
set udg_DeathEvent = 0.50
set udg_DeathEvent = 0.00
endif
set i = udg_CheckDeathList[i]
endloop
endfunction
function UnitEventCheckAfterProxy takes integer i returns nothing
if udg_CheckDeathList[0] == 0 then
call TimerStart(udg_CheckDeathTimer, 0.00, false, function UnitEventCheckAfter)
endif
set udg_CheckDeathList[i] = udg_CheckDeathList[0]
set udg_CheckDeathList[0] = i
endfunction
function UnitEventOnUnload takes nothing returns nothing
local integer i = udg_UDex
call GroupRemoveUnit(udg_CargoTransportGroup[GetUnitUserData(udg_CargoTransportUnit[i])], udg_UDexUnits[i])
set udg_IsUnitBeingUnloaded[i] = true
set udg_CargoEvent = 0.00
set udg_CargoEvent = 2.00
set udg_CargoEvent = 0.00
set udg_IsUnitBeingUnloaded[i] = false
if not IsUnitLoaded(udg_UDexUnits[i]) or IsUnitType(udg_CargoTransportUnit[i], UNIT_TYPE_DEAD) or GetUnitTypeId(udg_CargoTransportUnit[i]) == 0 then
set udg_CargoTransportUnit[i] = null
endif
endfunction
function UnitEventOnDeath takes nothing returns boolean
local integer pdex = udg_UDex
set udg_UDex = GetUnitUserData(GetTriggerUnit())
if udg_UDex != 0 then
set udg_KillerOfUnit[udg_UDex] = GetKillingUnit() //Added 29 May 2017 for GIMLI_2
set udg_IsUnitAlive[udg_UDex] = false
set udg_DeathEvent = 0.00
set udg_DeathEvent = 1.00
set udg_DeathEvent = 0.00
set udg_KillerOfUnit[udg_UDex] = null
if udg_CargoTransportUnit[udg_UDex] != null then
call UnitEventOnUnload()
endif
endif
set udg_UDex = pdex
return false
endfunction
function UnitEventOnOrder takes nothing returns boolean
local integer pdex = udg_UDex
local unit u = GetFilterUnit()
local integer i = GetUnitUserData(u)
if i > 0 then
set udg_UDex = i
if GetUnitAbilityLevel(u, udg_DetectRemoveAbility) == 0 then
if not udg_IsUnitRemoved[i] then
set udg_IsUnitRemoved[i] = true
set udg_IsUnitAlive[i] = false
set udg_SummonerOfUnit[i] = null
//For backwards-compatibility:
set udg_DeathEvent = 0.00
set udg_DeathEvent = 3.00
set udg_DeathEvent = 0.00
//Fire deindex event for UDex:
set udg_UnitIndexEvent = 0.00
set udg_UnitIndexEvent = 2.00
set udg_UnitIndexEvent = 0.00
set udg_UDexNext[udg_UDexPrev[i]] = udg_UDexNext[i]
set udg_UDexPrev[udg_UDexNext[i]] = udg_UDexPrev[i]
// Recycle the index for later use
set udg_UDexUnits[i] = null
set udg_UDexPrev[i] = udg_UDexLastRecycled
set udg_UDexLastRecycled = i
call UnitEventDestroyGroup(i)
endif
elseif not udg_IsUnitAlive[i] then
if not IsUnitType(u, UNIT_TYPE_DEAD) then
set udg_IsUnitAlive[i] = true
set udg_DeathEvent = 0.00
set udg_DeathEvent = 2.00
set udg_DeathEvent = 0.00
set udg_IsUnitReincarnating[i] = false
endif
elseif IsUnitType(u, UNIT_TYPE_DEAD) then
if udg_IsUnitNew[i] then
//This unit was created as a corpse.
set udg_IsUnitAlive[i] = false
set udg_DeathEvent = 0.00
set udg_DeathEvent = 1.00
set udg_DeathEvent = 0.00
elseif udg_CargoTransportUnit[i] == null or not IsUnitType(u, UNIT_TYPE_HERO) then
//The unit may have just started reincarnating.
call UnitEventCheckAfterProxy(i)
endif
elseif GetUnitAbilityLevel(u, udg_DetectTransformAbility) == 0 and not udg_IsUnitTransforming[i] then
set udg_IsUnitTransforming[i] = true
call UnitEventCheckAfterProxy(i) //This block has been updated on 21 July 2017
endif
if udg_CargoTransportUnit[i] != null and not udg_IsUnitBeingUnloaded[i] and not IsUnitLoaded(u) or IsUnitType(u, UNIT_TYPE_DEAD) then
call UnitEventOnUnload()
endif
set udg_UDex = pdex
endif
set u = null
return false
endfunction
function UnitEventOnSummon takes nothing returns boolean
local integer pdex = udg_UDex
set udg_UDex = GetUnitUserData(GetTriggerUnit())
if udg_IsUnitNew[udg_UDex] then
set udg_SummonerOfUnit[udg_UDex] = GetSummoningUnit()
set udg_UnitIndexEvent = 0.00
set udg_UnitIndexEvent = 0.50
set udg_UnitIndexEvent = 0.00
endif
set udg_UDex = pdex
return false
endfunction
function UnitEventOnLoad takes nothing returns boolean
local integer pdex = udg_UDex
local integer i = GetUnitUserData(GetTriggerUnit())
local integer index
if i != 0 then
set udg_UDex = i
if udg_CargoTransportUnit[i] != null then
call UnitEventOnUnload()
endif
//Loaded corpses do not issue an order when unloaded, therefore must
//use the enter-region event method taken from Jesus4Lyf's Transport.
if not udg_IsUnitAlive[i] then
call SetUnitX(udg_UDexUnits[i], udg_WorldMaxX)
call SetUnitY(udg_UDexUnits[i], udg_WorldMaxY)
endif
set udg_CargoTransportUnit[i] = GetTransportUnit()
set index = GetUnitUserData(udg_CargoTransportUnit[i])
if udg_CargoTransportGroup[index] == null then
set udg_CargoTransportGroup[index] = CreateGroup()
endif
call GroupAddUnit(udg_CargoTransportGroup[index], udg_UDexUnits[i])
set udg_CargoEvent = 0.00
set udg_CargoEvent = 1.00
set udg_CargoEvent = 0.00
set udg_UDex = pdex
endif
return false
endfunction
function UnitEventEnter takes nothing returns boolean
local integer pdex = udg_UDex
local integer i = udg_UDexLastRecycled
local unit u = GetFilterUnit()
if udg_UnitIndexerEnabled and GetUnitAbilityLevel(u, udg_DetectRemoveAbility) == 0 then
//Generate a unique integer index for this unit
if i == 0 then
set i = udg_UDexMax + 1
set udg_UDexMax = i
else
set udg_UDexLastRecycled = udg_UDexPrev[i]
endif
//Link index to unit, unit to index
set udg_UDexUnits[i] = u
call SetUnitUserData(u, i)
//For backwards-compatibility, add the unit to a linked list
set udg_UDexNext[i] = udg_UDexNext[0]
set udg_UDexPrev[udg_UDexNext[0]] = i
set udg_UDexNext[0] = i
set udg_UDexPrev[i] = 0
call UnitAddAbility(u, udg_DetectRemoveAbility)
call UnitMakeAbilityPermanent(u, true, udg_DetectRemoveAbility)
call UnitAddAbility(u, udg_DetectTransformAbility)
set udg_UnitTypeOf[i] = GetUnitTypeId(u)
set udg_IsUnitNew[i] = true
set udg_IsUnitAlive[i] = true
set udg_IsUnitRemoved[i] = false
set udg_IsUnitReincarnating[i] = false
set udg_IsUnitPreplaced[i] = udg_IsUnitPreplaced[0] //Added 29 May 2017 for Spellbound
call UnitEventCheckAfterProxy(i)
//Fire index event for UDex
set udg_UDex = i
set udg_UnitIndexEvent = 0.00
set udg_UnitIndexEvent = 1.00
set udg_UnitIndexEvent = 0.00
else
set udg_UDex = GetUnitUserData(u)
if udg_CargoTransportUnit[udg_UDex] != null and not IsUnitLoaded(u) then
//The unit was dead, but has re-entered the map.
call UnitEventOnUnload()
endif
endif
set udg_UDex = pdex
set u = null
return false
endfunction
//===========================================================================
function UnitEventInit takes nothing returns nothing
local integer i = 16
local player p
local trigger t = CreateTrigger()
local trigger load = CreateTrigger()
local trigger death = CreateTrigger()
local trigger summon = CreateTrigger()
local rect r = GetWorldBounds()
local region re = CreateRegion()
local boolexpr enterB = Filter(function UnitEventEnter)
local boolexpr orderB = Filter(function UnitEventOnOrder)
set udg_WorldMaxX = GetRectMaxX(r)
set udg_WorldMaxY = GetRectMaxY(r)
call RegionAddRect(re, r)
call RemoveRect(r)
call UnitEventDestroyGroup(0)
call UnitEventDestroyGroup(1)
set udg_UnitIndexerEnabled = true
call TriggerRegisterEnterRegion(CreateTrigger(), re, enterB)
call TriggerAddCondition(load, Filter(function UnitEventOnLoad))
call TriggerAddCondition(death, Filter(function UnitEventOnDeath))
call TriggerAddCondition(summon, Filter(function UnitEventOnSummon))
loop
set i = i - 1
set p = Player(i)
call SetPlayerAbilityAvailable(p, udg_DetectRemoveAbility, false)
call SetPlayerAbilityAvailable(p, udg_DetectTransformAbility, false)
call TriggerRegisterPlayerUnitEvent(summon, p, EVENT_PLAYER_UNIT_SUMMON, null)
call TriggerRegisterPlayerUnitEvent(t, p, EVENT_PLAYER_UNIT_ISSUED_ORDER, orderB)
call TriggerRegisterPlayerUnitEvent(death, p, EVENT_PLAYER_UNIT_DEATH, null)
call TriggerRegisterPlayerUnitEvent(load, p, EVENT_PLAYER_UNIT_LOADED, null)
call GroupEnumUnitsOfPlayer(bj_lastCreatedGroup, p, enterB)
exitwhen i == 0
endloop
set summon = null
set death = null
set load = null
set re = null
set enterB = null
set orderB = null
set p = null
set r = null
set t = null
endfunction
function InitTrig_Unit_Event takes nothing returns nothing
endfunction