function AdjustPlayerStateCS takes integer delta, integer i, playerstate whichPlayerState returns nothing
if (whichPlayerState == PLAYER_STATE_RESOURCE_GOLD) then
call SetPlayerState(Player(i), PLAYER_STATE_GOLD_GATHERED, GetPlayerState(Player(i), PLAYER_STATE_GOLD_GATHERED) + delta)
elseif (whichPlayerState == PLAYER_STATE_RESOURCE_LUMBER) then
call SetPlayerState(Player(i), PLAYER_STATE_LUMBER_GATHERED, GetPlayerState(Player(i), PLAYER_STATE_LUMBER_GATHERED) + delta)
endif
call SetPlayerState(Player(i), whichPlayerState, GetPlayerState(Player(i), whichPlayerState) + delta)
set udg_TotalAssets[i] = udg_TotalAssets[i] + delta
endfunction
function SetPlayerStateCS takes integer i, playerstate whichPlayerState, integer value returns nothing
local integer oldValue = GetPlayerState(Player(i), whichPlayerState)
call AdjustPlayerStateCS(value - oldValue, i, whichPlayerState)
endfunction
function ISignCS takes integer a returns string
if a >= 0 then
return "+" + I2S(a)
endif
return "-" + I2S(-a)
endfunction
function ISignCS2 takes integer a returns string
local string s = I2S(a)
local integer i = StringLength(s)
local integer j = i / 3
local integer k
if ModuloInteger(i, 3) == 0 then
set j = j - 1
endif
loop
exitwhen j < 1
set k = i - j * 3
set s = SubString(s, 0, k) + "," + SubString(s, k, i)
set i = i + 1
set j = j - 1
endloop
return s
endfunction
function BoardWidth takes nothing returns real
return 4 + 0.5 * Pow(2, 5-I2R(udg_Players))
endfunction
function DistanceBetweenUnits takes unit a, unit b returns real
local real dx = GetUnitX(b) - GetUnitX(a)
local real dy = GetUnitY(b) - GetUnitY(a)
return SquareRoot(dx * dx + dy * dy)
endfunction
function SetPlayerAbilityAvailableCS takes integer i returns nothing
call SetPlayerAbilityAvailable(Player(i), 'A008', false)
call SetPlayerAbilityAvailable(Player(i), 'A009', true)
endfunction
function SetPlayerAbilityAvailableCS2 takes integer i returns nothing
call SetPlayerAbilityAvailable(Player(i), 'A003', false)
call SetPlayerAbilityAvailable(Player(i), 'A005', true)
call SetPlayerAbilityAvailable(Player(i), 'A00F', false)
call SetPlayerAbilityAvailable(Player(i), 'A007', true)
endfunction
function SetPlayerAbilityAvailableCS3 takes integer i returns nothing
call DestroyEffect(udg_Attention)
set udg_Attention = null
call SetPlayerAbilityAvailable(Player(i), 'A009', false)
call SetPlayerAbilityAvailable(Player(i), 'A008', true)
call LeaderboardDisplay(udg_Leaderboard[i], false)
call TimerDialogDisplayForPlayerBJ(false, udg_TimerWindow, Player(i))
call PauseTimer(udg_Timer)
endfunction
function Destroy_Timer takes nothing returns nothing
call DestroyTimerDialog(udg_TimerWindow)
set udg_TimerWindow = null
call PauseTimer(udg_Timer)
endfunction
function Take_Over takes integer i returns nothing
local integer j = 0
local location loc = GetUnitLoc(udg_Token[i])
set udg_Status[i] = 0
call LeaderboardDisplay(udg_Leaderboard[i], false)
call KillUnit(udg_Token[i])
set udg_Token[i] = CreateUnitAtLoc(Player(i), 'n009', loc, GetRandomReal(0, 360))
call SetUnitUserData(udg_Token[i], i)
call DestroyEffect(AddSpecialEffectLoc("Objects\\Spawnmodels\\Human\\HumanLargeDeathExplode\\HumanLargeDeathExplode.mdl", loc))
loop
exitwhen j > udg_FoodCap
if udg_BuildingOwner[j] == i then
set udg_BuildingOwner[j] = 8
call SetUnitOwner(udg_Building[j], Player(8), true)
endif
set j = j + 1
endloop
call DisplayTimedTextToForce(GetPlayersAll(), 15, udg_PlayerName[i] + " has failed completely!")
call StartSound(gg_snd_ArrangedTeamInvitation)
call RemoveLocation(loc)
set loc = null
endfunction
function Game_Over takes nothing returns nothing
local integer i = udg_Turn[udg_Mover]
local integer j = 0
local location unitLoc = GetUnitLoc(udg_Token[i])
call ClearTextMessagesBJ(GetPlayersAll())
call DisplayTimedTextToForce(GetPlayersAll(), 15, udg_PlayerName[i] + " has won finally!")
call StartSound(gg_snd_ArrangedTeamInvitation)
call PolledWait(5)
call CinematicModeExBJ(true, GetPlayersAll(), 0.5)
call ClearSelection()
loop
exitwhen j > 4
call SetCameraFieldForPlayer(Player(j), CAMERA_FIELD_FARZ, 10000, 0)
call PanCameraToTimedLocForPlayer(Player(j), unitLoc, 5)
call SetCameraFieldForPlayer(Player(j), CAMERA_FIELD_TARGET_DISTANCE, 500, 5)
call SetCameraFieldForPlayer(Player(j), CAMERA_FIELD_ROTATION, GetUnitFacing(udg_Token[i])-150, 5)
call SetCameraFieldForPlayer(Player(j), CAMERA_FIELD_ZOFFSET, 65, 5)
set j = j + 1
endloop
call RemoveLocation(unitLoc)
set unitLoc = null
call PolledWait(2)
call StartSound(gg_snd_ClanInvitation)
call PolledWait(2)
call TransmissionFromUnitWithNameBJ(GetPlayersAll(), udg_Token[i], udg_PlayerName[i], null, "I have won this war.|nI don't feel surprised at all!", 0, 5, true)
call SetUnitAnimation(udg_Token[i], "attack")
call TransmissionFromUnitWithNameBJ(GetPlayersAll(), udg_Token[i], udg_PlayerName[i], null, "In fact other pitiful creatures have failed from the beginning of war.|nBecause their rival is me.", 0, 5, true)
call CinematicFadeBJ(1, 2, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 0, 0, 0, 0)
call DisplayTimedTextToForce(GetPlayersAll(), 15, "|cffffcc00Thanks you for playing!|r")
call PolledWait(8)
set j = 0
loop
exitwhen j > 4
if j == i then
call CustomVictoryBJ(Player(j), true, true)
else
call CustomDefeatBJ(Player(j), "Defeat!")
endif
set j = j + 1
endloop
endfunction
function Standing takes unit whichUnit returns nothing
local integer i = udg_Move[GetUnitUserData(whichUnit)]
local location loc = GetUnitLoc(udg_Circle[i])
call PauseUnit(whichUnit, true)
call SetUnitPositionLoc(whichUnit, loc)
call SetUnitFacing(whichUnit, udg_Signpost[i])
call RemoveLocation(loc)
set loc = null
call PauseUnit(whichUnit, false)
endfunction
function Rolling takes integer i returns nothing
set udg_TokenStatus[i] = 2
set udg_TempPoint = GetUnitLoc(udg_Token[i])
call SetUnitPositionLoc(udg_DiceUnit, udg_TempPoint)
call SetUnitFlyHeight(udg_DiceUnit, 0, 0)
call SetUnitFacing(udg_Token[i], udg_Signpost[udg_Move[i]])
set udg_Length = 18
call ShowUnit(udg_DiceUnit, true)
call SetPlayerAbilityAvailableCS3(i)
call EnableTrigger(gg_trg_Throwing)
endfunction
function Costing takes integer i, integer k, string s returns nothing
call LeaderboardAddItemBJ(Player(4), udg_Leaderboard[i], s, k)
call LeaderboardSetItemLabelColor(udg_Leaderboard[i], LeaderboardGetPlayerIndex(udg_Leaderboard[i], Player(4)), 126, 191, 241, 255)
call LeaderboardSetItemValueColor(udg_Leaderboard[i], LeaderboardGetPlayerIndex(udg_Leaderboard[i], Player(4)), 126, 191, 241, 255)
endfunction
function Buying takes integer i, string order, integer abilid, integer abilid2 returns nothing
call TimerDialogDisplayForPlayerBJ(true, udg_TimerWindow, Player(i))
call ResumeTimer(udg_Timer)
set udg_Attention = AddSpecialEffectTarget("Abilities\\Spells\\Other\\TalkToMe\\TalkToMe.mdl", udg_Token[i], "overhead")
call SetPlayerAbilityAvailable(Player(i), abilid, false)
call SetPlayerAbilityAvailable(Player(i), abilid2, true)
call SetPlayerAbilityAvailable(Player(i), 'A002', true)
if udg_Status[i] > 1 then
call UnitResetCooldown(udg_Token[i])
call PolledWait(0.05)
call IssueImmediateOrder(udg_Token[i], order)
endif
endfunction
function Selling takes unit whichUnit returns nothing
local integer i = GetUnitUserData(whichUnit)
local integer j = GetPlayerId(GetOwningPlayer(whichUnit))
local integer k = udg_BuildingValue[i]
call AdjustPlayerStateCS(-k, j, PLAYER_STATE_RESOURCE_LUMBER)
call AdjustPlayerStateCS(k/2, j, PLAYER_STATE_RESOURCE_GOLD)
set udg_BuildingOwner[i] = 8
call SetUnitOwner(whichUnit, Player(8), true)
call AddIndicator(whichUnit, 255, 255, 255, 255)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl", whichUnit, "origin"))
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[j] + " sells a |cff7ebff1" + udg_BuildingTypeName[udg_BuildingType[i]] + "|r at discount.")
endfunction
function Camping takes integer i, integer j returns nothing
local integer k
local integer m
local integer n
set udg_TokenStatus[i] = 2
call PolledWait(0.01)
if j <= udg_FoodCap then
call LeaderboardSetLabelBJ(udg_Leaderboard[i], udg_BuildingTypeName[udg_BuildingType[j]])
call LeaderboardSetItemValue(udg_Leaderboard[i], LeaderboardGetPlayerIndex(udg_Leaderboard[i], Player(0)), udg_BuildingValue[j])
call LeaderboardSetItemValue(udg_Leaderboard[i], LeaderboardGetPlayerIndex(udg_Leaderboard[i], Player(1)), udg_BuildingRent[j])
call LeaderboardSetItemValue(udg_Leaderboard[i], LeaderboardGetPlayerIndex(udg_Leaderboard[i], Player(2)), udg_BuildingLevel[j])
call LeaderboardSetItemLabel(udg_Leaderboard[i], LeaderboardGetPlayerIndex(udg_Leaderboard[i], Player(3)), "Owner " + udg_PlayerName[udg_BuildingOwner[j]])
call LeaderboardDisplay(udg_Leaderboard[i], true)
if udg_BuildingOwner[j] == 8 then
if udg_BuildingLevel[j] > 0 then
set k = udg_BuildingValue[j]
else
set k = udg_BuildingValue[j] * 9 / 10
endif
call Costing(i, k, "Conquer")
if GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD) > k then
call Buying(i, "thunderclap", 'A005', 'A003')
return
endif
elseif udg_BuildingOwner[j] == i then
set k = udg_BuildingUpgrade[udg_BuildingType[j] * 2 + udg_BuildingLevel[j] - 1]
if udg_BuildingLevel[j] > 0 and udg_BuildingLevel[j] < 3 and GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD) > k then
call Costing(i, k, "Upgrade")
call Buying(i, "stomp", 'A007', 'A00F')
return
else
call Costing(i, 0, "Cost")
endif
elseif udg_BuildingLevel[j] > 0 then
if udg_BuildingSleep[j] > 0 then
set udg_BuildingSleep[j] = udg_BuildingSleep[j] - 1
call PingMinimapForForceEx(GetPlayersAll(), GetUnitX(udg_Building[j]), GetUnitY(udg_Building[j]), 5, 0, 0, 100, 0)
call DisplayTextToForce( GetPlayersAll(), "A |cff7ebff1" + udg_BuildingTypeName[udg_BuildingType[j]] + "|r of the " + udg_PlayerName[udg_BuildingOwner[j]] + "'s is unable to charge the rent at present.")
elseif udg_TokenFree[i] > 0 then
call IssueTargetOrder(udg_DiceUnit, "bloodlust", udg_Token[i])
call DisplayTextToForce( GetPlayersAll(), udg_PlayerName[i] + " is exempt from the rent.")
else
set k = udg_BuildingRent[j]
set m = GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD)
call Costing(i, k, "Cost")
if m < k then
set k = m
endif
call AdjustPlayerStateCS(-k, i, PLAYER_STATE_RESOURCE_GOLD)
call AdjustPlayerStateCS(k, udg_BuildingOwner[j], PLAYER_STATE_RESOURCE_GOLD)
call DisplayTextToForce( GetPlayersAll(), udg_PlayerName[i] + " pays rent |cffffcc00" + ISignCS2(k) + "|r gold coins to " + udg_PlayerName[udg_BuildingOwner[j]] + ".")
call IssueTargetOrder(udg_DiceUnit, "faeriefire", udg_Token[i])
set m = GetRandomInt(1, 4)
if m == 1 then
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Orc\\Orcblood\\BattrollBlood.mdl", udg_Token[i], "origin"))
elseif m == 2 then
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl", udg_Token[i], "origin"))
elseif m == 3 then
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Orc\\Orcblood\\OrcBloodHellScream.mdl", udg_Token[i], "origin"))
else
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Undead\\UndeadBlood\\UndeadBloodAbomination.mdl", udg_Token[i], "origin"))
endif
call SetUnitAnimation(udg_Token[i], "attack")
call Destroy_Timer()
call PolledWait(0.2)
call SetUnitAnimation(udg_Token[i], "stand")
call PolledWait(0.5)
call LeaderboardDisplay(udg_Leaderboard[i], false)
call LeaderboardRemovePlayerItemBJ(Player(4), udg_Leaderboard[i])
call SetPlayerAbilityAvailableCS(i)
if GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD) == 0 then
call Take_Over(i)
endif
call TriggerExecute(gg_trg_Carry_On)
return
endif
call Costing(i, 0, "Cost")
else
call Costing(i, 0, "Cost")
endif
call PolledWait(0.5)
call Destroy_Timer()
call LeaderboardDisplay(udg_Leaderboard[i], false)
call LeaderboardRemovePlayerItemBJ(Player(4), udg_Leaderboard[i])
elseif j == udg_FoodCap + 1 then
if udg_Status[i] == 4 and GetRandomInt(0, 4) == 1 then
set k = 7
else
set k = GetRandomInt(0, 24)
endif
set n = -1
set m = 0
loop
exitwhen m > 5
if GetItemTypeId(UnitItemInSlot(udg_Token[i], m)) == udg_CardItemType[k] then
set n = m
endif
set m = m + 1
endloop
if n != -1 then
set m = GetItemUserData(UnitItemInSlot(udg_Token[i], n)) + 1
call SetItemUserData(UnitItemInSlot(udg_Token[i], n), m)
call SetItemCharges(UnitItemInSlot(udg_Token[i], n), m)
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Other\\ToonBoom\\ToonBoom.mdl", udg_Token[i], "origin"))
elseif UnitInventoryCount(udg_Token[i]) < 6 then
call UnitAddItemByIdSwapped(udg_CardItemType[k], udg_Token[i])
call SetItemUserData(GetLastCreatedItem(), 1)
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Other\\ToonBoom\\ToonBoom.mdl", udg_Token[i], "origin"))
endif
elseif j == udg_FoodCap + 2 then
set k = GetRandomInt(0, 17)
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[i] + udg_Event[k])
if k < 16 then
set m = GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD)
if udg_Bonus[k] + m < 0 then
call AdjustPlayerStateCS(-m, i, PLAYER_STATE_RESOURCE_GOLD)
call Take_Over(i)
else
call AdjustPlayerStateCS(udg_Bonus[k], i, PLAYER_STATE_RESOURCE_GOLD)
endif
elseif udg_TokenSleep[i] == 0 then
if k == 16 then
set udg_TokenSleep[i] = 1
else
set udg_TokenSleep[i] = 2
endif
endif
endif
call SetPlayerAbilityAvailableCS(i)
call TriggerExecute(gg_trg_Carry_On)
endfunction
function End_Turn takes integer i, boolean wink returns nothing
local integer j
set udg_TokenStatus[i] = 2
call PauseTimer(udg_Timer)
call DestroyEffect(udg_Attention)
set udg_Attention = null
if wink then
set j = 1
loop
exitwhen j > 6
if ModuloInteger(j, 2) != 0 then
call LeaderboardSetItemLabelColor(udg_Leaderboard[i], LeaderboardGetPlayerIndex(udg_Leaderboard[i], Player(4)), 255, 255, 255, 255)
call LeaderboardSetItemValueColor(udg_Leaderboard[i], LeaderboardGetPlayerIndex(udg_Leaderboard[i], Player(4)), 255, 255, 255, 255)
else
call LeaderboardSetItemLabelColor(udg_Leaderboard[i], LeaderboardGetPlayerIndex(udg_Leaderboard[i], Player(4)), 126, 191, 241, 255)
call LeaderboardSetItemValueColor(udg_Leaderboard[i], LeaderboardGetPlayerIndex(udg_Leaderboard[i], Player(4)), 126, 191, 241, 255)
endif
call PolledWait(0.12)
set j = j + 1
endloop
else
call PolledWait(0.5)
endif
call Destroy_Timer()
call LeaderboardDisplay(udg_Leaderboard[i], false)
call LeaderboardRemovePlayerItemBJ(Player(4), udg_Leaderboard[i])
call SetPlayerAbilityAvailableCS(i)
endfunction
function Item_Charges takes integer i,unit whichUnit returns nothing
local item whichItem = UnitItemInSlot(whichUnit, i)
local integer j = GetItemUserData(whichItem) - 1
if j == 0 then
call UnitRemoveItemFromSlot(whichUnit, i)
else
call SetItemUserData(whichItem, j)
call PolledWait(0.15)
call SetItemCharges(whichItem, j)
endif
endfunction
function Item_Charges2 takes item whichItem returns nothing
call SetItemUserData(whichItem, GetItemUserData(whichItem)+1)
call SetItemCharges(whichItem, GetItemCharges(whichItem)+1)
endfunction
function Item_Roaring takes integer j, unit whichUnit returns nothing
local integer i = GetUnitUserData(whichUnit)
local item whichItem = UnitItemInSlot(whichUnit, j)
local integer itemTypeId = GetItemTypeId(whichItem)
if itemTypeId == 'I003' then
call AdjustPlayerStateCS(3000, i, PLAYER_STATE_RESOURCE_GOLD)
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[i] + " finds the gold mine. Earn |cffffcc003,000|r gold coins.")
elseif itemTypeId == 'I002' then
call AdjustPlayerStateCS(6000, i, PLAYER_STATE_RESOURCE_GOLD)
call DisplayTextToForce(GetPlayersAll(), "The country where " + udg_PlayerName[i] + " ruled has obtained the great bumper harvest. Receive |cffffcc006,000|r gold coins of the repayment.")
elseif itemTypeId == 'I000' then
set udg_TokenFree[i] = 3
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Charm\\CharmTarget.mdl", whichUnit, "origin"))
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[i] + " promises not to pay the rent to any enemy.")
else
if udg_TokenStatus[i] == 0 then
if itemTypeId == 'I001' then
set udg_Dice = 1
elseif itemTypeId == 'I006' then
set udg_Dice = 2
elseif itemTypeId == 'I007' then
set udg_Dice = 3
elseif itemTypeId == 'I004' then
set udg_Dice = 4
elseif itemTypeId == 'I005' then
set udg_Dice = 5
elseif itemTypeId == 'I008' then
set udg_Dice = 0
endif
call SetPlayerAbilityAvailable(Player(i), 'A000', false)
call SetPlayerAbilityAvailable(Player(i), 'A001', true)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\HowlOfTerror\\HowlCaster.mdl", whichUnit, "origin"))
call Rolling(i)
else
call Item_Charges2(whichItem)
endif
endif
call Item_Charges(j, whichUnit)
endfunction
function Item_Robbery takes unit victim, unit villain returns boolean
local integer i = 0
local integer j = 0
local integer k
local integer n = 0
local integer array count
local integer itemTypeId
loop
exitwhen j > 5
if UnitItemInSlot(victim, j) != null then
set count[i] = j
set i = i + 1
endif
set j = j + 1
endloop
if i > 0 then
set k = GetRandomInt(0, i-1)
set itemTypeId = GetItemTypeId(UnitItemInSlot(victim, count[k]))
set i = 0
set j = 0
loop
exitwhen j > 5
if GetItemTypeId(UnitItemInSlot(villain, j)) == itemTypeId then
set i = j + 1
set j = 5
endif
set j = j + 1
endloop
set n = 1
if i != 0 then
call Item_Charges2(UnitItemInSlot(villain, i-1))
else
if UnitInventoryCount(villain) < 6 then
call UnitAddItemByIdSwapped(itemTypeId, villain)
call SetItemUserData(GetLastCreatedItem(), 1)
else
set n = 0
endif
endif
endif
if n == 1 then
call Item_Charges(count[k], victim)
return true
endif
return false
endfunction
function Item_Portal takes integer j returns nothing
local integer i = 0
local integer k
local location loc
loop
exitwhen i > udg_WayPoints
if udg_Portal[i] == j then
set k = i
set i = udg_WayPoints
endif
set i = i + 1
endloop
set loc = GetUnitLoc(udg_Circle[k])
call RemoveUnit(udg_Circle[k])
set udg_Circle[k] = null
set udg_Circle[k] = CreateUnitAtLoc(Player(6), udg_BuildingUnitType[udg_BuildingLevel[j]+3], loc, 270)
call SetUnitColor(udg_Circle[k], PLAYER_COLOR_GREEN)
call RemoveLocation(loc)
set loc = null
endfunction
function Item_RainOfFire takes integer i, unit victim returns nothing
local location loc = GetUnitLoc(victim)
call PingMinimapForForceEx(GetPlayersAll(), GetUnitX(victim), GetUnitY(victim), 5, 2, 100, 50, 0)
call IssuePointOrderLoc(udg_DiceUnit, "rainoffire", loc)
call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl", loc))
call KillUnit(victim)
set udg_Field[i] = CreateDestructable('DTrx', GetUnitX(victim), GetUnitY(victim), 270, 1, 0)
call ChangeElevatorHeight(udg_Field[i], 2)
set udg_Building[i] = CreateUnitAtLoc(Player(8), 'n003', loc, 270)
call SetUnitUserData(udg_Building[i], i)
call RemoveLocation(loc)
set loc = null
if udg_BuildingLevel[i] > 1 then
set udg_BuildingLevel[i] = 1
call Item_Portal(i)
endif
set udg_BuildingValue[i] = (8 - udg_BuildingType[i] * 2) * 1000
set udg_BuildingRent[i] = udg_BuildingValue[i] / 10
set udg_BuildingLevel[i] = 0
set udg_BuildingOwner[i] = 8
endfunction
function Item_AdjustStock takes integer stockId returns nothing
local integer i = 0
local integer j = udg_S_SharePrice[stockId] + udg_S_Swing[stockId]
if j < 10 then
set udg_S_Swing[stockId] = 10 - udg_S_SharePrice[stockId]
elseif j > 200 then
set udg_S_Swing[stockId] = 200 - udg_S_SharePrice[stockId]
endif
set udg_S_SharePrice[stockId] = udg_S_SharePrice[stockId] + udg_S_Swing[stockId]
call MultiboardSetItemValueBJ(udg_Multiboard, 2, stockId+2, I2S(udg_S_SharePrice[stockId]))
call MultiboardSetItemValueBJ(udg_Multiboard, 3, stockId+2, ISignCS(udg_S_Swing[stockId]))
loop
exitwhen i == udg_Players
set j = udg_S_Amount[stockId * 5 + udg_Turn[i]] * udg_S_Swing[stockId]
set udg_S_Amount[30+udg_Turn[i]] = udg_S_Amount[30+udg_Turn[i]] + j
call MultiboardSetItemValueBJ(udg_Multiboard, udg_S_Column[udg_Turn[i]], 8, ISignCS2(udg_S_Amount[30+udg_Turn[i]]))
set udg_TotalAssets[udg_Turn[i]] = udg_TotalAssets[udg_Turn[i]] + j
set i = i + 1
endloop
if udg_S_Swing[stockId] > 0 then
call MultiboardSetItemColorBJ(udg_Multiboard, 0, stockId+2, 100, 0, 0, 0)
else
call MultiboardSetItemColorBJ(udg_Multiboard, 0, stockId+2, 0, 100, 0, 0)
endif
call MultiboardSetItemColorBJ(udg_Multiboard, 1, stockId+2, 100, 80, 20, 0)
endfunction
function Item_Main takes integer i, unit victim, unit villain, integer m, integer n, integer itemTypeId returns nothing
local integer j
local integer k
if itemTypeId == 'I00D' then
set j = GetPlayerState(Player(m), PLAYER_STATE_RESOURCE_GOLD) / 5
call AdjustPlayerStateCS(-j, m, PLAYER_STATE_RESOURCE_GOLD)
call AdjustPlayerStateCS(j, n, PLAYER_STATE_RESOURCE_GOLD)
call IssueTargetOrder(udg_DiceUnit, "faeriefire", victim)
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanLargeDeathExplode\\HumanLargeDeathExplode.mdl", victim, "origin"))
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[n] + " use |cff7ebff1levy a tax|r card to " + udg_PlayerName[m] + ". The victim " + udg_PlayerName[m] + " is levied a tax by force.")
elseif itemTypeId == 'I009' then
set j = GetPlayerState(Player(n), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(m), PLAYER_STATE_RESOURCE_GOLD)
set k = ModuloInteger(j, 2)
set j = j / 2
call SetPlayerStateCS(n, PLAYER_STATE_RESOURCE_GOLD, j+k)
call SetPlayerStateCS(m, PLAYER_STATE_RESOURCE_GOLD, j)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Resurrect\\ResurrectCaster.mdl", victim, "origin"))
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanLargeDeathExplode\\HumanLargeDeathExplode.mdl", victim, "origin"))
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[n] + " use |cff7ebff1even and rich|r card to " + udg_PlayerName[m] + ". The victim " + udg_PlayerName[m] + " is dismembered the property by force.")
elseif itemTypeId == 'I00A' then
set udg_TokenSleep[m] = 3
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl", victim, "origin"))
call DisplayTextToForce( GetPlayersAll(), udg_PlayerName[n] + " use |cff7ebff1plot against|r card to " + udg_PlayerName[m] + ". The victim " + udg_PlayerName[m] + " is plotted against. |cffa0ff003|r rounds stop.")
elseif itemTypeId == 'I00C' then
call Item_Charges(i, villain)
if Item_Robbery(victim, villain) then
call IssueTargetOrder(udg_DiceUnit, "shadowstrike", victim)
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Other\\ToonBoom\\ToonBoom.mdl", villain, "origin"))
call DisplayTextToForce( GetPlayersAll(), udg_PlayerName[n] + " use |cff7ebff1robbery|r card to " + udg_PlayerName[m] + ". The victim " + udg_PlayerName[m] + " is robbed.")
else
call DisplayTextToForce(bj_FORCE_PLAYER[n], "|cffa0ff00Have robbed and failed!|r")
endif
return
elseif itemTypeId == 'I00E' then
set udg_SnapToken[m] = 1
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Feedback\\ArcaneTowerAttack.mdl", victim, "overhead"))
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[n] + " use |cff7ebff1fix the body|r card to " + udg_PlayerName[m] + ". The victim " + udg_PlayerName[m] + " has the body fixed.")
elseif itemTypeId == 'I00B' then
set j = udg_Turn[udg_Mover]
set k = GetPlayerState(Player(m), PLAYER_STATE_RESOURCE_GOLD)
if k <= 2000 and m == j then
if udg_TokenStatus[j] == 1 then
call Item_Charges2(UnitItemInSlot(villain, i))
set j = -1
endif
endif
if j != -1 then
if k > 2000 then
set k = 2000
endif
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Polymorph\\PolyMorphFallingSheepArt.mdl", victim, "overhead"))
call AdjustPlayerStateCS(-k, m, PLAYER_STATE_RESOURCE_GOLD)
call DisplayTextToForce( GetPlayersAll(), udg_PlayerName[n] + " use |cff7ebff1bad luck|r card to " + udg_PlayerName[m] + ". The victim " + udg_PlayerName[m] + "'s quilt bad luck.")
if GetPlayerState(Player(m), PLAYER_STATE_RESOURCE_GOLD) == 0 then
if m == j then
call PauseTimer(udg_Timer)
call Destroy_Timer()
call Take_Over(m)
call TriggerExecute(gg_trg_Carry_On)
else
call Take_Over(m)
endif
endif
endif
elseif itemTypeId == 'I00K' then
set j = GetUnitUserData(victim)
set k = udg_BuildingValue[j]
call AdjustPlayerStateCS(-k, m, PLAYER_STATE_RESOURCE_LUMBER)
call AdjustPlayerStateCS(k, n, PLAYER_STATE_RESOURCE_LUMBER)
set udg_BuildingOwner[j] = n
call PingMinimapForForceEx(GetPlayersAll(), GetUnitX(victim), GetUnitY(victim), 5, 2, 100, 50, 0)
call SetUnitOwner(victim, Player(n), true)
call AddIndicator(victim, 255, 255, 255, 255)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl", victim, "origin"))
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[n] + " use |cff7ebff1conquer by force|r card to a |cff7ebff1" + udg_BuildingTypeName[udg_BuildingType[j]] + "|r of " + udg_PlayerName[m] + "'s. It is conquered by force.")
elseif itemTypeId == 'I00G' then
set j = GetUnitUserData(victim)
set k = udg_BuildingValue[j]
call AdjustPlayerStateCS(-k, m, PLAYER_STATE_RESOURCE_LUMBER)
call AdjustPlayerStateCS(k/2, m, PLAYER_STATE_RESOURCE_GOLD)
set udg_BuildingOwner[j] = 8
call PingMinimapForForceEx(GetPlayersAll(), GetUnitX(victim), GetUnitY(victim), 5, 2, 100, 50, 0)
call SetUnitOwner(victim, Player(8), true)
call AddIndicator(victim, 255, 255, 255, 255)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl", victim, "origin"))
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[n] + " use |cff7ebff1sell by force|r card to a |cff7ebff1" + udg_BuildingTypeName[udg_BuildingType[j]] + "|r of " + udg_PlayerName[m] + "'s. It is sold by force.")
elseif itemTypeId == 'I00I' then
set j = GetUnitUserData(victim)
if udg_BuildingLevel[j] > 0 then
call AdjustPlayerStateCS(-udg_BuildingValue[j], m, PLAYER_STATE_RESOURCE_LUMBER)
call Item_RainOfFire(j, victim)
call DisplayTextToForce( GetPlayersAll(), udg_PlayerName[n] + " use |cff7ebff1destruction|r card to a |cff7ebff1" + udg_BuildingTypeName[udg_BuildingType[j]] + "|r of " + udg_PlayerName[m] + "'s. It is levelled to the ground.")
call Item_Charges(i, villain)
call PolledWait(5)
call RemoveUnit(victim)
set victim = null
return
else
call DisplayTextToForce(bj_FORCE_PLAYER[n], "|cffa0ff00The|r |cff7ebff1destruction|r |cffa0ff00card has been used and failed!|r")
endif
elseif itemTypeId == 'I00H' then
set udg_BuildingSleep[GetUnitUserData(victim)] = 3
call PingMinimapForForceEx(GetPlayersAll(), GetUnitX(victim), GetUnitY(victim), 5, 0, 0, 100, 0)
call IssueTargetOrder(udg_DiceUnit, "freezingbreath", victim)
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[n] + " use |cff7ebff1ice-bound|r card to a |cff7ebff1" + udg_BuildingTypeName[udg_BuildingType[GetUnitUserData(victim)]] + "|r of " + udg_PlayerName[m] + "'s. It has been sealed by the ice and snow.")
elseif itemTypeId == 'I00M' then
set j = GetUnitUserData(victim)
if udg_BuildingLevel[j] > 0 and udg_BuildingLevel[j] < 3 then
set k = udg_BuildingUpgrade[(udg_BuildingType[j] - 1) * 2 + udg_BuildingLevel[j]]
call AdjustPlayerStateCS(k, m, PLAYER_STATE_RESOURCE_LUMBER)
set udg_BuildingValue[j] = udg_BuildingValue[j] + k
set udg_BuildingRent[j] = udg_BuildingRent[j] * 9 / 5
set udg_BuildingLevel[j] = udg_BuildingLevel[j] + 1
call PingMinimapForForceEx(GetPlayersAll(), GetUnitX(victim), GetUnitY(victim), 5, 0, 100, 50, 0)
call AddIndicator(victim, 255, 255, 255, 255)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Awaken\\Awaken.mdl", victim, "origin"))
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[n] + " use |cff7ebff1upgrade|r card to a |cff7ebff1" + udg_BuildingTypeName[udg_BuildingType[j]] + "|r of " + udg_PlayerName[m] + "'s. It is succeeded in extending.")
call Item_Portal(j)
else
call DisplayTextToForce(bj_FORCE_PLAYER[n], "|cffa0ff00Have extended and failed.|r")
endif
elseif itemTypeId == 'I00L' then
set j = GetUnitUserData(victim)
set k = udg_BuildingValue[j] / 5
call AdjustPlayerStateCS(k, m, PLAYER_STATE_RESOURCE_LUMBER)
set udg_BuildingValue[j] = udg_BuildingValue[j] + k
set udg_BuildingRent[j] = udg_BuildingRent[j] * 6 / 5
call PingMinimapForForceEx(GetPlayersAll(), GetUnitX(victim), GetUnitY(victim), 5, 1, 100, 50, 0)
call AddIndicator(victim, 255, 255, 255, 255)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\ReviveHuman\\ReviveHuman.mdl", victim, "origin"))
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[n] + " use |cff7ebff1prosperity|r card to a |cff7ebff1" + udg_BuildingTypeName[udg_BuildingType[j]] + "|r of " + udg_PlayerName[m] + "'s. It is more prosperous.")
elseif itemTypeId == 'I00J' then
set j = GetUnitUserData(victim)
set k = udg_BuildingValue[j] / 5
call AdjustPlayerStateCS(-k, m, PLAYER_STATE_RESOURCE_LUMBER)
set udg_BuildingValue[j] = udg_BuildingValue[j] - k
set udg_BuildingRent[j] = udg_BuildingRent[j] * 4 / 5
call PingMinimapForForceEx(GetPlayersAll(), GetUnitX(victim), GetUnitY(victim), 5, 0, 0, 100, 0)
call AddIndicator(victim, 255, 255, 255, 255)
call DestroyEffect(AddSpecialEffectTarget("Units\\NightElf\\Wisp\\WispExplode.mdl", victim, "origin"))
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[n] + " use |cff7ebff1decline|r card to a |cff7ebff1" + udg_BuildingTypeName[udg_BuildingType[j]] + "|r of " + udg_PlayerName[m] + "'s. It has declined further.")
elseif itemTypeId == 'I00F' then
set j = GetUnitUserData(victim)
if udg_BuildingLevel[j] > 1 then
set udg_BuildingLevel[j] = udg_BuildingLevel[j] - 1
set k = udg_BuildingUpgrade[(udg_BuildingType[j] - 1) * 2 + udg_BuildingLevel[j]]
call AdjustPlayerStateCS(-k, m, PLAYER_STATE_RESOURCE_LUMBER)
set udg_BuildingValue[j] = udg_BuildingValue[j] - k
set udg_BuildingRent[j] = udg_BuildingRent[j] / 5
call PingMinimapForForceEx(GetPlayersAll(), GetUnitX(victim), GetUnitY(victim), 5, 2, 100, 50, 0)
call AddIndicator(victim, 255, 255, 255, 255)
call DestroyEffect(AddSpecialEffectTarget("Units\\Demon\\Infernal\\InfernalBirth.mdl", victim, "origin"))
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[n] + " use |cff7ebff1subversion|r card to a |cff7ebff1" + udg_BuildingTypeName[udg_BuildingType[j]] + "|r of " + udg_PlayerName[m] + "'s. It has been demoted.")
call Item_Portal(j)
else
call DisplayTextToForce(bj_FORCE_PLAYER[n], "|cffa0ff00Have subverted and failed.|r")
endif
endif
call Item_Charges(i, villain)
endfunction
function CheckStockId takes string source, integer start,integer end, integer start2, integer end2 returns integer
local integer i = -1
local integer j = 0
loop
exitwhen j > 5
if SubString(source, start, end) == SubString(udg_S_Acronym[j], start2, end2) then
set i = j
set j = 5
endif
set j = j + 1
endloop
return i
endfunction
function CheckStockItemSlot takes unit whichUnit,integer itemtypeId returns integer
local integer i = -1
local integer j = 0
loop
exitwhen j > 5
if GetItemTypeId(UnitItemInSlot(whichUnit, j)) == itemtypeId then
set i = j
set j = 5
endif
set j = j + 1
endloop
return i
endfunction
function Stock_Exchange takes string chatString, integer n returns nothing
local integer i
local integer j = 0
local integer k
local integer m
if SubString(chatString, 0, 4) == "buy " then
set i = CheckStockId(chatString, 4, 7, 0, 3)
if i != -1 then
set j = S2I(SubString(chatString, 7, StringLength(chatString)))
set k = udg_S_SharePrice[i] * j
if k < GetPlayerState(Player(n), PLAYER_STATE_RESOURCE_GOLD) then
set m = i * 5 + n
call AdjustPlayerStateCS(-k, n, PLAYER_STATE_RESOURCE_GOLD)
set udg_TotalAssets[n] = udg_TotalAssets[n] + k
set udg_S_Amount[m] = udg_S_Amount[m] + j
set udg_S_Amount[30+n] = udg_S_Amount[30+n] + k
call MultiboardSetItemValueBJ(udg_Multiboard, udg_S_Column[n], i+2, I2S(udg_S_Amount[m]))
call MultiboardSetItemValueBJ(udg_Multiboard, udg_S_Column[n], 8, ISignCS2(udg_S_Amount[30+n]))
else
call DisplayTextToForce(bj_FORCE_PLAYER[n], "|cffa0ff00You don't have enough money.|r")
endif
endif
elseif SubString(chatString, 0, 5) == "sell " then
set i = CheckStockId(chatString, 5, 8, 0, 3)
if i != -1 then
set j = S2I(SubString(chatString, 8, StringLength(chatString)))
set m = i * 5 + n
if j <= udg_S_Amount[m] then
set k = udg_S_SharePrice[i] * j
call AdjustPlayerStateCS(k, n, PLAYER_STATE_RESOURCE_GOLD)
set udg_TotalAssets[n] = udg_TotalAssets[n] - k
set udg_S_Amount[m] = udg_S_Amount[m] - j
set udg_S_Amount[30+n] = udg_S_Amount[30+n] - k
call MultiboardSetItemValueBJ(udg_Multiboard, udg_S_Column[n], i+2, I2S(udg_S_Amount[m]))
call MultiboardSetItemValueBJ(udg_Multiboard, udg_S_Column[n], 8, ISignCS2(udg_S_Amount[30+n]))
else
call DisplayTextToForce(bj_FORCE_PLAYER[n], "|cffa0ff00You don't have enough stock.|r")
endif
endif
else
if SubString(chatString, 0, 5) == "rise " then
set j = CheckStockItemSlot(udg_Token[n], 'I00N')
set k = 5
elseif SubString(chatString, 0, 5) == "fall " then
set j = CheckStockItemSlot(udg_Token[n], 'I00O')
set k = -5
endif
if j != -1 then
set i = CheckStockId(chatString, 5, StringLength(chatString), 0, 2)
if i != -1 then
if udg_S_SharePrice[i] > 1 or k > 0 then
set udg_S_Swing[i] = udg_S_SharePrice[i] / k
call Item_AdjustStock(i)
endif
call Item_Charges(j, udg_Token[n])
if k > 0 then
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[n] + " use |cff7ebff1bull market|r card. |cff7ebff1" + udg_S_StockName[i] + "|r's stock price rises sharply!")
else
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[n] + " use |cff7ebff1bear market|r card. |cff7ebff1" + udg_S_StockName[i] + "|r's stock price falls furiously!")
endif
endif
endif
endif
endfunction
function BotsGamble takes integer j returns nothing
local integer i = udg_Turn[udg_Mover]
local integer k = GetRandomInt(0, 5)
local integer m
local string chatString = SubString(udg_S_Acronym[k], 0, 2)
local string chatString2
if j == 23 then
set chatString = "rise " + chatString
if udg_Status[i] == 4 then
set m = (GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD) - 1) / udg_S_SharePrice[k]
set chatString2 = "buy " + udg_S_Acronym[k] + I2S(m)
call Stock_Exchange(chatString2, i)
call PolledWait(0.1)
call Stock_Exchange(chatString, i)
call PolledWait(0.1)
set chatString2 = "sell " + udg_S_Acronym[k] + I2S(m)
call Stock_Exchange(chatString2, i)
endif
else
set chatString = "fall " + chatString
call Stock_Exchange(chatString, i)
endif
endfunction
function BotsUseItem takes unit whichUnit returns integer
local integer i = 0
local integer j
local integer k = 0
local integer m = 0
local integer n
local integer a = 0
local integer array count
local item whichItem
loop
exitwhen i > 5
if UnitItemInSlot(whichUnit, i) != null then
set count[a] = i
set a = a + 1
endif
set i = i + 1
endloop
if a > 0 then
set whichItem = UnitItemInSlot(whichUnit, count[GetRandomInt(0, a-1)])
set i = 0
loop
exitwhen i > 24
if GetItemTypeId(whichItem) == udg_CardItemType[i] then
set j = i
set i = 24
endif
set i = i + 1
endloop
if j < 6 then
set udg_TokenStatus[udg_Turn[udg_Mover]] = 0
call UnitUseItem(whichUnit, whichItem)
return 1
elseif j > 5 and j < 8 then
call UnitUseItem(whichUnit, whichItem)
elseif j == 8 then
if udg_TokenFree[udg_Turn[udg_Mover]] < 1 then
call UnitUseItem(whichUnit, whichItem)
endif
elseif j > 8 and j < 11 then
set i = 0
loop
exitwhen i == udg_Players
if i != udg_Mover then
set n = GetPlayerState(Player(udg_Turn[i]), PLAYER_STATE_RESOURCE_GOLD)
if n > m then
set m = n
set count[k] = i
set k = k + 1
endif
endif
set i = i + 1
endloop
if GetPlayerState(Player(udg_Turn[udg_Mover]), PLAYER_STATE_RESOURCE_GOLD) < m or j == 9 then
call UnitUseItemTarget(whichUnit, whichItem, udg_Token[udg_Turn[count[GetRandomInt(0, k-1)]]])
endif
elseif j > 10 and j < 15 then
set i = 0
loop
exitwhen i == udg_Players
if i != udg_Mover then
set count[k] = i
set k = k + 1
endif
set i = i + 1
endloop
call UnitUseItemTarget(whichUnit, whichItem, udg_Token[udg_Turn[count[GetRandomInt(0, k-1)]]])
elseif j > 14 and j < 17 then
set n = GetPlayerState(Player(udg_Turn[udg_Mover]), PLAYER_STATE_RESOURCE_FOOD_USED)
if n > 0 then
set m = 0
set i = 0
loop
exitwhen i > udg_FoodCap
if udg_BuildingOwner[i] == udg_Turn[udg_Mover] then
set count[m] = i
set m = m + 1
if m == n then
set i = udg_FoodCap
endif
endif
set i = i + 1
endloop
set k = GetRandomInt(0, m-1)
call UnitUseItemTarget(whichUnit, whichItem, udg_Building[count[k]])
endif
elseif j > 16 and j < 21 then
set n = udg_FoodCap + 1 - GetPlayerState(Player(8), PLAYER_STATE_RESOURCE_FOOD_USED) - GetPlayerState(Player(udg_Turn[udg_Mover]), PLAYER_STATE_RESOURCE_FOOD_USED)
if n > 0 then
set m = 0
set i = 0
loop
exitwhen i > udg_FoodCap
if udg_BuildingOwner[i] != 8 and udg_BuildingOwner[i] != udg_Turn[udg_Mover] then
set count[m] = i
set m = m + 1
if m == n then
set i = udg_FoodCap
endif
endif
set i = i + 1
endloop
set k = GetRandomInt(0, m-1)
call UnitUseItemTarget(whichUnit, whichItem, udg_Building[count[k]])
endif
elseif j > 20 and j < 23 then
set n = udg_FoodCap + 1 - GetPlayerState(Player(udg_Turn[udg_Mover]), PLAYER_STATE_RESOURCE_FOOD_USED)
if n > 0 then
set m = 0
set i = 0
loop
exitwhen i > udg_FoodCap
if udg_BuildingOwner[i] != udg_Turn[udg_Mover] then
set count[m] = i
set m = m + 1
if m == n then
set i = udg_FoodCap
endif
endif
set i = i + 1
endloop
set k = GetRandomInt(0, m-1)
call UnitUseItemTarget(whichUnit, whichItem, udg_Building[count[k]])
endif
else
call BotsGamble(j)
endif
endif
return 0
endfunction
function Auto takes integer i returns nothing
set udg_Status[i] = 4
call UnitResetCooldown(udg_Token[i])
call PolledWait(0.05)
call IssueImmediateOrder(udg_Token[i], "howlofterror")
call IssueImmediateOrder(udg_Token[i], "thunderclap")
call IssueImmediateOrder(udg_Token[i], "stomp")
endfunction
function Take_Turns takes nothing returns nothing
local integer i = udg_Turn[udg_Mover]
local integer j = 0
if udg_TokenFree[i] > 0 then
set udg_TokenFree[i] = udg_TokenFree[i] - 1
endif
loop
exitwhen j == 1
if udg_Mover == udg_Players - 1 then
set udg_Mover = 0
set udg_Round = udg_Round + 1
if ModuloInteger(udg_Round, 6) == 0 then
set i = 0
loop
exitwhen i > udg_FoodCap
set udg_BuildingRent[i] = udg_BuildingRent[i] * 7 / 5
set i = i + 1
endloop
endif
else
set udg_Mover = udg_Mover + 1
endif
if udg_Status[udg_Turn[udg_Mover]] == 0 then
set udg_Players = udg_Players - 1
call MultiboardMinimize(udg_Multiboard, false)
call DisableTrigger(gg_trg_Chat_String)
set i = 0
loop
exitwhen i == udg_Mover
call MultiboardSetItemWidthBJ(udg_Multiboard, i+4, 0, BoardWidth())
set i = i + 1
endloop
loop
exitwhen i == udg_Players
set udg_Turn[i] = udg_Turn[i+1]
set udg_S_Column[udg_Turn[i]] = i+4
call MultiboardSetItemValueBJ(udg_Multiboard, i+4, 1, udg_PlayerName[udg_Turn[i]])
set j = 0
loop
exitwhen j > 5
call MultiboardSetItemValueBJ(udg_Multiboard, i+4, j+2, I2S(udg_S_Amount[j*5+udg_Turn[i]]))
set j = j + 1
endloop
call MultiboardSetItemValueBJ(udg_Multiboard, i+4, j+2, ISignCS2(udg_S_Amount[30+udg_Turn[i]]))
call MultiboardSetItemWidthBJ(udg_Multiboard, i+4, 0, BoardWidth())
set i = i + 1
endloop
set j = 0
call MultiboardSetItemStyleBJ(udg_Multiboard, i+4, 0, false, false)
call PolledWait(0.01)
call MultiboardSetColumnCount(udg_Multiboard, i+3)
call EnableTrigger(gg_trg_Chat_String)
set udg_Mover = udg_Mover - 1
else
set i = udg_Turn[udg_Mover]
if udg_TokenSleep[i] == 0 then
set j = 1
else
set udg_TokenSleep[i] = udg_TokenSleep[i] - 1
call IssueTargetOrder(udg_DiceUnit, "sleep", udg_Token[i])
endif
endif
endloop
set j = 0
loop
exitwhen j == udg_Players
if udg_LockCamera[j] then
call SetCameraTargetControllerNoZForPlayer(Player(j), udg_Token[i], 0, 0, false)
endif
set j = j + 1
endloop
endfunction
function Stock_Swing takes integer j returns nothing
local integer i = 0
if udg_Round > j then
call DisableTrigger(gg_trg_Chat_String)
loop
exitwhen i > 5
if udg_S_Periods[i] == 0 then
if udg_S_SharePrice[i] == 10 and GetRandomInt(1, 5) == 1 then
set udg_S_Swing[i] = 1
else
set udg_S_Swing[i] = GetRandomInt(-udg_S_SharePrice[i]/10, udg_S_SharePrice[i]/10-1)
endif
if udg_S_Swing[i] < 1 then
set udg_S_Periods[i] = GetRandomInt(1, 3)
else
set udg_S_Periods[i] = GetRandomInt(1, 2)
endif
endif
call Item_AdjustStock(i)
set udg_S_Periods[i] = udg_S_Periods[i] - 1
set i = i + 1
endloop
call EnableTrigger(gg_trg_Chat_String)
endif
endfunction
function Building_Company takes nothing returns nothing
local integer i
local integer j = 0
local integer k
loop
exitwhen j == udg_Builds
set i = udg_BuildingSite[j]
set udg_BuildingSiteTime[i] = udg_BuildingSiteTime[i] - 1
if udg_BuildingSiteTime[i] <= 0 then
call ChangeElevatorHeight(udg_Field[i], 1)
call PingMinimapForForceEx(GetPlayersAll(), GetUnitX(udg_Building[i]), GetUnitY(udg_Building[i]), 5, 1, 0, 100, 0)
call RemoveUnit(udg_Building[i])
set udg_Building[i] = null
set udg_TempPoint = GetDestructableLoc(udg_Field[i])
call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Other\\Awaken\\Awaken.mdl", udg_TempPoint))
call PolledWait(0.5)
call RemoveDestructable(udg_Field[i])
set udg_Field[i] = null
call PolledWait(0.01)
set udg_Building[i] = CreateUnitAtLoc(Player(udg_BuildingOwner[i]), udg_BuildingUnitType[udg_BuildingType[i]], udg_TempPoint, 270)
call SetUnitUserData(udg_Building[i], i)
call RemoveLocation(udg_TempPoint)
set udg_TempPoint = null
set udg_BuildingLevel[i] = 1
set udg_BuildingSite[j] = udg_BuildingSite[udg_Builds-1]
set j = j - 1
set udg_Builds = udg_Builds - 1
endif
set j = j + 1
endloop
endfunction
function Next_Player takes nothing returns nothing
local integer i = udg_Turn[udg_Mover]
local integer j = 0
local integer k = 0
call TimerStart(udg_Timer, 40, false, null)
set udg_TimerWindow = CreateTimerDialogBJ(udg_Timer, "Timer")
call TimerDialogDisplay(udg_TimerWindow, false)
call TimerDialogDisplayForPlayerBJ(true, udg_TimerWindow, Player(i))
set udg_Attention = AddSpecialEffectTarget("Abilities\\Spells\\Other\\TalkToMe\\TalkToMe.mdl", udg_Token[i], "overhead")
call SetPlayerAbilityAvailable(Player(i), 'A001', false)
call SetPlayerAbilityAvailable(Player(i), 'A000', true)
if udg_SnapToken[i] == 1 then
set udg_SnapToken[i] = 0
call SetPlayerAbilityAvailableCS3(i)
call SetPlayerAbilityAvailable(Player(i), 'A000', false)
call SetPlayerAbilityAvailable(Player(i), 'A001', true)
call IssueTargetOrder(udg_DiceUnit, "entanglingroots", udg_Token[i])
call PolledWait(0.5)
call Camping(i, udg_Portal[udg_Move[i]])
elseif udg_Status[i] > 1 then
if udg_Status[i] == 3 then
set j = GetRandomInt(1, 5)
elseif udg_Status[i] == 4 then
set j = GetRandomInt(1, 3)
endif
if j == 1 then
set k = BotsUseItem(udg_Token[i])
endif
if k == 0 then
call UnitResetCooldown(udg_Token[i])
call PolledWait(0.05)
call IssueImmediateOrder(udg_Token[i], "howlofterror")
endif
else
set udg_TokenStatus[i] = 0
endif
endfunction
Name | Type | is_array | initial_value |
Attention | effect | No | |
Bonus | integer | Yes | |
Building | unit | Yes | |
BuildingLevel | integer | Yes | |
BuildingOwner | integer | Yes | |
BuildingRent | integer | Yes | |
BuildingSite | integer | Yes | |
BuildingSiteTime | integer | Yes | |
BuildingSleep | integer | Yes | |
BuildingType | integer | Yes | |
BuildingTypeName | string | Yes | |
BuildingUnitType | unitcode | Yes | |
BuildingUpgrade | integer | Yes | |
BuildingValue | integer | Yes | |
Builds | integer | No | |
CardItemType | itemcode | Yes | |
Circle | unit | Yes | |
Dice | integer | No | |
DiceUnit | unit | No | |
Event | string | Yes | |
Field | destructable | Yes | |
FoodCap | integer | No | |
Frame | integer | No | |
Leaderboard | leaderboard | Yes | |
Length | real | No | |
LockCamera | boolean | Yes | |
Move | integer | Yes | |
Mover | integer | No | |
Multiboard | multiboard | No | |
OldPlaceId | integer | No | |
PlayerName | string | Yes | |
Players | integer | No | |
Portal | integer | Yes | |
Round | integer | No | |
S_Acronym | string | Yes | |
S_Amount | integer | Yes | |
S_Column | integer | Yes | |
S_Periods | integer | Yes | |
S_SharePrice | integer | Yes | |
S_StockName | string | Yes | |
S_Swing | integer | Yes | |
Signpost | real | Yes | |
SnapToken | integer | Yes | |
Soldier | unit | Yes | |
SoldierUnitType | unitcode | Yes | |
Status | integer | Yes | |
TempPoint | location | No | |
TempPoint2 | location | No | |
Timer | timer | No | |
TimerWindow | timerdialog | No | |
Token | unit | Yes | |
TokenFree | integer | Yes | |
TokenSleep | integer | Yes | |
TokenStatus | integer | Yes | |
TokenUnitType | unitcode | Yes | |
TotalAssets | integer | Yes | |
Turn | integer | Yes | |
Users | integer | No | |
Warning | integer | Yes | |
WayPoints | integer | No | |
X | real | No | |
Y | real | No | |
Z | real | No |
function Trig_Init_Map_Actions takes nothing returns nothing
local integer i = 0
call DestroyTrigger(gg_trg_Init_Map)
call SetAllyColorFilterState(0)
call SuspendTimeOfDay(true)
call SetFloatGameState(GAME_STATE_TIME_OF_DAY, 12)
call SetTerrainFogEx(0, 1400.00, 5000.00, 0, 0.10, 0.30, 0.50)
call SetPlayerOnScoreScreen(Player(8), false)
call SetMapFlag(MAP_LOCK_RESOURCE_TRADING, true)
loop
exitwhen i > 4
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call SetPlayerAllianceStateBJ(Player(i), Player(6), 6)
call SetPlayerAllianceStateBJ(Player(6), Player(i), 7)
call SetPlayerAllianceStateBJ(Player(i), Player(8), 6)
call SetPlayerAllianceStateBJ(Player(8), Player(i), 7)
call SetPlayerAllianceStateBJ(Player(i), Player(10), 6)
call SetPlayerAllianceStateBJ(Player(10), Player(i), 7)
set udg_Turn[udg_Players] = i
set udg_Players = udg_Players + 1
if GetPlayerController(Player(i)) == MAP_CONTROL_USER then
set udg_Status[i] = 1
set udg_Users = udg_Users + 1
elseif GetAIDifficulty(Player(i)) == AI_DIFFICULTY_NEWBIE then
set udg_Status[i] = 2
elseif GetAIDifficulty(Player(i)) == AI_DIFFICULTY_NORMAL then
set udg_Status[i] = 3
elseif GetAIDifficulty(Player(i)) == AI_DIFFICULTY_INSANE then
set udg_Status[i] = 4
endif
endif
set i = i + 1
endloop
call CinematicFadeBJ(1, 0, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 0, 0, 0, 0)
if udg_Players > 1 then
call TriggerExecute(gg_trg_Init_Stage)
call TriggerExecute(gg_trg_Init_Token)
call TriggerExecute(gg_trg_Beginning)
else
call DisplayTimedTextToForce(bj_FORCE_PLAYER[udg_Turn[udg_Players-1]], 30, "There should be 2 players at least!")
endif
endfunction
function InitTrig_Init_Map takes nothing returns nothing
set gg_trg_Init_Map = CreateTrigger()
call TriggerAddAction(gg_trg_Init_Map, function Trig_Init_Map_Actions)
endfunction
function LoadStage takes string source, string arrow, integer loan, integer k returns nothing
local integer i = 0
local integer j = 0
loop
exitwhen i > udg_WayPoints
set udg_Portal[i] = S2I(SubString(source, j, j+k))
set udg_Signpost[i] = S2R(SubString(arrow, i, i+1)) * 90
set j = j + k
set i = i + 1
endloop
set i = 0
loop
exitwhen i == udg_Players
set udg_TotalAssets[udg_Turn[i]] = loan
set i = i + 1
endloop
endfunction
function SetStage takes integer i, real j returns nothing
if i < 0 then
elseif udg_Signpost[i] == 0 then
set udg_X = udg_X + j
elseif udg_Signpost[i] == 90 then
set udg_Y = udg_Y + j
elseif udg_Signpost[i] == 180 then
set udg_X = udg_X - j
else
set udg_Y = udg_Y - j
endif
endfunction
function SetStage2 takes integer i returns nothing
local integer j = udg_Portal[i]
local location loc = Location(udg_X, udg_Y)
set udg_Circle[i] = CreateUnitAtLoc(Player(6), 'n000', loc, 270)
call RemoveLocation(loc)
set loc = null
if j <= udg_FoodCap then
call SetUnitColor(udg_Circle[i], PLAYER_COLOR_GREEN)
elseif j == udg_FoodCap+1 then
call SetUnitColor(udg_Circle[i], PLAYER_COLOR_ORANGE)
elseif j == udg_FoodCap+2 then
call SetUnitColor(udg_Circle[i], PLAYER_COLOR_LIGHT_BLUE)
else
call SetUnitColor(udg_Circle[i], PLAYER_COLOR_PINK)
endif
endfunction
function Trig_Init_Stage_Actions takes nothing returns nothing
local integer i
local integer j
local integer k
local integer m
local integer n
local integer a = 0
local integer z
local integer array count
local location array loc
call DestroyTrigger(gg_trg_Init_Stage)
if udg_Players == 5 then
set j = GetRandomInt(4, 6)
else
set j = udg_Players - 1
endif
if j == 1 then
set udg_FoodCap = 3
set udg_WayPoints = 7
set k = GetRandomInt(1, 6)
if k == 1 then
call LoadStage("40514253", "00332211", 16000, 1)
elseif k == 2 then
call LoadStage("50415243", "00332211", 16000, 1)
elseif k == 3 then
call LoadStage("40524153", "03301221", 16000, 1)
elseif k == 4 then
call LoadStage("50425143", "03301221", 16000, 1)
elseif k == 5 then
call LoadStage("43514052", "10012332", 16000, 1)
else
call LoadStage("53415042", "10012332", 16000, 1)
endif
set loc[0] = Location(0, 832)
set loc[1] = Location(832, 0)
set loc[2] = Location(0, -832)
set loc[3] = Location(-832, 0)
set udg_X = -384
if k < 5 then
set udg_Y = 384
else
set udg_Y = -384
endif
set i = 0
loop
exitwhen i > 7
call SetStage(i-1, 384)
if i == 6 and k > 2 then
set udg_Circle[6] = udg_Circle[2]
else
call SetStage2(i)
endif
set i = i + 1
endloop
elseif j == 2 then
set udg_FoodCap = 5
set udg_WayPoints = 11
if GetRandomInt(1, 2) == 1 then
call LoadStage("061726374657", "003033221211", 20000, 1)
else
call LoadStage("071627364756", "003033221211", 20000, 1)
endif
set loc[0] = Location(-1024, 576)
set loc[1] = Location(192, 1024)
set loc[2] = Location(1024, 192)
set loc[3] = Location(1024, -576)
set loc[4] = Location(-192, -1024)
set loc[5] = Location(-1024, -192)
set udg_X = -576
set udg_Y = 576
set i = 0
loop
exitwhen i > 11
call SetStage(i-1, 384)
call SetStage2(i)
set i = i + 1
endloop
elseif j == 3 then
set udg_FoodCap = 7
set udg_WayPoints = 15
set k = GetRandomInt(1, 6)
if k == 1 then
call LoadStage("0819283948596879", "0003333222211110", 25000, 1)
elseif k == 2 then
call LoadStage("0918293849586978", "0003333222211110", 25000, 1)
elseif k == 3 then
call LoadStage("0819283948596879", "0030332322121101", 25000, 1)
elseif k == 4 then
call LoadStage("0918293849586978", "0030332322121101", 25000, 1)
else
set udg_WayPoints = 23
if k == 5 then
call LoadStage("087989281989483989685989", "230000123333012222301111", 25000, 1)
else
call LoadStage("097898291898493898695898", "230000123333012222301111", 25000, 1)
endif
endif
set loc[0] = Location(-448, 1344)
set loc[1] = Location(448, 1344)
set loc[2] = Location(1344, 448)
set loc[3] = Location(1344, -448)
set loc[4] = Location(448, -1344)
set loc[5] = Location(-448, -1344)
set loc[6] = Location(-1344, -448)
set loc[7] = Location(-1344, 448)
set udg_X = -448
set udg_Y = 896
set i = 0
loop
exitwhen i > udg_WayPoints
call SetStage(i-1, 448)
if GetBooleanAnd(k > 4, i == 9 or i == 15 or i == 21 or i == 23) then
if i == 23 then
set udg_Circle[23] = udg_Circle[3]
else
set udg_Circle[i] = udg_Circle[i-4]
endif
else
call SetStage2(i)
endif
set i = i + 1
endloop
elseif j == 4 then
set udg_FoodCap = 13
set udg_WayPoints = 26
call LoadStage("150014011614021503140415050614071408151409101115121413", "000110000333332223322221111", 30000, 2)
set loc[0] = Location(-960, 1024)
set loc[1] = Location(256, 576)
set loc[2] = Location(192, 1792)
set loc[3] = Location(960, 1792)
set loc[4] = Location(1792, 960)
set loc[5] = Location(896, 192)
set loc[6] = Location(1792, -192)
set loc[7] = Location(960, -1024)
set loc[8] = Location(192, -128)
set loc[9] = Location(-192, -1792)
set loc[10] = Location(-576, -896)
set loc[11] = Location(-960, -1792)
set loc[12] = Location(-1792, -896)
set loc[13] = Location(-1792, 128)
set udg_X = -1344
set udg_Y = 576
set i = 0
loop
exitwhen i > 26
if i < 24 then
call SetStage(i-1, 384)
else
call SetStage(i-1, 480)
endif
call SetStage2(i)
set i = i + 1
endloop
elseif j == 5 then
set udg_FoodCap = 14
set udg_WayPoints = 27
call LoadStage("16000115021603041505171506160715081615091011161215131514", "0011000330033322332221122111", 30000, 2)
set loc[0] = Location(-1024, 1024)
set loc[1] = Location(-576, 128)
set loc[2] = Location(-576, 1792)
set loc[3] = Location(192, 1792)
set loc[4] = Location(1024, 1344)
set loc[5] = Location(128, 576)
set loc[6] = Location(1792, 192)
set loc[7] = Location(1792, -576)
set loc[8] = Location(576, -128)
set loc[9] = Location(256, -1792)
set loc[10] = Location(-256, -1792)
set loc[11] = Location(-1024, -1344)
set loc[12] = Location(-128, -576)
set loc[13] = Location(-1792, -576)
set loc[14] = Location(-1792, 192)
set udg_X = -1344
set udg_Y = 576
set i = 0
loop
exitwhen i > 27
call SetStage(i-1, 384)
call SetStage2(i)
set i = i + 1
endloop
else
set udg_FoodCap = 15
set udg_WayPoints = 39
call LoadStage("00180116170217160318041705161706171607180817091617101716111712181316171417161517", "3300000011223333330011222222330011111122", 35000, 2)
set loc[0] = Location(-1344, 1792)
set loc[1] = Location(-1792, 448)
set loc[2] = Location(0, 896)
set loc[3] = Location(1792, 448)
set loc[4] = Location(1344, 1792)
set loc[5] = Location(448, 1792)
set loc[6] = Location(896, 0)
set loc[7] = Location(448, -1792)
set loc[8] = Location(1344, -1792)
set loc[9] = Location(1792, -448)
set loc[10] = Location(0, -896)
set loc[11] = Location(-1792, -448)
set loc[12] = Location(-1344, -1792)
set loc[13] = Location(-448, -1792)
set loc[14] = Location(-896, 0)
set loc[15] = Location(-512, 1792)
set udg_X = -1344
set udg_Y = 1344
set i = 0
loop
exitwhen i > 39
call SetStage(i-1, 448)
if i == 14 or i == 24 or i == 34 or i == 36 then
if i == 36 then
set udg_Circle[36] = udg_Circle[4]
else
set udg_Circle[i] = udg_Circle[i-8]
endif
else
call SetStage2(i)
endif
set i = i + 1
endloop
endif
set udg_BuildingUpgrade[0] = 2000
set udg_BuildingUpgrade[1] = 3500
set udg_BuildingUpgrade[2] = 1500
set udg_BuildingUpgrade[3] = 2000
set udg_BuildingUpgrade[4] = 1000
set udg_BuildingUpgrade[5] = 1500
set udg_BuildingUpgrade[6] = 500
set udg_BuildingUpgrade[7] = 800
set udg_BuildingUnitType[0] = 'h000'
set udg_BuildingUnitType[1] = 'h001'
set udg_BuildingUnitType[2] = 'h002'
set udg_BuildingUnitType[3] = 'h003'
set udg_BuildingUnitType[4] = 'n000'
set udg_BuildingUnitType[5] = 'n001'
set udg_BuildingUnitType[6] = 'n002'
set udg_BuildingTypeName[0] = "Black Citadel"
set udg_BuildingTypeName[1] = "Human Castle"
set udg_BuildingTypeName[2] = "Orc Fortress"
set udg_BuildingTypeName[3] = "Temple of Tides"
set i = 0
loop
exitwhen i > udg_FoodCap
set udg_BuildingLevel[i] = 1
set count[i] = i
set i = i + 1
endloop
if j < 4 then
set m = GetRandomInt(j-1, j)
else
set m = GetRandomInt(3, 5)
endif
set i = 1
loop
exitwhen i > m
set j = GetRandomInt(0, udg_FoodCap)
if udg_BuildingLevel[j] != 0 then
set udg_BuildingLevel[j] = 0
set i = i + 1
endif
endloop
set z = udg_FoodCap
set j = 0
loop
exitwhen j > 3
if udg_Players == 2 then
set m = 1
elseif udg_Players < 5 and j < 3 then
set m = GetRandomInt(1, 2)
if j == 2 and z == 1 then
set m = 1
endif
elseif j < 2 then
set m = GetRandomInt(3, 5)
elseif j == 3 then
set m = udg_FoodCap - a + 1
else
if udg_FoodCap - a + 1 < 6 then
set m = GetRandomInt(1, udg_FoodCap-a)
else
set m = GetRandomInt(2, 5)
endif
endif
set a = a + m
set n = 1
loop
exitwhen n > m
set k = GetRandomInt(0, z)
set i = count[k]
if udg_BuildingLevel[i] == 0 then
set udg_Field[i] = CreateDestructable('DTrx', GetLocationX(loc[i]), GetLocationY(loc[i]), 270, 1, 0)
call ChangeElevatorHeight(udg_Field[i], 2)
set udg_Building[i] = CreateUnitAtLoc(Player(8), 'n003', loc[i], 270)
else
set udg_Building[i] = CreateUnitAtLoc(Player(8), udg_BuildingUnitType[j], loc[i], 270)
endif
call RemoveLocation(loc[i])
set loc[i] = null
call SetUnitUserData(udg_Building[i], i)
set udg_BuildingType[i] = j
set udg_BuildingValue[i] = (8 - j * 2) * 1000
set udg_BuildingRent[i] = udg_BuildingValue[i] / 10
set udg_BuildingOwner[i] = 8
set count[k] = count[z]
set z = z - 1
set n = n + 1
endloop
set j = j + 1
endloop
endfunction
function InitTrig_Init_Stage takes nothing returns nothing
set gg_trg_Init_Stage = CreateTrigger()
call TriggerAddAction(gg_trg_Init_Stage, function Trig_Init_Stage_Actions)
endfunction
function Army takes integer i, integer j, integer whichType returns nothing
local location unitLoc = GetUnitLoc(udg_Token[i])
set udg_Soldier[j] = CreateUnitAtLoc(Player(10), whichType, unitLoc, 270)
call SetUnitColor(udg_Soldier[j], GetPlayerColor(Player(i)))
call ShowUnit(udg_Soldier[j], false)
call RemoveLocation(unitLoc)
set unitLoc = null
endfunction
function Trig_Init_Token_Actions takes nothing returns nothing
local integer i
local integer j
local integer k
local integer m
local integer n
local integer z
local integer array bit
local integer array count
local location loc
call DestroyTrigger(gg_trg_Init_Token)
set udg_TokenUnitType[0] = 'H00N'
set udg_TokenUnitType[1] = 'H00G'
set udg_TokenUnitType[2] = 'H008'
set udg_TokenUnitType[3] = 'H00K'
set udg_TokenUnitType[4] = 'H00L'
set udg_TokenUnitType[5] = 'H00A'
set udg_TokenUnitType[6] = 'H00B'
set udg_TokenUnitType[7] = 'H007'
set udg_TokenUnitType[8] = 'H00D'
set udg_TokenUnitType[9] = 'H006'
set udg_TokenUnitType[10] = 'H00M'
set udg_TokenUnitType[11] = 'H00P'
set udg_TokenUnitType[12] = 'H00F'
set udg_TokenUnitType[13] = 'H009'
set udg_TokenUnitType[14] = 'H005'
set udg_TokenUnitType[15] = 'H00I'
set udg_TokenUnitType[16] = 'H00E'
set udg_TokenUnitType[17] = 'H00Q'
set udg_TokenUnitType[18] = 'H004'
set udg_TokenUnitType[19] = 'H00J'
set udg_TokenUnitType[20] = 'H00H'
set udg_TokenUnitType[21] = 'H00O'
set udg_TokenUnitType[22] = 'H00C'
set udg_TokenUnitType[23] = 'H00R'
set udg_SoldierUnitType[0] = 'n00S'
set udg_SoldierUnitType[1] = 'n00Q'
set udg_SoldierUnitType[2] = 'n016'
set udg_SoldierUnitType[3] = 'n00Z'
set udg_SoldierUnitType[4] = 'n011'
set udg_SoldierUnitType[5] = 'n014'
set udg_SoldierUnitType[6] = 'n00P'
set udg_SoldierUnitType[7] = 'n00X'
set udg_SoldierUnitType[8] = 'n00O'
set udg_SoldierUnitType[10] = 'n013'
set udg_SoldierUnitType[11] = 'n006'
set udg_SoldierUnitType[12] = 'n00R'
set udg_SoldierUnitType[13] = 'n00T'
set udg_SoldierUnitType[14] = 'n00W'
set udg_SoldierUnitType[15] = 'n00U'
set udg_SoldierUnitType[16] = 'n00Y'
set udg_SoldierUnitType[17] = 'n007'
set udg_SoldierUnitType[18] = 'n00V'
set udg_SoldierUnitType[19] = 'n010'
set udg_SoldierUnitType[20] = 'n012'
set udg_SoldierUnitType[21] = 'n005'
set udg_SoldierUnitType[22] = 'n015'
set udg_SoldierUnitType[23] = 'n008'
set udg_CardItemType[0] = 'I001'
set udg_CardItemType[1] = 'I006'
set udg_CardItemType[2] = 'I007'
set udg_CardItemType[3] = 'I004'
set udg_CardItemType[4] = 'I005'
set udg_CardItemType[5] = 'I008'
set udg_CardItemType[6] = 'I003'
set udg_CardItemType[7] = 'I002'
set udg_CardItemType[8] = 'I000'
set udg_CardItemType[9] = 'I00D'
set udg_CardItemType[10] = 'I009'
set udg_CardItemType[11] = 'I00A'
set udg_CardItemType[12] = 'I00B'
set udg_CardItemType[13] = 'I00C'
set udg_CardItemType[14] = 'I00E'
set udg_CardItemType[15] = 'I00M'
set udg_CardItemType[16] = 'I00L'
set udg_CardItemType[17] = 'I00K'
set udg_CardItemType[18] = 'I00F'
set udg_CardItemType[19] = 'I00G'
set udg_CardItemType[20] = 'I00H'
set udg_CardItemType[21] = 'I00I'
set udg_CardItemType[22] = 'I00J'
set udg_CardItemType[23] = 'I00N'
set udg_CardItemType[24] = 'I00O'
set udg_PlayerName[0] = "|cffff0303" + GetPlayerName(Player(0)) + "|r"
set udg_PlayerName[1] = "|cff0042ff" + GetPlayerName(Player(1)) + "|r"
set udg_PlayerName[2] = "|cff1ce6b9" + GetPlayerName(Player(2)) + "|r"
set udg_PlayerName[3] = "|cff540081" + GetPlayerName(Player(3)) + "|r"
set udg_PlayerName[4] = "|cfffffc00" + GetPlayerName(Player(4)) + "|r"
set udg_PlayerName[8] = "|cff959697" + GetPlayerName(Player(8)) + "|r"
set udg_Bonus[0] = 100
set udg_Bonus[1] = -1000
set udg_Bonus[2] = -200
set udg_Bonus[3] = 500
set udg_Bonus[4] = -200
set udg_Bonus[5] = 800
set udg_Bonus[6] = 200
set udg_Bonus[7] = -300
set udg_Bonus[8] = -800
set udg_Bonus[9] = -400
set udg_Bonus[10] = 500
set udg_Bonus[11] = -200
set udg_Bonus[12] = 500
set udg_Bonus[13] = -100
set udg_Bonus[14] = -500
set udg_Bonus[15] = 500
set udg_Bonus[16] = 1
set udg_Bonus[17] = 2
set udg_Event[0] = " plays card to win. Earn |cffffcc00100|r gold coins."
set udg_Event[1] = " attempts to conquer the neighbouring country, but failed finally. Spend |cffa0ff001,000|r gold coins."
set udg_Event[2] = " trains the army. Costs |cffa0ff00200|r gold coins."
set udg_Event[3] = " receives the tribute. Earn |cffffcc00500|r gold coins."
set udg_Event[4] = " bribes spies. Costs |cffa0ff00200|r gold coins."
set udg_Event[5] = " makes common people live and work in peace and contentment. Receive |cffffcc00800|r gold coins of the repayment."
set udg_Event[6] = " reduces the staff. Obtain |cffffcc00200|r gold coins."
set udg_Event[7] = " issues the soldier's pay and provisions to the soldiers. Costs |cffa0ff00300|r gold coins."
set udg_Event[8] = " bets with the bishop that has failed. Losses are |cffa0ff00800|r gold coins."
set udg_Event[9] = " buys the luxury goods. Costs |cffa0ff00400|r gold coins."
set udg_Event[10] = " helps to resist enemies in the neighbouring country. Receive |cffffcc00500|r gold coins of the repayment."
set udg_Event[11] = " is injured while hunting dragons. It costs |cffa0ff00200|r gold coins wounded to treat."
set udg_Event[12] = " punishes the corrupt official. Back to |cffffcc00500|r gold coins."
set udg_Event[13] = " awards subordinate. Costs |cffa0ff00100|r gold coins."
set udg_Event[14] = " fits up the luxurious house. Costs |cffa0ff00500|r gold coins."
set udg_Event[15] = " adopts the new production technology. Earn |cffffcc00500|r gold coins."
set udg_Event[16] = " is uncomfortable. |cffa0ff001|r rounds stop."
set udg_Event[17] = " holds the banquet. |cffa0ff002|r rounds stop."
set udg_S_Acronym[0] = "UL "
set udg_S_Acronym[1] = "AE "
set udg_S_Acronym[2] = "MW "
set udg_S_Acronym[3] = "PF "
set udg_S_Acronym[4] = "GA "
set udg_S_Acronym[5] = "NS "
set udg_S_StockName[0] = "Undead Life Insurance"
set udg_S_StockName[1] = "Archmage Express"
set udg_S_StockName[2] = "Moon Well bio-tech"
set udg_S_StockName[3] = "Pandaren Fast-food chains"
set udg_S_StockName[4] = "Goblin Academy"
set udg_S_StockName[5] = "Naga Seafood international"
set i = 0
loop
exitwhen i > 3
set bit[i] = 5
set i = i + 1
endloop
set i = 0
loop
exitwhen i > 23
set count[i] = i
set i = i + 1
endloop
set m = 0
loop
exitwhen m == udg_Players
set i = udg_Turn[m]
set j = 0
loop
exitwhen j > 1
set udg_Move[i] = GetRandomInt(0, udg_WayPoints)
set k = 0
loop
exitwhen k > m - 1
set n = udg_Move[udg_Turn[k]]
if udg_Move[i] == n or udg_Circle[udg_Move[i]] == udg_Circle[n] then
set k = m
set j = 0
else
set j = 1
endif
set k = k + 1
endloop
set j = j + 1
endloop
if GetPlayerRace(Player(i)) == RACE_HUMAN then
set j = 0
elseif GetPlayerRace(Player(i)) == RACE_ORC then
set j = 6
elseif GetPlayerRace(Player(i)) == RACE_UNDEAD then
set j = 12
else
set j = 18
endif
set k = GetRandomInt(j, j + bit[j/6])
set loc = GetUnitLoc(udg_Circle[udg_Move[i]])
call PanCameraToTimedLocForPlayer(Player(i), loc, 0)
set udg_Token[i] = CreateUnitAtLoc(Player(i), udg_TokenUnitType[count[k]], loc, udg_Signpost[udg_Move[i]])
call RemoveLocation(loc)
set loc = null
call UnitAddItemByIdSwapped(udg_CardItemType[GetRandomInt(0, 24)], udg_Token[i])
call SetItemUserData(GetLastCreatedItem(), 1)
call SetUnitUserData(udg_Token[i], i)
call SuspendHeroXP(udg_Token[i], true)
set udg_TokenStatus[i] = 2
set udg_S_Column[i] = m + 4
set n = i * 6
set z = 0
if count[k] == 9 then
loop
exitwhen z > 1
call Army(i, n, 'n018')
set n = n + 1
call Army(i, n, 'n019')
set n = n + 1
call Army(i, n, 'n017')
set n = n + 1
set z = z + 1
endloop
else
loop
exitwhen z > 5
call Army(i, n, udg_SoldierUnitType[count[k]])
set n = n + 1
set z = z + 1
endloop
endif
call SetPlayerAbilityAvailable(Player(i), 'A000', false)
call SetPlayerAbilityAvailable(Player(i), 'A003', false)
call SetPlayerAbilityAvailable(Player(i), 'A002', false)
call SetPlayerAbilityAvailable(Player(i), 'A00F', false)
call SetPlayerAbilityAvailable(Player(i), 'A008', false)
call SetPlayerState(Player(i), PLAYER_STATE_RESOURCE_FOOD_CAP, udg_FoodCap+1)
call AdjustPlayerStateBJ(udg_TotalAssets[i], Player(i), PLAYER_STATE_RESOURCE_GOLD)
call TriggerRegisterPlayerUnitEvent(gg_trg_Roll_Dice, Player(i), EVENT_PLAYER_UNIT_ISSUED_ORDER, null)
call TriggerRegisterPlayerUnitEvent(gg_trg_Move_Limit, Player(i), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null)
call TriggerRegisterPlayerUnitEvent(gg_trg_Target_Order, Player(i), EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, null)
call TriggerRegisterPlayerUnitEvent(gg_trg_Drop_Item, Player(i), EVENT_PLAYER_UNIT_DROP_ITEM, null)
call TriggerRegisterPlayerChatEvent(gg_trg_Chat_String, Player(i), "", false)
call TriggerRegisterPlayerEventLeave(gg_trg_Player_Left, Player(i))
set n = j / 6
set count[k] = count[j+bit[n]]
set bit[n] = bit[n] - 1
set m = m + 1
endloop
call SetPlayerState(Player(8), PLAYER_STATE_RESOURCE_FOOD_CAP, udg_FoodCap+1)
if udg_Users == 1 then
set udg_Frame = 32
call TriggerRegisterTimerEvent(gg_trg_Leap_Frog, 0.01, true)
else
set udg_Frame = 16
call TriggerRegisterTimerEvent(gg_trg_Leap_Frog, 0.02, true)
endif
set loc = GetUnitLoc(udg_Token[udg_Turn[udg_Mover]])
set udg_DiceUnit = CreateUnitAtLoc(Player(10), 'n01A', loc, 270)
call ShowUnit(udg_DiceUnit, false)
call RemoveLocation(loc)
set loc = null
endfunction
function InitTrig_Init_Token takes nothing returns nothing
set gg_trg_Init_Token = CreateTrigger()
call TriggerAddAction(gg_trg_Init_Token, function Trig_Init_Token_Actions)
endfunction
function Trig_Beginning_Actions takes nothing returns nothing
local integer i = 2
local integer j = 0
call DestroyTrigger(gg_trg_Beginning)
call CinematicModeExBJ(true, GetPlayersAll(), 0)
call PolledWait(0.5)
call CinematicFadeBJ(0, 2, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 0, 0, 0, 0)
call PolledWait(1.2)
call CinematicModeExBJ(false, GetPlayersAll(), 0.5)
set udg_Multiboard = CreateMultiboardBJ(udg_Players+3, 8, "Share-List")
call MultiboardMinimize(udg_Multiboard, true)
call MultiboardSetItemWidthBJ(udg_Multiboard, 0, 0, BoardWidth())
call MultiboardSetItemWidthBJ(udg_Multiboard, 1, 0, 3)
call MultiboardSetItemWidthBJ(udg_Multiboard, 2, 0, 2.5)
call MultiboardSetItemWidthBJ(udg_Multiboard, 3, 0, 3)
call MultiboardSetItemStyleBJ(udg_Multiboard, 0, 0, true, false)
loop
exitwhen i > 7
call MultiboardSetItemValueBJ(udg_Multiboard, 1, i, SubString(udg_S_Acronym[i-2], 0, 2))
set udg_S_SharePrice[i-2] = GetRandomInt(50, 95)
set udg_S_Periods[i-2] = 1
call MultiboardSetItemValueBJ(udg_Multiboard, 2, i, I2S(udg_S_SharePrice[i-2]))
call MultiboardSetItemValueBJ(udg_Multiboard, 3, i, "0")
call MultiboardSetItemColorBJ(udg_Multiboard, 0, i, 0, 100, 0, 0)
set i = i + 1
endloop
call MultiboardSetItemColorBJ(udg_Multiboard, 1, 0, 100, 80, 20, 0)
loop
exitwhen j == udg_Players
set i = udg_Turn[j]
call MultiboardSetItemValueBJ(udg_Multiboard, j+4, 0, "0")
call MultiboardSetItemValueBJ(udg_Multiboard, j+4, 1, udg_PlayerName[i])
call SelectUnitForPlayerSingle(udg_Token[i], Player(i))
call SetUnitFlyHeight(udg_Token[i], 0, 0)
set udg_Leaderboard[i] = CreateLeaderboardBJ(GetForceOfPlayer(Player(i)), "blank")
call LeaderboardAddItemBJ(Player(0), udg_Leaderboard[i], "Value", 0)
call LeaderboardAddItemBJ(Player(1), udg_Leaderboard[i], "Rent", 0)
call LeaderboardAddItemBJ(Player(2), udg_Leaderboard[i], "Level", 0)
call LeaderboardAddItemBJ(Player(3), udg_Leaderboard[i], "Owner", 0)
call LeaderboardSetItemLabelColor(udg_Leaderboard[i], LeaderboardGetPlayerIndex(udg_Leaderboard[i], Player(1)), 255, 252, 0, 255)
call LeaderboardSetItemValueColor(udg_Leaderboard[i], LeaderboardGetPlayerIndex(udg_Leaderboard[i], Player(1)), 255, 252, 0, 255)
call LeaderboardSetItemLabelColor(udg_Leaderboard[i], LeaderboardGetPlayerIndex(udg_Leaderboard[i], Player(2)), 254, 138, 14, 255)
call LeaderboardSetItemValueColor(udg_Leaderboard[i], LeaderboardGetPlayerIndex(udg_Leaderboard[i], Player(2)), 254, 138, 14, 255)
call LeaderboardSetItemLabelColor(udg_Leaderboard[i], LeaderboardGetPlayerIndex(udg_Leaderboard[i], Player(3)), 32, 192, 0, 255)
call LeaderboardSetItemStyle(udg_Leaderboard[i], LeaderboardGetPlayerIndex(udg_Leaderboard[i], Player(3)), true, false, false)
call LeaderboardDisplay(udg_Leaderboard[i], false)
set j = j + 1
endloop
call PolledWait(0.5)
call MultiboardMinimize(udg_Multiboard, false)
set udg_Mover = udg_Players - 1
call TriggerExecute(gg_trg_Carry_On)
endfunction
function InitTrig_Beginning takes nothing returns nothing
set gg_trg_Beginning = CreateTrigger()
call TriggerAddAction(gg_trg_Beginning, function Trig_Beginning_Actions)
endfunction
function Trig_Player_Left_Actions takes nothing returns nothing
local integer i = GetPlayerId(GetTriggerPlayer())
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[i] + " has left the game")
if udg_Status[i] != 0 then
call Auto(i)
endif
endfunction
function InitTrig_Player_Left takes nothing returns nothing
set gg_trg_Player_Left = CreateTrigger()
call TriggerAddAction(gg_trg_Player_Left, function Trig_Player_Left_Actions)
endfunction
function Trig_Roll_Dice_Actions takes nothing returns nothing
local integer orderId = GetIssuedOrderId()
local integer i = udg_Turn[udg_Mover]
local integer j = udg_Portal[udg_Move[i]]
local integer k = 0
if orderId == OrderId("howlofterror") then
set udg_Dice = GetRandomInt(1, 6)
call Rolling(i)
elseif orderId == OrderId("thunderclap") then
call SetPlayerAbilityAvailable(Player(i), 'A002', false)
call PingMinimapForForceEx(GetPlayersAll(), GetUnitX(udg_Building[j]), GetUnitY(udg_Building[j]), 5, 0, 100, 50, 0)
set udg_BuildingOwner[j] = i
if udg_BuildingLevel[j] > 0 then
set k = udg_BuildingValue[j]
else
set k = udg_BuildingValue[j] * 9 / 10
endif
call AdjustPlayerStateCS(-k, i, PLAYER_STATE_RESOURCE_GOLD)
call AdjustPlayerStateCS(udg_BuildingValue[j], i, PLAYER_STATE_RESOURCE_LUMBER)
call LeaderboardSetItemLabel(udg_Leaderboard[i], LeaderboardGetPlayerIndex(udg_Leaderboard[i], Player(3)), "Owner " + udg_PlayerName[i])
call SetUnitOwner(udg_Building[j], Player(i), true)
call AddIndicator(udg_Building[j], 255, 255, 255, 255)
if udg_BuildingLevel[j] == 0 and udg_BuildingSiteTime[j] == 0 then
set udg_BuildingSite[udg_Builds] = j
set udg_BuildingSiteTime[j] = (5 - udg_BuildingType[j]) * udg_Players + GetRandomInt(1, udg_Players)
set udg_Builds = udg_Builds + 1
endif
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[i] + " succeeds in conquering a |cff7ebff1" + udg_BuildingTypeName[udg_BuildingType[j]] + "|r")
call End_Turn(i, true)
call SetPlayerAbilityAvailable(Player(i), 'A003', false)
call SetPlayerAbilityAvailable(Player(i), 'A005', true)
call TriggerExecute(gg_trg_Carry_On)
elseif orderId == OrderId("stomp") then
call SetPlayerAbilityAvailable(Player(i), 'A002', false)
call PingMinimapForForceEx(GetPlayersAll(), GetUnitX(udg_Building[j]), GetUnitY(udg_Building[j]), 5, 0, 100, 50, 0)
set k = udg_BuildingUpgrade[udg_BuildingType[j] * 2 + udg_BuildingLevel[j] - 1]
set udg_BuildingValue[j] = udg_BuildingValue[j] + k
set udg_BuildingRent[j] = udg_BuildingRent[j] * 9 / 5
set udg_BuildingLevel[j] = udg_BuildingLevel[j] + 1
call AdjustPlayerStateCS(-k, i, PLAYER_STATE_RESOURCE_GOLD)
call AdjustPlayerStateCS(k, i, PLAYER_STATE_RESOURCE_LUMBER)
call LeaderboardSetItemValue(udg_Leaderboard[i], LeaderboardGetPlayerIndex(udg_Leaderboard[i], Player(0)), udg_BuildingValue[j])
call LeaderboardSetItemValue(udg_Leaderboard[i], LeaderboardGetPlayerIndex(udg_Leaderboard[i], Player(1)), udg_BuildingRent[j])
call LeaderboardSetItemValue(udg_Leaderboard[i], LeaderboardGetPlayerIndex(udg_Leaderboard[i], Player(2)), udg_BuildingLevel[j])
call AddIndicator(udg_Building[j], 255, 255, 255, 255)
set udg_TempPoint = GetUnitLoc(udg_Circle[udg_Move[i]])
call RemoveUnit(udg_Circle[udg_Move[i]])
set udg_Circle[udg_Move[i]] = CreateUnitAtLoc(Player(6), udg_BuildingUnitType[udg_BuildingLevel[j]+3], udg_TempPoint, 270)
call SetUnitColor(udg_Circle[udg_Move[i]], PLAYER_COLOR_GREEN)
call RemoveLocation(udg_TempPoint)
set udg_TempPoint = null
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[i] + " succeeds in extending a |cff7ebff1" + udg_BuildingTypeName[udg_BuildingType[j]] + "|r")
call End_Turn(i, true)
call SetPlayerAbilityAvailable(Player(i), 'A00F', false)
call SetPlayerAbilityAvailable(Player(i), 'A007', true)
call TriggerExecute(gg_trg_Carry_On)
elseif orderId == OrderId("channel") then
call SetPlayerAbilityAvailableCS2(i)
call End_Turn(i, false)
call SetPlayerAbilityAvailable(Player(i), 'A002', false)
call TriggerExecute(gg_trg_Carry_On)
elseif orderId == OrderId("unsummon") then
call Selling(GetOrderedUnit())
else
set k = orderId - 852008
if k > -1 and k < 6 then
call Item_Roaring(k, GetOrderedUnit())
endif
endif
endfunction
function InitTrig_Roll_Dice takes nothing returns nothing
set gg_trg_Roll_Dice = CreateTrigger()
call TriggerAddAction(gg_trg_Roll_Dice, function Trig_Roll_Dice_Actions)
endfunction
function Trig_Throwing_Actions takes nothing returns nothing
local integer i = udg_Turn[udg_Mover]
local integer j
local integer k
if udg_Length > 180 then
call DisableTrigger(gg_trg_Throwing)
call RemoveLocation(udg_TempPoint)
set udg_TempPoint = null
if udg_Dice == 1 then
set udg_Z = 0
elseif udg_Dice != 0 then
set udg_X = 360 / I2R(udg_Dice)
set udg_Z = 64
endif
set udg_Y = GetRandomReal(0, 360)
call ShowUnit(udg_DiceUnit, false)
set udg_TempPoint = GetUnitLoc(udg_DiceUnit)
call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Orc\\FeralSpirit\\feralspirittarget.mdl", udg_TempPoint))
set k = 1
loop
exitwhen k > udg_Dice
set udg_Y = udg_Y + udg_X
set udg_TempPoint2 = PolarProjectionBJ(udg_TempPoint, udg_Z, udg_Y)
set j = k + i * 6 - 1
call SetUnitPositionLoc(udg_Soldier[j], udg_TempPoint2)
call SetUnitFacing(udg_Soldier[j], GetRandomReal(0, 360))
call RemoveLocation(udg_TempPoint2)
set udg_TempPoint2 = null
call ShowUnit(udg_Soldier[j], true)
set k = k + 1
endloop
call PolledWait(0.8)
if udg_Dice == 0 then
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[i] + " use |cff7ebff1stopover|r card.")
else
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[i] + " rolls |cffffcc00" + I2S(udg_Dice) + "|r")
endif
set k = 1
loop
exitwhen k > udg_Dice
call ShowUnit(udg_Soldier[k+i*6-1], false)
set k = k + 1
endloop
set udg_Z = 0
call SetPlayerAbilityAvailable(Player(i), 'A000', false)
call SetPlayerAbilityAvailable(Player(i), 'A001', true)
call PolledWait(0.01)
set udg_TokenStatus[i] = 1
call EnableTrigger(gg_trg_Leap_Frog)
else
if udg_Length == 90 then
call SetUnitFlyHeight(udg_DiceUnit, 0., 1000)
elseif udg_Length == 18 then
call SetUnitFlyHeight(udg_DiceUnit, 300, 900)
endif
set udg_TempPoint2 = PolarProjectionBJ(udg_TempPoint, udg_Length, udg_Signpost[udg_Move[i]])
call SetUnitPositionLocFacingBJ(udg_DiceUnit, udg_TempPoint2, GetRandomReal(0, 360))
call RemoveLocation(udg_TempPoint2)
set udg_TempPoint2 = null
set udg_Length = udg_Length + 18
endif
endfunction
function InitTrig_Throwing takes nothing returns nothing
set gg_trg_Throwing = CreateTrigger()
call DisableTrigger(gg_trg_Throwing)
call TriggerRegisterTimerEventPeriodic(gg_trg_Throwing, 0.06)
call TriggerAddAction(gg_trg_Throwing, function Trig_Throwing_Actions)
endfunction
function Trig_Leap_Frog_Actions takes nothing returns nothing
local integer i = udg_Turn[udg_Mover]
if udg_Length > udg_Z then
call DisableTrigger(gg_trg_Leap_Frog)
call RemoveLocation(udg_TempPoint)
set udg_TempPoint = null
if udg_Dice == 0 then
call Camping(i, udg_Portal[udg_Move[i]])
else
set udg_Dice = udg_Dice - 1
set udg_OldPlaceId = udg_Move[i]
if udg_Move[i] == udg_WayPoints then
set udg_Move[i] = 0
else
set udg_Move[i] = udg_Move[i] + 1
endif
set udg_TempPoint = GetUnitLoc(udg_Circle[udg_OldPlaceId])
call SetUnitPositionLoc(udg_Token[i], udg_TempPoint)
call SetUnitFacing(udg_Token[i], udg_Signpost[udg_OldPlaceId])
call SetUnitFlyHeight(udg_Token[i], 0, 0)
set udg_Length = DistanceBetweenUnits(udg_Circle[udg_OldPlaceId], udg_Circle[udg_Move[i]]) / udg_Frame
set udg_X = udg_Length
set udg_Y = udg_Frame / 2 * udg_X
set udg_Z = udg_Y * 2
call TriggerSleepAction(0.01)
call EnableTrigger(gg_trg_Leap_Frog)
endif
else
if udg_Length == udg_Y then
call SetUnitFlyHeight(udg_Token[i], 0, 640)
elseif udg_Length == udg_X then
call SetUnitFlyHeight(udg_Token[i], 160, 640)
endif
set udg_TempPoint2 = PolarProjectionBJ(udg_TempPoint, udg_Length, udg_Signpost[udg_OldPlaceId])
call SetUnitPositionLoc(udg_Token[i], udg_TempPoint2)
call SetUnitFacing(udg_Token[i], udg_Signpost[udg_Move[i]])
call RemoveLocation(udg_TempPoint2)
set udg_TempPoint2 = null
call SetUnitAnimationWithRarity(udg_Token[i], "walk", RARITY_RARE)
set udg_Length = udg_Length + udg_X
endif
endfunction
function InitTrig_Leap_Frog takes nothing returns nothing
set gg_trg_Leap_Frog = CreateTrigger()
call DisableTrigger(gg_trg_Leap_Frog)
call TriggerAddAction(gg_trg_Leap_Frog, function Trig_Leap_Frog_Actions)
endfunction
function Trig_Carry_On_Actions takes nothing returns nothing
local integer i = udg_Round
call Take_Turns()
call Stock_Swing(i)
call Building_Company()
if udg_Players == 1 then
call Game_Over()
else
call Next_Player()
endif
endfunction
function InitTrig_Carry_On takes nothing returns nothing
set gg_trg_Carry_On = CreateTrigger()
call TriggerAddAction(gg_trg_Carry_On, function Trig_Carry_On_Actions)
endfunction
function Trig_Target_Order_Actions takes nothing returns nothing
local unit victim = GetOrderTargetUnit()
local unit villain = GetOrderedUnit()
local integer orderId = GetIssuedOrderId()
local integer i = orderId - 852008
local integer j = GetUnitUserData(villain)
local integer k = GetUnitUserData(victim)
if orderId == OrderId("charm") then
call LeaderboardSetLabelBJ(udg_Leaderboard[j], udg_BuildingTypeName[udg_BuildingType[k]])
call LeaderboardSetItemValue(udg_Leaderboard[j], LeaderboardGetPlayerIndex(udg_Leaderboard[j], Player(0)), udg_BuildingValue[k])
call LeaderboardSetItemValue(udg_Leaderboard[j], LeaderboardGetPlayerIndex(udg_Leaderboard[j], Player(1)), udg_BuildingRent[k])
call LeaderboardSetItemValue(udg_Leaderboard[j], LeaderboardGetPlayerIndex(udg_Leaderboard[j], Player(2)), udg_BuildingLevel[k])
call LeaderboardSetItemLabel(udg_Leaderboard[j], LeaderboardGetPlayerIndex(udg_Leaderboard[j], Player(3)), "Owner " + udg_PlayerName[udg_BuildingOwner[k]])
call LeaderboardDisplay(udg_Leaderboard[j], true)
elseif i > -1 and i < 6 then
call Item_Main(i, victim, villain, GetPlayerId(GetOwningPlayer(victim)), j, GetItemTypeId(UnitItemInSlot(villain, i)))
elseif udg_TokenStatus[j] != 1 then
call Standing(villain)
endif
endfunction
function InitTrig_Target_Order takes nothing returns nothing
set gg_trg_Target_Order = CreateTrigger()
call TriggerAddAction(gg_trg_Target_Order, function Trig_Target_Order_Actions)
endfunction
function Trig_Timer_Expire_Actions takes nothing returns nothing
local integer i = udg_Turn[udg_Mover]
local integer j = GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD)
set udg_TokenStatus[i] = 2
call SetPlayerAbilityAvailable(Player(i), 'A000', false)
call SetPlayerAbilityAvailable(Player(i), 'A001', true)
call SetPlayerAbilityAvailableCS2(i)
call SetPlayerAbilityAvailable(Player(i), 'A002', false)
call Destroy_Timer()
call DestroyEffect(udg_Attention)
set udg_Attention = null
set udg_Warning[i] = udg_Warning[i] + 1
if j > 1000 then
set j = 1000
endif
call AdjustPlayerStateCS(-j, i, PLAYER_STATE_RESOURCE_GOLD)
call DisplayTextToForce(GetPlayersAll(), udg_PlayerName[i] + " misses an opportunity because of a delay. Lose |cffa0ff001,000|r gold coins.")
if udg_Warning[i] == 3 or GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD) == 0 then
call Take_Over(i)
elseif udg_Warning[i] == 2 then
call DisplayTextToForce(bj_FORCE_PLAYER[i], "|cffa0ff00Warning! You have been already two times in overtime. Be considered to give up the match in overtime again.|r")
endif
call SetPlayerAbilityAvailableCS(i)
call TriggerExecute(gg_trg_Carry_On)
endfunction
function InitTrig_Timer_Expire takes nothing returns nothing
set gg_trg_Timer_Expire = CreateTrigger()
call TriggerRegisterTimerExpireEventBJ(gg_trg_Timer_Expire, udg_Timer)
call TriggerAddAction(gg_trg_Timer_Expire, function Trig_Timer_Expire_Actions)
endfunction
function Trig_Drop_Item_Actions takes nothing returns nothing
local item tempItem = GetManipulatedItem()
call PolledWait(0.01)
call RemoveItem(tempItem)
set tempItem = null
endfunction
function InitTrig_Drop_Item takes nothing returns nothing
set gg_trg_Drop_Item = CreateTrigger()
call TriggerAddAction(gg_trg_Drop_Item, function Trig_Drop_Item_Actions)
endfunction
function Trig_Move_Limit_Conditions takes nothing returns boolean
local integer i = GetIssuedOrderId()
if i == OrderId("smart") or i == OrderId("move") or i == OrderId("patrol") then
return true
endif
return false
endfunction
function Trig_Move_Limit_Actions takes nothing returns nothing
local unit whichUnit = GetOrderedUnit()
if udg_TokenStatus[GetUnitUserData(whichUnit)] != 1 then
call Standing(whichUnit)
endif
endfunction
function InitTrig_Move_Limit takes nothing returns nothing
set gg_trg_Move_Limit = CreateTrigger()
call TriggerAddCondition(gg_trg_Move_Limit, Condition(function Trig_Move_Limit_Conditions))
call TriggerAddAction(gg_trg_Move_Limit, function Trig_Move_Limit_Actions)
endfunction
function Trig_Chat_String_Actions takes nothing returns nothing
local string chatString = GetEventPlayerChatString()
local integer i = GetPlayerId(GetTriggerPlayer())
local integer j
if chatString == "total" then
set j = 0
loop
exitwhen j == udg_Players
call DisplayTextToForce(bj_FORCE_PLAYER[i], udg_PlayerName[udg_Turn[j]] + "'s total assets is |cffffcc00" + ISignCS2(udg_TotalAssets[udg_Turn[j]]) + "|r gold")
set j = j + 1
endloop
elseif udg_Users == 1 and chatString == "lock" then
set udg_LockCamera[i] = true
call SetCameraTargetControllerNoZForPlayer(Player(i), udg_Token[udg_Turn[udg_Mover]], 0, 0, false)
elseif udg_Users == 1 and chatString == "unlock" then
set udg_LockCamera[i] = false
call ResetToGameCameraForPlayer(Player(i), 0)
elseif udg_Status[i] != 0 then
if udg_Users == 1 and chatString == "auto" then
call Auto(i)
elseif udg_Users == 1 and chatString == "control" then
set udg_Status[i] = 1
elseif chatString == "clear" then
call ClearTextMessagesBJ(bj_FORCE_PLAYER[i])
elseif SubString(chatString, 0, 5) == "drop " then
call UnitRemoveItemFromSlot(udg_Token[i], S2I(SubString(chatString, 5, StringLength(chatString)))-1)
else
call Stock_Exchange(chatString, i)
endif
elseif chatString == "clear" then
call LeaderboardDisplay(udg_Leaderboard[i], false)
endif
endfunction
function InitTrig_Chat_String takes nothing returns nothing
set gg_trg_Chat_String = CreateTrigger()
call TriggerAddAction(gg_trg_Chat_String, function Trig_Chat_String_Actions)
endfunction