function echo takes string s returns nothing
call DisplayTimedTextToPlayer(GetLocalPlayer(),0.,0.,10.,s)
endfunction
Name | Type | is_array | initial_value |
CameraDistance | real | No | |
CampAgressiveRadius | integer | No | 100 |
CampBaseUnit | unitcode | Yes | |
CampBossType | unitcode | Yes | |
CampBuildingType | unitcode | Yes | |
CampCount | integer | No | |
CampGroup | group | No | |
CampGuardRadius | real | No | |
CampLevel1Unit | unitcode | Yes | |
CampLevel2Unit | unitcode | Yes | |
CampSpawnCurrentLimit | integer | Yes | |
CampTier | integer | Yes | |
CampTierSpawnLimit | integer | Yes | |
CampTierSpawnTime | real | Yes | |
DefaultCampBaseUnit | unitcode | No | |
DefaultCampBossType | unitcode | No | |
DefaultCampBuildingType | unitcode | No | |
DefaultCampLevel1Unit | unitcode | No | |
DefaultCampLevel2Unit | unitcode | No | |
G | group | No | |
GG | group | No | |
H | hashtable | No | |
NeutralPlayer | player | No | |
RallyAbility | abilcode | No | |
RallyUnit | unitcode | No | |
random_hero | integer | No | |
Tier1BossDropItem | itemcode | Yes | |
Tier1BossDropItemCount | integer | No | |
Tier1CampBaseUnit | unitcode | Yes | |
Tier1CampBossType | unitcode | Yes | |
Tier1CampBuildingType | unitcode | Yes | |
Tier1CampCount | integer | No | |
Tier1CampLevel1Unit | unitcode | Yes | |
Tier1CampLevel2Unit | unitcode | Yes | |
Tier1DefaultCampBaseUnit | unitcode | No | |
Tier1DefaultCampBossType | unitcode | No | |
Tier1DefaultCampBuildingType | unitcode | No | |
Tier1DefaultCampLevel1Unit | unitcode | No | |
Tier1DefaultCampLevel2Unit | unitcode | No | |
Tier2BossDropItem | itemcode | Yes | |
Tier2BossDropItemCount | integer | No | |
Tier2CampBaseUnit | unitcode | Yes | |
Tier2CampBossType | unitcode | Yes | |
Tier2CampBuildingType | unitcode | Yes | |
Tier2CampCount | integer | No | |
Tier2CampLevel1Unit | unitcode | Yes | |
Tier2CampLevel2Unit | unitcode | Yes | |
Tier2DefaultCampBaseUnit | unitcode | No | |
Tier2DefaultCampBossType | unitcode | No | |
Tier2DefaultCampBuildingType | unitcode | No | |
Tier2DefaultCampLevel1Unit | unitcode | No | |
Tier2DefaultCampLevel2Unit | unitcode | No | |
Tier3BossDropItem | itemcode | Yes | |
Tier3BossDropItemCount | integer | No | |
Tier3CampBaseUnit | unitcode | Yes | |
Tier3CampBossType | unitcode | Yes | |
Tier3CampBuildingType | unitcode | Yes | |
Tier3CampCount | integer | No | |
Tier3CampLevel1Unit | unitcode | Yes | |
Tier3CampLevel2Unit | unitcode | Yes | |
Tier3DefaultCampBaseUnit | unitcode | No | |
Tier3DefaultCampBossType | unitcode | No | |
Tier3DefaultCampBuildingType | unitcode | No | |
Tier3DefaultCampLevel1Unit | unitcode | No | |
Tier3DefaultCampLevel2Unit | unitcode | No | |
Timer | timer | No | |
TrainGroup | group | No | |
TrainUnits | group | No |
function TimerExpire takes nothing returns nothing
local integer i = 0
local unit u
local unit d
local integer id
local integer ct
local integer cn
local integer tt
local integer l
local real ti
local real x
local real y
set i = 0
loop
exitwhen i > bj_MAX_PLAYERS
if (GetLocalPlayer() == Player(i)) then
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, udg_CameraDistance, 0.)
endif
set i = i + 1
endloop
set i = 0
set bj_groupAddGroupDest = udg_GG
call ForGroup(udg_TrainGroup, function GroupAddGroupEnum)
set bj_groupCountUnits = 0
call ForGroup(udg_GG, function CountUnitsInGroupEnum)
if bj_groupCountUnits > 0 then
loop
set u = FirstOfGroup(udg_GG)
set id = GetHandleId(u)
if id > 0 then
//call echo("spawn time "+GetUnitName(u) +" level = "+ I2S(GetUnitAbilityLevel(u,'AHbh')))
set cn = LoadInteger(udg_H, id, StringHash("CampNumber"))
set ct = LoadInteger(udg_H, id, StringHash("CampType"))
set tt = LoadInteger(udg_H, id, StringHash("CampTier"))
set l = udg_CampSpawnCurrentLimit[cn]
if l < udg_CampTierSpawnLimit[tt] then
set ti = LoadReal(udg_H, id, StringHash("CampSpawnTime")) + 0.1
//call echo("spawn time CampNumber= " + I2S(cn) + "player = " + GetPlayerName(GetOwningPlayer(u)) + " tier = " + I2S(tt) + " ti = " + R2S(ti) + " limit = " + I2S(l))
//call echo("spawn time CampNumber= " + I2S(cn) + "player = " + GetPlayerName(l)+ " tier = " + I2S(tt) + " ti = " + R2S(ti) + " limit = " + I2S(l) + " ti1 = " + R2S(udg_CampTierSpawnTime[tt]) + " limit1 = " + I2S(udg_CampTierSpawnLimit[tt]))
if ti >= udg_CampTierSpawnTime[tt] then
set x = GetUnitX(u)
set y = GetUnitY(u)
if tt == 1 then
set d = CreateUnit(GetOwningPlayer(u), udg_Tier1CampBaseUnit[ct], x, y, 0)
elseif tt == 2 then
set d = CreateUnit(GetOwningPlayer(u), udg_Tier2CampBaseUnit[ct], x, y, 0)
elseif tt == 3 then
set d = CreateUnit(GetOwningPlayer(u), udg_Tier3CampBaseUnit[ct], x, y, 0)
endif
set udg_CampSpawnCurrentLimit[cn] = l + 1
call SaveInteger(udg_H, GetHandleId(d), StringHash("CampNumber"), cn)
call GroupAddUnit(udg_TrainUnits, d)
set x = LoadReal(udg_H, id, StringHash("CampRallyTargetX"))
set y = LoadReal(udg_H, id, StringHash("CampRallyTargetY"))
//call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl", x,y))
call IssuePointOrder(d, "attack" , x, y)
set ti = 0.
endif
call SaveReal(udg_H, id, StringHash("CampSpawnTime"), ti)
endif
endif
call GroupRemoveUnit(udg_GG, u)
exitwhen u == null
endloop
endif
endfunction
function ReplaceUnits takes real x, real y, player l, integer i, integer t returns nothing
local unit n
local unit d
local real f
local real p
local real a
local real b
call GroupEnumUnitsInRange(udg_GG, x, y, udg_CampGuardRadius, null)
loop
set d = FirstOfGroup(udg_GG)
if GetOwningPlayer(d) == udg_NeutralPlayer then
set a = GetUnitX(d)
set b = GetUnitY(d)
set f = GetUnitFacing(d)
call ShowUnit(d, false)
call RemoveUnit(d)
if t == 1 then
if GetUnitTypeId(d) == udg_Tier1DefaultCampBaseUnit then
set n = CreateUnit(l, udg_Tier1CampBaseUnit[i], a, b, f)
call SetUnitAcquireRange(n, 100.0)
elseif GetUnitTypeId(d) == udg_Tier1DefaultCampLevel1Unit then
set n = CreateUnit(l, udg_Tier1CampLevel1Unit[i], a, b, f)
call SetUnitAcquireRange(n, 100.0)
elseif GetUnitTypeId(d) == udg_Tier1DefaultCampLevel2Unit then
set n = CreateUnit(l, udg_Tier1CampLevel2Unit[i], a, b, f)
call SetUnitAcquireRange(n, 100.0)
elseif GetUnitTypeId(d) == udg_Tier1DefaultCampBossType then
set n = CreateUnit(l, udg_Tier1CampBossType[i], a, b, f)
call SetUnitAcquireRange(n, 100.0)
endif
elseif t == 2 then
if GetUnitTypeId(d) == udg_Tier2DefaultCampBaseUnit then
set n = CreateUnit(l, udg_Tier2CampBaseUnit[i], a, b, f)
call SetUnitAcquireRange(n, 100.0)
elseif GetUnitTypeId(d) == udg_Tier2DefaultCampLevel1Unit then
set n = CreateUnit(l, udg_Tier2CampLevel1Unit[i], a, b, f)
call SetUnitAcquireRange(n, 100.0)
elseif GetUnitTypeId(d) == udg_Tier2DefaultCampLevel2Unit then
set n = CreateUnit(l, udg_Tier2CampLevel2Unit[i], a, b, f)
call SetUnitAcquireRange(n, 100.0)
elseif GetUnitTypeId(d) == udg_Tier2DefaultCampBossType then
set n = CreateUnit(l, udg_Tier2CampBossType[i], a, b, f)
call SetUnitAcquireRange(n, 100.0)
endif
elseif t == 3 then
if GetUnitTypeId(d) == udg_Tier3DefaultCampBaseUnit then
set n = CreateUnit(l, udg_Tier3CampBaseUnit[i], a, b, f)
call SetUnitAcquireRange(n, 100.0)
elseif GetUnitTypeId(d) == udg_Tier3DefaultCampLevel1Unit then
set n = CreateUnit(l, udg_Tier3CampLevel1Unit[i], a, b, f)
call SetUnitAcquireRange(n, 100.0)
elseif GetUnitTypeId(d) == udg_Tier3DefaultCampLevel2Unit then
set n = CreateUnit(l, udg_Tier3CampLevel2Unit[i], a, b, f)
call SetUnitAcquireRange(n, 100.0)
elseif GetUnitTypeId(d) == udg_Tier3DefaultCampBossType then
set n = CreateUnit(l, udg_Tier3CampBossType[i], a, b, f)
call SetUnitAcquireRange(n, 100.0)
endif
endif
endif
call GroupRemoveUnit(udg_GG, d)
exitwhen d == null
endloop
set d = null
set n = null
endfunction
function Init takes nothing returns nothing
local unit u
local real x
local real y
local integer i
local integer id
local real p
local unit k
local player l
local integer n = 1
local integer t
set udg_H = InitHashtable()
call GroupEnumUnitsInRange(udg_G, 0., 0., 999999., null)
loop
set u = FirstOfGroup(udg_G)
if GetUnitTypeId(u) == udg_Tier1DefaultCampBuildingType or GetUnitTypeId(u) == udg_Tier2DefaultCampBuildingType or GetUnitTypeId(u) == udg_Tier3DefaultCampBuildingType then
set t = 0
if GetUnitTypeId(u) == udg_Tier1DefaultCampBuildingType then
set t = 1
set i = GetRandomInt(1, udg_Tier1CampCount)
elseif GetUnitTypeId(u) == udg_Tier2DefaultCampBuildingType then
set t = 2
set i = GetRandomInt(1, udg_Tier2CampCount)
elseif GetUnitTypeId(u) == udg_Tier3DefaultCampBuildingType then
set t = 3
set i = GetRandomInt(1, udg_Tier3CampCount)
endif
//call echo("tier = "+I2S(t)+" "+GetUnitName(u))
if t > 0 then
set l = GetOwningPlayer(u)
if i > 1 then
set x = GetUnitX(u)
set y = GetUnitY(u)
set p = GetUnitFacing(u)
call ReplaceUnits(x, y, l, i, t)
call ShowUnit(u, false)
call RemoveUnit(u)
if t == 1 then
set k = CreateUnit(l, udg_Tier1CampBuildingType[i], x, y, p)
elseif t == 2 then
set k = CreateUnit(l, udg_Tier2CampBuildingType[i], x, y, p)
elseif t == 3 then
set k = CreateUnit(l, udg_Tier3CampBuildingType[i], x, y, p)
endif
// call echo("CampNumber= " + I2S(LoadInteger(udg_H, GetHandleId(k), StringHash("CampNumber"))) + " type = " + I2S(LoadInteger(udg_H, GetHandleId(k), StringHash("CampType"))) )
else
set k = u
endif
set id = GetHandleId(k)
call GroupAddUnit(udg_CampGroup, k)
call SaveInteger(udg_H, id, StringHash("CampNumber"), n)
call SaveInteger(udg_H, id, StringHash("CampType"), i)
call SaveInteger(udg_H, id, StringHash("CampTier"), t)
//call UnitAddAbility(k, udg_RallyAbility)
call UnitAddAbility(k, 'ARal')
set p = 270 * bj_DEGTORAD
set x = GetUnitX(k) + 125 * Cos(p)
set y = GetUnitY(k) + 125 * Sin(p)
call SaveReal(udg_H, id, StringHash("CampRallyTargetX"), x)
call SaveReal(udg_H, id, StringHash("CampRallyTargetY"), y)
set n = n + 1
endif
endif
call GroupRemoveUnit(udg_G, u)
exitwhen u == null
endloop
call TimerStart(udg_Timer, 0.1, true, function TimerExpire)
set k = null
set u = null
endfunction
//===========================================================================
function InitTrig_Init takes nothing returns nothing
set gg_trg_Init = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Init, 0.10 )
call TriggerAddAction( gg_trg_Init, function Init )
endfunction
//Code indented using The_Witcher's Script language Aligner
//Download the newest version and report bugs at www.hiveworkshop.com
function BossDrop takes nothing returns nothing
local unit d = GetDyingUnit()
local integer id = GetUnitTypeId(d)
local integer i = 1
local integer t = 0
set i = 1
loop
exitwhen i > udg_Tier1CampCount
if id == udg_Tier1CampBossType[i] then
set t = 1
endif
set i = i + 1
endloop
set i = 1
loop
exitwhen i > udg_Tier2CampCount
if id == udg_Tier2CampBossType[i] then
set t = 2
endif
set i = i + 1
endloop
set i = 1
loop
exitwhen i > udg_Tier3CampCount
if id == udg_Tier3CampBossType[i] then
set t = 3
endif
set i = i + 1
endloop
if t == 1 then
set i = GetRandomInt(1, udg_Tier1BossDropItemCount)
call CreateItem(udg_Tier1BossDropItem[i], GetUnitX(d), GetUnitY(d))
elseif t == 2 then
set i = GetRandomInt(1, udg_Tier2BossDropItemCount)
call CreateItem(udg_Tier2BossDropItem[i], GetUnitX(d), GetUnitY(d))
elseif t == 3 then
set i = GetRandomInt(1, udg_Tier3BossDropItemCount)
call CreateItem(udg_Tier3BossDropItem[i], GetUnitX(d), GetUnitY(d))
endif
set d = null
endfunction
//===========================================================================
function InitTrig_Boss_Drop takes nothing returns nothing
set gg_trg_Boss_Drop = CreateTrigger( )
call TriggerRegisterPlayerUnitEvent(gg_trg_Boss_Drop, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH , null)
call TriggerAddAction( gg_trg_Boss_Drop, function BossDrop)
endfunction
function RallyOrderCon takes nothing returns boolean
return IsUnitType(GetOrderedUnit(), UNIT_TYPE_STRUCTURE) and IsUnitInGroup(GetOrderedUnit(), udg_TrainGroup)
endfunction
function RallyOrder takes nothing returns nothing
local unit u = GetOrderedUnit()
local integer oi = GetIssuedOrderId()
local unit t = GetOrderTargetUnit()
local integer id = GetHandleId(u)
local real x
local real y
if oi == 851980 or oi == 851971 then
if t != null then
set x = GetUnitX(t)
set y = GetUnitY(t)
else
set x = GetOrderPointX()
set y = GetOrderPointY()
endif
call SaveReal(udg_H, id, StringHash("CampRallyTargetX"), x)
call SaveReal(udg_H, id, StringHash("CampRallyTargetY"), y)
endif
set t = null
set u = null
endfunction
//===========================================================================
function InitTrig_Rally_Order takes nothing returns nothing
set gg_trg_Rally_Order = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Rally_Order, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Rally_Order, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerAddCondition( gg_trg_Rally_Order, Condition( function RallyOrderCon))
call TriggerAddAction( gg_trg_Rally_Order, function RallyOrder)
endfunction
function CampDeadCon takes nothing returns boolean
return IsUnitInGroup(GetDyingUnit(), udg_CampGroup) or IsUnitInGroup(GetDyingUnit(), udg_TrainGroup)
endfunction
function CampDead takes nothing returns nothing
local unit u = GetDyingUnit()
local player k = GetOwningPlayer(GetKillingUnit())
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local integer ty = GetUnitTypeId(u)
local real f = GetUnitFacing(u)
local integer cn = LoadInteger(udg_H, GetHandleId(u), StringHash("CampNumber"))
local integer id
local unit d
if IsUnitInGroup(u, udg_CampGroup) then
if k != GetOwningPlayer(u) then
set d = CreateUnit(k, ty, x, y, f)
call GroupAddUnit(udg_TrainGroup, d)
call GroupRemoveUnit(udg_CampGroup, u)
endif
elseif IsUnitInGroup(u, udg_TrainGroup) then
if k == GetOwningPlayer(u) then
set d = CreateUnit(udg_NeutralPlayer, ty, x, y, f)
call GroupAddUnit(udg_CampGroup, d)
call GroupRemoveUnit(udg_TrainGroup, u)
elseif k != GetOwningPlayer(u) then
set d = CreateUnit(k, ty, x, y, f)
call GroupAddUnit(udg_TrainGroup, d)
call GroupRemoveUnit(udg_TrainGroup, u)
endif
endif
call SaveInteger(udg_H, GetHandleId(d), StringHash("CampNumber"), cn)
call SaveInteger(udg_H, GetHandleId(d), StringHash("CampType"), LoadInteger(udg_H, GetHandleId(u), StringHash("CampType")))
call SaveInteger(udg_H, GetHandleId(d), StringHash("CampTier"), LoadInteger(udg_H, GetHandleId(u), StringHash("CampTier")))
call UnitAddAbility(d, 'ARal')
set f = 270 * bj_DEGTORAD
set x = x + 125 * Cos(f)
set y = y + 125 * Sin(f)
call SaveReal(udg_H, GetHandleId(d), StringHash("CampRallyTargetX"), x)
call SaveReal(udg_H, GetHandleId(d), StringHash("CampRallyTargetY"), y)
call FlushChildHashtable(udg_H, GetHandleId(u))
set bj_groupAddGroupDest = udg_GG
call ForGroup(udg_TrainUnits, function GroupAddGroupEnum)
set bj_groupCountUnits = 0
call ForGroup(udg_GG, function CountUnitsInGroupEnum)
if bj_groupCountUnits > 0 then
loop
set u = FirstOfGroup(udg_GG)
set id = GetHandleId(u)
if id > 0 then
if cn == LoadInteger(udg_H, id, StringHash("CampNumber")) then
call KillUnit(u)
endif
endif
call GroupRemoveUnit(udg_GG, u)
exitwhen u == null
endloop
endif
set udg_CampSpawnCurrentLimit[cn] = 0
//call echo("create CampNumber= " + I2S(LoadInteger(udg_H, GetHandleId(d), StringHash("CampNumber"))) + " type = " + I2S(LoadInteger(udg_H, GetHandleId(d), StringHash("CampType"))) +" level = "+ I2S(GetUnitAbilityLevel(d,'AHbh')))
//clear hash
set d = null
set u = null
endfunction
//===========================================================================
function InitTrig_Camp_Dead takes nothing returns nothing
set gg_trg_Camp_Dead = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Camp_Dead, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_Camp_Dead, Condition( function CampDeadCon ) )
call TriggerAddAction( gg_trg_Camp_Dead, function CampDead)
endfunction
function TrainDeadCon takes nothing returns boolean
return IsUnitInGroup(GetDyingUnit(), udg_TrainUnits)
endfunction
function TrainDead takes nothing returns nothing
local unit u = GetDyingUnit()
local integer cn = LoadInteger(udg_H, GetHandleId(u), StringHash("CampNumber"))
local integer l = udg_CampSpawnCurrentLimit[cn]
if l > 0 then
set udg_CampSpawnCurrentLimit[cn] = udg_CampSpawnCurrentLimit[cn] - 1
endif
call GroupRemoveUnit(udg_TrainUnits,u)
call FlushChildHashtable(udg_H, GetHandleId(u))
set u = null
endfunction
//===========================================================================
function InitTrig_Train_Dead takes nothing returns nothing
set gg_trg_Train_Dead = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Train_Dead, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_Train_Dead, Condition( function TrainDeadCon ))
call TriggerAddAction( gg_trg_Train_Dead, function TrainDead)
endfunction