Name | Type | is_array | initial_value |
AE_TmpGroup | group | Yes | |
AE_TmpPoint | location | Yes | |
AE_TmpReal | real | Yes | |
AE_TmpUnit | unit | Yes | |
AfterDamageEvent | real | No | |
AnimationResetGroup | group | No | |
AOEDamageEvent | real | No | |
AOEDamageSource | unit | No | |
ARMOR_TYPE_ETHEREAL | integer | No | |
ARMOR_TYPE_FLESH | integer | No | |
ARMOR_TYPE_METAL | integer | No | |
ARMOR_TYPE_NONE | integer | No | |
ARMOR_TYPE_STONE | integer | No | |
ARMOR_TYPE_WOOD | integer | No | |
ArmorDamageEvent | real | No | |
ArmorTypeDebugStr | string | Yes | |
ATTACK_TYPE_CHAOS | integer | No | |
ATTACK_TYPE_HERO | integer | No | |
ATTACK_TYPE_MAGIC | integer | No | |
ATTACK_TYPE_NORMAL | integer | No | |
ATTACK_TYPE_PIERCE | integer | No | |
ATTACK_TYPE_SIEGE | integer | No | |
ATTACK_TYPE_SPELLS | integer | No | |
AttackTypeDebugStr | string | Yes | |
CargoEvent | real | No | |
CargoEvent_Copy | real | No | |
CargoEvent_Copy_2 | real | No | |
CargoTransportGroup | group | Yes | |
CargoTransportGroup_Copy | group | Yes | |
CargoTransportUnit | unit | Yes | |
CargoTransportUnit_Copy | unit | Yes | |
CEvBlock | boolean | Yes | |
CEvNext | integer | Yes | |
CEvPrev | integer | Yes | |
CEvSpecial | boolean | Yes | |
CEvUnloadTimer | timer | No | |
CheckDeathInList | boolean | Yes | |
CheckDeathList | integer | Yes | |
CheckDeathList_Copy | integer | Yes | |
CheckDeathTimer | timer | No | |
CheckDeathTimer_Copy | timer | No | |
ClearDamageEvent | trigger | No | |
CONVERTED_ATTACK_TYPE | attacktype | Yes | |
CONVERTED_DAMAGE_TYPE | damagetype | Yes | |
CP_HiddenItems | item | Yes | |
CP_HiddenItemsIndex | integer | No | |
CP_Item | item | No | |
CP_Point | location | No | |
CP_PointIsWalkable | boolean | No | |
CP_Rect | rect | No | |
DAMAGE_TYPE_ACID | integer | No | |
DAMAGE_TYPE_COLD | integer | No | |
DAMAGE_TYPE_DEATH | integer | No | |
DAMAGE_TYPE_DEFENSIVE | integer | No | |
DAMAGE_TYPE_DEMOLITION | integer | No | |
DAMAGE_TYPE_DISEASE | integer | No | |
DAMAGE_TYPE_DIVINE | integer | No | |
DAMAGE_TYPE_ENHANCED | integer | No | |
DAMAGE_TYPE_FIRE | integer | No | |
DAMAGE_TYPE_FORCE | integer | No | |
DAMAGE_TYPE_LIGHTNING | integer | No | |
DAMAGE_TYPE_MAGIC | integer | No | |
DAMAGE_TYPE_MIND | integer | No | |
DAMAGE_TYPE_NORMAL | integer | No | |
DAMAGE_TYPE_PLANT | integer | No | |
DAMAGE_TYPE_POISON | integer | No | |
DAMAGE_TYPE_SHADOW_STRIKE | integer | No | |
DAMAGE_TYPE_SLOW_POISON | integer | No | |
DAMAGE_TYPE_SONIC | integer | No | |
DAMAGE_TYPE_SPIRIT_LINK | integer | No | |
DAMAGE_TYPE_UNIVERSAL | integer | No | |
DAMAGE_TYPE_UNKNOWN | integer | No | |
DamageBlockingAbility | abilcode | No | |
DamageEvent | real | No | |
DamageEvent_Copy | real | No | |
DamageEventAmount | real | No | |
DamageEventAOE | integer | No | |
DamageEventAOEGroup | group | No | |
DamageEventArmorPierced | real | No | |
DamageEventArmorT | integer | No | |
DamageEventAttackT | integer | No | |
DamageEventDamageT | integer | No | |
DamageEventDefenseT | integer | No | |
DamageEventLevel | integer | No | |
DamageEventOverride | boolean | No | |
DamageEventPrevAmt | real | No | |
DamageEventSource | unit | No | |
DamageEventsWasted | integer | No | |
DamageEventTarget | unit | No | |
DamageEventTrigger | trigger | No | |
DamageEventType | integer | No | |
DamageEventWeaponT | integer | No | |
DamageFilterAttackT | integer | No | |
DamageFilterDamageT | integer | No | |
DamageFilterFailChance | real | No | |
DamageFilterMinAmount | real | No | |
DamageFilterRunChance | real | No | |
DamageFilterSource | unit | No | |
DamageFilterSourceA | abilcode | No | |
DamageFilterSourceB | buffcode | No | |
DamageFilterSourceC | integer | No | |
DamageFilterSourceI | itemcode | No | |
DamageFilterSourceT | unitcode | No | |
DamageFilterTarget | unit | No | |
DamageFilterTargetA | abilcode | No | |
DamageFilterTargetB | buffcode | No | |
DamageFilterTargetC | integer | No | |
DamageFilterTargetI | itemcode | No | |
DamageFilterTargetT | unitcode | No | |
DamageFilterType | integer | No | |
DamageModifierEvent | real | No | |
DamageScalingUser | real | No | |
DamageScalingWC3 | real | No | |
DamageTypeBlocked | integer | No | |
DamageTypeCode | integer | No | |
DamageTypeCriticalStrike | integer | No | |
DamageTypeDebugStr | string | Yes | |
DamageTypeExplosive | integer | No | |
DamageTypeHeal | integer | No | |
DamageTypePure | integer | No | |
DamageTypePureExplosive | integer | No | |
DamageTypeReduced | integer | No | |
DeathEvent | real | No | |
DeathEvent_Copy | real | No | |
DeathEvent_Copy_2 | real | No | |
DebugInt | integer | No | |
DEFENSE_TYPE_DIVINE | integer | No | |
DEFENSE_TYPE_FORTIFIED | integer | No | |
DEFENSE_TYPE_HEAVY | integer | No | |
DEFENSE_TYPE_HERO | integer | No | |
DEFENSE_TYPE_LIGHT | integer | No | |
DEFENSE_TYPE_MEDIUM | integer | No | |
DEFENSE_TYPE_NORMAL | integer | No | |
DEFENSE_TYPE_UNARMORED | integer | No | |
DefenseTypeDebugStr | string | Yes | |
DetectRemoveAbility | abilcode | No | |
DetectRemoveAbility_Copy | abilcode | No | |
DetectTransformAbility | abilcode | No | |
DetectTransformAbility_Copy | abilcode | No | |
DEvAbility | abilcode | No | |
DEvAbilityTemp | abilcode | No | |
DEvBlock | boolean | Yes | |
DEvList | integer | Yes | |
DEvRemoved | boolean | Yes | |
DEvTimer | timer | No | |
DisplayBar | string | No | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
DisplayBarAlt | string | No | |cff8080ff|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
DisplayBarCount | real | No | 50.00 |
DisplayHidden | boolean | No | |
DisplayLoopInteger | integer | No | |
DisplayShieldHealthChanged | boolean | No | |
DisplayShieldTypeColor | string | Yes | |
DisplayUnitNeedsUpdate | boolean | Yes | |
DmgEvLife | real | No | |
DmgEvPrevLife | real | No | |
DmgEvRecursionLevel | integer | No | |
DmgEvRecursionN | integer | No | |
DmgEvRunning | boolean | No | |
DmgEvStarted | boolean | No | |
DmgEvTimer | timer | No | |
DmgEvTrig | trigger | No | |
DmgEvUnit | unit | No | |
DmgStr | string | No | |
DoNotClearNext | boolean | No | |
DraeneiBuildings | unitcode | No | |
Dummy | unit | No | |
DummyAbility | ability | No | |
ED_AugurAuraGroup | group | No | |
ED_ConvictionGroup | group | No | |
ED_DraeneiBuildingsGroup | group | No | |
ED_GemcraftersGroup | group | No | |
ED_HallowGroup | group | Yes | |
ED_NetherRayGroup | group | No | |
ED_NetherwindsGroup | group | No | |
ED_OrdnanceGroup | group | No | |
ED_StymieChainGroup | group | No | |
ED_SuppressionBeamGroup | group | No | |
EndOnTargetBounce | boolean | No | |
EnhancedDamageTarget | unit | No | |
GMF_Ability | abilcode | Yes | |
GMF_Array | integer | No | |
GMF_Group | group | No | |
GMF_Hashtable | hashtable | No | |
GMF_InitializationMines | group | No | |
GMF_TmpGroup | group | Yes | |
GMF_TmpHandle | handle | No | |
GMF_TmpInteger | integer | Yes | |
GMF_TmpPoint | location | Yes | |
GMF_TmpUnit | unit | Yes | |
GMF_Type | unitcode | Yes | |
group | group | No | |
HE_AbodeAuraGroup | group | No | |
HE_ConcentratedGroup | group | No | |
HE_GuardpostGroup | group | No | |
HE_HighElvesBaseGroup | group | Yes | |
HE_LiberatorGroup | group | No | |
HE_RangerGroup | group | No | |
HE_SacralizeGroup | group | Yes | |
heal_amount | real | No | |
heal_check | boolean | No | |
HEAL_CHECK_INTERVAL | real | No | |
heal_count | integer | No | |
heal_diff | real | No | |
heal_exitwhen | integer | No | |
heal_indexRef | integer | Yes | |
heal_indices | integer | Yes | |
heal_inSys | boolean | Yes | |
heal_integer | integer | No | |
heal_lastLife | real | Yes | |
heal_life | real | No | |
heal_regen | real | Yes | |
heal_source | unit | No | |
heal_target | unit | No | |
HEAL_THRESHOLD | real | No | |
heal_timer | timer | No | |
HealEvent | real | No | |
IL_RestrainingChainsGroup | group | No | |
IL_TidemageGroup | group | No | |
IllidariUIBlood_CurrentText | string | No | |
IllidariUIDemon_CurrentText | string | No | |
IllidariUINaga_CurrentText | string | No | |
Int_AbilityLevel | integer | No | |
IsDamageAttack | boolean | No | |
IsDamageCode | boolean | No | |
IsDamageMelee | boolean | No | |
IsDamageRanged | boolean | No | |
IsDamageSpell | boolean | No | |
IsUnitAlive | boolean | Yes | |
IsUnitAlive_Copy | boolean | Yes | |
IsUnitBeingUnloaded | boolean | Yes | |
IsUnitBeingUnloaded_Copy | boolean | Yes | |
IsUnitNew | boolean | Yes | |
IsUnitNew_Copy | boolean | Yes | |
IsUnitPreplaced | boolean | Yes | |
IsUnitPreplaced_Copy | boolean | Yes | |
IsUnitReincarnating | boolean | Yes | |
IsUnitReincarnating_Copy | boolean | Yes | |
IsUnitRemoved | boolean | Yes | |
IsUnitRemoved_Copy | boolean | Yes | |
IsUnitTransforming | boolean | Yes | |
IsUnitTransforming_Copy | boolean | Yes | |
KB3D_Accel | real | No | |
KB3D_AllowOutSiding | boolean | No | |
KB3D_Angle | real | No | |
KB3D_AoE | real | No | |
KB3D_AoEDamage | real | No | |
KB3D_AoEEndDamage | real | No | |
KB3D_AoEEndFx | string | No | |
KB3D_AoEKB | boolean | No | |
KB3D_AoEKB_Power | real | No | |
KB3D_Arc | real | No | |
KB3D_Attach | string | No | |
KB3D_AttackType | attacktype | No | |
KB3D_B | boolean | No | |
KB3D_Bounce_Fx | string | No | |
KB3D_Bounce_Power | real | No | |
KB3D_Bounce_Target | boolean | No | |
KB3D_Bounce_Unit | boolean | No | |
KB3D_Counter | integer | No | |
KB3D_CW_HiddenItems | item | Yes | |
KB3D_CW_HiddenItemsIndex | integer | No | |
KB3D_CW_Item | item | No | |
KB3D_D_ALLY | boolean | No | |
KB3D_D_ENEMY | boolean | No | |
KB3D_D_FLYING | boolean | No | |
KB3D_D_MAGIC_IMMINUE | boolean | No | |
KB3D_D_MECHANICAL | boolean | No | |
KB3D_D_RESISTANT | boolean | No | |
KB3D_D_STRUCTURE | boolean | No | |
KB3D_Damager | unit | No | |
KB3D_DamageType | damagetype | No | |
KB3D_DestroyDestructables | boolean | No | |
KB3D_DestroyTree | boolean | No | |
KB3D_DisableUnit | boolean | No | |
KB3D_EndFx | string | No | |
KB3D_EndisNormal | boolean | No | |
KB3D_EndisUnit | boolean | No | |
KB3D_EndisUnpathable | boolean | No | |
KB3D_EndOnObstacle | boolean | No | |
KB3D_EndOnTargetBounce | boolean | No | |
KB3D_EndTrigger | trigger | No | |
KB3D_EndUnit | unit | No | |
KB3D_EndwhenDead | boolean | No | |
KB3D_EndWhenHit | boolean | No | |
KB3D_FaceAngle | boolean | No | |
KB3D_Flyover | boolean | No | |
KB3D_Flyover_Duration | real | No | |
KB3D_Fx | string | No | |
KB3D_Fx_Attach | string | No | |
KB3D_g | group | No | |
KB3D_GroundDamage | boolean | No | |
KB3D_HA | hashtable | No | |
KB3D_Harvester | unit | No | |
KB3D_HomingMissile | boolean | No | |
KB3D_i | integer | No | |
KB3D_iKB | boolean | No | |
KB3D_ImpactDamage | real | No | |
KB3D_Instances | integer | No | |
KB3D_JumpOverCliff | boolean | No | |
KB3D_KBTarget | boolean | No | |
KB3D_KillatEnd | boolean | No | |
KB3D_KillatTime | real | No | |
KB3D_KillifOutSider | boolean | No | |
KB3D_KillWhenHit | boolean | No | |
KB3D_Line_Fx | string | No | |
KB3D_LineDamage | real | No | |
KB3D_Loop | trigger | No | |
KB3D_LoopDamage | real | No | |
KB3D_Paused | boolean | No | |
KB3D_PausedReg | boolean | No | |
KB3D_PauseID | integer | No | |
KB3D_Range | real | No | |
KB3D_Reals | real | Yes | |
KB3D_Registration | trigger | No | |
KB3D_RemoveUnit | unit | No | |
KB3D_Speed | real | No | |
KB3D_Speed_Changer | boolean | No | |
KB3D_StopTime | real | No | |
KB3D_TargetDamage | real | No | |
KB3D_Targeted_Unit | unit | No | |
KB3D_Time | real | No | |
KB3D_Timer | timer | No | |
KB3D_TrailFx | string | No | |
KB3D_Unit | unit | No | |
KB3D_UnpathableStop | boolean | No | |
KB3D_Zoffset | real | No | |
KillerOfUnit | unit | Yes | |
KillerOfUnit_Copy | unit | Yes | |
KT_EnlightenmentGroup | group | No | |
KT_HarmonicGroup | group | No | |
KT_HeadmasterGroup | group | No | |
KT_PrismaticGroup | group | No | |
KT_SageShieldGroup | group | No | |
KT_ScribeGroup | group | No | |
KT_TemporalCloakGroup | group | No | |
KT_TransparencyGroup | group | No | |
LastCreatedShield | integer | No | |
LastDamageHP | real | No | |
LastDmgPrevAmount | real | Yes | |
LastDmgPrevType | integer | Yes | |
LastDmgSource | unit | Yes | |
LastDmgTarget | unit | Yes | |
LastDmgValue | real | Yes | |
LastDmgWasSpell | boolean | Yes | |
LethalDamageEvent | real | No | |
LethalDamageHP | real | No | |
NextDamageIsAttack | boolean | No | |
NextDamageIsMelee | boolean | No | |
NextDamageIsRanged | boolean | No | |
NextDamageOverride | boolean | No | |
NextDamageType | integer | No | |
NextDamageWeaponT | integer | No | |
NextHealAmount | real | No | |
NextHealSource | unit | No | |
NextHealTarget | unit | No | |
NoTrigger | trigger | No | |
OnDamageEvent | real | No | |
ParagonHero | unit | No | |
Player | player | No | |
PlayerColour | player | Yes | |
PlayerNum | integer | Yes | |
PreDamageEvent | real | No | |
RayTimer | timer | No | |
regen_buildup | real | Yes | |
REGEN_EVENT_INTERVAL | real | No | |
REGEN_STRENGTH_VALUE | real | No | |
REGEN_THRESHOLD | real | No | |
regen_timeleft | real | Yes | |
RemoveDamageEvent | boolean | No | |
ShieldBlockType | trigger | Yes | |
ShieldBreak | trigger | Yes | |
ShieldCaster | unit | Yes | |
ShieldDamaged | trigger | Yes | |
ShieldDuration | real | Yes | |
ShieldedUnit | unit | Yes | |
ShieldEvent | real | No | |
ShieldEventDamagedAmount | real | No | |
ShieldEventOverkillAmount | real | No | |
ShieldExpire | trigger | Yes | |
ShieldFirstOfIDAdded | boolean | No | |
ShieldFunctionInteger | integer | No | |
ShieldFunctionReturnInteger | integer | No | |
ShieldFunctionUnit | unit | No | |
ShieldHealth | real | Yes | |
ShieldHealthMax | real | Yes | |
ShieldIndex | integer | No | |
ShieldIterationTrigger | trigger | No | |
ShieldLastOfIDRemoved | boolean | No | |
ShieldNextDiff | integer | Yes | |
ShieldNextSame | integer | Yes | |
ShieldPeriodic | trigger | Yes | |
ShieldPrevDiff | integer | Yes | |
ShieldPrevSame | integer | Yes | |
ShieldRemoved | trigger | Yes | |
ShieldRemoveWhenBroken | boolean | Yes | |
ShieldTable | hashtable | No | |
ShieldTypeID | integer | Yes | |
ShieldUnitDamaged | trigger | Yes | |
ShieldUnitIndex | integer | No | |
SourceDamageEvent | real | No | |
SummonerOfUnit | unit | Yes | |
SummonerOfUnit_Copy | unit | Yes | |
SystemShieldedUnits | group | No | |
SystemShieldFlaggedRemove | boolean | Yes | |
SystemShieldFreeIndexCurrent | integer | No | |
SystemShieldFreeIndexes | integer | Yes | |
SystemShieldIterationStop | boolean | No | |
SystemShieldListInUse | integer | No | |
SystemShieldMaxIndex | integer | No | -1 |
SystemShieldPeriodicTimer | timer | No | |
SystemShieldsRemovalQueue | integer | Yes | |
SystemShieldsRemovalQueueIndex | integer | No | 0 |
temp_loc | location | Yes | |
Temp_Unit | unit | No | |
TempEffect | effect | Yes | |
TempEffect_Copy | effect | No | |
TempGroup | group | No | |
TempInt | integer | Yes | |
TempInteger | integer | No | |
tempLoc | location | Yes | |
TempPoint | location | No | |
TempPoint2 | location | No | |
TempReal | real | Yes | |
TempString | string | No | |
TempStrings | string | Yes | |
TempUnit | unit | No | |
Timer_AnimationReset | timer | No | |
Timestamp | timer | No | |
TmpReal | real | Yes | |
UDex | integer | No | |
UDex_Copy | integer | No | |
UDexGen | integer | No | |
UDexLastRecycled | integer | No | |
UDexLastRecycled_Copy | integer | No | |
UDexMax | integer | No | |
UDexMax_Copy | integer | No | |
UDexNext | integer | Yes | |
UDexNext_Copy | integer | Yes | |
UDexPrev | integer | Yes | |
UDexPrev_Copy | integer | Yes | |
UDexRecycle | integer | No | |
UDexUnits | unit | Yes | |
UDexUnits_Copy | unit | Yes | |
UDexWasted | integer | No | |
UMovNext | integer | Yes | |
UMovPrev | integer | Yes | |
UNIT_CLASS_ANCIENT | integer | No | |
UNIT_CLASS_ATTACKS_FLYING | integer | No | |
UNIT_CLASS_ATTACKS_GROUND | integer | No | |
UNIT_CLASS_DEAD | integer | No | |
UNIT_CLASS_ETHEREAL | integer | No | |
UNIT_CLASS_FLYING | integer | No | |
UNIT_CLASS_GIANT | integer | No | |
UNIT_CLASS_GROUND | integer | No | |
UNIT_CLASS_HERO | integer | No | |
UNIT_CLASS_MAGIC_IMMUNE | integer | No | |
UNIT_CLASS_MECHANICAL | integer | No | |
UNIT_CLASS_MELEE | integer | No | |
UNIT_CLASS_PEON | integer | No | |
UNIT_CLASS_PLAGUED | integer | No | |
UNIT_CLASS_POISONED | integer | No | |
UNIT_CLASS_POLYMORPHED | integer | No | |
UNIT_CLASS_RANGED | integer | No | |
UNIT_CLASS_RESISTANT | integer | No | |
UNIT_CLASS_SAPPER | integer | No | |
UNIT_CLASS_SLEEPING | integer | No | |
UNIT_CLASS_SNARED | integer | No | |
UNIT_CLASS_STRUCTURE | integer | No | |
UNIT_CLASS_STUNNED | integer | No | |
UNIT_CLASS_SUMMONED | integer | No | |
UNIT_CLASS_TAUREN | integer | No | |
UNIT_CLASS_TOWNHALL | integer | No | |
UNIT_CLASS_UNDEAD | integer | No | |
UnitDamageRegistered | boolean | Yes | |
UnitFirstShield | integer | Yes | |
UnitGroup_Thane | group | No | |
UnitInAction | boolean | Yes | |
UnitInActionEvent | real | No | |
UnitIndexerEnabled | boolean | No | |
UnitIndexerEnabled_Copy | boolean | No | |
UnitIndexEvent | real | No | |
UnitIndexEvent_Copy | real | No | |
UnitIndexLock | integer | Yes | |
UnitKey | integer | Yes | |
UnitLastShield | integer | Yes | |
UnitMovementInterval | real | No | |
UnitMoving | boolean | Yes | |
UnitMovingEvent | real | No | |
UnitMovingX | real | Yes | |
UnitMovingY | real | Yes | |
UnitName | string | Yes | |
UnitShieldTag | texttag | Yes | |
UnitTypeEvent | real | No | |
UnitTypeEvent_Copy | real | No | |
UnitTypeOf | unitcode | Yes | |
UnitTypeOf_Copy | unitcode | Yes | |
WDS_AddUnit | unit | No | |
WDS_Count | integer | No | |
WDS_DockAbilityChannel | abilcode | No | |
WDS_DockAbilityLevel | abilcode | No | |
WDS_DockAlreadyAdded | group | No | |
WDS_DockArray | integer | No | |
WDS_DockChannelerAbility | abilcode | Yes | |
WDS_DockChannelerType | unitcode | Yes | |
WDS_DockEffect | string | Yes | |
WDS_DockHostType | unitcode | Yes | |
WDS_DockLimit | integer | Yes | |
WDS_DockLinked | unit | No | |
WDS_DockOffset | real | No | |
WDS_DockOffsetHost | real | Yes | |
WDS_DockSpot | unit | No | |
WDS_DockStartingAngle | real | Yes | |
WDS_EffectHashtable | hashtable | No | |
WDS_EventDock | real | No | |
WDS_EventDockCheck | real | No | |
WDS_EventDockCount | integer | No | |
WDS_EventDockGroup | group | No | |
WDS_EventDockSource | unit | No | |
WDS_EventDockTarget | unit | No | |
WDS_FoundSpot | boolean | No | |
WDS_GroupChannelers | group | No | |
WDS_GroupDock | group | No | |
WDS_Hashtable | hashtable | No | |
WDS_Limit | integer | No | |
WDS_LoopA | integer | No | |
WDS_LoopB | integer | No | |
WDS_LoopC | integer | No | |
WDS_OrderGroup | group | No | |
WDS_StartPoint | location | Yes | |
WDS_TmpAngle | real | Yes | |
WDS_TmpHandleA | handle | No | |
WDS_TmpHandleB | handle | No | |
WDS_TmpHost | unit | No | |
WDS_TmpInteger | integer | Yes | |
WDS_TmpPoint | location | Yes | |
WDS_TmpReal | real | Yes | |
WDS_TmpTarget | unit | No | |
WEAPON_TYPE_AM_CHOP | integer | No | |
WEAPON_TYPE_CH_SLICE | integer | No | |
WEAPON_TYPE_CL_SLICE | integer | No | |
WEAPON_TYPE_CM_SLICE | integer | No | |
WEAPON_TYPE_MH_BASH | integer | No | |
WEAPON_TYPE_MH_CHOP | integer | No | |
WEAPON_TYPE_MH_SLICE | integer | No | |
WEAPON_TYPE_MH_STAB | integer | No | |
WEAPON_TYPE_ML_CHOP | integer | No | |
WEAPON_TYPE_ML_SLICE | integer | No | |
WEAPON_TYPE_MM_BASH | integer | No | |
WEAPON_TYPE_MM_CHOP | integer | No | |
WEAPON_TYPE_MM_SLICE | integer | No | |
WEAPON_TYPE_MM_STAB | integer | No | |
WEAPON_TYPE_NONE | integer | No | |
WEAPON_TYPE_RH_BASH | integer | No | |
WEAPON_TYPE_WH_BASH | integer | No | |
WEAPON_TYPE_WH_SLICE | integer | No | |
WEAPON_TYPE_WL_BASH | integer | No | |
WEAPON_TYPE_WL_SLICE | integer | No | |
WEAPON_TYPE_WL_STAB | integer | No | |
WEAPON_TYPE_WM_BASH | integer | No | |
WEAPON_TYPE_WM_SLICE | integer | No | |
WEAPON_TYPE_WM_STAB | integer | No | |
WeaponTypeDebugStr | string | Yes | |
Winter_CargoHoldGroup | group | No | |
Winter_CargoHoldHandle | handle | No | |
Winter_CargoHoldHashtable | hashtable | No | |
Winter_CargoHoldUnit | unit | No | |
Winter_CargoHoldValue | integer | No | |
WorldMaxX | real | No | |
WorldMaxX_Copy | real | No | |
WorldMaxY | real | No | |
WorldMaxY_Copy | real | No | |
X | real | No | |
Y | real | No | |
ZeroDamageEvent | real | No |
//TESH.scrollpos=75
//TESH.alwaysfold=0
function IsUnitMovementTracked takes integer i returns boolean
return udg_UMovPrev[i] != 0 or udg_UMovNext[0] == i
endfunction
function UnitMovementRegister takes nothing returns boolean
local integer i = udg_UDex
if not IsUnitMovementTracked(i) and TriggerEvaluate(gg_trg_Is_Unit_Moving_Config) then
set udg_UMovPrev[udg_UMovNext[0]] = i
set udg_UMovNext[i] = udg_UMovNext[0]
set udg_UMovNext[0] = i
set udg_UnitMovingX[i] = GetUnitX(udg_UDexUnits[i])
set udg_UnitMovingY[i] = GetUnitY(udg_UDexUnits[i])
endif
return false
endfunction
function UnitMovementUnregister takes nothing returns boolean
local integer i = udg_UDex
if IsUnitMovementTracked(i) then
set udg_UnitMoving[i] = false
set udg_UMovNext[udg_UMovPrev[i]] = udg_UMovNext[i]
set udg_UMovPrev[udg_UMovNext[i]] = udg_UMovPrev[i]
set udg_UMovPrev[i] = 0
endif
return false
endfunction
function RunUnitMovementEvent takes integer i, real e returns nothing
local integer pdex = udg_UDex
if e == 1.00 then
set udg_UnitMoving[i] = true
else
set udg_UnitMoving[i] = false
endif
set udg_UDex = i
set udg_UnitMovingEvent = e
set udg_UnitMovingEvent = 0.00
set udg_UDex = pdex
endfunction
//===========================================================================
// This function runs periodically to check if units are actually moving.
//
function UnitMovementTracker takes nothing returns nothing
local integer i = 0
local integer n
local real x
local real y
loop
set i = udg_UMovNext[i]
exitwhen i == 0
set x = GetUnitX(udg_UDexUnits[i])
set y = GetUnitY(udg_UDexUnits[i])
if x != udg_UnitMovingX[i] or y != udg_UnitMovingY[i] then
set udg_UnitMovingX[i] = x
set udg_UnitMovingY[i] = y
if not udg_UnitMoving[i] then
if GetUnitTypeId(udg_UDexUnits[i]) != 0 then
call RunUnitMovementEvent(i, 1.00)
else
set n = udg_UDex
set udg_UDex = i
set i = udg_UMovPrev[i] //avoid skipping checks
call UnitMovementUnregister()
set udg_UDex = n
endif
endif
elseif udg_UnitMoving[i] then
call RunUnitMovementEvent(i, 2.00)
endif
endloop
endfunction
//===========================================================================
function InitTrig_Is_Unit_Moving takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterVariableEvent(t, "udg_UnitIndexEvent", EQUAL, 1.00)
call TriggerAddCondition(t, Filter(function UnitMovementRegister))
set t = CreateTrigger()
call TriggerRegisterVariableEvent(t, "udg_UnitIndexEvent", EQUAL, 2.00)
call TriggerAddCondition(t, Filter(function UnitMovementUnregister))
if gg_trg_Is_Unit_Moving_Config != null then
call TriggerExecute(gg_trg_Is_Unit_Moving_Config)
else
call ExecuteFunc("Trig_Is_Unit_Moving_Config_Actions")
endif
call TimerStart(CreateTimer(), udg_UnitMovementInterval, true, function UnitMovementTracker)
endfunction
//===========================================================================
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 id = 0
local unit u
loop
set id = udg_CheckDeathList[id]
exitwhen id == 0
set udg_UDex = id
set u = udg_UDexUnits[id]
if udg_IsUnitNew[id] then
//The unit was just created.
set udg_IsUnitNew[id] = false
set udg_UnitIndexEvent = 1.50 //New event requested by SpellBound to detect when unit fully enters scope.
set udg_UnitIndexEvent = 0.00
elseif udg_IsUnitTransforming[id] then
//Added 21 July 2017 to fix the issue re-adding this ability in the same instant
set udg_UnitTypeEvent = 0.00
set udg_UnitTypeEvent = 1.00
set udg_UnitTypeOf[id] = GetUnitTypeId(u) //Set this afterward as otherwise the user won't know what the previous unittype was.
set udg_IsUnitTransforming[id] = false
call UnitAddAbility(u, udg_DetectTransformAbility)
elseif udg_IsUnitAlive[id] then
//The unit has started reincarnating.
set udg_IsUnitReincarnating[id] = true
set udg_IsUnitAlive[id] = false
set udg_DeathEvent = 0.50
set udg_DeathEvent = 0.00
elseif GetUnitTypeId(u) != 0 and not IsUnitType(u, UNIT_TYPE_DEAD) then //with vJass, could just use UnitAlive instead of both of these values.
//Moved this code to fire after a 0 second timer instead.
set udg_IsUnitAlive[id] = true
set udg_DeathEvent = 2.00
set udg_DeathEvent = 0.00
set udg_IsUnitReincarnating[id] = false
endif
set udg_CheckDeathInList[id] = false
endloop
set u = null
//Empty the list
set udg_CheckDeathList[0] = 0
endfunction
function UnitEventCheckAfterProxy takes integer i returns nothing
if udg_CheckDeathList[0] == 0 then
call TimerStart(udg_CheckDeathTimer, 0.00, false, function UnitEventCheckAfter)
endif
if not udg_CheckDeathInList[i] then
set udg_CheckDeathList[i] = udg_CheckDeathList[0]
set udg_CheckDeathList[0] = i
set udg_CheckDeathInList[i] = true
endif
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
call UnitEventCheckAfterProxy(i) //modified 22 Oct 2022 to ensure the unit is fully revived before firing the event.
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
set udg_CheckDeathInList[i] = false
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 = bj_MAX_PLAYER_SLOTS //update to make it work with 1.29
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_CheckDeathList[0] = 0
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
function Trig_ShieldBlockFront_Conditions takes nothing returns boolean
local unit source = udg_DamageEventSource
local unit target = udg_DamageEventTarget
local real x2 = GetUnitX(source)
local real y2 = GetUnitY(source)
local real x1 = GetUnitX(target)
local real y1 = GetUnitY(target)
local real arc = 180
local real angle = Atan2(y2 - y1, x2 - x1)*bj_RADTODEG
local real anglefacing = GetUnitFacing(target)
local real angledifference
// if anglefacing > 180 then
// set anglefacing = -(360 -anglefacing)
// endif
set angledifference = ModuloReal(angle-(anglefacing+180),360) - 180
// call BJDebugMsg("AngleDifference: " +R2S(angledifference))
set source = null
set target = null
if angledifference <= arc/2.0 and angledifference >= -arc/2.0 then
return true
endif
return false
endfunction
function Trig_ShieldBlockFront_Actions takes nothing returns nothing
endfunction
//===========================================================================
function InitTrig_ShieldBlockFront takes nothing returns nothing
set gg_trg_ShieldBlockFront = CreateTrigger( )
call TriggerAddCondition( gg_trg_ShieldBlockFront, Condition( function Trig_ShieldBlockFront_Conditions ) )
call TriggerAddAction( gg_trg_ShieldBlockFront, function Trig_ShieldBlockFront_Actions )
endfunction
function Trig_ShieldBlockByEffect60_Conditions takes nothing returns boolean
local effect e = LoadEffectHandle(udg_ShieldTable, udg_ShieldIndex, StringHash("ShieldEffect"))
local unit source = udg_DamageEventSource
local unit target = udg_DamageEventTarget
local real x2 = GetUnitX(source)
local real y2 = GetUnitY(source)
local real x1 = GetUnitX(target)
local real y1 = GetUnitY(target)
local real x3 = BlzGetLocalSpecialEffectX(e)
local real y3 = BlzGetLocalSpecialEffectY(e)
local real arc = 120
local real angle = Atan2(y2 - y1, x2 - x1)*bj_RADTODEG
local real anglefacing = Atan2(y3 - y1, x3 - x1)*bj_RADTODEG
local real angledifference
set angledifference = ModuloReal(angle-(anglefacing+180),360) - 180
//call BJDebugMsg("AngleDifference: " +R2S(angledifference))
set source = null
set target = null
if angledifference <= arc/2.0 and angledifference >= -arc/2.0 then
return true
endif
return false
endfunction
//===========================================================================
function InitTrig_ShieldBlockByEffect120 takes nothing returns nothing
set gg_trg_ShieldBlockByEffect120 = CreateTrigger( )
call TriggerAddCondition( gg_trg_ShieldBlockByEffect120, Condition( function Trig_ShieldBlockByEffect60_Conditions ) )
endfunction
function Trig_ShieldPeriodicEval_Actions takes nothing returns nothing
local integer unitcount = BlzGroupGetSize(udg_SystemShieldedUnits)
local integer counter = 0
local unit u
local real shieldcurrenthp
local real shieldmaxhp
loop
exitwhen counter >= unitcount
set u = BlzGroupUnitAt(udg_SystemShieldedUnits, counter)
set udg_ShieldUnitIndex = GetUnitUserData(u)
set udg_ShieldIterationTrigger = gg_trg_ShieldPeriodicIterationTrigger
call TriggerExecute( gg_trg_ForAllShieldsOfUnit )
set udg_ShieldUnitIndex = GetUnitUserData(u)
set udg_ShieldEvent = 0.00
set udg_ShieldEvent = 4.00
set counter = counter + 1
endloop
set u = null
endfunction
//===========================================================================
function InitTrig_ShieldPeriodicEval takes nothing returns nothing
set gg_trg_ShieldPeriodicEval = CreateTrigger( )
call TriggerRegisterTimerExpireEventBJ( gg_trg_ShieldPeriodicEval, udg_SystemShieldPeriodicTimer )
call TriggerAddAction( gg_trg_ShieldPeriodicEval, function Trig_ShieldPeriodicEval_Actions )
endfunction
function Trig_RemoveShield_Actions takes nothing returns nothing
local integer shieldindex = udg_ShieldIndex
if ( udg_ShieldIndex != 0 ) then
if ( udg_SystemShieldListInUse <= 1 ) then
set udg_ShieldLastOfIDRemoved = false
set udg_ShieldUnitIndex = GetUnitUserData(udg_ShieldedUnit[udg_ShieldIndex])
// Adjust shield lists
if ( udg_ShieldNextSame[udg_ShieldIndex] == 0 ) then
// Next same does not exist
if ( udg_ShieldPrevSame[udg_ShieldIndex] == 0 ) then
// Next same, Prev same do not exist
// Last of type being removed
set udg_ShieldLastOfIDRemoved = true
// Check diff shield values, to see if it's head, tail, or middle removal
if ( udg_ShieldNextDiff[udg_ShieldIndex] == 0 ) then
if ( udg_ShieldPrevDiff[udg_ShieldIndex] == 0 ) then
// Only buff remaining
set udg_UnitFirstShield[udg_ShieldUnitIndex] = 0
set udg_UnitLastShield[udg_ShieldUnitIndex] = 0
call GroupRemoveUnitSimple( udg_ShieldedUnit[udg_ShieldIndex], udg_SystemShieldedUnits )
else
// no next, has prev, is on tail end of diff list
set udg_UnitLastShield[udg_ShieldUnitIndex] = udg_ShieldPrevDiff[udg_ShieldIndex]
set udg_ShieldNextDiff[udg_ShieldPrevDiff[udg_ShieldIndex]] = 0
endif
else
if ( udg_ShieldPrevDiff[udg_ShieldIndex] == 0 ) then
// Has next, no prev. Is head of diff list
set udg_UnitFirstShield[udg_ShieldUnitIndex] = udg_ShieldNextDiff[udg_ShieldIndex]
set udg_ShieldPrevDiff[udg_ShieldNextDiff[udg_ShieldIndex]] = 0
else
// has next, has prev, is in middle of diff list
set udg_ShieldPrevDiff[udg_ShieldNextDiff[udg_ShieldIndex]] = udg_ShieldPrevDiff[udg_ShieldIndex]
set udg_ShieldNextDiff[udg_ShieldPrevDiff[udg_ShieldIndex]] = udg_ShieldNextDiff[udg_ShieldIndex]
endif
endif
else
// On tail end of same list
set udg_ShieldNextSame[udg_ShieldPrevSame[udg_ShieldIndex]] = 0
endif
else
// Next same exists
if ( udg_ShieldPrevSame[udg_ShieldIndex] == 0 ) then
// On head of same list
set udg_ShieldPrevSame[udg_ShieldNextSame[udg_ShieldIndex]] = 0
if ( udg_ShieldNextDiff[udg_ShieldIndex] == 0 ) then
if ( udg_ShieldPrevDiff[udg_ShieldIndex] == 0 ) then
// No next, no prev. Only type
set udg_UnitFirstShield[udg_ShieldUnitIndex] = udg_ShieldNextSame[udg_ShieldIndex]
set udg_UnitLastShield[udg_ShieldUnitIndex] = udg_ShieldNextSame[udg_ShieldIndex]
else
// no next, has prev, is on tail end of diff list
set udg_UnitLastShield[udg_ShieldUnitIndex] = udg_ShieldNextSame[udg_ShieldIndex]
set udg_ShieldNextDiff[udg_ShieldPrevDiff[udg_ShieldIndex]] = udg_ShieldNextSame[udg_ShieldIndex]
set udg_ShieldPrevDiff[udg_ShieldNextSame[udg_ShieldIndex]] = udg_ShieldPrevDiff[udg_ShieldIndex]
endif
else
if ( udg_ShieldPrevDiff[udg_ShieldIndex] == 0 ) then
// Has next, no prev. Is head of diff list
set udg_UnitFirstShield[udg_ShieldUnitIndex] = udg_ShieldNextSame[udg_ShieldIndex]
set udg_ShieldPrevDiff[udg_ShieldNextDiff[udg_ShieldIndex]] = udg_ShieldNextSame[udg_ShieldIndex]
set udg_ShieldNextDiff[udg_ShieldNextSame[udg_ShieldIndex]] = udg_ShieldNextDiff[udg_ShieldIndex]
else
// has next, has prev, is in middle of diff list
set udg_ShieldPrevDiff[udg_ShieldNextDiff[udg_ShieldIndex]] = udg_ShieldNextSame[udg_ShieldIndex]
set udg_ShieldNextDiff[udg_ShieldPrevDiff[udg_ShieldIndex]] = udg_ShieldNextSame[udg_ShieldIndex]
set udg_ShieldNextDiff[udg_ShieldNextSame[udg_ShieldIndex]] = udg_ShieldNextDiff[udg_ShieldIndex]
set udg_ShieldPrevDiff[udg_ShieldNextSame[udg_ShieldIndex]] = udg_ShieldPrevDiff[udg_ShieldIndex]
endif
endif
else
// In middle of same list
set udg_ShieldNextSame[udg_ShieldPrevSame[udg_ShieldIndex]] = udg_ShieldNextSame[udg_ShieldIndex]
set udg_ShieldPrevSame[udg_ShieldNextSame[udg_ShieldIndex]] = udg_ShieldPrevSame[udg_ShieldIndex]
endif
endif
call TriggerExecute( udg_ShieldRemoved[udg_ShieldIndex] )
set udg_ShieldIndex = shieldindex
set udg_ShieldEvent = 0.00
set udg_ShieldEvent = 2.00
// Just in case the event somehow changed the shieldindex
set udg_ShieldIndex = shieldindex
set udg_SystemShieldFreeIndexCurrent = ( udg_SystemShieldFreeIndexCurrent - 1 )
set udg_SystemShieldFreeIndexes[udg_SystemShieldFreeIndexCurrent] = udg_ShieldIndex
call FlushChildHashtable(udg_ShieldTable, udg_ShieldIndex)
//call BJDebugMsg("Shield removed: "+I2S(udg_ShieldIndex))
else
// If list in use, do not remove entries yet, could affect traversal of list
// Add shields to be removed into a queue
if udg_SystemShieldFlaggedRemove[udg_ShieldIndex] == false then
set udg_SystemShieldFlaggedRemove[udg_ShieldIndex] = true
set udg_SystemShieldsRemovalQueueIndex = ( udg_SystemShieldsRemovalQueueIndex + 1 )
set udg_SystemShieldsRemovalQueue[udg_SystemShieldsRemovalQueueIndex] = udg_ShieldIndex
endif
endif
else
endif
endfunction
//===========================================================================
function InitTrig_RemoveShield takes nothing returns nothing
set gg_trg_RemoveShield = CreateTrigger( )
call TriggerAddAction( gg_trg_RemoveShield, function Trig_RemoveShield_Actions )
endfunction
function Trig_ForAllShieldsOfUnit_Actions takes nothing returns nothing
local integer counter
local integer previndex = udg_ShieldIndex
local integer shieldindex
local trigger iterationtrigger = udg_ShieldIterationTrigger
local integer unitindex = udg_ShieldUnitIndex
local integer topshield = udg_UnitFirstShield[udg_ShieldUnitIndex]
local integer queuedshields
local boolean baseiteration = false
if ( udg_SystemShieldListInUse == 0 ) then
set udg_SystemShieldsRemovalQueueIndex = -1
set baseiteration = true
endif
set udg_SystemShieldListInUse = ( udg_SystemShieldListInUse + 1 )
set udg_ShieldIndex = udg_UnitFirstShield[udg_ShieldUnitIndex]
set udg_SystemShieldIterationStop = false
loop
exitwhen topshield == 0 or udg_SystemShieldIterationStop
set udg_ShieldIndex = topshield
loop
exitwhen udg_ShieldIndex == 0 or udg_SystemShieldIterationStop
if udg_SystemShieldFlaggedRemove[udg_ShieldIndex] == false or udg_ShieldIterationTrigger == gg_trg_RemoveShield then
set shieldindex = udg_ShieldIndex
set udg_ShieldIterationTrigger = iterationtrigger
call TriggerExecute( udg_ShieldIterationTrigger )
set udg_ShieldIndex = shieldindex
endif
set udg_ShieldIndex = udg_ShieldNextSame[udg_ShieldIndex]
endloop
set topshield = udg_ShieldNextDiff[topshield]
endloop
// If any shields were queued to be removed, remove them after list traversal is done
if ( baseiteration and udg_SystemShieldsRemovalQueueIndex >= 0 ) then
call BJDebugMsg("Index: "+I2S(udg_SystemShieldsRemovalQueueIndex))
call BJDebugMsg("Removing shields in queue")
set counter = 0
loop
exitwhen counter > udg_SystemShieldsRemovalQueueIndex
set udg_ShieldIndex = udg_SystemShieldsRemovalQueue[counter]
set queuedshields = udg_SystemShieldsRemovalQueueIndex
call TriggerExecute( gg_trg_RemoveShield )
set udg_SystemShieldsRemovalQueueIndex = queuedshields
set counter = counter + 1
endloop
else
endif
set udg_ShieldUnitIndex = unitindex
set iterationtrigger = null
set udg_SystemShieldListInUse = ( udg_SystemShieldListInUse - 1 )
set udg_ShieldIndex = previndex
endfunction
//===========================================================================
function InitTrig_ForAllShieldsOfUnit takes nothing returns nothing
set gg_trg_ForAllShieldsOfUnit = CreateTrigger( )
call TriggerAddAction( gg_trg_ForAllShieldsOfUnit, function Trig_ForAllShieldsOfUnit_Actions )
endfunction
function Trig_ForAllShieldsOfUnitDisplayOrder_Actions takes nothing returns nothing
local integer counter
local integer shieldindex
local trigger iterationtrigger = udg_ShieldIterationTrigger
local integer unitindex = udg_ShieldUnitIndex
local integer topshield = udg_UnitFirstShield[udg_ShieldUnitIndex]
local integer queuedshields
local boolean baseiteration = false
if ( udg_SystemShieldListInUse == 0 ) then
set udg_SystemShieldsRemovalQueueIndex = -1
set baseiteration = true
endif
set udg_SystemShieldListInUse = ( udg_SystemShieldListInUse + 1 )
set udg_ShieldIndex = udg_UnitFirstShield[udg_ShieldUnitIndex]
set udg_SystemShieldIterationStop = false
loop
exitwhen topshield == 0 or udg_SystemShieldIterationStop
set udg_ShieldIndex = topshield
loop
exitwhen udg_ShieldNextSame[udg_ShieldIndex] == 0
set udg_ShieldIndex = udg_ShieldNextSame[udg_ShieldIndex]
endloop
loop
exitwhen udg_ShieldIndex == 0 or udg_SystemShieldIterationStop
if udg_SystemShieldFlaggedRemove[udg_ShieldIndex] == false or udg_ShieldIterationTrigger == gg_trg_RemoveShield then
set shieldindex = udg_ShieldIndex
set udg_ShieldIterationTrigger = iterationtrigger
call TriggerExecute( udg_ShieldIterationTrigger )
set udg_ShieldIndex = shieldindex
endif
set udg_ShieldIndex = udg_ShieldPrevSame[udg_ShieldIndex]
endloop
set topshield = udg_ShieldNextDiff[topshield]
endloop
// If any shields were queued to be removed, remove them after list traversal is done
if ( baseiteration and udg_SystemShieldsRemovalQueueIndex >= 0 ) then
call BJDebugMsg("Index: "+I2S(udg_SystemShieldsRemovalQueueIndex))
call BJDebugMsg("Removing shields in queue")
set counter = 0
loop
exitwhen counter > udg_SystemShieldsRemovalQueueIndex
set udg_ShieldIndex = udg_SystemShieldsRemovalQueue[counter]
set queuedshields = udg_SystemShieldsRemovalQueueIndex
call TriggerExecute( gg_trg_RemoveShield )
set udg_SystemShieldsRemovalQueueIndex = queuedshields
set counter = counter + 1
endloop
else
endif
set udg_ShieldUnitIndex = unitindex
set iterationtrigger = null
set udg_SystemShieldListInUse = ( udg_SystemShieldListInUse - 1 )
endfunction
//===========================================================================
function InitTrig_ForAllShieldsOfUnitDisplayOrder takes nothing returns nothing
set gg_trg_ForAllShieldsOfUnitDisplayOrder = CreateTrigger( )
call TriggerAddAction( gg_trg_ForAllShieldsOfUnitDisplayOrder, function Trig_ForAllShieldsOfUnitDisplayOrder_Actions )
endfunction
function Trig_ForAllShieldsOfUnitBackward_Actions takes nothing returns nothing
local integer counter
local integer shieldindex
local trigger iterationtrigger = udg_ShieldIterationTrigger
local integer unitindex = udg_ShieldUnitIndex
local integer topshield = udg_UnitLastShield[udg_ShieldUnitIndex]
local integer queuedshields
local boolean baseiteration = false
if ( udg_SystemShieldListInUse == 0 ) then
set udg_SystemShieldsRemovalQueueIndex = -1
set baseiteration = true
endif
set udg_SystemShieldListInUse = ( udg_SystemShieldListInUse + 1 )
set udg_ShieldIndex = udg_UnitLastShield[udg_ShieldUnitIndex]
set udg_SystemShieldIterationStop = false
loop
exitwhen topshield == 0 or udg_SystemShieldIterationStop
set udg_ShieldIndex = topshield
loop
exitwhen udg_ShieldNextSame[udg_ShieldIndex] == 0
set udg_ShieldIndex = udg_ShieldNextSame[udg_ShieldIndex]
endloop
loop
exitwhen udg_ShieldIndex == 0 or udg_SystemShieldIterationStop
if udg_SystemShieldFlaggedRemove[udg_ShieldIndex] == false or udg_ShieldIterationTrigger == gg_trg_RemoveShield then
set shieldindex = udg_ShieldIndex
set udg_ShieldIterationTrigger = iterationtrigger
call TriggerExecute( udg_ShieldIterationTrigger )
set udg_ShieldIndex = shieldindex
endif
set udg_ShieldIndex = udg_ShieldPrevSame[udg_ShieldIndex]
endloop
set topshield = udg_ShieldPrevDiff[topshield]
endloop
// If any shields were queued to be removed, remove them after list traversal is done
if ( baseiteration and udg_SystemShieldsRemovalQueueIndex >= 0 ) then
call BJDebugMsg("Index: "+I2S(udg_SystemShieldsRemovalQueueIndex))
call BJDebugMsg("Removing shields in queue")
set counter = 0
loop
exitwhen counter > udg_SystemShieldsRemovalQueueIndex
set udg_ShieldIndex = udg_SystemShieldsRemovalQueue[counter]
set queuedshields = udg_SystemShieldsRemovalQueueIndex
call TriggerExecute( gg_trg_RemoveShield )
set udg_SystemShieldsRemovalQueueIndex = queuedshields
set counter = counter + 1
endloop
else
endif
set udg_ShieldUnitIndex = unitindex
set iterationtrigger = null
set udg_SystemShieldListInUse = ( udg_SystemShieldListInUse - 1 )
endfunction
//===========================================================================
function InitTrig_ForAllShieldsOfUnitBackward takes nothing returns nothing
set gg_trg_ForAllShieldsOfUnitBackward = CreateTrigger( )
call TriggerAddAction( gg_trg_ForAllShieldsOfUnitBackward, function Trig_ForAllShieldsOfUnitBackward_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function KB3D_Features_JASS takes nothing returns nothing
// Those Values are Required for the KB
// ------------------------------------------------
// ------------------------
// Knock-Backed Unit, the Knock-Backed Unit who all actions orbit around
set udg_KB3D_Unit = null
// Requires: NONE
// ------------------------
// Max Range, Maximum Range possible of the Knock-Back
set udg_KB3D_Range = 0.00
// Requires: NONE
// ------------------------
// Base KB Speed, Base Speed when starting the Knock-Back
set udg_KB3D_Speed = 0.00
// Requires: NONE
// ------------------------
// Angle, The KB's line angle, this will be useless if KB3D_Targeted_Unit is not null
set udg_KB3D_Angle = 0.00
// Requires: NONE
// ------------------------
// ------------------------------------------------
// Those Values are Optional for the KB
// NOTE: some values may depend on other to function, like LineDamage that needs "Damager, AttackType, DamageType, AoE" to function
// ------------------------------------------------
// ------------------------
// Targets Allowed
// ------------------------
// Filter Damages and AoEKB with those values, if true, each one will allow filtering of Structures, Mechanicals, Magic Imminues, Allies
// ------------------------
set udg_KB3D_D_MAGIC_IMMINUE = false
set udg_KB3D_D_ALLY = false
set udg_KB3D_D_MECHANICAL = false
set udg_KB3D_D_STRUCTURE = false
set udg_KB3D_D_ENEMY = true
set udg_KB3D_D_FLYING = false
set udg_KB3D_D_RESISTANT = false
// Requires: AoEKB, or, Damagers, or, BounceTarget
// ------------------------
// Speed Changer, makes the unit move forward with a bonus speed equal to the KB speed, negative speed also works
set udg_KB3D_Speed_Changer = false
// Requires: NONE, Disables Angle
// ------------------------
// Homing Missile, automatically sets needed features of KB3D for a homing missile
set udg_KB3D_HomingMissile = true
// Requires: NONE, Disables Angle
// ------------------------
// Bounce Unit, Makes the KBed unit bounce on unpathable areas and units
set udg_KB3D_Bounce_Unit = false
// Requires: NONE
// ------------------------
// Bounce Targets, Bounces units that encounter the KBed unit
set udg_KB3D_Bounce_Target = false
// Requires: AoE
// ------------------------
// End on Target Bounce, when hits a unit, ends the KB
set udg_KB3D_EndOnTargetBounce = false
// Requires: Bounce_Target
// ------------------------
// Bounce Power, intensity of the Bounce
set udg_KB3D_Bounce_Power = 1.00
// Requires: Bounce
// ------------------------
// Bounce Effect, Effect created on units that get Bounced
set udg_KB3D_Bounce_Fx = ""
// Requires: Bounce
// ------------------------
// Destroy Destructibles, Destroys any destructibles on the path of the KB, does not destroy platforms, bridges, elevators
set udg_KB3D_DestroyDestructables = false
// Requires: Line Damage
// ------------------------
// Line Effect, Effect created on units damaged by Line Damage
set udg_KB3D_Line_Fx = ""
// Requires: Line Damage
// ------------------------
// End Trigger, This trigger will be excecuted at the end of the KB, you can use KB3D_Unit and KB3D_Targeted_Unit variables in the trigger
set udg_KB3D_EndTrigger = udg_KB3D_EndTrigger
// Requires: NONE
// ------------------------
// End on Obstacle, Immediatly Ends the KB if the KBed unit encounters an unpathable area
set udg_KB3D_EndOnObstacle = false
// Requires: NONE
// ------------------------
// Arc, Arc of the Angle of the KB, does not work with homing KB
set udg_KB3D_Arc = 0.00
// Requires: Angle
// ------------------------
// Ending Effect, an Effect created at the End of the KB on the KBed Unit
set udg_KB3D_EndFx = ""
// Requires: AoE
// ------------------------
// AoE End Damage, Damage dealt to enemy units in the AoE at the End of the KB
set udg_KB3D_AoEEndDamage = 0.00
// Requires: AoE, Damager, AType, DType
// ------------------------
// AoE KB, if true, KBs Enemy units within the AoE, Range, Speed, Angle, are automatic
set udg_KB3D_AoEKB = false
// Requires: AoE
// ------------------------
// AoE KB Power, The Power of the AoE KB, default value is 1.00 (normal), Min value: 0.01, Max value: 3.00
set udg_KB3D_AoEKB_Power = 0.00
// Requires: AoEKB
// ------------------------
// End when Dead, if true, the KB will end if the KBed unit is dead, TRUE by default
set udg_KB3D_EndwhenDead = true
// Requires: NONE
// ------------------------
// Ground Damage, Damages the Unit When it hits the Ground, Damage dealt is KB3D_ImpactDamage
set udg_KB3D_GroundDamage = false
// Requires: Damager, ImpactDamage, AType, DType
// ------------------------
// KB the Target, When the Targeted Unit is hit, it will be KBed depending on the speed of the original KB
set udg_KB3D_KBTarget = false
// Requires: Targeted_Unit
// ------------------------
// Stop Time, Maximum Time the KB will last, Note that if the KBed unit is flying at this time, it will be stuck
set udg_KB3D_StopTime = 0.00
// Requires: NONE
// ------------------------
// Kill at End, Kills the KBed Unit at the End of the KB
set udg_KB3D_KillatEnd = false
// Requires: NONE
// ------------------------
// Kill at Time, When this time is reached, the KBed unit will be killed, if this number is higher than KB3D_StopTime, EndWhenDead will be automatically turned on no matter what
set udg_KB3D_KillatTime = 0.00
// Requires: NONE
// ------------------------
// Acceleration, Speed Added/s to the KB speed
set udg_KB3D_Accel = 0.00
// Requires: NONE
// ------------------------
// Allow going outside playable bounds, Allows the KBed unit to go out of the Playable Bounds, SAFETY notice: this will not crash the game
set udg_KB3D_AllowOutSiding = false
// Requires: NONE
// ------------------------
// Area of Effect, Range where the Line Damage is applied to units
set udg_KB3D_AoE = 0.00
// Requires: NONE
// ------------------------
// Area of Effect Damage, Makes the KB3D_Damager, damage enemy units within KB3D_AoE by this value as a DPS
set udg_KB3D_AoEDamage = 0.00
// Requires: AoE, Damager, DType, AType
// ------------------------
// Attack Type, Attack type of ALL damagings in the Instance
set udg_KB3D_AttackType = ATTACK_TYPE_MELEE
// Requires: NONE
// ------------------------
// Damage Type, Damage type of ALL damagings in the Instance
set udg_KB3D_DamageType = DAMAGE_TYPE_MAGIC
// Requires: NONE
// ------------------------
// Damager, Source of ALL damagings in the Instance
set udg_KB3D_Damager = null
// Requires: NONE
// ------------------------
// Destroy Trees?, Destroy Trees around the KBed unit while he is KBed?
set udg_KB3D_DestroyTree = true
// Requires: NONE
// ------------------------
// Disable Unit?, Disable the KBed Unit's Movement and Turning?
set udg_KB3D_DisableUnit = false
// Requires: NONE
// ------------------------
// End When Hit?, Ends the KB if the KBed Unit hits the Targeted Unit
set udg_KB3D_EndWhenHit = false
// Requires: Targeted_Unit
// ------------------------
// Face KB Anlge, makes the KBed Unit Face the Anlge of the KB during the KB
set udg_KB3D_FaceAngle = false
// Requires: NONE
// ------------------------
// Effect, Effect created on the Unit's Location if he is not flying, and applied on the Unit if he is flying on the Attach Point
set udg_KB3D_Fx = ""
// Requires: Attach
// ------------------------
// Attachment Point, location on the KBed unit where Effects are attached
set udg_KB3D_Attach = ""
// Requires: NONE
// ------------------------
// AoE End Effect, Effect Created on target units in the AoE at the End of the KB
set udg_KB3D_AoEEndFx = ""
// Requires: AoE, Attach
// ------------------------
// Impact Damage, Damaged dealt to the KBed Unit if he hits an obstacle
set udg_KB3D_ImpactDamage = 0.00
// Requires: Damager
// ------------------------
// intelligent KB, Enables the intelligent features of KB3D, see Main Code Comments for more info
set udg_KB3D_iKB = true
// Requires: NONE
// ------------------------
// Kill When Hit?, Kills the KBed Unit if he hits the Targeted Unit, Automatically set EndWhenHit to true
set udg_KB3D_KillWhenHit = false
// Requires: Targeted_Unit
// ------------------------
// Kill if Out of Playable Bounds, Kills the KBed Unit if he gets out of Playable Bounds, this automatically sets KB3D_AllowOutSiding to TRUE
set udg_KB3D_KillifOutSider = false
// Requires: AllowOutSiding
// ------------------------
// Line Damage, Damage dealt to enemy units in the AoE around the KBed Unit
set udg_KB3D_LineDamage = 0.00
// Requires: Damager, AoE
// ------------------------
// Loop Damage, DPS dealt to the KBed Unit
set udg_KB3D_LoopDamage = 0.00
// Requires: Damager, AoE
// ------------------------
// Jump over Cliff, Allows the KBed unit to go over cliffs if he has more than 150 fly height and IF there is a possible location where he can land in a pathable point, not recommended with >0 Acceleration
set udg_KB3D_JumpOverCliff = false
// Requires: NONE
// ------------------------
// Target Damage, Damage dealt to the Targeted Unit when both KBed Unit and Targeted Unit hit each other, only happens once
set udg_KB3D_TargetDamage = 0.00
// Requires: Targeted_Unit, Damager
// ------------------------
// Targeted Unit, if not null, makes the KBed Unit act like a homing missile targeting this unit, it also used for other functions
set udg_KB3D_Targeted_Unit = null
// Requires: NONE
// ------------------------
// Trail Effect, Effect Attached on the KBed Unit all along the Knock-Back and Destroyed at the end of the KB
set udg_KB3D_TrailFx = ""
// Requires: Attach
// ------------------------
// Stop at Unpathable, Makes it impossible for the KBed Unit to path throught Unpathable Terrain
set udg_KB3D_UnpathableStop = true
// Requires: NONE
// ------------------------
// Z Offset, Max Flying Height reached while Knockbacking
set udg_KB3D_Zoffset = 0.00
// Requires: NONE
// ------------------------
// ------------------------------------------------
// Registed All of the Settings
call ExecuteFunc( "KB3D_Registration" )
// You can use the following to know how much the knock-back will last -- this can vary if the KB is homed on a moving unit
set udg_KB3D_Time = udg_KB3D_Time
endfunction
//===========================================================================
function InitTrig_KB3D_Features_JASS takes nothing returns nothing
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
/////////////////////////////////////////////////////////////////////////////
// //
// Knock-Back 3D [JASS - GUI] V. 3.2.1 //
// Multi-Movement System 3D //
// by Jad aka DotCa and T.D.W. //
// //
/////////////////////////////////////////////////////////////////////////////
// //
// System's Hidden Features: //
// //
// 1. To know if a unit is being KBed by the System, Use: //
// - LoadBoolean(udg_KB3D_HA, GetHandleId(Unit), GetHandleId(Unit)) //
// True means that the unit is being KBed, also works in GUI //
// 2. Use udg_KB3D_Time variable after registring the KB to actually //
// know how much the KB will last, NOTE that this the time may //
// varry if you have a Homing KB (using KB3D_Targeted_Unit) //
// 3. Some Variables in the System has default values, but useful; //
// in Example, "udg_KB3D_Attach" is "origin" even without setting //
// it, so you won't need to change it before Registering a KB //
// 4. You can get the ID of a Knockback after registrating it by //
// using the value of KB3D_Counter //
// 5. You can remove any KB on a specific unit by setting KB3D_Remove //
// KB3D_RemoveUnit to this Unit, and then calling the function: //
// "KB3D_RemoveUnit() //
// 6. You can know what caused the end of a KB in the EndTrigger by //
// checking those variables: KB3D_EndisUnit / KB3D_EndisUnpathable //
// KB3D_EndisNormal //
// 7. You can use the following Pause/Resume functions on a specific //
// KB instance or on all the system //
// - KB3D_Pause( ID ) Applies on a single KB //
// - KB3D_Resume( ID ) Applies on a single KB //
// - KB3D_PauseAll() Applies on a All KB Instances //
// - KB3D_ResumeAll() Applies on a All KB Instances //
// - KB3D_PauseRegistration() Applies on a All KB Instances //
// - KB3D_ResumeRegistration() Applies on a All KB Instances //
// //
/////////////////////////////////////////////////////////////////////////////
// //
// System Informations: //
// //
// The System is a well performing, ultra-purpose knockback (see uses //
// below ) Coded in JASS making it possible for all users to take //
// advantage of it, and GUI friendly to use, see Examples in the triggers //
// above //
// Configurations that have default values: //
// //
// - KB3D_EndWhenDead ==> TRUE by default //
// - KB3D_UnpathableStop ==> TRUE by default //
// - KB3D_iKB ==> TRUE by default //
// - KB3D_D_ENEMY ==> TRUE by default //
// - KB3D_DestroyTree ==> TRUE by default //
// - KB3D_AttackType ==> ATTACK_TYPE_NORMAL by default //
// - KB3D_DamageType ==> DAMAGE_TYPE_MAGIC by default //
// - KB3D_AoEKB_Power ==> 1.00 by default //
// - KB3D_Attach ==> "origin" by default //
// - Other Booleans ==> FALSE by default //
// //
// The System also uses Always positive values for some configurations //
// to not make the knockback go wrong, those configurations are: //
// //
// "KB3D_Range" - "KB3D_Speed" - "KB3D_ZOffset" - "KB3D_AoE" //
// //
/////////////////////////////////////////////////////////////////////////////
// //
// HomingMissile, Accessibility feature //
// //
// When true, there will be no need to set the range and some other //
// features, since they will be automatically set to fit a homing //
// missile: //
// - KB3D_Zoffset - KB3D_Range - KB3D_KillatEnd - KB3D_EndWhenHit - //
// - KB3D_FaceAngle - KB3D_UnpathableStop - KB3D_KillWhenHit - //
// //
// This feature allows to skip the configurations of some features //
// needed for a homing missile, Note that Targeted_Unit needs to be set //
// //
/////////////////////////////////////////////////////////////////////////////
// //
// iKB, intelligent KB informations: //
// //
// iKB, makes some features in KB3D act intelligently, those features: //
// //
// -Range: usually always positive, it will be available in negative //
// values, it will, if negative, flip the Angle (+180 d) //
// -Speed: usually always positive, it will be available in negative //
// values, it will act normally, just the KBed unit will //
// move backward if the current speed is negative //
// -Height: usually always positive, it will be available in negative//
// values, it will, if negative, make the unit go down //
// instead of up //
// -Damages: //
// AoEEndDamage, AoEDamage, LineDamage, ImpactDamage, TargetDamage //
// //
// All those values ^ will turn intelligent, by this, it means //
// that if the Target of the Damage is not in approximated //
// height (Z) of the KBed Unit, the damage won't occur //
// -AoEKB, usually KBs all units in the AoE, it will choose only //
// Units that are close to it by the height, Z offset //
// //
/////////////////////////////////////////////////////////////////////////////
// //
// System Requirements: Basic WE - (NONE) //
// //
// The System uses implemented CheckWalkability System by PurgeandFire //
// You "can" remove the initialization trigger of PnF's System since //
// it is directly implemented in the System, all will work fine with or //
// without removing your Initializer trigger //
// //
/////////////////////////////////////////////////////////////////////////////
// //
// Credits: //
// //
// *WEHZ & TS Helpers Group for helping in Script Fixes //
// *Barry the Moose for helping in main codes and fixes //
// *PurgeandFire for his CheckWalkability System //
// *Vexorian / Nestharus for the GetCollision function //
// //
/////////////////////////////////////////////////////////////////////////////
// //
// How to Import? //
// //
// 1. Check that Create Unknown Variables is ticked in your WE Settings //
// 2. Copy the Paste the Knock-Back 3D Folder //
// 3. Delete the Variable Creator Trigger and learn how to use the System //
// by reading the documentation in the 2 Features Triggers (GUI - JASS)//
// Congratulations, the System is now implemented in your map //
// //
/////////////////////////////////////////////////////////////////////////////
// //
// How to Use? //
// //
// 1. There are many Examples of use in the KB3D Example Folder //
// 2. Documentations are there in the Features Triggers to help you //
// 3. The KB3D System is an Ultra-Purpose System where you can use it for://
// -Projectiles, the system supports homing so a projectile is easy //
// -Jump, the System's smoothness in the fly is useful for a jump spell//
// -And of course, a 2D Knock-Back //
// -And More depending on your imagination //
// //
/////////////////////////////////////////////////////////////////////////////
// //
// Bug Reports - Feedbacks //
// //
// * We count on you to report bugs in the system, also telling the source//
// * Feedbacks about the system are much appreciated //
// * We mostly hope suggestions about enhancements for the System //
// //
/////////////////////////////////////////////////////////////////////////////
function KB3D_AlwaysNeg takes real R returns real
if R > 0 then
return -R
endif
return R
endfunction
function KB3D_InBetween takes real Min, real R, real Max returns real
return RMaxBJ(RMinBJ(R, Max), Min)
endfunction
function KB3D_IsInBetween takes real Min, real R, real Max returns boolean
return R > Min and R < Max
endfunction
function KB3D_CW_Loop takes nothing returns nothing
if IsItemVisible(GetEnumItem()) then
set udg_CP_HiddenItems[udg_CP_HiddenItemsIndex] = GetEnumItem()
call SetItemVisible(udg_CP_HiddenItems[udg_CP_HiddenItemsIndex], false)
set udg_CP_HiddenItemsIndex = ( udg_CP_HiddenItemsIndex + 1 )
endif
endfunction
function KB3D_CW takes real x, real y returns boolean
local real x2 = 0
local real y2 = 0
//---------------------------
call MoveRectTo(udg_CP_Rect, x, y)
call EnumItemsInRect(udg_CP_Rect, null, function KB3D_CW_Loop )
call SetItemPosition(udg_CP_Item, x, y)
set x2 = GetItemX(udg_CP_Item)
set y2 = GetItemY(udg_CP_Item)
call SetItemVisible(udg_CP_Item, false)
//---------------------------
loop
exitwhen udg_CP_HiddenItemsIndex == 0
set udg_CP_HiddenItemsIndex = udg_CP_HiddenItemsIndex - 1
call SetItemVisible(udg_CP_HiddenItems[udg_CP_HiddenItemsIndex], true)
set udg_CP_HiddenItems[udg_CP_HiddenItemsIndex] = null
endloop
//---------------------------
return (((x2-x)*(x2-x) + (y2-y)*(y2-y) <= 75) and (not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)))
endfunction
function KB3D_GetCoordinatesZ takes real x, real y returns real
local location L = Location(x,y)
local real r = 0
local integer I = 0
local integer t = 12
local boolean B = true
loop
exitwhen I == 12
if GetPlayerSlotState(Player(I)) != ConvertPlayerSlotState(1) then
set t = t - 1
else
if IsLocationFoggedToPlayer( L , Player(I)) then
set B = false
set t = t - 1
endif
endif
set I = I + 1
endloop
if B or t == 0 then
set r = GetLocationZ(L)
endif
call RemoveLocation(L)
set L = null
return r
endfunction
function KB3D_Approx takes unit U, unit U2, integer Loop returns boolean
local real r = KB3D_InBetween(50, LoadReal(udg_KB3D_HA, 29, Loop) / 2, 1000)
local real r1 = GetUnitFlyHeight(U2)
//---------------------------
return KB3D_IsInBetween(r1-r, GetUnitFlyHeight(U), r1+r)
endfunction
function KB3D_Filter takes unit U, unit U1, integer Loop returns boolean
if not IsUnitType(U, UNIT_TYPE_DEAD) then
//---------------------------
if not(LoadBoolean(udg_KB3D_HA, 48, Loop)) and ( IsUnitType(U, UNIT_TYPE_STRUCTURE)) then
return false
elseif not((LoadBoolean(udg_KB3D_HA, 48, Loop)) and ( IsUnitType(U, UNIT_TYPE_STRUCTURE))) then
if not(LoadBoolean(udg_KB3D_HA, 49, Loop)) and ( IsUnitType(U, UNIT_TYPE_MECHANICAL)) then
return false
endif
endif
//---------------------------
if not(LoadBoolean(udg_KB3D_HA, 50, Loop)) and ( IsUnitType(U, UNIT_TYPE_MAGIC_IMMUNE)) then
return false
endif
//---------------------------
if not(LoadBoolean(udg_KB3D_HA, 51, Loop)) and ( IsUnitAlly(U, GetOwningPlayer(U1))) then
return false
endif
//---------------------------
if not(LoadBoolean(udg_KB3D_HA, 63, Loop)) and ( IsUnitEnemy(U, GetOwningPlayer(U1))) then
return false
endif
//---------------------------
if not(LoadBoolean(udg_KB3D_HA, 64, Loop)) and ( IsUnitType(U, UNIT_TYPE_RESISTANT)) then
return false
endif
//---------------------------
if not(LoadBoolean(udg_KB3D_HA, 65, Loop)) and ( IsUnitType(U, UNIT_TYPE_FLYING)) then
return false
endif
//---------------------------
return true
endif
//---------------------------
return false
endfunction
function KB3D_RegisterUnitCollision 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.
call SaveReal( udg_KB3D_HA, 16, GetUnitTypeId(u), m )
//---------------------------
return m
endfunction
function KB3D_GetUnitCollision takes unit u returns real
local integer i = GetUnitTypeId(u)
//---------------------------
if HaveSavedReal( udg_KB3D_HA, 16, i) then
return LoadReal(udg_KB3D_HA, 16, i)
endif
//---------------------------
return KB3D_RegisterUnitCollision(u, GetUnitX(u), GetUnitY(u), i)
endfunction
function KB3D_Tree_Check takes destructable D returns boolean
return IssueTargetOrderById( udg_KB3D_Harvester, 852018, D ) and IssueImmediateOrderById(udg_KB3D_Harvester, 851972)
endfunction
function KB3D_KillEnumDest takes nothing returns nothing
local destructable D = GetEnumDestructable()
//---------------------------
if GetDestructableLife(D)>0 and ( KB3D_Tree_Check(D) ) and (GetUnitFlyHeight(LoadUnitHandle(udg_KB3D_HA, 0, R2I(udg_KB3D_Reals[0]))) < GetDestructableOccluderHeight(D)) and LoadBoolean(udg_KB3D_HA, 8, R2I(udg_KB3D_Reals[0])) then
call KillDestructable(D)
elseif /*not(KB3D_CW(GetDestructableX(D),GetDestructableY(D))) and*/ GetDestructableLife(D)>0 and not(KB3D_Tree_Check(D)) and LoadBoolean(udg_KB3D_HA, 56, R2I(udg_KB3D_Reals[0])) then
call KillDestructable(D)
endif
set D = null
endfunction
function KB3D_CircleTreeKill takes real radius, real x, real y returns nothing
local rect r = Rect(x-radius, y-radius, x+radius, y+radius)
//---------------------------
call EnumDestructablesInRect(r, null, function KB3D_KillEnumDest)
//---------------------------
call RemoveRect(r)
set r = null
endfunction
function KB3D_BounceOnUnit takes unit u, unit U, integer Loop returns nothing
set udg_KB3D_Angle = (Atan2(GetUnitY(u) - GetUnitY(U), GetUnitX(u) - GetUnitX(U)) *57.29578) + GetRandomReal(-15,15)
set udg_KB3D_Speed = LoadReal(udg_KB3D_HA, 2, Loop) / .03125 * .25 * LoadReal(udg_KB3D_HA, 59, Loop)
set udg_KB3D_DestroyTree = LoadBoolean(udg_KB3D_HA, 8, Loop)
set udg_KB3D_Fx = LoadStr(udg_KB3D_HA, 9, Loop)
set udg_KB3D_Attach = LoadStr(udg_KB3D_HA, 10, Loop)
set udg_KB3D_Range = 1.5*udg_KB3D_Speed*udg_KB3D_Bounce_Power
set udg_KB3D_Unit = u
set udg_KB3D_Bounce_Fx = LoadStr(udg_KB3D_HA, 62, Loop)
set udg_KB3D_Accel = -udg_KB3D_Speed*.6
set udg_KB3D_Bounce_Unit = true
call TriggerEvaluate(udg_KB3D_Registration)
call SaveEffectHandle(udg_KB3D_HA, 14, udg_KB3D_Counter, LoadEffectHandle(udg_KB3D_HA, 14, Loop))
endfunction
function KB3D_Bounce_Filter takes nothing returns boolean
local boolean b = not(IsUnitInGroup(GetFilterUnit(), LoadGroupHandle(udg_KB3D_HA, 68, R2I(udg_KB3D_Reals[0])))) or KB3D_Filter(LoadUnitHandle(udg_KB3D_HA, 0, R2I(udg_KB3D_Reals[0])),LoadUnitHandle(udg_KB3D_HA, 0, R2I(udg_KB3D_Reals[0])),R2I(udg_KB3D_Reals[0]))
if b then
call GroupAddUnit(LoadGroupHandle(udg_KB3D_HA, 68, R2I(udg_KB3D_Reals[0])), GetFilterUnit())
endif
return b
endfunction
function KB3D_FilterGrp takes nothing returns boolean
return KB3D_Filter(GetFilterUnit(), LoadUnitHandle(udg_KB3D_HA, 0, R2I(udg_KB3D_Reals[0])),R2I(udg_KB3D_Reals[0]))
endfunction
function KB3D_ClearInstance takes integer i returns nothing
local integer x = 0
//---------------------------
call DestroyGroup(LoadGroupHandle(udg_KB3D_HA, 27, i))
call DestroyGroup(LoadGroupHandle(udg_KB3D_HA, 67, i))
//---------------------------
loop
exitwhen x > 100
call RemoveSavedHandle(udg_KB3D_HA, x, i)
call SaveReal(udg_KB3D_HA, x, i, 0)
set x = x +1
endloop
endfunction
function KB3D_isPossiblePathability takes real x, real y, real RADangle, real MaxDist returns boolean
local real X = x
local real Y = y
local real max = RAbsBJ(MaxDist)
local real dist = max
//---------------------------
loop
exitwhen (dist <= 0)
set dist = dist - max/300
set X = x + ( dist * Cos(RADangle) )
set Y = y + ( dist * Sin(RADangle) )
if KB3D_CW(X,Y) then
return true
endif
endloop
//---------------------------
return false
endfunction
function MoveUnit_3D takes unit U, real x, real y, real z, real MaxZ, boolean P, boolean OS, boolean KiOS, real Angle, real S, real time, integer Loop returns boolean
local boolean B = false
local boolean b = true
local real tz
// CREEPY FUNCTION ALERT
if LoadBoolean(udg_KB3D_HA, 57, Loop) then
if LoadBoolean(udg_KB3D_HA, 44, Loop) then
set tz = KB3D_GetCoordinatesZ(x,y) - LoadReal(udg_KB3D_HA, 68, Loop)
set z = z - tz
call SaveReal(udg_KB3D_HA, 68, Loop, KB3D_GetCoordinatesZ(x,y))
if LoadReal(udg_KB3D_HA, 3, Loop)<0 and GetUnitDefaultFlyHeight(U)<z then
call SetUnitFlyHeight(U, KB3D_InBetween(-999,z,GetUnitDefaultFlyHeight(U)), 0)
else
call SetUnitFlyHeight(U, z, 0)
endif
else
call SetUnitFlyHeight(U, KB3D_InBetween(GetUnitDefaultFlyHeight(U), z, 9999), 0)
endif
endif
//---------------------------
if ( not(P) or ( KB3D_CW(x, y) ) ) then
set B = true
if (OS) then
call SetUnitX(U, KB3D_InBetween(udg_KB3D_Reals[6], x, udg_KB3D_Reals[5]))
call SetUnitY(U, KB3D_InBetween(udg_KB3D_Reals[8], y, udg_KB3D_Reals[7]))
set b = false
if (KiOS) and (not(KB3D_IsInBetween(udg_KB3D_Reals[2], x, udg_KB3D_Reals[1])) or not(KB3D_IsInBetween(udg_KB3D_Reals[4], x, udg_KB3D_Reals[3]))) then
call KillUnit(U)
endif
else
call SetUnitX(U, KB3D_InBetween(udg_KB3D_Reals[2], x, udg_KB3D_Reals[1]))
call SetUnitY(U, KB3D_InBetween(udg_KB3D_Reals[4], y, udg_KB3D_Reals[3]))
set b = false
endif
elseif LoadBoolean(udg_KB3D_HA, 52, Loop) and P and not(KB3D_CW(x, y)) then
if GetUnitFlyHeight(U) != 0 then
if KB3D_isPossiblePathability(GetUnitX(U),GetUnitY(U), Angle, S*time/0.03125) and LoadBoolean(udg_KB3D_HA, 44, Loop) then
set B = true
//call SaveBoolean(udg_KB3D_HA, 53, Loop, true)
if (OS) then
call SetUnitX(U, KB3D_InBetween(udg_KB3D_Reals[6], x, udg_KB3D_Reals[5]))
call SetUnitY(U, KB3D_InBetween(udg_KB3D_Reals[8], y, udg_KB3D_Reals[7]))
set b = false
if (KiOS) and (not(KB3D_IsInBetween(udg_KB3D_Reals[2], x, udg_KB3D_Reals[1])) or not(KB3D_IsInBetween(udg_KB3D_Reals[4], x, udg_KB3D_Reals[3]))) then
call KillUnit(U)
endif
else
call SetUnitX(U, KB3D_InBetween(udg_KB3D_Reals[2], x, udg_KB3D_Reals[1]))
call SetUnitY(U, KB3D_InBetween(udg_KB3D_Reals[4], y, udg_KB3D_Reals[3]))
set b = false
endif
else
call SaveBoolean(udg_KB3D_HA, 52, Loop, false)
endif
else
endif
endif
if b then
set udg_KB3D_B = true
if LoadBoolean(udg_KB3D_HA, 66, Loop) then
set udg_KB3D_EndisUnpathable = true
set udg_KB3D_EndisNormal = false
return true
endif
endif
return false
endfunction
function KB3D_LineDamageLoop takes unit U, group g returns nothing
local integer Loop = R2I(udg_KB3D_Reals[0])
local unit Damager = LoadUnitHandle(udg_KB3D_HA, 22, Loop)
local attacktype AType = ConvertAttackType(LoadInteger(udg_KB3D_HA, 20, Loop))
local damagetype DType = ConvertDamageType(LoadInteger(udg_KB3D_HA, 21, Loop))
local real LineD = LoadReal(udg_KB3D_HA, 28, Loop)
local unit U1 = LoadUnitHandle(udg_KB3D_HA, 0, Loop)
local group G = LoadGroupHandle(udg_KB3D_HA, 27, Loop)
//---------------------------
if KB3D_Filter(U, U1, Loop) and not ( IsUnitInGroup(U, G) ) then
call GroupAddUnit(G, U)
if not(LoadBoolean(udg_KB3D_HA, 44, Loop)) then
call UnitDamageTarget(Damager, U, LineD, true, false, AType, DType, null)
call DestroyEffect(AddSpecialEffectTarget(LoadStr(udg_KB3D_HA, 58, Loop), U, LoadStr(udg_KB3D_HA, 10, Loop)))
elseif KB3D_Approx(U, U1, Loop) then
call UnitDamageTarget(Damager, U, LineD, true, false, AType, DType, null)
call DestroyEffect(AddSpecialEffectTarget(LoadStr(udg_KB3D_HA, 58, Loop), U, LoadStr(udg_KB3D_HA, 10, Loop)))
endif
endif
//---------------------------
set G = null
set U1 = null
set Damager = null
set AType = null
set DType = null
endfunction
function KB3D_AoEDamageLoop takes unit U, group g returns nothing
local integer Loop = R2I(udg_KB3D_Reals[0])
local unit Damager = LoadUnitHandle(udg_KB3D_HA, 22, Loop)
local attacktype AType = ConvertAttackType(LoadInteger(udg_KB3D_HA, 20, Loop))
local damagetype DType = ConvertDamageType(LoadInteger(udg_KB3D_HA, 21, Loop))
local real AoED = LoadReal(udg_KB3D_HA, 32, Loop)
local unit U1 = LoadUnitHandle(udg_KB3D_HA, 0, Loop)
//---------------------------
if KB3D_Filter(U, U1, Loop) then
if not(LoadBoolean(udg_KB3D_HA, 44, Loop)) then
call UnitDamageTarget(Damager, U, AoED * 0.031250000, true, false, AType, DType, null)
elseif KB3D_Approx(U, U1, Loop) then
call UnitDamageTarget(Damager, U, AoED * 0.031250000, true, false, AType, DType, null)
endif
endif
//---------------------------
set U1 = null
set Damager = null
set AType = null
set DType = null
endfunction
function KB3D_AoEEndDamage takes unit U, group g returns nothing
local integer Loop = R2I(udg_KB3D_Reals[0])
local unit Damager = LoadUnitHandle(udg_KB3D_HA, 22, Loop)
local attacktype AType = ConvertAttackType(LoadInteger(udg_KB3D_HA, 20, Loop))
local damagetype DType = ConvertDamageType(LoadInteger(udg_KB3D_HA, 21, Loop))
local real D = LoadReal(udg_KB3D_HA, 38, Loop)
local unit U1 = LoadUnitHandle(udg_KB3D_HA, 0, Loop)
//---------------------------
if KB3D_Filter(U, U1, Loop) then
if not(LoadBoolean(udg_KB3D_HA, 44, Loop)) then
call UnitDamageTarget(Damager, U, D, true, false, AType, DType, null)
elseif KB3D_Approx(U, U1, Loop) then
call UnitDamageTarget(Damager, U, D, true, false, AType, DType, null)
endif
endif
//---------------------------
call GroupRemoveUnit(g, U)
//---------------------------
set U1 = null
set Damager = null
set AType = null
set DType = null
endfunction
function KB3D_GiveKBto takes unit U1, unit U2, integer Loop returns nothing
set udg_KB3D_AoEEndDamage = LoadReal(udg_KB3D_HA, 38, Loop)
set udg_KB3D_EndwhenDead = LoadBoolean(udg_KB3D_HA, 35, Loop)
set udg_KB3D_Speed = LoadReal(udg_KB3D_HA, 2, Loop)/0.031250000*.5
set udg_KB3D_Accel = -udg_KB3D_Speed
set udg_KB3D_AllowOutSiding = LoadBoolean(udg_KB3D_HA, 34, Loop)
set udg_KB3D_Angle = (LoadReal(udg_KB3D_HA, 5, Loop)*180/3.14159)
set udg_KB3D_AoE = LoadReal(udg_KB3D_HA, 29, Loop)
set udg_KB3D_AoEDamage = LoadReal(udg_KB3D_HA, 32, Loop)
set udg_KB3D_AttackType = ConvertAttackType(LoadInteger(udg_KB3D_HA, 20, Loop))
set udg_KB3D_DamageType = ConvertDamageType(LoadInteger(udg_KB3D_HA, 21, Loop))
set udg_KB3D_Damager = LoadUnitHandle(udg_KB3D_HA, 22, Loop)
set udg_KB3D_DestroyTree = LoadBoolean(udg_KB3D_HA, 8, Loop)
set udg_KB3D_DisableUnit = LoadBoolean(udg_KB3D_HA, 6, Loop)
set udg_KB3D_FaceAngle = LoadBoolean(udg_KB3D_HA, 31, Loop)
set udg_KB3D_Fx = LoadStr(udg_KB3D_HA, 9, Loop)
set udg_KB3D_Attach = LoadStr(udg_KB3D_HA, 10, Loop)
set udg_KB3D_ImpactDamage = LoadReal(udg_KB3D_HA, 17, Loop)
set udg_KB3D_LineDamage = LoadReal(udg_KB3D_HA, 28, Loop)
set udg_KB3D_LoopDamage = LoadReal(udg_KB3D_HA, 18, Loop)/0.031250000
set udg_KB3D_Range = 99999
set udg_KB3D_Unit = U1
if LoadBoolean(udg_KB3D_HA, 57, Loop) then
set udg_KB3D_Zoffset = LoadReal(udg_KB3D_HA, 3, Loop)/1.85 - GetUnitDefaultFlyHeight(U2)
endif
//---------------------------
call TriggerEvaluate( udg_KB3D_Registration )
endfunction
function KB3D_AoEGiveKBto takes unit U1, unit U2, integer Loop returns nothing
local real x1 = GetUnitX(U1)
local real y1 = GetUnitY(U1)
local real x2 = GetUnitX(U2)
local real y2 = GetUnitY(U2)
local real P = LoadReal(udg_KB3D_HA, 43, Loop)
//---------------------------
set udg_KB3D_AoE = LoadReal(udg_KB3D_HA, 29, Loop)
set udg_KB3D_EndwhenDead = LoadBoolean(udg_KB3D_HA, 35, Loop)
set udg_KB3D_Accel = -550*P
set udg_KB3D_AllowOutSiding = LoadBoolean(udg_KB3D_HA, 34, Loop)
set udg_KB3D_Angle = Atan2(y1 - y2, x1 - x2)*180/3.14159
set udg_KB3D_AoEDamage = LoadReal(udg_KB3D_HA, 32, Loop)
set udg_KB3D_AttackType = ConvertAttackType(LoadInteger(udg_KB3D_HA, 20, Loop))
set udg_KB3D_DamageType = ConvertDamageType(LoadInteger(udg_KB3D_HA, 21, Loop))
set udg_KB3D_Damager = LoadUnitHandle(udg_KB3D_HA, 22, Loop)
set udg_KB3D_DestroyTree = LoadBoolean(udg_KB3D_HA, 8, Loop)
set udg_KB3D_DisableUnit = LoadBoolean(udg_KB3D_HA, 6, Loop)
set udg_KB3D_FaceAngle = LoadBoolean(udg_KB3D_HA, 31, Loop)
set udg_KB3D_Fx = LoadStr(udg_KB3D_HA, 9, Loop)
set udg_KB3D_Attach = LoadStr(udg_KB3D_HA, 10, Loop)
set udg_KB3D_ImpactDamage = LoadReal(udg_KB3D_HA, 17, Loop)
set udg_KB3D_LineDamage = LoadReal(udg_KB3D_HA, 28, Loop)
set udg_KB3D_LoopDamage = LoadReal(udg_KB3D_HA, 18, Loop)/0.031250000
set udg_KB3D_Speed = udg_KB3D_AoE*2*P
set udg_KB3D_Range = udg_KB3D_Speed*2
set udg_KB3D_Unit = U1
if LoadBoolean(udg_KB3D_HA, 57, Loop) then
set udg_KB3D_Zoffset = (udg_KB3D_AoE - SquareRoot(x2 * x1 + y2 * y1)*3.14159/180)*P
endif
//---------------------------
call TriggerEvaluate( udg_KB3D_Registration )
endfunction
function KB3D_AoEKB takes unit U, group g returns nothing
local integer Loop = R2I(udg_KB3D_Reals[0])
local unit U1 = LoadUnitHandle(udg_KB3D_HA, 0, Loop)
local real r
//---------------------------
if KB3D_Filter(U, U1, Loop) then
if not(LoadBoolean(udg_KB3D_HA, 44, Loop)) then
call KB3D_AoEGiveKBto(U, U1, Loop)
elseif KB3D_Approx(U, U1, Loop) then
call KB3D_AoEGiveKBto(U, U1, Loop)
endif
endif
//---------------------------
call GroupRemoveUnit(g, U)
//---------------------------
set U1 = null
endfunction
function KB3D_AoEEndFx takes unit U, string A, string F, group g returns nothing
local integer Loop = R2I(udg_KB3D_Reals[0])
local unit U1 = LoadUnitHandle(udg_KB3D_HA, 0, Loop)
local real x
local real y
//---------------------------
if KB3D_Filter(U, U1, Loop) and (U != null) then
if not(LoadBoolean(udg_KB3D_HA, 44, Loop)) then
if ( GetUnitFlyHeight(U) > 20 ) then
call DestroyEffect(AddSpecialEffectTarget(F, U, A))
else
set x = GetUnitX(U)
set y = GetUnitY(U)
call DestroyEffect(AddSpecialEffect(F, x, y))
endif
elseif KB3D_Approx(U, U1, Loop) then
if ( GetUnitFlyHeight(U) > 20 ) then
call DestroyEffect(AddSpecialEffectTarget(F, U, A))
else
set x = GetUnitX(U)
set y = GetUnitY(U)
call DestroyEffect(AddSpecialEffect(F, x, y))
endif
endif
endif
//---------------------------
call GroupRemoveUnit(g, U)
//---------------------------
set U1 = null
endfunction
function KB3D_Grpto takes nothing returns nothing
call GroupAddUnit(udg_KB3D_g, GetEnumUnit())
endfunction
function KB3D_PointBounce takes real BAngle, real x, real y returns real
local real BAngle1 //bounce angle 1
local real BAngle2 //bounce angle 2
local real q //quadrant
set BAngle = BAngle*0.01745329251994329576923690768489
if 0<BAngle and BAngle<90 then
set q = 1
elseif 90<BAngle and BAngle<180 then
set q = 2
elseif 180<BAngle and BAngle<270 then
set q = 3
elseif 270<BAngle and BAngle<360 then
set q = 4
else
set q = BAngle/90 + 2
endif
set BAngle1 = q*90 - BAngle
set BAngle2 = - q*90 + BAngle + 90
if KB3D_isPossiblePathability(x, y, (BAngle - 2*BAngle2), 40) then
set BAngle = BAngle - 2*BAngle2
elseif KB3D_isPossiblePathability(x, y, (BAngle + 2*BAngle1), 40) then
set BAngle = BAngle + 2*BAngle1
endif
return BAngle
endfunction
function KB3D_Flyover takes real Zi, real Zf, real Yi, real Yf, real Xi, real Xf, real Speed, real dur, integer Loop returns nothing
local location Li = Location(Xi, Yi)
local location Lf = Location(Xf, Yf)
local real Xmax = Speed/0.03125*dur
local real Ymax = (GetLocationZ(Lf) - GetLocationZ(Li))*GetLocationZ(Lf)/Speed*Xmax ////BEWARE LOCATIONZ
if (GetLocationZ(Lf) - GetLocationZ(Li)) > 0.5 then
call SaveReal( udg_KB3D_HA, 74, Loop, GetLocationZ(Li) )
call BJDebugMsg("Sup")
elseif (GetLocationZ(Lf) - GetLocationZ(Li)) < -0.5 then
set Ymax = -(GetLocationZ(Lf) - LoadReal( udg_KB3D_HA, 74, Loop))*GetLocationZ(Lf)/Speed*Xmax
call SaveBoolean( udg_KB3D_HA, 75, Loop, false)
call BJDebugMsg(R2S(Ymax))
endif
endfunction
function KB3D_Loop takes integer Loop returns nothing
//Create all the nessesary locals
local unit U = LoadUnitHandle(udg_KB3D_HA, 0, Loop)
local real X = GetUnitX(U)
local real Y = GetUnitY(U)
local real Z = GetUnitFlyHeight(U)
local real x = X
local real y = Y
local real z = Z
local real Range = LoadReal(udg_KB3D_HA, 1, Loop)
local real Speed = LoadReal(udg_KB3D_HA, 2, Loop)
local real Zoffset = LoadReal(udg_KB3D_HA, 3, Loop)
local real Accel = LoadReal(udg_KB3D_HA, 4, Loop)
local real Angle
local real ZSpeed = LoadReal(udg_KB3D_HA, 12, Loop)
local real ZAccel = LoadReal(udg_KB3D_HA, 13, Loop)
local real ImpactD = LoadReal(udg_KB3D_HA, 17, Loop)
local real LoopD = LoadReal(udg_KB3D_HA, 18, Loop)
local real TargetD = LoadReal(udg_KB3D_HA, 19, Loop)
local real LineD = LoadReal(udg_KB3D_HA, 28, Loop)
local real AoE = LoadReal(udg_KB3D_HA, 29, Loop)
local real ZT = LoadReal(udg_KB3D_HA, 26, Loop)
local real AoED = LoadReal(udg_KB3D_HA, 32, Loop)
local real Time = LoadReal(udg_KB3D_HA, 41, Loop) + 0.031250000
local real KillatTime = LoadReal(udg_KB3D_HA, 36, Loop)
local real StopTime = LoadReal(udg_KB3D_HA, 37, Loop)
local real AoEEndDamage = LoadReal(udg_KB3D_HA, 38, Loop)
local real Flyover_dur = LoadReal(udg_KB3D_HA, 73, Loop)
local unit Target = LoadUnitHandle(udg_KB3D_HA, 5, Loop)
local unit Damager = LoadUnitHandle(udg_KB3D_HA, 22, Loop)
local unit u
local boolean DisableUnit = LoadBoolean(udg_KB3D_HA, 6, Loop)
local boolean UnpathableStop = LoadBoolean(udg_KB3D_HA, 7, Loop)
local boolean DestroyTree = LoadBoolean(udg_KB3D_HA, 8, Loop)
local boolean KillWhenHit = LoadBoolean(udg_KB3D_HA, 24, Loop)
local boolean EndWhenHit = LoadBoolean(udg_KB3D_HA, 25, Loop)
local boolean KiOS = LoadBoolean(udg_KB3D_HA, 33, Loop)
local boolean OS = LoadBoolean(udg_KB3D_HA, 34, Loop)
local boolean b = true
local boolean EndwhenDead = LoadBoolean(udg_KB3D_HA, 35, Loop)
local boolean KBTarget = LoadBoolean(udg_KB3D_HA, 39, Loop)
local boolean AoEKB = LoadBoolean(udg_KB3D_HA, 40, Loop)
local boolean KillatEnd = LoadBoolean(udg_KB3D_HA, 46, Loop)
local boolean GroundDamage = LoadBoolean(udg_KB3D_HA, 47, Loop)
local boolean EndB = false
local boolean EndOnObstacle = false
local boolean Flyover = LoadBoolean(udg_KB3D_HA, 72, Loop)
local string Fx = LoadStr(udg_KB3D_HA, 9, Loop)
local string Attach = LoadStr(udg_KB3D_HA, 10, Loop)
local string EndFx = LoadStr(udg_KB3D_HA, 42, Loop)
local string AoEEndFx = LoadStr(udg_KB3D_HA, 54, Loop)
local attacktype AType = ConvertAttackType(LoadInteger(udg_KB3D_HA, 20, Loop))
local damagetype DType = ConvertDamageType(LoadInteger(udg_KB3D_HA, 21, Loop))
local trigger EndT = LoadTriggerHandle(udg_KB3D_HA, 55, Loop)
//end of locals
//Loop Damage Execution
if LoopD != 0 and Damager != null then
call UnitDamageTarget(Damager, U, LoopD, true, false, AType, DType, null)
endif
//Calculate the Angle
if ( Target == null ) then
set Angle = LoadReal(udg_KB3D_HA, 5, Loop) + LoadReal(udg_KB3D_HA, 30, Loop)//if there is no unit target
else
set Angle = Atan2(GetUnitY(Target) - Y, GetUnitX(Target) - X)//if there is a unit target
endif
//
if LoadBoolean(udg_KB3D_HA, 16, Loop) then
set Angle = GetUnitFacing(U)*0.0174533
if LoadBoolean(udg_KB3D_HA, 44, Loop) then
if GetUnitCurrentOrder(U) != 851986 and GetUnitCurrentOrder(U) != 851971 then
set b = false
endif
else
set b = false
endif
endif
//Make Unit Face Angle
if LoadBoolean(udg_KB3D_HA, 31, Loop) then
call SetUnitFacing(U, Angle * 3.141592)
endif
//Calculate 3D coordinates
if b then
set Speed = Speed + ( Accel )//Increase the KB speed depending on the Acceleration
set Range = Range - ( RAbsBJ(Speed) )//Decrease distance traveled
set x = X + ( Speed * Cos(Angle) )//new X location of the KBed unit
set y = Y + ( Speed * Sin(Angle) )//new Y location of the KBed unit
set ZSpeed = ZSpeed + ( ZAccel )//change the fly changing rate //Acceleration is for smoothness
set z = Z + ( ZSpeed * 0.031250000 )//new Z Offset of the KBed unit
set ZT = ZT + ( ZSpeed * 0.031250000 )//Total Height Changings
endif
set b = false
if z >= Zoffset then
call SaveReal(udg_KB3D_HA, 12, Loop, -ZSpeed)
endif
//Flyover Feature
//if Flyover then
// if LoadBoolean(udg_KB3D_HA, 75, Loop) then
// if z-LoadReal(udg_KB3D_HA, 71, Loop) <= 0 and (Speed/0.03125*Flyover_dur) <= Range then
// call KB3D_Flyover(Z, z, Y, y, X, x, Speed, Flyover_dur, Loop)
// endif
// endif
//endif
//Destroy Trees around the Unit depending on the unit's Collision Size
if (DestroyTree) or (LoadBoolean(udg_KB3D_HA, 56, Loop)) then
set udg_KB3D_Reals[0] = I2R(Loop)
call KB3D_CircleTreeKill( KB3D_InBetween(2*Speed, 5 * KB3D_GetUnitCollision(U), Speed*4), x, y )
endif
//Move the unit according to the X, Y, Z
set EndOnObstacle = MoveUnit_3D(U, x, y, z, Zoffset, UnpathableStop, OS, KiOS, Angle, Speed, LoadReal(udg_KB3D_HA, 11, Loop)-Time, Loop)
//Bounce on Point
if udg_KB3D_B and LoadBoolean(udg_KB3D_HA, 60, Loop) then
set udg_KB3D_B = false
set Speed=Speed*.85
set Angle = KB3D_PointBounce(Angle,x,y)
if LoadReal(udg_KB3D_HA, 76, Loop) <= 0 then
call DestroyEffect(AddSpecialEffect(LoadStr(udg_KB3D_HA, 62, Loop), GetUnitX(U), GetUnitY(U)))
call SaveReal(udg_KB3D_HA, 76, Loop, 10)
endif
endif
//Create the Effect on the unit
if (Fx != "") then
if ( z > 20 ) then
if (Attach != "") then
call DestroyEffect(AddSpecialEffectTarget(Fx, U, Attach))//attach the effect on the unit if he is flying
endif
else
call DestroyEffect(AddSpecialEffect(Fx, x, y))//create the effect on his location if he is not flying
endif
endif
//Initiate Impact Damage
if ( (UnpathableStop) and not ( KB3D_CW(x, y) ) ) and ( (ImpactD != 0) and (Damager != null ) ) then//if the terrain is unpathable or if unpathable stop is disabled then..
if ( KB3D_CW(x, y) ) then
call SaveBoolean(udg_KB3D_HA, 23, Loop, true)
endif
if ( LoadBoolean(udg_KB3D_HA, 23, Loop) ) then
call UnitDamageTarget(Damager, U, ImpactD, true, false, AType, DType, null)//Apply Impact Damage to the unit
call SaveBoolean(udg_KB3D_HA, 23, Loop, false)
endif
endif
//Create AoE Grp
if (AoE != 0) and ((LineD != 0) or (AoED != 0) or LoadBoolean(udg_KB3D_HA, 61, Loop) or LoadBoolean(udg_KB3D_HA, 60, Loop)) then
set udg_KB3D_g = CreateGroup()
set udg_KB3D_Reals[0] = I2R(Loop)
call GroupEnumUnitsInRange(udg_KB3D_g, x, y, RAbsBJ(AoE), Filter(function KB3D_FilterGrp))
//----------------------------------
loop
set u = FirstOfGroup(udg_KB3D_g)
exitwhen (u == null)
if (Damager != null) then
if (LineD != 0) then
call KB3D_LineDamageLoop(u, udg_KB3D_g)
endif
if (AoED != 0) then
call KB3D_AoEDamageLoop(u, udg_KB3D_g)
endif
endif
if not IsUnitInGroup(u, LoadGroupHandle(udg_KB3D_HA, 67, Loop)) and RAbsBJ(AoE)>SquareRoot((GetUnitX(u) - GetUnitX(U)) * (GetUnitX(u) - GetUnitX(U)) + (GetUnitY(u) - GetUnitY(U)) * (GetUnitY(u) - GetUnitY(U))) then
if LoadBoolean(udg_KB3D_HA, 61, Loop) then
call KB3D_BounceOnUnit(u, U, Loop)
call GroupAddUnit(LoadGroupHandle(udg_KB3D_HA, 67, Loop),u)
call DestroyEffect(AddSpecialEffect(LoadStr(udg_KB3D_HA, 62, Loop), GetUnitX(u), GetUnitY(u)))
if LoadBoolean(udg_KB3D_HA, 70, Loop) then
set b = true
set udg_KB3D_EndisUnit = true
set udg_KB3D_EndisNormal = false
set udg_KB3D_EndUnit = u
endif
endif
if LoadBoolean(udg_KB3D_HA, 60, Loop) then
set Angle = (Atan2(GetUnitY(u) - GetUnitY(U), GetUnitX(u) - GetUnitX(U))) + Deg2Rad(GetRandomReal(-15,15) + 180)
set Speed = Speed*.85
call DestroyEffect(AddSpecialEffect(LoadStr(udg_KB3D_HA, 62, Loop), GetUnitX(U), GetUnitY(U)))
endif
endif
call GroupRemoveUnit(udg_KB3D_g,u)
endloop
//----------------------------------
call DestroyGroup(udg_KB3D_g)
set udg_KB3D_g = null
endif
//Disable the unit partially
if ( DisableUnit ) then
call SetUnitPropWindow(U, 0)
call SetUnitTurnSpeed(U, 0)
endif
//Initiate Target-Related Actions
if (Target != null) then
if (SquareRoot ( ( GetUnitX(Target) - x ) * ( GetUnitX(Target) - x ) + ( GetUnitY(Target) - y ) * ( GetUnitY(Target) - y ) ) < Speed+2) then//when the target and the unit are close
if not (TargetD == 0) and not(Damager == null) then//Damage the Target
call UnitDamageTarget(Damager, Target, TargetD, true, false, AType, DType, null)
call SaveReal(udg_KB3D_HA, 19, Loop, 0)
endif
if KBTarget then//KB the Target
call KB3D_GiveKBto(Target, U, Loop)
call SaveBoolean( udg_KB3D_HA, 39, udg_KB3D_Counter, false )
endif
if (KillWhenHit) then//Kill the Unit
call KillUnit(U)
endif
if (EndWhenHit) then//End the KB
call SaveReal(udg_KB3D_HA, 4, Loop, KB3D_AlwaysNeg(Speed))
call SaveReal(udg_KB3D_HA, 3, Loop, GetUnitFlyHeight(U) - ZT)
endif
set udg_KB3D_EndisUnit = true
set udg_KB3D_EndisNormal = false
endif
endif
//Kill the Unit at the time
if (KillatTime != 0) and ( Time > KillatTime ) then
call KillUnit(U)
endif
//Save Changes in the Hashtable
call SaveReal(udg_KB3D_HA, 1, Loop, Range)
call SaveReal(udg_KB3D_HA, 2, Loop, Speed)
call SaveReal(udg_KB3D_HA, 5, Loop, Angle)
call SaveReal(udg_KB3D_HA, 12, Loop, ZSpeed)
call SaveReal(udg_KB3D_HA, 26, Loop, ZT)
call SaveReal(udg_KB3D_HA, 41, Loop, Time)
call SaveReal(udg_KB3D_HA, 76, Loop, LoadReal(udg_KB3D_HA, 76, Loop)-1)
//Inititate End of the KB
if ( b or (LoadBoolean(udg_KB3D_HA, 45, Loop) and (Speed <= 2.34)) or ( Range <= 0 ) or ( (StopTime != 0) and ( Time > StopTime ) ) or EndOnObstacle ) then
call SaveBoolean(udg_KB3D_HA, 100, Loop, false)
set udg_KB3D_Instances = udg_KB3D_Instances - 1
if IsUnitType(U, UNIT_TYPE_DEAD) then
call SetUnitFlyHeight(U, GetUnitDefaultFlyHeight(U), 750 )
endif
call SetUnitPropWindow(U, LoadReal(udg_KB3D_HA, 15, Loop)*3.14159/180)
call SetUnitTurnSpeed(U, GetUnitDefaultTurnSpeed(U))
if HaveSavedHandle(udg_KB3D_HA, 14, Loop) and not EndB then
call DestroyEffect(LoadEffectHandle(udg_KB3D_HA, 14, Loop))
endif
set b = true
elseif IsUnitType(U, UNIT_TYPE_DEAD) and (EndwhenDead) then
call SaveBoolean(udg_KB3D_HA, 100, Loop, false)
set udg_KB3D_Instances = udg_KB3D_Instances - 1
if IsUnitType(U, UNIT_TYPE_DEAD) then
call SetUnitFlyHeight(U, GetUnitDefaultFlyHeight(U), 750 )
endif
call SetUnitPropWindow(U, LoadReal(udg_KB3D_HA, 15, Loop)*3.14159/180)
call SetUnitTurnSpeed(U, GetUnitDefaultTurnSpeed(U))
if HaveSavedHandle(udg_KB3D_HA, 14, Loop) and not EndB then
call DestroyEffect(LoadEffectHandle(udg_KB3D_HA, 14, Loop))
endif
set b = true
endif
//variable b refers to if the KB has ended
if b then
call SetUnitFlyHeight(U, GetUnitFlyHeight(U)-KB3D_InBetween(0,ZT-LoadReal(udg_KB3D_HA, 71, Loop),999), 500)
if LoadBoolean(udg_KB3D_HA, 44, Loop) then
call SetUnitFlyHeight(U, GetUnitFlyHeight(U)-KB3D_InBetween(0,(LoadReal(udg_KB3D_HA, 69, Loop)-KB3D_GetCoordinatesZ(x,y)),9999), RAbsBJ(ZSpeed))
endif
//----------
call SaveInteger(udg_KB3D_HA, -5, GetHandleId(U), LoadInteger(udg_KB3D_HA, -5, GetHandleId(U))-1)
if LoadInteger(udg_KB3D_HA, -5, GetHandleId(udg_KB3D_Unit)) == 0 then
call SaveBoolean(udg_KB3D_HA, GetHandleId(U), GetHandleId(U), false)
endif
//----------
if (AoEEndDamage != 0) and (Damager != null) and (AoE != 0) then
set udg_KB3D_g = CreateGroup()
set udg_KB3D_Reals[0] = I2R(Loop)
call GroupEnumUnitsInRange(udg_KB3D_g, x, y, RAbsBJ(AoE), null)
loop
set u = FirstOfGroup(udg_KB3D_g)
call KB3D_AoEEndDamage(u, udg_KB3D_g)
exitwhen (u == null)
endloop
call DestroyGroup(udg_KB3D_g)
set udg_KB3D_g = null
endif
//----------
if (AoEKB) and (AoE != 0) then
set udg_KB3D_g = CreateGroup()
set udg_KB3D_Reals[0] = I2R(Loop)
call GroupEnumUnitsInRange(udg_KB3D_g, x, y, RAbsBJ(AoE), null)
loop
set u = FirstOfGroup(udg_KB3D_g)
call KB3D_AoEKB(u, udg_KB3D_g)
exitwhen (u == null)
endloop
call DestroyGroup(udg_KB3D_g)
set udg_KB3D_g = null
endif
//----------
if (EndFx != "") then
if ( z > 20 ) and (Attach != "") then
call DestroyEffect(AddSpecialEffectTarget(EndFx, U, Attach))//attach the effect on the unit if he is flying
else
call DestroyEffect(AddSpecialEffect(EndFx, x, y))//create the effect on his location if he is not flying
endif
endif
//----------
if (AoEEndFx != "") and (Attach != "") and (AoE > 0) then
set udg_KB3D_g = CreateGroup()
set udg_KB3D_Reals[0] = I2R(Loop)
call GroupEnumUnitsInRange(udg_KB3D_g, x, y, RAbsBJ(AoE), null)
loop
set u = FirstOfGroup(udg_KB3D_g)
call KB3D_AoEEndFx(u, Attach, AoEEndFx, udg_KB3D_g)
exitwhen (u == null)
endloop
call DestroyGroup(udg_KB3D_g)
set udg_KB3D_g = null
endif
//----------
if (AoEEndFx != "") and (Attach != "") and (AoE > 0) then
set udg_KB3D_g = CreateGroup()
set udg_KB3D_Reals[0] = I2R(Loop)
call GroupEnumUnitsInRange(udg_KB3D_g, x, y, RAbsBJ(AoE), null)
loop
set u = FirstOfGroup(udg_KB3D_g)
call KB3D_AoEEndFx(u, Attach, AoEEndFx, udg_KB3D_g)
exitwhen (u == null)
endloop
call DestroyGroup(udg_KB3D_g)
set udg_KB3D_g = null
endif
//----------
if GroundDamage and (ImpactD != 0) and z < 75 and (Damager != null) then
call UnitDamageTarget(Damager, U, ImpactD, true, false, AType, DType, null)
endif
//----------
if (KillatEnd) and not EndB then
call KillUnit(U)
endif
//----------
if (EndT != null) then
set udg_KB3D_Unit = U
set udg_KB3D_Targeted_Unit = Target
call ConditionalTriggerExecute(EndT)
set udg_KB3D_Unit = null
set udg_KB3D_Targeted_Unit = null
set udg_KB3D_EndUnit = null
set udg_KB3D_EndisUnpathable = false
set udg_KB3D_EndisUnit = false
set udg_KB3D_EndisNormal = true
endif
endif
//Function to know if the unit is being KBed by the system
call SaveInteger(udg_KB3D_HA, -2, GetHandleId(udg_KB3D_Unit), LoadInteger(udg_KB3D_HA, -2, GetHandleId(udg_KB3D_Unit))-1)
call SaveBoolean(udg_KB3D_HA, -1, GetHandleId(udg_KB3D_Unit), LoadInteger(udg_KB3D_HA, -2, GetHandleId(udg_KB3D_Unit))!=0)
//Clear Instance
if b then
call KB3D_ClearInstance(Loop)
endif
//Clear locals
set udg_KB3D_B = false
set U = null
set Target = null
set Damager = null
endfunction
function KB3D_Loop_Actions takes nothing returns nothing
local integer x = 0
if udg_KB3D_Paused then
else
loop
exitwhen x >= udg_KB3D_Counter
set x = x + 1
if ( LoadBoolean(udg_KB3D_HA, 100, x) and not(LoadBoolean(udg_KB3D_HA, 77, x))) then
call KB3D_Loop(x)
endif
endloop
if ( udg_KB3D_Instances == 0 ) then
set udg_KB3D_Counter = 0
call PauseTimer(udg_KB3D_Timer)
endif
endif
endfunction
function KB3D_ClearVar takes nothing returns nothing
set udg_KB3D_HomingMissile = false
set udg_KB3D_EndOnTargetBounce = false
set udg_KB3D_Speed_Changer = false
set udg_KB3D_AoEEndFx = ""
set udg_KB3D_D_STRUCTURE = false
set udg_KB3D_D_MECHANICAL = false
set udg_KB3D_D_ALLY = false
set udg_KB3D_D_MAGIC_IMMINUE = false
set udg_KB3D_D_ENEMY = true
set udg_KB3D_D_RESISTANT = false
set udg_KB3D_D_FLYING = false
set udg_KB3D_Accel = 0.00
set udg_KB3D_AllowOutSiding = false
set udg_KB3D_Flyover = false
set udg_KB3D_Flyover_Duration = 0.00
set udg_KB3D_Angle = 0.00
set udg_KB3D_AoE = 0.00
set udg_KB3D_Arc = 0.00
set udg_KB3D_AoEDamage = 0.00
set udg_KB3D_AttackType = ATTACK_TYPE_NORMAL
set udg_KB3D_DamageType = DAMAGE_TYPE_MAGIC
set udg_KB3D_Damager = null
set udg_KB3D_DestroyTree = true
set udg_KB3D_DisableUnit = false
set udg_KB3D_EndWhenHit = false
set udg_KB3D_Fx = ""
set udg_KB3D_Fx_Attach = ""
set udg_KB3D_EndFx = ""
set udg_KB3D_Attach = "origin"
set udg_KB3D_ImpactDamage = 0.00
set udg_KB3D_KillWhenHit = false
set udg_KB3D_FaceAngle = false
set udg_KB3D_KillifOutSider = false
set udg_KB3D_LineDamage = 0.00
set udg_KB3D_LoopDamage = 0.00
set udg_KB3D_Range = 0.00
set udg_KB3D_Speed = 0.00
set udg_KB3D_TargetDamage = 0.00
set udg_KB3D_Targeted_Unit = null
set udg_KB3D_TrailFx = ""
set udg_KB3D_Unit = null
set udg_KB3D_UnpathableStop = true
set udg_KB3D_Zoffset = 0.00
set udg_KB3D_AoEEndDamage = 0.00
set udg_KB3D_AoEKB = false
set udg_KB3D_EndwhenDead = true
set udg_KB3D_KBTarget = false
set udg_KB3D_StopTime = 0.00
set udg_KB3D_KillatTime = 0.00
set udg_KB3D_AoEKB_Power = 1.00
set udg_KB3D_iKB = true
set udg_KB3D_KillatEnd = false
set udg_KB3D_GroundDamage = false
set udg_KB3D_EndTrigger = null
set udg_KB3D_JumpOverCliff = false
set udg_KB3D_DestroyDestructables = false
set udg_KB3D_Line_Fx = ""
set udg_KB3D_Bounce_Target = false
set udg_KB3D_Bounce_Unit = false
set udg_KB3D_Bounce_Power = 1.00
set udg_KB3D_Bounce_Fx = ""
set udg_KB3D_EndOnObstacle = false
set udg_KB3D_EndUnit = null
set udg_KB3D_RemoveUnit = null
set udg_KB3D_EndisUnpathable = false
set udg_KB3D_EndisUnit = false
set udg_KB3D_EndisNormal = true
endfunction
function KB3D_Registration takes nothing returns boolean
local real Time
local real R
local real R1
local real dx
local real dy
if udg_KB3D_PausedReg then
return false
endif
//------------------------
if udg_KB3D_Unit == null then
return false
endif
//------------------------
if udg_KB3D_Fx_Attach != "" then
set udg_KB3D_Fx = udg_KB3D_Fx_Attach
endif
//------------------------
if udg_KB3D_HomingMissile and udg_KB3D_Targeted_Unit != null then
set udg_KB3D_Zoffset = GetUnitFlyHeight(udg_KB3D_Targeted_Unit)
set dx = GetUnitX(udg_KB3D_Unit)-GetUnitX(udg_KB3D_Targeted_Unit)
set dy = GetUnitY(udg_KB3D_Unit)-GetUnitY(udg_KB3D_Targeted_Unit)
if udg_KB3D_Zoffset == 0 then
set udg_KB3D_Zoffset = 100
set udg_KB3D_Range = SquareRoot( dx * dx + dy * dy)*1.25
else
set udg_KB3D_Range = SquareRoot( dx * dx + dy * dy)*2
endif
set udg_KB3D_KillatEnd = true
set udg_KB3D_KillWhenHit = true
set udg_KB3D_EndWhenHit = true
set udg_KB3D_FaceAngle = true
set udg_KB3D_UnpathableStop = false
endif
//------------------------
set udg_KB3D_Arc = KB3D_InBetween(-10, udg_KB3D_Arc, 10)
set udg_KB3D_AoEKB_Power = KB3D_InBetween(0.01, udg_KB3D_AoEKB_Power, 3)
//------------------------
if IsUnitType(udg_KB3D_Unit, UNIT_TYPE_FLYING) then
set udg_KB3D_UnpathableStop = false
endif
//------------------------
if (udg_KB3D_iKB) and udg_KB3D_Range < 0 then
if ( udg_KB3D_Targeted_Unit == null ) then
set udg_KB3D_Angle = udg_KB3D_Angle + 180
else
set udg_KB3D_Speed = -1*(udg_KB3D_Speed)
endif
endif
//------------------------
set udg_KB3D_Range = KB3D_InBetween(0.0000001, RAbsBJ(udg_KB3D_Range), RAbsBJ(udg_KB3D_Range))
//------------------------
if (udg_KB3D_iKB) and udg_KB3D_Speed < 0 then
set udg_KB3D_Speed = KB3D_InBetween(udg_KB3D_Speed, udg_KB3D_Speed, 0)
else
set udg_KB3D_Speed = KB3D_InBetween(0.0, RAbsBJ(udg_KB3D_Speed), RAbsBJ(udg_KB3D_Speed))
endif
//------------------------
set udg_KB3D_Counter = udg_KB3D_Counter + 1
set udg_KB3D_Instances = udg_KB3D_Instances + 1
call SaveBoolean(udg_KB3D_HA, -1, GetHandleId(udg_KB3D_Unit), true)
call SaveBoolean(udg_KB3D_HA, 57, udg_KB3D_Counter, (udg_KB3D_Zoffset != 0))
//------------------------
if not udg_KB3D_iKB then
set udg_KB3D_Zoffset = RAbsBJ(udg_KB3D_Zoffset)
elseif GetUnitFlyHeight(udg_KB3D_Unit)+udg_KB3D_Zoffset < 0 then
set udg_KB3D_Zoffset = -GetUnitFlyHeight(udg_KB3D_Unit)
endif
//------------------------
set udg_KB3D_StopTime = RAbsBJ(udg_KB3D_StopTime)
set udg_KB3D_KillatTime = RAbsBJ(udg_KB3D_KillatTime)
set udg_KB3D_AoE = RAbsBJ(udg_KB3D_AoE)
//------------------------
//------------------------
call SaveUnitHandle( udg_KB3D_HA, 0, udg_KB3D_Counter, udg_KB3D_Unit )
call SaveReal( udg_KB3D_HA, 1, udg_KB3D_Counter, udg_KB3D_Range )
call SaveReal( udg_KB3D_HA, 2, udg_KB3D_Counter, udg_KB3D_Speed * 0.031250000 )
call SaveReal( udg_KB3D_HA, 4, udg_KB3D_Counter, udg_KB3D_Accel * 0.031250000 * 0.031250000 )
//------------------------
if ( udg_KB3D_Targeted_Unit == null ) then
call SaveReal( udg_KB3D_HA, 5, udg_KB3D_Counter, udg_KB3D_Angle * 3.14159 / 180 )
else
call SaveUnitHandle( udg_KB3D_HA, 5, udg_KB3D_Counter, udg_KB3D_Targeted_Unit )
set udg_KB3D_JumpOverCliff = false
endif
//------------------------
call SaveBoolean( udg_KB3D_HA, 6, udg_KB3D_Counter, udg_KB3D_DisableUnit )
call SaveBoolean( udg_KB3D_HA, 7, udg_KB3D_Counter, udg_KB3D_UnpathableStop )
call SaveBoolean( udg_KB3D_HA, 8, udg_KB3D_Counter, udg_KB3D_DestroyTree )
call SaveStr( udg_KB3D_HA, 9, udg_KB3D_Counter, udg_KB3D_Fx )
call SaveStr( udg_KB3D_HA, 10, udg_KB3D_Counter, udg_KB3D_Attach )
call SaveBoolean( udg_KB3D_HA, 45, udg_KB3D_Counter, udg_KB3D_Speed>0 )
//------------------------
//------------------------
set udg_KB3D_Speed = KB3D_InBetween(0.01, RAbsBJ(udg_KB3D_Speed), RAbsBJ(udg_KB3D_Speed))
//------------------------
if ( udg_KB3D_Accel == 0.00 ) then
set Time = udg_KB3D_Range / (udg_KB3D_Speed)//calculating time for the knockback if Acceleration = 0
else
if ( udg_KB3D_Accel > 0 ) then
set Time = (-udg_KB3D_Speed-SquareRoot(udg_KB3D_Speed*udg_KB3D_Speed + 2*udg_KB3D_Accel*udg_KB3D_Range))/-udg_KB3D_Accel//calculating time for the knockback if Acceleration > 0*/
endif
if ( udg_KB3D_Accel < 0 ) then
set Time = (-udg_KB3D_Speed+SquareRoot(udg_KB3D_Speed*udg_KB3D_Speed + 2*udg_KB3D_Accel*udg_KB3D_Range))/udg_KB3D_Accel
endif
endif
//------------------------
call SaveReal( udg_KB3D_HA, 11, udg_KB3D_Counter, Time )
call SaveBoolean( udg_KB3D_HA, 100, udg_KB3D_Counter, true )
//------------------------
if UnitAddAbility(udg_KB3D_Unit, 'Amrf') then
call UnitRemoveAbility(udg_KB3D_Unit, 'Amrf')
endif
//------------------------
call SaveReal( udg_KB3D_HA, 3, udg_KB3D_Counter, udg_KB3D_Zoffset )
call SaveReal( udg_KB3D_HA, 12, udg_KB3D_Counter, (2*udg_KB3D_Zoffset / ( Time / 2)) )
call SaveReal( udg_KB3D_HA, 13, udg_KB3D_Counter, ( -2 * udg_KB3D_Zoffset / ( Time / 2) ) / ( Time / 2) * 0.031250000 )
//------------------------
if not (udg_KB3D_TrailFx == "") and not (udg_KB3D_Attach == "") then
call SaveEffectHandle(udg_KB3D_HA, 14, udg_KB3D_Counter, AddSpecialEffectTarget(udg_KB3D_TrailFx, udg_KB3D_Unit, udg_KB3D_Attach))
endif
//------------------------
call SaveReal( udg_KB3D_HA, 15, udg_KB3D_Counter, GetUnitDefaultPropWindow(udg_KB3D_Unit) )
call SaveBoolean(udg_KB3D_HA, 16, udg_KB3D_Counter, udg_KB3D_Speed_Changer)
call SaveReal( udg_KB3D_HA, 17, udg_KB3D_Counter, udg_KB3D_ImpactDamage )
call SaveReal( udg_KB3D_HA, 18, udg_KB3D_Counter, udg_KB3D_LoopDamage * 0.031250000 )
call SaveReal( udg_KB3D_HA, 19, udg_KB3D_Counter, udg_KB3D_TargetDamage )
call SaveInteger( udg_KB3D_HA, 20, udg_KB3D_Counter, GetHandleId(udg_KB3D_AttackType))
call SaveInteger( udg_KB3D_HA, 21, udg_KB3D_Counter, GetHandleId(udg_KB3D_DamageType))
call SaveUnitHandle( udg_KB3D_HA, 22, udg_KB3D_Counter, udg_KB3D_Damager )
call SaveBoolean( udg_KB3D_HA, 23, udg_KB3D_Counter, true )
call SaveBoolean( udg_KB3D_HA, 24, udg_KB3D_Counter, udg_KB3D_KillWhenHit )
call SaveBoolean( udg_KB3D_HA, 25, udg_KB3D_Counter, udg_KB3D_EndWhenHit )
// 26 used
call SaveGroupHandle(udg_KB3D_HA, 27, udg_KB3D_Counter, CreateGroup() )
call SaveReal( udg_KB3D_HA, 28, udg_KB3D_Counter, udg_KB3D_LineDamage )
call SaveReal( udg_KB3D_HA, 29, udg_KB3D_Counter, RAbsBJ(udg_KB3D_AoE) )
call SaveReal( udg_KB3D_HA, 30, udg_KB3D_Counter, udg_KB3D_Arc * (3.14159/180) )
call SaveBoolean( udg_KB3D_HA, 31, udg_KB3D_Counter, udg_KB3D_FaceAngle )
call SaveReal( udg_KB3D_HA, 32, udg_KB3D_Counter, udg_KB3D_AoEDamage )
call SaveBoolean( udg_KB3D_HA, 33, udg_KB3D_Counter, udg_KB3D_KillifOutSider )
//------------------------
set udg_KB3D_AllowOutSiding = udg_KB3D_KillifOutSider
//------------------------
call SaveBoolean( udg_KB3D_HA, 34, udg_KB3D_Counter, udg_KB3D_AllowOutSiding )
//------------------------
if not udg_KB3D_EndwhenDead then
set udg_KB3D_EndwhenDead = udg_KB3D_KillatTime > udg_KB3D_StopTime
endif
//------------------------
call SaveBoolean( udg_KB3D_HA, 35, udg_KB3D_Counter, udg_KB3D_EndwhenDead )
call SaveReal( udg_KB3D_HA, 36, udg_KB3D_Counter, udg_KB3D_KillatTime )
call SaveReal( udg_KB3D_HA, 37, udg_KB3D_Counter, udg_KB3D_StopTime )
call SaveReal( udg_KB3D_HA, 38, udg_KB3D_Counter, udg_KB3D_AoEEndDamage )
call SaveBoolean( udg_KB3D_HA, 39, udg_KB3D_Counter, udg_KB3D_KBTarget )
call SaveBoolean( udg_KB3D_HA, 40, udg_KB3D_Counter, udg_KB3D_AoEKB )
//41 used
call SaveStr(udg_KB3D_HA, 42, udg_KB3D_Counter, udg_KB3D_EndFx )
call SaveReal( udg_KB3D_HA, 43, udg_KB3D_Counter, udg_KB3D_AoEKB_Power )
call SaveBoolean( udg_KB3D_HA, 44, udg_KB3D_Counter, udg_KB3D_iKB )
call SaveBoolean( udg_KB3D_HA, 46, udg_KB3D_Counter, udg_KB3D_KillatEnd )
call SaveBoolean( udg_KB3D_HA, 47, udg_KB3D_Counter, udg_KB3D_GroundDamage )
call SaveBoolean( udg_KB3D_HA, 48, udg_KB3D_Counter, udg_KB3D_D_STRUCTURE )
call SaveBoolean( udg_KB3D_HA, 49, udg_KB3D_Counter, udg_KB3D_D_MECHANICAL )
call SaveBoolean( udg_KB3D_HA, 50, udg_KB3D_Counter, udg_KB3D_D_MAGIC_IMMINUE )
call SaveBoolean( udg_KB3D_HA, 51, udg_KB3D_Counter, udg_KB3D_D_ALLY )
call SaveBoolean( udg_KB3D_HA, 52, udg_KB3D_Counter, udg_KB3D_JumpOverCliff )
//call SaveBoolean( udg_KB3D_HA, 53, udg_KB3D_Counter, false )
call SaveStr( udg_KB3D_HA, 54, udg_KB3D_Counter, udg_KB3D_AoEEndFx )
call SaveTriggerHandle( udg_KB3D_HA, 55, udg_KB3D_Counter, udg_KB3D_EndTrigger )
call SaveBoolean( udg_KB3D_HA, 56, udg_KB3D_Counter, udg_KB3D_DestroyDestructables )
//57 used
call SaveStr( udg_KB3D_HA, 58, udg_KB3D_Counter, udg_KB3D_Line_Fx )
call SaveReal( udg_KB3D_HA, 59, udg_KB3D_Counter, udg_KB3D_Bounce_Power )
call SaveBoolean( udg_KB3D_HA, 60, udg_KB3D_Counter, udg_KB3D_Bounce_Unit )
call SaveBoolean( udg_KB3D_HA, 61, udg_KB3D_Counter, udg_KB3D_Bounce_Target )
call SaveStr( udg_KB3D_HA, 62, udg_KB3D_Counter, udg_KB3D_Bounce_Fx )
call SaveBoolean( udg_KB3D_HA, 63, udg_KB3D_Counter, udg_KB3D_D_ENEMY )
call SaveBoolean( udg_KB3D_HA, 64, udg_KB3D_Counter, udg_KB3D_D_RESISTANT )
call SaveBoolean( udg_KB3D_HA, 65, udg_KB3D_Counter, udg_KB3D_D_FLYING )
call SaveBoolean( udg_KB3D_HA, 66, udg_KB3D_Counter, udg_KB3D_EndOnObstacle )
//------------------------
if udg_KB3D_Bounce_Target then
call SaveGroupHandle(udg_KB3D_HA, 67, udg_KB3D_Counter, CreateGroup())
endif
//------------------------
call SaveReal( udg_KB3D_HA, 68, udg_KB3D_Counter, KB3D_GetCoordinatesZ(GetUnitX(udg_KB3D_Unit), GetUnitY(udg_KB3D_Unit)) )
call SaveReal( udg_KB3D_HA, 69, udg_KB3D_Counter, KB3D_GetCoordinatesZ(GetUnitX(udg_KB3D_Unit), GetUnitY(udg_KB3D_Unit)) )
call SaveBoolean( udg_KB3D_HA, 70, udg_KB3D_Counter, udg_KB3D_EndOnTargetBounce )
call SaveReal(udg_KB3D_HA, 71, udg_KB3D_Counter, GetUnitFlyHeight(udg_KB3D_Unit))
call SaveBoolean(udg_KB3D_HA, 72, udg_KB3D_Counter, udg_KB3D_Flyover)
call SaveReal(udg_KB3D_HA, 73, udg_KB3D_Counter, udg_KB3D_Flyover_Duration)
//74 used
call SaveBoolean(udg_KB3D_HA, 75, udg_KB3D_Counter, udg_KB3D_Flyover)
call SaveReal(udg_KB3D_HA, 76, udg_KB3D_Counter, 0)
call SaveBoolean(udg_KB3D_HA, 77, udg_KB3D_Counter, false)
//------------------------
if ( udg_KB3D_Counter == 1 ) then
call TimerStart(udg_KB3D_Timer, 0.031250000, true, function KB3D_Loop_Actions )
endif
//------------------------
set udg_KB3D_Time = Time
//------------------------
//------------------------
call SaveInteger(udg_KB3D_HA, -5, GetHandleId(udg_KB3D_Unit), LoadInteger(udg_KB3D_HA, -5, GetHandleId(udg_KB3D_Unit))+1)
call SaveBoolean(udg_KB3D_HA, GetHandleId(udg_KB3D_Unit), GetHandleId(udg_KB3D_Unit), true)
//------------------------
//------------------------
//------------------------
call KB3D_ClearVar()
return false
endfunction
function KB3D_RemoveUnit takes nothing returns nothing
local integer x = 1
loop
exitwhen x > udg_KB3D_Counter
if LoadUnitHandle(udg_KB3D_HA, 0, x) == udg_KB3D_RemoveUnit then
call SaveReal(udg_KB3D_HA, 1, x, 0)
endif
set x = x + 1
endloop
endfunction
function KB3D_Pause takes nothing returns nothing
call SaveBoolean(udg_KB3D_HA, 77, udg_KB3D_PauseID, true)
set udg_KB3D_PauseID = -1
endfunction
function KB3D_Resume takes nothing returns nothing
call SaveBoolean(udg_KB3D_HA, 77, udg_KB3D_PauseID, false)
set udg_KB3D_PauseID = -1
endfunction
function KB3D_PauseAll takes nothing returns nothing
set udg_KB3D_Paused = true
endfunction
function KB3D_ResumeAll takes nothing returns nothing
set udg_KB3D_Paused = false
endfunction
function KB3D_PauseRegistration takes nothing returns nothing
set udg_KB3D_PausedReg = true
endfunction
function KB3D_ResumeRegistration takes nothing returns nothing
set udg_KB3D_PausedReg = false
endfunction
//===========================================================================
function InitTrig_KB3D takes nothing returns nothing
////////REGISTRATION
set udg_KB3D_Registration = CreateTrigger( )
call TriggerAddCondition( udg_KB3D_Registration, Condition(function KB3D_Registration) )
set udg_KB3D_Harvester = CreateUnit(Player(15), 'hpea', 0, 0, 0)
call ShowUnit(udg_KB3D_Harvester, false)
call UnitAddAbility(udg_KB3D_Harvester, 'Aloc')
call UnitAddAbility(udg_KB3D_Harvester, 'Ahar')
call UnitRemoveAbility(udg_KB3D_Harvester, 'Amov')
set udg_KB3D_HA = InitHashtable()
////////Check Walkability System by PnF
set udg_CP_Rect = Rect(0, 0, 128.00, 128.00)
set udg_CP_Item = CreateItem('wtlg', 0, 0)
call SetItemVisible( udg_CP_Item, false )
////////InitReals
set udg_KB3D_Reals[1] = GetRectMaxX(bj_mapInitialPlayableArea)
set udg_KB3D_Reals[2] = GetRectMinX(bj_mapInitialPlayableArea)
set udg_KB3D_Reals[3] = GetRectMaxY(bj_mapInitialPlayableArea)
set udg_KB3D_Reals[4] = GetRectMinY(bj_mapInitialPlayableArea)
set udg_KB3D_Reals[5] = GetRectMaxX(GetWorldBounds())
set udg_KB3D_Reals[6] = GetRectMinX(GetWorldBounds())
set udg_KB3D_Reals[7] = GetRectMaxY(GetWorldBounds())
set udg_KB3D_Reals[8] = GetRectMinY(GetWorldBounds())
//Initiate Default Values
call KB3D_ClearVar()
endfunction
library WorldBounds /* v2.0.0.0
************************************************************************************
*
* struct WorldBounds extends array
*
* Fields
* -------------------------
*
* 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
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 = true
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
/*****************************************************************************
*
* RegisterNativeEvent v1.1.1.2
* by Bannar
*
* Storage of trigger handles for native events.
*
******************************************************************************
*
* Optional requirements:
*
* Table by Bribe
* hiveworkshop.com/forums/jass-resources-412/snippet-new-table-188084/
*
******************************************************************************
*
* Important:
*
* Avoid using TriggerSleepAction within functions registered.
* Destroy native event trigger on your own responsibility.
*
******************************************************************************
*
* Core:
*
* function IsNativeEventRegistered takes integer whichIndex, integer whichEvent returns boolean
* Whether index whichIndex has already been attached to event whichEvent.
*
* function RegisterNativeEventTrigger takes integer whichIndex, integer eventId returns boolean
* Registers whichIndex within whichEvent scope and assigns new trigger handle for it.
*
* function GetIndexNativeEventTrigger takes integer whichIndex, integer whichEvent returns trigger
* Retrieves trigger handle for event whichEvent specific to provided index whichIndex.
*
* function GetNativeEventTrigger takes integer whichEvent returns trigger
* Retrieves trigger handle for event whichEvent.
*
*
* Custom events:
*
* function CreateNativeEvent takes nothing returns integer
* Returns unique id for new event and registers it with RegisterNativeEvent.
*
* function RegisterIndexNativeEvent takes integer whichIndex, integer whichEvent, code func returns nothing
* Registers new event handler func for event whichEvent specific to index whichIndex.
*
* function RegisterNativeEvent takes integer whichEvent, code func returns nothing
* Registers new event handler func for specified event whichEvent.
*
*****************************************************************************/
library RegisterNativeEvent uses optional Table
globals
private integer eventIndex = 500 // 0-499 reserved for Blizzard native events
endglobals
private module NativeEventInit
private static method onInit takes nothing returns nothing
static if LIBRARY_Table then
set table = TableArray[0x2000]
endif
endmethod
endmodule
private struct NativeEvent extends array
static if LIBRARY_Table then
static TableArray table
else
static hashtable table = InitHashtable()
endif
implement NativeEventInit
endstruct
function IsNativeEventRegistered takes integer whichIndex, integer whichEvent returns boolean
static if LIBRARY_Table then
return NativeEvent.table[whichEvent].trigger.has(whichIndex)
else
return HaveSavedHandle(NativeEvent.table, whichEvent, whichIndex)
endif
endfunction
function RegisterNativeEventTrigger takes integer whichIndex, integer whichEvent returns boolean
if not IsNativeEventRegistered(whichIndex, whichEvent) then
static if LIBRARY_Table then
set NativeEvent.table[whichEvent].trigger[whichIndex] = CreateTrigger()
else
call SaveTriggerHandle(NativeEvent.table, whichEvent, whichIndex, CreateTrigger())
endif
return true
endif
return false
endfunction
function GetIndexNativeEventTrigger takes integer whichIndex, integer whichEvent returns trigger
static if LIBRARY_Table then
return NativeEvent.table[whichEvent].trigger[whichIndex]
else
return LoadTriggerHandle(NativeEvent.table, whichEvent, whichIndex)
endif
endfunction
function GetNativeEventTrigger takes integer whichEvent returns trigger
return GetIndexNativeEventTrigger(bj_MAX_PLAYER_SLOTS, whichEvent)
endfunction
function CreateNativeEvent takes nothing returns integer
local integer eventId = eventIndex
call RegisterNativeEventTrigger(bj_MAX_PLAYER_SLOTS, eventId)
set eventIndex = eventIndex + 1
return eventId
endfunction
function RegisterIndexNativeEvent takes integer whichIndex, integer whichEvent, code func returns nothing
call RegisterNativeEventTrigger(whichIndex, whichEvent)
call TriggerAddCondition(GetIndexNativeEventTrigger(whichIndex, whichEvent), Condition(func))
endfunction
function RegisterNativeEvent takes integer whichEvent, code func returns nothing
call RegisterIndexNativeEvent(bj_MAX_PLAYER_SLOTS, whichEvent, func)
endfunction
endlibrary
/*****************************************************************************
*
* RegisterPlayerUnitEvent v1.0.3.2
* by Bannar
*
* Register version of TriggerRegisterPlayerUnitEvent.
*
* Special thanks to Magtheridon96, Bribe, azlier and BBQ for the original library version.
*
******************************************************************************
*
* Requirements:
*
* RegisterNativeEvent by Bannar
* hiveworkshop.com/threads/snippet-registerevent-pack.250266/
*
******************************************************************************
*
* Functions:
*
* function GetAnyPlayerUnitEventTrigger takes playerunitevent whichEvent returns trigger
* Retrieves trigger handle for playerunitevent whichEvent.
*
* function GetPlayerUnitEventTrigger takes player whichPlayer, playerunitevent whichEvent returns trigger
* Retrieves trigger handle for playerunitevent whichEvent specific to player whichPlayer.
*
* function RegisterAnyPlayerUnitEvent takes playerunitevent whichEvent, code func returns nothing
* Registers generic playerunitevent whichEvent adding code func as callback.
*
* function RegisterPlayerUnitEvent takes player whichPlayer, playerunitevent whichEvent, code func returns nothing
* Registers playerunitevent whichEvent for player whichPlayer adding code func as callback.
*
*****************************************************************************/
library RegisterPlayerUnitEvent requires RegisterNativeEvent
function GetAnyPlayerUnitEventTrigger takes playerunitevent whichEvent returns trigger
return GetNativeEventTrigger(GetHandleId(whichEvent))
endfunction
function GetPlayerUnitEventTrigger takes player whichPlayer, playerunitevent whichEvent returns trigger
return GetIndexNativeEventTrigger(GetPlayerId(whichPlayer), GetHandleId(whichEvent))
endfunction
function RegisterAnyPlayerUnitEvent takes playerunitevent whichEvent, code func returns nothing
local integer eventId = GetHandleId(whichEvent)
local integer index = 0
local trigger t = null
if RegisterNativeEventTrigger(bj_MAX_PLAYER_SLOTS, eventId) then
set t = GetNativeEventTrigger(eventId)
loop
call TriggerRegisterPlayerUnitEvent(t, Player(index), whichEvent, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
set t = null
endif
call RegisterNativeEvent(eventId, func)
endfunction
function RegisterPlayerUnitEvent takes player whichPlayer, playerunitevent whichEvent, code func returns nothing
local integer playerId = GetPlayerId(whichPlayer)
local integer eventId = GetHandleId(whichEvent)
if RegisterNativeEventTrigger(playerId, eventId) then
call TriggerRegisterPlayerUnitEvent(GetIndexNativeEventTrigger(playerId, eventId), whichPlayer, whichEvent, null)
endif
call RegisterIndexNativeEvent(playerId, eventId, func)
endfunction
endlibrary
library InitTOCFiles
private module init
private static method onInit takes nothing returns nothing
call BlzLoadTOCFile("UI\\CustomUI.toc")
endmethod
endmodule
private struct InitTOCFiles
implement init
endstruct
endlibrary
library GetDummy requires TimerUtils, WorldBounds
// Original library by Peppersawce, modified by Spellbound.
/*
API
set u = GetDummy(owner, abilId, level, x, y, duration)
Alternatively, if you need the dummy to be retrieved to face a certain point, you can use
set u = GetDummyAngled(owner, abilId, level, x, y, facing, duration)
*/
globals
private constant integer DUMMY_ID = 'n003'
private constant player NEURTAL_OWNER = Player(PLAYER_NEUTRAL_PASSIVE)
private integer availableDummies = 0
private group dummyGroup = CreateGroup()
private unit currentdummy = null
endglobals
private struct AbilRemoval
integer ab
unit dummy
static method create takes unit dumdum, integer index returns AbilRemoval
local AbilRemoval abrem = AbilRemoval.allocate()
set abrem.dummy = dumdum
set abrem.ab = index
return abrem
endmethod
method destroy takes nothing returns nothing
set this.dummy = null
call this.deallocate()
endmethod
endstruct
/*================================================================
//
// CORE
*/
private function RecycleDummy takes nothing returns nothing
local AbilRemoval abrem = GetTimerData(GetExpiredTimer())
call UnitRemoveAbility(abrem.dummy, abrem.ab)
if GetOwningPlayer(abrem.dummy) != NEURTAL_OWNER then
call SetUnitOwner(abrem.dummy, NEURTAL_OWNER, false)
endif
call GroupAddUnit(dummyGroup, abrem.dummy)
call SetUnitX(abrem.dummy, WorldBounds.minX)
call SetUnitY(abrem.dummy, WorldBounds.minY)
call PauseUnit(abrem.dummy, true)
call ShowUnit(abrem.dummy, false)
call SetUnitFlyHeight(abrem.dummy, 5000., 0.)
set availableDummies = availableDummies + 1
call ReleaseTimer(GetExpiredTimer())
call abrem.destroy()
endfunction
function GetDummy takes player owner, integer abilId, integer abilLevel, real x, real y, real expiration returns unit
local AbilRemoval abrem
if availableDummies > 0 then
set availableDummies = availableDummies - 1
set currentdummy = BlzGroupUnitAt(dummyGroup, availableDummies)
call GroupRemoveUnit(dummyGroup, currentdummy)
if owner != NEURTAL_OWNER then
call SetUnitOwner(currentdummy, owner, false)
endif
call SetUnitX(currentdummy, x)
call SetUnitY(currentdummy, y)
call PauseUnit(currentdummy, false)
call ShowUnit(currentdummy, true)
call SetUnitFlyHeight(currentdummy, 0., 0.)
else
set currentdummy = CreateUnit(owner, DUMMY_ID, x, y, bj_UNIT_FACING)
endif
call UnitAddAbility(currentdummy, abilId)
call SetUnitAbilityLevel(currentdummy, abilId, abilLevel)
set abrem = AbilRemoval.create(currentdummy, abilId)
call TimerStart(NewTimerEx(abrem), expiration, false, function RecycleDummy)
return currentdummy
endfunction
function GetDummyAngled takes player owner, integer abilId, integer abilLevel, real x, real y, real facing, real expiration returns unit
set currentdummy = GetDummy(owner, abilId, abilLevel, x, y, expiration)
call BlzSetUnitFacingEx(currentdummy, facing)
return currentdummy
endfunction
/*================================================================
//
// ORIGINAL GETTERS
*/
function GetDummyImmediate takes player owner, integer abilId, integer abilLevel, real x, real y, integer orderId, real expiration returns nothing
call IssueImmediateOrderById(GetDummy(owner, abilId, abilLevel, x, y, expiration), orderId)
endfunction
function GetDummyPoint takes player owner, integer abilId, integer abilLevel, real x, real y, integer orderId, real xTarget, real yTarget, real expiration returns nothing
call IssuePointOrderById(GetDummy(owner, abilId, abilLevel, x, y, expiration), orderId, xTarget, yTarget)
endfunction
function GetDummyTarget takes player owner, integer abilId, integer abilLevel, real x, real y, integer orderId, widget target, real expiration returns nothing
call IssueTargetOrderById(GetDummy(owner, abilId, abilLevel, x, y, expiration), orderId, target)
endfunction
/*================================================================
//
// ALTERNATE GETTERS
*/
// Immediate
function DummyCast takes player owner, real x, real y, integer abilId, integer abilLevel, integer orderId, real expiration returns nothing
call IssueImmediateOrderById(GetDummy(owner, abilId, abilLevel, x, y, expiration), orderId)
endfunction
// Point
function DummyCastPoint takes player owner, integer abilId, integer abilLevel, real xTarget, real yTarget, integer orderId, real expiration returns nothing
call IssuePointOrderById(GetDummy(owner, abilId, abilLevel, xTarget, yTarget, expiration), orderId, xTarget, yTarget)
endfunction
function DummyCastPointEx takes player owner, real x, real y, integer abilId, integer abilLevel, real xTarget, real yTarget, integer orderId, real expiration returns nothing
call IssuePointOrderById(GetDummy(owner, abilId, abilLevel, x, y, expiration), orderId, xTarget, yTarget)
endfunction
// Target
function DummyCastUnit takes player owner, integer abilId, integer abilLevel, unit target, integer orderId, real expiration returns nothing
call IssueTargetOrderById(GetDummy(owner, abilId, abilLevel, GetUnitX(target), GetUnitY(target), expiration), orderId, target)
endfunction
function DummyCastTarget takes player owner, integer abilId, integer abilLevel, widget target, integer orderId, real expiration returns nothing
call IssueTargetOrderById(GetDummy(owner, abilId, abilLevel, GetWidgetX(target), GetWidgetY(target), expiration), orderId, target)
endfunction
function DummyCastTargetEx takes player owner, real x, real y, integer abilId, integer abilLevel, widget target, integer orderId, real expiration returns nothing
call IssueTargetOrderById(GetDummy(owner, abilId, abilLevel, x, y, expiration), orderId, target)
endfunction
endlibrary
library GetAttackDummy requires TimerUtils, WorldBounds
// Original library by Peppersawce, modified by Spellbound.
/*
API
set u = GetAttackDummy(owner, abilId, level, x, y, duration)
Alternatively, if you need the dummy to be retrieved to face a certain point, you can use
set u = GetAttackDummy(owner, abilId, level, x, y, facing, duration)
*/
globals
private constant integer DummyId = 'n00T'
private integer AvailableDummy = 0
private group Dummies = CreateGroup()
private unit currentdummy = null
private constant player NEURTAL_OWNER = Player(PLAYER_NEUTRAL_PASSIVE)
endglobals
private struct AbilRemoval
integer ab
unit dummy
static method create takes unit dumdum, integer index returns AbilRemoval
local AbilRemoval abrem = AbilRemoval.allocate()
set abrem.dummy = dumdum
set abrem.ab = index
return abrem
endmethod
method destroy takes nothing returns nothing
set this.dummy = null
call this.deallocate()
endmethod
endstruct
private function RecycleDummy takes nothing returns nothing
local AbilRemoval abrem = GetTimerData(GetExpiredTimer())
call UnitRemoveAbility(abrem.dummy, abrem.ab)
call UnitAddAbility(abrem.dummy, 'Abun')
if GetOwningPlayer(abrem.dummy) != NEURTAL_OWNER then
call SetUnitOwner(abrem.dummy, NEURTAL_OWNER, false)
endif
call GroupAddUnit(Dummies, abrem.dummy)
call PauseUnit(abrem.dummy, true)
call SetUnitX(abrem.dummy, WorldBounds.minX)
call SetUnitY(abrem.dummy, WorldBounds.minY)
set AvailableDummy = AvailableDummy + 1
call ReleaseTimer(GetExpiredTimer())
call abrem.destroy()
endfunction
function GetAttackDummy takes player owner, integer abilId, integer abillevel, real x, real y, real expiration returns unit
local AbilRemoval abrem
if AvailableDummy > 0 then
set AvailableDummy = AvailableDummy - 1
set currentdummy = BlzGroupUnitAt(Dummies, AvailableDummy)
call GroupRemoveUnit(Dummies, currentdummy)
if owner != NEURTAL_OWNER then
call SetUnitOwner(currentdummy, owner, false)
endif
call PauseUnit(currentdummy, false)
call SetUnitX(currentdummy, x)
call SetUnitY(currentdummy, y)
else
set currentdummy = CreateUnit(owner, DummyId, x, y, bj_UNIT_FACING)
endif
call UnitRemoveAbility(currentdummy, 'Abun')
call UnitAddAbility(currentdummy, abilId)
if abillevel > 1 then
call SetUnitAbilityLevel(currentdummy, abilId, abillevel)
endif
set abrem = AbilRemoval.create(currentdummy, abilId)
call TimerStart(NewTimerEx(abrem), expiration, false, function RecycleDummy)
return currentdummy
endfunction
function GetAttackDummyAngled takes player owner, integer abilId, integer abillevel, real x, real y, real facing, real expiration returns unit
set currentdummy = GetAttackDummy(owner, abilId, abillevel, x, y, expiration)
call BlzSetUnitFacingEx(currentdummy, facing)
return currentdummy
endfunction
endlibrary
//===========================================================================
//
// Damage Engine 5.9.0.0 - update requires re-copying the Damage Engine category.
//
/*
Three GUI Damage systems for the community of The Hive,
Seven vJass Damage systems for the JASS-heads on their pedestals high,
Nine competing Damage systems, doomed to die,
One for Bribe on his dark throne
In the Land of the Hive where the Workshop lies.
One Damage Engine to rule them all, One Damage Engine to find them,
One Damage Engine to bring them all and in cross-compatibility unite them.
*/
//! novjass
JASS API (work in progress - I have a lot of documentation to go through):
struct Damage extends array
readonly static unit source //stores udg_DamageEventSource
readonly static unit target //stores udg_DamageEventTarget
static real amount //stores udg_DamageEventAmount
readonly unit sourceUnit //stores udg_DamageEventSource by index
readonly unit targetUnit //stores udg_DamageEventTarget by index
real damage //stores udg_DamageEventAmount by index
readonly real prevAmt //stores udg_DamageEventPrevAmt by index
attacktype attackType //stores udg_DamageEventAttackT by index
damagetype damageType //stores udg_DamageEventDamageT by index
weapontype weaponType //stores udg_DamageEventWeaponT by index
integer userType //stores udg_DamageEventType by index
readonly integer eFilter //replaces the previous eventFilter variable
readonly boolean isAttack //stores udg_IsDamageAttack by index
readonly boolean isCode //stores udg_IsDamageCode by index
readonly boolean isMelee //stores udg_IsDamageMelee by index
readonly boolean isRanged //stores udg_IsDamageRanged by index
readonly boolean isSpell //stores udg_IsDamageSpell by index
real armorPierced //stores udg_DamageEventArmorPierced by index
integer armorType //stores udg_DamageEventArmorT by index
integer defenseType //stores udg_DamageEventDefenseT by index
static boolean operator enabled
- Set to false to disable the damage event triggers/false to reverse that
static method apply takes unit src, unit tgt, real amt, boolean a, boolean r, attacktype at, damagetype dt, weapontype wt returns Damage
- Same arguments as "UnitDamageTarget" but has the benefit of being performance-friendly during recursive events.
- Will automatically cause the damage to be registered as Code damage.
static method applySpell takes unit src, unit tgt, real amt, damagetype dt returns Damage
- A simplified version of the above function that autofills in the booleans, attack type and weapon type.
static method applyAttack takes unit src, unit tgt, real amt, boolean ranged, attacktype at, weapontype wt returns Damage
- A different variation of the above which autofills the "attack" boolean and sets the damagetype to DAMAGE_TYPE_NORMAL.
struct DamageTrigger extends array
method operator filter= takes integer filter returns nothing
// Apply primary filters such as DamageEngine_FILTER_MELEE/RANGED/SPELL which are based off of limitop handles to enable easier access for GUI folks
// Full filter list:
- global integer DamageEngine_FILTER_ATTACK
- global integer DamageEngine_FILTER_MELEE
- global integer DamageEngine_FILTER_OTHER
- global integer DamageEngine_FILTER_RANGED
- global integer DamageEngine_FILTER_SPELL
- global integer DamageEngine_FILTER_CODE
boolean configured //set to True after configuring any filters listed below.
method configure takes nothing returns nothing
// Apply custom filters after setting any desired udg_DamageFilter variables (for GUI).
// Alternatively, vJass users can set these instead. Just be mindful to set the variable
// "configured" to true after settings these.
unit source
unit target
integer sourceType
integer targetType
integer sourceBuff
integer targetBuff
real damageMin
integer attackType
integer damageType
integer userType
//The string in the aruments below requires the following API:
// "" for standard damage event
// "Modifier(or Mod if you prefer)/After/Lethal/AOE" for the others
static method registerTrigger takes trigger whichTrig, string var, real value returns nothing
static method unregister takes trigger t, string eventName, real value, boolean reset returns boolean
static method getIndex takes trigger t, string eventName, real value returns integer
//If you already have the index of the trigger you want to unregister.
method unregisterByIndex takes boolean reset returns boolean
// Converts a code argument to a trigger, while checking if the same code had already been registered before.
static method operator [] takes code c returns trigger
//The accepted strings here use the same criteria as DamageTrigger.getIndex/registerTrigger/unregister
function TriggerRegisterDamageEngineEx takes trigger whichTrig, string eventName, real value, integer f returns nothing
function TriggerRegisterDamageEngine takes trigger whichTrig, string eventName, real value returns nothing
function RegisterDamageEngineEx takes code c, string eventName, real value, integer f returns nothing
function RegisterDamageEngine takes code c, string eventName, real value returns nothing
//! endnovjass
//===========================================================================
library DamageEngine
globals
private constant boolean USE_GUI = true //If you don't use any of the GUI events, set to false to slightly improve performance
private constant boolean USE_SCALING = USE_GUI //If you don't need or want to use DamageScalingUser/WC3 then set this to false
private constant boolean USE_EXTRA = true //If you don't use DamageEventLevel or AOEDamageEvent, set this to false
private constant boolean USE_ARMOR_MOD = true //If you do not modify nor detect armor/defense, set this to false
private constant boolean USE_MELEE_RANGE= true //If you do not detect melee nor ranged damage, set this to false
private constant boolean USE_LETHAL = true //If you do not use LethalDamageEvent nor negative damage (explosive) types, set this to false
private constant integer LIMBO = 16 //When manually-enabled recursion is enabled via DamageEngine_recurion, the engine will never go deeper than LIMBO.
public constant integer TYPE_CODE = 1 //Must be the same as udg_DamageTypeCode, or 0 if you prefer to disable the automatic flag.
public constant integer TYPE_PURE = 2 //Must be the same as udg_DamageTypePure
private constant real DEATH_VAL = 0.405 //In case Blizz ever changes this, it'll be a quick fix here.
private timer alarm = null
private boolean alarmSet = false
//Values to track the original pre-spirit Link/defensive damage values
private Damage lastInstance = 0
private boolean canKick = true
private boolean totem = false
private boolean array attacksImmune
private boolean array damagesImmune
//Made global in order to use enable/disable behavior.
private trigger t1 = null
private trigger t2 = null
private trigger t3 = null //Catches, stores recursive events
//These variables coincide with Blizzard's "limitop" type definitions so as to enable users (GUI in particular) with some nice performance perks.
public constant integer FILTER_ATTACK = 0 //LESS_THAN
public constant integer FILTER_MELEE = 1 //LESS_THAN_OR_EQUAL
public constant integer FILTER_OTHER = 2 //EQUAL
public constant integer FILTER_RANGED = 3 //GREATER_THAN_OR_EQUAL
public constant integer FILTER_SPELL = 4 //GREATER_THAN
public constant integer FILTER_CODE = 5 //NOT_EQUAL
public constant integer FILTER_MAX = 6
private integer eventFilter = FILTER_OTHER
public boolean inception = false //When true, it allows your trigger to potentially go recursive up to LIMBO. However it must be set per-trigger throughout the game and not only once per trigger during map initialization.
private boolean dreaming = false
private integer sleepLevel = 0
private group proclusGlobal = null //track sources of recursion
private group fischerMorrow = null //track targets of recursion
private boolean kicking = false
private boolean eventsRun = false
private keyword run
private keyword trigFrozen
private keyword levelsDeep
private keyword inceptionTrig
private boolean hasLethal = false
endglobals
native UnitAlive takes unit u returns boolean
//GUI Vars:
/*
Retained from 3.8 and prior:
----------------------------
unit udg_DamageEventSource
unit udg_DamageEventTarget
unit udg_EnhancedDamageTarget
group udg_DamageEventAOEGroup
integer udg_DamageEventAOE
integer udg_DamageEventLevel
real udg_DamageModifierEvent
real udg_DamageEvent
real udg_AfterDamageEvent
real udg_DamageEventAmount
real udg_DamageEventPrevAmt
real udg_AOEDamageEvent
boolean udg_DamageEventOverride
boolean udg_NextDamageType
boolean udg_DamageEventType
boolean udg_IsDamageSpell
//Added in 5.0:
boolean udg_IsDamageMelee
boolean udg_IsDamageRanged
unit udg_AOEDamageSource
real udg_LethalDamageEvent
real udg_LethalDamageHP
real udg_DamageScalingWC3
integer udg_DamageEventAttackT
integer udg_DamageEventDamageT
integer udg_DamageEventWeaponT
//Added in 5.1:
boolean udg_IsDamageCode
//Added in 5.2:
integer udg_DamageEventArmorT
integer udg_DamageEventDefenseT
//Addded in 5.3:
real DamageEventArmorPierced
real udg_DamageScalingUser
//Added in 5.4.2 to allow GUI users to re-issue the exact same attack and damage type at the attacker.
attacktype array udg_CONVERTED_ATTACK_TYPE
damagetype array udg_CONVERTED_DAMAGE_TYPE
//Added after Reforged introduced the new native BlzGetDamageIsAttack
boolean udg_IsDamageAttack
//Added in 5.6 to give GUI users control over the "IsDamageAttack", "IsDamageRanged" and "DamageEventWeaponT" field
boolean udg_NextDamageIsAttack //The first boolean value in the UnitDamageTarget native
boolean udg_NextDamageIsMelee //Flag the damage classification as melee
boolean udg_NextDamageIsRanged //The second boolean value in the UnitDamageTarget native
integer udg_NextDamageWeaponT //Allows control over damage sound effect
//Added in 5.7 to enable efficient, built-in filtering (see the below "checkConfig" method - I recommend commenting-out anything you don't need in your map)
integer udg_DamageFilterAttackT
integer udg_DamageFilterDamageT //filter for a specific attack/damage type
unit udg_DamageFilterSource
unit udg_DamageFilterTarget //filter for a specific source/target
integer udg_DamageFilterSourceT
integer udg_DamageFilterTargetT //unit type of source/target
integer udg_DamageFilterType //which DamageEventType was used
integer udg_DamageFilterSourceB
integer udg_DamageFilterTargetB //if source/target has a buff
real udg_DamageFilterMinAmount //only allow a minimum damage threshold
//Added in 5.8:
boolean udg_RemoveDamageEvent //Allow GUI users to more fully unregister a damage event trigger. Can only be used from within a damage event (of any kind).
integer udg_DamageFilterSourceA
integer udg_DamageFilterTargetA //Check if a source or target have a specific ability (will overwrite any source or target buff check, I need to use this because GUI differentiates ability ID and buff ID)
integer udg_DamageFilterSourceI
integer udg_DamageFilterTargetI //Check if a source or target have a specific type of item
integer udg_DamageFilterSourceC
integer udg_DamageFilterTargetC //Classification of source/target (e.g. hero, treant, ward)
*/
struct DamageTrigger extends array
static method checkItem takes unit u, integer id returns boolean
local integer i
if IsUnitType(u, UNIT_TYPE_HERO) then
set i = UnitInventorySize(u)
loop
exitwhen i <= 0
set i = i - 1
if GetItemTypeId(UnitItemInSlot(u, i)) == id then
return true
endif
endloop
endif
return false
endmethod
//Map-makers should comment-out any lines they will never need to check for and move to the top any lines
//that are checked more frequently in their map.
method checkConfig takes nothing returns boolean
//call BJDebugMsg("Checking configuration")
if this.sourceType != 0 and GetUnitTypeId(udg_DamageEventSource) != this.sourceType then
elseif this.targetType != 0 and GetUnitTypeId(udg_DamageEventTarget) != this.targetType then
elseif this.sourceBuff != 0 and GetUnitAbilityLevel(udg_DamageEventSource, this.sourceBuff) == 0 then
elseif this.targetBuff != 0 and GetUnitAbilityLevel(udg_DamageEventTarget, this.targetBuff) == 0 then
elseif this.failChance > 0.00 and GetRandomReal(0.00, 1.00) <= this.failChance then
elseif this.userType != 0 and udg_DamageEventType != this.userType then
elseif this.source != null and this.source != udg_DamageEventSource then
elseif this.target != null and this.target != udg_DamageEventTarget then
elseif this.attackType >= 0 and this.attackType != udg_DamageEventAttackT then
elseif this.damageType >= 0 and this.damageType != udg_DamageEventDamageT then
elseif this.sourceItem != 0 and not .checkItem(udg_DamageEventSource, this.sourceItem) then
elseif this.targetItem != 0 and not .checkItem(udg_DamageEventTarget, this.targetItem) then
elseif this.sourceClass >= 0 and not IsUnitType(udg_DamageEventSource, ConvertUnitType(this.sourceClass)) then
elseif this.targetClass >= 0 and not IsUnitType(udg_DamageEventTarget, ConvertUnitType(this.targetClass)) then
elseif udg_DamageEventAmount >= this.damageMin then
//call BJDebugMsg("Configuration passed")
return true
endif
//call BJDebugMsg("Checking failed")
return false
endmethod
//The below variables are to be treated as constant
readonly static thistype MOD = 1
readonly static thistype SHIELD = 4
readonly static thistype DAMAGE = 5
readonly static thistype ZERO = 6
readonly static thistype AFTER = 7
readonly static thistype LETHAL = 8
readonly static thistype AOE = 9
private static integer count = 9
static thistype lastRegistered = 0
private static thistype array trigIndexStack
static thistype eventIndex = 0
static boolean array filters
readonly string eventStr
readonly real weight
boolean usingGUI
//The below variables are to be treated as private
private thistype next
private trigger rootTrig
boolean trigFrozen //Whether the trigger is currently disabled due to recursion
integer levelsDeep //How deep the user recursion currently is.
boolean inceptionTrig //Added in 5.4.2 to simplify the inception variable for very complex DamageEvent trigger.
//configuration variables:
boolean configured
unit source
unit target
integer sourceType
integer targetType
integer sourceBuff
integer targetBuff
integer sourceItem
integer targetItem
integer sourceClass
integer targetClass
real damageMin
real failChance
integer attackType
integer damageType
integer userType
method operator runChance takes nothing returns real
return 1.00 - this.failChance
endmethod
method operator runChance= takes real r returns nothing
set this.failChance = 1.00 - r
endmethod
method configure takes nothing returns nothing
set this.attackType = udg_DamageFilterAttackT
set this.damageType = udg_DamageFilterDamageT
set this.source = udg_DamageFilterSource
set this.target = udg_DamageFilterTarget
set this.sourceType = udg_DamageFilterSourceT
set this.targetType = udg_DamageFilterTargetT
set this.sourceItem = udg_DamageFilterSourceI
set this.targetItem = udg_DamageFilterTargetI
set this.sourceClass = udg_DamageFilterSourceC
set this.targetClass = udg_DamageFilterTargetC
set this.userType = udg_DamageFilterType
set this.damageMin = udg_DamageFilterMinAmount
set this.failChance = 1.00 - (udg_DamageFilterRunChance - udg_DamageFilterFailChance)
if udg_DamageFilterSourceA > 0 then
set this.sourceBuff = udg_DamageFilterSourceA
set udg_DamageFilterSourceA = 0
else
set this.sourceBuff = udg_DamageFilterSourceB
endif
if udg_DamageFilterTargetA > 0 then
set this.targetBuff = udg_DamageFilterTargetA
set udg_DamageFilterTargetA = 0
else
set this.targetBuff = udg_DamageFilterTargetB
endif
set udg_DamageFilterAttackT = -1
set udg_DamageFilterDamageT = -1
set udg_DamageFilterSource = null
set udg_DamageFilterTarget = null
set udg_DamageFilterSourceT = 0
set udg_DamageFilterTargetT = 0
set udg_DamageFilterType = 0
set udg_DamageFilterSourceB = 0
set udg_DamageFilterTargetB = 0
set udg_DamageFilterSourceC = -1
set udg_DamageFilterTargetC = -1
set udg_DamageFilterSourceI = 0
set udg_DamageFilterTargetI = 0
set udg_DamageFilterMinAmount = 0.00
set udg_DamageFilterFailChance = 0.00
set udg_DamageFilterRunChance = 1.00
set this.configured = true
endmethod
static method setGUIFromStruct takes boolean full returns nothing
set udg_DamageEventAmount = Damage.index.damage
set udg_DamageEventAttackT = GetHandleId(Damage.index.attackType)
set udg_DamageEventDamageT = GetHandleId(Damage.index.damageType)
set udg_DamageEventWeaponT = GetHandleId(Damage.index.weaponType)
set udg_DamageEventType = Damage.index.userType
static if USE_ARMOR_MOD then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
set udg_DamageEventArmorPierced = Damage.index.armorPierced
set udg_DamageEventArmorT = Damage.index.armorType
set udg_DamageEventDefenseT = Damage.index.defenseType
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
if full then
set udg_DamageEventSource = Damage.index.sourceUnit
set udg_DamageEventTarget = Damage.index.targetUnit
set udg_DamageEventPrevAmt = Damage.index.prevAmt
set udg_IsDamageAttack = Damage.index.isAttack
set udg_IsDamageCode = Damage.index.isCode
set udg_IsDamageSpell = Damage.index.isSpell
static if USE_MELEE_RANGE then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
set udg_IsDamageMelee = Damage.index.isMelee
set udg_IsDamageRanged = Damage.index.isRanged
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
endif
endmethod
static method setStructFromGUI takes nothing returns nothing
set Damage.index.damage = udg_DamageEventAmount
set Damage.index.attackType = ConvertAttackType(udg_DamageEventAttackT)
set Damage.index.damageType = ConvertDamageType(udg_DamageEventDamageT)
set Damage.index.weaponType = ConvertWeaponType(udg_DamageEventWeaponT)
set Damage.index.userType = udg_DamageEventType
static if USE_ARMOR_MOD then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
set Damage.index.armorPierced = udg_DamageEventArmorPierced
set Damage.index.armorType = udg_DamageEventArmorT
set Damage.index.defenseType = udg_DamageEventDefenseT
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
endmethod
static method getVerboseStr takes string eventName returns string
if eventName == "Modifier" or eventName == "Mod" then
return "udg_DamageModifierEvent"
endif
return "udg_" + eventName + "DamageEvent"
endmethod
private static method getStrIndex takes string var, real lbs returns thistype
local integer root = R2I(lbs)
if (var == "udg_DamageModifierEvent" and root < 4) or var == "udg_PreDamageEvent" then
set root = MOD
elseif var == "udg_DamageModifierEvent" or var == "udg_ArmorDamageEvent" then
set root = SHIELD
elseif (var == "udg_DamageEvent" and root == 2 or root == 0) or var == "udg_ZeroDamageEvent" then
set root = ZERO
elseif var == "udg_DamageEvent" or var == "udg_OnDamageEvent" then
set root = DAMAGE
elseif var == "udg_AfterDamageEvent" then
set root = AFTER
elseif var == "udg_LethalDamageEvent" then
set root = LETHAL
elseif var == "udg_AOEDamageEvent" or var == "udg_SourceDamageEvent" then
set root = AOE
else
set root = 0
//! runtextmacro optional DAMAGE_EVENT_REG_PLUGIN_GDD()
//! runtextmacro optional DAMAGE_EVENT_REG_PLUGIN_PDD()
//! runtextmacro optional DAMAGE_EVENT_REG_PLUGIN_01()
//! runtextmacro optional DAMAGE_EVENT_REG_PLUGIN_02()
//! runtextmacro optional DAMAGE_EVENT_REG_PLUGIN_03()
//! runtextmacro optional DAMAGE_EVENT_REG_PLUGIN_04()
//! runtextmacro optional DAMAGE_EVENT_REG_PLUGIN_05()
endif
return root
endmethod
private method toggleAllFilters takes boolean flag returns nothing
set filters[this + FILTER_ATTACK] = flag
set filters[this + FILTER_MELEE] = flag
set filters[this + FILTER_OTHER] = flag
set filters[this + FILTER_RANGED] = flag
set filters[this + FILTER_SPELL] = flag
set filters[this + FILTER_CODE] = flag
endmethod
method operator filter= takes integer f returns nothing
set this = this*FILTER_MAX
if f == FILTER_OTHER then
call this.toggleAllFilters(true)
else
if f == FILTER_ATTACK then
set filters[this + FILTER_ATTACK] = true
set filters[this + FILTER_MELEE] = true
set filters[this + FILTER_RANGED] = true
else
set filters[this + f] = true
endif
endif
endmethod
static method registerVerbose takes trigger whichTrig, string var, real lbs, boolean GUI, integer filt returns thistype
local thistype index= getStrIndex(var, lbs)
local thistype i = 0
local thistype id = 0
if index == 0 then
return 0
elseif lastRegistered.rootTrig == whichTrig and lastRegistered.usingGUI then
set filters[lastRegistered*FILTER_MAX + filt] = true //allows GUI to register multiple different types of Damage filters to the same trigger
return 0
endif
if not hasLethal and index == LETHAL then
set hasLethal = true
endif
if trigIndexStack[0] == 0 then
set count = count + 1 //List runs from index 10 and up
set id = count
else
set id = trigIndexStack[0]
set trigIndexStack[0] = trigIndexStack[id]
endif
set lastRegistered = id
set id.filter = filt
set id.rootTrig = whichTrig
set id.usingGUI = GUI
set id.weight = lbs
set id.eventStr = var
//Next 2 lines added to fix a bug when using manual vJass configuration,
//discovered and solved by lolreported
set id.attackType = -1
set id.damageType = -1
//they will probably bug out with class types as well, so I should add them, just in case:
set id.sourceClass = -1
set id.targetClass = -1
loop
set i = index.next
exitwhen i == 0 or lbs < i.weight
set index = i
endloop
set index.next = id
set id.next = i
//call BJDebugMsg("Registered " + I2S(id) + " to " + I2S(index) + " and before " + I2S(i))
return lastRegistered
endmethod
static method registerTrigger takes trigger t, string var, real lbs returns thistype
return registerVerbose(t, DamageTrigger.getVerboseStr(var), lbs, false, FILTER_OTHER)
endmethod
private static thistype prev = 0
static method getIndex takes trigger t, string eventName, real lbs returns thistype
local thistype index = getStrIndex(getVerboseStr(eventName), lbs)
loop
set prev = index
set index = index.next
exitwhen index == 0 or index.rootTrig == t
endloop
return index
endmethod
method unregisterByIndex takes boolean reset returns boolean
if this == 0 then
return false
endif
set prev.next = this.next
set trigIndexStack[this] = trigIndexStack[0]
set trigIndexStack[0] = this
if reset then
call this.configure()
set this.configured = false
call thistype(this*FILTER_MAX).toggleAllFilters(false)
endif
return true
endmethod
static method unregister takes trigger t, string eventName, real lbs, boolean reset returns boolean
return getIndex(t, eventName, lbs).unregisterByIndex(reset)
endmethod
method run takes nothing returns nothing
local integer cat = this
local Damage d = Damage.index
static if USE_GUI then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
local boolean structUnset = false
local boolean guiUnset = false
local boolean mod = cat <= DAMAGE
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
if dreaming then
return
endif
set dreaming = true
call DisableTrigger(t1)
call DisableTrigger(t2)
call EnableTrigger(t3)
//call BJDebugMsg("Start of event running")
loop
set this = this.next
exitwhen this == 0
exitwhen cat == MOD and (udg_DamageEventOverride or udg_DamageEventType == TYPE_PURE)
exitwhen cat == SHIELD and udg_DamageEventAmount <= 0.00
static if USE_LETHAL then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
exitwhen cat == LETHAL and udg_LethalDamageHP > DEATH_VAL
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
set eventIndex = this
if (not this.trigFrozen) and filters[this*FILTER_MAX + d.eFilter] and IsTriggerEnabled(this.rootTrig) and ((not this.configured) or (this.checkConfig())) and (cat != AOE or udg_DamageEventAOE > 1 or this.eventStr == "udg_SourceDamageEvent") then
static if USE_GUI then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
if mod then
if this.usingGUI then
if guiUnset then
set guiUnset = false
call setGUIFromStruct(false)
endif
//! runtextmacro optional DAMAGE_EVENT_FILTER_PLUGIN_PDD()
elseif structUnset then
set structUnset = false
call setStructFromGUI()
endif
endif
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
//! runtextmacro optional DAMAGE_EVENT_FILTER_PLUGIN_01()
//! runtextmacro optional DAMAGE_EVENT_FILTER_PLUGIN_02()
//! runtextmacro optional DAMAGE_EVENT_FILTER_PLUGIN_03()
//! runtextmacro optional DAMAGE_EVENT_FILTER_PLUGIN_04()
//! runtextmacro optional DAMAGE_EVENT_FILTER_PLUGIN_05()
//JASS users who do not use actions can modify the below block to just evaluate.
//It should not make any perceptable difference in terms of performance.
if TriggerEvaluate(this.rootTrig) then
call TriggerExecute(this.rootTrig)
endif
//! runtextmacro optional DAMAGE_EVENT_MOD_PLUGIN_01()
//! runtextmacro optional DAMAGE_EVENT_MOD_PLUGIN_02()
//! runtextmacro optional DAMAGE_EVENT_MOD_PLUGIN_03()
//! runtextmacro optional DAMAGE_EVENT_MOD_PLUGIN_04()
//! runtextmacro optional DAMAGE_EVENT_MOD_PLUGIN_05()
static if USE_GUI then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
if mod then
if this.usingGUI then
//! runtextmacro optional DAMAGE_EVENT_MOD_PLUGIN_PDD()
if cat != MOD then
set d.damage = udg_DamageEventAmount
else
set structUnset = true
endif
elseif cat != MOD then
set udg_DamageEventAmount = d.damage
else
set guiUnset = true
endif
endif
if udg_RemoveDamageEvent then
set udg_RemoveDamageEvent = false
call this.unregisterByIndex(true)
endif
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
endif
endloop
static if USE_GUI then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
if structUnset then
call setStructFromGUI()
endif
if guiUnset then
call setGUIFromStruct(false)
endif
else// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
call setGUIFromStruct(false)
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
//call BJDebugMsg("End of event running")
call DisableTrigger(t3)
call EnableTrigger(t1)
call EnableTrigger(t2)
set dreaming = false
endmethod
static trigger array autoTriggers
static boolexpr array autoFuncs
static integer autoN = 0
static method operator [] takes code c returns trigger
local integer i = 0
local boolexpr b = Filter(c)
loop
if i == autoN then
set autoTriggers[i] = CreateTrigger()
set autoFuncs[i] = b
call TriggerAddCondition(autoTriggers[i], b)
exitwhen true
endif
set i = i + 1
exitwhen b == autoFuncs[i]
endloop
return autoTriggers[i]
endmethod
endstruct
//! runtextmacro optional DAMAGE_EVENT_USER_STRUCT_PLUGIN_01()
//! runtextmacro optional DAMAGE_EVENT_USER_STRUCT_PLUGIN_02()
//! runtextmacro optional DAMAGE_EVENT_USER_STRUCT_PLUGIN_03()
//! runtextmacro optional DAMAGE_EVENT_USER_STRUCT_PLUGIN_04()
//! runtextmacro optional DAMAGE_EVENT_USER_STRUCT_PLUGIN_05()
struct Damage extends array
readonly unit sourceUnit //stores udg_DamageEventSource
readonly unit targetUnit //stores udg_DamageEventTarget
real damage //stores udg_DamageEventAmount
readonly real prevAmt //stores udg_DamageEventPrevAmt
attacktype attackType //stores udg_DamageEventAttackT
damagetype damageType //stores udg_DamageEventDamageT
weapontype weaponType //stores udg_DamageEventWeaponT
integer userType //stores udg_DamageEventType
readonly boolean isAttack //stores udg_IsDamageAttack
readonly boolean isCode //stores udg_IsDamageCode
readonly boolean isSpell //stores udg_IsDamageSpell
static if USE_MELEE_RANGE then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
readonly boolean isMelee //stores udg_IsDamageMelee
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
readonly boolean isRanged //stores udg_IsDamageRanged
readonly integer eFilter //stores the previous eventFilter variable
static if USE_ARMOR_MOD then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
real armorPierced //stores udg_DamageEventArmorPierced
integer armorType //stores udg_DamageEventArmorT
integer defenseType //stores udg_DamageEventDefenseT
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
readonly static Damage index = 0
private static Damage damageStack = 0
private static Damage prepped = 0
private static integer count = 0 //The number of currently-running queued or sequential damage instances
private Damage stackRef
private DamageTrigger recursiveTrig
private integer prevArmorT
private integer prevDefenseT
static method operator source takes nothing returns unit
return udg_DamageEventSource
endmethod
static method operator target takes nothing returns unit
return udg_DamageEventTarget
endmethod
static method operator amount takes nothing returns real
return Damage.index.damage
endmethod
static method operator amount= takes real r returns nothing
set Damage.index.damage = r
endmethod
static if USE_ARMOR_MOD then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
private method setArmor takes boolean reset returns nothing
local real pierce
local integer at
local integer dt
if reset then
set pierce = udg_DamageEventArmorPierced
set at = Damage.index.prevArmorT
set dt = Damage.index.prevDefenseT
set udg_DamageEventArmorPierced = 0.00
set this.armorPierced = 0.00
else
set pierce = -udg_DamageEventArmorPierced
set at = udg_DamageEventArmorT
set dt = udg_DamageEventDefenseT
endif
if not (pierce == 0.00) then //Changed condition thanks to bug reported by BLOKKADE
call BlzSetUnitArmor(udg_DamageEventTarget, BlzGetUnitArmor(udg_DamageEventTarget) + pierce)
endif
if Damage.index.prevArmorT != udg_DamageEventArmorT then
call BlzSetUnitIntegerField(udg_DamageEventTarget, UNIT_IF_ARMOR_TYPE, at)
endif
if Damage.index.prevDefenseT != udg_DamageEventDefenseT then
call BlzSetUnitIntegerField(udg_DamageEventTarget, UNIT_IF_DEFENSE_TYPE, dt)
endif
endmethod
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
static if USE_EXTRA then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
private static method onAOEEnd takes nothing returns nothing
call DamageTrigger.AOE.run()
set udg_DamageEventAOE = 1
set udg_DamageEventLevel = 1
set udg_EnhancedDamageTarget = null
set udg_AOEDamageSource = null
call GroupClear(udg_DamageEventAOEGroup)
endmethod
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
private static method afterDamage takes nothing returns nothing
if udg_DamageEventDamageT != 0 and not (udg_DamageEventPrevAmt == 0.00) then
call DamageTrigger.AFTER.run()
set udg_DamageEventDamageT = 0
set udg_DamageEventPrevAmt = 0.00
endif
endmethod
private method doPreEvents takes boolean natural returns boolean
static if USE_ARMOR_MOD then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
set this.armorType = BlzGetUnitIntegerField(this.targetUnit, UNIT_IF_ARMOR_TYPE)
set this.defenseType = BlzGetUnitIntegerField(this.targetUnit, UNIT_IF_DEFENSE_TYPE)
set this.prevArmorT = this.armorType
set this.prevDefenseT = this.defenseType
set this.armorPierced = 0.00
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
set Damage.index = this
call DamageTrigger.setGUIFromStruct(true)
call GroupAddUnit(proclusGlobal, udg_DamageEventSource)
call GroupAddUnit(fischerMorrow, udg_DamageEventTarget)
//! runtextmacro optional DAMAGE_EVENT_PRE_VARS_PLUGIN_01()
//! runtextmacro optional DAMAGE_EVENT_PRE_VARS_PLUGIN_02()
//! runtextmacro optional DAMAGE_EVENT_PRE_VARS_PLUGIN_03()
//! runtextmacro optional DAMAGE_EVENT_PRE_VARS_PLUGIN_04()
//! runtextmacro optional DAMAGE_EVENT_PRE_VARS_PLUGIN_05()
if not (udg_DamageEventAmount == 0.00) then
set udg_DamageEventOverride = udg_DamageEventDamageT == 0
call DamageTrigger.MOD.run()
static if not USE_GUI then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
call DamageTrigger.setGUIFromStruct(false)
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
if natural then
call BlzSetEventAttackType(this.attackType)
call BlzSetEventDamageType(this.damageType)
call BlzSetEventWeaponType(this.weaponType)
call BlzSetEventDamage(udg_DamageEventAmount)
endif
static if USE_ARMOR_MOD then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
call this.setArmor(false)
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
return false
endif
return true
endmethod
private static method unfreeze takes nothing returns nothing
local Damage i = damageStack
loop
exitwhen i == 0
set i = i - 1
set i.stackRef.recursiveTrig.trigFrozen = false
set i.stackRef.recursiveTrig.levelsDeep = 0
endloop
call EnableTrigger(t1)
call EnableTrigger(t2)
set kicking = false
set damageStack = 0
set prepped = 0
set dreaming = false
set sleepLevel = 0
call GroupClear(proclusGlobal)
call GroupClear(fischerMorrow)
//call BJDebugMsg("Cleared up the groups")
endmethod
static method finish takes nothing returns nothing
local Damage i = 0
local integer exit
if eventsRun then
set eventsRun = false
call afterDamage()
endif
if canKick and not kicking then
if damageStack != 0 then
set kicking = true
loop
set sleepLevel = sleepLevel + 1
set exit = damageStack
loop
set prepped = i.stackRef
if UnitAlive(prepped.targetUnit) then //Added just in case dead units had issues.
call prepped.doPreEvents(false) //don't evaluate the pre-event
if prepped.damage > 0.00 then
call DisableTrigger(t1) //Force only the after armor event to run.
call EnableTrigger(t2) //in case the user forgot to re-enable this
set totem = true
call UnitDamageTarget(prepped.sourceUnit, prepped.targetUnit, prepped.damage, prepped.isAttack, prepped.isRanged, prepped.attackType, prepped.damageType, prepped.weaponType)
else
//No new events run at all in this case
if udg_DamageEventDamageT != 0 then
call DamageTrigger.DAMAGE.run()
endif
if prepped.damage < 0.00 then
//No need for BlzSetEventDamage here
call SetWidgetLife(prepped.targetUnit, GetWidgetLife(prepped.targetUnit) - prepped.damage)
endif
static if USE_ARMOR_MOD then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
call prepped.setArmor(true)
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
endif
call afterDamage()
endif
set i = i + 1
exitwhen i == exit
endloop
exitwhen i == damageStack
endloop
endif
call unfreeze()
endif
endmethod
private static method failsafeClear takes nothing returns nothing
static if USE_ARMOR_MOD then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
call Damage.index.setArmor(true)
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
set canKick = true
set kicking = false
set totem = false
if udg_DamageEventDamageT != 0 then
call DamageTrigger.DAMAGE.run()
set eventsRun = true
endif
call finish()
endmethod
static method operator enabled= takes boolean b returns nothing
if b then
if dreaming then
call EnableTrigger(t3)
else
call EnableTrigger(t1)
call EnableTrigger(t2)
endif
else
if dreaming then
call DisableTrigger(t3)
else
call DisableTrigger(t1)
call DisableTrigger(t2)
endif
endif
endmethod
static method operator enabled takes nothing returns boolean
return IsTriggerEnabled(t1)
endmethod
private static boolean arisen = false
private static method getOutOfBed takes nothing returns nothing
if totem then
call failsafeClear() //WarCraft 3 didn't run the DAMAGED event despite running the DAMAGING event.
else
set canKick = true
set kicking = false
call finish()
endif
static if USE_EXTRA then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
call onAOEEnd()
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
set arisen = true
endmethod
private static method wakeUp takes nothing returns nothing
set dreaming = false
set Damage.enabled = true
call ForForce(bj_FORCE_PLAYER[0], function thistype.getOutOfBed) //Moved to a new thread in case of a thread crash
if not arisen then
//call BJDebugMsg("DamageEngine issue: thread crashed!")
call unfreeze()
else
set arisen = false
endif
set Damage.count = 0
set Damage.index = 0
set alarmSet = false
//call BJDebugMsg("Timer wrapped up")
endmethod
private method addRecursive takes nothing returns nothing
if not (this.damage == 0.00) then
set this.recursiveTrig = DamageTrigger.eventIndex
if not this.isCode then
set this.isCode = true
set this.userType = TYPE_CODE
endif
set inception = inception or DamageTrigger.eventIndex.inceptionTrig
if kicking and IsUnitInGroup(this.sourceUnit, proclusGlobal) and IsUnitInGroup(this.targetUnit, fischerMorrow) then
if not inception then
set DamageTrigger.eventIndex.trigFrozen = true
elseif not DamageTrigger.eventIndex.trigFrozen then
set DamageTrigger.eventIndex.inceptionTrig = true
if DamageTrigger.eventIndex.levelsDeep < sleepLevel then
set DamageTrigger.eventIndex.levelsDeep = DamageTrigger.eventIndex.levelsDeep + 1
if DamageTrigger.eventIndex.levelsDeep >= LIMBO then
set DamageTrigger.eventIndex.trigFrozen = true
endif
endif
endif
endif
set damageStack.stackRef = this
set damageStack = damageStack + 1
//call BJDebugMsg("damageStack: " + I2S(damageStack) + " levelsDeep: " + I2S(DamageTrigger.eventIndex.levelsDeep) + " sleepLevel: " + I2S(sleepLevel))
endif
set inception = false
endmethod
private static method clearNexts takes nothing returns nothing
set udg_NextDamageIsAttack = false
set udg_NextDamageType = 0
set udg_NextDamageWeaponT = 0
static if USE_MELEE_RANGE then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
set udg_NextDamageIsMelee = false
set udg_NextDamageIsRanged = false
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
endmethod
static method create takes unit src, unit tgt, real amt, boolean a, attacktype at, damagetype dt, weapontype wt returns Damage
local Damage d = Damage.count + 1
set Damage.count = d
set d.sourceUnit = src
set d.targetUnit = tgt
set d.damage = amt
set d.prevAmt = amt
set d.attackType = at
set d.damageType = dt
set d.weaponType = wt
set d.isAttack = udg_NextDamageIsAttack or a
set d.isSpell = d.attackType == null and not d.isAttack
return d
endmethod
private static method createFromEvent takes nothing returns Damage
local Damage d = create(GetEventDamageSource(), GetTriggerUnit(), GetEventDamage(), BlzGetEventIsAttack(), BlzGetEventAttackType(), BlzGetEventDamageType(), BlzGetEventWeaponType())
set d.isCode = udg_NextDamageType != 0 or udg_NextDamageIsAttack or udg_NextDamageIsRanged or udg_NextDamageIsMelee or d.damageType == DAMAGE_TYPE_MIND or udg_NextDamageWeaponT != 0 or (d.damageType == DAMAGE_TYPE_UNKNOWN and not (d.damage == 0.00))
if d.isCode then
if udg_NextDamageType != 0 then
set d.userType = udg_NextDamageType
else
set d.userType = TYPE_CODE
endif
static if USE_MELEE_RANGE then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
set d.isMelee = udg_NextDamageIsMelee
set d.isRanged = udg_NextDamageIsRanged
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
set d.eFilter = FILTER_CODE
if udg_NextDamageWeaponT != 0 then
set d.weaponType = ConvertWeaponType(udg_NextDamageWeaponT)
set udg_NextDamageWeaponT = 0
endif
else
set d.userType = 0
if d.damageType == DAMAGE_TYPE_NORMAL and d.isAttack then
static if USE_MELEE_RANGE then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
set d.isMelee = IsUnitType(d.sourceUnit, UNIT_TYPE_MELEE_ATTACKER)
set d.isRanged = IsUnitType(d.sourceUnit, UNIT_TYPE_RANGED_ATTACKER)
if d.isMelee and d.isRanged then
set d.isMelee = d.weaponType != null // Melee units play a sound when damaging
set d.isRanged = not d.isMelee // In the case where a unit is both ranged and melee, the ranged attack plays no sound.
endif
if d.isMelee then
set d.eFilter = FILTER_MELEE
elseif d.isRanged then
set d.eFilter = FILTER_RANGED
else
set d.eFilter = FILTER_ATTACK
endif
else
set d.eFilter = FILTER_ATTACK
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
else
if d.isSpell then
set d.eFilter = FILTER_SPELL
else
set d.eFilter = FILTER_OTHER
endif
static if USE_MELEE_RANGE then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
set d.isMelee = false
set d.isRanged = false
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
endif
endif
call clearNexts()
return d
endmethod
private static method onRecursion takes nothing returns boolean //New in 5.7
local Damage d = Damage.createFromEvent()
call d.addRecursive()
call BlzSetEventDamage(0.00)
return false
endmethod
private static method onDamaging takes nothing returns boolean
local Damage d = Damage.createFromEvent()
//call BJDebugMsg("Pre-damage event running for " + GetUnitName(GetTriggerUnit()))
if alarmSet then
if totem then //WarCraft 3 didn't run the DAMAGED event despite running the DAMAGING event.
if d.damageType == DAMAGE_TYPE_SPIRIT_LINK or d.damageType == DAMAGE_TYPE_DEFENSIVE or d.damageType == DAMAGE_TYPE_PLANT then
set totem = false
set lastInstance= Damage.index
set canKick = false
else
call failsafeClear() //Not an overlapping event - just wrap it up
endif
else
call finish() //wrap up any previous damage index
endif
static if USE_EXTRA then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
if d.sourceUnit != udg_AOEDamageSource then
call onAOEEnd()
set udg_AOEDamageSource = d.sourceUnit
elseif d.targetUnit == udg_EnhancedDamageTarget then
set udg_DamageEventLevel= udg_DamageEventLevel + 1
elseif not IsUnitInGroup(d.targetUnit, udg_DamageEventAOEGroup) then
set udg_DamageEventAOE = udg_DamageEventAOE + 1
endif
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
else
call TimerStart(alarm, 0.00, false, function Damage.wakeUp)
set alarmSet = true
static if USE_EXTRA then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
set udg_AOEDamageSource = d.sourceUnit
set udg_EnhancedDamageTarget= d.targetUnit
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
endif
static if USE_EXTRA then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
call GroupAddUnit(udg_DamageEventAOEGroup, d.targetUnit)
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
if d.doPreEvents(true) then
call DamageTrigger.ZERO.run()
set canKick = true
call finish()
endif
set totem = lastInstance == 0 or attacksImmune[udg_DamageEventAttackT] or damagesImmune[udg_DamageEventDamageT] or not IsUnitType(udg_DamageEventTarget, UNIT_TYPE_MAGIC_IMMUNE)
return false
endmethod
private static method onDamaged takes nothing returns boolean
local real r = GetEventDamage()
local Damage d = Damage.index
//call BJDebugMsg("Second damage event running for " + GetUnitName(GetTriggerUnit()))
if prepped > 0 then
set prepped = 0
elseif dreaming or d.prevAmt == 0.00 then
return false
elseif totem then
set totem = false
else
//This should only happen for stuff like Spirit Link or Thorns Aura/Carapace
call afterDamage()
set Damage.index = lastInstance
set lastInstance = 0
set d = Damage.index
set canKick = true
call DamageTrigger.setGUIFromStruct(true)
endif
static if USE_ARMOR_MOD then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
call d.setArmor(true)
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
static if USE_SCALING then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
if not (udg_DamageEventAmount == 0.00) and not (r == 0.00) then
set udg_DamageScalingWC3 = r / udg_DamageEventAmount
elseif udg_DamageEventAmount > 0.00 then
set udg_DamageScalingWC3 = 0.00
else
set udg_DamageScalingWC3 = 1.00
if udg_DamageEventPrevAmt == 0.00 then
set udg_DamageScalingUser = 0.00
else
set udg_DamageScalingUser = udg_DamageEventAmount/udg_DamageEventPrevAmt
endif
endif
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
set udg_DamageEventAmount = r
set d.damage = r
//! runtextmacro optional DAMAGE_EVENT_VARS_PLUGIN_GDD()
//! runtextmacro optional DAMAGE_EVENT_VARS_PLUGIN_PDD()
//! runtextmacro optional DAMAGE_EVENT_VARS_PLUGIN_01()
//! runtextmacro optional DAMAGE_EVENT_VARS_PLUGIN_02()
//! runtextmacro optional DAMAGE_EVENT_VARS_PLUGIN_03()
//! runtextmacro optional DAMAGE_EVENT_VARS_PLUGIN_04()
//! runtextmacro optional DAMAGE_EVENT_VARS_PLUGIN_05()
if udg_DamageEventAmount > 0.00 then
call DamageTrigger.SHIELD.run()
static if not USE_GUI then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
set udg_DamageEventAmount = d.damage
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
static if USE_LETHAL then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
if hasLethal or udg_DamageEventType < 0 then
set udg_LethalDamageHP = GetWidgetLife(udg_DamageEventTarget) - udg_DamageEventAmount
if udg_LethalDamageHP <= DEATH_VAL then
if hasLethal then
call DamageTrigger.LETHAL.run()
set udg_DamageEventAmount = GetWidgetLife(udg_DamageEventTarget) - udg_LethalDamageHP
set d.damage = udg_DamageEventAmount
endif
if udg_DamageEventType < 0 and udg_LethalDamageHP <= DEATH_VAL then
call SetUnitExploded(udg_DamageEventTarget, true)
endif
endif
endif
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
static if USE_SCALING then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
if udg_DamageEventPrevAmt == 0.00 or udg_DamageScalingWC3 == 0.00 then
set udg_DamageScalingUser = 0.00
else
set udg_DamageScalingUser = udg_DamageEventAmount/udg_DamageEventPrevAmt/udg_DamageScalingWC3
endif
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
endif
if udg_DamageEventDamageT != 0 then
call DamageTrigger.DAMAGE.run()
endif
call BlzSetEventDamage(udg_DamageEventAmount)
set eventsRun = true
if udg_DamageEventAmount == 0.00 then
call finish()
endif
return false
endmethod
static method apply takes unit src, unit tgt, real amt, boolean a, boolean r, attacktype at, damagetype dt, weapontype wt returns Damage
local Damage d
if udg_NextDamageType == 0 then
set udg_NextDamageType = TYPE_CODE
endif
if dreaming then
set d = create(src, tgt, amt, a, at, dt, wt)
set d.isCode = true
set d.eFilter = FILTER_CODE
set d.userType = udg_NextDamageType
static if USE_MELEE_RANGE then// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
if not d.isSpell then
set d.isRanged = udg_NextDamageIsRanged or r
set d.isMelee = not d.isRanged
endif
endif// \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
call d.addRecursive()
else
call UnitDamageTarget(src, tgt, amt, a, r, at, dt, wt)
set d = Damage.index
call finish()
endif
call clearNexts()
return d
endmethod
static method applySpell takes unit src, unit tgt, real amt, damagetype dt returns Damage
return apply(src, tgt, amt, false, false, null, dt, null)
endmethod
static method applyAttack takes unit src, unit tgt, real amt, boolean ranged, attacktype at, weapontype wt returns Damage
return apply(src, tgt, amt, true, ranged, at, DAMAGE_TYPE_NORMAL, wt)
endmethod
//===========================================================================
private static method onInit takes nothing returns nothing
set alarm = CreateTimer()
set proclusGlobal = CreateGroup()
set fischerMorrow = CreateGroup()
set t1 = CreateTrigger()
set t2 = CreateTrigger()
set t3 = CreateTrigger() //Moved from globals block as per request of user Ricola3D
call TriggerRegisterAnyUnitEventBJ(t1, EVENT_PLAYER_UNIT_DAMAGING)
call TriggerAddCondition(t1, Filter(function Damage.onDamaging))
call TriggerRegisterAnyUnitEventBJ(t2, EVENT_PLAYER_UNIT_DAMAGED)
call TriggerAddCondition(t2, Filter(function Damage.onDamaged))
//For recursion
call TriggerRegisterAnyUnitEventBJ(t3, EVENT_PLAYER_UNIT_DAMAGING)
call TriggerAddCondition(t3, Filter(function Damage.onRecursion))
call DisableTrigger(t3)
//For preventing Thorns/Defensive glitch.
//Data gathered from https://www.hiveworkshop.com/threads/repo-in-progress-mapping-damage-types-to-their-abilities.316271/
set attacksImmune[0] = false //ATTACK_TYPE_NORMAL
set attacksImmune[1] = true //ATTACK_TYPE_MELEE
set attacksImmune[2] = true //ATTACK_TYPE_PIERCE
set attacksImmune[3] = true //ATTACK_TYPE_SIEGE
set attacksImmune[4] = false //ATTACK_TYPE_MAGIC
set attacksImmune[5] = true //ATTACK_TYPE_CHAOS
set attacksImmune[6] = true //ATTACK_TYPE_HERO
set damagesImmune[0] = true //DAMAGE_TYPE_UNKNOWN
set damagesImmune[4] = true //DAMAGE_TYPE_NORMAL
set damagesImmune[5] = true //DAMAGE_TYPE_ENHANCED
set damagesImmune[8] = false //DAMAGE_TYPE_FIRE
set damagesImmune[9] = false //DAMAGE_TYPE_COLD
set damagesImmune[10] = false //DAMAGE_TYPE_LIGHTNING
set damagesImmune[11] = true //DAMAGE_TYPE_POISON
set damagesImmune[12] = true //DAMAGE_TYPE_DISEASE
set damagesImmune[13] = false //DAMAGE_TYPE_DIVINE
set damagesImmune[14] = false //DAMAGE_TYPE_MAGIC
set damagesImmune[15] = false //DAMAGE_TYPE_SONIC
set damagesImmune[16] = true //DAMAGE_TYPE_ACID
set damagesImmune[17] = false //DAMAGE_TYPE_FORCE
set damagesImmune[18] = false //DAMAGE_TYPE_DEATH
set damagesImmune[19] = false //DAMAGE_TYPE_MIND
set damagesImmune[20] = false //DAMAGE_TYPE_PLANT
set damagesImmune[21] = false //DAMAGE_TYPE_DEFENSIVE
set damagesImmune[22] = true //DAMAGE_TYPE_DEMOLITION
set damagesImmune[23] = true //DAMAGE_TYPE_SLOW_POISON
set damagesImmune[24] = false //DAMAGE_TYPE_SPIRIT_LINK
set damagesImmune[25] = false //DAMAGE_TYPE_SHADOW_STRIKE
set damagesImmune[26] = true //DAMAGE_TYPE_UNIVERSAL
endmethod
//! runtextmacro optional DAMAGE_EVENT_STRUCT_PLUGIN_DMGPKG()
//! runtextmacro optional DAMAGE_EVENT_STRUCT_PLUGIN_01()
//! runtextmacro optional DAMAGE_EVENT_STRUCT_PLUGIN_02()
//! runtextmacro optional DAMAGE_EVENT_STRUCT_PLUGIN_03()
//! runtextmacro optional DAMAGE_EVENT_STRUCT_PLUGIN_04()
//! runtextmacro optional DAMAGE_EVENT_STRUCT_PLUGIN_05()
endstruct
public function DebugStr takes nothing returns nothing
local integer i = 0
loop
set udg_CONVERTED_ATTACK_TYPE[i] = ConvertAttackType(i)
exitwhen i == 6
set i = i + 1
endloop
set i = 0
loop
set udg_CONVERTED_DAMAGE_TYPE[i] = ConvertDamageType(i)
exitwhen i == 26
set i = i + 1
endloop
set udg_AttackTypeDebugStr[0] = "SPELLS" //ATTACK_TYPE_NORMAL in JASS
set udg_AttackTypeDebugStr[1] = "NORMAL" //ATTACK_TYPE_MELEE in JASS
set udg_AttackTypeDebugStr[2] = "PIERCE"
set udg_AttackTypeDebugStr[3] = "SIEGE"
set udg_AttackTypeDebugStr[4] = "MAGIC"
set udg_AttackTypeDebugStr[5] = "CHAOS"
set udg_AttackTypeDebugStr[6] = "HERO"
set udg_DamageTypeDebugStr[0] = "UNKNOWN"
set udg_DamageTypeDebugStr[4] = "NORMAL"
set udg_DamageTypeDebugStr[5] = "ENHANCED"
set udg_DamageTypeDebugStr[8] = "FIRE"
set udg_DamageTypeDebugStr[9] = "COLD"
set udg_DamageTypeDebugStr[10] = "LIGHTNING"
set udg_DamageTypeDebugStr[11] = "POISON"
set udg_DamageTypeDebugStr[12] = "DISEASE"
set udg_DamageTypeDebugStr[13] = "DIVINE"
set udg_DamageTypeDebugStr[14] = "MAGIC"
set udg_DamageTypeDebugStr[15] = "SONIC"
set udg_DamageTypeDebugStr[16] = "ACID"
set udg_DamageTypeDebugStr[17] = "FORCE"
set udg_DamageTypeDebugStr[18] = "DEATH"
set udg_DamageTypeDebugStr[19] = "MIND"
set udg_DamageTypeDebugStr[20] = "PLANT"
set udg_DamageTypeDebugStr[21] = "DEFENSIVE"
set udg_DamageTypeDebugStr[22] = "DEMOLITION"
set udg_DamageTypeDebugStr[23] = "SLOW_POISON"
set udg_DamageTypeDebugStr[24] = "SPIRIT_LINK"
set udg_DamageTypeDebugStr[25] = "SHADOW_STRIKE"
set udg_DamageTypeDebugStr[26] = "UNIVERSAL"
set udg_WeaponTypeDebugStr[0] = "NONE" //WEAPON_TYPE_WHOKNOWS in JASS
set udg_WeaponTypeDebugStr[1] = "METAL_LIGHT_CHOP"
set udg_WeaponTypeDebugStr[2] = "METAL_MEDIUM_CHOP"
set udg_WeaponTypeDebugStr[3] = "METAL_HEAVY_CHOP"
set udg_WeaponTypeDebugStr[4] = "METAL_LIGHT_SLICE"
set udg_WeaponTypeDebugStr[5] = "METAL_MEDIUM_SLICE"
set udg_WeaponTypeDebugStr[6] = "METAL_HEAVY_SLICE"
set udg_WeaponTypeDebugStr[7] = "METAL_MEDIUM_BASH"
set udg_WeaponTypeDebugStr[8] = "METAL_HEAVY_BASH"
set udg_WeaponTypeDebugStr[9] = "METAL_MEDIUM_STAB"
set udg_WeaponTypeDebugStr[10] = "METAL_HEAVY_STAB"
set udg_WeaponTypeDebugStr[11] = "WOOD_LIGHT_SLICE"
set udg_WeaponTypeDebugStr[12] = "WOOD_MEDIUM_SLICE"
set udg_WeaponTypeDebugStr[13] = "WOOD_HEAVY_SLICE"
set udg_WeaponTypeDebugStr[14] = "WOOD_LIGHT_BASH"
set udg_WeaponTypeDebugStr[15] = "WOOD_MEDIUM_BASH"
set udg_WeaponTypeDebugStr[16] = "WOOD_HEAVY_BASH"
set udg_WeaponTypeDebugStr[17] = "WOOD_LIGHT_STAB"
set udg_WeaponTypeDebugStr[18] = "WOOD_MEDIUM_STAB"
set udg_WeaponTypeDebugStr[19] = "CLAW_LIGHT_SLICE"
set udg_WeaponTypeDebugStr[20] = "CLAW_MEDIUM_SLICE"
set udg_WeaponTypeDebugStr[21] = "CLAW_HEAVY_SLICE"
set udg_WeaponTypeDebugStr[22] = "AXE_MEDIUM_CHOP"
set udg_WeaponTypeDebugStr[23] = "ROCK_HEAVY_BASH"
set udg_DefenseTypeDebugStr[0] = "LIGHT"
set udg_DefenseTypeDebugStr[1] = "MEDIUM"
set udg_DefenseTypeDebugStr[2] = "HEAVY"
set udg_DefenseTypeDebugStr[3] = "FORTIFIED"
set udg_DefenseTypeDebugStr[4] = "NORMAL" //Typically deals flat damage to all armor types
set udg_DefenseTypeDebugStr[5] = "HERO"
set udg_DefenseTypeDebugStr[6] = "DIVINE"
set udg_DefenseTypeDebugStr[7] = "UNARMORED"
set udg_ArmorTypeDebugStr[0] = "NONE" //ARMOR_TYPE_WHOKNOWS in JASS, added in 1.31
set udg_ArmorTypeDebugStr[1] = "FLESH"
set udg_ArmorTypeDebugStr[2] = "METAL"
set udg_ArmorTypeDebugStr[3] = "WOOD"
set udg_ArmorTypeDebugStr[4] = "ETHEREAL"
set udg_ArmorTypeDebugStr[5] = "STONE"
// -
// Added 25 July 2017 to allow detection of things like Bash or Pulverize or AOE spread
// -
set udg_DamageEventAOE = 1
set udg_DamageEventLevel = 1
// -
// In-game World Editor doesn't allow Attack Type and Damage Type comparisons. Therefore I need to code them as integers into GUI
// -
set udg_ATTACK_TYPE_SPELLS = 0
set udg_ATTACK_TYPE_NORMAL = 1
set udg_ATTACK_TYPE_PIERCE = 2
set udg_ATTACK_TYPE_SIEGE = 3
set udg_ATTACK_TYPE_MAGIC = 4
set udg_ATTACK_TYPE_CHAOS = 5
set udg_ATTACK_TYPE_HERO = 6
// -
set udg_DAMAGE_TYPE_UNKNOWN = 0
set udg_DAMAGE_TYPE_NORMAL = 4
set udg_DAMAGE_TYPE_ENHANCED = 5
set udg_DAMAGE_TYPE_FIRE = 8
set udg_DAMAGE_TYPE_COLD = 9
set udg_DAMAGE_TYPE_LIGHTNING = 10
set udg_DAMAGE_TYPE_POISON = 11
set udg_DAMAGE_TYPE_DISEASE = 12
set udg_DAMAGE_TYPE_DIVINE = 13
set udg_DAMAGE_TYPE_MAGIC = 14
set udg_DAMAGE_TYPE_SONIC = 15
set udg_DAMAGE_TYPE_ACID = 16
set udg_DAMAGE_TYPE_FORCE = 17
set udg_DAMAGE_TYPE_DEATH = 18
set udg_DAMAGE_TYPE_MIND = 19
set udg_DAMAGE_TYPE_PLANT = 20
set udg_DAMAGE_TYPE_DEFENSIVE = 21
set udg_DAMAGE_TYPE_DEMOLITION = 22
set udg_DAMAGE_TYPE_SLOW_POISON = 23
set udg_DAMAGE_TYPE_SPIRIT_LINK = 24
set udg_DAMAGE_TYPE_SHADOW_STRIKE = 25
set udg_DAMAGE_TYPE_UNIVERSAL = 26
// -
// The below variables don't affect damage amount, but do affect the sound played
// They also give important information about the type of attack used.
// They can differentiate between ranged and melee for units who are both
// -
set udg_WEAPON_TYPE_NONE = 0
// Metal Light/Medium/Heavy
set udg_WEAPON_TYPE_ML_CHOP = 1
set udg_WEAPON_TYPE_MM_CHOP = 2
set udg_WEAPON_TYPE_MH_CHOP = 3
set udg_WEAPON_TYPE_ML_SLICE = 4
set udg_WEAPON_TYPE_MM_SLICE = 5
set udg_WEAPON_TYPE_MH_SLICE = 6
set udg_WEAPON_TYPE_MM_BASH = 7
set udg_WEAPON_TYPE_MH_BASH = 8
set udg_WEAPON_TYPE_MM_STAB = 9
set udg_WEAPON_TYPE_MH_STAB = 10
// Wood Light/Medium/Heavy
set udg_WEAPON_TYPE_WL_SLICE = 11
set udg_WEAPON_TYPE_WM_SLICE = 12
set udg_WEAPON_TYPE_WH_SLICE = 13
set udg_WEAPON_TYPE_WL_BASH = 14
set udg_WEAPON_TYPE_WM_BASH = 15
set udg_WEAPON_TYPE_WH_BASH = 16
set udg_WEAPON_TYPE_WL_STAB = 17
set udg_WEAPON_TYPE_WM_STAB = 18
// Claw Light/Medium/Heavy
set udg_WEAPON_TYPE_CL_SLICE = 19
set udg_WEAPON_TYPE_CM_SLICE = 20
set udg_WEAPON_TYPE_CH_SLICE = 21
// Axe Medium
set udg_WEAPON_TYPE_AM_CHOP = 22
// Rock Heavy
set udg_WEAPON_TYPE_RH_BASH = 23
// -
// Since GUI still doesn't provide Defense Type and Armor Types, I needed to include the below
// -
set udg_ARMOR_TYPE_NONE = 0
set udg_ARMOR_TYPE_FLESH = 1
set udg_ARMOR_TYPE_METAL = 2
set udg_ARMOR_TYPE_WOOD = 3
set udg_ARMOR_TYPE_ETHEREAL = 4
set udg_ARMOR_TYPE_STONE = 5
// -
set udg_DEFENSE_TYPE_LIGHT = 0
set udg_DEFENSE_TYPE_MEDIUM = 1
set udg_DEFENSE_TYPE_HEAVY = 2
set udg_DEFENSE_TYPE_FORTIFIED = 3
set udg_DEFENSE_TYPE_NORMAL = 4
set udg_DEFENSE_TYPE_HERO = 5
set udg_DEFENSE_TYPE_DIVINE = 6
set udg_DEFENSE_TYPE_UNARMORED = 7
// -
set udg_UNIT_CLASS_HERO = 0
set udg_UNIT_CLASS_DEAD = 1
set udg_UNIT_CLASS_STRUCTURE = 2
// -
set udg_UNIT_CLASS_FLYING = 3
set udg_UNIT_CLASS_GROUND = 4
// -
set udg_UNIT_CLASS_ATTACKS_FLYING = 5
set udg_UNIT_CLASS_ATTACKS_GROUND = 6
// -
set udg_UNIT_CLASS_MELEE = 7
set udg_UNIT_CLASS_RANGED = 8
// -
set udg_UNIT_CLASS_GIANT = 9
set udg_UNIT_CLASS_SUMMONED = 10
set udg_UNIT_CLASS_STUNNED = 11
set udg_UNIT_CLASS_PLAGUED = 12
set udg_UNIT_CLASS_SNARED = 13
// -
set udg_UNIT_CLASS_UNDEAD = 14
set udg_UNIT_CLASS_MECHANICAL = 15
set udg_UNIT_CLASS_PEON = 16
set udg_UNIT_CLASS_SAPPER = 17
set udg_UNIT_CLASS_TOWNHALL = 18
set udg_UNIT_CLASS_ANCIENT = 19
// -
set udg_UNIT_CLASS_TAUREN = 20
set udg_UNIT_CLASS_POISONED = 21
set udg_UNIT_CLASS_POLYMORPHED = 22
set udg_UNIT_CLASS_SLEEPING = 23
set udg_UNIT_CLASS_RESISTANT = 24
set udg_UNIT_CLASS_ETHEREAL = 25
set udg_UNIT_CLASS_MAGIC_IMMUNE = 26
// -
set udg_DamageFilterAttackT = -1
set udg_DamageFilterDamageT = -1
set udg_DamageFilterSourceC = -1
set udg_DamageFilterTargetC = -1
set udg_DamageFilterRunChance = 1.00
endfunction
//===========================================================================
//
// Setup of automatic events from GUI and custom ones from JASS alike
//
//===========================================================================
public function RegisterFromHook takes trigger whichTrig, string var, limitop op, real value returns nothing
call DamageTrigger.registerVerbose(whichTrig, var, value, true, GetHandleId(op))
endfunction
hook TriggerRegisterVariableEvent RegisterFromHook
function TriggerRegisterDamageEngineEx takes trigger whichTrig, string eventName, real value, integer f returns DamageTrigger
return DamageTrigger.registerVerbose(whichTrig, DamageTrigger.getVerboseStr(eventName), value, false, f)
endfunction
function TriggerRegisterDamageEngine takes trigger whichTrig, string eventName, real value returns DamageTrigger
return DamageTrigger.registerTrigger(whichTrig, eventName, value)
endfunction
function RegisterDamageEngineEx takes code c, string eventName, real value, integer f returns DamageTrigger
return TriggerRegisterDamageEngineEx(DamageTrigger[c], eventName, value, f)
endfunction
//Similar to TriggerRegisterDamageEvent, although takes code instead of trigger as the first argument.
function RegisterDamageEngine takes code c, string eventName, real value returns DamageTrigger
return RegisterDamageEngineEx(c, eventName, value, FILTER_OTHER)
endfunction
//For GUI to tap into more powerful vJass event filtering:
//! textmacro DAMAGE_TRIGGER_CONFIG
if not DamageTrigger.eventIndex.configured then
//! endtextmacro
//! textmacro DAMAGE_TRIGGER_CONFIG_END
call DamageTrigger.eventIndex.configure()
endif
if not DamageTrigger.eventIndex.checkConfig() then
return
endif
//! endtextmacro
endlibrary
// Arcing Text Tag v1.0.0.3 by Maker
library FloatingTextArc
globals
private constant real SIZE_MIN = 0.018 // Minimum size of text
private constant real SIZE_BONUS = 0.012 // Text size increase
private constant real TIME_LIFE = 1.0 // How long the text lasts
private constant real TIME_FADE = 0.8 // When does the text start to fade
private constant real Z_OFFSET = 50 // Height above unit
private constant real Z_OFFSET_BON = 50 // How much extra height the text gains
private constant real VELOCITY = 2 // How fast the text move in x/y plane
private constant real ANGLE = bj_PI/2 // Movement angle of the text. Does not apply if
// ANGLE_RND is true
private constant boolean ANGLE_RND = true // Is the angle random or fixed
private timer TMR = CreateTimer()
endglobals
struct ArcingTextTag extends array
private texttag tt
private real as // angle, sin component
private real ac // angle, cos component
private real ah // arc height
private real t // time
private real x // origin x
private real y // origin y
private string s // text
private static integer array next
private static integer array prev
private static integer array rn
private static integer ic = 0 // Instance count
private static method update takes nothing returns nothing
local thistype this=next[0]
local real p
loop
set p = Sin(bj_PI*.t)
set .t = .t - 0.03125
set .x = .x + .ac
set .y = .y + .as
call SetTextTagPos(.tt, .x, .y, Z_OFFSET + Z_OFFSET_BON * p)
call SetTextTagText(.tt, .s, SIZE_MIN + SIZE_BONUS * p)
if .t <= 0 then
set .tt = null
set next[prev[this]] = next[this]
set prev[next[this]] = prev[this]
set rn[this] = rn[0]
set rn[0] = this
if next[0]==0 then
call PauseTimer(TMR)
endif
endif
set this = next[this]
exitwhen this == 0
endloop
endmethod
public static method create takes string s, unit u returns thistype
local thistype this = rn[0]
static if ANGLE_RND then
local real a = GetRandomReal(0, 2*bj_PI)
else
local real a = ANGLE
endif
if this == 0 then
set ic = ic + 1
set this = ic
else
set rn[0] = rn[this]
endif
set next[this] = 0
set prev[this] = prev[0]
set next[prev[0]] = this
set prev[0] = this
set .s = s
set .x = GetUnitX(u)
set .y = GetUnitY(u)
set .t = TIME_LIFE
set .as = Sin(a)*VELOCITY
set .ac = Cos(a)*VELOCITY
set .ah = 0.
if IsUnitVisible(u, GetLocalPlayer()) then
set .tt = CreateTextTag()
call SetTextTagPermanent(.tt, false)
call SetTextTagLifespan(.tt, TIME_LIFE)
call SetTextTagFadepoint(.tt, TIME_FADE)
call SetTextTagText(.tt, s, SIZE_MIN)
call SetTextTagPos(.tt, .x, .y, Z_OFFSET)
endif
if prev[this] == 0 then
call TimerStart(TMR, 0.03125, true, function thistype.update)
endif
return this
endmethod
endstruct
endlibrary
library HumanSetup initializer Init requires CustomRaceSystem
private function StartMining takes player play, group workers, unit goldmine, unit townhall, unit randhero returns nothing
call IssueTargetOrderById(BlzGroupUnitAt(workers, 0), 851971, goldmine)
call IssueTargetOrderById(BlzGroupUnitAt(workers, 1), 851971, goldmine)
call IssueTargetOrderById(BlzGroupUnitAt(workers, 2), 851971, goldmine)
call IssueTargetOrderById(BlzGroupUnitAt(workers, 3), 851971, goldmine)
call IssueTargetOrderById(BlzGroupUnitAt(workers, 4), 851971, goldmine)
endfunction
private function Init takes nothing returns nothing
local CustomRace c = CustomRace.create("Human",RACE_HUMAN,1.0)
call c.setTownHall('htow') // Town Hall
call c.addWorkerType('hpea',c.NEAR_MINE,5) // Peasant
call c.addHeroType('Hpal') // Paladin
call c.addHeroType('Hamg') // Archmage
call c.addHeroType('Hmkg') // Mountain King
call c.addHeroType('Hblm') // Blood Mage
call c.setCallback(CustomRaceCall.StartMining)
call c.setAIScript("human.ai")
endfunction
endlibrary
library OrcSetup initializer Init requires CustomRaceSystem
private function StartMining takes player play, group workers, unit goldmine, unit townhall, unit randhero returns nothing
call IssueTargetOrderById(BlzGroupUnitAt(workers, 0), 851971, goldmine)
call IssueTargetOrderById(BlzGroupUnitAt(workers, 1), 851971, goldmine)
call IssueTargetOrderById(BlzGroupUnitAt(workers, 2), 851971, goldmine)
call IssueTargetOrderById(BlzGroupUnitAt(workers, 3), 851971, goldmine)
call IssueTargetOrderById(BlzGroupUnitAt(workers, 4), 851971, goldmine)
endfunction
private function Init takes nothing returns nothing
local CustomRace c = CustomRace.create("Orc",RACE_ORC,1.0)
call c.setTownHall('ogre') // Great Hall
call c.addWorkerType('opeo',c.NEAR_MINE,5) // Peon
call c.addHeroType('Obla') // Blademaster
call c.addHeroType('Ofar') // Far Seer
call c.addHeroType('Otch') // Tauren Chieftain
call c.addHeroType('Oshd') // Shadow Hunter
call c.setCallback(CustomRaceCall.StartMining)
call c.setAIScript("orc.ai")
endfunction
endlibrary
library UndeadSetup initializer Init requires CustomRaceSystem
private function WorkerHideToggle takes nothing returns nothing
call ShowUnit(GetEnumUnit(),IsUnitHidden(GetEnumUnit()))
endfunction
private function StartWorking takes nothing returns nothing
if GetUnitTypeId(GetEnumUnit()) == 'uaco' then
call IssueImmediateOrderById(GetEnumUnit(), 852021)
elseif GetUnitTypeId(GetEnumUnit()) == 'ugho' then
call IssueImmediateOrderById(GetEnumUnit(), 852022)
endif
endfunction
private function HauntGoldMine takes player play, group workers, unit goldmine, unit townhall, unit randhero returns nothing
call ForGroup(workers, function WorkerHideToggle)
call BlightGoldMineForPlayerBJ(goldmine, play)
call ForGroup(workers, function WorkerHideToggle)
call ForGroup(workers, function StartWorking)
call DestroyGroup(workers)
endfunction
private function Init takes nothing returns nothing
local CustomRace c = CustomRace.create("Undead",RACE_UNDEAD,1.)
call c.setTownHall('unpl') // Necropolis
call c.addWorkerType('uaco',c.NEAR_MINE,3) // Acolyte
call c.addWorkerType('ugho',c.NEAR_HALL,1) // Ghoul
call c.addHeroType('Udea') // Death Knight
call c.addHeroType('Ulic') // Lich
call c.addHeroType('Udre') // Dreadlord
call c.addHeroType('Ucrl') // Crypt Lord
call c.setCallback(CustomRaceCall.HauntGoldMine)
call c.setAIScript("undead.ai")
endfunction
endlibrary
library NightElfSetup initializer Init requires CustomRaceSystem
private function callback takes nothing returns nothing
call IssueImmediateOrderById(GetEnumUnit(), 852021) // autoharvestgold
endfunction
private function EntangleGoldMine takes player play, group workers, unit goldmine, unit townhall, unit randhero returns nothing
local unit entangledMine
call SetUnitPosition(townhall,GetUnitX(goldmine),GetUnitY(goldmine))
call IssueTargetOrder(townhall, "entangleinstant", goldmine)
// call ForGroup(workers, function callback)
call IssueImmediateOrderById(BlzGroupUnitAt(workers, 0), 852021)
call IssueImmediateOrderById(BlzGroupUnitAt(workers, 1), 852021)
call IssueImmediateOrderById(BlzGroupUnitAt(workers, 2), 852021)
call IssueImmediateOrderById(BlzGroupUnitAt(workers, 3), 852022)
call IssueImmediateOrderById(BlzGroupUnitAt(workers, 4), 852022)
call DestroyGroup(workers)
endfunction
private function Init takes nothing returns nothing
local CustomRace c = CustomRace.create("Night Elf",RACE_NIGHTELF,1.0)
call c.setTownHall('etol') // Tree of Life
call c.addWorkerType('ewsp',c.NEAR_MINE,5) // Wisp
call c.addHeroType('Ekee') // Keeper of the Grove
call c.addHeroType('Emoo') // Priestess of the Moon
call c.addHeroType('Edem') // Demon Hunter
call c.addHeroType('Ewar') // Warden
call c.setCallback(CustomRaceCall.EntangleGoldMine)
call c.setAIScript("elf.ai")
endfunction
endlibrary
library KirinTorSetup initializer Init requires CustomRaceSystem
private function StartWorking takes nothing returns nothing
if GetUnitTypeId(GetEnumUnit()) == 'h006' then
call IssueImmediateOrderById(GetEnumUnit(), 852021)
//elseif GetUnitTypeId(GetEnumUnit()) == 'u000' then
//call IssueImmediateOrderById(GetEnumUnit(), 852022)
endif
endfunction
private function StartMining takes player play, group workers, unit goldmine, unit townhall, unit randhero returns nothing
call IssueTargetOrderById(BlzGroupUnitAt(workers, 0), 851971, goldmine)
call IssueTargetOrderById(BlzGroupUnitAt(workers, 1), 851971, goldmine)
call IssueTargetOrderById(BlzGroupUnitAt(workers, 2), 851971, goldmine)
call IssueTargetOrderById(BlzGroupUnitAt(workers, 3), 851971, goldmine)
call IssueTargetOrderById(BlzGroupUnitAt(workers, 4), 851971, goldmine)
call IssueTargetOrderById(BlzGroupUnitAt(workers, 5), 851971, goldmine)
endfunction
private function Init takes nothing returns nothing
local CustomRace c = CustomRace.create("Human",RACE_HUMAN,.9)
call c.setTownHall('h00M') // Bastion
call c.addWorkerType('h006',c.NEAR_MINE,5) // Artisan
call c.addHeroType('H008') // Arcanomancer
call c.addHeroType('H007') // Grand Magus
call c.addHeroType('O000') // Liberator
call c.addHeroType('N000') // Ranger-General
call c.setCallback(CustomRaceCall.StartMining)
call c.setAIScript("war3mapImported/high_elf2.ai")
endfunction
endlibrary
//==============================================================================
// Custom Race System by Archmage Owenalacaster (Note: with "CustomGetAllyKeyStructureCount" 1.30 fix)
//==============================================================================
//
// Purpose:
// - Creates the starting units for custom races and replaces the standard
// Melee Initialization trigger. Custom races are selected by race and
// handicap.
//
// Usage:
// - Register a new custom race with CustomRace.create(name, RACE, handicap)
// Handicaps: Valid handicap values are 1.0, 0.9, 0.8, 0.7, 0.6 and 0.5.
// - Register a new custom race for all handicaps of a single race with
// CustomRace.createAll(name, RACE)
// - Extend the registration of a race with c.register(RACE, handicap)
// - Set the townhall type with c.setTownHall(unitid)
// - Add a new worker type with c.addWorkerType(unitid, priority, qty)
// Priorities: c.NEAR_MINE spawns workers near the mine, where workers
// typically spawn.
// c.NEAR_HALL spawns workers near the town hall, where
// Ghouls spawn.
// - Add a random hero type with c.addHeroType(unitid)
// - Set the ai script used by computer players with c.setAIScript(stringpath)
// - Set a callback function with c.setCallback(CustomRaceCall.function)
// Callbacks: The callback is executed after all the starting units for a
// player are created, and its purpose is to provide enhanced
// initial behaviour for a race. A good example of this with the
// standard races would be the Undead Goldmine Haunting and
// Night Elves Goldmine Entangling.
// The callback function passes as arguments all the units
// generated in addition to the nearest goldmine detected.
// Please note that if a random hero is not created, the last
// argument will have a null value, so always do a check.
// - Get a player's custom race name string with GetPlayerCustomRaceName(player)
//
// Notes:
// - Supports a maximum of 24 custom races.
// - Maximum for worker and hero types are configurable.
//
// Requirements:
// - JassHelper version 0.9.E.0 or newer (older versions may still work).
//
// Installation:
// - Create a new trigger called CustomRaceSystem.
// - Convert it to custom text and replace all the code with this code.
//
// Special Thanks:
// - Alevice: He practically co-wrote the code.
// - cosmicat: His formula for circular unit formation.
// Co-developing the single-array registry.
//
//==============================================================================
library CustomRaceSystem initializer Init
//===========================================================================
// CONFIGURATION SECTION
//===========================================================================
globals
// Unit Type Constants
private constant integer MAX_WORKERTYPES = 4
private constant integer MAX_HEROTYPES = 4
endglobals
//===========================================================================
// END CONFIGURATION SECTION
//===========================================================================
function interface CustomRaceCall takes player play, group workers, unit goldmine, unit townhall, unit randhero returns nothing
private function r2S takes race r returns string
if r == RACE_HUMAN then
return "Human"
elseif r == RACE_ORC then
return "Orc"
elseif r == RACE_UNDEAD then
return "Undead"
elseif r == RACE_NIGHTELF then
return "Night Elf"
endif
return "Unknown"
endfunction
private function r2I takes race r returns integer
if r == RACE_HUMAN then
return 1
elseif r == RACE_ORC then
return 2
elseif r == RACE_UNDEAD then
return 3
elseif r == RACE_NIGHTELF then
return 4
endif
return 5
endfunction
globals
// Victory Defeat Variables
private string array KEY_STRUCTURE
private integer KEY_STRUCTURE_COUNT = 0
endglobals
//===========================================================================
// STRUCT DATA
//===========================================================================
private keyword createStartingUnits
struct CustomRace
string name
// Town Hall Variable
integer townhallType = 0
//string townhallName
// Town Hall name is not currently supported.
// Worker Variables
integer totalWorkerTypes = 0
integer array workerType[MAX_WORKERTYPES]
integer array workerPriority[MAX_WORKERTYPES]
integer array workerQty[MAX_WORKERTYPES]
// Random Hero Variables
integer totalHeroTypes = 0
integer array heroType[MAX_HEROTYPES]
// AI Script Directory String Variable
string aiscript = ""
// Callback Variable
private CustomRaceCall c
// Registry Variable
static integer array REGISTRY
// Spawn Priority Variables
static integer NEAR_MINE = 0
static integer NEAR_HALL = 1
static method get takes race r, real h returns CustomRace
return CustomRace(.REGISTRY[((r2I(r)-1)*6)+(10-R2I(h*10.))])
endmethod
method register takes race r, real h returns boolean
local CustomRace c = CustomRace.get(r,h)
if c != 0 then
debug call BJDebugMsg("|cffff0000Registration of "+.name+" failed due to conflict with "+c.name+" registered for "+r2S(r)+" race Handicap "+R2S(h))
return false
endif
set .REGISTRY[((r2I(r)-1)*6)+(10-R2I(h*10.))] = integer(this)
return true
endmethod
static method create takes string name, race r, real h returns CustomRace
local CustomRace c = CustomRace.allocate()
set c.name = name
if not c.register(r,h) then
call c.destroy()
return 0
endif
return c
endmethod
static method createAll takes string name, race r returns CustomRace
local CustomRace c = CustomRace.allocate()
set c.name = name
if not c.register(r,1.0) and not c.register(r,0.9) and not c.register(r,0.8) and not c.register(r,0.7) and not c.register(r,0.6) and not c.register(r,0.5) then
call c.destroy()
return 0
endif
return c
endmethod
method setTownHall takes integer hallid returns nothing
set .townhallType = hallid
set KEY_STRUCTURE[KEY_STRUCTURE_COUNT] = UnitId2String(hallid)
set KEY_STRUCTURE_COUNT = KEY_STRUCTURE_COUNT+1
endmethod
method addWorkerType takes integer workerid, integer priority, integer quantity returns nothing
set .workerType[.totalWorkerTypes] = workerid
set .workerPriority[.totalWorkerTypes] = priority
set .workerQty[.totalWorkerTypes] = quantity
set .totalWorkerTypes = .totalWorkerTypes+1
endmethod
method addHeroType takes integer heroid returns nothing
local integer i = 0
set .heroType[.totalHeroTypes] = heroid
set .totalHeroTypes = .totalHeroTypes+1
loop
call SetPlayerTechMaxAllowed(Player(i),heroid,1)
set i = i+1
exitwhen i == bj_MAX_PLAYERS
endloop
endmethod
private method getRandomHeroType takes nothing returns integer
local integer randomindex = GetRandomInt(0,.totalHeroTypes-1)
return .heroType[randomindex]
endmethod
method setAIScript takes string s returns nothing
set .aiscript = s
endmethod
method setCallback takes CustomRaceCall callb returns nothing
set .c = callb
endmethod
private method createRandomHero takes player p, location loc returns unit
local unit h = CreateUnitAtLoc(p, .getRandomHeroType(), loc, bj_UNIT_FACING)
if bj_meleeGrantHeroItems then
call MeleeGrantItemsToHero(h)
endif
return h
endmethod
method createStartingUnits takes player p returns nothing
local location startLoc = GetPlayerStartLocationLoc(p)
local location nearMineLoc = startLoc
local location nearTownLoc = startLoc
local location spawnLoc = startLoc
local location heroLoc = startLoc
local unit nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
local unit myTownhall = null
local unit myRandHero = null
local group workerGroup = CreateGroup()
local integer workertypeindex = 0
local integer workerqty = 0
local integer spawnPriority = 0
if nearestMine != null then
set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine),startLoc,320,0)
set nearTownLoc = MeleeGetProjectedLoc(startLoc,GetUnitLoc(nearestMine),288,0)
set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine),startLoc,384,45)
endif
set myTownhall = CreateUnitAtLoc(p,.townhallType,startLoc,bj_UNIT_FACING)
loop
exitwhen workertypeindex == .totalWorkerTypes
set spawnPriority = .workerPriority[workertypeindex]
if (spawnPriority==.NEAR_HALL) then
set spawnLoc = nearTownLoc
elseif(spawnPriority==.NEAR_MINE) then
set spawnLoc = nearMineLoc
endif
loop
call GroupAddUnit(workerGroup, CreateUnitAtLoc(p,.workerType[workertypeindex],PolarProjectionBJ(spawnLoc,65,(I2R(workerqty)*(360.00 / I2R(.workerQty[workertypeindex]))) + 90),bj_UNIT_FACING))
set workerqty = workerqty + 1
exitwhen workerqty >= .workerQty[workertypeindex]
endloop
call RemoveLocation(spawnLoc)
set workerqty = 0
set workertypeindex = workertypeindex+1
endloop
if (IsMapFlagSet(MAP_RANDOM_HERO) and .totalHeroTypes>0 ) then
set myRandHero = .createRandomHero(p,heroLoc)
else
call SetPlayerState(p,PLAYER_STATE_RESOURCE_HERO_TOKENS,bj_MELEE_STARTING_HERO_TOKENS)
endif
if(.c!=0) then
call .c.evaluate(p,workerGroup,nearestMine,myTownhall,myRandHero)
else
call DestroyGroup(workerGroup)
endif
if nearMineLoc != startLoc then
call RemoveLocation(nearMineLoc)
call RemoveLocation(nearTownLoc)
call RemoveLocation(heroLoc)
endif
call RemoveLocation(startLoc)
set startLoc = null
set nearMineLoc = null
set nearTownLoc = null
set spawnLoc = null
set heroLoc = null
set nearestMine = null
set myTownhall = null
set myRandHero = null
set workerGroup = null
endmethod
endstruct
globals
private string array PLAYER_RACE
endglobals
function GetPlayerCustomRaceName takes player p returns string
return PLAYER_RACE[GetPlayerId(p)]
endfunction
//===========================================================================
// UNIT CREATION SECTION
//===========================================================================
private function CreateStartingUnitsForAllPlayers takes nothing returns nothing
local integer index = 0
local player indexPlayer
local race playerRace
local CustomRace c
loop
set indexPlayer = Player(index)
if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then
set playerRace = GetPlayerRace(indexPlayer)
set c = CustomRace.get(playerRace,GetPlayerHandicap(indexPlayer)+0.01)
if (GetPlayerController(indexPlayer) == MAP_CONTROL_USER or (GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER and c.aiscript != "" )) and c != 0 then
set PLAYER_RACE[index] = c.name
call c.createStartingUnits(indexPlayer)
elseif playerRace == RACE_HUMAN then
call MeleeStartingUnitsHuman(indexPlayer,GetStartLocationLoc(GetPlayerStartLocation(indexPlayer)),true,true,true)
elseif playerRace == RACE_ORC then
call MeleeStartingUnitsOrc(indexPlayer,GetStartLocationLoc(GetPlayerStartLocation(indexPlayer)),true,true,true)
elseif playerRace == RACE_NIGHTELF then
call MeleeStartingUnitsNightElf(indexPlayer,GetStartLocationLoc(GetPlayerStartLocation(indexPlayer)),true,true,true)
elseif playerRace == RACE_UNDEAD then
call MeleeStartingUnitsUndead(indexPlayer,GetStartLocationLoc(GetPlayerStartLocation(indexPlayer)),true,true,true)
else
call MeleeStartingUnitsUnknownRace(indexPlayer,GetStartLocationLoc(GetPlayerStartLocation(indexPlayer)),true,true,true)
endif
endif
set index = index + 1
exitwhen index == bj_MAX_PLAYERS
endloop
endfunction
//===========================================================================
// CUSTOM MELEE AI SECTION
//===========================================================================
private function CustomMeleeStartingAI takes nothing returns nothing
local integer index = 0
local player indexPlayer
local race indexRace
local CustomRace c
loop
set indexPlayer = Player(index)
if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then
set indexRace = GetPlayerRace(indexPlayer)
set c = CustomRace.get(indexRace,GetPlayerHandicap(indexPlayer)+0.01)
call SetPlayerHandicap(indexPlayer,1.0)
if (GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER) then
// Run a race-specific melee AI script.
if c != 0 and c.aiscript != "" then
call StartMeleeAI(indexPlayer, c.aiscript)
elseif (indexRace == RACE_HUMAN) then
call PickMeleeAI(indexPlayer, "human.ai", null, null)
elseif (indexRace == RACE_ORC) then
call PickMeleeAI(indexPlayer, "orc.ai", null, null)
elseif (indexRace == RACE_UNDEAD) then
call PickMeleeAI(indexPlayer, "undead.ai", null, null)
call RecycleGuardPosition(bj_ghoul[index])
elseif (indexRace == RACE_NIGHTELF) then
call PickMeleeAI(indexPlayer, "elf.ai", null, null)
else
// Unrecognized race.
endif
call ShareEverythingWithTeamAI(indexPlayer)
endif
endif
set index = index + 1
exitwhen index == bj_MAX_PLAYERS
endloop
endfunction
//===========================================================================
// VICTORY DEFEAT SECTION
//===========================================================================
private function CustomGetAllyKeyStructureCount takes player whichPlayer returns integer
local integer i = 0
local integer keyStructs = 0
local integer playerIndex = 0
local player indexPlayer
loop
set indexPlayer = Player(playerIndex)
if (PlayersAreCoAllied(whichPlayer, indexPlayer)) then
set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, "townhall", true, true)
set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, "greathall", true, true)
set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, "necropolis", true, true)
set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, "treeoflife", true, true)
loop
set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, KEY_STRUCTURE[i], true, true)
set i = i+1
exitwhen i == KEY_STRUCTURE_COUNT
endloop
endif
set i = 0 //1.30 fix
set playerIndex = playerIndex + 1
exitwhen playerIndex == bj_MAX_PLAYERS
endloop
return keyStructs
endfunction
private function CustomPlayerIsCrippled takes player whichPlayer returns boolean
local integer allyStructures = MeleeGetAllyStructureCount(whichPlayer)
local integer allyKeyStructures = CustomGetAllyKeyStructureCount(whichPlayer)
return (allyStructures > 0) and (allyKeyStructures <= 0)
endfunction
private function CustomCheckForCrippledPlayers takes nothing returns nothing
local integer playerIndex
local player indexPlayer
local boolean isNowCrippled
call MeleeCheckForLosersAndVictors()
if bj_finishSoonAllExposed then
return
endif
set playerIndex = 0
loop
set indexPlayer = Player(playerIndex)
set isNowCrippled = CustomPlayerIsCrippled(indexPlayer)
if (not bj_playerIsCrippled[playerIndex] and isNowCrippled) then
set bj_playerIsCrippled[playerIndex] = true
call TimerStart(bj_crippledTimer[playerIndex], bj_MELEE_CRIPPLE_TIMEOUT, false, function MeleeCrippledPlayerTimeout)
if (GetLocalPlayer() == indexPlayer) then
call TimerDialogDisplay(bj_crippledTimerWindows[playerIndex], true)
call DisplayTimedTextToPlayer(indexPlayer, 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, GetLocalizedString("CRIPPLE_WARNING_HUMAN"))
endif
elseif (bj_playerIsCrippled[playerIndex] and not isNowCrippled) then
set bj_playerIsCrippled[playerIndex] = false
call PauseTimer(bj_crippledTimer[playerIndex])
if (GetLocalPlayer() == indexPlayer) then
call TimerDialogDisplay(bj_crippledTimerWindows[playerIndex], false)
if (MeleeGetAllyStructureCount(indexPlayer) > 0) then
if (bj_playerIsExposed[playerIndex]) then
call DisplayTimedTextToPlayer(indexPlayer, 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, GetLocalizedString("CRIPPLE_UNREVEALED"))
else
call DisplayTimedTextToPlayer(indexPlayer, 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, GetLocalizedString("CRIPPLE_UNCRIPPLED"))
endif
endif
endif
call MeleeExposePlayer(indexPlayer, false)
endif
set playerIndex = playerIndex + 1
exitwhen playerIndex == bj_MAX_PLAYERS
endloop
endfunction
private function CustomInitVictoryDefeat takes nothing returns nothing
local trigger checker = CreateTrigger()
local trigger trig
local integer index
local player indexPlayer
set bj_finishSoonTimerDialog = CreateTimerDialog(null)
call TriggerAddAction(checker, function CustomCheckForCrippledPlayers)
set trig = CreateTrigger()
call TriggerRegisterGameEvent(trig, EVENT_GAME_TOURNAMENT_FINISH_SOON)
call TriggerAddAction(trig, function MeleeTriggerTournamentFinishSoon)
set trig = CreateTrigger()
call TriggerRegisterGameEvent(trig, EVENT_GAME_TOURNAMENT_FINISH_NOW)
call TriggerAddAction(trig, function MeleeTriggerTournamentFinishNow)
set index = 0
loop
set indexPlayer = Player(index)
if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then
set bj_meleeDefeated[index] = false
set bj_meleeVictoried[index] = false
set bj_playerIsCrippled[index] = false
set bj_playerIsExposed[index] = false
set bj_crippledTimer[index] = CreateTimer()
set bj_crippledTimerWindows[index] = CreateTimerDialog(bj_crippledTimer[index])
call TimerDialogSetTitle(bj_crippledTimerWindows[index], MeleeGetCrippledTimerMessage(indexPlayer))
call TriggerRegisterPlayerUnitEvent(checker, indexPlayer, EVENT_PLAYER_UNIT_CONSTRUCT_CANCEL, null)
call TriggerRegisterPlayerUnitEvent(checker, indexPlayer, EVENT_PLAYER_UNIT_DEATH, null)
call TriggerRegisterPlayerUnitEvent(checker, indexPlayer, EVENT_PLAYER_UNIT_CONSTRUCT_START, null)
call TriggerRegisterPlayerAllianceChange(checker, indexPlayer, ALLIANCE_PASSIVE)
call TriggerRegisterPlayerStateEvent(checker, indexPlayer, PLAYER_STATE_ALLIED_VICTORY, EQUAL, 1)
set trig = CreateTrigger()
call TriggerRegisterPlayerEvent(trig, indexPlayer, EVENT_PLAYER_DEFEAT)
call TriggerAddAction(trig, function MeleeTriggerActionPlayerDefeated)
set trig = CreateTrigger()
call TriggerRegisterPlayerEvent(trig, indexPlayer, EVENT_PLAYER_LEAVE)
call TriggerAddAction(trig, function MeleeTriggerActionPlayerLeft)
else
set bj_meleeDefeated[index] = true
set bj_meleeVictoried[index] = false
if (IsPlayerObserver(indexPlayer)) then
set trig = CreateTrigger()
call TriggerRegisterPlayerEvent(trig, indexPlayer, EVENT_PLAYER_LEAVE)
call TriggerAddAction(trig, function MeleeTriggerActionPlayerLeft)
endif
endif
set index = index + 1
exitwhen index == bj_MAX_PLAYERS
endloop
call TimerStart(CreateTimer(), 2.0, false, function CustomCheckForCrippledPlayers)
endfunction
private function TimerAction takes nothing returns nothing
call SetFloatGameState(GAME_STATE_TIME_OF_DAY, bj_MELEE_STARTING_TOD)
call MeleeStartingHeroLimit()
call MeleeGrantHeroItems()
call MeleeStartingResources()
call MeleeClearExcessUnits()
call CreateStartingUnitsForAllPlayers()
call CustomMeleeStartingAI()
call CustomInitVictoryDefeat()
call DestroyTimer(GetExpiredTimer())
endfunction
private function Init takes nothing returns nothing
call TimerStart(CreateTimer(),0,false,function TimerAction)
endfunction
endlibrary