//TESH.scrollpos=39
//TESH.alwaysfold=0
function CreateExplosionSizedTimed takes player Owner, real x, real y, real scaleSize, real scaleSpeed returns unit
local unit Explosion = CreateUnit( Owner, 'h001', x, y, 90 )
call SetUnitScale(Explosion, scaleSize, scaleSize, scaleSize)
call SetUnitTimeScale( Explosion, scaleSpeed )
call KillUnit( Explosion )
return Explosion
endfunction
function FlashPointSizedTimed takes real x, real y, real power, real size, real duration returns nothing
local real distx = x-GetCameraTargetPositionX()
local real disty = y-GetCameraTargetPositionY()
local real dist = SquareRoot(distx*distx + disty*disty)
local real powerVisible = power
if dist > size*2 then
set power=0
elseif dist > size then
set power = power*(2*size-dist)/size
endif
call AbortCinematicFadeBJ()
call SetCineFilterTexture("ReplaceableTextures\\CameraMasks\\White_mask.blp")
call SetCineFilterBlendMode(BLEND_MODE_BLEND)
call SetCineFilterTexMapFlags(TEXMAP_FLAG_NONE)
call SetCineFilterStartUV(0, 0, 1, 1)
call SetCineFilterEndUV(0, 0, 1, 1)
call SetCineFilterStartColor(255, 255, 255, IMaxBJ(R2I(power*2.55),0))
call SetCineFilterEndColor(255, 255, 255, 0)
call SetCineFilterDuration(duration)
call DisplayCineFilter(true)
call FinishCinematicFadeAfterBJ(duration)
endfunction
function IsUnitBuilder takes unit U returns boolean
if GetUnitTypeId(U) == 'h009' then
return true
endif
if GetUnitTypeId(U) == 'h00I' then
return true
endif
if GetUnitTypeId(U) == 'h00H' then
return true
endif
if GetUnitTypeId(U) == 'H016' then
return true
endif
if GetUnitTypeId(U) == 'H017' then
return true
endif
if GetUnitTypeId(U) == 'H018' then
return true
endif
return false
endfunction
function UnitGo takes unit U returns nothing
local real x
local real y = 0
if IsUnitAlly(U, Player(0)) then
if GetUnitX(U) >= -992 then
set x = -1280
set y = I2R(GetUnitUserData(U))
else
set x = -3072.00
endif
else
if GetUnitX(U) <= 992 then
set x = 1280
set y = I2R(GetUnitUserData(U))
else
set x = 3072.00
endif
endif
call IssuePointOrder( U, "attack", x, y )
endfunction
Name | Type | is_array | initial_value |
ai_worker | unit | Yes | |
CountPlayers | integer | Yes | |
notcam | boolean | Yes | |
RND | integer | No | |
Spawn_Diff | integer | No | |
timer | timer | No |
//TESH.scrollpos=76
//TESH.alwaysfold=0
function Trig_Use_Buildings_IsVehicleToHack takes nothing returns boolean
if not IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetEnumUnit())) then
return false
endif
if GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) <= 0 then
return false
endif
if IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) then
return false
endif
if GetUnitTypeId(GetFilterUnit()) == 'h00W' then
return false
endif
if not IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) then
return false
endif
return true
endfunction
function Trig_Use_Buildings_IsOrganicAlliedUnitToHeal takes nothing returns boolean
if not IsUnitAlly(GetFilterUnit(), GetOwningPlayer(GetEnumUnit())) then
return false
endif
if GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) <= 0 then
return false
endif
if GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) >= GetUnitState(GetFilterUnit(), UNIT_STATE_MAX_LIFE) then
return false
endif
if IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) then
return false
endif
return true
endfunction
function Trig_Use_Buildings_IsOrganicAlliedUnitToBuff takes nothing returns boolean
if not IsUnitAlly(GetFilterUnit(), GetOwningPlayer(GetEnumUnit())) then
return false
endif
if GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) <= 0 then
return false
endif
if IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) then
return false
endif
if GetUnitAbilityLevel(GetFilterUnit(), 'B001') > 0 then
return false
endif
return true
endfunction
function Trig_Use_Buildings_IsOrganicAlliedUnitToClone takes nothing returns boolean
if not IsUnitAlly(GetFilterUnit(), GetOwningPlayer(GetEnumUnit())) then
return false
endif
if GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) <= 0 then
return false
endif
if IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) then
return false
endif
if IsUnitBuilder(GetFilterUnit()) then
return false
endif
return true
endfunction
function Trig_Use_Buildings_CheckUnitGo takes unit PickUnit returns nothing
if not IsUnitBuilder(PickUnit) and GetUnitTypeId(PickUnit) != 'h00W' then
if OrderId2StringBJ(GetUnitCurrentOrder(PickUnit)) == "stop" then
call UnitGo( PickUnit )
elseif OrderId2StringBJ(GetUnitCurrentOrder(PickUnit)) == "" then
call UnitGo( PickUnit )
endif
endif
endfunction
function Trig_Use_Buildings_Loop takes nothing returns nothing
local unit PickUnit = GetEnumUnit()
local group G
if IsUnitType(PickUnit, UNIT_TYPE_STRUCTURE) then
if GetUnitAbilityLevelSwapped('A00H', PickUnit) == 1 then
set G = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function Trig_Use_Buildings_IsOrganicAlliedUnitToHeal))
if FirstOfGroup(G) != null then
call IssueTargetOrder( PickUnit, "healingwave", GroupPickRandomUnit(G) )
endif
call DestroyGroup( G )
set G = null
elseif GetUnitAbilityLevelSwapped('A008', PickUnit) == 1 then
set G = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function Trig_Use_Buildings_IsVehicleToHack))
if FirstOfGroup(G) != null then
call IssueTargetOrder( PickUnit, "shadowstrike", GroupPickRandomUnit(G) )
endif
call DestroyGroup( G )
set G = null
elseif GetUnitAbilityLevelSwapped('A00P', PickUnit) == 1 then
set G = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function Trig_Use_Buildings_IsOrganicAlliedUnitToBuff))
if FirstOfGroup(G) != null then
call IssueTargetOrder( PickUnit, "bloodlust", GroupPickRandomUnit(G) )
endif
call DestroyGroup( G )
set G = null
elseif GetUnitAbilityLevelSwapped('A00R', PickUnit) == 1 then
set G = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function Trig_Use_Buildings_IsOrganicAlliedUnitToClone))
if FirstOfGroup(G) != null then
call IssueTargetOrder( PickUnit, "shadowstrike", GroupPickRandomUnit(G) )
endif
call DestroyGroup( G )
set G = null
else
call IssueImmediateOrder( PickUnit, "waterelemental" )
endif
else
call Trig_Use_Buildings_CheckUnitGo( PickUnit )
endif
set PickUnit = null
endfunction
function Trig_Use_Buildings_Actions takes nothing returns nothing
local group AllUnits = GetUnitsInRectAll(GetPlayableMapRect())
call ForGroupBJ( AllUnits, function Trig_Use_Buildings_Loop )
call DestroyGroup( AllUnits )
set AllUnits = null
endfunction
//===========================================================================
function InitTrig_Use_Buildings takes nothing returns nothing
set gg_trg_Use_Buildings = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Use_Buildings, 2.50 )
call TriggerAddAction( gg_trg_Use_Buildings, function Trig_Use_Buildings_Actions )
endfunction
//TESH.scrollpos=6
//TESH.alwaysfold=0
function Trig_Income_Actions takes nothing returns nothing
local integer i = 0
local integer j = 1
local integer Team = 1
local integer array TeamIncome
set TeamIncome[1] = 4
set TeamIncome[2] = 4
if udg_Spawn_Diff > 0 then
set TeamIncome[1] = TeamIncome[1] + udg_Spawn_Diff/udg_CountPlayers[1]
elseif udg_Spawn_Diff < 0 then
set TeamIncome[2] = TeamIncome[2] - udg_Spawn_Diff/udg_CountPlayers[2]
endif
set udg_Spawn_Diff = 0
loop
set i = 0
set Team = 1
loop
exitwhen i > 9
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call AdjustPlayerStateBJ( TeamIncome[Team]/(5-j), Player(i), PLAYER_STATE_RESOURCE_GOLD )
endif
set Team = 3-1
set i = i + 1
endloop
exitwhen j >= 4
set TeamIncome[1] = TeamIncome[1]-TeamIncome[1]/(5-j)
set TeamIncome[2] = TeamIncome[2]-TeamIncome[2]/(5-j)
call PolledWait(2.5)
set j = j + 1
endloop
endfunction
//===========================================================================
function InitTrig_Income takes nothing returns nothing
set gg_trg_Income = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Income, 10 )
call TriggerAddAction( gg_trg_Income, function Trig_Income_Actions )
call TriggerExecute( gg_trg_Income )
endfunction
function Trig_Move_Summoned_Actions takes nothing returns nothing
if GetPlayerTeam(GetOwningPlayer(GetSummoningUnit())) == 0 then
set udg_Spawn_Diff = udg_Spawn_Diff + 1
else
set udg_Spawn_Diff = udg_Spawn_Diff - 1
endif
call SetUnitUserData( GetSummonedUnit(), GetUnitUserData(GetSummoningUnit()) )
call UnitGo( GetSummonedUnit() )
endfunction
//===========================================================================
function InitTrig_Move_Summoned takes nothing returns nothing
set gg_trg_Move_Summoned = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Move_Summoned, EVENT_PLAYER_UNIT_SUMMON )
call TriggerAddAction( gg_trg_Move_Summoned, function Trig_Move_Summoned_Actions )
endfunction
function Trig_Player_Leaves_Actions takes nothing returns nothing
local integer i = 0
local integer j = GetPlayerTeam( GetTriggerPlayer() )
local integer PlayersLeft = 0
local force F = CreateForce()
local group G
local unit U
loop
if GetPlayerTeam(Player(i)) == j then
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
if GetPlayerController(Player(i)) == MAP_CONTROL_USER then
if GetPlayerController(Player(i)) != GetTriggerPlayer() then
call ForceAddPlayer(F, Player(i))
set PlayersLeft = PlayersLeft + 1
endif
endif
endif
endif
exitwhen i == 9
set i = i + 1
endloop
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, GetPlayerName(GetTriggerPlayer()) + " has left the game.")
set udg_CountPlayers[j + 1] = udg_CountPlayers[j + 1] - 1
if PlayersLeft != 0 then
set G = CreateGroup()
call GroupEnumUnitsOfPlayer(G, GetTriggerPlayer(), null)
loop
set U = FirstOfGroup( G )
exitwhen U == null
call GroupRemoveUnit( G, U )
call SetUnitOwner( U, ForcePickRandomPlayer(F), true )
endloop
call DestroyGroup( G )
set G = null
set i = 0
set j = GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD) / PlayersLeft
loop
if IsPlayerInForce(Player(i), F) then
call SetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD) + j)
endif
exitwhen i == 9
set i = i + 1
endloop
endif
call DestroyForce( F )
set F = null
endfunction
//===========================================================================
function InitTrig_Player_Leaves takes nothing returns nothing
set gg_trg_Player_Leaves = CreateTrigger( )
call TriggerAddAction( gg_trg_Player_Leaves, function Trig_Player_Leaves_Actions )
endfunction
function Trig_Build_Actions takes nothing returns nothing
call SetUnitUserData( GetConstructedStructure(), R2I(GetUnitY(GetConstructedStructure())) )
endfunction
//===========================================================================
function InitTrig_Build takes nothing returns nothing
set gg_trg_Build = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Build, EVENT_PLAYER_UNIT_CONSTRUCT_FINISH )
call TriggerAddAction( gg_trg_Build, function Trig_Build_Actions )
endfunction
//TESH.scrollpos=46
//TESH.alwaysfold=0
function Trig_Winwalk_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00W'
endfunction
function Trig_Windwalk_IsTarget takes nothing returns boolean
if not IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) then
return false
endif
if IsUnitBuilder(GetFilterUnit()) then
return false
endif
if IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING) then
return false
endif
if GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) <= 0 then
return false
endif
return true
endfunction
function Trig_Winwalk_GetBestTarget takes nothing returns unit
local group G = CreateGroup()
local unit Caster = GetTriggerUnit()
local real r
local real X = GetUnitX(Caster)
local real Y = GetUnitY(Caster)
local unit PickUnit
local real DistQuad
local unit BestUnit
local real BestDistQuad = -1
local boolexpr IsTarget = Condition(function Trig_Windwalk_IsTarget)
call GroupEnumUnitsInRange(G, X, Y, 1500, IsTarget)
set PickUnit=FirstOfGroup(G)
loop
exitwhen PickUnit==null
set r = X - GetUnitX(PickUnit)
set DistQuad = r*r
set r = Y - GetUnitY(PickUnit)
set DistQuad = DistQuad + r*r
if DistQuad < BestDistQuad or BestDistQuad == -1 then
set BestDistQuad = DistQuad
set BestUnit = PickUnit
endif
call GroupRemoveUnit(G,PickUnit)
set PickUnit=FirstOfGroup(G)
endloop
call DestroyBoolExpr(IsTarget)
call DestroyGroup( G )
set IsTarget = null
set G = null
return BestUnit
endfunction
function Trig_Winwalk_Actions takes nothing returns nothing
local unit Caster = GetTriggerUnit()
local unit Target = Trig_Winwalk_GetBestTarget()
if Target != null then
call IssueTargetOrder(Caster,"attack", Target )
call TriggerSleepAction( 0.7 )
if not IsUnitEnemy(Target, GetOwningPlayer(Caster)) or GetUnitState(Target, UNIT_STATE_LIFE) <= 0 then
set Target = Trig_Winwalk_GetBestTarget()
endif
if Target != null then
call IssueTargetOrder(Caster,"attack", Target )
set Target = null
else
call UnitGo( Caster )
endif
else
call UnitGo( Caster )
endif
set Caster = null
endfunction
//===========================================================================
function InitTrig_Winwalk takes nothing returns nothing
set gg_trg_Winwalk = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Winwalk, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Winwalk, Condition( function Trig_Winwalk_Conditions ) )
call TriggerAddAction( gg_trg_Winwalk, function Trig_Winwalk_Actions )
endfunction
function Trig_Nuclear_Explosion_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == 'h00W' or GetUnitTypeId(GetTriggerUnit()) == 'h00A'
endfunction
function Trig_Nuclear_Explosion_DamageTarget takes nothing returns boolean
if GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) <= 0 then
return false
endif
if IsUnitBuilder(GetFilterUnit()) then
return false
endif
return true
endfunction
function Trig_Nuclear_Explosion_Actions takes nothing returns nothing
local unit Missile = GetTriggerUnit()
local player Owner = GetOwningPlayer(Missile)
local real x = GetUnitX(Missile)
local real y = GetUnitY(Missile)
local integer i = 1
local unit U
local unit array Explosion
local group G = CreateGroup()
local boolexpr DamageTarget = Condition(function Trig_Nuclear_Explosion_DamageTarget)
if GetUnitTypeId(Missile) == 'h00W' then
call RemoveUnit(Missile)
endif
call FlashPointSizedTimed(x,y,100,1000,7)
loop
set Explosion[i] = CreateExplosionSizedTimed(Owner,x,y,3.8,0.08)
exitwhen i == 8
set i = i + 1
endloop
set i = 1
loop
call GroupEnumUnitsInRange(G, x, y, 800-IAbsBJ(i-10)*60, DamageTarget)
loop
set U = FirstOfGroup(G)
exitwhen U == null
if i <= 10 then
call UnitDamageTarget(Explosion[1], U, 250, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
else
call UnitDamageTarget(Explosion[1], U, 50, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
endif
call GroupRemoveUnit(G, U)
endloop
exitwhen i == 20
call PolledWait(0.2)
set i = i + 1
endloop
set i = 1
call DestroyBoolExpr(DamageTarget)
set DamageTarget = null
call DestroyGroup( G )
set G = null
call TriggerSleepAction(3)
loop
call RemoveUnit(Explosion[i])
set Explosion[i] = null
exitwhen i == 8
set i = i + 1
endloop
endfunction
//===========================================================================
function InitTrig_Nuclear_Explosion takes nothing returns nothing
set gg_trg_Nuclear_Explosion = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Nuclear_Explosion, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_Nuclear_Explosion, Condition( function Trig_Nuclear_Explosion_Conditions ) )
call TriggerAddAction( gg_trg_Nuclear_Explosion, function Trig_Nuclear_Explosion_Actions )
endfunction