Name | Type | is_array | initial_value |
CargoEvent | real | No | |
CargoTransportGroup | group | Yes | |
CargoTransportUnit | unit | Yes | |
CheckDeathList | integer | Yes | |
CheckDeathTimer | timer | No | |
DeathEvent | real | No | |
DetectRemoveAbility | abilcode | No | A00L |
DetectTransformAbility | abilcode | No | A00M |
groupStopUnits | group | No | |
IsUnitAlive | boolean | Yes | |
IsUnitBeingUnloaded | boolean | Yes | |
IsUnitNew | boolean | Yes | |
IsUnitReincarnating | boolean | Yes | |
IsUnitRemoved | boolean | Yes | |
MBGame | multiboard | No | |
MBMode | multiboard | No | |
SummonerOfUnit | unit | Yes | |
TempFloatingText | texttag | No | |
TempInt | integer | No | |
TempU | unit | No | |
timerBankMeeting | timer | No | |
timerModes | timer | No | |
timerPause | timer | No | |
timerStopUnits | timer | No | |
UDex | integer | No | |
UDexLastRecycled | integer | No | |
UDexMax | integer | No | |
UDexNext | integer | Yes | |
UDexPrev | integer | Yes | |
UDexUnits | unit | Yes | |
ug | group | No | |
UnitIndexerEnabled | boolean | No | |
UnitIndexEvent | real | No | |
UnitTypeEvent | real | No | |
WorldMaxX | real | No | |
WorldMaxY | real | No |
//TESH.scrollpos=0
//TESH.alwaysfold=0
//===========================================================================
function UnitEventDestroyGroup takes integer i returns nothing
if udg_CargoTransportGroup[i] != null then
call DestroyGroup(udg_CargoTransportGroup[i])
set udg_CargoTransportGroup[i] = null
endif
endfunction
function UnitEventCheckDeath takes nothing returns nothing
local integer i = udg_CheckDeathList[0]
set udg_CheckDeathList[0] = 0
loop
exitwhen i == 0
if udg_IsUnitNew[i] then
//The unit was just created.
set udg_IsUnitNew[i] = false
elseif udg_IsUnitAlive[i] then
//The unit has started reincarnating.
set udg_IsUnitReincarnating[i] = true
set udg_IsUnitAlive[i] = false
set udg_UDex = i
set udg_DeathEvent = 0.50
set udg_DeathEvent = 0.00
endif
set i = udg_CheckDeathList[i]
endloop
endfunction
function UnitEventCheckDeathProxy takes integer i returns nothing
if udg_CheckDeathList[0] == 0 then
call TimerStart(udg_CheckDeathTimer, 0.00, false, function UnitEventCheckDeath)
endif
set udg_CheckDeathList[i] = udg_CheckDeathList[0]
set udg_CheckDeathList[0] = i
endfunction
function UnitEventOnUnload takes nothing returns nothing
local integer i = udg_UDex
call GroupRemoveUnit(udg_CargoTransportGroup[GetUnitUserData(udg_CargoTransportUnit[i])], udg_UDexUnits[i])
set udg_IsUnitBeingUnloaded[i] = true
set udg_CargoEvent = 0.00
set udg_CargoEvent = 2.00
set udg_CargoEvent = 0.00
set udg_IsUnitBeingUnloaded[i] = false
if not IsUnitLoaded(udg_UDexUnits[i]) or IsUnitType(udg_CargoTransportUnit[i], UNIT_TYPE_DEAD) or GetUnitTypeId(udg_CargoTransportUnit[i]) == 0 then
set udg_CargoTransportUnit[i] = null
endif
endfunction
function UnitEventOnDeath takes nothing returns boolean
local integer pdex = udg_UDex
set udg_UDex = GetUnitUserData(GetTriggerUnit())
if udg_UDex != 0 then
set udg_IsUnitAlive[udg_UDex] = false
set udg_DeathEvent = 0.00
set udg_DeathEvent = 1.00
set udg_DeathEvent = 0.00
if udg_CargoTransportUnit[udg_UDex] != null then
call UnitEventOnUnload()
endif
endif
set udg_UDex = pdex
return false
endfunction
function UnitEventOnOrder takes nothing returns boolean
local integer pdex = udg_UDex
local unit u = GetFilterUnit()
local integer i = GetUnitUserData(u)
if i > 0 then
set udg_UDex = i
if GetUnitAbilityLevel(u, udg_DetectRemoveAbility) == 0 then
if not udg_IsUnitRemoved[i] then
set udg_IsUnitRemoved[i] = true
set udg_IsUnitAlive[i] = false
set udg_SummonerOfUnit[i] = null
//For backwards-compatibility:
set udg_DeathEvent = 0.00
set udg_DeathEvent = 3.00
set udg_DeathEvent = 0.00
//Fire deindex event for UDex:
set udg_UnitIndexEvent = 0.00
set udg_UnitIndexEvent = 2.00
set udg_UnitIndexEvent = 0.00
set udg_UDexNext[udg_UDexPrev[i]] = udg_UDexNext[i]
set udg_UDexPrev[udg_UDexNext[i]] = udg_UDexPrev[i]
// Recycle the index for later use
set udg_UDexUnits[i] = null
set udg_UDexPrev[i] = udg_UDexLastRecycled
set udg_UDexLastRecycled = i
call UnitEventDestroyGroup(i)
endif
elseif not udg_IsUnitAlive[i] then
if not IsUnitType(u, UNIT_TYPE_DEAD) then
set udg_IsUnitAlive[i] = true
set udg_DeathEvent = 0.00
set udg_DeathEvent = 2.00
set udg_DeathEvent = 0.00
set udg_IsUnitReincarnating[i] = false
endif
elseif IsUnitType(u, UNIT_TYPE_DEAD) then
if udg_IsUnitNew[i] then
//This unit was created as a corpse.
set udg_IsUnitAlive[i] = false
set udg_DeathEvent = 0.00
set udg_DeathEvent = 1.00
set udg_DeathEvent = 0.00
elseif udg_CargoTransportUnit[i] == null or not IsUnitType(u, UNIT_TYPE_HERO) then
//The unit may have just started reincarnating.
call UnitEventCheckDeathProxy(i)
endif
elseif GetUnitAbilityLevel(u, udg_DetectTransformAbility) == 0 then
call UnitAddAbility(u, udg_DetectTransformAbility)
set udg_UnitTypeEvent = 0.00
set udg_UnitTypeEvent = 1.00
set udg_UnitTypeEvent = 0.00
endif
if udg_CargoTransportUnit[i] != null and not udg_IsUnitBeingUnloaded[i] and not IsUnitLoaded(u) or IsUnitType(u, UNIT_TYPE_DEAD) then
call UnitEventOnUnload()
endif
set udg_UDex = pdex
endif
set u = null
return false
endfunction
function UnitEventOnSummon takes nothing returns boolean
local integer pdex = udg_UDex
set udg_UDex = GetUnitUserData(GetTriggerUnit())
if udg_IsUnitNew[udg_UDex] then
set udg_SummonerOfUnit[udg_UDex] = GetSummoningUnit()
set udg_UnitIndexEvent = 0.00
set udg_UnitIndexEvent = 0.50
set udg_UnitIndexEvent = 0.00
endif
set udg_UDex = pdex
return false
endfunction
function UnitEventOnLoad takes nothing returns boolean
local integer pdex = udg_UDex
local integer i = GetUnitUserData(GetTriggerUnit())
local integer index
if i != 0 then
set udg_UDex = i
if udg_CargoTransportUnit[i] != null then
call UnitEventOnUnload()
endif
//Loaded corpses do not issue an order when unloaded, therefore must
//use the enter-region event method taken from Jesus4Lyf's Transport.
if not udg_IsUnitAlive[i] then
call SetUnitX(udg_UDexUnits[i], udg_WorldMaxX)
call SetUnitY(udg_UDexUnits[i], udg_WorldMaxY)
endif
set udg_CargoTransportUnit[i] = GetTransportUnit()
set index = GetUnitUserData(udg_CargoTransportUnit[i])
if udg_CargoTransportGroup[index] == null then
set udg_CargoTransportGroup[index] = CreateGroup()
endif
call GroupAddUnit(udg_CargoTransportGroup[index], udg_UDexUnits[i])
set udg_CargoEvent = 0.00
set udg_CargoEvent = 1.00
set udg_CargoEvent = 0.00
set udg_UDex = pdex
endif
return false
endfunction
function UnitEventEnter takes nothing returns boolean
local integer pdex = udg_UDex
local integer i = udg_UDexLastRecycled
local unit u = GetFilterUnit()
if udg_UnitIndexerEnabled and GetUnitAbilityLevel(u, udg_DetectRemoveAbility) == 0 then
//Generate a unique integer index for this unit
if i == 0 then
set i = udg_UDexMax + 1
set udg_UDexMax = i
else
set udg_UDexLastRecycled = udg_UDexPrev[i]
endif
//Link index to unit, unit to index
set udg_UDexUnits[i] = u
call SetUnitUserData(u, i)
//For backwards-compatibility, add the unit to a linked list
set udg_UDexNext[i] = udg_UDexNext[0]
set udg_UDexPrev[udg_UDexNext[0]] = i
set udg_UDexNext[0] = i
set udg_UDexPrev[i] = 0
call UnitAddAbility(u, udg_DetectRemoveAbility)
call UnitMakeAbilityPermanent(u, true, udg_DetectRemoveAbility)
call UnitAddAbility(u, udg_DetectTransformAbility)
set udg_IsUnitNew[i] = true
set udg_IsUnitAlive[i] = true
set udg_IsUnitRemoved[i] = false
set udg_IsUnitReincarnating[i] = false
call UnitEventCheckDeathProxy(i)
//Fire index event for UDex
set udg_UDex = i
set udg_UnitIndexEvent = 0.00
set udg_UnitIndexEvent = 1.00
set udg_UnitIndexEvent = 0.00
else
set udg_UDex = GetUnitUserData(u)
if udg_CargoTransportUnit[udg_UDex] != null and not IsUnitLoaded(u) then
//The unit was dead, but has re-entered the map.
call UnitEventOnUnload()
endif
endif
set udg_UDex = pdex
set u = null
return false
endfunction
//===========================================================================
function UnitEventInit takes nothing returns nothing
local integer i = 16
local player p
local trigger t = CreateTrigger()
local trigger summon = CreateTrigger()
local trigger death = CreateTrigger()
local trigger load = CreateTrigger()
local region re = CreateRegion()
local rect r = GetWorldBounds()
set udg_WorldMaxX = GetRectMaxX(r)
set udg_WorldMaxY = GetRectMaxY(r)
call RegionAddRect(re, r)
call RemoveRect(r)
call UnitEventDestroyGroup(0)
call UnitEventDestroyGroup(1)
set udg_UnitIndexerEnabled = true
call TriggerRegisterEnterRegion(CreateTrigger(), re, Filter(function UnitEventEnter))
call TriggerAddCondition(summon, Filter(function UnitEventOnSummon))
call TriggerAddCondition(death, Filter(function UnitEventOnDeath))
call TriggerAddCondition(load, Filter(function UnitEventOnLoad))
loop
set i = i - 1
set p = Player(i)
call SetPlayerAbilityAvailable(p, udg_DetectRemoveAbility, false)
call SetPlayerAbilityAvailable(p, udg_DetectTransformAbility, false)
call TriggerRegisterPlayerUnitEvent(t, p, EVENT_PLAYER_UNIT_ISSUED_ORDER, Filter(function UnitEventOnOrder))
call TriggerRegisterPlayerUnitEvent(summon, p, EVENT_PLAYER_UNIT_SUMMON, null)
call TriggerRegisterPlayerUnitEvent(death, p, EVENT_PLAYER_UNIT_DEATH, null)
call TriggerRegisterPlayerUnitEvent(load, p, EVENT_PLAYER_UNIT_LOADED, null)
call GroupEnumUnitsOfPlayer(bj_lastCreatedGroup, p, Filter(function UnitEventEnter))
exitwhen i == 0
endloop
set summon = null
set death = null
set load = null
set re = null
set p = null
set r = null
set t = null
set udg_UnitIndexEvent = 3.00
set udg_UnitIndexEvent = 0.00
endfunction
function InitTrig_Unit_Event takes nothing returns nothing
call UnitEventInit()
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
library UnitMaxState initializer Initialize requires optional AbilityPreload, optional xepreload
//==============================================================================
// UnitMaxState v2.1
//==============================================================================
// Credits:
//------------------------------------------------------------------------------
// Written By:
// Earth-Fury
//
// Original System By:
// Blade.dk
//
// Intermittent Version By:
// Deaod
//
// With Thanks To:
// - weaaddar for BonusMod and thus inspiration
// - PitzerMike for the ObjectMerger
// - Vexorian for vJass and Jass Helper
// - PipeDream for Grimoire
// - SFilip for TESH
// - MindWorX for maintaining NewGen
//------------------------------------------------------------------------------
// If you use this library in your map, please at least give credit to Blade.dk.
// Without him, this library would not exist.
//==============================================================================
// Introduction:
//------------------------------------------------------------------------------
// UnitMaxState is a library which allows you to modify a unit's maximum life,
// or maximum mana. To achieve this, the library abuses a bug with the AIlf and
// AImz abilities, which is too complex to explain here.
//
// I do believe it was indeed Blade.dk who initially found this bug. If not,
// it's still his system I stole and rewrote. Further, let me thank Deaod for
// writing up his version of this system, which inspired both the reality of
// this rewrite, and the method abilities are handled within it.
//
//==============================================================================
// Requirements:
//------------------------------------------------------------------------------
// UnitMaxState is written in vJass and requires the NewGen editor, or
// Jass Helper with PitzerMike's Object Merger configured for it.
//
// UnitMaxState requires the latest version of Jass Helper.
//
// Preloading of abilities requires either AbilityPreload or xepreload. Neither
// are required for the library to function; however, having one or the other
// will remove the slight delay the first time a unit's max state is changed.
//
//==============================================================================
// Using UnitMaxState:
//------------------------------------------------------------------------------
// UnitMaxState comes with two useful functions:
//
// nothing SetUnitMaxState(unit <target>, unitstate <state>, real <value>)
// Changes <target>'s unitstate <state> to be equal to <value>.
//
// nothing AddUnitMaxState(unit <target>, unitstate <state>, real <value>)
// Adds <value> to <target>'s <state> unitstate. Note that you can use
// negative values with this function.
//
// Both of these functions accept unitstate's other than UNIT_STATE_MAX_LIFE and
// UNIT_STATE_MAX_MANA. There is a small performance penalty in using these over
// direct usage of SetUnitState.
//
// You must not use life/mana boosting upgrades in combination with this system.
//
// Attempting to set a unit's maximum life below 1, or mana below 0 will do
// nothing. A debug message will be output if the script is compiled in
// debug mode.
//==============================================================================
//==============================================================================
// Configuration:
//------------------------------------------------------------------------------
// The below textmacro call is an all-in-one configuration line.
//------------------------------------------------------------------------------
// The first parameter is a boolean.
//
// If true, the abilities used by this system will be created on save. This adds
// a slight delay to saving your map. You only ever have to create the abilities
// the first time this library is added to your map, or if you modify any of
// the other configuration options.
//
// Note that to make the ability creation permanent, you must save with ability
// creation enabled, close your map, and reopen it in the editor. You can then
// disable ability creation, as the abilities will be permanently in your map.
//------------------------------------------------------------------------------
// The second parameter is an integer.
//
// This is the number of abilities this system will use for adding/removing
// life/mana. Note that this system uses four sets of abilities, so the actual
// number of abilities generated and used will be the value you pass here,
// multiplied by 4.
//
// The higher this number, the faster large bonuses will be added. This number
// should never have to go above 13. Between 3 and 5 will work fine for most
// maps.
//------------------------------------------------------------------------------
// The fourth and fifth parameters are 3 character prefixes for rawcodes.
//
// The first one is for the life-modifying abilities, while the second is for
// the mana-modifying abilities.
//
// Please, make sure your map has no abilities whose rawcodes begin with either
// of these prefixes before saving! Otherwise, those abilities will be
// overwritten. You can change these to any 3 character combination, if your
// map does already contain abilities whose rawcodes begin with these prefixes.
//------------------------------------------------------------------------------
//! runtextmacro UnitMaxState_Configuration("false", "3", "ZxL", "ZxM")
//------------------------------------------------------------------------------
// End of configuration
//------------------------------------------------------------------------------
//! textmacro UnitMaxState_Configuration takes LOAD_ABILITIES, ABILITY_COUNT, LIFE_PREFIX, MANA_PREFIX
//*
//! externalblock extension=lua ObjectMerger $FILENAME$
//! i function CreateAbilities(baseAbility, rawcodePrefix, field, name, icon)
//! i k = 0
//! i for sign = -1, 1, 2 do
//! i signStr = "+"
//! i if sign < 0 then
//! i signStr = "-"
//! i end
//! i j = 0
//! i for i = 0, (abilityCount - 1) * 3, 3 do
//! i j = j + 1
//! i createobject(baseAbility, rawcodePrefix .. string.sub(Chars, k + 1, k + 1))
//! i makechange(current, "anam", "UnitMaxState - " .. name)
//! i makechange(current, "ansf", "(" .. signStr .. tostring(j) .. ")")
//! i makechange(current, "aart", "ReplaceableTextures\\CommandButtons\\" .. icon)
//! i makechange(current, "aite", 0)
//! i makechange(current, "alev", 4)
//! i makechange(current, field, 1, 0)
//! i makechange(current, field, 2, 2^(i + 0) * sign)
//! i makechange(current, field, 3, 2^(i + 1) * sign)
//! i makechange(current, field, 4, 2^(i + 2) * sign)
//! i k = k + 1
//! i end
//! i end
//! i end
//! i if $LOAD_ABILITIES$ then
//! i setobjecttype("abilities")
//! i abilityCount = $ABILITY_COUNT$
//! i Chars = "abcdefghijklmnopqrstuvwxyz"
//! i CreateAbilities("AIlf", "$LIFE_PREFIX$", "Ilif", "Life", "BTNHealthStone.blp")
//! i CreateAbilities("AImz", "$MANA_PREFIX$", "Iman", "Mana", "BTNManaStone.blp")
//! i end
//! endexternalblock
// */
globals
private constant integer RAWCODE_LIFE = '$LIFE_PREFIX$a'
private constant integer RAWCODE_MANA = '$MANA_PREFIX$a'
public constant integer ABILITY_COUNT = $ABILITY_COUNT$
endglobals
//! endtextmacro
globals
private constant boolean PRELOAD_ABILITIES = true
private integer array POWERS_OF_2
endglobals
private function ErrorMsg takes string s returns nothing
debug call BJDebugMsg("SetUnitMaxState: " + s)
endfunction
function SetUnitMaxState takes unit target, unitstate state, real targetValue returns nothing
local integer difference
local integer rawcode
local integer abilityId
local integer abilityLevel
local integer currentAbility
if state == UNIT_STATE_MAX_LIFE then
set rawcode = RAWCODE_LIFE
if targetValue < 1 then
call ErrorMsg("You can not set a unit's max life to below 1")
return
endif
elseif state == UNIT_STATE_MAX_MANA then
set rawcode = RAWCODE_MANA
if targetValue < 0 then
call ErrorMsg("You can not set a unit's max mana to below 0")
return
endif
else
call SetUnitState(target, state, targetValue)
return
endif
set difference = R2I(targetValue) - R2I(GetUnitState(target, state))
if difference < 0 then
set difference = -difference
set rawcode = rawcode + ABILITY_COUNT
endif
set abilityId = ABILITY_COUNT - 1
set abilityLevel = 4
set currentAbility = rawcode + abilityId
loop
exitwhen difference == 0
if difference >= POWERS_OF_2[abilityId * 3 + (abilityLevel - 2)] then
call UnitAddAbility(target, currentAbility)
call SetUnitAbilityLevel(target, currentAbility, abilityLevel)
call UnitRemoveAbility(target, currentAbility)
set difference = difference - POWERS_OF_2[abilityId * 3 + (abilityLevel - 2)]
else
set abilityLevel = abilityLevel - 1
if abilityLevel <= 1 then
set abilityId = abilityId - 1
set abilityLevel = 4
set currentAbility = rawcode + abilityId
endif
endif
endloop
endfunction
function AddUnitMaxState takes unit target, unitstate state, real additionalValue returns nothing
call SetUnitMaxState(target, state, GetUnitState(target, state) + additionalValue)
endfunction
//! textmacro UnitMaxState_Preload takes RAWCODE
set i = 0
loop
exitwhen i == ABILITY_COUNT * 2 - 1
static if LIBRARY_AbilityPreload then
call AbilityPreload($RAWCODE$ + i)
elseif LIBRARY_xepreload then
call XE_PreloadAbility($RAWCODE$ + i)
endif
set i = i + 1
endloop
//! endtextmacro
private function Initialize takes nothing returns nothing
local integer i
local integer k
set i = 1
set POWERS_OF_2[0] = 1
loop
exitwhen i == ABILITY_COUNT * 2 * 2 * 3 + 1
set POWERS_OF_2[i] = POWERS_OF_2[i - 1] * 2
set i = i + 1
endloop
static if DEBUG_MODE and PRELOAD_ABILITIES and not LIBRARY_AbilityPreload and not LIBRARY_xepreload then
call ErrorMsg("Ability preloading was enabled, but neither of the supported preload libraries are present")
elseif PRELOAD_ABILITIES then
//! runtextmacro UnitMaxState_Preload("RAWCODE_LIFE")
//! runtextmacro UnitMaxState_Preload("RAWCODE_MANA")
endif
endfunction
endlibrary
//TESH.scrollpos=63
//TESH.alwaysfold=0
library AbilityPreload
//===========================================================================
// Information:
//==============
//
// Preloading removes the noticeable delay the first time an ability
// is loaded in a game. If an ability was not already on a pre-placed unit
// or a unit that was created during initialization, preloading is needed
// to prevent a delay.
//
//===========================================================================
// AbilityPreload API:
//=====================
//
// AbilityPreload(abilityid) :
// Call this before any time has elapsed to preload a specific
// ability. If debug mode is enabled, you will see an error message
// if you call this after initialization, or if you try to preload
// an ability that does not exist. Will inline to a UnitAddAbility
// call if debug mode is disabled.
//
// AbilityRangePreload(start, end) :
// Same as AbilityPreload, but preloads a range of abilities.
// It will iterates between the two rawcode values and preload
// every ability along the way. It will not show an error message
// for non-existent abilities.
//
//===========================================================================
// Configuration:
//================
globals
private constant integer PreloadUnitRawcode = 'hpea'
//This is the rawcode for "Sammy!". It is never used and has no model,
//which makes an ideal preloading unit. Change it if you want to. /changed to peasant/
endglobals
//===========================================================================
globals
private unit PreloadUnit
endglobals
function AbilityPreload takes integer abilityid returns nothing
static if DEBUG_MODE then
if GetUnitTypeId(PreloadUnit) == 0 then
call BJDebugMsg("AbilityPreload error: Can't preload an ability after initialization")
return
endif
endif
call UnitAddAbility(PreloadUnit, abilityid)
static if DEBUG_MODE then
if GetUnitAbilityLevel(PreloadUnit, abilityid) == 0 then
call BJDebugMsg("AbilityPreload error: Attempted to preload a non-existent ability")
endif
endif
endfunction
function AbilityRangePreload takes integer start, integer end returns nothing
local integer i = 1
static if DEBUG_MODE then
if GetUnitTypeId(PreloadUnit) == 0 then
call BJDebugMsg("AbilityPreload error: Can't preload an ability after initialization")
return
endif
endif
if start > end then
set i = -1
endif
loop
exitwhen start > end
call UnitAddAbility(PreloadUnit, start)
set start = start + i
endloop
endfunction
//===========================================================================
private struct Init extends array
private static method onInit takes nothing returns nothing
set PreloadUnit = CreateUnit(Player(15), PreloadUnitRawcode, 0., 0., 0.)
call UnitApplyTimedLife(PreloadUnit, 0, .001)
call ShowUnit(PreloadUnit, false)
call UnitAddAbility(PreloadUnit, 'Aloc')
endmethod
endstruct
endlibrary
//TESH.scrollpos=8
//TESH.alwaysfold=0
function Init_SetPropertiesValues takes nothing returns nothing
local integer a=1
// DZIALKI :
// 30% of those values is an passive income payed on every begining of your turn
set buyCost[1] = 1 //start
set buyCost[11] = 1 // prison
set buyCost[6] = 200 // railway station west
set buyCost[26] = 200 // railway station east
set g_railwayStationRent1 = 25
set g_railwayStationRent2 = 50
set buyCost[37] = 760 // CASINO
set rent[37] = 50
set buyCost[18] = 350 // factory 1
set rent[18] = 30
set buyCost[16] = 1000 // law firm north
set rent[16] = 100
set buyCost[36] = 1000 // law firm south
set rent[36] = 100
set buyCost[13] = 250 // Power Station [serviceman]
set rent[13] = 25
set buyCost[29] = 200 // Water Supply [serviceman]
set rent[29] = 20
set buyCost[21] = 300 // supermarket [overdue food]
set g_supermarketRent1 = 30
set g_supermarketRent2 = 150
set buyCost[31] = 200 // restaurant [overdue food]
set g_restaurantRent1 = 20
set g_restaurantRent2 = 100
set buyCost[3] = 250 // police municipal [thief]
set rent[3] = 25
set buyCost[8] = 300 // police [thief]
set rent[8] = 30
set buyCost[23] = 300 // fire dept [pyromaniac]
set rent[23] = 30
set buyCost[34] = 350 // hospital [pyromaniac]
set rent[34] = 35
set buyCost[12] = 100 // konopacka [1] H
set rent[12] = 10
set rent1h[12] = 35 //70
set rent2h[12] = 80 //80
set rent3h[12] = 135 //90
set rentH[12] = 260 //130
set buildCost[12] = 50
set buyCost[22] = 100 // stalowa [1] H
set rent[22] = 10
set rent1h[22] = 35
set rent2h[22] = 80
set rent3h[22] = 135
set rentH[22] = 260
set buildCost[22] = 50
set buyCost[2] = 110 // gronowa [1] H
set rent[2] = 15
set rent1h[2] = 35
set rent2h[2] = 80
set rent3h[2] = 135
set rentH[2] = 280
set buildCost[2] = 50
set buyCost[7] = 100 // radzyminska [2] G
set rent[7] = 15
set rent1h[7] = 35 //70
set rent2h[7] = 80 //80
set rent3h[7] = 135 //90
set rentH[7] = 260 //130
set buildCost[7] = 50
set buyCost[32] = 100 // jagiellonska [2] G
set rent[32] = 15
set rent1h[32] = 35
set rent2h[32] = 80
set rent3h[32] = 135
set rentH[32] = 260
set buildCost[32] = 50
set buyCost[20] = 120 // targowa [2] G
set rent[20] = 20
set rent1h[20] = 35
set rent2h[20] = 80
set rent3h[20] = 135
set rentH[20] = 280
set buildCost[20] = 50
set buyCost[40] = 140 // plowiecka [3] F
set rent[40] = 20
set rent1h[40] = 70
set rent2h[40] = 160
set rent3h[40] = 270
set rentH[40] = 520
set buildCost[40] = 100
set buyCost[28] = 140 // marsa [3] F
set rent[28] = 20
set rent1h[28] = 70
set rent2h[28] = 160
set rent3h[28] = 270
set rentH[28] = 520
set buildCost[28] = 100
set buyCost[14] = 160 // grochowska [3] F
set rent[14] = 25
set rent1h[14] = 70
set rent2h[14] = 160
set rent3h[14] = 270
set rentH[14] = 570
set buildCost[14] = 100
set buyCost[5] = 180 // obozowa [4] E
set rent[5] = 25
set rent1h[5] = 70
set rent2h[5] = 160
set rent3h[5] = 270
set rentH[5] = 520
set buildCost[5] = 100
set buyCost[19] = 180 // gorczewska [4] E
set rent[19] = 25
set rent1h[19] = 70
set rent2h[19] = 160
set rent3h[19] = 270
set rentH[19] = 520
set buildCost[19] = 100
set buyCost[33] = 200 // wolska [4] E
set rent[33] = 30
set rent1h[33] = 70
set rent2h[33] = 160
set rent3h[33] = 270
set rentH[33] = 570
set buildCost[33] = 100
set buyCost[39] = 220 // mickiewicza [5] D
set rent[39] = 30
set rent1h[39] = 105 //70
set rent2h[39] = 240 //80
set rent3h[39] = 405 //90
set rentH[39] = 780 //130
set buildCost[39] = 150
set buyCost[10] = 220 // slowackiego [5] D
set rent[10] = 30
set rent1h[10] = 105
set rent2h[10] = 240
set rent3h[10] = 405
set rentH[10] = 780
set buildCost[10] = 150
set buyCost[25] = 230 // plac wilsona [5] D
set rent[25] = 35
set rent1h[25] = 105
set rent2h[25] = 240
set rent3h[25] = 405
set rentH[25] = 850
set buildCost[25] = 150
set buyCost[17] = 250 // swietokrzyska [6] C
set rent[17] = 35
set rent1h[17] = 105
set rent2h[17] = 240
set rent3h[17] = 405
set rentH[17] = 780
set buildCost[17] = 150
set buyCost[4] = 250 // krakowskie przedmiescie [6] C
set rent[4] = 35
set rent1h[4] = 105
set rent2h[4] = 240
set rent3h[4] = 405
set rentH[4] = 780
set buildCost[4] = 150
set buyCost[30] = 280 // nowy swiat [6] C
set rent[30] = 40
set rent1h[30] = 105
set rent2h[30] = 240
set rent3h[30] = 405
set rentH[30] = 850
set buildCost[30] = 150
set buyCost[9] = 300 // plac trzech krzyzy [7] B
set rent[9] = 40
set rent1h[9] = 140 //70
set rent2h[9] = 320 //80
set rent3h[9] = 540 //90
set rentH[9] = 1040 //130
set buildCost[9] = 200
set buyCost[24] = 300 // marszalkowska [7] B
set rent[24] = 40
set rent1h[24] = 140
set rent2h[24] = 320
set rent3h[24] = 540
set rentH[24] = 1040
set buildCost[24] = 200
set buyCost[35] = 320 // aleje jerozolimskie [7] B
set rent[35] = 45
set rent1h[35] = 140
set rent2h[35] = 320
set rent3h[35] = 540
set rentH[35] = 1140
set buildCost[35] = 200
set buyCost[38] = 330 // belwederska [8] A
set rent[38] = 45
set rent1h[38] = 140
set rent2h[38] = 320
set rent3h[38] = 540
set rentH[38] = 1040
set buildCost[38] = 200
set buyCost[27] = 330 // kopernika [8] A
set rent[27] = 45
set rent1h[27] = 140
set rent2h[27] = 320
set rent3h[27] = 540
set rentH[27] = 1040
set buildCost[27] = 200
set buyCost[15] = 350 // aleje ujazdowskie [8] A
set rent[15] = 50
set rent1h[15] = 140 //70%
set rent2h[15] = 320 //80%
set rent3h[15] = 540 // 90%
set rentH[15] = 1140 // 130%
set buildCost[15] = 200
//-----------
set a=1
loop
exitwhen a>40
call SetUnitMaxState(circle[a], UNIT_STATE_MAX_LIFE, I2R(buyCost[a]))
set a=a+1
endloop
endfunction
//TESH.scrollpos=141
//TESH.alwaysfold=0
globals
player g_playerActive = null
player g_tempPlayer = null
player g_districtOwningPlayer = null
player BANK = null
unit FLAG = null
timerdialog g_timerWindow = null
force g_playersGroup = null
timer g_startingTimer = null
timer g_timerTurn = null
timer g_timerInterrupt = null
group g_charactersGroup = null
group g_streetGroup = null
group g_interruptGroup = null
integer g_playersCount = 0
integer g_tempInt = 0
integer g_railwayStationRent1 = 0
integer g_railwayStationRent2 = 0
integer g_restaurantRent1 = 0
integer g_restaurantRent2 = 0
integer g_supermarketRent1 = 0
integer g_supermarketRent2 = 0
integer g_dividend = 0
integer g_bankMeetingInvitedPlayers = 0
integer g_bankMeetingCircleNr = 0
integer g_cost_Ticket = 150
integer g_cost_CloakingDevice = 200
real g_incomeMultiplier = 0.30
integer ClockS0 = 0
integer ClockS1 = 0
integer ClockM0 = 0
integer ClockM1 = 0
integer ClockH0 = 0
timer g_timerClock = null
// multiboard mode related:
integer g_startingMoney_mb = 1000
real g_turnTime_mb = 40.00
integer g_bankMeetInterval_mb_min = 8
integer g_invitationsInterval_mb = 3 //min
integer g_accusationsInterval_mb = 4 //min
integer g_currentRow = 1
//starting settings:
integer g_startingMoney = 1000
real g_turnTime = 40.00
real g_bankMeetInterval = 480.00
real g_invitationsInterval = 180
real g_accusationsInterval = 240
//attackers part
integer g_cost_Invitation = 180
integer g_cost_Pyromaniac = 150
integer g_cost_Thief = 130
integer g_cost_OverdueFood = 120
integer g_cost_Serviceman = 100
integer g_cost_Sue = 1500
real g_amountServiceman = 0.80 //used in "UpdateCircleMana"
real g_amountOverdueFood = 0.70
real g_amountThief = 0.60
real g_amountPyromaniac = 0.50
timer g_timerJudgment = null
timer g_timerInvitationInProgress = null
integer g_invitedPlayerId = 0
real g_messengerTimedLife = 360.00 //6min
integer g_lotteryCost1 = 100
integer g_lotteryCost10 = 500
integer g_lotteryCost100 = 2000
integer g_lotteryChance1 = 10
integer g_lotteryChance10 = 15
integer g_lotteryChance100 = 20
integer g_lotteryWin1 = 1000
integer g_lotteryWin10 = 2500
integer g_lotteryWin100 = 8000
//ARRAY VARS
unit array g_requirementUnit1
unit array g_requirementUnit2
unit array g_requirementUnit3
unit array g_requirementUnit4
unit array g_picture
unit array g_investor
unit array g_wisp
boolean array g_statusBankrupt
boolean array g_statusLeft
boolean array g_isMyTurn
integer array g_investorPositionNr
integer array g_statusInJail
real array g_cameraDistance
real array g_pictureLocX
real array g_pictureLocY
real array g_owningState
group array g_colorArea
rect array g_rect
rect array g_rectResting
string array g_playerName
string array g_mbIconPath
string array g_mbIconPathCity
unit array circle
unit array house1
unit array house2
unit array house3
unit array hotel
integer array circleNr
integer array buyCost
integer array rent
integer array rent1h
integer array rent2h
integer array rent3h
integer array rentH
integer array buildCost
//spells
unit array spellCaster
unit array spellTarget
integer array spellInteger
integer array spellLevel
integer array spellCounter
real array spellDuration
real array spellDamage
real array spellRadius
group array spellGroup
timer array spellTimer
constant integer DUMMY = 'n00A'
constant integer LAWSUIT_FLAG = 'h00L'
constant integer MESSENGER = 'h00Z'
constant integer PYROMANIAC = 'h00Q'
constant integer THIEF = 'h00S'
constant integer OVERDUE_FOOD = 'h00X'
constant integer SERVICEMAN = 'h00V'
constant integer REQ_UNIT_1 = 'n00B' // serviceman
constant integer REQ_UNIT_2 = 'n01E' // overdue food
constant integer REQ_UNIT_3 = 'n01F' //thief
constant integer REQ_UNIT_4 = 'n01G' //pyromaniac
constant integer DEVICE_FLAG = 'h00O'
constant integer ABI_INVITATION = 'A008'
constant integer ABI_SEND_PYROMANIAC = 'A001'
constant integer ABI_SEND_THIEF = 'A00J'
constant integer ABI_SEND_OVERDUEFOOD = 'A00K'
constant integer ABI_SEND_SERVICEMAN = 'A00O'
constant integer ABI_IM_DONE = 'A01A'
constant integer ABI_BUY = 'A01B'
constant integer ABI_BUILD = 'A019'
constant integer ABI_SELL_BUILDING = 'A002'
constant integer ABI_BUY_TICKET = 'A00P'
constant integer ABI_SUE = 'A007'
constant integer ABI_BUY_LOTTERY_1 = 'A000'
constant integer ABI_BUY_LOTTERY_10 = 'A005'
constant integer ABI_BUY_LOTTERY_100 = 'A00Q'
constant integer ABI_PRODUCE_DEVICE = 'A00H'
constant integer BUFF_CLOAKING_DEVICE = 'B008'
constant integer ABI_BLINK = 'A00I'
constant integer ITEM_INVITATION = 'I001'
constant integer ITEM_PYROMANIAC = 'I00R'
constant integer ITEM_THIEF = 'I002'
constant integer ITEM_OVERDUEFOOD = 'I00T'
constant integer ITEM_SERVICEMAN = 'I00U'
constant integer ITEM_ACCUSATION = 'I016'
constant integer ITEM_CLOAKING_DEVICE = 'I019'
endglobals
//====================================
native GetPlayerUnitTypeCount takes player p, integer unitid returns integer
//counts only alive units/heroes/structures
//counts also units during training; also counts buildings under construction
//counts building during upgrade (like upgrade town hall-->keep in progress, counts as keep)
//counts also heroes during revieving
native GetUnitGoldCost takes integer unitid returns integer
native GetUnitWoodCost takes integer unitid returns integer
native GetUnitBuildTime takes integer unitid returns integer
// these natives will copy values from Object Editor fields "Gold Cost", "Lumber Cost", "Build Time"
// do NOT use for heroes! *it will crash a game*
//=====================================
//=====================================
function Init_SetCirclesAndHouses takes nothing returns nothing
// DZIALKI :
set circle[1] = gg_unit_n008_0109 //start
set circle[3] = gg_unit_n016_0057 // police municipal
set circle[6] = gg_unit_n004_0059 // railway station west
set circle[8] = gg_unit_n015_0056 // police
set circle[11] = gg_unit_n001_0098 // prison
set circle[13] = gg_unit_n005_0106 // Power Station
set circle[16] = gg_unit_n01B_0060 // law firm north
set circle[18] = gg_unit_n002_0100 // factory 1
set circle[21] = gg_unit_n009_0110 // supermarket
set circle[23] = gg_unit_n000_0055 // fire dept
set circle[26] = gg_unit_n01D_0053 // railway station east
set circle[29] = gg_unit_n006_0107 // Water Supply
set circle[31] = gg_unit_n007_0108 // restaurant
set circle[34] = gg_unit_n017_0058 // hospital
set circle[36] = gg_unit_n01C_0073 // law firm south
set circle[37] = gg_unit_n01A_0049 // factory 2
set circle[12] = gg_unit_n00J_0084 // konopacka [1]
set house1[12] = gg_unit_h000_0112
set house2[12] = gg_unit_h000_0008
set house3[12] = gg_unit_h000_0113
set hotel[12] = gg_unit_h001_0114
set circle[22] = gg_unit_n00K_0085 // stalowa [1]
set house1[22] = gg_unit_h000_0005
set house2[22] = gg_unit_h000_0017
set house3[22] = gg_unit_h000_0002
set hotel[22] = gg_unit_h001_0016
set circle[2] = gg_unit_n018_0038 // gronowa [1]
set house1[2] = gg_unit_h000_0111
set house2[2] = gg_unit_h000_0015
set house3[2] = gg_unit_h000_0072
set hotel[2] = gg_unit_h001_0071
set circle[7] = gg_unit_n00L_0215 // radzyminska [2]
set house1[7] = gg_unit_h002_0019
set house2[7] = gg_unit_h002_0018
set house3[7] = gg_unit_h002_0020
set hotel[7] = gg_unit_h003_0021
set circle[32] = gg_unit_n00M_0216 // jagiellonska [2]
set house1[32] = gg_unit_h002_0118
set house2[32] = gg_unit_h002_0117
set house3[32] = gg_unit_h002_0119
set hotel[32] = gg_unit_h003_0116
set circle[20] = gg_unit_n00N_0217 // targowa [2]
set house1[20] = gg_unit_h002_0123
set house2[20] = gg_unit_h002_0122
set house3[20] = gg_unit_h002_0124
set hotel[20] = gg_unit_h003_0121
set circle[40] = gg_unit_n00O_0218 // plowiecka [3]
set house1[40] = gg_unit_h004_0125
set house2[40] = gg_unit_h004_0126
set house3[40] = gg_unit_h004_0127
set hotel[40] = gg_unit_h005_0129
set circle[28] = gg_unit_n00P_0219 // marsa [3]
set house1[28] = gg_unit_h004_0012
set house2[28] = gg_unit_h004_0022
set house3[28] = gg_unit_h004_0023
set hotel[28] = gg_unit_h005_0025
set circle[14] = gg_unit_n00Q_0220 // grochowska [3]
set house1[14] = gg_unit_h004_0130
set house2[14] = gg_unit_h004_0131
set house3[14] = gg_unit_h004_0132
set hotel[14] = gg_unit_h005_0134
set circle[5] = gg_unit_n00R_0222 // obozowa [4]
set house1[5] = gg_unit_h006_0026
set house2[5] = gg_unit_h006_0027
set house3[5] = gg_unit_h006_0028
set hotel[5] = gg_unit_h007_0030
set circle[19] = gg_unit_n00S_0221 // gorczewska [4]
set house1[19] = gg_unit_h006_0135
set house2[19] = gg_unit_h006_0136
set house3[19] = gg_unit_h006_0137
set hotel[19] = gg_unit_h007_0139
set circle[33] = gg_unit_n00T_0223 // wolska [4]
set house1[33] = gg_unit_h006_0140
set house2[33] = gg_unit_h006_0141
set house3[33] = gg_unit_h006_0142
set hotel[33] = gg_unit_h007_0144
set circle[39] = gg_unit_n00U_0227 // mickiewicza [5]
set house1[39] = gg_unit_h009_0033
set house2[39] = gg_unit_h009_0035
set house3[39] = gg_unit_h009_0032
set hotel[39] = gg_unit_h008_0031
set circle[10] = gg_unit_n00V_0228 // slowackiego [5]
set house1[10] = gg_unit_h009_0147
set house2[10] = gg_unit_h009_0149
set house3[10] = gg_unit_h009_0146
set hotel[10] = gg_unit_h008_0145
set circle[25] = gg_unit_n00W_0229 // plac wilsona [5]
set house1[25] = gg_unit_h009_0152
set house2[25] = gg_unit_h009_0154
set house3[25] = gg_unit_h009_0151
set hotel[25] = gg_unit_h008_0150
set circle[17] = gg_unit_n00X_0230 // swietokrzyska [6]
set house1[17] = gg_unit_h00A_0036
set house2[17] = gg_unit_h00A_0037
set house3[17] = gg_unit_h00A_0039
set hotel[17] = gg_unit_h00B_0040
set circle[4] = gg_unit_n00Y_0231 // krakowskie przedmiescie [6]
set house1[4] = gg_unit_h00A_0051
set house2[4] = gg_unit_h00A_0052
set house3[4] = gg_unit_h00A_0054
set hotel[4] = gg_unit_h00B_0155
set circle[30] = gg_unit_n00Z_0232 // nowy swiat [6]
set house1[30] = gg_unit_h00A_0156
set house2[30] = gg_unit_h00A_0157
set house3[30] = gg_unit_h00A_0159
set hotel[30] = gg_unit_h00B_0160
set circle[9] = gg_unit_n010_0233 // plac trzech krzyzy [7]
set house1[9] = gg_unit_h00C_0041
set house2[9] = gg_unit_h00C_0042
set house3[9] = gg_unit_h00C_0044
set hotel[9] = gg_unit_h00D_0045
set circle[24] = gg_unit_n011_0234 // marszalkowska [7]
set house1[24] = gg_unit_h00C_0161
set house2[24] = gg_unit_h00C_0162
set house3[24] = gg_unit_h00C_0164
set hotel[24] = gg_unit_h00D_0165
set circle[35] = gg_unit_n012_0235 // aleje jerozolimskie [7]
set house1[35] = gg_unit_h00C_0166
set house2[35] = gg_unit_h00C_0167
set house3[35] = gg_unit_h00C_0169
set hotel[35] = gg_unit_h00D_0170
set circle[38] = gg_unit_n013_0236 // belwederska [8]
set house1[38] = gg_unit_h00E_0047
set house2[38] = gg_unit_h00E_0046
set house3[38] = gg_unit_h00E_0048
set hotel[38] = gg_unit_h00F_0050
set circle[27] = gg_unit_n019_0043 // kopernika [8]
set house1[27] = gg_unit_h00E_0024
set house2[27] = gg_unit_h00E_0029
set house3[27] = gg_unit_h00E_0000
set hotel[27] = gg_unit_h00F_0034
set circle[15] = gg_unit_n014_0237 // aleje ujazdowskie [8]
set house1[15] = gg_unit_h00E_0172
set house2[15] = gg_unit_h00E_0171
set house3[15] = gg_unit_h00E_0173
set hotel[15] = gg_unit_h00F_0175
endfunction
//---------------------------------------------------------------
function Init_HideAllHouses takes nothing returns nothing
local integer i=1
loop
exitwhen i>40
call ShowUnit(house1[i], false)
call ShowUnit(house2[i], false)
call ShowUnit(house3[i], false)
call ShowUnit(hotel[i], false)
set i=i+1
endloop
endfunction
//---------------------------------------------------------------
function Init_SetColorGroups takes nothing returns nothing
call GroupAddUnit(g_colorArea[1], circle[2]) // H
call GroupAddUnit(g_colorArea[1], circle[12])
call GroupAddUnit(g_colorArea[1], circle[22])
call GroupAddUnit(g_streetGroup, circle[2])
call GroupAddUnit(g_streetGroup, circle[12])
call GroupAddUnit(g_streetGroup, circle[22])
call GroupAddUnit(g_colorArea[2], circle[7]) // G
call GroupAddUnit(g_colorArea[2], circle[20])
call GroupAddUnit(g_colorArea[2], circle[32])
call GroupAddUnit(g_streetGroup, circle[7])
call GroupAddUnit(g_streetGroup, circle[20])
call GroupAddUnit(g_streetGroup, circle[32])
call GroupAddUnit(g_colorArea[3], circle[14]) // F
call GroupAddUnit(g_colorArea[3], circle[28])
call GroupAddUnit(g_colorArea[3], circle[40])
call GroupAddUnit(g_streetGroup, circle[14])
call GroupAddUnit(g_streetGroup, circle[28])
call GroupAddUnit(g_streetGroup, circle[40])
call GroupAddUnit(g_colorArea[4], circle[19]) // E
call GroupAddUnit(g_colorArea[4], circle[33])
call GroupAddUnit(g_colorArea[4], circle[5])
call GroupAddUnit(g_streetGroup, circle[19])
call GroupAddUnit(g_streetGroup, circle[33])
call GroupAddUnit(g_streetGroup, circle[5])
call GroupAddUnit(g_colorArea[5], circle[25]) // D
call GroupAddUnit(g_colorArea[5], circle[39])
call GroupAddUnit(g_colorArea[5], circle[10])
call GroupAddUnit(g_streetGroup, circle[25])
call GroupAddUnit(g_streetGroup, circle[39])
call GroupAddUnit(g_streetGroup, circle[10])
call GroupAddUnit(g_colorArea[6], circle[30]) // C
call GroupAddUnit(g_colorArea[6], circle[4])
call GroupAddUnit(g_colorArea[6], circle[17])
call GroupAddUnit(g_streetGroup, circle[30])
call GroupAddUnit(g_streetGroup, circle[4])
call GroupAddUnit(g_streetGroup, circle[17])
call GroupAddUnit(g_colorArea[7], circle[35]) // B
call GroupAddUnit(g_colorArea[7], circle[9])
call GroupAddUnit(g_colorArea[7], circle[24])
call GroupAddUnit(g_streetGroup, circle[35])
call GroupAddUnit(g_streetGroup, circle[9])
call GroupAddUnit(g_streetGroup, circle[24])
call GroupAddUnit(g_colorArea[8], circle[38]) // A
call GroupAddUnit(g_colorArea[8], circle[15])
call GroupAddUnit(g_colorArea[8], circle[27])
call GroupAddUnit(g_streetGroup, circle[38])
call GroupAddUnit(g_streetGroup, circle[15])
call GroupAddUnit(g_streetGroup, circle[27])
// police municipale [3], police [8], power station [13]
// fire dept [23], water supply [29], hospital [34]
call GroupAddUnit(g_colorArea[10], circle[3])
call GroupAddUnit(g_colorArea[10], circle[8])
call GroupAddUnit(g_colorArea[10], circle[13])
call GroupAddUnit(g_colorArea[10], circle[23])
call GroupAddUnit(g_colorArea[10], circle[29])
call GroupAddUnit(g_colorArea[10], circle[34])
endfunction
//======================================================
function InitTrig_VarsSettings takes nothing returns nothing
local integer a=0
set BANK = Player(11) // brown
set FLAG = gg_unit_n00C_0007
loop
exitwhen a>10
set g_colorArea[a] = CreateGroup()
set spellGroup[a] = CreateGroup()
set spellTimer[a] = CreateTimer()
set a=a+1
endloop
set g_startingTimer = CreateTimer()
set g_timerClock = CreateTimer()
set g_timerTurn = CreateTimer()
set g_timerInterrupt = CreateTimer()
set g_timerInvitationInProgress = CreateTimer()
set g_timerJudgment = CreateTimer()
set g_playersGroup = CreateForce()
set g_charactersGroup = CreateGroup()
set g_streetGroup = CreateGroup()
set g_interruptGroup = CreateGroup()
set a=0
loop
exitwhen a>3
set g_isMyTurn[a] = false
set g_statusInJail[a] = 0
set g_statusBankrupt[a] = false
set g_statusLeft[a] = false
set g_owningState[a] = 0.00
set g_requirementUnit1[a] = CreateUnit(Player(15), REQ_UNIT_1, 0.00, 0.00, 0.00) //for neutral passive
set g_requirementUnit2[a] = CreateUnit(Player(15), REQ_UNIT_2, 0.00, 0.00, 0.00)
set g_requirementUnit3[a] = CreateUnit(Player(15), REQ_UNIT_3, 0.00, 0.00, 0.00)
set g_requirementUnit4[a] = CreateUnit(Player(15), REQ_UNIT_4, 0.00, 0.00, 0.00)
set a=a+1
endloop
call Init_SetCirclesAndHouses()
call Init_SetPropertiesValues()
call Init_HideAllHouses()
call Init_SetColorGroups()
set g_pictureLocX[0] = 256.00
set g_pictureLocY[0] = -1610.00
set g_pictureLocX[1] = 384.00
set g_pictureLocY[1] = -1610.00
set g_pictureLocX[2] = 512.00
set g_pictureLocY[2] = -1610.00
set g_pictureLocX[3] = 640.00
set g_pictureLocY[3] = -1610.00
//multiboard related
set g_mbIconPath[0] = "ReplaceableTextures\\PassiveButtons\\PASreddot.blp"
set g_mbIconPath[1] = "ReplaceableTextures\\PassiveButtons\\PASbluedot.blp"
set g_mbIconPath[2] = "ReplaceableTextures\\PassiveButtons\\PAStealdot.blp"
set g_mbIconPath[3] = "ReplaceableTextures\\PassiveButtons\\PASpurpledot.blp"
set g_mbIconPath[11] = "UI\\Minimap\\MinimapIconCreepLoc2.blp" //bank owns
set g_mbIconPathCity[0] = "ReplaceableTextures\\CommandButtons\\BTNPAScityBuildingRed.blp"
set g_mbIconPathCity[1] = "ReplaceableTextures\\CommandButtons\\BTNPAScityBuildingBlue.blp"
set g_mbIconPathCity[2] = "ReplaceableTextures\\CommandButtons\\BTNPAScityBuildingTeal.blp"
set g_mbIconPathCity[3] = "ReplaceableTextures\\CommandButtons\\BTNPAScityBuildingPurple.blp"
set g_mbIconPathCity[11] = "ReplaceableTextures\\CommandButtons\\BTNPAScityBuildingWhite.blp" //bank owns
set g_rectResting[0] = gg_rct_MessengersRed
set g_rectResting[1] = gg_rct_MessengersBlue
set g_rectResting[2] = gg_rct_MessengersTeal
set g_rectResting[3] = gg_rct_MessengersPurple
set g_wisp[0] = gg_unit_e000_0224 // wisp for choosing character
set g_wisp[1] = gg_unit_e000_0210
set g_wisp[2] = gg_unit_e000_0225
set g_wisp[3] = gg_unit_e000_0226
call GroupAddUnit(g_charactersGroup, gg_unit_H00J_0091)
call RemoveGuardPosition(gg_unit_H00J_0091)
call GroupAddUnit(g_charactersGroup, gg_unit_H00I_0090)
call RemoveGuardPosition(gg_unit_H00I_0090)
call GroupAddUnit(g_charactersGroup, gg_unit_H00K_0092)
call RemoveGuardPosition(gg_unit_H00K_0092)
call GroupAddUnit(g_charactersGroup, gg_unit_H00M_0011)
call RemoveGuardPosition(gg_unit_H00M_0011)
call GroupAddUnit(g_charactersGroup, gg_unit_H00G_0061)
call RemoveGuardPosition(gg_unit_H00G_0061)
call GroupAddUnit(g_charactersGroup, gg_unit_H00W_0095)
call RemoveGuardPosition(gg_unit_H00W_0095)
//pictures:
call ShowUnit(gg_unit_n00D_0087, false) // DAVE
call ShowUnit(gg_unit_n00E_0086, false) // DOC
call ShowUnit(gg_unit_n00F_0096, false) // INQUISTOR
call ShowUnit(gg_unit_n00G_0097, false) // LUKE
call ShowUnit(gg_unit_n00H_0178, false) // OICHI
call ShowUnit(gg_unit_n00I_0211, false) // ROSE
endfunction
//TESH.scrollpos=105
//TESH.alwaysfold=0
//============================================
function IsUnitAlive takes unit u returns boolean
return not (GetUnitTypeId(u) == 0 or IsUnitType(u, UNIT_TYPE_DEAD))
endfunction
//---------------------------------------------------------------
// DisableUnitMovement /* v1.0.0.1
// * Disables unit movement. They can still turn, but will stay in
// * place. It simulates an ensnare-like effect, except that it will
// * not ground units, it does not have buffs, does not interrupt
// * channeled casts and appears to have no downsides.
// * Full credits to WaterKnight for discovering this technique.
//--------------------------------------------------------------------
function DisableUnitMovement takes unit u returns nothing
call SetUnitPropWindow(u, 0)
endfunction
//--------------------------------------------------------------------
function EnableUnitMovement takes unit u returns nothing
call SetUnitPropWindow(u, GetUnitDefaultPropWindow(u) * bj_DEGTORAD)
endfunction
//--------------------------------------------------------------------
//--------------------------------------------------------------------
function PlaySoundForPlayer takes sound s, player p returns nothing
set bj_lastPlayedSound = s
if s != null and GetLocalPlayer() == p then
call StartSound(s)
endif
endfunction
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
function GetCircleNumber takes unit whatCircle returns integer
local integer a=1
loop
exitwhen a>40
if circle[a] == whatCircle then
return a
endif
set a=a+1
endloop
return 0
endfunction
//--------------------------------------------------------------------------------------------------
function IsBuyableCircleType takes unit u returns boolean
local integer nr = GetCircleNumber(u)
return (nr > 0 and nr != 1 and nr != 11)
endfunction
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
function GetAreaNumber takes unit whatCircle returns integer
local integer a=1
if not IsUnitInGroup(whatCircle, g_streetGroup) then
return 0
endif
loop // checking area number
exitwhen a>8
if IsUnitInGroup(whatCircle, g_colorArea[a]) then
exitwhen true
endif
set a=a+1
endloop
return a
endfunction
//---------------------------------------------------------------------
//---------------------------------------------------------------------
// return number of houses *or* returns 4 if hotel is constructed
function StreetCountBuildings takes integer circleNr returns integer
local integer count=0
if IsUnitInGroup(circle[circleNr], g_streetGroup) then
if not IsUnitHidden(house1[circleNr]) then
set count=count+1
endif
if not IsUnitHidden(house2[circleNr]) then
set count=count+1
endif
if not IsUnitHidden(house3[circleNr]) then
set count=count+1
endif
if (not IsUnitHidden(hotel[circleNr])) then
return 4
endif
endif
return count
endfunction
//---------------------------------------------------------------------
//---------------------------------------------------------------------
function CountStreetsOwnedByPlayerInArea_Enum takes nothing returns nothing
if GetOwningPlayer(GetEnumUnit()) == g_tempPlayer then
set g_tempInt = g_tempInt + 1
endif
endfunction
//---
function CountStreetsOwnedByPlayerInArea takes player p, integer areaNr returns integer
set g_tempInt = 0
set g_tempPlayer = p
call ForGroup(g_colorArea[areaNr], function CountStreetsOwnedByPlayerInArea_Enum)
return g_tempInt
endfunction
//---------------------------------------------------------------------
// if returns "true" then sets global g_districtOwningPlayer to player who owns whole district
function IsDistrictOwnedByPlayer takes integer areaNr returns boolean
local integer i0 = CountStreetsOwnedByPlayerInArea(Player(0), areaNr)
local integer i1 = CountStreetsOwnedByPlayerInArea(Player(1), areaNr)
local integer i2 = CountStreetsOwnedByPlayerInArea(Player(2), areaNr)
local integer i3 = CountStreetsOwnedByPlayerInArea(Player(3), areaNr)
if i0==3 then
set g_districtOwningPlayer = Player(0)
return true
elseif i1==3 then
set g_districtOwningPlayer = Player(1)
return true
elseif i2==3 then
set g_districtOwningPlayer = Player(2)
return true
elseif i3==3 then
set g_districtOwningPlayer = Player(3)
return true
endif
return false
endfunction
//---------------------------------------------------------------------
//---------------------------------------------------------------------
function DetectHumanSlotPlaying takes integer i returns boolean // *not* at map init , run at 0.10sec
return (GetPlayerController(Player(i))==MAP_CONTROL_USER) and (GetPlayerSlotState(Player(i))==PLAYER_SLOT_STATE_PLAYING)
//return (GetPlayerSlotState(Player(i))==PLAYER_SLOT_STATE_PLAYING)
endfunction
//---------------------------------------------------------------------
//---------------------------------------------------------------------
//TESH.scrollpos=138
//TESH.alwaysfold=0
function UpdateMBIcon takes integer circleNr returns nothing
local integer playerId = GetPlayerId(GetOwningPlayer(circle[circleNr]))
if circleNr > 0 and circleNr != 1 and circleNr != 11 then
if circleNr==2 then
call MultiboardSetItemIconBJ(udg_MBGame, 1, 10, g_mbIconPath[playerId])
elseif circleNr==3 then
call MultiboardSetItemIconBJ(udg_MBGame, 1, 9, g_mbIconPathCity[playerId])
elseif circleNr==4 then
call MultiboardSetItemIconBJ(udg_MBGame, 1, 8, g_mbIconPath[playerId])
elseif circleNr==5 then
call MultiboardSetItemIconBJ(udg_MBGame, 1, 7, g_mbIconPath[playerId])
elseif circleNr==6 then
call MultiboardSetItemIconBJ(udg_MBGame, 1, 6, g_mbIconPathCity[playerId])
elseif circleNr==7 then
call MultiboardSetItemIconBJ(udg_MBGame, 1, 5, g_mbIconPath[playerId])
elseif circleNr==8 then
call MultiboardSetItemIconBJ(udg_MBGame, 1, 4, g_mbIconPathCity[playerId])
elseif circleNr==9 then
call MultiboardSetItemIconBJ(udg_MBGame, 1, 3, g_mbIconPath[playerId])
elseif circleNr==10 then
call MultiboardSetItemIconBJ(udg_MBGame, 1, 2, g_mbIconPath[playerId])
elseif circleNr==12 then
call MultiboardSetItemIconBJ(udg_MBGame, 2, 1, g_mbIconPath[playerId])
elseif circleNr==13 then
call MultiboardSetItemIconBJ(udg_MBGame, 3, 1, g_mbIconPathCity[playerId])
elseif circleNr==14 then
call MultiboardSetItemIconBJ(udg_MBGame, 4, 1, g_mbIconPath[playerId])
elseif circleNr==15 then
call MultiboardSetItemIconBJ(udg_MBGame, 5, 1, g_mbIconPath[playerId])
elseif circleNr==16 then
call MultiboardSetItemIconBJ(udg_MBGame, 6, 1, g_mbIconPathCity[playerId])
elseif circleNr==17 then
call MultiboardSetItemIconBJ(udg_MBGame, 7, 1, g_mbIconPath[playerId])
elseif circleNr==18 then
call MultiboardSetItemIconBJ(udg_MBGame, 8, 1, g_mbIconPathCity[playerId])
elseif circleNr==19 then
call MultiboardSetItemIconBJ(udg_MBGame, 9, 1, g_mbIconPath[playerId])
elseif circleNr==20 then
call MultiboardSetItemIconBJ(udg_MBGame, 10, 1, g_mbIconPath[playerId])
elseif circleNr==21 then
call MultiboardSetItemIconBJ(udg_MBGame, 11, 1, g_mbIconPathCity[playerId])
elseif circleNr==22 then
call MultiboardSetItemIconBJ(udg_MBGame, 11, 2, g_mbIconPath[playerId])
elseif circleNr==23 then
call MultiboardSetItemIconBJ(udg_MBGame, 11, 3, g_mbIconPathCity[playerId])
elseif circleNr==24 then
call MultiboardSetItemIconBJ(udg_MBGame, 11, 4, g_mbIconPath[playerId])
elseif circleNr==25 then
call MultiboardSetItemIconBJ(udg_MBGame, 11, 5, g_mbIconPath[playerId])
elseif circleNr==26 then
call MultiboardSetItemIconBJ(udg_MBGame, 11, 6, g_mbIconPathCity[playerId])
elseif circleNr==27 then
call MultiboardSetItemIconBJ(udg_MBGame, 11, 7, g_mbIconPath[playerId])
elseif circleNr==28 then
call MultiboardSetItemIconBJ(udg_MBGame, 11, 8, g_mbIconPath[playerId])
elseif circleNr==29 then
call MultiboardSetItemIconBJ(udg_MBGame, 11, 9, g_mbIconPathCity[playerId])
elseif circleNr==30 then
call MultiboardSetItemIconBJ(udg_MBGame, 11, 10, g_mbIconPath[playerId])
elseif circleNr==31 then
call MultiboardSetItemIconBJ(udg_MBGame, 11, 11, g_mbIconPathCity[playerId])
elseif circleNr==32 then
call MultiboardSetItemIconBJ(udg_MBGame, 10, 11, g_mbIconPath[playerId])
elseif circleNr==33 then
call MultiboardSetItemIconBJ(udg_MBGame, 9, 11, g_mbIconPath[playerId])
elseif circleNr==34 then
call MultiboardSetItemIconBJ(udg_MBGame, 8, 11, g_mbIconPathCity[playerId])
elseif circleNr==35 then
call MultiboardSetItemIconBJ(udg_MBGame, 7, 11, g_mbIconPath[playerId])
elseif circleNr==36 then
call MultiboardSetItemIconBJ(udg_MBGame, 6, 11, g_mbIconPathCity[playerId])
elseif circleNr==37 then
call MultiboardSetItemIconBJ(udg_MBGame, 5, 11, g_mbIconPathCity[playerId])
elseif circleNr==38 then
call MultiboardSetItemIconBJ(udg_MBGame, 4, 11, g_mbIconPath[playerId])
elseif circleNr==39 then
call MultiboardSetItemIconBJ(udg_MBGame, 3, 11, g_mbIconPath[playerId])
elseif circleNr==40 then
call MultiboardSetItemIconBJ(udg_MBGame, 2, 11, g_mbIconPath[playerId])
endif
endif
endfunction
//-------------------------------------------------------------------
function UpdateMBAllIcons takes nothing returns nothing
local integer a=1
loop
exitwhen a>40
call UpdateMBIcon(a)
set a=a+1
endloop
endfunction
//-------------------------------------------------------------------
function UpdateMBMoney_Enum takes nothing returns nothing
local integer id = GetPlayerId(GetEnumPlayer())
local string amount = I2S(GetPlayerState(GetEnumPlayer(), PLAYER_STATE_RESOURCE_GOLD))
call MultiboardSetItemValueBJ(udg_MBGame, 1, (13+id), g_playerName[id] + "$" + amount)
set amount=null
endfunction
//---
function UpdateMBMoney takes nothing returns nothing
call ForForce(g_playersGroup, function UpdateMBMoney_Enum)
endfunction
//---------------------------------------------------------------------
//---------------------------------------------------------------------
//--------------- Clock ----------------------------------------------------------------------
function Clock takes nothing returns nothing
local integer min=0
local integer sec=0
local integer currTimer = R2I(TimerGetRemaining(udg_timerBankMeeting))
local string s=null
set ClockS0 = ClockS0 + 1
if ClockS0 == 10 then
set ClockS0 = 0
set ClockS1 = ClockS1 + 1
endif
if ClockS1 == 6 then
set ClockS0 = 0
set ClockS1 = 0
set ClockM0 = ClockM0 + 1
endif
if ClockM0 == 10 then
set ClockS0 = 0
set ClockS1 = 0
set ClockM0 = 0
set ClockM1 = ClockM1 + 1
endif
if ClockM1 == 6 then
set ClockS0 = 0
set ClockS1 = 0
set ClockM0 = 0
set ClockM1 = 0
set ClockH0 = ClockH0 + 1
endif
//update gold:
call UpdateMBMoney()
// time:
call MultiboardSetItemValueBJ(udg_MBGame, 1, 12, "|cff808080Game Time: " + I2S(ClockH0) + ":" + I2S(ClockM1) + I2S(ClockM0) + ":" + I2S(ClockS1) + I2S(ClockS0) + "|r")
set min = currTimer / 60
set sec = currTimer - (min*60)
set s = I2S(min) + ":" + I2S(sec)
if sec <10 then
set s = I2S(min) + ":0" + I2S(sec)
endif
call MultiboardSetItemValueBJ(udg_MBGame, 1, 17, "|cffffff00Bank Meeting: " + s + "|r")
set s=null
endfunction
//----------------------------------------------------------------------------------
function UpdateMB_PlayerLeft takes integer playerId returns nothing
call MultiboardSetItemValueBJ(udg_MBGame, 1, (13+playerId), " ")
endfunction
//---
function UpdateMB_PlayerBankrupt takes integer playerId, string s returns nothing
call MultiboardSetItemValueBJ(udg_MBGame, 1, (13+playerId), g_playerName[playerId] + ": " + s)
endfunction
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// run on events: build & sell building, for 4 players
function UpdateHousesHotels takes nothing returns nothing
local integer a=0
local integer array structures
local integer array hotels
local player p
local integer id
local integer i=0
//reset:
loop
exitwhen a>3
set structures[a] = 0
set hotels[a] = 0
set a=a+1
endloop
// detect:
set a=1
loop
exitwhen a>40
set p = GetOwningPlayer(circle[a])
set id = GetPlayerId(p)
set i = StreetCountBuildings(a)
if IsPlayerInForce(p, g_playersGroup) then
if i==4 then // =hotel
set structures[id] = structures[id] + 1
set hotels[id] = hotels[id] + 1
else
set structures[id] = structures[id] + i
endif
endif
set a=a+1
endloop
//set:
set a=0
loop
exitwhen a>3
call SetPlayerState(Player(a), PLAYER_STATE_RESOURCE_FOOD_CAP, structures[a]) // all structures
call SetPlayerState(Player(a), PLAYER_STATE_RESOURCE_FOOD_USED, hotels[a]) // hotel
set a=a+1
endloop
set p=null
endfunction
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// representing by lumber
function UpdateNrOfPlotsOwnedByPlayers takes nothing returns nothing // 4players + bank(8)
local integer a=1
local integer id
local integer array lumb
set lumb[0] = 0
set lumb[1] = 0
set lumb[2] = 0
set lumb[3] = 0
set lumb[GetPlayerId(BANK)] = 0
loop
exitwhen a>40
set id = GetPlayerId(GetOwningPlayer(circle[a]))
set lumb[id] = lumb[id] + 1
set a=a+1
endloop
//set new lumber values
call SetPlayerState(Player(0), PLAYER_STATE_RESOURCE_LUMBER, lumb[0])
call SetPlayerState(Player(1), PLAYER_STATE_RESOURCE_LUMBER, lumb[1])
call SetPlayerState(Player(2), PLAYER_STATE_RESOURCE_LUMBER, lumb[2])
call SetPlayerState(Player(3), PLAYER_STATE_RESOURCE_LUMBER, lumb[3])
call SetPlayerState(BANK, PLAYER_STATE_RESOURCE_LUMBER, lumb[GetPlayerId(BANK)])
endfunction
//-----------------------------------------------------------------------------
//g_owningState = 0.00 //no properties at all
//g_owningState = 0.50 //owns street
//g_owningState = 1.00 //owns 1 house
//g_owningState = 2.00 //owns 2 houses
//g_owningState = 3.00 //owns 3 houses
//g_owningState = 4.00 //owns hotel
function UpdatePlayerOwningState takes player p returns nothing
local integer id = GetPlayerId(p)
local integer hotels = GetPlayerState(p, PLAYER_STATE_RESOURCE_FOOD_USED) // hotel
local integer house1 = GetPlayerState(p, PLAYER_STATE_RESOURCE_FOOD_CAP) // all structures
local integer plots = GetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER)
local integer a=1
local integer i=0
set g_owningState[id] = 0.00 //reset
if hotels>0 then
set g_owningState[id] = 4.00
elseif house1>0 then
set g_owningState[id] = 1.00
elseif plots>0 then
set g_owningState[id] = 0.50
endif
if house1>0 then //look for 2 or 3 houses on property
loop
exitwhen a>40 or g_owningState[id]==3.00
if GetOwningPlayer(circle[a]) == p then
set i = StreetCountBuildings(a)
if g_owningState[id] < I2R(i) then
set g_owningState[id] = I2R(i)
endif
endif
set a=a+1
endloop
endif
//set req units:
if g_owningState[id] == 4.00 or g_owningState[id] == 3.00 then
call SetUnitOwner(g_requirementUnit1[id], p, false)
call SetUnitOwner(g_requirementUnit2[id], p, false)
call SetUnitOwner(g_requirementUnit3[id], p, false)
call SetUnitOwner(g_requirementUnit4[id], p, false)
elseif g_owningState[id] == 2.00 then
call SetUnitOwner(g_requirementUnit1[id], p, false)
call SetUnitOwner(g_requirementUnit2[id], p, false)
call SetUnitOwner(g_requirementUnit3[id], p, false)
call SetUnitOwner(g_requirementUnit4[id], Player(15), false)
elseif g_owningState[id] == 1.00 then
call SetUnitOwner(g_requirementUnit1[id], p, false)
call SetUnitOwner(g_requirementUnit2[id], p, false)
call SetUnitOwner(g_requirementUnit3[id], Player(15), false)
call SetUnitOwner(g_requirementUnit4[id], Player(15), false)
elseif g_owningState[id] == 0.50 then
call SetUnitOwner(g_requirementUnit1[id], p, false)
call SetUnitOwner(g_requirementUnit2[id], Player(15), false)
call SetUnitOwner(g_requirementUnit3[id], Player(15), false)
call SetUnitOwner(g_requirementUnit4[id], Player(15), false)
elseif g_owningState[id] == 0.00 then
call SetUnitOwner(g_requirementUnit1[id], Player(15), false)
call SetUnitOwner(g_requirementUnit2[id], Player(15), false)
call SetUnitOwner(g_requirementUnit3[id], Player(15), false)
call SetUnitOwner(g_requirementUnit4[id], Player(15), false)
endif
endfunction
//-----------------------------------------------------------------------------
function UpdateAllPlayersOwningState takes nothing returns nothing
local integer a=0
loop
exitwhen a>3
if IsPlayerInForce(Player(a), g_playersGroup) then
call UpdatePlayerOwningState(Player(a))
endif
set a=a+1
endloop
endfunction
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function SetTwoPlayersAlly takes integer p1, integer p2 returns nothing
call SetPlayerAlliance(Player(p1), Player(p2), ALLIANCE_PASSIVE, true)
call SetPlayerAlliance(Player(p1), Player(p2), ALLIANCE_HELP_REQUEST, true)
call SetPlayerAlliance(Player(p1), Player(p2), ALLIANCE_HELP_RESPONSE, true)
call SetPlayerAlliance(Player(p1), Player(p2), ALLIANCE_SHARED_XP, true)
call SetPlayerAlliance(Player(p1), Player(p2), ALLIANCE_SHARED_SPELLS, true)
call SetPlayerAlliance(Player(p1), Player(p2), ALLIANCE_SHARED_VISION, true)
call SetPlayerAlliance(Player(p1), Player(p2), ALLIANCE_SHARED_CONTROL, false)
call SetPlayerAlliance(Player(p1), Player(p2), ALLIANCE_SHARED_ADVANCED_CONTROL, false)
// ----- must be 2-sided-------
call SetPlayerAlliance(Player(p2), Player(p1), ALLIANCE_PASSIVE, true)
call SetPlayerAlliance(Player(p2), Player(p1), ALLIANCE_HELP_REQUEST, true)
call SetPlayerAlliance(Player(p2), Player(p1), ALLIANCE_HELP_RESPONSE, true)
call SetPlayerAlliance(Player(p2), Player(p1), ALLIANCE_SHARED_XP, true)
call SetPlayerAlliance(Player(p2), Player(p1), ALLIANCE_SHARED_SPELLS, true)
call SetPlayerAlliance(Player(p2), Player(p1), ALLIANCE_SHARED_VISION, true)
call SetPlayerAlliance(Player(p2), Player(p1), ALLIANCE_SHARED_CONTROL, false)
call SetPlayerAlliance(Player(p2), Player(p1), ALLIANCE_SHARED_ADVANCED_CONTROL, false)
endfunction
//-------------------------------------------------------------------
//-------------------------------------------------------------------------
function SetFloatTextOverUnit takes string s, unit u returns nothing
call CreateTextTagUnitBJ(s , u, 10.00, 12, 100.00, 100, 100.00, 0)
set udg_TempFloatingText = bj_lastCreatedTextTag
call SetTextTagVelocityBJ( udg_TempFloatingText, 64, 90 )
call SetTextTagPermanent( udg_TempFloatingText, false )
call SetTextTagLifespan( udg_TempFloatingText, 5 )
call SetTextTagFadepoint( udg_TempFloatingText, 2.50 )
endfunction
//-------------------------------------------------------------------
//-------------------------------------------------------------------
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_StartGame_Actions takes nothing returns nothing
local integer a=0
call SetPlayerState(BANK, PLAYER_STATE_RESOURCE_GOLD, 999999)
call EnablePreSelect( true, false )
loop
exitwhen a>3
call CreateFogModifierRectBJ(true, Player(a), FOG_OF_WAR_VISIBLE, bj_mapInitialPlayableArea)
if DetectHumanSlotPlaying(a) then
call ForceAddPlayer(g_playersGroup, Player(a))
set g_playersCount = g_playersCount + 1
else
call KillUnit(g_wisp[a])
endif
set a=a+1
endloop
set g_playerName[0] = "|cffff0000" + GetPlayerName(Player(0)) + " |r"
set g_playerName[1] = "|cff0000ff" + GetPlayerName(Player(1)) + " |r"
set g_playerName[2] = "|cff40e0d0" + GetPlayerName(Player(2)) + " |r"
set g_playerName[3] = "|cff800080" + GetPlayerName(Player(3)) + " |r"
call UpdateNrOfPlotsOwnedByPlayers()
endfunction
//==================================================
function InitTrig_MapLoaded takes nothing returns nothing
set gg_trg_MapLoaded = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_MapLoaded, 0.00 )
call TriggerAddAction( gg_trg_MapLoaded, function Trig_StartGame_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_FindModesPlayer_Actions takes nothing returns nothing
local integer a=0
loop
exitwhen a>3 or IsPlayerInForce(Player(a), g_playersGroup)
set a=a+1
endloop
call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS, 30.00, g_playerName[a] + " can choose game modes in 30sec.")
call DisplayTimedTextToPlayer(Player(a), 0.00, 0.00, 30.00, "Use 4 arrow keys.")
call TriggerRegisterPlayerEvent(gg_trg_ChooseModes, Player(a), EVENT_PLAYER_ARROW_DOWN_DOWN) //pressed
call TriggerRegisterPlayerEvent(gg_trg_ChooseModes, Player(a), EVENT_PLAYER_ARROW_UP_DOWN)
call TriggerRegisterPlayerEvent(gg_trg_ChooseModes, Player(a), EVENT_PLAYER_ARROW_LEFT_DOWN)
call TriggerRegisterPlayerEvent(gg_trg_ChooseModes, Player(a), EVENT_PLAYER_ARROW_RIGHT_DOWN)
call SetCameraTargetControllerNoZForPlayer( Player(a), gg_unit_H00M_0011, 0, 0, false )
endfunction
//==================================================================
function InitTrig_FindModesPlayer takes nothing returns nothing
set gg_trg_FindModesPlayer = CreateTrigger( )
call TriggerAddAction( gg_trg_FindModesPlayer, function Trig_FindModesPlayer_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
function Trig_UpDownArrows_Actions takes nothing returns nothing
local integer i = GetHandleId(GetTriggerEventId())
if i==265 then //DOWN
if g_currentRow < 6 then
set g_currentRow = g_currentRow + 1
call MultiboardSetItemStyleBJ(udg_MBMode, 1, (g_currentRow-1), false, false)
call MultiboardSetItemStyleBJ(udg_MBMode, 1, g_currentRow, false, true)
endif
elseif i==267 then //UP
if g_currentRow > 1 then
set g_currentRow = g_currentRow - 1
call MultiboardSetItemStyleBJ(udg_MBMode, 1, (g_currentRow+1), false, false)
call MultiboardSetItemStyleBJ(udg_MBMode, 1, g_currentRow, false, true)
endif
//---------------- LEFT --------------------------------------------------------------
elseif i==261 then //LEFT
if g_currentRow==1 then //starting money [1000 default]
set g_startingMoney_mb = g_startingMoney_mb - 100
if g_startingMoney_mb < 700 then
set g_startingMoney_mb = 700
endif
call MultiboardSetItemValueBJ(udg_MBMode, 3, 1, I2S(g_startingMoney_mb))
elseif g_currentRow==2 then // round time [40 defalut]
set g_turnTime_mb = g_turnTime_mb - 5.00
if g_turnTime_mb < 30.00 then
set g_turnTime_mb = 30.00
endif
call MultiboardSetItemValueBJ(udg_MBMode, 3, 2, I2S(R2I(g_turnTime_mb)))
elseif g_currentRow==3 then // bank meeting interval [8min defalut]
set g_bankMeetInterval_mb_min = g_bankMeetInterval_mb_min - 1
if g_bankMeetInterval_mb_min < 5 then // set5min
set g_bankMeetInterval_mb_min = 5
endif
call MultiboardSetItemValueBJ(udg_MBMode, 3, 3, I2S(g_bankMeetInterval_mb_min))
elseif g_currentRow==4 then // invitations interval [3 min default]
set g_invitationsInterval_mb = g_invitationsInterval_mb - 1
if g_invitationsInterval_mb < 2 then
set g_invitationsInterval_mb = 2
endif
call MultiboardSetItemValueBJ(udg_MBMode, 3, 4, I2S(g_invitationsInterval_mb))
elseif g_currentRow==5 then // accusations interval [4 min default]
set g_accusationsInterval_mb = g_accusationsInterval_mb - 1
if g_accusationsInterval_mb < 3 then
set g_accusationsInterval_mb = 3
endif
call MultiboardSetItemValueBJ(udg_MBMode, 3, 5, I2S(g_accusationsInterval_mb))
endif
//---------------- RIGHT --------------------------------------------------------------
elseif i==263 then //RIGHT
if g_currentRow==1 then //starting money [1000 default]
set g_startingMoney_mb = g_startingMoney_mb + 100
if g_startingMoney_mb > 2000 then
set g_startingMoney_mb = 2000
endif
call MultiboardSetItemValueBJ(udg_MBMode, 3, 1, I2S(g_startingMoney_mb))
elseif g_currentRow==2 then // round time [40 defalut]
set g_turnTime_mb = g_turnTime_mb + 5.00
if g_turnTime_mb > 60.00 then
set g_turnTime_mb = 60.00
endif
call MultiboardSetItemValueBJ(udg_MBMode, 3, 2, I2S(R2I(g_turnTime_mb)))
elseif g_currentRow==3 then // bank meeting interval [8min defalut]
set g_bankMeetInterval_mb_min = g_bankMeetInterval_mb_min + 1
if g_bankMeetInterval_mb_min > 15 then
set g_bankMeetInterval_mb_min = 15
endif
call MultiboardSetItemValueBJ(udg_MBMode, 3, 3, I2S(g_bankMeetInterval_mb_min))
elseif g_currentRow==4 then // invitations interval [3 min default]
set g_invitationsInterval_mb = g_invitationsInterval_mb + 1
if g_invitationsInterval_mb > 5 then
set g_invitationsInterval_mb = 5
endif
call MultiboardSetItemValueBJ(udg_MBMode, 3, 4, I2S(g_invitationsInterval_mb))
elseif g_currentRow==5 then // accusations interval [3 min default]
set g_accusationsInterval_mb = g_accusationsInterval_mb + 1
if g_accusationsInterval_mb > 5 then
set g_accusationsInterval_mb = 5
endif
call MultiboardSetItemValueBJ(udg_MBMode, 3, 5, I2S(g_accusationsInterval_mb))
elseif g_currentRow==6 then // FINISH
call TriggerExecute(gg_trg_ExecuteModes)
endif
endif
endfunction
//===========================================================================
function InitTrig_ChooseModes takes nothing returns nothing
set gg_trg_ChooseModes = CreateTrigger( )
call TriggerAddAction( gg_trg_ChooseModes, function Trig_UpDownArrows_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_ExecuteModes_Actions takes nothing returns nothing
local integer a=0
call DisableTrigger(GetTriggeringTrigger())
call DisableTrigger(gg_trg_ChooseModes)
call MultiboardDisplay(udg_MBMode, false)
call DestroyMultiboard(udg_MBMode)
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, "End modes settings.")
//move settings from multiboard mode to main globals settings
set g_startingMoney = g_startingMoney_mb
set g_turnTime = g_turnTime_mb
set g_bankMeetInterval = 60.00 * I2R(g_bankMeetInterval_mb_min)
set g_invitationsInterval = 60.00 * I2R(g_invitationsInterval_mb)
set g_accusationsInterval = 60.00 * I2R(g_accusationsInterval_mb)
loop
exitwhen a>3
call ResetToGameCameraForPlayer( Player(a), 0 )
call SetPlayerState(Player(a), PLAYER_STATE_RESOURCE_GOLD, g_startingMoney)
set a=a+1
endloop
call TimerStart(udg_timerBankMeeting, g_bankMeetInterval, false, null) // bank meeting
call TriggerExecute(gg_trg_ChooseCharacter)
endfunction
//==============================================================
function InitTrig_ExecuteModes takes nothing returns nothing
set gg_trg_ExecuteModes = CreateTrigger( )
call TriggerRegisterTimerExpireEventBJ( gg_trg_ExecuteModes, udg_timerModes )
call TriggerAddAction( gg_trg_ExecuteModes, function Trig_ExecuteModes_Actions )
endfunction
//TESH.scrollpos=10
//TESH.alwaysfold=0
//------------------------------------------------------------------------
//------------------------------------------------------------------------
function StartUpTheGame takes nothing returns nothing
local integer id
set g_playerActive = ForcePickRandomPlayer(g_playersGroup)
set id = GetPlayerId(g_playerActive)
call DestroyTimerDialog(g_timerWindow)
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, "Player " + g_playerName[id] + " will begin the game.")
//new
call TimerStart(g_timerTurn, g_turnTime, false, null)
set g_timerWindow = CreateTimerDialog(g_timerTurn)
call TimerDialogSetTitle(g_timerWindow, g_playerName[id])
call TimerDialogDisplay(g_timerWindow, true)
call UnitAddAbility(g_investor[id], ABI_IM_DONE)
call EnableUnitMovement(g_investor[id])
call SetUnitColor(FLAG, ConvertPlayerColor(id))
set g_isMyTurn[id] = true
call DisableTrigger(gg_trg_PlayerLeft)
call EnableTrigger(gg_trg_PlayerLeftGameStarted)
// multiboard
call TriggerExecute(gg_trg_NextMB)
call UpdateMBAllIcons()
call TimerStart(g_timerClock, 1.00, true, function Clock)
endfunction
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
function MoveUnusedCharacters_Enum takes nothing returns nothing
local unit u = GetEnumUnit()
call SetUnitOwner(u, Player(15), true)
call RemoveGuardPosition(u)
call SetUnitPosition(u, 3010.00, 0.00)
call SetUnitFacing(u, 45.00)
call GroupRemoveUnit(g_charactersGroup, u)
set u=null
endfunction
//------------------------------------------------------------------------
function SetInvestorPicture takes integer playerId returns nothing
local integer investorType = GetUnitTypeId(g_investor[playerId])
if investorType == 'H00J' then // Dave
set g_picture[playerId] = gg_unit_n00D_0087
elseif investorType == 'H00I' then // Luke
set g_picture[playerId] = gg_unit_n00G_0097
elseif investorType == 'H00K' then // Doc
set g_picture[playerId] = gg_unit_n00E_0086
elseif investorType == 'H00M' then // Oichi
set g_picture[playerId] = gg_unit_n00H_0178
elseif investorType == 'H00G' then // Rose
set g_picture[playerId] = gg_unit_n00I_0211
elseif investorType == 'H00W' then // Inquistor
set g_picture[playerId] = gg_unit_n00F_0096
endif
call SetUnitX(g_picture[playerId], g_pictureLocX[playerId])
call SetUnitY(g_picture[playerId], g_pictureLocY[playerId])
call ShowUnit(g_picture[playerId], true)
call UnitAddAbility(g_picture[playerId], 'Aloc')
endfunction
//------------------------------------------------------------------------
// on timer "startingTimer" 20sec expires
function TimeUpForCharacter takes nothing returns nothing
local integer a=0
loop
exitwhen a>3
if DetectHumanSlotPlaying(a) and g_investor[a]==null then
call KillUnit(g_wisp[a])
set g_investor[a] = GroupPickRandomUnit(g_charactersGroup)
call SetUnitOwner(g_investor[a], Player(a), true)
call SetUnitPosition(g_investor[a], GetUnitX(circle[1]), GetUnitY(circle[1]))
set g_investorPositionNr[a] = 1
call DisableUnitMovement(g_investor[a])
call GroupRemoveUnit(g_charactersGroup, g_investor[a])
call SetInvestorPicture(a)
endif
set a=a+1
endloop
call ForGroup(g_charactersGroup, function MoveUnusedCharacters_Enum)
call TimerStart(g_startingTimer, 5.00, false, function StartUpTheGame)
call TimerDialogSetTitle(g_timerWindow, "Game starts in ")
endfunction
//------------------------------------------------------------------------
//------------------------------------------------------------------------
function Trig_ChooseCharacter_Actions takes nothing returns nothing
local integer a=0
loop
exitwhen a>3
call SetUnitOwner(g_wisp[a], Player(a), true)
call SelectUnitForPlayerSingle(g_wisp[a], Player(a))
set a=a+1
endloop
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, "Choose your character.")
call TimerStart(g_startingTimer, 20.00, false, function TimeUpForCharacter)
set g_timerWindow = CreateTimerDialog(g_startingTimer)
call TimerDialogSetTitle(g_timerWindow, "Choose character")
call TimerDialogDisplay(g_timerWindow, true)
endfunction
//=============================================================
function InitTrig_ChooseCharacter takes nothing returns nothing
set gg_trg_ChooseCharacter = CreateTrigger( )
call TriggerAddAction( gg_trg_ChooseCharacter, function Trig_ChooseCharacter_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_WispCond takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == 'e000'
endfunction
// ---------------------------------------------------------------
function Trig_Select_CommonFunc takes unit u returns nothing
local integer id = GetPlayerId(GetOwningPlayer(u))
call KillUnit(u)
call SetUnitOwner(g_investor[id], Player(id), true)
call SetUnitPosition(g_investor[id], GetUnitX(circle[1]), GetUnitY(circle[1]))
call DisableUnitMovement(g_investor[id])
call GroupRemoveUnit(g_charactersGroup, g_investor[id])
set g_investorPositionNr[id] = 1
call SetUnitState(g_investor[id], UNIT_STATE_MANA, 1.00)
call SetInvestorPicture(id)
endfunction
// ---------------------------------------------------------------
// ---------------------------------------------------------------
function Trig_Select_1_Actions takes nothing returns nothing
local integer id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
set g_investor[id] = gg_unit_H00J_0091
call DisableTrigger(GetTriggeringTrigger())
call Trig_Select_CommonFunc(GetTriggerUnit())
endfunction
//---
function Trig_Select_2_Actions takes nothing returns nothing
local integer id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
set g_investor[id] = gg_unit_H00I_0090
call DisableTrigger(GetTriggeringTrigger())
call Trig_Select_CommonFunc(GetTriggerUnit())
endfunction
//---
function Trig_Select_3_Actions takes nothing returns nothing
local integer id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
set g_investor[id] = gg_unit_H00K_0092
call DisableTrigger(GetTriggeringTrigger())
call Trig_Select_CommonFunc(GetTriggerUnit())
endfunction
//---
function Trig_Select_4_Actions takes nothing returns nothing
local integer id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
set g_investor[id] = gg_unit_H00M_0011
call DisableTrigger(GetTriggeringTrigger())
call Trig_Select_CommonFunc(GetTriggerUnit())
endfunction
//---
function Trig_Select_5_Actions takes nothing returns nothing
local integer id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
set g_investor[id] = gg_unit_H00G_0061
call DisableTrigger(GetTriggeringTrigger())
call Trig_Select_CommonFunc(GetTriggerUnit())
endfunction
//---
function Trig_Select_6_Actions takes nothing returns nothing
local integer id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
set g_investor[id] = gg_unit_H00W_0095
call DisableTrigger(GetTriggeringTrigger())
call Trig_Select_CommonFunc(GetTriggerUnit())
endfunction
//======================================================
// run at map init
//======================================================
function InitTrig_SelectHero takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterUnitInRange(t, gg_unit_H00J_0091, 100.00, null)
call TriggerAddCondition(t, Condition( function Trig_WispCond))
call TriggerAddAction(t, function Trig_Select_1_Actions)
set t = CreateTrigger()
call TriggerRegisterUnitInRange(t, gg_unit_H00I_0090, 100.00, null)
call TriggerAddCondition(t, Condition( function Trig_WispCond))
call TriggerAddAction(t, function Trig_Select_2_Actions)
set t = CreateTrigger()
call TriggerRegisterUnitInRange(t, gg_unit_H00K_0092, 100.00, null)
call TriggerAddCondition(t, Condition( function Trig_WispCond))
call TriggerAddAction(t, function Trig_Select_3_Actions)
set t = CreateTrigger()
call TriggerRegisterUnitInRange(t, gg_unit_H00M_0011, 100.00, null)
call TriggerAddCondition(t, Condition( function Trig_WispCond))
call TriggerAddAction(t, function Trig_Select_4_Actions)
set t = CreateTrigger()
call TriggerRegisterUnitInRange(t, gg_unit_H00G_0061, 100.00, null)
call TriggerAddCondition(t, Condition( function Trig_WispCond))
call TriggerAddAction(t, function Trig_Select_5_Actions)
set t = CreateTrigger()
call TriggerRegisterUnitInRange(t, gg_unit_H00W_0095, 100.00, null)
call TriggerAddCondition(t, Condition( function Trig_WispCond))
call TriggerAddAction(t, function Trig_Select_6_Actions)
set t=null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_ShowModes_Actions takes nothing returns nothing
local player p = GetTriggerPlayer()
call DisplayTimedTextToPlayer(p, 0.00, 0.00, 15.00, "Starting money: |cffffa500$" + I2S(g_startingMoney) + "|r")
call DisplayTimedTextToPlayer(p, 0.00, 0.00, 15.00, "Round time: |cffffa500" + I2S(R2I(g_turnTime)) + "sec|r")
call DisplayTimedTextToPlayer(p, 0.00, 0.00, 15.00, "Bank meeting interval: |cffffa500" + I2S(R2I(g_bankMeetInterval/60.00)) + "min|r")
call DisplayTimedTextToPlayer(p, 0.00, 0.00, 15.00, "Invitations interval: |cffffa500" + I2S(R2I(g_invitationsInterval/60.00)) + "min|r")
call DisplayTimedTextToPlayer(p, 0.00, 0.00, 15.00, "Accusations interval: |cffffa500" + I2S(R2I(g_accusationsInterval/60.00)) + "min|r")
set p=null
endfunction
//============================================================
function InitTrig_ShowModes takes nothing returns nothing
set gg_trg_ShowModes = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_ShowModes, Player(0), "-modes", true )
call TriggerRegisterPlayerChatEvent( gg_trg_ShowModes, Player(1), "-modes", true )
call TriggerRegisterPlayerChatEvent( gg_trg_ShowModes, Player(2), "-modes", true )
call TriggerRegisterPlayerChatEvent( gg_trg_ShowModes, Player(3), "-modes", true )
call TriggerAddAction( gg_trg_ShowModes, function Trig_ShowModes_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_ShowCheapPub_Actions takes nothing returns nothing
call DisplayTextToForce( GetPlayersAll(), "Use Cheap Pub to send units to decrease opponents income." )
call TriggerSleepAction(2.00)
if GetLocalPlayer() == Player(0) then
call PingMinimap(GetUnitX(gg_unit_n003_0010), GetUnitY(gg_unit_n003_0010), 7.00)
endif
if GetLocalPlayer() == Player(1) then
call PingMinimap(GetUnitX(gg_unit_n003_0074), GetUnitY(gg_unit_n003_0074), 7.00)
endif
if GetLocalPlayer() == Player(2) then
call PingMinimap(GetUnitX(gg_unit_n003_0006), GetUnitY(gg_unit_n003_0006), 7.00)
endif
if GetLocalPlayer() == Player(3) then
call PingMinimap(GetUnitX(gg_unit_n003_0082), GetUnitY(gg_unit_n003_0082), 7.00)
endif
endfunction
//========================================================
function InitTrig_ShowCheapPub takes nothing returns nothing
set gg_trg_ShowCheapPub = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_ShowCheapPub, 100.00 )
call TriggerRegisterTimerEventSingle( gg_trg_ShowCheapPub, 240.00 )
call TriggerAddAction( gg_trg_ShowCheapPub, function Trig_ShowCheapPub_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
// numbers: 6, 26
function SetManaOnAllRailwayStations takes nothing returns nothing
local player owner1 = GetOwningPlayer(circle[6])
local player owner2 = GetOwningPlayer(circle[26])
call SetUnitState(circle[6], UNIT_STATE_MANA, 0.00)
call SetUnitState(circle[26], UNIT_STATE_MANA, 0.00)
if owner1 != BANK then
call SetUnitState(circle[6], UNIT_STATE_MANA, I2R(g_railwayStationRent1))
endif
if owner2 != BANK then
call SetUnitState(circle[26], UNIT_STATE_MANA, I2R(g_railwayStationRent1))
endif
if owner1 != BANK and (owner1 == owner2) then // double
call SetUnitState(circle[6], UNIT_STATE_MANA, I2R(g_railwayStationRent2))
call SetUnitState(circle[26], UNIT_STATE_MANA, I2R(g_railwayStationRent2))
endif
set owner1 = null
set owner2 = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
//------------------------------------------------------------------------------
// numbers: 18, 37, 16, 36
function SetManaOnFactoryCasinoLawFirms takes integer nr returns nothing
call SetUnitState(circle[nr], UNIT_STATE_MANA, 0.00)
if GetOwningPlayer(circle[nr]) != BANK then
call SetUnitState(circle[nr], UNIT_STATE_MANA, I2R(rent[nr]))
endif
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
//------------------------------------------------------------------------------
// numbers: 21-supermarket, 31-restaurant
function SetManaOnAllMarkets takes nothing returns nothing
local player ownerSupermarket = GetOwningPlayer(circle[21])
local player ownerRestaurant = GetOwningPlayer(circle[31])
call SetUnitState(circle[21], UNIT_STATE_MANA, 0.00)
call SetUnitState(circle[31], UNIT_STATE_MANA, 0.00)
if ownerSupermarket != BANK then //supermarket
call SetUnitState(circle[21], UNIT_STATE_MANA, I2R(g_supermarketRent1))
endif
if ownerRestaurant != BANK then // restaurant
call SetUnitState(circle[31], UNIT_STATE_MANA, I2R(g_restaurantRent1))
endif
if ownerSupermarket != BANK and (ownerSupermarket == ownerRestaurant) then // double
call SetUnitState(circle[21], UNIT_STATE_MANA, I2R(g_supermarketRent2))
call SetUnitState(circle[31], UNIT_STATE_MANA, I2R(g_restaurantRent2))
endif
set ownerSupermarket = null
set ownerRestaurant = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
// ----------------------------------------------------------------------
// police municipale [3], police [8], power station [13]
// fire dept [23], water supply [29], hospital [34]
// g_colorArea[10]
// ----------------------------------------------------------------------
function IsCircleCityServices takes integer nr returns boolean
return IsUnitInGroup(circle[nr], g_colorArea[10])
endfunction
//-----------------------------------------------------------------------
function SetManaOnCityService takes integer nr returns nothing
call SetUnitState(circle[nr], UNIT_STATE_MANA, 0.00)
if GetOwningPlayer(circle[nr]) != BANK then
call SetUnitState(circle[nr], UNIT_STATE_MANA, I2R(rent[nr]))
endif
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
// run on events: mortgage, unmortgage, buying
function SetManaOnStreet takes integer nr returns nothing
local integer structures = StreetCountBuildings(nr)
if not IsUnitInGroup(circle[nr], g_streetGroup) then
return
endif
call SetUnitState(circle[nr], UNIT_STATE_MANA, 0.00)
if GetOwningPlayer(circle[nr]) != BANK then
call SetUnitState(circle[nr], UNIT_STATE_MANA, I2R(rent[nr]))
if structures==1 then //count structures
call SetUnitState(circle[nr], UNIT_STATE_MANA, I2R(rent1h[nr]))
elseif structures==2 then
call SetUnitState(circle[nr], UNIT_STATE_MANA, I2R(rent2h[nr]))
elseif structures==3 then
call SetUnitState(circle[nr], UNIT_STATE_MANA, I2R(rent3h[nr]))
elseif structures==4 then //hotel
call SetUnitState(circle[nr], UNIT_STATE_MANA, I2R(rentH[nr]))
endif
endif
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
// police municipale [3], police [8], power station [13]
// fire dept [23], water supply [29], hospital [34]
// and :
// supermarket [21], restaurant [31]
function IsCircleDefendingFromAttacker takes integer circleNr returns boolean
return IsCircleCityServices(circleNr) or circleNr==21 or circleNr==31
endfunction
function IsPlayerImmuneTo_Attacker takes player p, integer attackerId returns boolean
if attackerId == PYROMANIAC then // FireDept or Hospital
return GetOwningPlayer(circle[23]) == p or GetOwningPlayer(circle[34]) == p
elseif attackerId == THIEF then // PoliceStation or PoliceMunicipale
return GetOwningPlayer(circle[8]) == p or GetOwningPlayer(circle[3]) == p
elseif attackerId == SERVICEMAN then // PowerStation or WaterSupply
return GetOwningPlayer(circle[13]) == p or GetOwningPlayer(circle[29]) == p
elseif attackerId == OVERDUE_FOOD then // Supermarket or Restaurant
return GetOwningPlayer(circle[21]) == p or GetOwningPlayer(circle[31]) == p
endif
return false
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
//------------------------------------------------------------------------------------------
//update circle mana depends on attakers (remove item if player is immune to this attacker)
function UpdateAttackersOnCircle takes integer nr returns nothing
local player circleOwner = GetOwningPlayer(circle[nr])
local integer servicemanQuantity = GetItemCharges(UnitItemInSlot(circle[nr], 2))
local integer overduefoodQuantity = GetItemCharges(UnitItemInSlot(circle[nr], 3))
local integer thiefQuantity = GetItemCharges(UnitItemInSlot(circle[nr], 4))
local integer pyromaniacQuantity = GetItemCharges(UnitItemInSlot(circle[nr], 5))
//serviceman:
if servicemanQuantity>0 then
if IsPlayerImmuneTo_Attacker(circleOwner, SERVICEMAN) then
call RemoveItem(UnitItemInSlot(circle[nr], 2))
else
loop
exitwhen servicemanQuantity==0
call SetUnitState(circle[nr], UNIT_STATE_MANA, GetUnitState(circle[nr], UNIT_STATE_MANA)*g_amountServiceman)
set servicemanQuantity = servicemanQuantity - 1
endloop
endif
endif
//overdue food:
if overduefoodQuantity>0 then
if IsPlayerImmuneTo_Attacker(circleOwner, OVERDUE_FOOD) then
call RemoveItem(UnitItemInSlot(circle[nr], 3))
else
loop
exitwhen overduefoodQuantity==0
call SetUnitState(circle[nr], UNIT_STATE_MANA, GetUnitState(circle[nr], UNIT_STATE_MANA)*g_amountOverdueFood)
set overduefoodQuantity = overduefoodQuantity - 1
endloop
endif
endif
//thief:
if thiefQuantity>0 then
if IsPlayerImmuneTo_Attacker(circleOwner, THIEF) then
call RemoveItem(UnitItemInSlot(circle[nr], 4))
else
loop
exitwhen thiefQuantity==0
call SetUnitState(circle[nr], UNIT_STATE_MANA, GetUnitState(circle[nr], UNIT_STATE_MANA)*g_amountThief)
set thiefQuantity = thiefQuantity - 1
endloop
endif
endif
// pyromaniac:
if pyromaniacQuantity>0 then
if IsPlayerImmuneTo_Attacker(circleOwner, PYROMANIAC) then
call RemoveItem(UnitItemInSlot(circle[nr], 5))
else
loop
exitwhen pyromaniacQuantity==0
call SetUnitState(circle[nr], UNIT_STATE_MANA, GetUnitState(circle[nr], UNIT_STATE_MANA)*g_amountPyromaniac)
set pyromaniacQuantity = pyromaniacQuantity - 1
endloop
endif
endif
set circleOwner=null
endfunction
//========================================================
function UpdateCircleMana takes unit whatCircle returns nothing
local integer nr = GetCircleNumber(whatCircle)
if (nr==6 or nr==26) then //2 railway stations
call SetManaOnAllRailwayStations()
elseif (nr==18 or nr==37 or nr==16 or nr==36) then // factory[18], Casino[37], LawFirms [16], [36]
call SetManaOnFactoryCasinoLawFirms(nr)
elseif (nr==21 or nr==31) then // 21-supermarket, 31-restaurant
call SetManaOnAllMarkets()
//police municipale [3], police [8], power station [13], fire dept [23], water supply [29], hospital [34]
elseif IsCircleCityServices(nr) then
call SetManaOnCityService(nr)
elseif IsUnitInGroup(whatCircle, g_streetGroup) then // streets
call SetManaOnStreet(nr) //setting mana but ignoring attackers
call UpdateAttackersOnCircle(nr)
endif
endfunction
//========================================================
//========================================================
function UpdateManaOnPlayerAllCircles takes player p returns nothing
local integer a=1
loop
exitwhen a>40
if GetOwningPlayer(circle[a])==p then
call UpdateCircleMana(circle[a])
endif
set a=a+1
endloop
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
//------------------------------------------------------------------------
function SetCircleOwner takes unit whatCircle, player playerOwner returns nothing
local integer nr = GetCircleNumber(whatCircle)
call SetUnitOwner(whatCircle, playerOwner, true)
//---
call UpdateCircleMana(whatCircle)
//---
call UpdateMBIcon(nr)
call UpdateNrOfPlotsOwnedByPlayers()
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_CheckOrder_Actions takes nothing returns nothing
local integer h = GetHandleId(GetTriggerEventId())
local integer ord = GetIssuedOrderId()
if h==38 then
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, "instant " + I2S(ord) + ", " + OrderId2StringBJ(ord))
elseif h==39 then
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, "point " + I2S(ord) + ", " + OrderId2StringBJ(ord))
elseif h==40 then
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, "target " + I2S(ord) + ", " + OrderId2StringBJ(ord))
endif
endfunction
//===========================================================================
function InitTrig_CheckOrder takes nothing returns nothing
set gg_trg_CheckOrder = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_CheckOrder, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerRegisterAnyUnitEventBJ( gg_trg_CheckOrder, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
call TriggerRegisterAnyUnitEventBJ( gg_trg_CheckOrder, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerAddAction( gg_trg_CheckOrder, function Trig_CheckOrder_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
//============================================
function Trig_Ticket_Conditions takes nothing returns boolean
local unit c = GetSpellAbilityUnit() //railway station circle
local unit t = GetSpellTargetUnit()
local player p = GetOwningPlayer(c) //caster
local integer id = GetPlayerId(p)
local integer ok = 0
if GetSpellAbilityId() == ABI_BUY_TICKET then
set ok=1
if not (t==g_investor[id]) then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Please target your Investor.|r")
set ok=0
endif
if not (GetOwningPlayer(circle[6]) == p and GetOwningPlayer(circle[26]) == p) then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072You must own both Railway Station.|r")
set ok=0
endif
if GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) < g_cost_Ticket then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Not enough money ($" + I2S(g_cost_Ticket) + ").|r")
set ok=0
endif
endif
set c=null
set t=null
set p=null
return ok==1
endfunction
//-----------------------------------------------------------------------
function Trig_Ticket_Actions takes nothing returns nothing
local unit t = GetSpellTargetUnit() // my investor
local player p = GetOwningPlayer(t)
local integer id = GetPlayerId(p)
local integer nr = GetCircleNumber(GetSpellAbilityUnit())
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) - g_cost_Ticket)
//move investor:
if nr==6 then
set g_investorPositionNr[id] = 26
call SetUnitPosition(t, GetUnitX(circle[26]), GetUnitY(circle[26]))
call SetUnitState(t, UNIT_STATE_MANA, I2R(26))
elseif nr==26 then
set g_investorPositionNr[id] = 6
call SetUnitPosition(t, GetUnitX(circle[6]), GetUnitY(circle[6]))
call SetUnitState(t, UNIT_STATE_MANA, I2R(6))
endif
call PingMinimapForPlayer(p, GetUnitX(t), GetUnitY(t), 3.00)
call DisplayTextToPlayer(p, 0.00, 0.00, "Investor moved.")
set t=null
set p=null
endfunction
//=============================================================
function InitTrig_RailwayStationTicket takes nothing returns nothing
set gg_trg_RailwayStationTicket = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_RailwayStationTicket, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_RailwayStationTicket, Condition( function Trig_Ticket_Conditions ) )
call TriggerAddAction( gg_trg_RailwayStationTicket, function Trig_Ticket_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Casino_Conditions takes nothing returns boolean
local integer spell = GetSpellAbilityId()
return spell==ABI_BUY_LOTTERY_1 or spell==ABI_BUY_LOTTERY_10 or spell==ABI_BUY_LOTTERY_100
endfunction
//---------------------
function Trig_Casino_Actions takes nothing returns nothing
local integer spell = GetSpellAbilityId()
local player p = GetOwningPlayer(GetSpellAbilityUnit())
local integer money = GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD)
if spell==ABI_BUY_LOTTERY_1 then
if g_lotteryCost1 <= money then
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) - g_lotteryCost1)
if GetRandomInt(1, 100) < g_lotteryChance1 then
call DisplayTextToPlayer(p, 0.00, 0.00, "You won $" + I2S(g_lotteryWin1) + " !")
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) + g_lotteryWin1)
else
call DisplayTextToPlayer(p, 0.00, 0.00, "You lose. Sorry.")
endif
else
call DisplayTextToPlayer(p, 0.00, 0.00, "Not enough money: $" + I2S(g_lotteryCost1))
endif
elseif spell==ABI_BUY_LOTTERY_10 then
if g_lotteryCost10 <= money then
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) - g_lotteryCost10)
if GetRandomInt(1, 100) < g_lotteryChance10 then
call DisplayTextToPlayer(p, 0.00, 0.00, "You won $" + I2S(g_lotteryWin10) + " !")
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) + g_lotteryWin10)
else
call DisplayTextToPlayer(p, 0.00, 0.00, "You lose. Sorry.")
endif
else
call DisplayTextToPlayer(p, 0.00, 0.00, "Not enough money: $" + I2S(g_lotteryCost10))
endif
elseif spell==ABI_BUY_LOTTERY_100 then
if g_lotteryCost100 <= money then
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) - g_lotteryCost100)
if GetRandomInt(1, 100) < g_lotteryChance100 then
call DisplayTextToPlayer(p, 0.00, 0.00, "You won $" + I2S(g_lotteryWin100) + " !")
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) + g_lotteryWin100)
else
call DisplayTextToPlayer(p, 0.00, 0.00, "You lose. Sorry.")
endif
else
call DisplayTextToPlayer(p, 0.00, 0.00, "Not enough money: $" + I2S(g_lotteryCost100))
endif
endif
set p=null
endfunction
//======================================================
function InitTrig_Casino takes nothing returns nothing
set gg_trg_Casino = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Casino, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Casino, Condition( function Trig_Casino_Conditions ) )
call TriggerAddAction( gg_trg_Casino, function Trig_Casino_Actions )
endfunction
//TESH.scrollpos=25
//TESH.alwaysfold=0
//============================================
// Investor slot 4 reserved for Item Cloaking Device
function Trig_Cloak_Conditions takes nothing returns boolean
local player p = GetOwningPlayer(GetSpellAbilityUnit()) //factory owner
local integer id = GetPlayerId(p)
local integer ok = 0
if GetSpellAbilityId() == ABI_PRODUCE_DEVICE then
set ok=1
if not (GetPlayerUnitTypeCount(p, DEVICE_FLAG) < 1) then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: You reach Cloaking Devices limit(1). Wait few minutes to produce next.|r")
set ok=0
endif
if GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) < g_cost_CloakingDevice then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Not enough money ($" + I2S(g_cost_CloakingDevice) + ").|r")
set ok=0
endif
if UnitItemInSlot(g_investor[id], 4) != null then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: You cannot produce next Device until you use old one.|r")
set ok=0
endif
endif
set p=null
return ok==1
endfunction
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
function Trig_Cloak_Actions takes nothing returns nothing
local player p = GetOwningPlayer(GetSpellAbilityUnit()) //factory owner
local integer id = GetPlayerId(p)
local location loc = GetRandomLocInRect(gg_rct_RegCloakingDevice)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) - g_cost_CloakingDevice)
set bj_lastCreatedUnit = CreateUnitAtLoc(p, DEVICE_FLAG, loc, 0.00)
call UnitApplyTimedLife(bj_lastCreatedUnit, 'BTLF', 300.00) //5min <---
if UnitItemInSlot(g_investor[id], 4)==null then
call UnitAddItemToSlotById(g_investor[id], ITEM_CLOAKING_DEVICE, 4)
endif
call DisplayTextToPlayer(p, 0.00, 0.00, "Investor has received Cloaking Device item.")
call RemoveLocation(loc)
set loc=null
set p=null
endfunction
//=============================================================
function InitTrig_FactoryCloakingDevice takes nothing returns nothing
set gg_trg_FactoryCloakingDevice = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_FactoryCloakingDevice, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_FactoryCloakingDevice, Condition( function Trig_Cloak_Conditions ) )
call TriggerAddAction( gg_trg_FactoryCloakingDevice, function Trig_Cloak_Actions )
endfunction
//TESH.scrollpos=5
//TESH.alwaysfold=0
//============================================
function Trig_blink_Conditions takes nothing returns boolean
local player p = GetOwningPlayer(GetSpellAbilityUnit())
local integer id = GetPlayerId(p)
local integer nr = R2I(GetUnitState(g_investor[id], UNIT_STATE_MANA)) // current investor loc
local unit t = GetSpellTargetUnit()
local integer ok = 0
if GetSpellAbilityId() == ABI_BLINK then
set ok=1
if not (IsBuyableCircleType(t) and (GetCircleNumber(t) != nr)) then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Please target property other then " + I2S(nr) + "|r")
set ok=0
endif
if g_statusInJail[id] > 0 then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Investor is in jail.|r")
set ok=0
endif
endif
set p=null
set t=null
return ok==1
endfunction
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
function Trig_blink_Actions takes nothing returns nothing
local player p = GetOwningPlayer(GetSpellAbilityUnit())
local integer id = GetPlayerId(p)
local unit t = GetSpellTargetUnit()
local integer targetNr = GetCircleNumber(t)
set g_investorPositionNr[id] = targetNr
call SetUnitPosition(g_investor[id], GetUnitX(t), GetUnitY(t))
call SetUnitState(g_investor[id], UNIT_STATE_MANA, I2R(targetNr))
call UnitRemoveAbility(g_investor[id], ABI_BLINK)
call DisplayTextToPlayer(p, 0.00, 0.00, "Investor moved.")
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, g_playerName[id] + " used a Blink ability.")
set t=null
set p=null
endfunction
//=============================================================
function InitTrig_Blink takes nothing returns nothing
set gg_trg_Blink = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Blink, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Blink, Condition( function Trig_blink_Conditions ) )
call TriggerAddAction( gg_trg_Blink, function Trig_blink_Actions )
endfunction
//TESH.scrollpos=84
//TESH.alwaysfold=0
//-----------------------------------------------------------------------
function IsInvitedInvestorInHotel takes nothing returns nothing
local integer nr = GetItemCharges(UnitItemInSlot(g_investor[g_invitedPlayerId], 1)) //circle number where hotel is
local integer player2Id = GetPlayerId(GetOwningPlayer(circle[nr]))
local integer endThis = 0
if g_statusBankrupt[player2Id] or g_statusLeft[player2Id] then // inviting player
set endThis=1
elseif g_statusBankrupt[g_invitedPlayerId] or g_statusLeft[g_invitedPlayerId] then // invited player
set endThis=1
elseif g_statusInJail[g_invitedPlayerId] > 0 then // invited player in jail
set endThis=1
// elseif RectContainsUnit(g_rect[nr], g_investor[g_invitedPlayerId]) then
elseif IsUnitInRange(g_investor[g_invitedPlayerId], circle[nr], 120.00) then
set endThis=1
endif
if endThis==1 then
if (not g_statusBankrupt[g_invitedPlayerId]) and (not g_statusLeft[g_invitedPlayerId]) then
call SetUnitOwner(g_investor[g_invitedPlayerId], Player(g_invitedPlayerId), false)
call IssueImmediateOrder(g_investor[g_invitedPlayerId], "stop")
endif
call RemoveItem(UnitItemInSlot(g_investor[g_invitedPlayerId], 1))
call PauseTimer(g_timerInvitationInProgress)
endif
endfunction
//-----------------------------------------------------------------------
// --- it is executed in trigger gg_trg_NextPlayerActions: ---
//-----------------------------------------------------------------------
function InvitedInvestor_StartMove takes nothing returns nothing
local integer playerId = GetPlayerId(g_playerActive)
local integer nr = GetItemCharges(UnitItemInSlot(g_investor[playerId], 1)) //circle number where hotel is
call SetUnitOwner(g_investor[playerId], Player(PLAYER_NEUTRAL_PASSIVE), false)
call RemoveGuardPosition(g_investor[playerId])
call IssueTargetOrder(g_investor[playerId], "move", circle[nr])
call DisplayTextToPlayer(g_playerActive, 0.00, 0.00, "You won't be able to control your Investor, while he moves to the Hotel.")
set g_invitedPlayerId = playerId
call TimerStart(g_timerInvitationInProgress, 1.00, true, function IsInvitedInvestorInHotel)
endfunction
//-----------------------------------------------------------------------
//============================================
//============================================
function Trig_Invitation_Conditions takes nothing returns boolean
local unit c = GetSpellAbilityUnit() //circle
local unit t = GetSpellTargetUnit()
local player p = GetOwningPlayer(c) //caster
local integer id = GetPlayerId(p)
local integer nr = GetCircleNumber(c)
local integer ok=0
if GetSpellAbilityId() == ABI_INVITATION then
set ok=1
if not ((t==g_investor[0] or t==g_investor[1] or t==g_investor[2] or t==g_investor[3]) and (p != GetOwningPlayer(t))) then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Please target other player's Investor.|r")
set ok=0
endif
if not (StreetCountBuildings(nr)==4) then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Build a Hotel to use invitation.|r")
set ok=0
endif
if not (UnitItemInSlot(t, 1) == null) then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Targeted Investor is already invited.|r")
set ok=0
endif
if not (GetPlayerUnitTypeCount(p, MESSENGER) < 2) then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: You reach invitations limit(2). Wait few minutes to send next invitation.|r")
set ok=0
endif
if GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) < g_cost_Invitation then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Not enough money ($" + I2S(g_cost_Invitation) + ").|r")
set ok=0
endif
endif
set c=null
set t=null
set p=null
return ok==1
endfunction
//-----------------------------------------------------------------------
//--- hero slot number "1" reserved for item invitation !
function Trig_Invitation_Actions takes nothing returns nothing
local unit t = GetSpellTargetUnit()
local player p = GetOwningPlayer(GetSpellAbilityUnit()) //caster, circle owner
local integer id = GetPlayerId(p)
local player p1 = GetOwningPlayer(t)
local integer nr = GetCircleNumber(GetSpellAbilityUnit())
local location loc = GetRandomLocInRect(g_rectResting[id])
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) - g_cost_Invitation)
set bj_lastCreatedUnit = CreateUnitAtLoc(p, MESSENGER, loc, GetRandomReal(0.00, 360.00))
call UnitApplyTimedLife(bj_lastCreatedUnit, 'BTLF', g_invitationsInterval)
//---
call UnitAddItemToSlotById(t, ITEM_INVITATION, 1)
call SetItemCharges(UnitItemInSlot(t, 1), nr)
call DisplayTextToPlayer(p, 0.00, 0.00, "You just invited " + g_playerName[GetPlayerId(p1)] + " to hotel on street nr " + I2S(nr))
call DisplayTextToPlayer(p1, 0.00, 0.00, "You have been invited by " + g_playerName[id] + " to hotel on street nr " + I2S(nr))
call PlaySoundForPlayer(gg_snd_Rescue, p1)
//---
call RemoveLocation(loc)
set loc=null
set t=null
set p=null
set p1=null
endfunction
//=============================================================
function InitTrig_Invitation takes nothing returns nothing
set gg_trg_Invitation = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Invitation, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Invitation, Condition( function Trig_Invitation_Conditions ) )
call TriggerAddAction( gg_trg_Invitation, function Trig_Invitation_Actions )
endfunction
//TESH.scrollpos=64
//TESH.alwaysfold=0
// investor slot "2" reserved for item "Accusation", ITEM_ACCUSATION
function Trig_Sue_Cond takes nothing returns boolean
local unit c = GetSpellAbilityUnit() //law-firm circle
local player p = GetOwningPlayer(c) //law-firm caster
local integer id = GetPlayerId(p)
local integer nr = GetCircleNumber(c)
local unit t = GetSpellTargetUnit()
local player p1 = GetOwningPlayer(t) //player target
local integer ok=0
if GetSpellAbilityId() == ABI_SUE then
set ok=1
if not ((t==g_investor[0] or t==g_investor[1] or t==g_investor[2] or t==g_investor[3]) and (p != p1)) then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Please target other player's Investor.|r")
set ok=0
endif
if (GetOwningPlayer(circle[16])==p1 or GetOwningPlayer(circle[36])==p1) then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Cannot target player who owns Law Firm.|r")
set ok=0
endif
if g_statusInJail[GetPlayerId(p1)] > 0 then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Targeted Investor is in jail.|r")
set ok=0
endif
if not (UnitItemInSlot(t, 2) == null) then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Investor is already accused.|r")
set ok=0
endif
if not (GetPlayerUnitTypeCount(p, LAWSUIT_FLAG) < 1) then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: You reach accusations limit(1). Wait few minutes to execute next.|r")
set ok=0
endif
if GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) < g_cost_Sue then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Not enough money ($" + I2S(g_cost_Sue) + ").|r")
set ok=0
endif
endif
set c=null
set t=null
set p=null
return ok==1
endfunction
//----------------------------------------------------------------------
//----------------------------------------------------------------------
function SueInvestor_End takes nothing returns nothing
local integer playerId = GetPlayerId(g_playerActive) // victim
local integer nr = GetItemCharges(UnitItemInSlot(g_investor[playerId], 2)) //caster player id (GUI!)
local integer id = nr - 1 // player caster id
local player caster = Player(id)
local integer chance = 0
call RemoveItem(UnitItemInSlot(g_investor[playerId], 2))
if (not g_statusBankrupt[playerId]) and (not g_statusLeft[playerId]) then
call SetUnitOwner(g_investor[playerId], g_playerActive, false)
endif
// calculate chance:
if GetOwningPlayer(circle[16])==g_playerActive or GetOwningPlayer(circle[36])==g_playerActive then
set chance = 0 // victim defend
elseif GetOwningPlayer(circle[16])==caster and GetOwningPlayer(circle[36])==caster then //both
set chance = 80
elseif GetOwningPlayer(circle[16])==caster or GetOwningPlayer(circle[36])==caster then //both
set chance = 60
else // caster lost LawFirm in meantime
set chance = 0
endif
if g_statusBankrupt[playerId] or g_statusLeft[playerId] or g_statusInJail[playerId]>0 then // accused player
set chance = 0
elseif g_statusBankrupt[id] or g_statusLeft[id] or g_statusInJail[id]>0 then // caster player
set chance = 0
endif
if GetRandomInt(1,100) < chance then
set g_investorPositionNr[playerId] = 11
set g_statusInJail[playerId] = 3
call SetUnitPosition(g_investor[playerId], GetUnitX(circle[11]), GetUnitY(circle[11]))
call SetUnitState(g_investor[playerId], UNIT_STATE_MANA, I2R(11))
call SetItemCharges(UnitItemInSlot(g_investor[playerId], 3), GetItemCharges(UnitItemInSlot(g_investor[playerId], 3)) + 1)
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, g_playerName[playerId] + " was convicted! (for 2 game rounds)")
call TriggerExecute(gg_trg_TimerTurnExpires) // <----
else
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, g_playerName[playerId] + " was acquitted!")
endif
set caster=null
endfunction
//----------------------------------------------------------------------
// --- "SueInvestor_Start" is executed in trigger gg_trg_NextPlayerActions: ---
//-----------------------------------------------------------------------
function SueInvestor_Start takes nothing returns nothing
local integer playerId = GetPlayerId(g_playerActive) // victim
call SetUnitOwner(g_investor[playerId], Player(PLAYER_NEUTRAL_PASSIVE), false)
call TimerStart(g_timerJudgment, 3.00, false, function SueInvestor_End)
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, g_playerName[playerId] + " is waiting for judgment..")
endfunction
//----------------------------------------------------------------------
function Trig_Sue_Actions takes nothing returns nothing
local unit c = GetSpellAbilityUnit() // circle Law-Firm
local player p = GetOwningPlayer(c) //caster, circle owner
local integer id = GetPlayerId(p)
local unit t = GetSpellTargetUnit() // target investor
local player p1 = GetOwningPlayer(t) // targeted player
local integer nr = GetCircleNumber(c)
local location loc = GetRandomLocInRect(g_rectResting[id])
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) - g_cost_Sue)
set bj_lastCreatedUnit = CreateUnitAtLoc(p, LAWSUIT_FLAG, loc, GetRandomReal(0.00, 360.00))
call UnitApplyTimedLife(bj_lastCreatedUnit, 'BTLF', g_accusationsInterval)
// investor slot "2" reserved for item "Accusation", ITEM_ACCUSATION
call UnitAddItemToSlotById(t, ITEM_ACCUSATION, 2)
call SetItemCharges(UnitItemInSlot(t, 2), id+1) // to remember caster player id
call DisplayTextToPlayer(p, 0.00, 0.00, "You just accused " + g_playerName[GetPlayerId(p1)])
call DisplayTextToPlayer(p1, 0.00, 0.00, "You have been accused of financial fraud by " + g_playerName[id])
call PlaySoundForPlayer(gg_snd_BattlenetDeath1, p1)
//---
endfunction
//=========================================================
function InitTrig_Sue takes nothing returns nothing
set gg_trg_Sue = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Sue, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Sue, Condition( function Trig_Sue_Cond ) )
call TriggerAddAction( gg_trg_Sue, function Trig_Sue_Actions )
endfunction
//TESH.scrollpos=1
//TESH.alwaysfold=0
//============================================
function Trig_Pyro_Conditions takes nothing returns boolean
local unit c = GetSpellAbilityUnit() //circle
local unit t = GetSpellTargetUnit()
local player p = GetOwningPlayer(c) //caster
local integer id = GetPlayerId(p)
local integer ok=0
if GetSpellAbilityId() == ABI_SEND_PYROMANIAC then
set ok=1
if not ((IsUnitInGroup(t, g_streetGroup)) and (p != GetOwningPlayer(t))) then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Please target other player's street.|r")
set ok=0
endif
if GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) < g_cost_Pyromaniac then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Not enough money ($" + I2S(g_cost_Pyromaniac) + ").|r")
set ok=0
endif
if IsPlayerImmuneTo_Attacker(GetOwningPlayer(t), PYROMANIAC) then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Target's owner is immune to Pyromaniac's influence.|r")
set ok=0
endif
endif
set c=null
set t=null
set p=null
return ok==1
endfunction
//-----------------------------------------------------------------------
//--- circle slot number "5" (last) reserved for item Pyromaniac detection !
function Trig_Pyro_Actions takes nothing returns nothing
local player p = GetOwningPlayer(GetSpellAbilityUnit()) //caster, circle owner
local integer id = GetPlayerId(p)
local unit t = GetSpellTargetUnit() // target
local player p1 = GetOwningPlayer(t)
local integer nr = GetCircleNumber(t)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) - g_cost_Pyromaniac)
//---
if UnitItemInSlot(t, 5)==null then
call UnitAddItemToSlotById(t, ITEM_PYROMANIAC, 5)
endif
call SetItemCharges(UnitItemInSlot(t, 5), GetItemCharges(UnitItemInSlot(t, 5))+1)
call DisplayTextToPlayer(p, 0.00, 0.00, "You just send Pyromaniac to street nr " + I2S(nr))
call DisplayTextToPlayer(p1, 0.00, 0.00, g_playerName[id] + " just send you Pyromaniac to street nr " + I2S(nr))
call UpdateCircleMana(t)
//---
set t=null
set p=null
set p1=null
endfunction
//=============================================================
function InitTrig_Pyromaniac takes nothing returns nothing
set gg_trg_Pyromaniac = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Pyromaniac, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Pyromaniac, Condition( function Trig_Pyro_Conditions ) )
call TriggerAddAction( gg_trg_Pyromaniac, function Trig_Pyro_Actions )
endfunction
//TESH.scrollpos=33
//TESH.alwaysfold=0
//============================================
function Trig_Thief_Conditions takes nothing returns boolean
local unit c = GetSpellAbilityUnit() //circle
local unit t = GetSpellTargetUnit()
local player p = GetOwningPlayer(c) //caster
local integer id = GetPlayerId(p)
local integer ok=0
if GetSpellAbilityId() == ABI_SEND_THIEF then
set ok=1
if not ((IsUnitInGroup(t, g_streetGroup)) and (p != GetOwningPlayer(t))) then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Please target other player's street.|r")
set ok=0
endif
if GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) < g_cost_Thief then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Not enough money ($" + I2S(g_cost_Thief) + ").|r")
set ok=0
endif
if IsPlayerImmuneTo_Attacker(GetOwningPlayer(t), THIEF) then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Target's owner is immune to Thief's influence.|r")
set ok=0
endif
endif
set c=null
set t=null
set p=null
return ok==1
endfunction
//-----------------------------------------------------------------------
//--- circle slot number "4" reserved for item Thief detection !
function Trig_Thief_Actions takes nothing returns nothing
local player p = GetOwningPlayer(GetSpellAbilityUnit()) //caster, circle owner
local integer id = GetPlayerId(p)
local unit t = GetSpellTargetUnit() // target
local player p1 = GetOwningPlayer(t)
local integer nr = GetCircleNumber(t)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) - g_cost_Thief)
//---
if UnitItemInSlot(t, 4)==null then
call UnitAddItemToSlotById(t, ITEM_THIEF, 4)
endif
call SetItemCharges(UnitItemInSlot(t, 4), GetItemCharges(UnitItemInSlot(t, 4))+1)
call DisplayTextToPlayer(p, 0.00, 0.00, "You just send a Thief to street nr " + I2S(nr))
call DisplayTextToPlayer(p1, 0.00, 0.00, g_playerName[id] + " just send you a Thief to street nr " + I2S(nr))
call UpdateCircleMana(t)
//---
set t=null
set p=null
set p1=null
endfunction
//=============================================================
function InitTrig_Thief takes nothing returns nothing
set gg_trg_Thief = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Thief, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Thief, Condition( function Trig_Thief_Conditions ) )
call TriggerAddAction( gg_trg_Thief, function Trig_Thief_Actions )
endfunction
//TESH.scrollpos=30
//TESH.alwaysfold=0
//============================================
function Trig_OverdueFood_Conditions takes nothing returns boolean
local unit c = GetSpellAbilityUnit() //circle
local unit t = GetSpellTargetUnit()
local player p = GetOwningPlayer(c) //caster
local integer id = GetPlayerId(p)
local integer ok=0
if GetSpellAbilityId() == ABI_SEND_OVERDUEFOOD then
set ok=1
if not ((IsUnitInGroup(t, g_streetGroup)) and (p != GetOwningPlayer(t))) then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Please target other player's street.|r")
set ok=0
endif
if GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) < g_cost_OverdueFood then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Not enough money ($" + I2S(g_cost_OverdueFood) + ").|r")
set ok=0
endif
if IsPlayerImmuneTo_Attacker(GetOwningPlayer(t), OVERDUE_FOOD) then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Target's owner is immune to Overdue food influence.|r")
set ok=0
endif
endif
set c=null
set t=null
set p=null
return ok==1
endfunction
//-----------------------------------------------------------------------
//--- circle slot number "3" reserved for item OverdueFood detection !
function Trig_OverdueFood_Actions takes nothing returns nothing
local player p = GetOwningPlayer(GetSpellAbilityUnit()) //caster, circle owner
local integer id = GetPlayerId(p)
local unit t = GetSpellTargetUnit() // target
local player p1 = GetOwningPlayer(t)
local integer nr = GetCircleNumber(t)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) - g_cost_OverdueFood)
//---
if UnitItemInSlot(t, 3)==null then
call UnitAddItemToSlotById(t, ITEM_OVERDUEFOOD, 3)
endif
call SetItemCharges(UnitItemInSlot(t, 3), GetItemCharges(UnitItemInSlot(t, 3))+1)
call DisplayTextToPlayer(p, 0.00, 0.00, "You just send Overdue Food to street nr " + I2S(nr))
call DisplayTextToPlayer(p1, 0.00, 0.00, g_playerName[id] + " just send you Overdue Food to street nr " + I2S(nr))
call UpdateCircleMana(t)
//---
set t=null
set p=null
set p1=null
endfunction
//=============================================================
function InitTrig_OverdueFood takes nothing returns nothing
set gg_trg_OverdueFood = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_OverdueFood, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_OverdueFood, Condition( function Trig_OverdueFood_Conditions ) )
call TriggerAddAction( gg_trg_OverdueFood, function Trig_OverdueFood_Actions )
endfunction
//TESH.scrollpos=31
//TESH.alwaysfold=0
//============================================
function Trig_Serviceman_Conditions takes nothing returns boolean
local unit c = GetSpellAbilityUnit() // tavern
local unit t = GetSpellTargetUnit()
local player p = GetOwningPlayer(c) //caster
local integer id = GetPlayerId(p)
local integer ok=0
if GetSpellAbilityId() == ABI_SEND_SERVICEMAN then
set ok=1
if not ((IsUnitInGroup(t, g_streetGroup)) and (p != GetOwningPlayer(t))) then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Please target other player's street.|r")
set ok=0
endif
if GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) < g_cost_Serviceman then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Not enough money ($" + I2S(g_cost_Serviceman) + ").|r")
set ok=0
endif
if IsPlayerImmuneTo_Attacker(GetOwningPlayer(t), SERVICEMAN) then
call DisplayTextToPlayer(p, 0.00, 0.00, "|cfffa8072Error: Target's owner is immune to Serviceman's influence.|r")
set ok=0
endif
endif
set c=null
set t=null
set p=null
return ok==1
endfunction
//-----------------------------------------------------------------------
//--- circle slot number "2" reserved for item Serviceman detection !
function Trig_Serviceman_Actions takes nothing returns nothing
local player p = GetOwningPlayer(GetSpellAbilityUnit()) //caster, tavern owner
local integer id = GetPlayerId(p)
local unit t = GetSpellTargetUnit() // target
local player p1 = GetOwningPlayer(t)
local integer nr = GetCircleNumber(t) // target circle nr
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) - g_cost_Serviceman)
//---
if UnitItemInSlot(t, 2)==null then
call UnitAddItemToSlotById(t, ITEM_SERVICEMAN, 2)
endif
call SetItemCharges(UnitItemInSlot(t, 2), GetItemCharges(UnitItemInSlot(t, 2))+1)
call DisplayTextToPlayer(p, 0.00, 0.00, "You just send Serviceman to street nr " + I2S(nr))
call DisplayTextToPlayer(p1, 0.00, 0.00, g_playerName[id] + " just send you Serviceman unit to street nr " + I2S(nr))
call UpdateCircleMana(t)
//---
set t=null
set p=null
set p1=null
endfunction
//=============================================================
function InitTrig_Serviceman takes nothing returns nothing
set gg_trg_Serviceman = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Serviceman, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Serviceman, Condition( function Trig_Serviceman_Conditions ) )
call TriggerAddAction( gg_trg_Serviceman, function Trig_Serviceman_Actions )
endfunction
//TESH.scrollpos=12
//TESH.alwaysfold=0
//-----------------------------------------------------------------------
function StartMovingForBankMeeting_LoopEnum takes nothing returns nothing
local unit d = GetEnumUnit()
local integer id = GetUnitUserData(d)
local player p = GetOwningPlayer(d)
local integer playerId = GetPlayerId(p)
local real x = GetUnitX(g_investor[playerId])
local real y = GetUnitY(g_investor[playerId])
local integer nr = g_bankMeetingCircleNr // circle where is bank meeting
// investor[playerId] walking Investor
if g_statusBankrupt[playerId] or g_statusLeft[playerId] or g_statusInJail[playerId]>0 then // invited player
set spellDuration[id] = 0.00
elseif spellCounter[id]==1 then
call DisplayTextToPlayer(p, 0.00, 0.00, "You won't be able to control your Investor for a while, becouse he moves to the Bank Meeting on street number " + I2S(nr))
elseif spellCounter[id]==4 or spellCounter[id]>14 then
call IssueTargetOrder(g_investor[playerId], "move", circle[nr])
// elseif RectContainsCoords(g_rect[nr], x, y) then
elseif IsUnitInRange(g_investor[playerId], circle[nr], 120.00) then
set spellDuration[id] = 0.00
call DisplayTextToPlayer(p, 0.00, 0.00, "Welcome on meeting! Bank pays you dividend: $" + I2S(g_dividend))
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) + g_dividend)
endif
//---
set spellCounter[id] = spellCounter[id] + 1
set spellDuration[id] = spellDuration[id] - 1.00
if spellDuration[id] <= 0.00 then
// Remember to null spellCaster, spellTarget etc..
set spellCounter[id] = 0
if (not g_statusBankrupt[playerId]) and (not g_statusLeft[playerId]) then
call SetUnitOwner(g_investor[playerId], p, false)
call IssueImmediateOrder(g_investor[playerId], "stop")
endif
call DisableUnitMovement(g_investor[playerId])
set g_bankMeetingInvitedPlayers = g_bankMeetingInvitedPlayers - 1
//---
call GroupRemoveUnit(spellGroup[4], d)
call RemoveUnit(d)
if FirstOfGroup(spellGroup[4])==null then
call PauseTimer(spellTimer[4])
endif
endif
set d=null
set p=null
endfunction
//-----------------------------------------------------------------------
function StartMovingForBankMeeting_Loop takes nothing returns nothing
call ForGroup(spellGroup[4], function StartMovingForBankMeeting_LoopEnum)
endfunction
//-----------------------------------------------------------------------
function StartMovingForBankMeeting takes player p returns nothing
local integer playerId = GetPlayerId(p)
local unit d = CreateUnit(p, DUMMY, GetUnitX(g_investor[playerId]), GetUnitY(g_investor[playerId]), 0.00)
local integer id = GetUnitUserData(d)
set spellDuration[id] = 60.00
set spellCounter[id] = 0
call SetUnitOwner(g_investor[playerId], Player(PLAYER_NEUTRAL_PASSIVE), false)
call RemoveGuardPosition(g_investor[playerId])
call EnableUnitMovement(g_investor[playerId])
//---
if FirstOfGroup(spellGroup[4])==null then
call TimerStart(spellTimer[4], 1.00, true, function StartMovingForBankMeeting_Loop)
endif
call GroupAddUnit(spellGroup[4], d)
set d=null
endfunction
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function Trig_BankMeetingStart_Actions takes nothing returns nothing
local unit targetCircle = GroupPickRandomUnit(g_streetGroup)
local integer a=0
set g_bankMeetingCircleNr = GetCircleNumber(targetCircle)
set g_bankMeetingInvitedPlayers = 0
set g_dividend = GetRandomInt(100, 300)
loop
exitwhen a>3
if IsPlayerInForce(Player(a), g_playersGroup) and g_statusInJail[a]==0 then //covers: leave, bankrupt, empty slot from begining
set g_bankMeetingInvitedPlayers = g_bankMeetingInvitedPlayers + 1 //remember how many players should walk for meeting
call StartMovingForBankMeeting(Player(a))
endif
set a=a+1
endloop
call EnableTrigger(gg_trg_BankMeetingCheck)
call ClearTextMessagesBJ(bj_FORCE_ALL_PLAYERS)
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, "Bank Meeting. [" + I2S(g_bankMeetingCircleNr) + "]")
call PlaySoundBJ(gg_snd_SecretFound)
set targetCircle = null
endfunction
//=============================================================
// this trigger is executed from inside "NextPlayerActions" trigger
//=============================================================
function InitTrig_BankMeetingStart takes nothing returns nothing
set gg_trg_BankMeetingStart = CreateTrigger( )
call TriggerAddAction( gg_trg_BankMeetingStart, function Trig_BankMeetingStart_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
//-----------------------------------------------------------------
function CalculateIncome takes player p returns integer
local integer a=1
local integer i=0
loop
exitwhen a>40
if GetOwningPlayer(circle[a]) == p then
set i = i + R2I(GetUnitState(circle[a], UNIT_STATE_MANA))
endif
set a=a+1
endloop
set i = R2I(I2R(i) * g_incomeMultiplier)
return i
endfunction
//-----------------------------------------------------------------
// setting global var : "g_playerActive"
function SetNextActivePlayer takes nothing returns nothing
local integer newId = GetPlayerId(g_playerActive)
loop
set newId=newId+1
if newId==4 then
set newId=0
endif
exitwhen IsPlayerInForce(Player(newId), g_playersGroup)
endloop
set g_playerActive = Player(newId)
endfunction
//-----------------------------------------------------------------
function IsPlayerBankrupt takes integer playerId returns boolean
local integer properties = GetPlayerState(Player(playerId), PLAYER_STATE_RESOURCE_LUMBER)
local integer money = GetPlayerState(Player(playerId), PLAYER_STATE_RESOURCE_GOLD)
local integer criminal = GetItemCharges(UnitItemInSlot(g_investor[playerId], 3))
return (properties + money) == 0
endfunction
//---
function IsPlayerFraudster takes integer playerId returns boolean
return GetItemCharges(UnitItemInSlot(g_investor[playerId], 3)) >= 6
endfunction
//-----------------------------------------------------------------
// actions similar to "player left"
//-----------------------------------------------------------------
function OnBankrupcy takes player p, string s returns nothing
local integer id = GetPlayerId(p)
local integer a=1
call PlaySoundForPlayer(gg_snd_MuradinTaunt1, Player(id))
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, g_playerName[id] + " is a " + s + "!")
set g_statusBankrupt[id] = true
call UpdateMB_PlayerBankrupt(id, s)
//---
call ForceRemovePlayer(g_playersGroup, p)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, 0)
if IsUnitAlive(g_investor[id]) then
call SetUnitOwner(g_investor[id], Player(15), true)
call SetUnitPosition(g_investor[id], 3000.00, 0.00)
call SetUnitFacing(g_investor[id], 45.00)
endif
if IsUnitAlive(g_picture[id]) then
call ShowUnit(g_picture[id], false)
endif
loop // a is circle number
exitwhen a>40
if GetOwningPlayer(circle[a]) == p then
call SetCircleOwner(circle[a], BANK) // bank owner, also updating circle mana
//update hp representing buy cost ! or not?
if IsUnitInGroup(circle[a], g_streetGroup) then //hide houses:
call ShowUnit(house1[a], false)
call ShowUnit(house2[a], false)
call ShowUnit(house3[a], false)
call ShowUnit(hotel[a], false)
endif
endif
call UpdateCircleMana(circle[a]) // update all 40 circles' mana
set a=a+1
endloop
call UpdateNrOfPlotsOwnedByPlayers() // representing by lumber
call UpdateAllPlayersOwningState()
set g_playersCount = g_playersCount - 1
endfunction
//TESH.scrollpos=41
//TESH.alwaysfold=0
//----------------------------------------------------------------------------
function Trig_NextPlayerActions_Actions takes nothing returns nothing
local integer id = 0
local integer inc = 0
local player winner=null
if TimerGetRemaining(udg_timerBankMeeting) == 0.00 then // bank meeting begin
call TriggerExecute(gg_trg_BankMeetingStart)
return
endif // bank meeting end
call SetNextActivePlayer() // find next player
set id = GetPlayerId(g_playerActive) // next player's id
set inc = CalculateIncome(g_playerActive)
if IsPlayerBankrupt(id) and (not g_statusBankrupt[id]) then
call OnBankrupcy(g_playerActive, "BANKRUPT")
// set next player
call SetNextActivePlayer() // find next player
set id = GetPlayerId(g_playerActive) // next player's id
set inc = CalculateIncome(g_playerActive)
elseif IsPlayerFraudster(id) and (not g_statusBankrupt[id]) then
call OnBankrupcy(g_playerActive, "FRAUDSTER")
// set next player
call SetNextActivePlayer() // find next player
set id = GetPlayerId(g_playerActive) // next player's id
set inc = CalculateIncome(g_playerActive)
endif
if g_statusInJail[id] > 0 then
set g_statusInJail[id] = g_statusInJail[id] - 1
if g_statusInJail[id] > 0 then
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, g_playerName[id] + " cannot play while in jail!")
call DisplayTextToPlayer(g_playerActive, 0.00, 0.00, "No Income")
// set next player:
call SetNextActivePlayer() // find next player
set id = GetPlayerId(g_playerActive) // next player's id
set inc = CalculateIncome(g_playerActive)
endif
endif
set g_isMyTurn[id] = true
call SetUnitColor(FLAG, ConvertPlayerColor(id))
call UnitAddAbility(g_investor[id], ABI_IM_DONE)
call IssueImmediateOrder(g_investor[id], "stop")
call EnableUnitMovement(g_investor[id])
call TimerStart(g_timerTurn, g_turnTime, false, null)
call TimerDialogSetTitle(g_timerWindow, g_playerName[id])
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, g_playerName[id] + " 's turn!")
call DisplayTextToPlayer(g_playerActive, 0.00, 0.00, "Income: $" + I2S(inc))
call SetPlayerState(g_playerActive, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(g_playerActive, PLAYER_STATE_RESOURCE_GOLD) + inc)
call PlaySoundBJ(gg_snd_BattleNetTick)
if GetItemTypeId(UnitItemInSlot(g_investor[id], 2)) == ITEM_ACCUSATION then // sue
call SueInvestor_Start()
elseif GetItemTypeId(UnitItemInSlot(g_investor[id], 1)) == ITEM_INVITATION then //invitation actions:
call InvitedInvestor_StartMove()
endif
if g_playersCount == 1 then
set winner = ForcePickRandomPlayer(g_playersGroup)
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, g_playerName[GetPlayerId(winner)] + " IS THE WINNER ! ")
call PlaySoundBJ(gg_snd_ClanInvitation)
// GAME OVER
endif
endfunction
//=========================================================
function InitTrig_NextPlayerActions takes nothing returns nothing
set gg_trg_NextPlayerActions = CreateTrigger( )
call TriggerAddAction( gg_trg_NextPlayerActions, function Trig_NextPlayerActions_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_PlayerLeft_Actions takes nothing returns nothing
local player p = GetTriggerPlayer()
local integer id = GetPlayerId(p)
call PlaySoundBJ(gg_snd_Warning)
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, GetPlayerName(p) + " has left the game.")
set g_statusLeft[id] = true
call ForceRemovePlayer(g_playersGroup, p)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, 0)
call KillUnit(g_wisp[id])
if IsUnitAlive(g_investor[id]) then
call SetUnitOwner(g_investor[id], Player(15), true)
call SetUnitPosition(g_investor[id], 3000.00, 0.00)
call SetUnitFacing(g_investor[id], 45.00)
endif
if IsUnitAlive(g_picture[id]) then
call ShowUnit(g_picture[id], false)
endif
set g_playersCount = g_playersCount - 1
endfunction
//====================================================
function InitTrig_PlayerLeft takes nothing returns nothing
set gg_trg_PlayerLeft = CreateTrigger( )
call TriggerRegisterPlayerEvent(gg_trg_PlayerLeft, Player(0), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(gg_trg_PlayerLeft, Player(1), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(gg_trg_PlayerLeft, Player(2), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(gg_trg_PlayerLeft, Player(3), EVENT_PLAYER_LEAVE)
call TriggerAddAction( gg_trg_PlayerLeft, function Trig_PlayerLeft_Actions )
endfunction
//TESH.scrollpos=27
//TESH.alwaysfold=0
function Trig_PlaerLeftGameStarted_Actions takes nothing returns nothing
local player p = GetTriggerPlayer()
local integer id = GetPlayerId(p)
local integer a=1
local player winner = null
call PlaySoundBJ(gg_snd_Warning)
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, g_playerName[id] + " has left the game.")
set g_statusLeft[id] = true
call UpdateMB_PlayerLeft(id)
//---
call ForceRemovePlayer(g_playersGroup, p)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, 0)
if IsUnitAlive(g_investor[id]) then
call SetUnitOwner(g_investor[id], Player(15), true)
call SetUnitPosition(g_investor[id], 3000.00, 0.00)
call SetUnitFacing(g_investor[id], 45.00)
endif
if IsUnitAlive(g_picture[id]) then
call ShowUnit(g_picture[id], false)
endif
loop // a is circle number
exitwhen a>40
if GetOwningPlayer(circle[a]) == p then
call SetCircleOwner(circle[a], BANK) // bank owner, also updating circle mana
//update hp representing buy cost ! or not?
if IsUnitInGroup(circle[a], g_streetGroup) then //hide houses:
call ShowUnit(house1[a], false)
call ShowUnit(house2[a], false)
call ShowUnit(house3[a], false)
call ShowUnit(hotel[a], false)
endif
endif
call UpdateCircleMana(circle[a]) // update all 40 circles' mana
set a=a+1
endloop
call UpdateNrOfPlotsOwnedByPlayers() // representing by lumber
call UpdateAllPlayersOwningState()
set g_playersCount = g_playersCount - 1
if g_playersCount == 1 then
set winner = ForcePickRandomPlayer(g_playersGroup)
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, g_playerName[GetPlayerId(winner)] + " IS THE WINNER ! ")
call PlaySoundBJ(gg_snd_ClanInvitation)
// GAME OVER
if not IsTriggerEnabled(gg_trg_BankMeetingCheck) then // its enabled when bank meeting in progress
if g_isMyTurn[id] then
call TriggerExecute(gg_trg_NextPlayerActions) // alows last player to play alone
endif
endif
else
if not IsTriggerEnabled(gg_trg_BankMeetingCheck) then // its enabled when bank meeting in progress
if g_isMyTurn[id] then
call TriggerExecute(gg_trg_NextPlayerActions) // alows last player to play alone
endif
endif
endif
endfunction
//===========================================================
function InitTrig_PlayerLeftGameStarted takes nothing returns nothing
set gg_trg_PlayerLeftGameStarted = CreateTrigger( )
call DisableTrigger( gg_trg_PlayerLeftGameStarted )
call TriggerRegisterPlayerEvent(gg_trg_PlayerLeftGameStarted, Player(0), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(gg_trg_PlayerLeftGameStarted, Player(1), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(gg_trg_PlayerLeftGameStarted, Player(2), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(gg_trg_PlayerLeftGameStarted, Player(3), EVENT_PLAYER_LEAVE)
call TriggerAddAction( gg_trg_PlayerLeftGameStarted, function Trig_PlaerLeftGameStarted_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_TimerTurnExpires_Actions takes nothing returns nothing
local integer id = GetPlayerId(g_playerActive)
set g_isMyTurn[id] = false
call UnitRemoveAbility(g_investor[id], ABI_IM_DONE)
call DisableUnitMovement(g_investor[id])
call TimerStart(g_timerTurn, g_turnTime, false, null)
call PauseTimer(g_timerTurn)
call TriggerExecute(gg_trg_NextPlayerActions)
endfunction
//=========================================================
function InitTrig_TimerTurnExpires takes nothing returns nothing
set gg_trg_TimerTurnExpires = CreateTrigger( )
call TriggerRegisterTimerExpireEventBJ( gg_trg_TimerTurnExpires, g_timerTurn )
call TriggerAddAction( gg_trg_TimerTurnExpires, function Trig_TimerTurnExpires_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_PlayerImDone_Conditions takes nothing returns boolean
if GetSpellAbilityId() == ABI_IM_DONE then
call Trig_TimerTurnExpires_Actions()
endif
return false
endfunction
//=============================================================
function InitTrig_PlayerImDone takes nothing returns nothing
set gg_trg_PlayerImDone = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_PlayerImDone, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_PlayerImDone, Condition( function Trig_PlayerImDone_Conditions ) )
endfunction
//TESH.scrollpos=15
//TESH.alwaysfold=0
function PayRent takes unit u returns nothing
local integer nr = R2I(GetUnitState(u, UNIT_STATE_MANA))
local player circleOwner = GetOwningPlayer(circle[nr])
local integer rent = R2I(GetUnitState(circle[nr], UNIT_STATE_MANA))
local integer mandates = GetItemCharges(UnitItemInSlot(u, 0))
local integer id=0
local player p
local integer money
//---
loop
exitwhen u==g_investor[id]
set id=id+1
endloop
//---
set p = Player(id)
set money = GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD)
if rent==0 or (p == circleOwner) or (g_statusInJail[GetPlayerId(circleOwner)]>0) or (GetUnitAbilityLevel(u, BUFF_CLOAKING_DEVICE)>0) then
return
endif
if money>=rent then //pay
call SetFloatTextOverUnit(" |cffff0000 -" + I2S(rent) + " |r " , u)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, money - rent)
call SetPlayerState(circleOwner, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(circleOwner, PLAYER_STATE_RESOURCE_GOLD) + rent)
else
if money>0 then // pay not full rent amount
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, 0)
call SetPlayerState(circleOwner, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(circleOwner, PLAYER_STATE_RESOURCE_GOLD) + money)
endif
if mandates<7 then //give mandate
call SetItemCharges(UnitItemInSlot(u, 0), mandates+1)
call SetFloatTextOverUnit(" |cffff0000 " + "mandate!" + " |r " , u)
elseif mandates==7 then //go to jail
call PlaySoundForPlayer(gg_snd_ArrangedTeamInvitation, p)
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, g_playerName[id] + " is in jail.")
call SetItemCharges(UnitItemInSlot(u, 0), 0)
call SetItemCharges(UnitItemInSlot(u, 3), GetItemCharges(UnitItemInSlot(u, 3)) + 1)
set g_investorPositionNr[id] = 11
set g_statusInJail[id] = 2
call SetUnitPosition(u, GetUnitX(circle[11]), GetUnitY(circle[11]))
call SetUnitState(u, UNIT_STATE_MANA, I2R(11))
if not IsTriggerEnabled(gg_trg_BankMeetingCheck) then // its enabled when bank meeting in progress
call Trig_TimerTurnExpires_Actions()
endif
endif
endif
set p=null
set circleOwner=null
endfunction
//TESH.scrollpos=15
//TESH.alwaysfold=0
//--------------------------------------------------------------------
function Trig_Leave_Conditions takes nothing returns boolean
local unit u = GetLeavingUnit()
if u==g_investor[0] or u==g_investor[1] or u==g_investor[2] or u==g_investor[3] then
set u=null
return true
endif
return false
endfunction
//--------------------------------------------------------------------
//--------------------------------------------------------------------
function TrigLeaveRect takes unit u, integer prev, integer current, integer next returns nothing
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local integer id=0
loop
exitwhen u==g_investor[id]
set id=id+1
endloop
if RectContainsCoords(g_rect[next], x, y) then
set g_investorPositionNr[id] = next
call SetUnitState(u, UNIT_STATE_MANA, I2R(next))
call PayRent(u)
elseif RectContainsCoords(g_rect[prev], x, y) then
set g_investorPositionNr[id] = prev
call SetUnitState(u, UNIT_STATE_MANA, I2R(prev))
call PayRent(u)
endif
set u=null
endfunction
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
function Trig_Leave_01 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 40, 1, 2)
endfunction
function Trig_Leave_02 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 1, 2, 3)
endfunction
function Trig_Leave_03 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 2, 3, 4)
endfunction
function Trig_Leave_04 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 3, 4, 5)
endfunction
function Trig_Leave_05 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 4, 5, 6)
endfunction
function Trig_Leave_06 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 5, 6, 7)
endfunction
function Trig_Leave_07 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 6, 7, 8)
endfunction
function Trig_Leave_08 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 7, 8, 9)
endfunction
function Trig_Leave_09 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 8, 9, 10)
endfunction
function Trig_Leave_10 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 9, 10, 11)
endfunction
function Trig_Leave_11 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 10, 11, 12)
endfunction
function Trig_Leave_12 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 11, 12, 13)
endfunction
function Trig_Leave_13 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 12, 13, 14)
endfunction
function Trig_Leave_14 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 13, 14, 15)
endfunction
function Trig_Leave_15 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 14, 15, 16)
endfunction
function Trig_Leave_16 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 15, 16, 17)
endfunction
function Trig_Leave_17 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 16, 17, 18)
endfunction
function Trig_Leave_18 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 17, 18, 19)
endfunction
function Trig_Leave_19 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 18, 19, 20)
endfunction
function Trig_Leave_20 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 19, 20, 21)
endfunction
function Trig_Leave_21 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 20, 21, 22)
endfunction
function Trig_Leave_22 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 21, 22, 23)
endfunction
function Trig_Leave_23 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 22, 23, 24)
endfunction
function Trig_Leave_24 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 23, 24, 25)
endfunction
function Trig_Leave_25 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 24, 25, 26)
endfunction
function Trig_Leave_26 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 25, 26, 27)
endfunction
function Trig_Leave_27 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 26, 27, 28)
endfunction
function Trig_Leave_28 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 27, 28, 29)
endfunction
function Trig_Leave_29 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 28, 29, 30)
endfunction
function Trig_Leave_30 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 29, 30, 31)
endfunction
function Trig_Leave_31 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 30, 31, 32)
endfunction
function Trig_Leave_32 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 31, 32, 33)
endfunction
function Trig_Leave_33 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 32, 33, 34)
endfunction
function Trig_Leave_34 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 33, 34, 35)
endfunction
function Trig_Leave_35 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 34, 35, 36)
endfunction
function Trig_Leave_36 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 35, 36, 37)
endfunction
function Trig_Leave_37 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 36, 37, 38)
endfunction
function Trig_Leave_38 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 37, 38, 39)
endfunction
function Trig_Leave_39 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 38, 39, 40)
endfunction
function Trig_Leave_40 takes nothing returns nothing
call TrigLeaveRect(GetLeavingUnit(), 39, 40, 1)
endfunction
//=========================================================
function InitTrig_DetectLocation takes nothing returns nothing
local trigger t = CreateTrigger()
set g_rect[1] = gg_rct_Reg01
set g_rect[2] = gg_rct_Reg02
set g_rect[3] = gg_rct_Reg03
set g_rect[4] = gg_rct_Reg04
set g_rect[5] = gg_rct_Reg05
set g_rect[6] = gg_rct_Reg06
set g_rect[7] = gg_rct_Reg07
set g_rect[8] = gg_rct_Reg08
set g_rect[9] = gg_rct_Reg09
set g_rect[10] = gg_rct_Reg10
set g_rect[11] = gg_rct_Reg11
set g_rect[12] = gg_rct_Reg12
set g_rect[13] = gg_rct_Reg13
set g_rect[14] = gg_rct_Reg14
set g_rect[15] = gg_rct_Reg15
set g_rect[16] = gg_rct_Reg16
set g_rect[17] = gg_rct_Reg17
set g_rect[18] = gg_rct_Reg18
set g_rect[19] = gg_rct_Reg19
set g_rect[20] = gg_rct_Reg20
set g_rect[21] = gg_rct_Reg21
set g_rect[22] = gg_rct_Reg22
set g_rect[23] = gg_rct_Reg23
set g_rect[24] = gg_rct_Reg24
set g_rect[25] = gg_rct_Reg25
set g_rect[26] = gg_rct_Reg26
set g_rect[27] = gg_rct_Reg27
set g_rect[28] = gg_rct_Reg28
set g_rect[29] = gg_rct_Reg29
set g_rect[30] = gg_rct_Reg30
set g_rect[31] = gg_rct_Reg31
set g_rect[32] = gg_rct_Reg32
set g_rect[33] = gg_rct_Reg33
set g_rect[34] = gg_rct_Reg34
set g_rect[35] = gg_rct_Reg35
set g_rect[36] = gg_rct_Reg36
set g_rect[37] = gg_rct_Reg37
set g_rect[38] = gg_rct_Reg38
set g_rect[39] = gg_rct_Reg39
set g_rect[40] = gg_rct_Reg40
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg01)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_01)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg02)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_02)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg03)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_03)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg04)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_04)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg05)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_05)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg06)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_06)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg07)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_07)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg08)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_08)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg09)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_09)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg10)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_10)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg11)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_11)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg12)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_12)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg13)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_13)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg14)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_14)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg15)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_15)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg16)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_16)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg17)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_17)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg18)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_18)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg19)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_19)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg20)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_20)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg21)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_21)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg22)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_22)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg23)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_23)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg24)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_24)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg25)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_25)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg26)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_26)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg27)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_27)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg28)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_28)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg29)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_29)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg30)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_30)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg31)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_31)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg32)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_32)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg33)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_33)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg34)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_34)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg35)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_35)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg36)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_36)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg37)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_37)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg38)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_38)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg39)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_39)
set t = CreateTrigger()
call TriggerRegisterLeaveRectSimple(t, gg_rct_Reg40)
call TriggerAddCondition(t, Condition( function Trig_Leave_Conditions))
call TriggerAddAction(t, function Trig_Leave_40)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_CameraSet_Actions takes nothing returns nothing
local integer i = GetPlayerId(GetTriggerPlayer())
local real dist = S2R(SubStringBJ(GetEventPlayerChatString(), 5, 8))
if dist < 1650.00 then
set g_cameraDistance[i] = 1650.00
elseif dist > 2600.00 then
set g_cameraDistance[i] = 2600.00
else
set g_cameraDistance[i] = dist
endif
call DisplayTextToPlayer(GetTriggerPlayer(), 0.00, 0.00, "Setting camera distance view to: " + I2S(R2I(g_cameraDistance[i])))
call SetCameraFieldForPlayer(Player(i), CAMERA_FIELD_TARGET_DISTANCE, g_cameraDistance[i], 0)
endfunction
//===========================================================
function InitTrig_CommandCam takes nothing returns nothing
set gg_trg_CommandCam = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_CommandCam, Player(0), "-cam", false )
call TriggerRegisterPlayerChatEvent( gg_trg_CommandCam, Player(1), "-cam", false )
call TriggerRegisterPlayerChatEvent( gg_trg_CommandCam, Player(2), "-cam", false )
call TriggerRegisterPlayerChatEvent( gg_trg_CommandCam, Player(3), "-cam", false )
call TriggerAddAction( gg_trg_CommandCam, function Trig_CameraSet_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
//=======================================
function InterruptOrder_Enum takes nothing returns nothing
call GroupRemoveUnit(g_interruptGroup, GetEnumUnit())
call IssueImmediateOrderById(GetEnumUnit(), 851972) // stop
endfunction
//---
function InterruptOrder takes nothing returns nothing
call ForGroup(g_interruptGroup, function InterruptOrder_Enum)
endfunction
//------------------------------------------------------------------------------
function Trig_NewBuildCheck_Conditions takes nothing returns boolean
return IsUnitType(GetOrderedUnit(), UNIT_TYPE_HERO) and GetIssuedOrderId() == 852501
endfunction // healingwave
//---
function Trig_NewBuildCheck_Actions takes nothing returns nothing
local unit caster = GetOrderedUnit()
local unit target = GetOrderTargetUnit()
local player p = GetOwningPlayer(caster)
local integer nr = GetCircleNumber(target)
local integer areaNr
local integer ownedStreets
local integer buildingsCount
local integer cost
local integer money = GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD)
local integer ok=1
//add all required conditions ...
if not g_isMyTurn[GetPlayerId(p)] then
call DisplayTextToPlayer(p, 0, 0, "|cffff4500Wait for your turn!|r")
set ok=0
elseif not IsUnitInGroup(circle[nr], g_streetGroup) then
call DisplayTextToPlayer(p, 0.00, 0.00, "You can build only on street-type area.")
set ok=0
else
set areaNr = GetAreaNumber(circle[nr])
set ownedStreets = CountStreetsOwnedByPlayerInArea(p, areaNr)
set buildingsCount = StreetCountBuildings(nr)
set cost = buildCost[nr]
if buildingsCount==4 then //hotel already costructed, interrupt
call DisplayTextToPlayer(p, 0.00, 0.00, "You cannot build after hotel has been costructed.")
set ok=0
elseif cost>money then
call DisplayTextToPlayer(p, 0.00, 0.00, "Not enough money, you need: $" + I2S(cost))
set ok=0
elseif (ownedStreets==1 and buildingsCount>=1) or (ownedStreets==2 and buildingsCount>=2) then
call DisplayTextToPlayer(p, 0.00, 0.00, "Cannot build more houses then number of owned streets in district.")
set ok=0
endif
endif
if ok==0 then
call GroupAddUnit(g_interruptGroup, caster)
call TimerStart(g_timerInterrupt, 0.00, false, function InterruptOrder)
endif
//call BJDebugMsg("build..on street " + I2S(nr))
set caster=null
set target=null
endfunction
//==================================================================
function InitTrig_BuildCheck takes nothing returns nothing
set gg_trg_BuildCheck = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_BuildCheck, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerAddCondition( gg_trg_BuildCheck, Condition( function Trig_NewBuildCheck_Conditions ) )
call TriggerAddAction( gg_trg_BuildCheck, function Trig_NewBuildCheck_Actions )
endfunction
//TESH.scrollpos=33
//TESH.alwaysfold=0
function Trig_Build_Conditions takes nothing returns boolean
return GetSpellAbilityId() == ABI_BUILD
endfunction
//---
function Trig_Build_Actions takes nothing returns nothing
local unit caster = GetSpellAbilityUnit()
local unit target = GetSpellTargetUnit()
local player p = GetOwningPlayer(caster)
local integer id = GetPlayerId(p)
local integer money = GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD)
local integer nr = GetCircleNumber(target)
local integer areaNr = GetAreaNumber(target)
local integer cost = buildCost[nr]
local integer ownedStreets = CountStreetsOwnedByPlayerInArea(p, areaNr)
local integer buildingsCount = StreetCountBuildings(nr)
local integer allowBuild=0
if cost>money then
call DisplayTextToPlayer(p, 0.00, 0.00, "Not enough money, you need: $" + I2S(cost))
else //all ok , proceed
if buildingsCount==0 then
call ShowUnit(house1[nr], true)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) - cost)
call DisplayTextToPlayer(p, 0, 0, "A house has been constructed for $" + I2S(cost))
call PlaySoundForPlayer(gg_snd_GoodJob, p)
elseif buildingsCount==1 then
call ShowUnit(house2[nr], true)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) - cost)
call DisplayTextToPlayer(p, 0, 0, "A house has been constructed for $" + I2S(cost))
call PlaySoundForPlayer(gg_snd_GoodJob, p)
elseif buildingsCount==2 then
call ShowUnit(house3[nr], true)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) - cost)
call DisplayTextToPlayer(p, 0, 0, "A house has been constructed for $" + I2S(cost))
call PlaySoundForPlayer(gg_snd_GoodJob, p)
elseif buildingsCount==3 then
call ShowUnit(hotel[nr], true)
call ShowUnit(house1[nr], false)
call ShowUnit(house2[nr], false)
call ShowUnit(house3[nr], false)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) - cost)
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, g_playerName[GetPlayerId(p)] + " build a " + "|cff00ff00Hotel!|r")
call PlaySoundBJ(gg_snd_ClanInvitation)
endif
//update circle hp, represents buy value, here for build event just *add* cost to existing hp
call AddUnitMaxState(target, UNIT_STATE_MAX_LIFE, I2R(cost))
call UpdateHousesHotels()
call UpdateCircleMana(target)
call UpdatePlayerOwningState(p)
endif
set caster=null
set target=null
set p=null
endfunction
//=========================================================
function InitTrig_Build takes nothing returns nothing
set gg_trg_Build = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Build, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Build, Condition( function Trig_Build_Conditions ) )
call TriggerAddAction( gg_trg_Build, function Trig_Build_Actions )
endfunction
//TESH.scrollpos=7
//TESH.alwaysfold=0
function Trig_SellCheck_Conditions takes nothing returns boolean
return IsUnitType(GetOrderedUnit(), UNIT_TYPE_HERO) and GetIssuedOrderId() == 852502 // hex
endfunction
//---
function Trig_SellCheck_Actions takes nothing returns nothing
local unit caster = GetOrderedUnit()
local unit target = GetOrderTargetUnit()
local player p = GetOwningPlayer(caster)
local integer nr = GetCircleNumber(target)
local integer buildingsCount = StreetCountBuildings(nr)
if not g_isMyTurn[GetPlayerId(p)] then
call DisplayTextToPlayer(p, 0, 0, "|cffff4500Wait for your turn!|r")
call GroupAddUnit(g_interruptGroup, caster)
call TimerStart(g_timerInterrupt, 0.00, false, function InterruptOrder)
elseif (not IsUnitInGroup(circle[nr], g_streetGroup)) or buildingsCount==0 then
call DisplayTextToPlayer(p, 0.00, 0.00, "Target your own area with buildings.")
call GroupAddUnit(g_interruptGroup, caster)
call TimerStart(g_timerInterrupt, 0.00, false, function InterruptOrder)
endif
set caster=null
set target=null
endfunction
//==============================================================
function InitTrig_SellCheck takes nothing returns nothing
set gg_trg_SellCheck = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SellCheck, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerAddCondition( gg_trg_SellCheck, Condition( function Trig_SellCheck_Conditions ) )
call TriggerAddAction( gg_trg_SellCheck, function Trig_SellCheck_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
//--------------------------------------------------------------------
function Trig_SellBuilding_Conditions takes nothing returns boolean
return GetSpellAbilityId() == ABI_SELL_BUILDING
endfunction
//--------------------------------------------------------------------
//--------------------------------------------------------------------
function Trig_SellBuilding_Actions takes nothing returns nothing
local unit caster = GetSpellAbilityUnit()
local unit target = GetSpellTargetUnit()
local player p = GetOwningPlayer(caster)
local integer id= GetPlayerId(p)
local integer nr = GetCircleNumber(target)
local integer areaNr = GetAreaNumber(target)
local integer bankPays = buildCost[nr] / 2
local integer buildingsCount = StreetCountBuildings(nr)
if buildingsCount==4 then // hotel
call ShowUnit(hotel[nr], false)
call ShowUnit(house1[nr], true)
call ShowUnit(house2[nr], true)
call ShowUnit(house3[nr], true)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) + bankPays)
call DisplayTextToPlayer(p, 0, 0, "Hotel sold to Bank for $" + I2S(bankPays))
elseif buildingsCount==3 then
call ShowUnit(house3[nr], false)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) + bankPays)
call DisplayTextToPlayer(p, 0, 0, "House sold to Bank for $" + I2S(bankPays))
elseif buildingsCount==2 then
call ShowUnit(house2[nr], false)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) + bankPays)
call DisplayTextToPlayer(p, 0, 0, "House sold to Bank for $" + I2S(bankPays))
elseif buildingsCount==1 then
call ShowUnit(house1[nr], false)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) + bankPays)
call DisplayTextToPlayer(p, 0, 0, "House sold to Bank for $" + I2S(bankPays))
endif
//update circle hp, represents buy value, here for build event just remove cost from existing hp
call AddUnitMaxState(target, UNIT_STATE_MAX_LIFE, - I2R(buildCost[nr]))
call UpdateHousesHotels()
call UpdateCircleMana(target)
set caster=null
set target=null
set p=null
endfunction
//==============================================================
function InitTrig_SellHouse takes nothing returns nothing
set gg_trg_SellHouse = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SellHouse, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_SellHouse, Condition( function Trig_SellBuilding_Conditions ) )
call TriggerAddAction( gg_trg_SellHouse, function Trig_SellBuilding_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
//------------------------------------------------------------------------------
function Trig_BuyCheckCheck_Conditions takes nothing returns boolean
return IsUnitType(GetOrderedUnit(), UNIT_TYPE_HERO) and GetIssuedOrderId() == 852119
endfunction // chainlightning
//---
function Trig_BuyCheckCheck_Actions takes nothing returns nothing
local unit caster = GetOrderedUnit()
local unit target = GetOrderTargetUnit()
local player p = GetOwningPlayer(caster)
local integer nr = GetCircleNumber(target)
local integer areaNr = GetAreaNumber(target)
local integer cost = R2I(GetUnitState(target, UNIT_STATE_MAX_LIFE))
local integer money = GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD)
local integer ok=1
if not g_isMyTurn[GetPlayerId(p)] then
call DisplayTextToPlayer(p, 0, 0, "|cffff4500Wait for your turn!|r")
set ok=0
elseif not IsBuyableCircleType(target) then
call DisplayTextToPlayer(p, 0, 0, "Cannot target this unit.")
set ok=0
elseif p==GetOwningPlayer(target) then
call DisplayTextToPlayer(p, 0.00, 0.00, "This property is yours..")
set ok=0
elseif IsDistrictOwnedByPlayer(areaNr) and (g_statusInJail[GetPlayerId(g_districtOwningPlayer)]==0) then // if returns "true" then sets global g_districtOwningPlayer to player who owns whole district
call DisplayTextToPlayer(p, 0.00, 0.00, "You cannot buy property owned by player who owns whole district.")
set ok=0
elseif cost>money then
call DisplayTextToPlayer(p, 0.00, 0.00, "Not enough money, you need: $" + I2S(cost))
set ok=0
endif
if ok==0 then
call GroupAddUnit(g_interruptGroup, caster)
call TimerStart(g_timerInterrupt, 0.00, false, function InterruptOrder)
endif
set caster=null
set target=null
endfunction
//==================================================================
function InitTrig_BuyCheck takes nothing returns nothing
set gg_trg_BuyCheck = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_BuyCheck, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerAddCondition( gg_trg_BuyCheck, Condition( function Trig_BuyCheckCheck_Conditions ) )
call TriggerAddAction( gg_trg_BuyCheck, function Trig_BuyCheckCheck_Actions )
endfunction
//TESH.scrollpos=38
//TESH.alwaysfold=0
function Trig_PlayerBuy_Conditions takes nothing returns boolean
return GetSpellAbilityId() == ABI_BUY
endfunction
//-----------------------------------------------------------------------
function Trig_PlayerBuy_Actions takes nothing returns nothing
local unit caster = GetSpellAbilityUnit()
local unit target = GetSpellTargetUnit()
local player p = GetOwningPlayer(caster)
local player p1 = GetOwningPlayer(target)
local integer id = GetPlayerId(p)
local integer nr = GetCircleNumber(target)
local integer areaNr = GetAreaNumber(target)
local integer cost = R2I(GetUnitState(target, UNIT_STATE_MAX_LIFE))
local integer money = GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD)
local string property = GetUnitName(target)
local integer countBuildings = StreetCountBuildings(nr)
local integer b=0
local integer c=0
local integer payBank
local integer payPlayer
if cost>money then
call DisplayTextToPlayer(p, 0.00, 0.00, "Not enough money, you need: $" + I2S(cost))
else
if p1 == BANK then //from Bank
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, property + " sold to " + g_playerName[id] + " for $" + I2S(cost))
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) - cost)
call PlaySoundBJ(gg_snd_Hint)
set buyCost[nr] = R2I(I2R(buyCost[nr])*1.50) // new property cost for next buyer
call SetUnitMaxState(target, UNIT_STATE_MAX_LIFE, I2R(buyCost[nr]))
call SetCircleOwner(target, p)
else // from other player
set b = countBuildings * buildCost[nr] //---pay it to player, houses cost
set c = cost - b
set payPlayer = (c*100)/150
set payBank = c - payPlayer
call SetPlayerState(p1, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p1, PLAYER_STATE_RESOURCE_GOLD) + b + payPlayer)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) - cost)
// set new hp
set buyCost[nr] = R2I(I2R(buyCost[nr])*1.50)
call SetUnitMaxState(target, UNIT_STATE_MAX_LIFE, I2R(buyCost[nr] + b)) // new base-cost + houses cost
// call BJDebugMsg("pay houses: " + I2S(b) + ", pay player: " + I2S(payPlayer) + ", payBank " + I2S(payBank))
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, property + " sold to " + g_playerName[id] + " for $" + I2S(cost))
call PlaySoundBJ(gg_snd_Hint)
call SetCircleOwner(target, p)
endif
if IsCircleDefendingFromAttacker(nr) then // one from 8 possible, may cancel attakers
call UpdateManaOnPlayerAllCircles(p) //buyer
call UpdateManaOnPlayerAllCircles(p1) //previous owner
endif
call UpdateHousesHotels()
call UpdatePlayerOwningState(p)
call UpdatePlayerOwningState(p1)
call Trig_TimerTurnExpires_Actions() // end of player turn
endif
set caster=null
set target=null
set p=null
set p1=null
set property=null
endfunction
//=============================================================
function InitTrig_Buy takes nothing returns nothing
set gg_trg_Buy = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Buy, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Buy, Condition( function Trig_PlayerBuy_Conditions ) )
call TriggerAddAction( gg_trg_Buy, function Trig_PlayerBuy_Actions )
endfunction