//===================================================================
function StartGameSound takes player whichPlayer returns nothing
if udg_StartGameSound == null then
set udg_StartGameSound = CreateSoundFromLabel("H02Arthas03",false,false,false,10,10)
endif
if GetLocalPlayer()==whichPlayer then
call StartSound(udg_StartGameSound)
endif
endfunction
//===================================================================
function ErrorMessage takes string error, player whichPlayer returns nothing
if udg_ErrorSound == null then
set udg_ErrorSound = CreateSoundFromLabel("InterfaceError",false,false,false,10,10)
endif
set error = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+error+"|r"
if GetLocalPlayer()==whichPlayer then
call ClearTextMessages()
call DisplayTimedTextToPlayer(whichPlayer,0.52,0.96,2,error)
call StartSound(udg_ErrorSound)
endif
endfunction
//===================================================================
function PlaySoundAtPoint takes string f, real x, real y, real p, integer v returns nothing
local sound s = CreateSound( f, false, true, true, 10, 10, "" )
call SetSoundDuration( s, GetSoundFileDuration(f) )
call SetSoundChannel( s, 0 )
call SetSoundVolume( s, v )
call SetSoundPitch( s, p )
call SetSoundPosition(s, x, y, 0)
call StartSound(s)
call KillSoundWhenDone(s)
set s = null
endfunction
//===========================================================================
// Counts key structures owned by a player and his or her allies, including
// structures currently upgrading or under construction.
//
// Key structures: Town Hall, Great Hall, Tree of Life, Necropolis
//
function LivingPlayerHallsFilter takes nothing returns boolean
return (IsUnitAliveBJ(GetFilterUnit()) and IsUnitType(GetFilterUnit(),UNIT_TYPE_TOWNHALL))
endfunction
function CountLivingPlayerTownHalls takes player whichPlayer returns integer
local group g
local integer matchedCount
local boolexpr b=Filter(function LivingPlayerHallsFilter)
set g = CreateGroup()
call GroupEnumUnitsOfPlayer(g, whichPlayer, b)
set matchedCount = CountUnitsInGroup(g)
call DestroyGroup(g)
call DestroyBoolExpr(b)
set b=null
set g=null
return matchedCount
endfunction
function Custom_MeleeGetAllyKeyStructureCount takes player whichPlayer returns integer
local integer playerIndex
local player indexPlayer
local integer keyStructs
// Count the number of buildings controlled by all not-yet-defeated co-allies.
set keyStructs = 0
set playerIndex = 0
loop
set indexPlayer = Player(playerIndex)
if (PlayersAreCoAllied(whichPlayer, indexPlayer)) then
set keyStructs = keyStructs + CountLivingPlayerTownHalls(indexPlayer)
// set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, "townhall", true, true)
// set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, "greathall", true, true)
// set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, "treeoflife", true, true)
// set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, "necropolis", true, true)
// set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, "custom_h030", true, true)
// set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, "custom_h01C", true, true)
// set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, "custom_h012", true, true)
// set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, "custom_h013", true, true)
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('h013',indexPlayer)//Never use group functions for this, just count living units for player. Much better idea.
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('h014',indexPlayer)
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('h015',indexPlayer)
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('h01C',indexPlayer)
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('h01E',indexPlayer)
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('h01F',indexPlayer)
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('h012',indexPlayer)
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('h02F',indexPlayer)
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('h02J',indexPlayer)
// set keyStructs = keySructs + CountLivingPlayerUnitsOfTypeId('h030',indexPlayer)
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('h000',indexPlayer)//Non-modded human custom ids
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('h00D',indexPlayer)
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('h00E',indexPlayer)
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('o00C',indexPlayer)//Non-modded orc custom ids
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('o00D',indexPlayer)
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('o00E',indexPlayer)
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('e00M',indexPlayer)//Non-modded night elf custom ids
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('e00N',indexPlayer)
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('e00O',indexPlayer)
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('u00C',indexPlayer)//Non-modded undead custom ids
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('u00D',indexPlayer)
// set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId('u00E',indexPlayer)
endif
set playerIndex = playerIndex + 1
exitwhen playerIndex == bj_MAX_PLAYERS
endloop
return keyStructs
endfunction
//===========================================================================
function Custom_MeleePlayerIsCrippled takes player whichPlayer returns boolean
local integer allyStructures = MeleeGetAllyStructureCount(whichPlayer)
local integer allyKeyStructures = Custom_MeleeGetAllyKeyStructureCount(whichPlayer)
// Dead teams are not considered to be crippled.
return (allyStructures > 0) and (allyKeyStructures <= 0)
endfunction
//===========================================================================
// Test each player to determine if anyone has become crippled.
//
function Custom_MeleeCheckForCrippledPlayers takes nothing returns nothing
local integer playerIndex
local player indexPlayer
local force crippledPlayers = CreateForce()
local boolean isNowCrippled
local race indexRace
// The "finish soon" exposure of all players overrides any "crippled" exposure
if bj_finishSoonAllExposed then
return
endif
// Check each player to see if he or she has been crippled or uncrippled.
set playerIndex = 0
loop
set indexPlayer = Player(playerIndex)
set isNowCrippled = Custom_MeleePlayerIsCrippled(indexPlayer)
if (not bj_playerIsCrippled[playerIndex] and isNowCrippled) then
// Player became crippled; start their cripple timer.
set bj_playerIsCrippled[playerIndex] = true
call TimerStart(bj_crippledTimer[playerIndex], bj_MELEE_CRIPPLE_TIMEOUT, false, function MeleeCrippledPlayerTimeout)
if (GetLocalPlayer() == indexPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
// Show the timer window.
call TimerDialogDisplay(bj_crippledTimerWindows[playerIndex], true)
// Display a warning message.
call DisplayTimedTextToPlayer(indexPlayer, 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, "|cffffcc00"+udg_RevealWarning+"|r")
endif
elseif (bj_playerIsCrippled[playerIndex] and not isNowCrippled) then
// Player became uncrippled; stop their cripple timer.
set bj_playerIsCrippled[playerIndex] = false
call PauseTimer(bj_crippledTimer[playerIndex])
if (GetLocalPlayer() == indexPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
// Hide the timer window for this player.
call TimerDialogDisplay(bj_crippledTimerWindows[playerIndex], false)
// Display a confirmation message if the player's team is still alive.
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
// If the player granted shared vision, deny that vision now.
call MeleeExposePlayer(indexPlayer, false)
endif
set playerIndex = playerIndex + 1
exitwhen playerIndex == bj_MAX_PLAYERS
endloop
endfunction
//===========================================================================
// Determine if the lost unit should result in any defeats or victories.
//
function Custom_MeleeCheckLostUnit takes unit lostUnit returns nothing
local player lostUnitOwner = GetOwningPlayer(lostUnit)
// We only need to check for mortality if this was the last building.
if (GetPlayerStructureCount(lostUnitOwner, true) <= 0) then
call MeleeCheckForLosersAndVictors()
endif
// Check if the lost unit has crippled or uncrippled the player.
// (A team with 0 units is dead, and thus considered uncrippled.)
call Custom_MeleeCheckForCrippledPlayers()
endfunction
//===========================================================================
// Determine if the gained unit should result in any defeats, victories,
// or cripple-status changes.
//
function Custom_MeleeCheckAddedUnit takes unit addedUnit returns nothing
local player addedUnitOwner = GetOwningPlayer(addedUnit)
// If the player was crippled, this unit may have uncrippled him/her.
if (bj_playerIsCrippled[GetPlayerId(addedUnitOwner)]) then
call Custom_MeleeCheckForCrippledPlayers()
endif
endfunction
//===========================================================================
function Custom_MeleeTriggerActionConstructCancel takes nothing returns nothing
call Custom_MeleeCheckLostUnit(GetCancelledStructure())
endfunction
//===========================================================================
function Custom_MeleeTriggerActionUnitDeath takes nothing returns nothing
if (IsUnitType(GetDyingUnit(), UNIT_TYPE_STRUCTURE)) then
call Custom_MeleeCheckLostUnit(GetDyingUnit())
endif
endfunction
//===========================================================================
function Custom_MeleeTriggerActionUnitConstructionStart takes nothing returns nothing
call Custom_MeleeCheckAddedUnit(GetConstructingStructure())
endfunction
//===========================================================================
function Custom_MeleeTriggerActionAllianceChange takes nothing returns nothing
call MeleeCheckForLosersAndVictors()
call Custom_MeleeCheckForCrippledPlayers()
endfunction
//===========================================================================
function MeleeInitVictoryDefeatCustomized takes nothing returns nothing
local trigger trig
local integer index
local player indexPlayer
// Create a timer window for the "finish soon" timeout period, it has no timer
// because it is driven by real time (outside of the game state to avoid desyncs)
set bj_finishSoonTimerDialog = CreateTimerDialog(null)
// Set a trigger to fire when we receive a "finish soon" game event
set trig = CreateTrigger()
call TriggerRegisterGameEvent(trig , EVENT_GAME_TOURNAMENT_FINISH_SOON)
call TriggerAddAction(trig , function MeleeTriggerTournamentFinishSoon)
// Set a trigger to fire when we receive a "finish now" game event
set trig = CreateTrigger()
call TriggerRegisterGameEvent(trig , EVENT_GAME_TOURNAMENT_FINISH_NOW)
call TriggerAddAction(trig , function MeleeTriggerTournamentFinishNow)
// Set up each player's mortality code.
set index = 0
loop
set indexPlayer = Player(index)
// Make sure this player slot is playing.
if ( GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING ) then
set bj_meleeDefeated[index]=false
set bj_meleeVictoried[index]=false
// Create a timer and timer window in case the player is crippled.
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))
// Set a trigger to fire whenever a building is cancelled for this player.
set trig = CreateTrigger()
call TriggerRegisterPlayerUnitEvent(trig , indexPlayer , EVENT_PLAYER_UNIT_CONSTRUCT_CANCEL , null)
call TriggerAddAction(trig , function Custom_MeleeTriggerActionConstructCancel)
// Set a trigger to fire whenever a unit dies for this player.
set trig = CreateTrigger()
call TriggerRegisterPlayerUnitEvent(trig , indexPlayer , EVENT_PLAYER_UNIT_DEATH , null)
call TriggerAddAction(trig , function Custom_MeleeTriggerActionUnitDeath)
// Set a trigger to fire whenever a unit begins construction for this player
set trig = CreateTrigger()
call TriggerRegisterPlayerUnitEvent(trig , indexPlayer , EVENT_PLAYER_UNIT_CONSTRUCT_START , null)
call TriggerAddAction(trig , function Custom_MeleeTriggerActionUnitConstructionStart)
// Set a trigger to fire whenever this player defeats-out
set trig = CreateTrigger()
call TriggerRegisterPlayerEvent(trig , indexPlayer , EVENT_PLAYER_DEFEAT)
call TriggerAddAction(trig , function MeleeTriggerActionPlayerDefeated)
// Set a trigger to fire whenever this player leaves
set trig = CreateTrigger()
call TriggerRegisterPlayerEvent(trig , indexPlayer , EVENT_PLAYER_LEAVE)
call TriggerAddAction(trig , function MeleeTriggerActionPlayerLeft)
// Set a trigger to fire whenever this player changes his/her alliances.
set trig = CreateTrigger()
call TriggerRegisterPlayerAllianceChange(trig , indexPlayer , ALLIANCE_PASSIVE)
call TriggerRegisterPlayerStateEvent(trig , indexPlayer , PLAYER_STATE_ALLIED_VICTORY , EQUAL , 1)
call TriggerAddAction(trig , function Custom_MeleeTriggerActionAllianceChange)
else
set bj_meleeDefeated[index]=true
set bj_meleeVictoried[index]=false
// Handle leave events for observers
if ( IsPlayerObserver(indexPlayer) ) then
// Set a trigger to fire whenever this player leaves
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
// Test for victory / defeat at startup, in case the user has already won / lost.
// Allow for a short time to pass first, so that the map can finish loading.
call TimerStart(CreateTimer() , 2.0 , false , function Custom_MeleeTriggerActionAllianceChange)
endfunction
Name | Type | is_array | initial_value |
A | integer | No | |
AbductTable | hashtable | No | |
AfterDamageEvent | real | No | |
AfterDamageEvent_Copy | real | No | |
AmbushersTable | hashtable | No | |
AmbusherWaitGroup | group | No | |
AMSAmount | real | Yes | |
AOEDamageEvent | real | No | |
AOEDamageEvent_Copy | real | No | |
AOEDamageSource | unit | No | |
AOEString | string | No | |
ArcaneRunes_Group | group | No | |
ArcaneUnit | unit | No | |
Archives_Type | abilcode | 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 | |
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 | |
BarrageAlreadyDMG | group | No | |
Brainwash | hashtable | No | |
BrainwashUnits | group | No | |
BreezeGroup | group | No | |
BroodCareHealTarget | unit | No | |
BroodCareLifeMeter | real | No | |
BroodGuardTable | hashtable | No | |
BroodKeeperMinions | hashtable | No | |
BS_Bonus_Ability | abilcode | Yes | |
BS_Buff | buffcode | Yes | |
BS_Buff_Ability | abilcode | Yes | |
BS_Buff_Category | integer | Yes | |
BS_Buff_Duration | real | Yes | |
BS_Buff_Type | integer | Yes | |
BS_Buffed_Event | real | No | |
BS_Buffed_Unit | unit | Yes | |
BS_Buffing_Unit | unit | Yes | |
BS_Event_Index | integer | No | |
BS_Index1 | integervar | No | |
BS_Index2 | integer | No | |
BS_Index3 | integervar | No | |
BS_IntegerA | integervar | No | |
BS_MagicImmune | boolean | Yes | |
BS_MaxStack | integer | Yes | |
BS_Permanent | boolean | Yes | |
BS_Recycle | boolean | No | |
BS_Stack | integer | Yes | |
BS_Use_Bonus | boolean | Yes | |
BuildHastable | hashtable | No | |
buildings_BuildNaga | group | No | |
BurrowedUnit | unit | No | |
Caster | unit | No | |
CasterMindBlast | unit | No | |
CatchFishTable | hashtable | No | |
ChooseRace | button | Yes | |
ChoosingRace | dialog | No | |
ClearDamageEvent | trigger | No | |
CocoonGroup | group | No | |
CocoonHashTable | hashtable | No | |
CocoonTimer | real | No | |
CONVERTED_ATTACK_TYPE | attacktype | Yes | |
CONVERTED_DAMAGE_TYPE | damagetype | Yes | |
DAMAGE_FACTOR_BRACERS | real | No | |
DAMAGE_FACTOR_ELUNES | real | No | |
DAMAGE_FACTOR_ETHEREAL | real | 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 | |
DamageAmount | real | No | |
DamageBlockingAbility | abilcode | No | |
DamageEvent | real | No | |
DamageEvent_Copy | real | No | |
DamageEventAmount | real | No | |
DamageEventAmount_Copy | real | No | |
DamageEventAOE | integer | No | |
DamageEventAOE_Copy | integer | No | |
DamageEventAOEGroup | group | No | |
DamageEventAOEGroup_Copy | group | No | |
DamageEventArmorPierced | real | No | |
DamageEventArmorT | integer | No | |
DamageEventAttackT | integer | No | |
DamageEventDamageT | integer | No | |
DamageEventDefenseT | integer | No | |
DamageEventLevel | integer | No | |
DamageEventLevel_Copy | integer | No | |
DamageEventOverride | boolean | No | |
DamageEventOverride_Copy | boolean | No | |
DamageEventPrevAmt | real | No | |
DamageEventPrevAmt_Copy | real | No | |
DamageEventSource | unit | No | |
DamageEventSource_Copy | unit | No | |
DamageEventsWasted | integer | No | |
DamageEventTarget | unit | No | |
DamageEventTarget_Copy | unit | No | |
DamageEventTrigger | trigger | No | |
DamageEventTrigger_Copy | trigger | No | |
DamageEventType | integer | No | |
DamageEventType_Copy | integer | No | |
DamageEventWeaponT | integer | No | |
DamageModifierEvent | real | No | |
DamageModifierEvent_Copy | real | No | |
DamageScalingUser | real | No | |
DamageScalingWC3 | real | No | |
DamageTypeBlocked | integer | No | |
DamageTypeBlocked_Copy | integer | No | |
DamageTypeCode | integer | No | |
DamageTypeCriticalStrike | integer | No | |
DamageTypeCriticalStrike_Copy | integer | No | |
DamageTypeDebugStr | string | Yes | |
DamageTypeExplosive | integer | No | |
DamageTypeExplosive_Copy | integer | No | |
DamageTypeHeal | integer | No | |
DamageTypeHeal_Copy | integer | No | |
DamageTypePure | integer | No | |
DamageTypePureExplosive | integer | No | |
DamageTypeReduced | integer | No | |
DamageTypeReduced_Copy | integer | No | |
DeathEvent | real | No | |
Debuff_Buffs | buffcode | Yes | |
Debuff_IntegerA | integervar | No | |
Debuff_IntegerB | integervar | No | |
Debuff_Number | integer | No | |
Debuff_Unit | unit | 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 | |
DestinyOverTimeUnits | group | No | |
DestinyRemainingTime | real | No | |
DestinyTable | hashtable | No | |
Dispell_BuffCount | integer | No | |
Dispell_Buffs_Number | integer | No | |
Dispell_Buffs_Type | integer | No | |
Dispell_Categories | integer | No | |
Dispell_Category | integer | Yes | |
Dispell_IntegerA | integervar | No | |
Dispell_IntegerB | integervar | No | |
Dispell_Target | unit | No | |
Distance | real | No | |
DiveAttackAudioInt | integer | No | |
DiveAttackCanceled | boolean | Yes | |
DiveAttackCaster | unit | Yes | |
DiveAttackChaseDur | real | No | |
DiveAttackCooldownMax | real | No | |
DiveAttackCooldownMin | real | No | |
DiveAttackCooldownTimer | real | Yes | |
DiveAttackDamage | real | Yes | |
DiveAttackDamageMax | real | No | |
DiveAttackDamageMin | real | No | |
DiveAttackDir | real | No | |
DiveAttackDist | real | No | |
DiveAttackGroup | group | No | |
DiveAttackGroupAutocast | group | No | |
DiveAttackHeal | real | Yes | |
DiveAttackHealMultiplier | real | No | |
DiveAttackHeight | real | Yes | |
DiveAttackHeightLoss | real | No | |
DiveAttackIndex | integer | No | |
DiveAttackLocCasterCurrent | location | No | |
DiveAttackLocCasterNew | location | No | |
DiveAttackLocCursor | location | No | |
DiveAttackLoop | integervar | No | |
DiveAttackMaxDur | real | Yes | |
DiveAttackMoveSpeed | real | No | |
DiveAttackSpeed | real | Yes | |
DiveAttackSpeedMultiplier | real | No | |
DiveAttackState | integer | Yes | |
DiveAttackTarget | unit | Yes | |
DiveAttackUnit | unit | Yes | |
DmgEvBracers | itemcode | No | |
DmgEvMana | real | No | |
DmgEvManaMult | real | No | |
DmgEvMSlvl | integer | No | |
DmgEvRecursionN | integer | No | |
DmgEvRunning | boolean | No | |
DmgEvStarted | boolean | No | |
DmgEvTimer | timer | No | |
DmgEvTrig | trigger | No | |
DummyDamageRetraction | hashtable | No | |
EmberGroup | group | No | |
EnemiesRiptide | group | No | |
EnhancedDamageTarget | unit | No | |
EnhancedDamageTarget_Copy | unit | No | |
ErrorMessage | string | No | |
ErrorPlayer | player | No | |
ErrorSound | sound | No | |
Exp | integer | Yes | |
ExpTable | hashtable | No | |
FadeSystemGroup | group | No | |
FadeSystemHash | hashtable | No | |
FadeUnitKey | integer | No | |
FearGroup | group | No | |
FearTable | hashtable | No | |
FL_Ability | abilcode | No | |
FL_Alpha | real | Yes | |
FL_Caster | unit | Yes | |
FL_CasterLoc | location | Yes | |
FL_CheckVisibility | boolean | No | |
FL_CollisionBoolean | boolean | No | |
FL_CutRange | real | No | |
FL_Duration | real | Yes | |
FL_Lightning | lightning | Yes | |
FL_MaxDistance | real | No | |
FL_PercentDamage | real | Yes | |
FL_SE | effect | Yes | |
FL_SlowFactor | real | No | |
FL_StringSE | string | No | |
FL_StringSE2 | string | No | |
FL_Target | unit | Yes | |
FL_TargetLoc | location | Yes | |
FL_UnitDistance | real | Yes | |
FSBlue | real | No | |
FSEnd | real | No | |
FSFadeIn | boolean | No | |
FSGreen | real | No | |
FSRed | real | No | |
FSRemove | boolean | No | |
FSSpeed | real | No | |
FSStart | real | No | |
FSStartOpacity | real | No | |
FSTinted | boolean | No | |
FSUnit | unit | No | |
Gamers | force | No | |
Gold | integer | No | |
GuardianCooldownGroup | group | No | |
Handle | integer | No | |
handle | handle | No | |
hash_BuildNaga | hashtable | No | |
HashTable_ArcaneRunes | hashtable | No | |
HashtableRiptide | hashtable | No | |
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 | integervar | 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 | |
HideDamageFrom | boolean | Yes | |
HM_Angle | real | Yes | |
HM_Angle_Add | real | Yes | |
HM_CASTER | unit | No | |
HM_CHECK | boolean | No | |
HM_Check_Homing | boolean | Yes | |
HM_Count | integer | Yes | |
HM_DAMAGE | real | No | |
HM_Damage | real | Yes | |
HM_DISTANCE | real | No | |
HM_Distance | real | Yes | |
HM_Distance2 | real | Yes | |
HM_Group | group | Yes | |
HM_LEVEL | integer | No | |
HM_Mui | integer | Yes | |
HM_Point_Dummy | location | Yes | |
HM_Points | location | Yes | |
HM_Sfx | string | Yes | |
HM_SFX | string | No | |
HM_Speed | real | Yes | |
HM_SPEED | real | No | |
HM_Speed_Add | real | Yes | |
HM_SPEED_ADD | real | No | |
HM_Unit_Caster | unit | Yes | |
HM_Unit_Dummy | unit | Yes | |
HM_Unit_Target | unit | Yes | |
HM_Unit_Type | unitcode | No | |
i | integer | No | |
ImpaleDMG | boolean | No | |
Index | integer | Yes | |
InfestedBuildingTable | hashtable | No | |
Intrappola_Bi | boolean | Yes | |
Intrappola_BOOL | boolean | Yes | |
Intrappola_Caster | unit | Yes | |
Intrappola_Count | integer | Yes | |
Intrappola_Distance | real | Yes | |
Intrappola_Effect1 | effect | Yes | |
Intrappola_Light | lightning | Yes | |
Intrappola_Target | unit | Yes | |
IsDamageCode | boolean | No | |
IsDamageMelee | boolean | No | |
IsDamageRanged | boolean | No | |
IsDamageSpell | boolean | No | |
IsDamageSpell_Copy | boolean | No | |
Jump_Caster | unit | No | |
Jump_Hashtable | hashtable | No | |
Jump_Leapers | group | 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 | |
LifeForQueenTable | hashtable | No | |
Lightning | lightning | No | |
LightningRodGroup | group | No | |
LightningRodTable | hashtable | No | |
LitCandleTable | hashtable | No | |
ManabugTable | hashtable | No | |
MathSacrifice | real | No | |
MindBlastTable | hashtable | No | |
MuddyWaters | hashtable | No | |
MuddyWatersUnits | group | No | |
MurlocOrderTable | hashtable | No | |
MurlocTideDamage | group | No | |
NagaOverseerTable | hashtable | No | |
NerubianHashtable | hashtable | No | |
NextDamageOverride | boolean | No | |
NextDamageType | integer | No | |
NextDamageType_Copy | integer | No | |
NextHealAmount | real | No | |
NextHealSource | unit | No | |
NextHealTarget | unit | No | |
Order | ordercode | No | |
Overseers | integer | Yes | 1 |
Point | location | No | |
Point_2 | location | No | |
Point_3 | location | No | |
Points | location | Yes | |
PStun_Category | integer | No | |
PStun_Event | real | No | |
PStun_LeakPoint | location | No | |
QJ_AoE | boolean | No | |
QJ_AoERadius | real | No | |
QJ_AoESFX | string | No | |
QJ_attackTypeID | integer | No | |
QJ_Caster | unit | No | |
QJ_Collision | boolean | No | |
QJ_Damage | real | No | |
QJ_damageTypeID | integer | No | |
QJ_Homing | boolean | No | |
QJ_Model | unitcode | No | |
QJ_Pierce | boolean | No | |
QJ_Position | location | No | |
QJ_Size | real | No | |
QJ_Solo | boolean | No | |
QJ_Speed | real | No | |
QJ_TargetPoint | location | No | |
QJ_TargetUnit | unit | No | |
QJS_Angle | real | No | |
QJS_arrowGroup | group | No | |
QJS_arrowPos | location | No | |
QJS_arrowTable | hashtable | No | |
QJS_atkTypePreset | attacktype | Yes | |
QJS_AttackType | attacktype | No | |
QJS_DamagedGroup | group | No | |
QJS_DamageType | damagetype | No | |
QJS_Distance | real | No | |
QJS_dmgTypePreset | damagetype | Yes | |
QJS_movePos | location | No | |
QJS_tempPos | location | No | |
QJS_tempPos_Target | location | No | |
QJS_victimGroup | group | No | |
QJS_victimPos | location | No | |
RaceChoosenTable | hashtable | No | |
Random | integer | No | |
RayCasters | group | No | |
Ready | integer | No | |
Real | real | Yes | |
RealSacrifice | real | No | |
regen_buildup | real | Yes | |
REGEN_EVENT_INTERVAL | real | No | |
REGEN_STRENGTH_VALUE | real | No | |
REGEN_THRESHOLD | real | No | |
regen_timeleft | real | Yes | |
RemainingTime_Stagger | real | No | |
RemainingTimeofDestiny | real | No | |
ReportLife | real | No | |
RessurectTable | hashtable | No | |
Restoration | unit | No | |
RetreatGroup | group | No | |
RetreatTable | hashtable | No | |
RevealWarning | string | No | You will be revealed to your opponents unless you build a town-hall type structure. |
RiptideHeal | real | No | |
RoyalGuard | hashtable | No | |
RS_Angle | real | Yes | |
RS_Boolean | boolean | Yes | |
RS_Caster | unit | Yes | |
RS_CurDis | real | Yes | |
RS_Index | integer | Yes | |
RS_LevelA | integer | Yes | |
RS_Loc | location | Yes | |
RS_MaxD | real | Yes | |
RS_MaxH | real | Yes | |
RS_Player | player | Yes | |
RS_Real | real | Yes | |
RS_Speed | real | Yes | |
RS_Target | unit | Yes | |
SeaElementalTable | hashtable | No | |
SeasickGroup | group | No | |
SeasickTable | hashtable | No | |
SecretTimer | real | No | |
SeismicActivityGroup | group | No | |
SeismicActivityTable | hashtable | No | |
Shockwaves | group | No | |
Slaves | group | No | |
SpellDamageAbility | abilcode | No | |
SpellSteal_BuffCount | integer | No | |
SpellSteal_Buffs_Number | integer | No | |
SpellSteal_Caster | unit | No | |
SpellSteal_Categories | integer | No | |
SpellSteal_Category | integer | Yes | |
SpellSteal_IntegerA | integervar | No | |
SpellSteal_IntegerB | integervar | No | |
SpellSteal_Target | unit | No | |
spider_size | real | No | |
SpiderLord_LineAttackGroup | group | No | |
SpiderLordLineDamageAmount | real | No | |
SS_CheckIntegerA | integervar | No | |
SS_CountStuns | integer | No | |
StartGameSound | sound | No | |
StormEyeGroup | group | No | |
TargetMindBlast | unit | No | |
TempBool | boolean | No | |
TempInteger | integer | No | |
TempLoc | location | No | |
tempReal1_BuildNaga | real | No | |
tempReal2_BuildNaga | real | No | |
TempUnit | unit | No | |
TempX | real | No | |
TempY | real | No | |
Tic | sound | No | |
TidalGuard | hashtable | No | |
TimerGameStart | integer | No | |
TrueSightAbility | ability | No | |
UDex | integer | No | |
UDexGen | integer | No | |
UDexNext | integer | Yes | |
UDexPrev | integer | Yes | |
UDexRecycle | integer | No | |
UDexUnits | unit | Yes | |
UDexWasted | integer | No | |
UMovNext | integer | Yes | |
UMovPrev | integer | Yes | |
UnderlordGroup | group | No | |
Unit | unit | No | |
UnitDamageRegistered | boolean | Yes | |
UnitGroup | group | No | |
UnitGroup_2 | group | No | |
UnitIndexerEnabled | boolean | No | |
UnitIndexEvent | real | No | |
UnitIndexLock | integer | Yes | |
UnitMoving | boolean | Yes | |
UnitMovingEvent | real | No | |
UnitMovingX | real | Yes | |
UnitMovingY | real | Yes | |
VialGroup | group | No | |
VialNagaTable | hashtable | 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 | |
Weather | weathereffect | No | |
WeatherUnit | unit | No | |
WEBB | lightningtype | No | |
x1 | real | Yes | |
x2 | real | Yes | |
y1 | real | Yes | |
y2 | real | Yes | |
z1 | real | Yes | |
z2 | real | Yes |
//===========================================================================
//
// Damage Engine 5.4.2.3 - update requires copying of the JASS script
//
//===========================================================================
library DamageEngine initializer Init
globals
private timer alarm = CreateTimer()
private boolean alarmSet = false
//Values to track the original pre-spirit Link/defensive damage values
private boolean canKick = true
private boolean totem = false
private real lastAmount = 0.00
private real lastPrevAmt = 0.00
private integer lastType = 0
private boolean lastCode = false
private real lastPierced = 0.00
private integer armorType = 0
private integer lastArmor = 0
private integer lastPrevArmor = 0
private integer defenseType = 0
private integer lastDefense = 0
private integer lastPrevDefense = 0
//Stuff to track recursive UnitDamageTarget calls.
private boolean eventsRun = false
private boolean kicking = false
private integer damageStack = 0
private unit array sourceStack
private unit array targetStack
private real array amountStack
private attacktype array attackTStack
private damagetype array damageTStack
private weapontype array weaponTStack
private integer array userTrigStack
private integer array typeStack
//Added in 5.4 to silently eliminate infinite recursion.
private integer userTrigs = 9
private integer eventTrig = 0
private integer array nextTrig
private trigger array userTrig
private boolean array trigFrozen
//Added/re-tooled in 5.4.1 to allow forced recursion (for advanced users only).
private constant integer LIMBO = 16 //Recursion will never go deeper than LIMBO.
private integer array levelsDeep //How deep the user recursion currently is.
public boolean inception = false //You must set DamageEngine_inception = true before dealing damage to utlize this.
//When true, it allows your trigger to potentially go recursive up to LIMBO.
private boolean dreaming = false
private boolean array inceptionTrig //Added in 5.4.2 to simplify the inception variable for very complex DamageEvent trigger.
private integer sleepLevel = 0
private group proclusGlobal = CreateGroup() //track sources of recursion
private group fischerMorrow = CreateGroup() //track targets of recursion
//Improves readability in the code to have these as named constants.
private constant integer MOD_EVENT = 1
private constant integer SHIELD_EVENT = 4
private constant integer DAMAGE_EVENT = 5
private constant integer ZERO_EVENT = 6
private constant integer AFTER_EVENT = 7
private constant integer LETHAL_EVENT = 8
private constant integer AOE_EVENT = 9
//private string crashStr = ""
endglobals
//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
*/
private function RunTrigs takes integer i returns nothing
local integer cat = i
if dreaming then
//call BJDebugMsg("Tried to run triggers while triggers were already running.")
return
endif
set dreaming = true
//call BJDebugMsg("Start of event running")
loop
set i = nextTrig[i]
exitwhen i == 0
exitwhen cat == MOD_EVENT and (udg_DamageEventOverride or udg_DamageEventType*udg_DamageEventType == 4)
exitwhen cat == SHIELD_EVENT and udg_DamageEventAmount <= 0.00
exitwhen cat == LETHAL_EVENT and udg_LethalDamageHP > 0.405
//set crashStr = "Bout to inspect " + I2S(i)
if not trigFrozen[i] and IsTriggerEnabled(userTrig[i]) then
set eventTrig = i
//set crashStr = "Bout to evaluate " + I2S(i)
if TriggerEvaluate(userTrig[i]) then
//set crashStr = "Bout to execute " + I2S(i)
call TriggerExecute(userTrig[i])
endif
//set crashStr = "Ran " + I2S(i)
//call BJDebugMsg("Ran " + I2S(i))
//if not (udg_DamageEventPrevAmt == 0.00 or udg_DamageScalingWC3 == 0.00 or udg_DamageEventAmount == 0.00) then
// if cat == MOD_EVENT then
// set udg_DamageScalingUser = udg_DamageEventAmount/udg_DamageEventPrevAmt
// elseif cat == SHIELD_EVENT then
// set udg_DamageScalingUser = udg_DamageEventAmount/udg_DamageEventPrevAmt/udg_DamageScalingWC3
// endif
//elseif udg_DamageEventPrevAmt == 0.00 then
// call BJDebugMsg("Prev amount 0.00 and User Amount " + R2S(udg_DamageEventAmount))
//elseif udg_DamageEventAmount == 0.00 then
// call BJDebugMsg("User amount 0.00 and Prev Amount " + R2S(udg_DamageEventPrevAmt))
//elseif udg_DamageScalingWC3 == 0.00 then
// call BJDebugMsg("WC3 amount somehow 0.00")
//endif
//set crashStr = "Filtered " + I2S(i)
//elseif i > 9 then
// if trigFrozen[i] then
// call BJDebugMsg("User Trigger is frozen")
// else
// call BJDebugMsg("User Trigger is off")
// endif
endif
endloop
//call BJDebugMsg("End of event running")
set dreaming = false
endfunction
private function OnAOEEnd takes nothing returns nothing
if udg_DamageEventAOE > 1 then
call RunTrigs(AOE_EVENT)
set udg_DamageEventAOE = 1
endif
set udg_DamageEventLevel = 1
set udg_EnhancedDamageTarget = null
set udg_AOEDamageSource = null
call GroupClear(udg_DamageEventAOEGroup)
endfunction
private function AfterDamage takes nothing returns nothing
if udg_DamageEventPrevAmt != 0.00 and udg_DamageEventDamageT != udg_DAMAGE_TYPE_UNKNOWN then
call RunTrigs(AFTER_EVENT)
endif
endfunction
private function Finish takes nothing returns nothing
local integer i = 0
local integer exit
if eventsRun then
//call BJDebugMsg("events ran")
set eventsRun = false
call AfterDamage()
endif
if canKick and not kicking then
//call BJDebugMsg("can kick")
if damageStack > 0 then
set kicking = true
//call BJDebugMsg("Clearing queued damage instances: " + I2S(damageStack))
loop
set exit = damageStack
set sleepLevel = sleepLevel + 1
loop
set udg_NextDamageType = typeStack[i]
//call BJDebugMsg("Stacking on " + R2S(amountStack[i]))
call UnitDamageTarget(sourceStack[i], targetStack[i], amountStack[i], true, false, attackTStack[i], damageTStack[i], weaponTStack[i])
call AfterDamage()
set i = i + 1 //Need to loop bottom to top to make sure damage order is preserved.
exitwhen i == exit
endloop
//call BJDebugMsg("Exit at: " + I2S(i))
exitwhen i == damageStack
endloop
//call BJDebugMsg("Terminate at at: " + I2S(i))
set sleepLevel = 0
loop
set i = i - 1
set trigFrozen[userTrigStack[i]] = false //Only re-enable recursive triggers AFTER all damage is dealt.
set levelsDeep[userTrigStack[i]] = 0 //Reset this stuff if the user tried some nonsense
exitwhen i == 0
endloop
//call BJDebugMsg("Cleared queued damage instances: " + I2S(damageStack))
set damageStack = 0 //Can only be set after all the damage has successfully ended.
set kicking = false
endif
call GroupClear(proclusGlobal)
call GroupClear(fischerMorrow)
//elseif kicking then
// call BJDebugMsg("Somehow still kicking")
//else
// call BJDebugMsg("Cannot kick")
endif
endfunction
private function ResetArmor takes nothing returns nothing
if udg_DamageEventArmorPierced != 0.00 then
call BlzSetUnitArmor(udg_DamageEventTarget, BlzGetUnitArmor(udg_DamageEventTarget) + udg_DamageEventArmorPierced)
endif
if armorType != udg_DamageEventArmorT then
call BlzSetUnitIntegerField(udg_DamageEventTarget, UNIT_IF_ARMOR_TYPE, armorType) //revert changes made to the damage instance
endif
if defenseType != udg_DamageEventDefenseT then
call BlzSetUnitIntegerField(udg_DamageEventTarget, UNIT_IF_DEFENSE_TYPE, defenseType)
endif
endfunction
private function FailsafeClear takes nothing returns nothing
//call BJDebugMsg("Damage from " + GetUnitName(udg_DamageEventSource) + " to " + GetUnitName(udg_DamageEventTarget) + " has been messing up Damage Engine.")
//call BJDebugMsg(R2S(udg_DamageEventAmount) + " " + " " + R2S(udg_DamageEventPrevAmt) + " " + udg_AttackTypeDebugStr[udg_DamageEventAttackT] + " " + udg_DamageTypeDebugStr[udg_DamageEventDamageT])
call ResetArmor()
set canKick = true
set totem = false
set udg_DamageEventAmount = 0.00
set udg_DamageScalingWC3 = 0.00
if udg_DamageEventDamageT != udg_DAMAGE_TYPE_UNKNOWN then
call RunTrigs(DAMAGE_EVENT) //Run the normal on-damage event based on this failure.
set eventsRun = true //Run the normal after-damage event based on this failure.
endif
call Finish()
endfunction
private function WakeUp takes nothing returns nothing
set alarmSet = false //The timer has expired. Flag off to allow it to be restarted when needed.
//if dreaming then
// set dreaming= false
// call BJDebugMsg("Timer set dreaming to False")
// call BJDebugMsg(crashStr)
//endif
if totem then
//Something went wrong somewhere; the WarCraft 3 engine didn't run the DAMAGED event despite running the DAMAGING event.
call FailsafeClear()
else
if not canKick and damageStack > 0 then
//call BJDebugMsg("Damage Engine recursion deployment was failing with application of: " + R2S(udg_DamageEventAmount))
set canKick = true
endif
call Finish() //Wrap up any outstanding damage instance
endif
call OnAOEEnd() //Reset things so they don't perpetuate for AoE/Level target detection
set udg_DamageEventPrevAmt = 0.00 //Added in 5.4.2.1 to try to squash the Cold Arrows glitch (failed to do it)
endfunction
private function CalibrateMR takes nothing returns nothing
set udg_IsDamageMelee = false
set udg_IsDamageRanged = false
set udg_IsDamageSpell = udg_DamageEventAttackT == 0 //In Patch 1.31, one can just check the attack type to find out if it's a spell.
if udg_DamageEventDamageT == udg_DAMAGE_TYPE_NORMAL and not udg_IsDamageSpell then //This damage type is the only one that can get reduced by armor.
set udg_IsDamageMelee = IsUnitType(udg_DamageEventSource, UNIT_TYPE_MELEE_ATTACKER)
set udg_IsDamageRanged = IsUnitType(udg_DamageEventSource, UNIT_TYPE_RANGED_ATTACKER)
if udg_IsDamageMelee and udg_IsDamageRanged then
set udg_IsDamageMelee = udg_DamageEventWeaponT > 0// Melee units play a sound when damaging
set udg_IsDamageRanged = not udg_IsDamageMelee // In the case where a unit is both ranged and melee, the ranged attack plays no sound.
endif // The Huntress has a melee sound for her ranged projectile, however it is only an issue
endif //if she also had a melee attack, because by default she is only UNIT_TYPE_RANGED_ATTACKER.
endfunction
private function OnPreDamage takes nothing returns boolean
local unit src = GetEventDamageSource()
local unit tgt = GetTriggerUnit()
local real amt = GetEventDamage()
local attacktype at = BlzGetEventAttackType()
local damagetype dt = BlzGetEventDamageType()
local weapontype wt = BlzGetEventWeaponType()
//call BJDebugMsg("First damage event running")
if dreaming then
//call BJDebugMsg("Dreaming")
if amt != 0.00 then
//Store recursive damage into a queue from index "damageStack" (0-15)
//This damage will be fired after the current damage instance has wrapped up its events.
//This damage can only be caused by triggers.
set amountStack[damageStack] = amt
set sourceStack[damageStack] = src
set targetStack[damageStack] = tgt
set attackTStack[damageStack] = at
set damageTStack[damageStack] = dt
set weaponTStack[damageStack] = wt
set userTrigStack[damageStack] = eventTrig
if udg_NextDamageType == 0 then
set typeStack[damageStack] = udg_DamageTypeCode
else
set typeStack[damageStack] = udg_NextDamageType
endif
//Next block added in 5.4.1 to allow *some* control over whether recursion should kick
//in. Also it's important to track whether the source and target were both involved at
//some earlier point, so this is a more accurate and lenient method than before.
set inception = inception or inceptionTrig[eventTrig]
call GroupAddUnit(proclusGlobal, udg_DamageEventSource)
call GroupAddUnit(fischerMorrow, udg_DamageEventTarget)
if kicking and IsUnitInGroup(src, proclusGlobal) and IsUnitInGroup(tgt, fischerMorrow) then
if inception and not trigFrozen[eventTrig] then
set inceptionTrig[eventTrig] = true
if levelsDeep[eventTrig] < sleepLevel then
set levelsDeep[eventTrig] = levelsDeep[eventTrig] + 1
if levelsDeep[eventTrig] >= LIMBO then
set trigFrozen[eventTrig] = true
endif
endif
else
set trigFrozen[eventTrig] = true
endif
endif
set damageStack = damageStack + 1
//call BJDebugMsg("damageStack: " + I2S(damageStack) + " levelsDeep: " + I2S(levelsDeep[eventTrig]) + " sleepLevel: " + I2S(sleepLevel))
call BlzSetEventDamage(0.00) //queue the damage instance instead of letting it run recursively
endif
else
if not kicking then
//Added 25 July 2017 to detect AOE damage or multiple single-target damage
if alarmSet then
if totem then
if dt != DAMAGE_TYPE_SPIRIT_LINK and dt != DAMAGE_TYPE_DEFENSIVE and dt != DAMAGE_TYPE_PLANT then
//if 'totem' is still set and it's not due to spirit link distribution or defense retaliation,
//the next function must be called as a debug. This reverts an issue I created in patch 5.1.3.
call FailsafeClear()
else
set totem = false
set lastAmount = udg_DamageEventAmount
set lastPrevAmt = udg_DamageEventPrevAmt //Store the actual pre-armor value.
set lastType = udg_DamageEventType //also store the damage type.
set lastCode = udg_IsDamageCode //store this as well.
set lastArmor = udg_DamageEventArmorT
set lastPrevArmor = armorType
set lastDefense = udg_DamageEventDefenseT
set lastPrevDefense = defenseType
set lastPierced = udg_DamageEventArmorPierced
set canKick = false
endif
else
call Finish()
endif
if src != udg_AOEDamageSource then //Source has damaged more than once
call OnAOEEnd() //New damage source - unflag everything
set udg_AOEDamageSource = src
elseif tgt == udg_EnhancedDamageTarget then
set udg_DamageEventLevel= udg_DamageEventLevel + 1 //The number of times the same unit was hit.
elseif not IsUnitInGroup(tgt, udg_DamageEventAOEGroup) then
set udg_DamageEventAOE = udg_DamageEventAOE + 1 //Multiple targets hit by this source - flag as AOE
endif
else
call TimerStart(alarm, 0.00, false, function WakeUp)
set alarmSet = true
set udg_AOEDamageSource = src
set udg_EnhancedDamageTarget= tgt
endif
call GroupAddUnit(udg_DamageEventAOEGroup, tgt)
endif
set udg_DamageEventType = udg_NextDamageType
set udg_IsDamageCode = udg_NextDamageType != 0
set udg_DamageEventOverride = dt == null //Got rid of NextDamageOverride in 5.1 for simplicity
set udg_DamageEventPrevAmt = amt
set udg_DamageEventSource = src
set udg_DamageEventTarget = tgt
set udg_DamageEventAmount = amt
set udg_DamageEventAttackT = GetHandleId(at)
set udg_DamageEventDamageT = GetHandleId(dt)
set udg_DamageEventWeaponT = GetHandleId(wt)
call CalibrateMR() //Set Melee and Ranged settings.
set udg_DamageEventArmorT = BlzGetUnitIntegerField(udg_DamageEventTarget, UNIT_IF_ARMOR_TYPE) //Introduced in Damage Engine 5.2.0.0
set udg_DamageEventDefenseT = BlzGetUnitIntegerField(udg_DamageEventTarget, UNIT_IF_DEFENSE_TYPE)
set armorType = udg_DamageEventArmorT
set defenseType = udg_DamageEventDefenseT
set udg_DamageEventArmorPierced = 0.00
set udg_DamageScalingUser = 1.00
set udg_DamageScalingWC3 = 1.00
if amt != 0.00 then
if not udg_DamageEventOverride then
call RunTrigs(MOD_EVENT)
//All events have run and the pre-damage amount is finalized.
call BlzSetEventAttackType(ConvertAttackType(udg_DamageEventAttackT))
call BlzSetEventDamageType(ConvertDamageType(udg_DamageEventDamageT))
call BlzSetEventWeaponType(ConvertWeaponType(udg_DamageEventWeaponT))
if udg_DamageEventArmorPierced != 0.00 then
call BlzSetUnitArmor(udg_DamageEventTarget, BlzGetUnitArmor(udg_DamageEventTarget) - udg_DamageEventArmorPierced)
endif
if armorType != udg_DamageEventArmorT then
call BlzSetUnitIntegerField(udg_DamageEventTarget, UNIT_IF_ARMOR_TYPE, udg_DamageEventArmorT) //Introduced in Damage Engine 5.2.0.0
endif
if defenseType != udg_DamageEventDefenseT then
call BlzSetUnitIntegerField(udg_DamageEventTarget, UNIT_IF_DEFENSE_TYPE, udg_DamageEventDefenseT) //Introduced in Damage Engine 5.2.0.0
endif
call BlzSetEventDamage(udg_DamageEventAmount)
endif
//call BJDebugMsg("Ready to deal " + R2S(udg_DamageEventAmount))
set totem = true
else
call RunTrigs(ZERO_EVENT)
set canKick = true
call Finish()
endif
endif
set src = null
set tgt = null
set inception = false
set udg_NextDamageType = 0
return false
endfunction
//The traditional on-damage response, where armor reduction has already been factored in.
private function OnDamage takes nothing returns boolean
local real r = GetEventDamage()
//call BJDebugMsg("Second damage event running")
if dreaming or udg_DamageEventPrevAmt == 0.00 then
//if dreaming then
// call BJDebugMsg("Dreaming")
//else
// call BJDebugMsg("Prev amount is zero")
//endif
return false
endif
if totem then
set totem = false //This should be the case in almost all circumstances
else
call AfterDamage() //Wrap up the outstanding damage instance
set canKick = true
//Unfortunately, Spirit Link and Thorns Aura/Spiked Carapace fire the DAMAGED event out of sequence with the DAMAGING event,
//so I have to re-generate a buncha stuff here.
set udg_DamageEventSource = GetEventDamageSource()
set udg_DamageEventTarget = GetTriggerUnit()
set udg_DamageEventAmount = lastAmount
set udg_DamageEventPrevAmt = lastPrevAmt
set udg_DamageEventAttackT = GetHandleId(BlzGetEventAttackType())
set udg_DamageEventDamageT = GetHandleId(BlzGetEventDamageType())
set udg_DamageEventWeaponT = GetHandleId(BlzGetEventWeaponType())
set udg_DamageEventType = lastType
set udg_IsDamageCode = lastCode
set udg_DamageEventArmorT = lastArmor
set udg_DamageEventDefenseT = lastDefense
set udg_DamageEventArmorPierced = lastPierced
set armorType = lastPrevArmor
set defenseType = lastPrevDefense
call CalibrateMR() //Apply melee/ranged settings once again.
endif
call ResetArmor()
if udg_DamageEventAmount != 0.00 and 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
set udg_DamageScalingUser = udg_DamageEventAmount / udg_DamageEventPrevAmt
endif
set udg_DamageEventAmount = udg_DamageEventAmount*udg_DamageScalingWC3
if udg_DamageEventAmount > 0.00 then
//This event is used for custom shields which have a limited hit point value
//The shield here kicks in after armor, so it acts like extra hit points.
call RunTrigs(SHIELD_EVENT)
set udg_LethalDamageHP = GetWidgetLife(udg_DamageEventTarget) - udg_DamageEventAmount
if udg_LethalDamageHP <= 0.405 then
call RunTrigs(LETHAL_EVENT) //Added 10 May 2019 to detect and potentially prevent lethal damage. Instead of
//modifying the damage, you need to modify LethalDamageHP instead (the final HP of the unit).
set udg_DamageEventAmount = GetWidgetLife(udg_DamageEventTarget) - udg_LethalDamageHP
if udg_DamageEventType < 0 and udg_LethalDamageHP <= 0.405 then
call SetUnitExploded(udg_DamageEventTarget, true) //Explosive damage types should blow up the target.
endif
endif
set udg_DamageScalingUser = udg_DamageEventAmount/udg_DamageEventPrevAmt/udg_DamageScalingWC3
endif
call BlzSetEventDamage(udg_DamageEventAmount) //Apply the final damage amount.
if udg_DamageEventDamageT != udg_DAMAGE_TYPE_UNKNOWN then
call RunTrigs(DAMAGE_EVENT)
endif
set eventsRun = true
if udg_DamageEventAmount == 0.00 then
call Finish()
endif
return false
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger trig = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_DAMAGED) //Thanks to this I no longer have to create an event for every unit in the map.
call TriggerAddCondition(trig, Filter(function OnDamage))
set trig = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_DAMAGING) //The new 1.31 event which fires before damage.
call TriggerAddCondition(trig, Filter(function OnPreDamage))
set trig = null
endfunction
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"
endfunction
//This function exists mainly to make it easier to switch from another DDS, like PDD.
function UnitDamageTargetEx takes unit src, unit tgt, real amt, boolean a, boolean r, attacktype at, damagetype dt, weapontype wt returns boolean
if udg_NextDamageType == 0 then
set udg_NextDamageType = udg_DamageTypeCode
endif
call UnitDamageTarget(src, tgt, amt, a, r, at, dt, wt)
return dreaming
endfunction
public function SetupEvent takes trigger whichTrig, string var, integer index returns nothing
local integer max = 1
local integer off = 0
local integer exit = 0
local integer i
if var == "udg_DamageModifierEvent" then //MOD_EVENT 1-4 -> Events 1-4
if index < 3 then
set exit = index + 1
endif
if nextTrig[1] == 0 then
set nextTrig[1] = 2
set nextTrig[2] = 3
set trigFrozen[2] = true
set trigFrozen[3] = true
endif
set max = 4
elseif var == "udg_DamageEvent" then //DAMAGE_EVENT 1,2 -> Events 5,6
set max = 2
set off = 4
elseif var == "udg_AfterDamageEvent" then //AFTER_EVENT -> Event 7
set off = 6
elseif var == "udg_LethalDamageEvent" then //LETHAL_EVENT -> Event 8
set off = 7
elseif var == "udg_AOEDamageEvent" then //AOE_EVENT -> Event 9
set off = 8
else
return
endif
set i = IMaxBJ(IMinBJ(index, max), 1) + off
//call BJDebugMsg("Root index: " + I2S(i))
loop
set index = i
set i = nextTrig[i]
exitwhen i == exit
endloop
set userTrigs = userTrigs + 1 //User list runs from index 10 and up
set nextTrig[index] = userTrigs
set nextTrig[userTrigs] = exit
set userTrig[userTrigs] = whichTrig
//call BJDebugMsg("Registered " + I2S(userTrigs) + " to " + I2S(index))
endfunction
private function PreSetup takes trigger whichTrig, string var, limitop op, real value returns nothing
call SetupEvent(whichTrig, var, R2I(value))
endfunction
hook TriggerRegisterVariableEvent PreSetup
endlibrary
library FrameLoader initializer init_function
// in 1.31 and upto 1.32.9 PTR (when I wrote this). Frames are not correctly saved and loaded, breaking the game.
// This library runs all functions added to it with a 0s delay after the game was loaded.
// function FrameLoaderAdd takes code func returns nothing
// func runs when the game is loaded.
globals
private trigger eventTrigger = CreateTrigger()
private trigger actionTrigger = CreateTrigger()
private timer t = CreateTimer()
endglobals
function FrameLoaderAdd takes code func returns nothing
call TriggerAddAction(actionTrigger, func)
endfunction
private function timerAction takes nothing returns nothing
call TriggerExecute(actionTrigger)
endfunction
private function eventAction takes nothing returns nothing
call TimerStart(t, 0, false, function timerAction)
endfunction
private function init_function takes nothing returns nothing
call TriggerRegisterGameEvent(eventTrigger, EVENT_GAME_LOADED)
call TriggerAddAction(eventTrigger, function eventAction)
endfunction
endlibrary
library CustomConsoleUI initializer init_function requires optional FrameLoader
// CustomConsoleUI by Tasyen
// CustomConsoleUI allows to change the UI during the game, when setuped correctly. This excludes the mouse cursor and the UI sounds.
// In non reforged it can also not change the Idle worker Button nor the no inventory cover.
// How to setup this: First you have to make the default Console Textures be hidden that is done in Game Interface.
// Set ConsoleTexture01 to ConsoleTexture06 to UI\Widgets\EscMenu\Human\blank-background.blp
// The Day of Time clock has hardcoded textures therefore you need to swap it out. That also should be done in Gameinterface.
// TimeOfDayIndicator to the model included in this system.
// Now export and Import war3mapImported\CustomConsoleUI.toc & war3mapImported\CustomConsoleUI.fdf
// Finally you have to set the used textures into local data
globals
private framehandle idleWorkerButton
private framehandle idleWorkerButtonOverlay
private framehandle idleWorkerButtonOverlayParent
private framehandle customInventoryCover
private framehandle customInventoryCoverParent
public string array data
public integer array dataCount
private integer dataPageSize = 11
public real array x
public real array y
private constant boolean workerFace = false
endglobals
function AddCustomConsole takes integer index, string texture returns nothing
set dataCount[index] = dataCount[index] + 1
set data[index*dataPageSize + dataCount[index]] = texture
endfunction
function UseCustomConsole takes player p, integer index returns nothing
local integer pageValue
if GetLocalPlayer() != p then
return
endif
if index < 1 then
set index = GetHandleId(GetPlayerRace(p))
endif
set pageValue = index*dataPageSize
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI5T", 0), data[pageValue + 5], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI6T", 0), data[pageValue + 6], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI4T", 0), data[pageValue + 4], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI3T", 0), data[pageValue + 3], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI2TL", 0), data[pageValue + 2], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI2TR", 0), data[pageValue + 2], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI1T", 0), data[pageValue + 1], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI1B", 0), data[pageValue + 1], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI2B", 0), data[pageValue + 2], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI3B", 0), data[pageValue + 3], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI4B", 0), data[pageValue + 4], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI5B", 0), data[pageValue + 5], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI6B", 0), data[pageValue + 6], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUIClock", 0), data[pageValue + 7] ,0, true)
if GetLocalizedString("REFORGED") != "REFORGED" then
call BlzFrameSetTexture(BlzGetFrameByName("InventoryCoverTexture", 0), data[pageValue + 8] ,0, true)
static if workerFace then
call BlzFrameSetTexture(idleWorkerButtonOverlay, data[pageValue + 9], 0, false)
endif
else
call BlzFrameSetTexture(customInventoryCover, data[pageValue + 8] ,0, true)
endif
call BlzFrameSetPoint(BlzGetFrameByName("CustomConsoleUIClock", 0), FRAMEPOINT_TOP, BlzGetFrameByName("ConsoleUI", 0), FRAMEPOINT_TOP, x[index], y[index])
endfunction
function CreateCustomConsole takes nothing returns nothing
call BlzLoadTOCFile( "war3mapimported\\CustomConsoleUI.toc" )
call BlzCreateSimpleFrame( "CustomConsoleUI", BlzGetFrameByName("ConsoleUI", 0), 0)
call BlzFrameSetLevel(BlzGetFrameByName("CustomConsoleUI", 0), 0)
if GetLocalizedString("REFORGED") != "REFORGED" then
// Requires a native existing only in Reforged
static if workerFace then
set idleWorkerButton = BlzFrameGetChild(BlzGetFrameByName("ConsoleUI", 0), 7)
set idleWorkerButtonOverlayParent = BlzCreateSimpleFrame( "SimpleTextureFrame", idleWorkerButton, 0 )
set idleWorkerButtonOverlay = BlzGetFrameByName("SimpleTextureFrameValue", 0)
call BlzFrameSetAllPoints(idleWorkerButtonOverlay, idleWorkerButton)
call BlzFrameSetLevel(idleWorkerButtonOverlayParent, 4)
endif
else
set customInventoryCoverParent = BlzCreateSimpleFrame( "SimpleTextureFrame", BlzGetFrameByName("ConsoleUI", 0), 0)
call BlzFrameSetLevel(customInventoryCoverParent, 4)
set customInventoryCover = BlzGetFrameByName("SimpleTextureFrameValue", 0)
call BlzFrameSetAbsPoint(customInventoryCover, FRAMEPOINT_BOTTOMRIGHT, 0.6, 0)
call BlzFrameSetAbsPoint(customInventoryCover, FRAMEPOINT_TOPLEFT, 0.6 - 0.128, 0.2558)
endif
// Preload
call BlzGetOriginFrame(ORIGIN_FRAME_ITEM_BUTTON, 0)
call BlzGetFrameByName("InventoryCoverTexture", 0)
call BlzGetFrameByName("CustomConsoleUIClock", 0)
call BlzGetFrameByName("CustomConsoleUI5T", 0)
call BlzGetFrameByName("CustomConsoleUI6T", 0)
call BlzGetFrameByName("CustomConsoleUI4T", 0)
call BlzGetFrameByName("CustomConsoleUI3T", 0)
call BlzGetFrameByName("CustomConsoleUI2TL", 0)
call BlzGetFrameByName("CustomConsoleUI2TR", 0)
call BlzGetFrameByName("CustomConsoleUI1T", 0)
call BlzGetFrameByName("CustomConsoleUI1B", 0)
call BlzGetFrameByName("CustomConsoleUI2B", 0)
call BlzGetFrameByName("CustomConsoleUI3B", 0)
call BlzGetFrameByName("CustomConsoleUI4B", 0)
call BlzGetFrameByName("CustomConsoleUI5B", 0)
call BlzGetFrameByName("CustomConsoleUI6B", 0)
endfunction
private function Init takes nothing returns nothing
call CreateCustomConsole()
call UseCustomConsole(GetLocalPlayer(), 0)
endfunction
private function at0s takes nothing returns nothing
call Init()
call DestroyTimer(GetExpiredTimer())
endfunction
private function update takes nothing returns nothing
call BlzFrameSetVisible(customInventoryCoverParent, not BlzFrameIsVisible(BlzGetOriginFrame(ORIGIN_FRAME_ITEM_BUTTON, 0)))
endfunction
private function init_function takes nothing returns nothing
local integer index = 0
set index = 10
call AddCustomConsole(index, "ui\\console\\human\\humanuitile01")
call AddCustomConsole(index, "ui\\console\\human\\humanuitile02")
call AddCustomConsole(index, "ui\\console\\human\\humanuitile03")
call AddCustomConsole(index, "ui\\console\\human\\humanuitile04")
call AddCustomConsole(index, "war3mapImported\\humanuitile05")
call AddCustomConsole(index, "war3mapImported\\humanuitile06")
call AddCustomConsole(index, "ui\\console\\human\\humanuitile-timeindicatorframe")
call AddCustomConsole(index, "ui\\console\\human\\humanuitile-inventorycover")
call AddCustomConsole(index, "ReplaceableTextures\\CommandButtons\\BTNPeasant")
// offset this mostly is used to fit to the glowing orbs showing the houers
set x[index] = 0.0009
set y[index] = 0.0
set index = 20
call AddCustomConsole(index, "ui\\console\\orc\\orcuitile01")
call AddCustomConsole(index, "ui\\console\\orc\\orcuitile02")
call AddCustomConsole(index, "ui\\console\\orc\\orcuitile03")
call AddCustomConsole(index, "ui\\console\\orc\\orcuitile04")
call AddCustomConsole(index, "war3mapImported\\orcuitile05")
call AddCustomConsole(index, "war3mapImported\\orcuitile06")
call AddCustomConsole(index, "ui\\console\\orc\\orcuitile-timeindicatorframe")
call AddCustomConsole(index, "ui\\console\\orc\\orcuitile-inventorycover")
call AddCustomConsole(index, "ReplaceableTextures\\CommandButtons\\BTNPeon")
set x[index] = 0.0004
set y[index] = 0.0
set index = 30
call AddCustomConsole(index, "ui\\console\\undead\\undeaduitile01")
call AddCustomConsole(index, "ui\\console\\undead\\undeaduitile02")
call AddCustomConsole(index, "ui\\console\\undead\\undeaduitile03")
call AddCustomConsole(index, "ui\\console\\undead\\undeaduitile04")
call AddCustomConsole(index, "war3mapImported\\undeaduitile05")
call AddCustomConsole(index, "war3mapImported\\undeaduitile06")
call AddCustomConsole(index, "ui\\console\\undead\\undeaduitile-timeindicatorframe")
call AddCustomConsole(index, "ui\\console\\undead\\undeaduitile-inventorycover")
call AddCustomConsole(index, "ReplaceableTextures\\CommandButtons\\BTNAcolyte")
set x[index] = 0.0009
set y[index] = 0.0
set index = 40
call AddCustomConsole(index, "ui\\console\\nightelf\\nightelfuitile01")
call AddCustomConsole(index, "ui\\console\\nightelf\\nightelfuitile02")
call AddCustomConsole(index, "ui\\console\\nightelf\\nightelfuitile03")
call AddCustomConsole(index, "ui\\console\\nightelf\\nightelfuitile04")
call AddCustomConsole(index, "war3mapImported\\nightelfuitile05")
call AddCustomConsole(index, "war3mapImported\\nightelfuitile06")
call AddCustomConsole(index, "ui\\console\\nightelf\\nightelfuitile-timeindicatorframe")
call AddCustomConsole(index, "ui\\console\\nightelf\\nightelfuitile-inventorycover")
call AddCustomConsole(index, "ReplaceableTextures\\CommandButtons\\BTNWisp")
set x[index] = 0.0009
set y[index] = 0.0
set index = 50
call AddCustomConsole(index, "war3mapImported\\naga01")
call AddCustomConsole(index, "war3mapImported\\naga02")
call AddCustomConsole(index, "war3mapImported\\naga03")
call AddCustomConsole(index, "war3mapImported\\naga04")
call AddCustomConsole(index, "war3mapImported\\nagauitile05")
call AddCustomConsole(index, "war3mapImported\\nagauitile06")
call AddCustomConsole(index, "war3mapImported\\nagauitile-timeindicatorframe")
call AddCustomConsole(index, "war3mapImported\\nagauitile-inventorycover")
call AddCustomConsole(index, "ReplaceableTextures\\CommandButtons\\BTNMurgalSlave")
set x[index] = 0.002
set y[index] = 0.0
set index = 60
call AddCustomConsole(index, "war3mapImported\\nerub-tile 1")
call AddCustomConsole(index, "war3mapImported\\nerub-tile 2")
call AddCustomConsole(index, "war3mapImported\\nerub-tile 3")
call AddCustomConsole(index, "war3mapImported\\nerub-tile 4")
call AddCustomConsole(index, "war3mapImported\\nerub-tile 5")
call AddCustomConsole(index, "war3mapImported\\nerub-tile 6")
call AddCustomConsole(index, "war3mapImported\\nerub-timeindicatorframe")
call AddCustomConsole(index, "war3mapImported\\nerub-inventory cover")
call AddCustomConsole(index, "BTNGatherer")
set x[index] = 0.000
set y[index] = 0.0
if GetLocalizedString("REFORGED") == "REFORGED" then
call TimerStart(CreateTimer(), 1/32.0, true, function update)
endif
call TimerStart(CreateTimer(), 0, false, function at0s)
static if LIBRARY_FrameLoader then
call FrameLoaderAdd(function Init)
endif
endfunction
endlibrary
//===========================================================================
// Starting Units for Undead Players
// - 1 Necropolis, placed at start location
// - 1 Haunted Gold Mine, placed on nearest gold mine
// - 3 Acolytes, placed between start location and nearest gold mine
// - 1 Ghoul, placed between start location and nearest gold mine
// - Blight, centered on nearest gold mine, spread across a "large area"
//
function XMeleeStartingUnitsUndead takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
local boolean useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
local real unitSpacing = 64.00
local unit nearestMine
local location nearMineLoc
local location nearTownLoc
local location heroLoc
local real peonX
local real peonY
local real ghoulX
local real ghoulY
if (doPreload) then
call Preloader( "scripts\\UndeadMelee.pld" )
endif
set nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine != null) then
// Spawn Necropolis at the start location.
call CreateUnitAtLoc(whichPlayer, 'unpl', startLoc, bj_UNIT_FACING)
// Replace the nearest gold mine with a blighted version.
set nearestMine = BlightGoldMineForPlayerBJ(nearestMine, whichPlayer)
// Spawn Ghoul near the Necropolis.
set nearTownLoc = MeleeGetProjectedLoc(startLoc, GetUnitLoc(nearestMine), 288, 0)
set ghoulX = GetLocationX(nearTownLoc)
set ghoulY = GetLocationY(nearTownLoc)
set bj_ghoul[GetPlayerId(whichPlayer)] = CreateUnit(whichPlayer, 'ugho', ghoulX + 0.00 * unitSpacing, ghoulY + 0.00 * unitSpacing, bj_UNIT_FACING)
// Spawn Acolytes near the mine.
set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0)
set peonX = GetLocationX(nearMineLoc)
set peonY = GetLocationY(nearMineLoc)
call CreateUnit(whichPlayer, 'uaco', peonX + 0.00 * unitSpacing, peonY + 0.50 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'uaco', peonX + 0.65 * unitSpacing, peonY - 0.50 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'uaco', peonX - 0.65 * unitSpacing, peonY - 0.50 * unitSpacing, bj_UNIT_FACING)
// Create a patch of blight around the gold mine.
//call SetBlightLoc(whichPlayer,nearMineLoc, 768, true)
// Set random hero spawn point to be off to the side of the start location.
set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45)
else
// Spawn Necropolis at the start location.
call CreateUnitAtLoc(whichPlayer, 'unpl', startLoc, bj_UNIT_FACING)
// Spawn Acolytes and Ghoul directly south of the Necropolis.
set peonX = GetLocationX(startLoc)
set peonY = GetLocationY(startLoc) - 224.00
call CreateUnit(whichPlayer, 'uaco', peonX - 1.50 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'uaco', peonX - 0.50 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'uaco', peonX + 0.50 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'ugho', peonX + 1.50 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
// Create a patch of blight around the start location.
//call SetBlightLoc(whichPlayer,startLoc, 768, true)
// Set random hero spawn point to be just south of the start location.
set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
endif
if (doHeroes) then
// If the "Random Hero" option is set, start the player with a random hero.
// Otherwise, give them a "free hero" token.
if useRandomHero then
call MeleeRandomHeroLoc(whichPlayer, 'Udea', 'Udre', 'Ulic', 'Ucrl', heroLoc)
else
call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
endif
endif
if (doCamera) then
// Center the camera on the initial Acolytes.
call SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
endif
endfunction
//===========================================================================
function XMeleeStartingUnits takes nothing returns nothing
local integer index
local player indexPlayer
local location indexStartLoc
local race indexRace
call Preloader( "scripts\\SharedMelee.pld" )
set index = 0
loop
set indexPlayer = Player(index)
if GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER then
set indexStartLoc = GetStartLocationLoc(GetPlayerStartLocation(indexPlayer))
set indexRace = GetPlayerRace(indexPlayer)
// Create initial race-specific starting units
if (indexRace == RACE_HUMAN) then
call MeleeStartingUnitsHuman(indexPlayer, indexStartLoc, true, true, true)
elseif (indexRace == RACE_ORC) then
call MeleeStartingUnitsOrc(indexPlayer, indexStartLoc, true, true, true)
elseif (indexRace == RACE_UNDEAD) then
call MeleeStartingUnitsUndead(indexPlayer, indexStartLoc, true, true, true)
elseif (indexRace == RACE_NIGHTELF) then
call MeleeStartingUnitsNightElf(indexPlayer, indexStartLoc, true, true, true)
else
call MeleeStartingUnitsHuman(indexPlayer, indexStartLoc, true, true, true)
endif
call RemoveLocation(indexStartLoc)
set indexStartLoc = null
endif
set index = index + 1
exitwhen index == bj_MAX_PLAYERS
endloop
set indexPlayer = null
set indexRace = null
endfunction
function Trig_XMelee_Initialization_Actions takes nothing returns nothing
call MeleeStartingVisibility( )
call MeleeStartingHeroLimit( )
call MeleeGrantHeroItems( )
call MeleeStartingResources( )
call MeleeClearExcessUnits( )
//call MeleeStartingUnits( )
call XMeleeStartingUnits( )
call MeleeStartingAI( )
endfunction
//===========================================================================
function InitTrig_XMelee_Initialization takes nothing returns nothing
set gg_trg_XMelee_Initialization = CreateTrigger( )
call TriggerAddAction( gg_trg_XMelee_Initialization, function Trig_XMelee_Initialization_Actions )
endfunction