//TESH.scrollpos=0
//TESH.alwaysfold=0
native GetUnitGoldCost takes integer unitid returns integer
native GetUnitWoodCost takes integer unitid returns integer
native GetUnitBuildTime takes integer unitid returns integer
native GetUpgradeLevel takes integer id returns integer
native GetUpgradeGoldCost takes integer id returns integer
native GetUpgradeWoodCost takes integer id returns integer
Name | Type | is_array | initial_value |
//TESH.scrollpos=0
//TESH.alwaysfold=0
//TESH.scrollpos=0
//TESH.alwaysfold=0
//TESH.scrollpos=0
//TESH.alwaysfold=0
//TESH.scrollpos=0
//TESH.alwaysfold=0
//TESH.scrollpos=0
//TESH.alwaysfold=0
//TESH.scrollpos=0
//TESH.alwaysfold=0
//TESH.scrollpos=0
//TESH.alwaysfold=0
//TESH.scrollpos=0
//TESH.alwaysfold=0
//TESH.scrollpos=0
//TESH.alwaysfold=0
//TESH.scrollpos=0
//TESH.alwaysfold=0
//TESH.scrollpos=0
//TESH.alwaysfold=0
//TESH.scrollpos=0
//TESH.alwaysfold=0
//TESH.scrollpos=0
//TESH.alwaysfold=0
//TESH.scrollpos=0
//TESH.alwaysfold=0
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_dumporders_Actions takes nothing returns nothing
DisplayTextToPlayer(GetLocalPlayer(),0.,0., GetUnitName(GetTriggerUnit())+" : "+OrderId2String(GetIssuedOrderId())+"/"+I2S(GetIssuedOrderId()))
endfunction
//===========================================================================
function InitTrig_dumporders takes nothing returns nothing
gg_trg_dumporders = CreateTrigger( )
TriggerRegisterAnyUnitEventBJ( gg_trg_dumporders, EVENT_PLAYER_UNIT_SPELL_CAST )
TriggerRegisterAnyUnitEventBJ(gg_trg_dumporders,EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
TriggerRegisterAnyUnitEventBJ(gg_trg_dumporders,EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER)
TriggerRegisterAnyUnitEventBJ(gg_trg_dumporders,EVENT_PLAYER_UNIT_ISSUED_ORDER)
TriggerAddAction( gg_trg_dumporders, function Trig_dumporders_Actions )
endfunction
//TESH.scrollpos=2679
//TESH.alwaysfold=0
library_once Main initializer init uses Coins, Utils, StartPosition//, UnitsAI
include "cj_types.j"
include "cj_order.j"
rect ST_GLOBAL_MAP_RECT
bool addingByXR=false
//bool array peon_enabled
define peon_random=-1
define peon_chaos='h00O'
define peon_corrupted='u006'
define peon_human='h00C'
define peon_orc='h019'
define peon_naga='h00E'
define peon_northern='h017'
define peon_nelf='h089'
define peon_helf='h00P'
define peon_undead='h018'
define peon_mech='h06P'
define peon_nature='h01A'
define peon_magic='h051'
define peon_desert='h06N'
multiboard array playerBoards
multiboard array mpMBoard
int array relayedOwnerTablePosition
int array RandPlID //players shuffled
int array SidePlayedCnt
void FillRPID(){
int i = 0
int j
int k
int l
loop
RandPlID[i]=i
i++
exitwhen i > 11
endloop
i=0
loop
j=GetRandomInt(0,11)
k=GetRandomInt(0,11)
l = RandPlID[j]
RandPlID[j] = RandPlID[k]
RandPlID[k] = l
i++
exitwhen i > 7
endloop
}
multiboard spectatorMultiboard=null
int array spectatorPosition
int spectatorMultiboardClockPosition=0
string array names
private multiboarditem cursor
void SetMBValue(int x, int y, string lb)
{
int i=0
if(lb==null) {lb="?"}
loop
if(playerBoards[i]!=null){
cursor=MultiboardGetItem(playerBoards[i],y,x)
MultiboardSetItemValue(cursor,lb)
MultiboardReleaseItem(cursor)
}
i++
exitwhen i>11
endloop
if(x==1){
cursor=MultiboardGetItem(spectatorMultiboard,1,(y-1)*6+1)
MultiboardSetItemValue(cursor,lb)
MultiboardReleaseItem(cursor)
}elseif(x>2 and x<5){
cursor=MultiboardGetItem(spectatorMultiboard,1,(y-1)*6+x-1)
MultiboardSetItemValue(cursor,lb)
MultiboardReleaseItem(cursor)
}elseif(x==5){
cursor=MultiboardGetItem(spectatorMultiboard,spectatorMultiboardClockPosition,10)
MultiboardSetItemValue(cursor,lb)
MultiboardReleaseItem(cursor)
}
}
void AssignSpectatorMultiboard(int x, int y, string lb)
{
cursor=MultiboardGetItem(spectatorMultiboard,x,y)
MultiboardSetItemValue(cursor,lb)
MultiboardReleaseItem(cursor)
}
int currentRound=0
constant timer GameTime=CreateTimer()
constant timer tmrUpdCloneCap=CreateTimer()
int GameTimeMinutes
int GameTimeSeconds
int Ticks
int NextTicks
int RStrikeNextTicks
real SplashW
real hpFactor = 1.0
void UpdCloneCap(){
int i=0
loop
if(CloneCap[i] > BaseCloneCap) {
CloneCap[i]--
}
i++
exitwhen i>11
endloop
}
string GetGameTime()
{
string s=I2S(GameTimeSeconds)
if(GameTimeSeconds<10){s="0"+s}
return "|cffFFFF00"+I2S(GameTimeMinutes)+"|cffFF8000:|cffFFFF00"+s+"|r"
}
void SignalWorkers(){
int i=0
unit u
loop
u = Common_workers[i]
if(GetHandleId(u)!=0) {
//SetResourceAmount(Common_workers[i],GetPlayerState(Player(i),PLAYER_STATE_RESOURCE_GOLD))
if(GetPlayerId(GetLocalPlayer())==i){
PingMinimapEx(GetUnitX(u),GetUnitY(u),0.02,160,160,160,false)
}
}
i++
exitwhen i>11
endloop
u=null
}
void GameTimeExec()
{
Ticks++
if(Ticks>=NextTicks)
{
NextTicks = Ticks + 5
GameTimeSeconds++
if(GameTimeSeconds==60){
GameTimeSeconds=0
GameTimeMinutes++
SplashW = SplashW * 0.85 + 0.15 //
}
SetMBValue(5,3,GetGameTime())
SignalWorkers()
}
}
hashtable tableJU
hashtable tableIN
hashtable tableOr
constant group flowers=CreateGroup()
constant group ugr=CreateGroup()
define RS_radius = 800.
define htKeyAIBTRG='TrAi'
define htKeyCagTmID='CaTm' //used in AntiCaging
define htKeyCagCnt='CaCn'
define htSyncGrKey='SyGr'
define htSyncUnitKey='SyUn'
define htSyncTmrKey='SyTm'
define htKeyBldId2Pred='BlPr'
define H_ELEMENTAL_DEPENDER_UNIT=20
define H_ELEMENTAL_DEPENDER_TIMER=21
define H_ELEMENTAL_DEPENDER_OWNER=22
define H_ELEMENTAL_GENERATOR_LGHT=25 // lighting
define H_ELEMENTAL_GENERATOR_CSTR=26 // caster
define htKeyTmrID=30
rect dummyArea
location dummyAreaCenter
//constant group dummyGroupContainer=CreateGroup()
bool IsGameLoading=true
bool IsGameEnding=false
bool IsMapAllVisible=false
string peonCreator
//resources
int map_start_gold=250
int map_start_lumb='}'
int map_start_legn=1
//modes
int mode_gamemode=-1 //0-pick, 1-random, 2-mirror, 3-draft
int mode_rounds=0
int mode_lines=1 //0-both,1-up,2-down,3-singleline
int mode_autobalance=2 //0-off,1-capturing,2-ai
int mode_fogtime=-1 // 0
real mode_incomeTime=10.
real mode_itm=1.
bool mode_CI=false
bool mode_permamentRace
bool mode_dualraces=false
bool mode_na=false
//bool mode_uo=false //units only
bool mode_tb=false //treasure boxes
bool mode_nb=false //no unit bounty
bool mode_sb=true //special buildings
bool mode_ia=true //items able
bool mode_la=true //legendary able
bool mode_rse=true //rescue strike
bool mode_ur=false //unique races
bool mode_cc=true //caging able
bool mode_gates=false
bool spawn_bstuff=false
bool mode_dom=false
bool mode_nafk=false
bool mode_uai=false //custom unit AI
int mode_taxes=0 //0-normal,1-no taxes,2-high taxes
int mode_lumberLimit=-1
int mode_bans=0
int mode_mp=0
int mode_coins=0 //a value of iterations
int mode_gameLimit=0 //above zero = detect winner
int mode_emp=0 //extended -mp
int mode_nfr=0 //not-full-races
bool array gameAutoTrain
//byforceId
int array wins
location array targetRectLoc
define BaseCloneCap=5
define MaxCloneCap=9
define CloneCapUpdInterval=16
int array chanceToReviveUnit // HE shrine
int array CloneCnt
int array CloneCap
int array chanceToCloneUnit // group of Human shrines
int array chanceToGetElSpirit // Elem shrine
rect array enemyRectByTeam
//for leaderbord
int array mpRsCount
int array RsActive
//int array mpCoinsCount
int array mpDestrCount
//int array mpIncomeCount
string array forceName
unit array Gates
real array GatesIM
bool array GatesPr
//byPlayer
//unit array peon
int array peonsUID
location array startPosition
int array statisticKills
int array statisticBuildings
int array statisticSpecials
int UnitMostKills
int UnitMostKillsId
int array statisticIncomed
real array IncRest
int array statisticRSDamage
int array statisticRSKills
int array statisticCoins
int array statisticCoinsGold
int array pGoldBonuses
int array pGoldBuildings
int array pGoldItems
real array GoldBoxM
int array lumberProduced
constant force leftPlayers=CreateForce()
constant force rightPlayers=CreateForce()
constant force quotaPlayers=CreateForce()
constant force spectatorPlayers=CreateForce()
int array forceId //byPlayer
force array relayedForces
unit array forcedCastle
private bool IsConfigPossible()
{
int pl=CountPlayersInForceBJ(leftPlayers)
int pr=CountPlayersInForceBJ(rightPlayers)
int pq=CountPlayersInForceBJ(quotaPlayers)
int pc=pl+pr
int act_bans=IntegerTertiaryOp(mode_bans>0,2*mode_bans,-mode_bans)
if(mode_mp>0 and pc*mode_mp>RaceSelector_count-act_bans){return false}
if(pc>RaceSelector_count-act_bans){return false}
if(pc*(mode_mp-1)>pq){return false}
if(pc>RaceSelector_count and mode_ur){return false}
if(mode_emp>0 and MathNOK(IMaxBJ(pl,pr)*mode_emp,IMinBJ(pl,pr))*2>pq+pc){return false}
return true
}
void SetUnitAIStatus(bool fl){
mode_uai=fl
//UnitsAI_UnitsAIInit()
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00AI|r enabled. Units will choose targets by its armor type.")
}
void SetArtilleryStatus(bool fl)
{
mode_na=not fl
if(fl){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Artillery|r enabled. You can build structures that attack enemy structures.")
tentacleType='n01C'//'n021'
starfallType='A0GH'//'A08T'
volcanoType='A01I'//'A05H'
tornadoType='A0BD'
//blizzardType='A0D1'//'A0D2'
meteorType='A0I8'
monsoonType='A0I6'
}else{
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00No Artillery|r has been chosen. You cannot build structures that attack enemy structures.")
tentacleType='n021'
starfallType='A08T'
volcanoType='A05H'
tornadoType='A0BQ'
//blizzardType='A0D2'
meteorType='A0I9'
monsoonType='A0I7'
}
bj_forLoopAIndex=0
bj_forLoopAIndexEnd=11
loop
exitwhen bj_forLoopAIndex>bj_forLoopAIndexEnd
SetPlayerUnitAvailableBJ('h001',fl,Player(bj_forLoopAIndex))
SetPlayerUnitAvailableBJ('h048',fl,Player(bj_forLoopAIndex))
SetPlayerUnitAvailableBJ('h01E',fl,Player(bj_forLoopAIndex))
bj_forLoopAIndex=bj_forLoopAIndex+1
endloop
}
void SetNAFKStatus(bool fl)
{
mode_nafk=fl
if(not fl){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00No AFK|r mode has been disabled. Command -afk enabled.")
}else{
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00No AFK|r has been chosen. Command -afk disabled.")
}
}
void SetCoinsStatus()
{
mode_coins=1
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Coin|r has been chosen. There will be a coin spawn every 40 seconds.")
}
void SetCCoinsStatus()
{
mode_coins=10
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Crazy Coins|r has been chosen. Ten coins will spawn every 40 seconds.")
}
void SetDRStatus(bool fl)
{
mode_dualraces=fl
if(not fl){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Dual Race|r mode has been disabled.")
}else{
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Dual Race|r has been chosen. Each race can be chosen more than once per team.")
}
}
void SetURStatus(bool fl)
{
mode_ur=fl
if(fl){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Unique Races|r has been chosen. Each race can be chosen only once (even across the teams).")
if((CountPlayersInForceBJ(leftPlayers)+CountPlayersInForceBJ(rightPlayers))+mode_bans*2>10){
mode_ur=false
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Unique Races|r mode has been disabled due so many players.")
}
}else{
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Unique Races|r mode has been disabled.")
}
}
void SetTBStatus(bool fl)
{
mode_tb=fl
if(fl){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00No Treasure Box|r mode has been disabled.")
}else{
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00No Treasure Box|r has been chosen. You cannot build Treasure Boxes.")
}
bj_forLoopAIndex=0
bj_forLoopAIndexEnd=11
loop
exitwhen bj_forLoopAIndex>bj_forLoopAIndexEnd
SetPlayerUnitAvailableBJ('h008',fl,Player(bj_forLoopAIndex))
bj_forLoopAIndex=bj_forLoopAIndex+1
endloop
}
void SetNBStatus(bool fl)
{
mode_nb=fl
if(fl){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00No Bounty|r mode has been disabled.")
}else{
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00No Bounty|r has been chosen. Neither units nor buildings will give bounty when destroyed.")
}
bj_forLoopAIndex=0
bj_forLoopAIndexEnd=11
loop
exitwhen bj_forLoopAIndex>bj_forLoopAIndexEnd
SetPlayerFlagBJ(PLAYER_STATE_GIVES_BOUNTY,fl,Player(bj_forLoopAIndex))
bj_forLoopAIndex=bj_forLoopAIndex+1
endloop
}
void SetSBStatus(bool fl)
{
mode_sb=fl
if(fl){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00No Specials|r mode has been disabled.")
}else{
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00No Specials|r has been chosen. You can't build special buildings except towers and Treasure Boxes.")
}
bj_forLoopAIndex=0
bj_forLoopAIndexEnd=11
loop
exitwhen bj_forLoopAIndex>bj_forLoopAIndexEnd
SetPlayerUnitAvailableBJ('h01P',fl,Player(bj_forLoopAIndex))
SetPlayerUnitAvailableBJ('h056',fl,Player(bj_forLoopAIndex))
SetPlayerUnitAvailableBJ('h014',fl,Player(bj_forLoopAIndex))
SetPlayerUnitAvailableBJ('h03Q',fl,Player(bj_forLoopAIndex))
SetPlayerUnitAvailableBJ('h01O',fl,Player(bj_forLoopAIndex))
SetPlayerUnitAvailableBJ('o000',fl,Player(bj_forLoopAIndex))
SetPlayerUnitAvailableBJ('h006',fl,Player(bj_forLoopAIndex))
SetPlayerUnitAvailableBJ('n01J',fl,Player(bj_forLoopAIndex))
SetPlayerUnitAvailableBJ('h073',fl,Player(bj_forLoopAIndex))
SetPlayerUnitAvailableBJ('h05L',fl,Player(bj_forLoopAIndex))
bj_forLoopAIndex=bj_forLoopAIndex+1
endloop
}
void SetIAStatus(bool fl)
{
mode_ia=fl
if(fl){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00No Items|r mode has been disabled.")
}else{
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00No Items|r has been chosen. The castle doesn't sell any items.")
}
}
void SetLAStatus(bool fl)
{
mode_la=fl
if(fl){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00No Legendaries|r mode has been disabled.")
}else{
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00No Legendaries|r has been chosen. You don't get food to buy legendary buildings.")
}
}
void SetRSEStatus(bool fl)
{
mode_rse=fl
if(fl){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00No Devastating Strike|r mode has been disabled.")
}else{
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00No Devastating Strike|r has been chosen. Your worker doesn't have a Devastating Strike!")
}
}
void SetLLStatus(int val)
{
if(val<150){
mode_lumberLimit=-1
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Lumber Limit|r mode has been disabled.")
}else{
mode_lumberLimit=val
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Lumber Limit|r has been set to |cffFFFF00"+I2S(mode_lumberLimit)+"|r.")
}
}
void SetITStatus(real val)
{
mode_incomeTime=RMaxBJ(RMinBJ(val,15.),5.)
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Income Timer|r has been set to |cffFFFF00"+R2SW(mode_incomeTime,2,1)+"|r.")
}
void SetTStatus(int var)
{
mode_taxes=var //0-normal,1-no taxes,2-high taxes
if(mode_taxes==1){
Income_mTaxesValue=1000.
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00No Taxes|r has been chosen. You don't have to pay taxes on your income.")
}elseif(mode_taxes==2){
Income_mTaxesValue=12.5
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00High Taxes|r has been chosen. Tax rate increases 10% every 12.5 income.")
}
}
void SetCCStatus(bool fl)
{
mode_cc=fl
if(fl){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Caging|r mode has been disabled.")
}else{
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Caging|r has been chosen. You can trap units with your buildings")
}
}
void SetDOMStatus(bool fl)
{
mode_dom=fl
if(fl){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Domination|r has been chosen. Forces will loose income(up to 30%) if 10 or more units besiege its base.")
}else{
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"TODO::SetDOMStatus(false)")
}
}
void SetBALStatus(int var)
{
if(var>2){
DisplayTextToPlayer(Player(0),0.,0.,"|cffFF0000Wrong Autobalance variation!|r")
return
}
mode_autobalance=var
if(var==0){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Autobalance|r has been setted to |cffFFFF000|r. All units of any left player will be divided between members in team.")
}elseif(var==1){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Autobalance|r has been setted to |cffFFFF001|r. All depended players of any left player will be shared between members in team.")
}else{
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Autobalance|r has been setted to |cffFFFF001|r. AI will take control of any left player.")
}
}
void SetRBANStatus(int var)
{
if(var==0){
mode_bans=-1
}else{
mode_bans=-var
}
if(not IsConfigPossible()){
DisplayTextToPlayer(Player(0),0.,0.,"|cffFF0000Too many players for Random Ban Race mode!|r")
mode_bans=0
return
}
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Random Ban Race|r has been chosen. Number of bans: |cffFFFF00"+I2S(IAbsBJ(mode_bans))+"|r.")
}
void SetBANStatus(int var)
{
if(var==0){
mode_bans=1
}else{
mode_bans=var
}
if(not IsConfigPossible()){
DisplayTextToPlayer(Player(0),0.,0.,"|cffFF0000Too many players for Ban Race mode!|r")
mode_bans=0
return
}
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Ban Race|r has been chosen. Number of bans per team: |cffFFFF00"+I2S(mode_bans)+"|r.")
}
void SetEMPStatus(int var)
{
if(var==0){
mode_emp=1
}else{
mode_emp=var
}
mode_mp=0
if(not IsConfigPossible()){
DisplayTextToPlayer(Player(0),0.,0.,"|cffFF0000Too many players for Extended Multi Race mode!|r")
mode_emp=0
return
}
mode_autobalance=1
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Extended Multiple Players|r has been chosen. Parameter's value is: |cffFFFF00"+I2S(mode_emp)+"|r.")
}
void SetMPStatus(int var)
{
if(var<1 or var>5){
DisplayTextToPlayer(Player(0),0.,0.,"|cffFF0000Wrong number of players per player! Must be between 2 and 4!|r")
return
}
mode_emp=0
mode_mp=var
if(not IsConfigPossible()){
DisplayTextToPlayer(Player(0),0.,0.,"|cffFF0000Too many players for Multi Race mode!|r")
mode_mp=0
return
}
mode_autobalance=1
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Multiple Players|r has been chosen. Number of additional players per human player: |cffFFFF00"+I2S(var)+"|r")
}
void SetGRLStatus(int param)
{
if(IAbsBJ(param)>5){
mode_gameLimit=param
if(param>0){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Round time limit for win|r has been activated. Round will automatically end after "+I2S(IAbsBJ(param))+" minutes and owner of first building will win.")
}else{
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Round time limit for draw|r has been activated. Round will automatically end after "+I2S(IAbsBJ(param))+" minutes with draw result.")
}
}else{
DisplayTextToPlayer(Player(0),0.,0.,"|cffFF0000Wrong value of minutes for round time limitation! Must be more 5!|r")
}
}
void SetNFRStatus(int param)
{
int p=RaceSelector_count
if(param==0){param=1}
RaceSelector_count=RaceSelector_count-param
if(not IsConfigPossible()){
DisplayTextToPlayer(Player(0),0.,0.,"|cffFF0000Not possible to disable so many races!|r")
RaceSelector_count=p
return
}
mode_nfr=param
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00System-races-pool|r has been changed. There are |cffFFFF00"+I2S(param)+"|r new races have been removed.|r")
}
private void ReleaseLearningTec(){
integer i=0
integer j
player p
unit u
loop
exitwhen i>11
j=1
p=Player(i)
loop
u=CreateUnitAtLoc(p,'tec0'+j,dummyAreaCenter,.0)
ShowUnit(u,false)
j++
exitwhen j>3
endloop
i++
endloop
}
void ReleaseStatisticByPid(int i)
{
GoldBoxM[i]=1.
IncRest[i] = 0.
Income_ivalue[i]=0.
Income_mCachedIncome[i] = 0
statisticKills[i]=-1
statisticBuildings[i]=-1
statisticSpecials[i]=-1
statisticIncomed[i]=-1
statisticRSDamage[i]=-1
statisticRSKills[i]=-1
statisticCoins[i]=-1
statisticCoinsGold[i]=-1
pGoldBonuses[i]=-1
pGoldBuildings[i]=-1
pGoldItems[i]=-1
lumberProduced[i]=0
}
void PrepareStatisticByPid(int i)
{
GoldBoxM[i]=1.
IncRest[i] = 0.
Income_ivalue[i]=5.
Income_mCachedIncome[i]=5
statisticKills[i]=0
statisticBuildings[i]=0
statisticSpecials[i]=0
statisticIncomed[i]=0
statisticRSDamage[i]=0
statisticRSKills[i]=0
statisticCoins[i]=0
statisticCoinsGold[i]=0
pGoldBonuses[i]=0
pGoldBuildings[i]=0
pGoldItems[i]=0
lumberProduced[i]='}'
}
string array savedPlayerNames
define GetColoredName(pid) = savedPlayerNames[pid]
private string GetPlayerNameWithColor(int pid)
{
playercolor pc=GetPlayerColor(Player(pid))
string res
if(pc==PLAYER_COLOR_RED){
res="|cffff0000"
}elseif(pc==PLAYER_COLOR_BLUE){
res="|cff0000FF"
}elseif(pc==PLAYER_COLOR_CYAN){
res="|cff00FFFF"
}elseif(pc==PLAYER_COLOR_PURPLE){
res="|cff800080"
}elseif(pc==PLAYER_COLOR_YELLOW){
res="|cffFFFF00"
}elseif(pc==PLAYER_COLOR_ORANGE){
res="|cffFFCC00"
}elseif(pc==PLAYER_COLOR_GREEN){
res="|cff00ff00"
}elseif(pc==PLAYER_COLOR_PINK){
res="|cffff00ff"
}elseif(pc==PLAYER_COLOR_LIGHT_GRAY){
res="|cffc0c0c0"
}elseif(pc==PLAYER_COLOR_LIGHT_BLUE){
res="|cffCCFFFF"
}elseif(pc==PLAYER_COLOR_AQUA){
res="|cff087329"
}elseif(pc==PLAYER_COLOR_BROWN){
res="|cffC16D00"
}else{
res="|CFFFFFFFF"
}
pc=null
return res
}
public void UpdatePlayerName(int pid)
{
savedPlayerNames[pid]=GetPlayerNameWithColor(pid)+GetPlayerName(Player(pid))+"|r"
}
private void EnumReturnToQuotaRelayed(){
player p=GetEnumPlayer()
int i=GetPlayerId(p)
//multiboarditem mbitem
ForceRemovePlayer(leftPlayers,p)
ForceRemovePlayer(rightPlayers,p)
ForceAddPlayer(quotaPlayers,p)
mpMBoard[i]=null
p=null
}
private void SunMP(){
int i=0
int j
player p
bool playerForce
loop
if(relayedForces[i]!=null){
ForForce(relayedForces[i],function EnumReturnToQuotaRelayed)
SetPlayerName(Player(i),names[i])
}
i++
exitwhen i>11
endloop
i=0
loop
if(relayedForces[i]!=null){
playerForce=IsPlayerInForce(Player(i),leftPlayers)
j=1
loop
p=AllocateFreeSlot(playerForce)
ForceRemovePlayer(quotaPlayers,p)
ForceAddPlayer(relayedForces[i],p)
if(playerForce){
ForceAddPlayer(leftPlayers,p)
startPosition[GetPlayerId(p)]=PolarProjectionBJ(startPosition[i],96.*j,0.)
}else{
ForceAddPlayer(rightPlayers,p)
startPosition[GetPlayerId(p)]=PolarProjectionBJ(startPosition[i],96.*j,180.)
}
SetPlayerName(p,names[i])
savedPlayerNames[GetPlayerId(p)]=GetPlayerNameWithColor(GetPlayerId(p))+GetPlayerName(p)+"|r"
forceId[GetPlayerId(p)]=forceId[i]
j++
exitwhen j>=mode_mp
endloop
}
i++
exitwhen i>11
endloop
}
private void SunEMP()
{
int pl=CountPlayersInForceBJ(leftPlayers)
int pr=CountPlayersInForceBJ(rightPlayers)
int pos=MathNOK(IMaxBJ(pl,pr)*mode_emp,IMinBJ(pl,pr))
int apl=pos/pl
int apr=pos/pr
int i=0
int j
int l
player p
bool playerForce
loop
if(relayedForces[i]!=null){
ForForce(relayedForces[i],function EnumReturnToQuotaRelayed)
SetPlayerName(Player(i),names[i])
}
i++
exitwhen i>11
endloop
i=0
loop
if(relayedForces[i]!=null){
playerForce=IsPlayerInForce(Player(i),leftPlayers)
l=IntegerTertiaryOp(playerForce,apl,apr)
j=1
loop
exitwhen j>=l
p=AllocateFreeSlot(playerForce)
ForceRemovePlayer(quotaPlayers,p)
ForceAddPlayer(relayedForces[i],p)
if(playerForce){
ForceAddPlayer(leftPlayers,p)
startPosition[GetPlayerId(p)]=PolarProjectionBJ(startPosition[i],96.*j,0.)
}else{
ForceAddPlayer(rightPlayers,p)
startPosition[GetPlayerId(p)]=PolarProjectionBJ(startPosition[i],96.*j,180.)
}
SetPlayerName(p,names[i])
savedPlayerNames[GetPlayerId(p)]=GetPlayerNameWithColor(GetPlayerId(p))+GetPlayerName(p)+"|r"
forceId[GetPlayerId(p)]=forceId[i]
j++
endloop
}
i++
exitwhen i>11
endloop
}
public void SunAMP()
{
if(mode_emp>0){
SunEMP()
return
}elseif(mode_mp>0){
SunMP()
return
}
DisplayTimedTextToPlayer(GetLocalPlayer(),0.,0.,60.,"Unknown exception at module Main::SunAMP. Please report.")
}
unit BG1
unit BG2
destructable D1
destructable D2
public void SetBottomLanePathable(boolean en){
real x = -1440.//448
real y = -835.
/*
loop
SetTerrainPathable(1472.,y,PATHING_TYPE_WALKABILITY,en)
SetTerrainPathable(1472.,y,PATHING_TYPE_FLYABILITY,en)
SetTerrainPathable(-1472.,y,PATHING_TYPE_WALKABILITY,en)
SetTerrainPathable(-1472.,y,PATHING_TYPE_FLYABILITY,en)
y+=32.
exitwhen(y>=-448.)
endloop*/
if(en) {
if(BG1!=null) {RemoveUnit(BG1); BG1=null}
if(BG2!=null) {RemoveUnit(BG2);BG2=null}
if(D1!=null) {RemoveDestructable(D1);D1=null}
if(D2!=null) {RemoveDestructable(D2);D2=null}
}
else {
BG1 = CreateUnit(Player(15),'h077',x,y,0.)
BG2 = CreateUnit(Player(15),'h077',-x,y,0.)
D1 = CreateDestructable('B000',x,0.,0.,1.,0)
D2 = CreateDestructable('B000',-x,0.,0.,1.,0)
}
}
public void init()
{
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"Main_Init")
int i=0
tableJU=InitHashtable()
tableIN=InitHashtable()
tableOr=InitHashtable()
ST_GLOBAL_MAP_RECT = GetWorldBounds()
SetBottomLanePathable(false)
SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 2200.0, 0.5)
//for flower
dummyArea=Rect(-280.,3200.,-64.,3400.)
loop
forceId[i]=0
if(GetPlayerSlotState(Player(i))==PLAYER_SLOT_STATE_PLAYING){
ForceAddPlayer(leftPlayers,Player(i))
CreateFogModifierRectBJ(true,Player(i),FOG_OF_WAR_VISIBLE,dummyArea)
startPosition[i]=StartPosition_GiveMeRespawn(true)//GetPlayerStartLocationLoc(Player(i))
relayedForces[i]=CreateForce()
names[i]=GetPlayerName(Player(i))
}elseif(GetPlayerSlotState(Player(i))==PLAYER_SLOT_STATE_EMPTY){
ForceAddPlayer(quotaPlayers,Player(i))
}
forceId[i+6]=1
if(GetPlayerSlotState(Player(i+6))==PLAYER_SLOT_STATE_PLAYING){
ForceAddPlayer(rightPlayers,Player(i+6))
CreateFogModifierRectBJ(true,Player(i+6),FOG_OF_WAR_VISIBLE,dummyArea)
startPosition[i+6]=StartPosition_GiveMeRespawn(false)//GetPlayerStartLocationLoc(Player(i+6))
relayedForces[i+6]=CreateForce()
names[i+6]=GetPlayerName(Player(i+6))
}elseif(GetPlayerSlotState(Player(i+6))==PLAYER_SLOT_STATE_EMPTY){
ForceAddPlayer(quotaPlayers,Player(i+6))
}
i++
exitwhen i>=6
endloop
dummyAreaCenter=Location(-192.,3392.)
targetRectLoc[0]=GetRectCenter(gg_rct_RightCastle)
targetRectLoc[1]=GetRectCenter(gg_rct_LeftCastle)
//backway +2
targetRectLoc[2]=GetRectCenter(gg_rct_LeftCastle)
targetRectLoc[3]=GetRectCenter(gg_rct_RightCastle)
//
enemyRectByTeam[0]=gg_rct_RightPlayers
enemyRectByTeam[1]=gg_rct_LeftPlayers
//
forceName[0]="|cffff0303Western Forces|r"
forceName[1]="|cff20c000Eastern Forces|r"
//fun units
player p=Player(12) //neutral hostile
i=0
loop
GroupAddUnit(flowers,CreateUnit(p,'h00L',-192.,3300.,0.))
i++
exitwhen i>33
endloop
p=Player(15)
/*
CreateUnit(p,'h00L',-192.,3392.,270.)
CreateUnit(p,'nshp',320.,1856.,270.)
SetUnitColor(CreateUnit(p,'nmrk',-256.,-2816.,270.),ConvertPlayerColor(0))
CreateUnit(p,'nder',-4735.4,3246.1,109.526)
CreateUnit(p,'nfro',-1091.1,2532.8,224.842)
CreateUnit(p,'nfro',-1750.8,3170.3,12.503)
CreateUnit(p,'nfro',-4208.5,-3103.9,62.844)
CreateUnit(p,'nrac',3575.1,-3410.6,28.565)
CreateUnit(p,'nrac',215.3,-2989.1,39.991)
CreateUnit(p,'nder',-734.9,-2927.2,354.77)
CreateUnit(p,'nder',-778.4,3161.3,100.297)
CreateUnit(p,'nder',486.3,3092.6,147.507)
CreateUnit(p,'nder',2097.6,2634.9,173.293)
CreateUnit(p,'necr',2734.8,2968.,320.909)
CreateUnit(p,'necr',-601.3,1917.2,359.418)
CreateUnit(p,'necr',-2505.3,3205.6,108.405)
CreateUnit(p,'necr',-2553.8,3097.9,314.669)
CreateUnit(p,'nfro',4466.5,3139.7,42.463)
CreateUnit(p,'nfro',539.6,2646.5,108.054)
CreateUnit(p,'necr',-5469.2,2773.2,240.63)
CreateUnit(p,'nrac',-3882.6,3455.9,171.348)
CreateUnit(p,'necr',-2951.9,3480.5,75.248)
CreateUnit(p,'nder',-1995.2,3031.8,320.569)
CreateUnit(p,'nder',-4755.9,-3285.9,96.265)
CreateUnit(p,'necr',-2813.4,-3182.2,270.799)
CreateUnit(p,'nrac',-2009.7,-3134.2,263.79)
CreateUnit(p,'nder',5212.3,-3150.6,44.199)
CreateUnit(p,'nfro',4753.5,-3152.8,349.596)
CreateUnit(p,'nrac',-10.6,3013.2,169.052)
CreateUnit(p,'ndwm',1689.8,-2774.7,192.19)
CreateUnit(p,'ndog',-3610.9,-3243.8,118.216)
CreateUnit(p,'ndog',1334.7,2849.5,136.344)
CreateUnit(p,'ndog',3868.8,3221.9,302.375)
CreateUnit(p,'nshe',-5537.3,3457.1,52.22)
CreateUnit(p,'nsno',824.5,3262.9,175.677)
CreateUnit(p,'nsno',202.1,-2945.4,216.679)
CreateUnit(p,'npnw',745.5,2441.4,238.74)
CreateUnit(p,'npnw',-1503.3,3397.6,70.468)
CreateUnit(p,'nhmc',-1045.4,2540.1,279.314)
CreateUnit(p,'nskk',-1729.,3470.5,317.767)
CreateUnit(p,'nskk',-2433.4,2555.1,311.109)
CreateUnit(p,'nskk',3859.9,-3350.3,329.995)
CreateUnit(p,'ncrb',4721.1,-3370.7,285.192)
CreateUnit(p,'nalb',4473.6,-3164.3,324.601)
CreateUnit(p,'nhmc',4158.9,-3098.4,273.93)
*/
//
ReleaseLearningTec()
bj_forLoopAIndex=0
bj_forLoopAIndexEnd=11
loop
exitwhen bj_forLoopAIndex>bj_forLoopAIndexEnd
SetPlayerFlagBJ(PLAYER_STATE_GIVES_BOUNTY,true,Player(bj_forLoopAIndex))
savedPlayerNames[bj_forLoopAIndex]=GetPlayerNameWithColor(bj_forLoopAIndex)+GetPlayerName(Player(bj_forLoopAIndex))+"|r"
gameAutoTrain[bj_forLoopAIndex]=true
chanceToCloneUnit[bj_forLoopAIndex]=0
CloneCnt[bj_forLoopAIndex]=0
CloneCap[bj_forLoopAIndex]=BaseCloneCap
bj_forLoopAIndex=bj_forLoopAIndex+1
endloop
SetMapFlag(MAP_LOCK_RESOURCE_TRADING,true)
FogMaskEnable(false)
FogEnable(false)
//
CreateQuestBJ(0,"Game Modes","Gamemodes are entered by the red player in the first 20 seconds of game time.\nA gamemode consists of a dash followed by two characters and a number:\n\nThe first character determines the race distribution.\n|cffFFFF00p :|r pick race\n|cffFFFF00d :|r draft race\n|cffFFFF00r :|r random race\n|cffFFFF00m :|r mirror mode (random)\n\nThe second character determines how long races are kept:\n|cffFFFF00g :|r The race is determined in round one and then |cffFFFF80kept for the whole game|r\n|cffFFFF00r :|r The race is determined before |cffFFFF80EACH round|r\n\nThe 3rd character is a number between |cffFFFF001|r and |cffFFFF006|r determining the number of wins for overall victory\n\n|cffFFFF00Examples:|r\n-|cffFF0000r|cff00FF00r|cffFFFF002|r would start a |cffFF0000RANDOM|r race |cff00FF00EACH ROUND|r game with |cffFFFF002 wins|r for overall victory\n-|cffFF0000p|cff00FF00g|cffFFFF004|r would start a |cffFF0000PICK|r race |cff00FF00ONCE FOR WHOLE GAME|r game with |cffFFFF004 wins|r for overall victory","ReplaceableTextures\\CommandButtons\\BTNPickUpItem.blp")
CreateQuestBJ(0,"Modifications","TRIGSTR_005","ReplaceableTextures\\CommandButtons\\BTNSpy.blp")
CreateQuestBJ(0,"Other Commands","TRIGSTR_006","ReplaceableTextures\\CommandButtons\\BTNAuraOfDarkness.blp")
CreateQuestBJ(2,"First Match?","|cffFFFF80This is your very first match of Castle Fight?|r\n\nThis game is easy to learn - just pick a builder and construct something.\nRead the basic hints in the questlog and watch for armor and damage types to counter your enemies best.\n\n|cffFF0000Note that the game may have more than one round, so please don't leave at the end of the round, another round may come after this one!.|r\n\nGood luck and have fun!","ReplaceableTextures\\CommandButtons\\BTNSelectHeroOff.blp")
CreateQuestBJ(2,"Basic Hints","-Don't use your Rescue Strike if only 3 units are attacking your building and try to use it only if one building is about to be destroyed, but don't wait with your RS until a few buildings are down. Destroyed buildings gives a huge advantage to the enemy team!\n\n-Some units are particularly strong against others because of their damage/armor type or abilities. Try to build units with best armor and attack types considering what units your enemies have built. You can type \"-armor\" to see a list of which attack type is good/bad against different armor type. In addition you'll see the same list if you when you set mouse pointer over the attack or armor icon of a unit\n\n-CF is a TEAM GAME. If there is an enemy unit with divine armor and you can't build chaos damage units, ask a team mate to help you with chaos instead of trying it yourself. Also ask teammates to build towers if you cannot build 'em.\n\n|cffFF0000 There are a lot of tutorials and articles about Castle Fight in the Internet.|r","ReplaceableTextures\\CommandButtons\\BTNMilitia.blp")
CreateQuestBJ(2,"About","|cffFFFF80The recommended gamemode is 3x3 with 3 wins (to ensure that nobody with a slow pc lags out).|r\n\nMap is based on CF 1.14b by |cffFFFF00Gex|r; CF 1.22ES by |c0000ffffElf_Stratigo|r and |c0000ffffVam-pirrr|r.\nAuthors of races:\nOrcs - |cffFFFF00gex|r\nHumans - |cffFFFF00gex|r\nElf Union - |cffFFFF00gex|r\nUndead - |cffFFFF00gex|r\nChaos - |cffFFFF00gex|r\nNaga - |cffFFFF00gex|r\nCorrupted - |cffFFFF00Natac|r\nNorthern - |cffFFFF00gex|r\nNight Elf - |cffFFFF00gex|r\nMechanical - |cffFFFF00gex|r\nNature - |cffFFFF00sushi159|r\nElementals - |cffFFFF00Vam-pirrr|r, |cffFFFF00K_O_S|r, |cffFFFF00Elf_Stratigo|r, |cffFFFF00sushi159|r\nDesert - |cffFFFF00Ricirich91 \n\nExternal models: Sin (Thrikodius), Mage (ossus)\nThanks to the next tools developers: |cffFFFF00Vexorian|r, |cffFFFF00Adolf|r, |cffFFFF00Shadow Daemon|r, |cffFFFF00PitzerMike|r, |cffFFFF00Doc|r, |cffFFFF00ZeToX2007|r.","ReplaceableTextures\\CommandButtons\\BTNTomeOfRetraining.blp")
}
endlibrary
library MMD initializer init
globals
public constant integer GOAL_NONE = 101
public constant integer GOAL_HIGH = 102
public constant integer GOAL_LOW = 103
public constant integer TYPE_STRING = 101
public constant integer TYPE_REAL = 102
public constant integer TYPE_INT = 103
public constant integer OP_ADD = 101
public constant integer OP_SUB = 102
public constant integer OP_SET = 103
public constant integer SUGGEST_NONE = 101
public constant integer SUGGEST_TRACK = 102
public constant integer SUGGEST_LEADERBOARD = 103
public constant integer FLAG_DRAWER = 101
public constant integer FLAG_LOSER = 102
public constant integer FLAG_WINNER = 103
public constant integer FLAG_LEAVER = 104
public constant integer FLAG_PRACTICING = 105
endglobals
///////////////////////////////////////////////////////////////
/// Private variables and constants
///////////////////////////////////////////////////////////////
globals
private constant boolean SHOW_DEBUG_MESSAGES = true
private constant string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-+= \\!@#$%^&*()/?>.<,;:'\"{}[]|`~"
private constant integer num_chars = StringLength(chars)
private string array flags
private string array goals
private string array ops
private string array types
private string array suggestions
private boolean initialized = false
private gamecache gc = null
private constant string ESCAPED_CHARS = " \\"
private constant integer CURRENT_VERSION = 1
private constant integer MINIMUM_PARSER_VERSION = 1
private constant string FILENAME = "MMD.Dat"
private constant string M_KEY_VAL = "val:"
private constant string M_KEY_CHK = "chk:"
private constant integer NUM_SENDERS_NAIVE = 1
private constant integer NUM_SENDERS_SAFE = 3
private integer num_senders = NUM_SENDERS_NAIVE
private integer num_msg = 0
private timer clock = CreateTimer()
private string array q_msg
private real array q_time
private integer array q_index
private keyword QueueNode
private QueueNode q_head = 0
private QueueNode q_tail = 0
endglobals
///////////////////////////////////////////////////////////////
/// Private functions
///////////////////////////////////////////////////////////////
///Triggered when tampering is detected. Increases the number of safeguards against tampering.
public function RaiseGuard takes string reason returns nothing
debug if SHOW_DEBUG_MESSAGES then
debug call BJDebugMsg("MMD: Guard Raised! (" + reason + ")")
debug endif
set num_senders = NUM_SENDERS_SAFE //increase number of players voting on each message
endfunction
///Returns seconds elapsed in game time
private function time takes nothing returns real
return TimerGetElapsed(clock)
endfunction
///Initializes the char-to-int conversion
private function prepC2I takes nothing returns nothing
local integer i = 0
local string id
loop
exitwhen i >= num_chars
set id = SubString(chars, i, i+1)
if id == StringCase(id, true) then
set id = id + "U"
endif
call StoreInteger(gc, "c2i", id, i)
set i = i + 1
endloop
endfunction
///Converts a character to an integer
private function C2I takes string c returns integer
local integer i
local string id = c
if id == StringCase(id, true) then
set id = id + "U"
endif
set i = GetStoredInteger(gc, "c2i", id)
if (i < 0 or i >= num_chars or SubString(chars, i, i+1) != c) and HaveStoredInteger(gc, "c2i", id) then
//A cheater sent a fake sync to screw with the cached values
set i = 0
loop
exitwhen i >= num_chars //just a weird character
if c == SubString(chars, i, i+1) then //cheating!
call RaiseGuard("c2i poisoned")
call StoreInteger(gc, "c2i", id, i)
exitwhen true
endif
set i = i + 1
endloop
endif
return i
endfunction
///Computes a weak hash value, hopefully secure enough for our purposes
private function poor_hash takes string s, integer seed returns integer
local integer n = StringLength(s)
local integer m = n + seed
local integer i = 0
loop
exitwhen i >= n
set m = m * 41 + C2I(SubString(s, i, i+1))
set i = i + 1
endloop
return m
endfunction
///Stores previously sent messages for tamper detection purposes
private struct QueueNode
readonly real timeout
readonly string msg
readonly integer checksum
readonly string key
public QueueNode next = 0
public static method create takes integer id, string msg returns QueueNode
local QueueNode this = QueueNode.allocate()
set .timeout = time() + 7.0 + GetRandomReal(0, 2+0.1*GetPlayerId(GetLocalPlayer()))
set .msg = msg
set .checksum = poor_hash(.msg, id)
set .key = I2S(id)
return this
endmethod
private method onDestroy takes nothing returns nothing
call FlushStoredInteger(gc, M_KEY_VAL+.key, .msg)
call FlushStoredInteger(gc, M_KEY_CHK+.key, .key)
set .msg = null
set .key = null
set .next = 0
endmethod
public method send takes nothing returns nothing
call StoreInteger(gc, M_KEY_VAL+.key, .msg, .checksum)
call StoreInteger(gc, M_KEY_CHK+.key, .key, .checksum)
call SyncStoredInteger(gc, M_KEY_VAL+.key, .msg)
call SyncStoredInteger(gc, M_KEY_CHK+.key, .key)
endmethod
endstruct
///Returns true for a fixed size uniform random subset of players in the game
private function isEmitter takes nothing returns boolean
local integer i = 0
local integer n = 0
local integer r
local integer array picks
local boolean array pick_flags
loop
exitwhen i >= 12
if GetPlayerController(Player(i)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
if n < num_senders then //initializing picks
set picks[n] = i
set pick_flags[i] = true
else //maintain the invariant 'P(being picked) = c/n'
set r = GetRandomInt(0, n)
if r < num_senders then
set pick_flags[picks[r]] = false
set picks[r] = i
set pick_flags[i] = true
endif
endif
set n = n + 1
endif
set i = i + 1
endloop
return pick_flags[GetPlayerId(GetLocalPlayer())]
endfunction
///Places meta-data in the replay and in network traffic
private function emit takes string message returns nothing
local QueueNode q
if not initialized then
call BJDebugMsg("MMD Emit Error: Library not initialized yet.")
return
endif
//remember sent messages for tamper check
set q = QueueNode.create(num_msg, message)
if q_head == 0 then
set q_head = q
else
set q_tail.next = q
endif
set q_tail = q
//send new message
set num_msg = num_msg + 1
if isEmitter() then
call q.send()
endif
endfunction
///Performs tamper checks
private function tick takes nothing returns nothing
local QueueNode q
local integer i
//check previously sent messages for tampering
set q = q_head
loop
exitwhen q == 0 or q.timeout >= time()
if not HaveStoredInteger(gc, M_KEY_VAL+q.key, q.msg) then
call RaiseGuard("message skipping")
call q.send()
elseif not HaveStoredInteger(gc, M_KEY_CHK+q.key, q.key) then
call RaiseGuard("checksum skipping")
call q.send()
elseif GetStoredInteger(gc, M_KEY_VAL+q.key, q.msg) != q.checksum then
call RaiseGuard("message tampering")
call q.send()
elseif GetStoredInteger(gc, M_KEY_CHK+q.key, q.key) != q.checksum then
call RaiseGuard("checksum tampering")
call q.send()
endif
set q_head = q.next
call q.destroy()
set q = q_head
endloop
if q_head == 0 then
set q_tail = 0
endif
//check for future message tampering
set i = 0
loop
exitwhen not HaveStoredInteger(gc, M_KEY_CHK+I2S(num_msg), I2S(num_msg))
call RaiseGuard("message insertion")
call emit("Blank")
set i = i + 1
exitwhen i >= 10
endloop
endfunction
///Replaces control characters with escape sequences
private function pack takes string value returns string
local integer j
local integer i = 0
local string result = ""
local string c
loop //for each character in argument string
exitwhen i >= StringLength(value)
set c = SubString(value, i, i+1)
set j = 0
loop //for each character in escaped chars string
exitwhen j >= StringLength(ESCAPED_CHARS)
//escape control characters
if c == SubString(ESCAPED_CHARS, j, j+1) then
set c = "\\" + c
exitwhen true
endif
set j = j + 1
endloop
set result = result + c
set i = i + 1
endloop
return result
endfunction
///Updates the value of a defined variable for a given player
private function update_value takes string name, player p, string op, string value, integer val_type returns nothing
local integer id = GetPlayerId(p)
if p == null or id < 0 or id >= 12 then
call BJDebugMsg("MMD Set Error: Invalid player. Must be P1 to P12.")
elseif val_type != GetStoredInteger(gc, "types", name) then
call BJDebugMsg("MMD Set Error: Updated value of undefined variable or used value of incorrect type.")
elseif StringLength(op) == 0 then
call BJDebugMsg("MMD Set Error: Unrecognized operation type.")
elseif StringLength(name) > 50 then
call BJDebugMsg("MMD Set Error: Variable name is too long.")
elseif StringLength(name) == 0 then
call BJDebugMsg("MMD Set Error: Variable name is empty.")
else
call emit("VarP " + I2S(id) + " " + pack(name) + " " + op + " " + value)
endif
endfunction
///Defines an event's arguments and format
private function DefineEvent takes string name, integer num_args, string format, string arg_data returns nothing
if GetStoredInteger(gc, "events", name) != 0 then
call BJDebugMsg("MMD DefEvent Error: Event redefined.")
else
call StoreInteger(gc, "events", name, num_args+1)
call emit("DefEvent " + pack(name) + " " + I2S(num_args) + " " + arg_data + pack(format))
endif
endfunction
///Places an event in the meta-data
private function LogEvent takes string name, integer num_args, string data returns nothing
if GetStoredInteger(gc, "events", name) != num_args+1 then
call BJDebugMsg("MMD LogEvent Error: Event not defined or defined with different # of args.")
else
call emit("Event " + pack(name) + data)
endif
endfunction
///////////////////////////////////////////////////////////////
/// Public functions
///////////////////////////////////////////////////////////////
///Sets a player flag like "win_on_leave"
public function FlagPlayer takes player p, integer flag_type returns nothing
local string flag = flags[flag_type]
local integer id = GetPlayerId(p)
if p == null or id < 0 or id >= 12 then
call BJDebugMsg("MMD Flag Error: Invalid player. Must be P1 to P12.")
elseif StringLength(flag) == 0 then
call BJDebugMsg("MMD Flag Error: Unrecognized flag type.")
elseif GetPlayerController(Player(id)) == MAP_CONTROL_USER then
call emit("FlagP " + I2S(id) + " " + flag)
endif
endfunction
///Defines a variable to store things in
public function DefineValue takes string name, integer value_type, integer goal_type, integer suggestion_type returns nothing
local string goal = goals[goal_type]
local string vtype = types[value_type]
local string stype = suggestions[suggestion_type]
if goal == null then
call BJDebugMsg("MMD Def Error: Unrecognized goal type.")
elseif vtype == null then
call BJDebugMsg("MMD Def Error: Unrecognized value type.")
elseif stype == null then
call BJDebugMsg("Stats Def Error: Unrecognized suggestion type.")
elseif StringLength(name) > 32 then
call BJDebugMsg("MMD Def Error: Variable name is too long.")
elseif StringLength(name) == 0 then
call BJDebugMsg("MMD Def Error: Variable name is empty.")
elseif value_type == TYPE_STRING and goal_type != GOAL_NONE then
call BJDebugMsg("MMD Def Error: Strings must have goal type of none.")
elseif GetStoredInteger(gc, "types", name) != 0 then
call BJDebugMsg("MMD Def Error: Value redefined.")
else
call StoreInteger(gc, "types", name, value_type)
call emit("DefVarP " + pack(name) + " " + vtype + " " + goal + " " + stype)
endif
endfunction
///Updates the value of an integer variable
public function UpdateValueInt takes string name, player p, integer op, integer value returns nothing
call update_value(name, p, ops[op], I2S(value), TYPE_INT)
endfunction
///Updates the value of a real variable
public function UpdateValueReal takes string name, player p, integer op, real value returns nothing
call update_value(name, p, ops[op], R2S(value), TYPE_REAL)
endfunction
///Updates the value of a string variable
public function UpdateValueString takes string name, player p, string value returns nothing
local string q = "\""
call update_value(name, p, ops[OP_SET], q + pack(value) + q, TYPE_STRING)
endfunction
public function DefineEvent0 takes string name, string format returns nothing
call DefineEvent(name, 0, format, "")
endfunction
public function DefineEvent1 takes string name, string format, string argName0 returns nothing
call DefineEvent(name, 1, format, pack(argName0) + " ")
endfunction
public function DefineEvent2 takes string name, string format, string argName0, string argName1 returns nothing
call DefineEvent(name, 2, format, pack(argName0) + " " + pack(argName1) + " ")
endfunction
public function DefineEvent3 takes string name, string format, string argName0, string argName1, string argName2 returns nothing
call DefineEvent(name, 3, format, pack(argName0) + " " + pack(argName1) + " " + pack(argName2) + " ")
endfunction
public function LogEvent0 takes string name returns nothing
call LogEvent(name, 0, "")
endfunction
public function LogEvent1 takes string name, string arg0 returns nothing
call LogEvent(name, 1, " " + pack(arg0))
endfunction
public function LogEvent2 takes string name, string arg0, string arg1 returns nothing
call LogEvent(name, 2, " " + pack(arg0) + " " + pack(arg1))
endfunction
public function LogEvent3 takes string name, string arg0, string arg1, string arg2 returns nothing
call LogEvent(name, 3, " " + pack(arg0) + " " + pack(arg1) + " " + pack(arg2))
endfunction
///Emits meta-data which parsers will ignore unless they are customized to understand it
public function LogCustom takes string unique_identifier, string data returns nothing
call emit("custom " + pack(unique_identifier) + " " + pack(data))
endfunction
///////////////////////////////////////////////////////////////
/// Initialization
///////////////////////////////////////////////////////////////
///Emits initialization data
private function init2 takes nothing returns nothing
local integer i
local trigger t
set initialized = true
call emit("init version " + I2S(MINIMUM_PARSER_VERSION) + " " + I2S(CURRENT_VERSION))
set i = 0
loop
exitwhen i >= 12
if GetPlayerController(Player(i)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call emit("init pid " + I2S(i) + " " + pack(GetPlayerName(Player(i))))
endif
set i = i + 1
endloop
set t = CreateTrigger()
call TriggerAddAction(t, function tick)
call TriggerRegisterTimerEvent(t, 0.37, true)
endfunction
///Places init2 on a timer, initializes game cache, and translates constants
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 0, false)
call TriggerAddAction(t, function init2)
set goals[GOAL_NONE] = "none"
set goals[GOAL_HIGH] = "high"
set goals[GOAL_LOW] = "low"
set types[TYPE_INT] = "int"
set types[TYPE_REAL] = "real"
set types[TYPE_STRING] = "string"
set suggestions[SUGGEST_NONE] = "none"
set suggestions[SUGGEST_TRACK] = "track"
set suggestions[SUGGEST_LEADERBOARD] = "leaderboard"
set ops[OP_ADD] = "+="
set ops[OP_SUB] = "-="
set ops[OP_SET] = "="
set flags[FLAG_DRAWER] = "drawer"
set flags[FLAG_LOSER] = "loser"
set flags[FLAG_WINNER] = "winner"
set flags[FLAG_LEAVER] = "leaver"
set flags[FLAG_PRACTICING] = "practicing"
call FlushGameCache(InitGameCache(FILENAME))
set gc = InitGameCache(FILENAME)
call TimerStart(clock, 999999999, false, null)
call prepC2I()
endfunction
endlibrary
library_once RaceSelector initializer init uses Utils
public trigger callBack =null
public int callBackCode=0
public int array selection
define private BUTTON_NEXT = 'A0DP'
define private BUTTON_PREV = 'A0DQ'
define private BUTTON_RAND = 'A0DR'
define private PAGE_BUTTONS_ON_PAGE = 9
public int array builders
private string array names
private int array abils // selector
private sound array sounds
public bool array possible
// for optimization without setter and getter
public int count = 0
private constant trigger t = CreateTrigger()
private int array curPage
define private RegisterRace(name,peasant,abil,snd)={
names[count]=name
builders[count]=peasant
abils[count]=abil
sounds[count]=snd
count++
}
public int BuilderId(int uid){
int i = 0
loop
exitwhen builders[i]==uid or i>=count
i++
endloop
if(i>=count){return -1}
return i
}
public string GetRaceName(int uid)
{
int i=0
loop
exitwhen builders[i]==uid or i>=count
i++
endloop
if(i>=count){return "Unregistred Race"}
return names[i]
}
private void UpdatePossabilityFlagAll(int raceId) //__!!!
{
int i=0
int z
loop
z = curPage[i]*PAGE_BUTTONS_ON_PAGE
SetPlayerAbilityAvailable(Player(i),abils[raceId],possible[forceId[i]*count+raceId] and raceId>z and raceId<(z+PAGE_BUTTONS_ON_PAGE))
i++
exitwhen i>=12
endloop
}
public void ChangePossabilityFlagAll(int peon,bool fl)
{
int i=0
loop
exitwhen builders[i]==peon or i>=count
i++
endloop
if(i>=count){return}
possible[i]=fl
possible[count+i]=fl
UpdatePossabilityFlagAll(i)
}
public void ChangePossabilityFlagTeam(int peon,bool fl,int team)
{
int i=0
loop
exitwhen builders[i]==peon or i>=count
i++
endloop
if(i>=count){return}
possible[count*team+i]=fl
UpdatePossabilityFlagAll(i)
}
private void PrepareUnit(unit u)
{
int i=0
player p=GetOwningPlayer(u)
loop
UnitAddAbility(u,abils[i])
i++
exitwhen i>=count
endloop
UnitAddAbility(u,BUTTON_NEXT)
UnitAddAbility(u,BUTTON_PREV)
UnitAddAbility(u,BUTTON_RAND)
SelectUnitForPlayerSingle(u,p)
PanCameraToForPlayer(p,GetUnitX(u),GetUnitY(u))
}
public unit GetRaceRef(unit u)
{
PrepareUnit(u)
return u
}
public int GetRaceRefWithWaitTimeLimited(unit u,real time)
{
int pid=GetPlayerId(GetOwningPlayer(u))
timer sleep=CreateTimer()
int res=0
PrepareUnit(u)
TimerStart(sleep,time,false,null)
loop
TriggerSleepAction(.33)
exitwhen selection[pid]!=0 or TimerGetRemaining(sleep)<.33
endloop
PauseTimer(sleep)
DestroyTimer(sleep)
sleep=null
RemoveUnit(u)
if(selection[pid]==0){return peon_random}
res=selection[pid]
selection[pid]=0
return res
}
private void ShowCurrentPage(int pid)
{
int i=0
int nfrom=curPage[pid]*PAGE_BUTTONS_ON_PAGE
int nto=nfrom+PAGE_BUTTONS_ON_PAGE
int offset=forceId[pid]*count
player p=Player(pid)
loop
SetPlayerAbilityAvailable(p,abils[i],possible[offset+i] and i>=nfrom and i<nto)
i++
exitwhen i>=count
endloop
SetPlayerAbilityAvailable(p,BUTTON_NEXT,nto<count)
SetPlayerAbilityAvailable(p,BUTTON_PREV,nfrom>0)
}
public void Finally()
{
DisableTrigger(t)
}
public void ResetSaveRestrictions()
{
int i=0
loop
curPage[i]=0
selection[i]=0
ShowCurrentPage(i)
i++
exitwhen i>=12
endloop
callBack=null
}
public void Reset()
{
int i=0
loop
possible[i]=true
i++
exitwhen i>=count*2
endloop
ResetSaveRestrictions()
EnableTrigger(t)
}
private bool OnSpellSelect()
{
unit u=GetTriggerUnit()
int pid=GetPlayerId(GetOwningPlayer(u))
int abid=GetSpellAbilityId()
int i=0
if(abid==BUTTON_NEXT){
curPage[pid]++
ShowCurrentPage(pid)
u=null
return false
}elseif(abid==BUTTON_PREV){
curPage[pid]--
ShowCurrentPage(pid)
u=null
return false
}elseif(abid==BUTTON_RAND){
selection[pid]=peon_random
if(callBack!=null){
callBackCode=pid
TriggerEvaluate(callBack)
}
RemoveUnit(u)
u=null
return false
}
loop
exitwhen abils[i]==abid or i>=count
i++
endloop
//DisplayTextToPlayer(Player(0),0.,0.,"Choosen "+Utils_RawCode2S(abid)+"*"+I2S(i)+"*"+I2S(count))
RemoveUnit(u)
u=null
if(i>=count){return false}
selection[pid]=builders[i]
if(GetLocalPlayer()==Player(pid)){
StartSound(sounds[i])
}
if(callBack!=null){
callBackCode=pid
TriggerEvaluate(callBack)
}
return false
}
public void init()
{
RegisterRace("Chaos Legions",peon_chaos,'A0DD',CreateSound("Units\\Demon\\HeroPitLord\\HPitLordYesAttack2.wav", false, false, false, 10, 10, "DefaultEAXON"))
RegisterRace("Elven Union",peon_helf,'A0DE',CreateSound("Units\\Critters\\BloodElfPeasant\\BloodElfEngineerWarcry1.wav", false, false, false, 10, 10, "DefaultEAXON"))
RegisterRace("Corrupted Conglomerate",peon_corrupted,'A0DF',CreateSound("Units\\Demon\\Pitlord\\PitLordYesAttack1.wav", false, false, false, 10, 10, "DefaultEAXON"))
RegisterRace("Human Alliance",peon_human,'A0DG',CreateSound("Units\\Human\\Peasant\\PeasantReady1.wav", false, false, false, 10, 10, "DefaultEAXON"))
RegisterRace("Orcish Horde",peon_orc,'A0DH',CreateSound("Units\\Orc\\Peon\\PeonReady1.wav", false, false, false, 10, 10, "DefaultEAXON"))
RegisterRace("Naga Faction",peon_naga,'A0DI',CreateSound("Units\\Creeps\\Murloc\\MurlocPissed2.wav", false, false, false, 10, 10, "DefaultEAXON"))
RegisterRace("Northern Realms",peon_northern,'A0DJ',CreateSound("Units\\Creeps\\Bandit\\BanditWhat1.wav", false, false, false, 10, 10, "DefaultEAXON"))
RegisterRace("Night Elfs",peon_nelf,'A0DK',CreateSound("Units\\NightElf\\Runner\\RunnerWarcry1.wav", false, false, false, 10, 10, "DefaultEAXON"))
RegisterRace("Undead Forces",peon_undead,'A0DL',CreateSound("Units\\Undead\\Acolyte\\AcolyteWarcry1.wav", false, false, false, 10, 10, "HeroAcksEAX"))
RegisterRace("Mech Coalition",peon_mech,'A0DM',CreateSound("Units\\Creeps\\HeroTinker\\HeroTinkerReady1.wav", false, false, false, 10, 10, "HeroAcksEAX"))
RegisterRace("Nature Force",peon_nature,'A0DN',CreateSound("Units\\NightElf\\Ent\\EntReady1.wav", false, false, false, 10, 10, "DefaultEAXON"))
RegisterRace("Elementals' Universe",peon_magic,'A0DO',CreateSound("Units\\NightElf\\Wisp\\WispPissed3.wav", false, false, false, 10, 10, "DefaultEAXON"))
RegisterRace("Desert Plains",peon_desert,'A0GL',CreateSound("Units\\Creeps\\Kobold\\KoboldPissed3.wav", false, false, false, 10, 10, "DefaultEAXON"))
DisableTrigger(t)
TriggerAddCondition(t,Condition(function OnSpellSelect))
TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_CAST)
}
endlibrary
library_once Utils initializer init
public real map_minx
public real map_maxx
public real map_miny
public real map_maxy
private unit array randomSetUnits
private unit array randomSetUnits2
unit GetRandomUnit(group g)
{
unit u
int randomSetCount=0
//ForGroup(g,function GetRandomUnitPersonal)
loop
u = FirstOfGroup(g)
exitwhen (u == null or randomSetCount>50)
randomSetUnits[randomSetCount]=u
randomSetCount++
GroupRemoveUnit(g,u)
endloop
u=null
if(randomSetCount<=0){return null}
return randomSetUnits[GetRandomInt(0,randomSetCount-1)]
}
unit GetRandomAssassinTarget(group g)
{
unit u
int c = 0
int d = 0
int e = 0
loop
u = FirstOfGroup(g)
exitwhen (u == null or c>25 or d>25 or e>50)
if(GetUnitState(u,UNIT_STATE_MAX_MANA)>1. or GetUnitAbilityLevel(u,'A0CV')>0) {
randomSetUnits[c]=u
c++
} else {
randomSetUnits2[d]=u
d++
}
GroupRemoveUnit(g,u)
e++
endloop
u=null
if(c>0){return randomSetUnits[GetRandomInt(0,c-1)]}
if(d>0){return randomSetUnits2[GetRandomInt(0,d-1)]}
return null
}
real Dist(real x, real y){
return SquareRoot(x*x+y*y)
}
//private bool array TPing
public void Tele2PT(unit tu,real tx,real ty, real mind){
int pn = GetPlayerId(GetOwningPlayer(tu))
int n = 5
real d
//IssuePointOrderById(tu,851986,tx,ty) //move
loop
d = Dist(tx-GetUnitX(tu),ty-GetUnitY(tu))
exitwhen d < mind or n<=0
IssuePointOrderById(tu,852525,tx,ty) //blink
TriggerSleepAction(0.15)
n--
endloop
//IssueImmediateOrderById(tu,851972)
//TriggerSleepAction(.1)
}
int MathNOD(int x, int y)
{
int r
if(x==0 or y==0){
return x+y
}
r=x-y*(x/y)
loop
exitwhen r==0
x=y
y=r
r=x-y*(x/y)
endloop
return y
}
int MathNOK(int x, int y)
{
return (x*y)/MathNOD(x,y)
}
private constant sound sndErrorMessage=CreateSoundFromLabel("InterfaceError",false,false,false,10,10)
void ErrorMessage(player p,string s){
if(GetLocalPlayer()==p){
ClearTextMessages()
DisplayTimedTextToPlayer(p,0.52,-1.00,2.00,"|cffffcc00"+s+"|r")
StopSound(sndErrorMessage,false,false)
StartSound(sndErrorMessage)
}
}
player FirstOfForce(force f)
{
int i=0
loop
if(IsPlayerInForce(Player(i),f)){
return Player(i)
}
i++
exitwhen i>11
endloop
return null
}
void ForceAddForce(force f1, force f2)
{
int i=0
player p
loop
p=Player(i)
if(IsPlayerInForce(p,f2) and not IsPlayerInForce(p,f1)){
ForceAddPlayer(f1,p)
}
i++
exitwhen i>11
endloop
}
void ForceRemoveForce(force f1, force f2)
{
int i=0
player p
loop
p=Player(i)
if(IsPlayerInForce(p,f2) and IsPlayerInForce(p,f1)){
ForceRemovePlayer(f1,p)
}
i++
exitwhen i>11
endloop
}
int CalculateLeftPlayers()
{
int i=0
int j=0
loop
if(IsPlayerInForce(Player(i),leftPlayers) and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING){
j++
}
i++
exitwhen i>11
endloop
return j
}
int CalculateRightPlayers()
{
int i=0
int j=0
loop
if(IsPlayerInForce(Player(i),rightPlayers) and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING){
j++
}
i++
exitwhen i>11
endloop
return j
}
private integer MIN_RAW_CODE = ' '
private string RAW_CHARS = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
public string RawCode2S(int rawCode){
int placeNum //number at current place
string str = ""
if(rawCode < MIN_RAW_CODE)then
return str
endif
loop
exitwhen rawCode == 0
placeNum = ModuloInteger(rawCode, 256) - MIN_RAW_CODE
str = SubString(RAW_CHARS, placeNum, placeNum+1) + str
rawCode = rawCode / 256
endloop
return str
}
///////////////////////////////////////////////////////////////////////////
// Quota Players Operations
///////////////////////////////////////////////////////////////////////////
bool restructureAlliesRequered=true
player AllocateFreeSlot(bool leftSide)
{
int i=0
restructureAlliesRequered=true
if(not leftSide){i=7}
loop
exitwhen IsPlayerInForce(Player(i),quotaPlayers) or i>11
i++
endloop
if(i>11){
if(leftSide){return null}
//restructRequired=true
i=0
loop
exitwhen IsPlayerInForce(Player(i),quotaPlayers) or i>6
i++
endloop
if(i>6){return null}
}
return Player(i)
}
//aliances
private void ReAllianceAll() {
int i=0
int j
loop
j=0
loop
if(forceId[i]==forceId[j]){
if(relayedForces[j]!=null and IsPlayerInForce(Player(i),relayedForces[j])){
SetPlayerAllianceStateBJ(Player(i),Player(j),bj_ALLIANCE_ALLIED_ADVUNITS)
}else{
SetPlayerAllianceStateAllyBJ(Player(i),Player(j),true)
SetPlayerAlliance(Player(i),Player(j),ALLIANCE_SHARED_VISION,true)
if(GetPlayerController(Player(i))==MAP_CONTROL_COMPUTER){
SetPlayerAllianceStateControlBJ(Player(i),Player(j), true)
}
}
}else{
SetPlayerAllianceStateBJ(Player(i),Player(j),bj_ALLIANCE_UNALLIED)
}
j++
exitwhen j>11
endloop
i++
exitwhen i>11
endloop
}
void RestructAlliances()
{
ReAllianceAll()
restructureAlliesRequered=false
}
private void init()
{
map_minx=GetRectMinX(bj_mapInitialPlayableArea)
map_maxx=GetRectMaxX(bj_mapInitialPlayableArea)
map_miny=GetRectMinY(bj_mapInitialPlayableArea)
map_maxy=GetRectMaxY(bj_mapInitialPlayableArea)
//falseCondition=Condition(function FalseCondition)
}
endlibrary
library_once AttackOrders uses SpecialControl
define SpecialAttackOrder=SpecialControl_Operate
void AttackCreepOrder(unit u)
{
IssuePointOrderByIdLoc(u,851983,targetRectLoc[forceId[GetPlayerId(GetOwningPlayer(u))]])
}
void AttackCreepOrderCommon(unit u)
{
if(IsUnitType(u, UNIT_TYPE_TAUREN)){return}
if(GetUnitAbilityLevel(u,'A07M')>=1 and GetRandomInt(0,99) > 20){
SpecialAttackOrder(u)
}
elseif(GetUnitAbilityLevel(u,'A0ID')>=1) {
IssueImmediateOrderById(u,order_stop)
return
}
else{
IssuePointOrderByIdLoc(u,851983,targetRectLoc[forceId[GetPlayerId(GetOwningPlayer(u))]])
}
}
endlibrary
library UnitPool
private int array ltypes
private int lcount
private int array rtypes
private int rcount
private int array builders
public void FillUnitPools()
{
int i=0
int j
int k
int unitId
lcount = 0
rcount = 0
loop
builders[i] = RaceSelector_builders[i]
i++
exitwhen i>=RaceSelector_count
endloop
i=0
loop
unitId = builders[i]
if(RaceSelector_possible[i]){
ltypes[lcount]=unitId
lcount++
}
if(RaceSelector_possible[RaceSelector_count+i]){
rtypes[rcount]=unitId
rcount++
}
i++
exitwhen i>=RaceSelector_count
endloop
}
public void remove(int unitId,boolean side){ //left=true
int i=0
if(side) {
loop
exitwhen ltypes[i]==unitId or i>=lcount
i++
endloop
if(i>=lcount){return}
lcount--
ltypes[i]=ltypes[lcount]
} else {
loop
exitwhen rtypes[i]==unitId or i>=rcount
i++
endloop
if(i>=rcount){return}
rcount--
rtypes[i]=rtypes[rcount]
}
}
public int getRandom(boolean side) {
if(side) {
return ltypes[GetRandomInt(0,lcount-1)]
} else {
return rtypes[GetRandomInt(0,rcount-1)]
}
}
endlibrary
library StartPosition initializer init
private location array positions
private bool array isUsed
public location GiveMeRespawn(bool leftSide)
{
int i=0
if(not leftSide){i=6}
loop
if(not isUsed[i]){
isUsed[i]=true
return positions[i]
}
i++
exitwhen i>11
endloop
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"GENERAL FAILURE AT MODULE 'SP:GMR'. PLEASE REPORT ABOUT THIS BUG!")
return Location(0.,0.)
}
public void ReleaseRespawn(location loc)
{
int i=0
loop
if(loc==positions[i]){
isUsed[i]=false
return
}
i++
exitwhen i>11
endloop
}
public void init()
{
int i=0
loop
positions[i]=GetPlayerStartLocationLoc(Player(i))
i++
exitwhen i>11
endloop
}
endlibrary
library_once Multiboard uses Main, Income
public string Caption
public timer UpdateTimer=null
public void ReShowAllMulti()
{
int i=0
loop
if(playerBoards[i]!=null){
if(GetLocalPlayer()==Player(i)){
MultiboardDisplay(playerBoards[i],true)
}
}else{
if(GetLocalPlayer()==Player(i)){
MultiboardDisplay(spectatorMultiboard,true)
}
}
i++
exitwhen i>11
endloop
}
private void UpdaterResourses()
{
int i=0
int x=0
multiboarditem mbitem
player p
loop
if(mpMBoard[i]!=null){
p=Player(i)
mbitem=MultiboardGetItem(mpMBoard[i],relayedOwnerTablePosition[i],3)
MultiboardSetItemValue(mbitem,I2S(GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)))
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(mpMBoard[i],relayedOwnerTablePosition[i],4)
MultiboardSetItemValue(mbitem,I2S(GetPlayerState(p,PLAYER_STATE_RESOURCE_LUMBER)))
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(mpMBoard[i],relayedOwnerTablePosition[i],5)
MultiboardSetItemValue(mbitem,I2S(GetPlayerState(p,PLAYER_STATE_RESOURCE_FOOD_USED))+"/"+I2S(GetPlayerState(p,PLAYER_STATE_RESOURCE_FOOD_CAP)))
MultiboardReleaseItem(mbitem)
}
if(spectatorPosition[i]>0){
p=Player(i)
if(IsPlayerInForce(p,leftPlayers)){x=0}else{x=6}
mbitem=MultiboardGetItem(spectatorMultiboard,spectatorPosition[i],x+2)
MultiboardSetItemValue(mbitem,I2S(GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)))
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(spectatorMultiboard,spectatorPosition[i],x+3)
MultiboardSetItemValue(mbitem,I2S(GetPlayerState(p,PLAYER_STATE_RESOURCE_LUMBER)))
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(spectatorMultiboard,spectatorPosition[i],x+4)
MultiboardSetItemValue(mbitem,I2S(Income_mCachedIncome[i]))
MultiboardReleaseItem(mbitem)
}
i++
exitwhen i>11
endloop
mbitem=null
}
define private RestuctureMultiboard2Normal(m)={
MultiboardSetRowCount(m,4)
MultiboardSetColumnCount(m,6)
MultiboardSetTitleText(m,Caption)
MultiboardSetItemStyleBJ(m,0,0,true,false)
//MultiboardSetItemStyleBJ(m,0,0,true,false)
MultiboardSetItemValueBJ(m,0,0,"0")
MultiboardSetItemValueBJ(m,0,4,"")
MultiboardSetItemColorBJ(m,6,0,'d',90.,.0,0)
MultiboardSetItemValueBJ(m,1,1,"")
MultiboardSetItemValueBJ(m,2,1,"Resc.")
MultiboardSetItemValueBJ(m,3,1,"Coins")
MultiboardSetItemValueBJ(m,4,1,"Destr.")
MultiboardSetItemValueBJ(m,5,1,"Income")
MultiboardSetItemValueBJ(m,6,1,"|cffFFFF80Wins|r")
MultiboardSetItemValueBJ(m,1,2,"|cffFF0000West|r")
MultiboardSetItemValueBJ(m,1,3,"|cff00FF00East|r")
MultiboardSetItemValueBJ(m,1,4,"|cffFFFF00Round Time:|r")
MultiboardSetItemValueBJ(m,6,4,"|cffFFFF000|cffFF8000:|cffFFFF0000|r")
MultiboardSetItemWidthBJ(m,0,4,2.)
MultiboardSetItemWidthBJ(m,1,4,7.)
MultiboardSetItemWidthBJ(m,6,4,3.)
}
define private formateString(m, strid, rip)={
//DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(rip))
mbitem=MultiboardGetItem(m,strid,0)
MultiboardSetItemStyle(mbitem,true,false)
MultiboardSetItemValue(mbitem,GetColoredName(rip))
MultiboardSetItemWidth(mbitem,.09)
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(m,strid,1)
MultiboardSetItemStyle(mbitem,false,false)
MultiboardSetItemWidth(mbitem,.0001)
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(m,strid,2)
MultiboardSetItemStyle(mbitem,false,false)
MultiboardSetItemWidth(mbitem,.0001)
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(m,strid,3)
MultiboardSetItemStyle(mbitem,true,true)
MultiboardSetItemIcon(mbitem,"UI\\Feedback\\Resources\\ResourceGold.blp")
MultiboardSetItemWidth(mbitem,.035)
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(m,strid,4)
MultiboardSetItemStyle(mbitem,true,true)
MultiboardSetItemIcon(mbitem,"UI\\Feedback\\Resources\\ResourceLumber.blp")
MultiboardSetItemWidth(mbitem,.035)
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(m,strid,5)
MultiboardSetItemStyle(mbitem,true,true)
MultiboardSetItemIcon(mbitem,"UI\\Feedback\\Resources\\ResourceManaStone.blp")
MultiboardSetItemWidth(mbitem,.03)
MultiboardReleaseItem(mbitem)
}
public void AddDependedPlayersToPlayer(int pid, string cap){
int i=0
int j=0
multiboarditem mbitem
MultiboardSetRowCount(playerBoards[pid],CountPlayersInForceBJ(relayedForces[pid])+6)
mbitem=MultiboardGetItem(playerBoards[pid],4,0)
MultiboardSetItemStyle(mbitem,false,false)
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(playerBoards[pid],4,1)
MultiboardSetItemStyle(mbitem,false,false)
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(playerBoards[pid],4,2)
MultiboardSetItemStyle(mbitem,false,false)
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(playerBoards[pid],4,3)
MultiboardSetItemStyle(mbitem,false,false)
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(playerBoards[pid],4,4)
MultiboardSetItemStyle(mbitem,false,false)
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(playerBoards[pid],4,5)
MultiboardSetItemStyle(mbitem,false,false)
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(playerBoards[pid],5,0)
MultiboardSetItemStyle(mbitem,false,false)
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(playerBoards[pid],5,1)
MultiboardSetItemStyle(mbitem,true,false)
MultiboardSetItemValue(mbitem,cap)
MultiboardSetItemWidth(mbitem,.1)
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(playerBoards[pid],5,2)
MultiboardSetItemStyle(mbitem,false,false)
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(playerBoards[pid],5,3)
MultiboardSetItemStyle(mbitem,false,false)
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(playerBoards[pid],5,4)
MultiboardSetItemStyle(mbitem,false,false)
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(playerBoards[pid],5,5)
MultiboardSetItemStyle(mbitem,false,false)
MultiboardReleaseItem(mbitem)
loop
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,I2S(i))
if(IsPlayerInForce(Player(i),relayedForces[pid])){
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,I2S(pid)+":"+I2S(i)+":"+I2S(j+6))
formateString(playerBoards[pid],j+6,i)
mpMBoard[i]=playerBoards[pid]
relayedOwnerTablePosition[i]=j+6
j++
}
i++
exitwhen i>11
endloop
mbitem=null
}
define private configSpectrSetCaption(x,y,value)={
mbitem=MultiboardGetItem(spectatorMultiboard,x,y)
MultiboardSetItemValue(mbitem,value)
MultiboardReleaseItem(mbitem)
}
private void configSpectr()
{
int i=IMaxBJ(CountPlayersInForceBJ(leftPlayers),CountPlayersInForceBJ(rightPlayers))
int j=0
multiboarditem mbitem
MultiboardSetTitleText(spectatorMultiboard,Caption)
MultiboardSetRowCount(spectatorMultiboard,6+i)
spectatorMultiboardClockPosition=4+i
MultiboardSetColumnCount(spectatorMultiboard,11)
MultiboardSetItemStyleBJ(spectatorMultiboard,0,0,true,false)
MultiboardSetItemWidthBJ(spectatorMultiboard,1,0,8.)
MultiboardSetItemWidthBJ(spectatorMultiboard,6,0,1.)
MultiboardSetItemWidthBJ(spectatorMultiboard,7,0,8.)
mbitem=MultiboardGetItem(spectatorMultiboard,spectatorMultiboardClockPosition+1,0)
MultiboardSetItemWidth(mbitem,10.)
MultiboardReleaseItem(mbitem)
i=0
loop
configSpectrSetCaption(0,i+0,"|cffFFFF80Team|r")
configSpectrSetCaption(0,i+1,"|cffFFFF80Resc.|r")
configSpectrSetCaption(0,i+2,"|cffFFFF80Destr.|r")
configSpectrSetCaption(0,i+3,"|cffFFFF80Income|r")
configSpectrSetCaption(0,i+4,"|cffFFFF80Wins|r")
MultiboardSetItemWidthBJ(spectatorMultiboard,i+5,0,1.8)
i+=6
exitwhen i>6
endloop
configSpectrSetCaption(1,0,"|cffFF0000West|r")
configSpectrSetCaption(1,6,"|cff00FF00East|r")
configSpectrSetCaption(1,2,"0")
configSpectrSetCaption(1,8,"0")
configSpectrSetCaption(1,4,I2S(wins[0]))
configSpectrSetCaption(1,10,I2S(wins[1]))
i=0
loop
configSpectrSetCaption(3,i+0,"|cffFFFF80Player|r")
mbitem=MultiboardGetItem(spectatorMultiboard,3,i+1)
MultiboardSetItemStyle(mbitem,false,true)
MultiboardSetItemIcon(mbitem,"ReplaceableTextures\\CommandButtons\\BTNHolyBolt.blp")
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(spectatorMultiboard,3,i+2)
MultiboardSetItemStyle(mbitem,false,true)
MultiboardSetItemIcon(mbitem,"UI\\Feedback\\Resources\\ResourceGold.blp")
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(spectatorMultiboard,3,i+3)
MultiboardSetItemStyle(mbitem,false,true)
MultiboardSetItemIcon(mbitem,"UI\\Feedback\\Resources\\ResourceLumber.blp")
MultiboardReleaseItem(mbitem)
mbitem=MultiboardGetItem(spectatorMultiboard,3,i+4)
MultiboardSetItemStyle(mbitem,false,true)
MultiboardSetItemIcon(mbitem,"ReplaceableTextures\\CommandButtons\\BTNChestOfGold.blp")
MultiboardReleaseItem(mbitem)
i+=6
exitwhen i>6
endloop
i=0
j=4
loop
if(IsPlayerInForce(Player(i),leftPlayers)){
spectatorPosition[i]=j
configSpectrSetCaption(spectatorPosition[i],0,GetColoredName(i))
j++
}else{
spectatorPosition[i]=0
}
i++
exitwhen i>11
endloop
i=0
j=4
loop
if(IsPlayerInForce(Player(i),rightPlayers)){
spectatorPosition[i]=j
configSpectrSetCaption(spectatorPosition[i],6,GetColoredName(i))
j++
}
i++
exitwhen i>11
endloop
mbitem=null
}
public void init()
{
int i=0
player p
string resourses=GetLocalizedString("TEAM_RESOURCES")+":"
if(mode_mp>0 or mode_emp>0){
//resourses=GetLocalizedString("TEAM_RESOURCES")
//resourses+=":"
if(restructureAlliesRequered){
Main_SunAMP()
}
}
if(restructureAlliesRequered){
RestructAlliances()
}
if(spectatorMultiboard!=null){DestroyMultiboard(spectatorMultiboard)}
spectatorMultiboard=CreateMultiboard()
configSpectr()
loop
p=Player(i)
if(relayedForces[i]!=null){
if(playerBoards[i]!=null){DestroyMultiboard(playerBoards[i])}
playerBoards[i]=CreateMultiboard()
RestuctureMultiboard2Normal(playerBoards[i])
if(CountPlayersInForceBJ(relayedForces[i])>0){
AddDependedPlayersToPlayer(i,resourses)
}
}
i++
exitwhen i>11
endloop
if(UpdateTimer==null){
UpdateTimer=CreateTimer()
TimerStart(UpdateTimer,1.,true,function UpdaterResourses)
}
SetMBValue(5,1,I2S(wins[0]))
SetMBValue(5,2,I2S(wins[1]))
ReShowAllMulti()
}
endlibrary
library_once DialogMainInit initializer init uses Main, Multiboard
public timer pretime=CreateTimer()
private timerdialog td
private trigger tr=CreateTrigger()
private dialog dial=DialogCreate()
private button array buttons
private bool reported=false
public void ReportPlayers(bool fl)
{
if((not fl) and reported){return}
reported=true
string s1
string s2
if(mode_rounds==1){
if(mode_gamemode==0){
s1=GetColoredName(0)+" has chosen single round/pick race. You may pick your race! The first round determines the winner!"
s2="Single Round Pick"
}elseif(mode_gamemode==1){
s1=GetColoredName(0)+" has chosen single round/random race. You will get a random race! The first round determines the winner!"
s2="Single Round Random"
}elseif(mode_gamemode==2){
s1=GetColoredName(0)+" has chosen single round/mirror mode. Both teams will get the same random races! The first round determines the winner!"
s2="Single Round Random"
}elseif(mode_gamemode==3){
s1=GetColoredName(0)+" has chosen single round/draft race. Races will be drafted! The first round determines the winner!"
s2="Single Round Draft"
}
}else{
if(mode_permamentRace){
if(mode_gamemode==0){
s1=GetColoredName(0)+" has chosen |cffFFFF00pick|r race. You may pick a race at the beginning that you keep for the |cffFFFF00whole game|r! Number of wins for overall victory: |cffFFFF00"+I2S(mode_rounds)+"|r"
s2="Pick once, |cffFFCC00"+I2S(mode_rounds)+"|cffFFFF80 wins"
}elseif(mode_gamemode==1){
s1=GetColoredName(0)+" has chosen |cffFFFF00random|r race. You will get a random race at the beginning that you keep for the |cffFFFF00whole game|r! Number of wins for overall victory: |cffFFFF00"+I2S(mode_rounds)+"|r"
s2="Random once, |cffFFCC00"+I2S(mode_rounds)+"|cffFFFF80 wins"
}elseif(mode_gamemode==2){
s1=GetColoredName(0)+" has chosen |cffFFFF00mirror mode|r. Both teams will get the same random races at the beginning that they will keep for the |cffFFFF00whole game|r! Number of wins for overall victory: |cffFFFF00"+I2S(mode_rounds)+"|r"
s2="Mirror once, |cffFFCC00"+I2S(mode_rounds)+"|cffFFFF80 wins"
}elseif(mode_gamemode==3){
s1=GetColoredName(0)+" has chosen |cffFFFF00draft|r race. You will draft a race at the beginning that you keep for the |cffFFFF00whole game|r! Number of wins for overall victory: |cffFFFF00"+I2S(mode_rounds)+"|r"
s2="Draft once, |cffFFCC00"+I2S(mode_rounds)+"|cffFFFF80 wins"
}
}else{
if(mode_gamemode==0){
s1=GetColoredName(0)+" has chosen |cffFFFF00pick|r race |cffFFFF00each round|r. You may pick a new race each round! Number of wins for overall victory: |cffFFFF00"+I2S(mode_rounds)+"|r"
s2="Pick each round, |cffFFCC00"+I2S(mode_rounds)+"|cffFFFF80 wins"
}elseif(mode_gamemode==1){
s1=GetColoredName(0)+" has chosen |cffFFFF00random|r race |cffFFFF00each round|r. You will get a new random race each round! Number of wins for overall victory: |cffFFFF00"+I2S(mode_rounds)+"|r"
s2="Random each round, |cffFFCC00"+I2S(mode_rounds)+"|cffFFFF80 wins"
}elseif(mode_gamemode==2){
s1=GetColoredName(0)+" has chosen |cffFFFF00mirror mode each round|r. Both teams will get the same random races each round! Number of wins for overall victory: |cffFFFF00"+I2S(mode_rounds)+"|r"
s2="Mirror each round, |cffFFCC00"+I2S(mode_rounds)+"|cffFFFF80 wins"
}elseif(mode_gamemode==3){
s1=GetColoredName(0)+" has chosen |cffFFFF00draft|r race |cffFFFF00each round|r. You will draft a new race each round! Number of wins for overall victory: |cffFFFF00"+I2S(mode_rounds)+"|r"
s2="Draft each round, |cffFFCC00"+I2S(mode_rounds)+"|cffFFFF80 wins"
}
}
}
Multiboard_Caption="|cffFFFF80"+s2+"|r"
if(fl or not addingByXR){
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,25.,s1)
}
}
public void Free()
{
buttons[0]=null
buttons[1]=null
buttons[2]=null
buttons[3]=null
DialogClear(dial)
DialogDestroy(dial)
dial=null
//DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,25.,"1")
DestroyTimerDialog(td)
td=null
PauseTimer(pretime)
DestroyTimer(pretime)
pretime=null
//DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,25.,"2")
DestroyTrigger(tr)
tr=null
ReportPlayers(false)
//DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,25.,"3")
//Multiboard_init()
TriggerExecute(Common_Launcher)
}
private void ConfigDialToVariantSelectionB()
{
mode_permamentRace=not (GetClickedButton()==buttons[0])
TriggerSleepAction(.1)
Free()
}
private void ConfigDialToVariantSelection()
{
TriggerSleepAction(.1)
DialogClear(dial)
DialogSetMessage(dial,"New races after each round?")
buttons[0]=DialogAddButton(dial,"YES",0)
buttons[1]=DialogAddButton(dial,"NO",0)
TriggerClearActions(tr)
TriggerAddAction(tr,function ConfigDialToVariantSelectionB)
DialogDisplay(Player(0),dial,true)
}
private void ConfigDialToDeploySelectionB()
{
if(GetClickedButton()==buttons[0]) {
peonCreator="Pick_Peon"
mode_gamemode=0
}else{
peonCreator="Random_Peon"
mode_gamemode=1
}
if(mode_rounds==1){
mode_permamentRace=false
Free()
}else{
ConfigDialToVariantSelection()
}
}
private void ConfigDialToDeploySelection()
{
TriggerSleepAction(.1)
DialogClear(dial)
DialogSetMessage(dial,"Race selection?")
buttons[0]=DialogAddButton(dial,"Pick your race!",0)
buttons[1]=DialogAddButton(dial,"Random race!",0)
TriggerClearActions(tr)
TriggerAddAction(tr,function ConfigDialToDeploySelectionB)
DialogDisplay(Player(0),dial,true)
}
private void ConfigDialToRoundsSelectionB()
{
button cl=GetClickedButton()
int i=0
loop
exitwhen cl==buttons[i]
i++
endloop
mode_rounds=i+1
cl=null
ConfigDialToDeploySelection()
}
public void ConfigDialToRoundsSelection()
{
PauseTimer(pretime)
IsGameLoading=false
if(mode_gamemode!=-1){
Free()
return
}
DialogSetMessage(dial,"Number of victories?")
buttons[0]=DialogAddButton(dial,"1",0)
buttons[1]=DialogAddButton(dial,"2",0)
buttons[2]=DialogAddButton(dial,"3",0)
buttons[3]=DialogAddButton(dial,"4",0)
TriggerAddAction(tr,function ConfigDialToRoundsSelectionB)
DialogDisplay(Player(0),dial,true)
}
private void postinit()
{
TimerStart(pretime,20.,false,function ConfigDialToRoundsSelection)
td=CreateTimerDialog(pretime)
TimerDialogSetTitle(td,"Game starts:")
TimerDialogDisplay(td,true)
DisplayTimedTextToPlayer(Player(0),0.,0.,30.,"Welcome to |cffFFFF80Castle Fight|r! You have 20 seconds to enter gamemodes. If you don't enter a valid command, you will be able to choose gamemodes via dialogues. If you don't know how to enter gamemodes read the |cff80FF00Manual|r (|cffFFBA17F9|r).")
CinematicFadeBJ(1,.0,"ReplaceableTextures\\CameraMasks\\Black_mask.blp",.0,0,0,6.)
FlashQuestDialogButton()
}
public void init()
{
TimerStart(pretime,.01,false,function postinit)
TriggerRegisterDialogEvent(tr,dial)
//bj_lastCreatedMultiboard=CreateMultiboard()
}
endlibrary
library_once Data initializer init uses Utils
define RACE_CORRUPTED = 0
define RACE_HUMAN = 1
define RACE_ORC = 2
define RACE_NAGA = 3
define RACE_NORTH = 4
define RACE_CHAOS = 5
define RACE_DEAD = 6
define RACE_HELF = 7
define RACE_NELF = 8
define RACE_MECH = 9
define RACE_NATURE = 10
define RACE_ELEMENT = 11
define RACE_DESERT = 12
define RACE_OFFSET=50
constant group pickgroup=CreateGroup()
player filterPlayer
int array BuildingPrice
int array BuildingFullPrice
int array trainOrder
int array PV2UID
real array SincomeModifier
int array SgivesLumber
real array BWCost
bool array SArtilleryProduction
int array RaceBldId
int array BldReqId //predecessor id = f(pointvalue)
define MaxPV=300
int array BldNum //bilding counters, MaxPV=300
private int rcnt
private int rofs
public void SetRace(int rid){
rofs = rid*RACE_OFFSET
rcnt = 0
}
public void RegisterBuilding(int bid,real income,bool giveLumber,int reqBid, bool IsArt){
int id=GetUnitPointValueByType(bid)
int price=GetUnitGoldCost(bid)
if(id>8000) {DisplayTextToPlayer(GetLocalPlayer(),0.,0.," Wrong PV value for "+GetObjectName(bid))}
if(BuildingPrice[id]!=0 and (bid!='h008')) {DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"!Check unit PV "+GetObjectName(bid)+"/"+GetObjectName(PV2UID[id]))}
BuildingPrice[id]=price
if(price==0) {DisplayTextToPlayer(GetLocalPlayer(),0.,0.,Utils_RawCode2S(bid)+" price "+ I2S(price))}
SincomeModifier[id]=price*income*0.1
if(reqBid>0){ price += BuildingFullPrice[GetUnitPointValueByType(reqBid)] }
BuildingFullPrice[id]=price
if(giveLumber){ SgivesLumber[id]=1 }
else { SgivesLumber[id]=-1 }
BldReqId[id]=reqBid
SArtilleryProduction[id]=IsArt
//SaveInteger(tableIN,htKeyBldId2Pred,1,1)
PV2UID[id] = bid
BWCost[id] = GetUnitWoodCost(bid)
if(bid=='h008') {return}
rcnt++
RaceBldId[rofs]=rcnt
RaceBldId[rcnt+rofs]=bid
}
public void RegisterTrainOrder(int bid,int uid)
{
//debug if(trainOrder[GetUnitPointValueByType(bid)]!=0){DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"Conflict in Train registration!")}
trainOrder[GetUnitPointValueByType(bid)]=uid
}
public int GetUnitTypeByBId(int bid)
{
return trainOrder[GetUnitPointValueByType(bid)]
}
public int GetUnitTypeByB(unit b)
{
return trainOrder[GetUnitPointValue(b)]
}
public unit joinedUnit
public void JoinUnitUnit(unit u, int tid, real an, real x, real y)
{
int num=GetUnitUserData(u)
real mx=GetUnitX(u)+x
real my=GetUnitY(u)+y
joinedUnit=CreateUnit(GetOwningPlayer(u),tid,mx,my,an)
SetUnitPathing(joinedUnit,false)
SetUnitX(joinedUnit,mx)
SetUnitY(joinedUnit,my)
SaveUnitHandle(tableJU,GetHandleId(u),num,joinedUnit)
SetUnitUserData(u,num+1)
}
public void JoinU2U(unit u,int tid){
int num=GetUnitUserData(u)
unit ju=CreateUnit(GetOwningPlayer(u),tid,GetUnitX(u),GetUnitY(u),0.0)
SetUnitPathing(ju,false)
ShowUnit(ju,false)
SaveUnitHandle(tableJU,GetHandleId(u),num,ju)
SetUnitUserData(u,num+1)
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,I2S(GetHandleId(ju))+" attached to "+GetUnitName(u)+" : "+I2S(num+1))
ju = null
}
public void KillJoinedUnits(unit u)
{
int count=GetUnitUserData(u)
int hid=GetHandleId(u)
unit ju
if(count>0){
loop
count--
ju = LoadUnitHandle(tableJU,hid,count)
if(ju!=null) { //crashes here sometimes
ShowUnit(ju,false)
KillUnit(ju)
}
exitwhen count<=0
endloop
ju = null
}
}
private trigger array attachingCode
public unit buildingAttacher
public void RegisterAttachEffects(int bid,code condition)
{
int id=GetUnitPointValueByType(bid)
if(attachingCode[id]!=null){DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"Conflict in Attach registration! ("+GetObjectName(bid)+")")}
attachingCode[id]=CreateTrigger()
TriggerAddCondition(attachingCode[id],Condition(condition))
}
public void ExecuteAttaching(unit u)
{
int id=GetUnitPointValue(u)
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"attach to "+GetUnitName(u))
if(attachingCode[id]!=null){
buildingAttacher=u
TriggerEvaluate(attachingCode[id])
}
if(trainOrder[id]!=0){ //attach progr ind.
Data_JoinU2U(u,'e00M')
}
}
private real array towerRanges
public void RegisterTowerRange(int bid,real r)
{
//debug if(towerRanges[GetUnitPointValueByType(bid)]>0.){DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"Conflict in TowerRange registration!")}
towerRanges[GetUnitPointValueByType(bid)]=r
}
public real GetTowerRange(unit u)
{
return towerRanges[GetUnitPointValue(u)]
}
private trigger array buildingSpells
public unit buildingCaster
public void RegisterBuildingSpell(int bid,code func)
{
int id=GetUnitPointValueByType(bid)
//debug if(buildingSpells[id]!=null){DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"Conflict in Building registration!")}
buildingSpells[id]=CreateTrigger()
TriggerAddAction(buildingSpells[id],func)
}
public void ExecuteBuildingSpell(unit u)
{
int id=GetUnitPointValue(u)
if(buildingSpells[id]!=null){
buildingCaster=u
TriggerExecute(buildingSpells[id])
}
}
private trigger array unitSpells
private int array unitSpellsId
public unit unitCaster
public unit unitCasterTarget
public void RegisterUnitSpell(int bid,int acid,code handler)
{
int id=GetUnitPointValueByType(bid)
if(unitSpells[id]!=null){DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"!Spell registration error "+Utils_RawCode2S(bid)+" : " + I2S(id))}
unitSpells[id]=CreateTrigger()
TriggerAddAction(unitSpells[id],handler)
unitSpellsId[id]=acid
}
public void ExecuteUnitSpell(unit u, int acid, unit t)
{
int id=GetUnitPointValue(u)
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,GetUnitName(u)+" casted "+I2S(acid))
if(unitSpells[id]!=null and acid==unitSpellsId[id]){
unitCaster=u
unitCasterTarget=t
TriggerExecute(unitSpells[id])
}
}
private timer tmrMoveAttchd
public void init()
{
tmrMoveAttchd = CreateTimer()
}
endlibrary
library_once Income initializer init uses Main
public constant timer Timer=CreateTimer()
public real mTaxesValue=25.
public real array ivalue
public int array mCachedIncome
private string mTempStr
private real array mo //hash of CalculateTreasureMult
private real tempIncomeContainer
private real CalculateTreasureMult(int x)
{
if(x<10){
if(mode_CI) {return mo[x]*.15+1.}
else {return mo[x]*.25+1.}
}
return ((((I2R(x-9))*.24)+5.15)*.25)+1.
}
private real GetTreasureIncome(int pid)
{
return ivalue[pid]*GoldBoxM[pid]
}
private real GetIncome(int pid)
{
real i=GetTreasureIncome(pid)
int fid = forceId[pid]
if(i>25.0){
if(i<=130.0) { //default taxes
i = 0.6+i-(0.035*i)*(0.05*i)
} else { i = 60.0+i * 0.35 }
}
//DisplayTextToPlayer(Player(0),0.,0.,"Inc:"+R2S(ivalue[pid])+" GBM:"+R2S(GoldBoxM[pid])+" GIM:"+R2S(GatesIM[fid]) )
return i*Domination_incomeModifier[fid]*GatesIM[fid]
}
define htKeyIncome='incm'
define htKeyUnitBnt='ubnt'
public void AddIncome(int pid, unit u)
{
int uid=GetHandleId(u)
real iv=SincomeModifier[GetUnitPointValue(u)]
real ain = LoadReal(tableIN,htKeyIncome,uid)
ivalue[pid]+=iv
LogAdd("AddInc:" + I2S(pid) + " :" + GetUnitName(u) + " :" + R2S(iv))
if(ain==null) { ain = 0.0 }
SaveReal(tableIN,htKeyIncome,uid,ain+iv) //base+upgrades
}
public void DecIncome(int pid, unit u)
{
real v = LoadReal(tableIN,htKeyIncome,GetHandleId(u))
ivalue[pid]-= v
LogAdd("DecIncome:" + I2S(pid) + " :" + GetUnitName(u) + " :" + R2S(v))
}
public void UpIncome(int pid, unit u)
{
real v = LoadReal(tableIN,htKeyIncome,GetHandleId(u))
ivalue[pid]+= v
LogAdd("DecIncome:" + I2S(pid) + " :" + GetUnitName(u) + " :" + R2S(v))
}
private void ActionFormStrRe()
{
mTempStr+=" "+I2S(mCachedIncome[GetPlayerId(GetEnumPlayer())])
}
private void ActionPersonal()
{
player p=GetEnumPlayer()
int id=GetPlayerId(p)
int ii
real val=GetIncome(id)
tempIncomeContainer+=val
mCachedIncome[id]=R2I(val)
val = val * mode_itm + IncRest[id]
ii = R2I(val)
if(ii>0) {
val -= I2R(ii)
statisticIncomed[id]+=ii
SetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)+ii)
SetPlayerState(p,PLAYER_STATE_GOLD_GATHERED,GetPlayerState(p,PLAYER_STATE_GOLD_GATHERED)+ii)
}
IncRest[id] = val
//DisplayTextToPlayer(Player(0),0.,0.,"Inc:"+I2S(id)+":"+I2S(ii)+","+R2S(val))
}
public void Action()
{
int i=0
tempIncomeContainer=0.
ForForce(leftPlayers,function ActionPersonal)
SetMBValue(4,1,I2S(R2I(tempIncomeContainer)))
tempIncomeContainer=0.
ForForce(rightPlayers,function ActionPersonal)
SetMBValue(4,2,I2S(R2I(tempIncomeContainer)))
if(!mode_CI) {
loop
if(mCachedIncome[i]>0){
mTempStr="Income: |cffFFFF00"+I2S(mCachedIncome[i])
if(relayedForces[i]!=null){
ForForce(relayedForces[i],function ActionFormStrRe)
}
DisplayTextToPlayer(Player(i),0,0,mTempStr)
}
i++
exitwhen i>11
endloop
}
}
public void ViewIncome(player p)
{
int pid=GetPlayerId(p)
string s="Your Treasure Box income multiplier is |cffFFFF00"+R2SW(GoldBoxM[pid],1,2)
s+="|r, your income is |cffFFFF00"+I2S(R2I(GetTreasureIncome(pid)))
s+="|r. After paying taxes your income is |cffFFFF00"+I2S(mCachedIncome[pid])+"|r."
DisplayTextToPlayer(p,0.,0.,s)
}
define private CalcGoldOfCreeps(id)=GetPlayerState(Player(id),PLAYER_STATE_RESOURCE_GOLD)+pGoldBuildings[id]+pGoldItems[id]-pGoldBonuses[id]-statisticIncomed[id]-statisticCoinsGold[id]-250
define private GainedGoldById(id)=GetPlayerState(Player(id),PLAYER_STATE_RESOURCE_GOLD)+pGoldBuildings[id]+pGoldItems[id]+statisticIncomed[id]+statisticCoinsGold[id]-250-pGoldBonuses[id]
public void ViewStats(player p)
{
int id=GetPlayerId(p)
DisplayTimedTextToPlayer(p,0.,0.,15.,"-------- Round statistics: --------")
DisplayTimedTextToPlayer(p,0.,0.,15.,"Income: |cffFFFF00"+I2S(R2I(GetIncome(id)))+"|r (|cffFFFF00"+I2S(statisticIncomed[id])+"|r gold in total)")
if(mode_coins>0){
DisplayTimedTextToPlayer(p,0.,0.,15.,"Coins collected: |cffFFFF00"+I2S(statisticCoins[id])+"|r (|cffFFFF00"+I2S(statisticCoinsGold[id])+"|r gold)")
}
DisplayTimedTextToPlayer(p,0.,0.,15.,"Units killed: |cffFFFF00"+I2S(statisticKills[id])+"|r (|cffFFFF00"+I2S(CalcGoldOfCreeps(id))+"|r gold in total)")
DisplayTimedTextToPlayer(p,0.,0.,15.,"|cffFFFF00"+I2S(statisticBuildings[id])+"|r creepspawning buildings")
DisplayTimedTextToPlayer(p,0.,0.,15.,"Specials built: |cffFFFF00"+I2S(statisticSpecials[id])+"|r")
DisplayTimedTextToPlayer(p,0.,0.,15.,"Devastating Strike damage: |cffFFFF00"+I2S(statisticRSDamage[id])+"|r (|cffFFFF00"+I2S(statisticRSKills[id])+"|r units killed)")
DisplayTimedTextToPlayer(p,0.,0.,15.,"----------------------------------------------------")
}
private int GetGreatestRSDamager()
{
int j=1
int i=0
loop
if(statisticRSDamage[i]>statisticRSDamage[j]){j=i}
if(statisticRSDamage[i]>0) {LogAdd(I2S(i)+" DSD "+I2S(statisticRSDamage[i]))}
i++
exitwhen i>11
endloop
return j
}
private int GetGreatestSpec()
{
int j=1
int i=0
loop
if(statisticSpecials[i]>statisticSpecials[j]){j=i}
i++
exitwhen i>11
endloop
return statisticSpecials[j]
}
private int GetGreatestCreepBuildings()
{
int j=1
int i=0
loop
if(statisticBuildings[i]>statisticBuildings[j]){j=i}
if(statisticBuildings[i]>0) {LogAdd(I2S(i)+" built "+I2S(statisticBuildings[i])+"/"+I2S(statisticSpecials[i]))}
i++
exitwhen i>11
endloop
return statisticBuildings[j]
}
private int GetGreatestKills()
{
int j=1
int i=0
loop
if(statisticKills[i]>statisticKills[j]){j=i}
if(statisticKills[i]>0) {LogAdd(I2S(i)+" killed "+I2S(statisticKills[i]))}
i++
exitwhen i>11
endloop
return j
}
private int GetGreatestCoins()
{
int j=0
int i=1
loop
if(statisticCoins[i]>statisticCoins[j]){j=i}
i++
exitwhen i>11
endloop
return j
}
private int GetGreatestIncome()
{
int j=0
int v=0
int i=0
int t
loop
t=R2I(GetIncome(i))
if(t>v){v=t;j=i}
if(t>0.0) {LogAdd(I2S(i)+" incomed "+I2S(GainedGoldById(i)))}
i++
exitwhen i>11
endloop
return j
}
public void EndOfRound()
{
string s
string t
int g
int i
player p
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,20.,"|cffFFFF80----------- End of round statistics -----------|r")
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,20.,"Round time: "+GetGameTime())
LogAdd("=== Round finished ===")
g=R2I(GetIncome(GetGreatestIncome()))
s=""
i=0
loop
if(R2I(GetIncome(i))==g){
if(s==""){
s=GetColoredName(i)
t=I2S(statisticIncomed[i])
}else{
s=s+", "+GetColoredName(i)
t=t+"|r, |cffFFFF00"+I2S(statisticIncomed[i])
}
}
i++
exitwhen i>11
endloop
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,20.,"Moneymaker: "+s+" - |cffFFFF00"+I2S(g)+"|r (|cffFFFF00"+t+"|r gold in total)")
if(mode_coins>0){
g=GetGreatestCoins()
s=""
i=0
loop
p=Player(i)
if(statisticCoins[i]==statisticCoins[g]){
if(s==""){
s=GetColoredName(i)
t=I2S(statisticCoinsGold[i])
}else{
s=s+", "+GetColoredName(i)
t=t+"|r, |cffFFFF00"+I2S(statisticCoinsGold[i])
}
}
i++
exitwhen i>11
endloop
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,20.,"Coincollector: "+s+" - |cffFFFF00"+I2S(statisticCoins[g])+"|r (|cffFFFF00"+t+"|r gold in total)")
}
g=GetGreatestKills()
s=""
i=0
loop
if(statisticKills[i]==statisticKills[g]){
if(s==""){
s=GetColoredName(i)
t=I2S(CalcGoldOfCreeps(i))
}else{
s=s+", "+GetColoredName(i)
t=t+"|r, |cffFFFF00"+I2S(CalcGoldOfCreeps(i))
}
}
i++
exitwhen i>11
endloop
//DisplayTextToPlayer(GetLocalPlayer(),0,0,"2!")
s="Warlord: "+s+" - |cffFFFF00"+I2S(statisticKills[g])+"|r"
if(mode_nb){
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,20.,s)
}else{
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,20.,s+" (|cffFFFF00"+t+"|r gold in total)")
}
g=GetGreatestCreepBuildings()
s=""
t=""
i=0
loop
if(statisticBuildings[i]==g){
if(s==""){
s=GetColoredName(i)
}else{
s=s+", "+GetColoredName(i)
}
}
i++
exitwhen i>11
endloop
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,20.,"Constructor: "+s+" - |cffFFFF00"+I2S(g))
if(mode_sb){
g=GetGreatestSpec()
s=""
i=0
if(g>0) {
loop
if(statisticSpecials[i]==g){
if(s==""){
s=GetColoredName(i)
}else{
s=s+", "+GetColoredName(i)
}
}
i++
exitwhen i>11
endloop
}
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,20.,"Specialist: "+s+" - |cffFFFF00"+I2S(g)+"|r")
}
g=GetGreatestRSDamager()
if(statisticRSDamage[g]>0) {
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,20.,"Striker: "+GetColoredName(g)+" - |cffFFFF00"+I2S(statisticRSDamage[g])+"|r (|cffFFFF00"+I2S(statisticRSKills[g])+"|r units killed)")
}
if(UnitMostKills>0) {
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,20.,GetObjectName(UnitMostKillsId)+" killed most enemies: |cffFFFF00"+I2S(UnitMostKills)+"|r units")
}
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,20.,"|cffFFFF80--------------------------------------------------------------------|r")
WriteLog()
}
public void init()
{
mo[0]=.0
mo[1]=1.
mo[2]=1.85
mo[3]=2.57
mo[4]=3.18
mo[5]=3.7
mo[6]=4.14
mo[7]=4.52
mo[8]=4.84
mo[9]=5.11
Domination_incomeModifier[0]=1.
Domination_incomeModifier[1]=1.
}
endlibrary
library_once Coins initializer init
private timer t
private item array coins
private int count
private code runFunc
private real value
//by forceID
public int array lastPicker //0..1 id; 2..3 count; 4..5 total count
private void OnReset()
{
int i=0
loop
RemoveItem(coins[i])
i++
exitwhen i>=count
endloop
TimerStart(t,31.25,false,runFunc)
//TimerStart(t,3.25,false,runFunc)
}
private void OnExecute()
{
int i=0
value+=3.
loop
coins[i]=CreateItem('I000',GetRandomReal(GetRectMinX(gg_rct_RightPlayers),GetRectMaxX(gg_rct_RightPlayers)),GetRandomReal(GetRectMinY(gg_rct_RightPlayers),GetRectMaxY(gg_rct_RightPlayers)))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl",GetItemX(coins[i]),GetItemY(coins[i])))
coins[i+1]=CreateItem('I000',GetRandomReal(GetRectMinX(gg_rct_LeftPlayers),GetRectMaxX(gg_rct_LeftPlayers)),GetRandomReal(GetRectMinY(gg_rct_LeftPlayers),GetRectMaxY(gg_rct_LeftPlayers)))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl",GetItemX(coins[i+1]),GetItemY(coins[i+1])))
i+=2
exitwhen i>=count
endloop
TimerStart(t,4.75,false, function OnReset)
}
private void OnEstablish()
{
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffFFFF80Bounty incoming!|r")
TimerStart(t,4.,false, function OnExecute)
}
public void OnCoin(player p)
{
int id=GetPlayerId(p)
int income=R2I(GoldBoxM[id]*(8.+value))
statisticCoins[id]++
DisplayTextToPlayer(p,0.,0.,"|cffFFFF80You found |cffFFFF00"+I2S(income)+"|cffFFFF80 gold!|r")
statisticCoinsGold[id]+=income
AdjustPlayerStateBJ(income,p,PLAYER_STATE_RESOURCE_GOLD)
}
public void Stop(bool free)
{
if(t==null){return}
PauseTimer(t)
if(free){PauseTimer(t);DestroyTimer(t);t=null}
}
public void Start()
{
if(mode_coins<=0){return}
if(t==null){
t=CreateTimer()
count=mode_coins*2
}
value=0.
int i=0
loop
lastPicker[i]=-1
i++
exitwhen i>=4
endloop
lastPicker[4]=0
lastPicker[5]=0
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"!")
TimerStart(t,40.,false,function OnEstablish)
}
public void init()
{
t=null
runFunc=function OnEstablish
}
endlibrary
library_once Domination uses Utils
public real array incomeModifier //by forceId
private bool created=false
private timer tmrDOM
private bool LeftDom
private bool RightDom
define private hi=0.70
define private DomMin=10
private boolexpr filterDOMCnt
private int NDom
private bool FilterDOMCnt()
{
unit u=GetFilterUnit()
if (NDom<DomMin and IsUnitEnemy(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER) and GetWidgetLife(u)>200. and GetUnitAbilityLevel(u,'A08H')<=0 and GetUnitAbilityLevel(u,'B012')<=0 and GetUnitAbilityLevel(u,'BHbn')<=0 and GetUnitAbilityLevel(u,'BOhx')<=0) {
NDom++
}
u=null
return false
}
private void DOMCheckRegs()
{
bool LBO
bool RBO
NDom = 0; filterPlayer = Player(6)
GroupEnumUnitsInRect(pickgroup,gg_rct_RightPlayers,filterDOMCnt)
RBO = (NDom>=DomMin)
NDom = 0; filterPlayer = Player(0)
GroupEnumUnitsInRect(pickgroup,gg_rct_LeftPlayers,filterDOMCnt)
LBO = (NDom>=DomMin)
if(RBO) {
if(!LeftDom) {LeftDom=true;
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,8.,forceName[0]+"|cffFFFF00 are dominating!|r")}
if(incomeModifier[1]>hi) {incomeModifier[1]-=0.02}
}
elseif (LeftDom) {
if(incomeModifier[1]<1.0) {incomeModifier[1]+=0.05}
else {LeftDom=false;incomeModifier[1]=1.0;
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,8.,forceName[0]+"|cffFFFF00 are no longer dominating!|r")}
}
if (LBO){
if(!RightDom) {RightDom=true;
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,8.,forceName[1]+"|cffFFFF00 are dominating!|r")}
if(incomeModifier[0]>hi) {incomeModifier[0]-=0.02}
}
elseif (RightDom) {
if(incomeModifier[0]<1.0) {incomeModifier[0]+=0.05}
else {
RightDom=false;incomeModifier[0]=1.0;
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,8.,forceName[1]+"|cffFFFF00 are no longer dominating!|r")}
}
}
public void init()
{
if(not created){
filterDOMCnt = Filter(function FilterDOMCnt)
tmrDOM=CreateTimer()
TimerStart(tmrDOM,2.5,true,function DOMCheckRegs)
created=true
}
LeftDom = false
RightDom = false
incomeModifier[0]=1.
incomeModifier[1]=1.
}
endlibrary
library AntiCaging uses AttackOrders
define AF_CAGED = 'A0BG'
//define private R_CAGING_DISTANCE = 768.
//private constant timer THIS_UNIT_CAGED = CreateTimer()
//private unit array units
//private real array posX
//private real array posY
//private timer array timers
//private int count = 0
//private code onCheckFunction
group gr_cc = CreateGroup()
private timer tm_cc = CreateTimer()
private void tfLeaveCage()
{
timer t=GetExpiredTimer()
unit u = LoadUnitHandle(tableIN,htKeyCagTmID,GetHandleId(t))
if(u!=null) {
SetUnitPathing(u,true)
AttackCreepOrderCommon(u)
}
PauseTimer(t)
DestroyTimer(t)
u=null
t=null
}
private void grCheckCg()
{
unit u = GetEnumUnit()
timer t
int n = LoadInteger(tableIN,htKeyCagCnt,GetHandleId(u))
if(GetUnitCurrentOrder(u)==0){
n=n+1
if(n>=3) {
SetUnitPathing(u,false)
AttackCreepOrderCommon(u)
t = CreateTimer()
TimerStart(t,3.,false,function tfLeaveCage)
SaveUnitHandle(tableIN,htKeyCagTmID,GetHandleId(t),u)
t=null
n=0
}
} else {
n=0
}
SaveInteger(tableIN,htKeyCagCnt,GetHandleId(u),n)
u=null
}
private void onCheckCg()
{
ForGroup(gr_cc,function grCheckCg)
}
public void newUnit(unit u)
{
//reset stand counter
SaveInteger(tableIN,htKeyCagCnt,GetHandleId(u),0)
GroupAddUnit(gr_cc,u)
}
public void init()
{
if(mode_cc){
TimerStart(tm_cc,1.3,true,function onCheckCg)
}
}
endlibrary
library_once SpecialControl initializer init uses Utils
/*
private boolexpr filterAssassinTargetNew
private bool FilterAssassinTargetNew()
{
unit u=GetFilterUnit()
real r=GetWidgetLife(u)
bool res=r>.405 and IsUnitEnemy(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_GROUND) and GetUnitAbilityLevel(u,'A0CV')>0 and GetUnitAbilityLevel(u,'BHbn')<=0 and r<=600.0
u=null
return res
}*/
//(GetUnitState(u,UNIT_STATE_MAX_MANA)>15.) GetUnitAbilityLevel(u,'A0CV')>0
private boolexpr filterAssassinTarget
private bool FilterAssassinTarget()
{
unit u=GetFilterUnit()
real r=GetWidgetLife(u)
bool res=r>50 and IsUnitEnemy(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER) and IsUnitType(u,UNIT_TYPE_GROUND) and GetUnitAbilityLevel(u,'BHbn')<=0 and GetUnitAbilityLevel(u,'A08H')<=0 and GetUnitAbilityLevel(u,'B012')<=0
u=null
return res
}
private boolexpr filterRepairTargetMech
private unittype fltUT
private real fltHPDiff=0.
private bool FilterRepairTargetMech()
{
unit u=GetFilterUnit()
real r=GetWidgetLife(u)
bool res=r>.405 and IsUnitAlly(u,filterPlayer) and IsUnitType(u,fltUT) and GetUnitState(u,UNIT_STATE_MAX_LIFE)-r>fltHPDiff
u=null
return res
}
private group repGroupU = CreateGroup()
private group repGroupB = CreateGroup()
public int lastRepGrUpd = -1
define htKeyTrgID='ASTR'
public void Operate(unit u)
{
int tid=GetUnitPointValue(u)
int id = GetHandleId(u)
filterPlayer=GetOwningPlayer(u)
unit tu = LoadUnitHandle(tableIN,htKeyTrgID,id)
if(tid==129){ //assasins
if(tu!=null and GetWidgetLife(tu)>.405 and IsUnitEnemy(tu,filterPlayer)){
if(GetUnitAbilityLevel(tu,'B012')>0 or GetUnitAbilityLevel(tu,'BHbn')>0 or not IssueTargetOrderById(u,851983,tu) ){
RemoveSavedHandle(tableIN,htKeyTrgID,id)
}
}elseif(GetUnitAbilityLevel(u,'B012')>0 or IssueImmediateOrderById(u,852129)){ //invisible
GroupEnumUnitsInRect(pickgroup,gg_rct_NCreg,filterAssassinTarget)
bj_groupRandomCurrentPick=GetRandomAssassinTarget(pickgroup)
if(bj_groupRandomCurrentPick==null){
//IssueImmediateOrderById(u,851972)
if(GetRandomInt(0,99)<33){
IssuePointOrderById(u,851986,GetRandomReal(-450.,450.)+GetUnitX(u),GetRandomReal(-400.,400.)+GetUnitY(u))
}
}else{
SaveUnitHandle(tableIN,htKeyTrgID,id,bj_groupRandomCurrentPick)
IssuePointOrderById(u,851986,GetUnitX(bj_groupRandomCurrentPick),GetUnitY(bj_groupRandomCurrentPick))
}
}else{
IssuePointOrderByIdLoc(u,851983,targetRectLoc[forceId[GetPlayerId(filterPlayer)]])
}
}
/*
elseif(tid==130 and GetUnitCurrentOrder(u)==0){ //gobbo mach
if(Ticks>lastRepGrUpd){
fltUT = UNIT_TYPE_MECHANICAL;fltHPDiff=50.
GroupEnumUnitsInRect(repGroupU,bj_mapInitialPlayableArea,filterRepairTargetMech)
fltUT = UNIT_TYPE_STRUCTURE;fltHPDiff=150.
GroupEnumUnitsInRect(repGroupB,bj_mapInitialPlayableArea,filterRepairTargetMech)
lastRepGrUpd = Ticks + 2
}
bj_groupRandomCurrentPick=GetRandomUnit(repGroupB)
if(bj_groupRandomCurrentPick==null){ bj_groupRandomCurrentPick=GetRandomUnit(repGroupU) }
if(bj_groupRandomCurrentPick==null){
IssuePointOrderById(u,851983,GetUnitX(u)+GetRandomReal(-350.,350.),GetUnitY(u)+GetRandomReal(-300.,300.))
}else{
if (!IssueTargetOrderById(u,852024,bj_groupRandomCurrentPick)) {
IssueTargetOrderById(u,851983,bj_groupRandomCurrentPick)
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"GRT:"+GetUnitName(bj_groupRandomCurrentPick))
}
}
}*/
}
public void init()
{
//filterAssassinTargetNew=Filter(function FilterAssassinTargetNew)
filterAssassinTarget=Filter(function FilterAssassinTarget)
filterRepairTargetMech=Filter(function FilterRepairTargetMech)
}
endlibrary
library_once Functions initializer init uses SpecialControl, AntiCaging
void ShowTowerRange(unit u,real r)
{
int steps=20+R2I((r-500.)/50)
real x=GetUnitX(u)
real y=GetUnitY(u)
int i=0
string model=""
real an
effect array e
if(GetOwningPlayer(u)==GetLocalPlayer()){
model="Abilities\\Spells\\NightElf\\Barkskin\\BarkSkinTarget.mdl"
}
loop
exitwhen i>=steps
an=2.*bj_PI*i/steps
e[i]=AddSpecialEffect("Abilities\\Spells\\NightElf\\Barkskin\\BarkSkinTarget.mdl",x+r*Cos(an),y+r*Sin(an))
i++
endloop
TriggerSleepAction(6.)
i=0
loop
exitwhen i>=steps
DestroyEffect(e[i])
e[i]=null
i++
endloop
}
void MoveCreepOrder(unit u)
{
IssuePointOrderByIdLoc(u,851986,targetRectLoc[forceId[GetPlayerId(GetOwningPlayer(u))]])
}
void FleeCreepOrder(unit u)
{
IssuePointOrderByIdLoc(u,851986,targetRectLoc[forceId[GetPlayerId(GetOwningPlayer(u))]+2])
}
boolexpr filterEnemyGroundUnit
boolexpr filterVisibleEnemyGroundUnit
private bool FilterEnemyGroundUnit()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>.405 and IsUnitEnemy(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER) and IsUnitType(u,UNIT_TYPE_GROUND) and GetUnitAbilityLevel(u,'Avul')<=0 and GetUnitAbilityLevel(u,'A08H')<=0
u=null
return res
}
private bool FilterVisibleEnemyGroundUnit()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>.405 and IsUnitEnemy(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER) and IsUnitType(u,UNIT_TYPE_GROUND) and IsUnitVisible(u,filterPlayer) and GetUnitAbilityLevel(u,'Avul')<=0 and GetUnitAbilityLevel(u,'A08H')<=0
u=null
return res
}
boolexpr filterLivingEnemy
private bool FilterLivingEnemy(){
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>100. and IsUnitEnemy(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER) and not IsUnitType(u,UNIT_TYPE_MECHANICAL)
u=null
return res
}
void PrintAndAddLumber(unit u, int lumber)
{
player p=GetOwningPlayer(u)
int pid=GetPlayerId(p)
if(mode_lumberLimit>0){
if(lumberProduced[pid]+lumber>=mode_lumberLimit){
lumber=mode_lumberLimit-lumberProduced[pid]
if(lumber<=0){return}
lumberProduced[pid]=mode_lumberLimit
}else{
lumberProduced[pid]+=lumber
}
}
AdjustPlayerStateBJ(lumber,p,PLAYER_STATE_RESOURCE_LUMBER)
bj_lastCreatedTextTag=CreateTextTag()
SetTextTagText(bj_lastCreatedTextTag,I2S(lumber),.024)
SetTextTagPos(bj_lastCreatedTextTag,GetUnitX(u)-36.,GetUnitY(u)-16.,0.)
SetTextTagColor(bj_lastCreatedTextTag,0,200,80,255)
SetTextTagPermanent(bj_lastCreatedTextTag,false)
SetTextTagLifespan(bj_lastCreatedTextTag,3.)
SetTextTagFadepoint(bj_lastCreatedTextTag,1.)
SetTextTagVelocity(bj_lastCreatedTextTag,0,.06)
if(p!=GetLocalPlayer()){
SetTextTagVisibility(bj_lastCreatedTextTag,false)
}else{
SetTextTagVisibility(bj_lastCreatedTextTag,true)
}
}
bool UnitDispelMagic(unit u)
{
int i
bool r
if(GetUnitAbilityLevel(u,'A09L')>0){//shield
i=GetUnitAbilityLevel(u,'A09L')
if(i==2){
SetUnitAbilityLevel(u,'A09L',1)
SetUnitAbilityLevel(u,'A09Q',1)
//UnitRemoveAbility(u,0)
//SetUnitState(u,UNIT_STATE_MANA,GetUnitState(u,UNIT_STATE_MANA)+100.)
SetUnitState(u,UNIT_STATE_LIFE,GetWidgetLife(u)+150.)
}else{
UnitRemoveAbility(u,'A09L')
UnitRemoveAbility(u,'A09Q')
}
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIvi\\AIviTarget.mdl",u,"origin"))
r = true
}elseif(GetUnitTypeId(u)=='n01T'){// goblin shreder
i=GetUnitAbilityLevel(u,'A09C')+1
if(i>=6){return false}
else {
SetUnitAbilityLevel(u,'A09C',i)
SetUnitAbilityLevel(u,'A09B',i)
SetUnitAbilityLevel(u,'A00J',i)
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Avatar\\AvatarCaster.mdl",u,"origin"))
r = true }
} else {
r = GetUnitAbilityLevel(u,'A07H')>0
}
if(r) {DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl",u,"origin"))}
return r
}
boolexpr filterEnemyUnit
private bool FilterEnemyUnit()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>.405 and IsUnitEnemy(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER) and GetUnitAbilityLevel(u,'Avul')<=0 and GetUnitAbilityLevel(u,'A08H')<=0
u=null
return res
}
boolexpr filterEnemyUnitWMana
boolexpr filterEnemySpecialWMana
private bool FilterEnemyUnitWMana()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>.405 and IsUnitEnemy(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER) and GetUnitAbilityLevel(u,'Avul')<=0 and GetUnitAbilityLevel(u,'A08H')<=0 and (GetUnitState(u, UNIT_STATE_MANA) > 0 or GetRandomInt(0,99) > 75)
u=null
return res
}
private bool FilterEnemySpecialWMana()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>.405 and IsUnitEnemy(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_STRUCTURE) and (GetUnitState(u, UNIT_STATE_MANA) > 0) and SB2WPrice[GetUnitPointValue(u)] > 0
u=null
return res
}
constant group SpecialUnitsGroup=CreateGroup()
private void SpecialUnitsActivatorPersonal()
{
SpecialAttackOrder(GetEnumUnit())
}
private void SpecialUnitsActivator()
{
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"1")
ForGroup(SpecialUnitsGroup,function SpecialUnitsActivatorPersonal)
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"2")
}
boolexpr orderGiverFilter
private bool OrderGiverFilter()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>.405 and IsUnitType(u, UNIT_TYPE_SAPPER) and GetUnitCurrentOrder(u)==0 and GetUnitAbilityLevel(u,'A07I')<=0 and GetUnitAbilityLevel(u,'A07M')<=0 and GetUnitAbilityLevel(u,'A0ID')<=0
if(res) {
//AttackCreepOrder(u)
//IssuePointOrderByIdLoc(u,851983,og_loc)
}
u=null
return false
}
private void OrderGiverPerson()
{
AttackCreepOrder(GetEnumUnit())
}
private void OrderGiver()
{
int i = 11
player p
unit u
location og_loc
//GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,orderGiverFilter)
//ForGroup(pickgroup, function OrderGiverPerson)
loop
p = Player(i)
og_loc = targetRectLoc[forceId[i]]
GroupEnumUnitsOfPlayer(pickgroup,p,null)
loop
u = FirstOfGroup(pickgroup)
exitwhen u == null
if( IsUnitType(u, UNIT_TYPE_SAPPER) and GetUnitCurrentOrder(u)==0 and GetWidgetLife(u)>.405 and GetUnitAbilityLevel(u,'A07I')<=0 and GetUnitAbilityLevel(u,'A07M')<=0 and GetUnitAbilityLevel(u,'A0ID')<=0) {
IssuePointOrderByIdLoc(u,851983,og_loc)
}
GroupRemoveUnit(pickgroup,u)
endloop
i--
exitwhen i < 0
endloop
p=null
u=null
og_loc = null
}
public constant timer SpecialControls=CreateTimer()
public constant timer CommonControls=CreateTimer()
public void CheckAndStartSpecials()
{
bool filterRace=false
int i=0
loop
if(peonsUID[i]==peon_nelf or peonsUID[i]==peon_mech){
filterRace=true
}
i++
exitwhen i>11 or filterRace
endloop
if(filterRace){
TimerStart(SpecialControls,2.,true,function SpecialUnitsActivator)
}
}
public void CheckAndStartCommon()
{
TimerStart(CommonControls,2.,true,function OrderGiver)
}
boolexpr filterOwnedPeon
private bool FilterOwnedPeon()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>.405 and IsUnitType(u, UNIT_TYPE_PEON)
u=null
return res
}
void EnumResetAnimation()
{
SetUnitAnimation(GetEnumUnit(),"stand")
}
private void UnitProduceTwin(unit u, unit producer)
{
if(GetUnitAbilityLevel(producer,'B01K')>0){//if in plant
UnitAddAbility(u,'A09M')
SetUnitAbilityLevel(u,'A09M',3)
UnitRemoveAbility(u,'A09M')
UnitAddAbility(u,'A09Q')
UnitAddAbility(u,'A09R')
}
if(mode_cc and not IsUnitType(u,UNIT_TYPE_FLYING) ){
AntiCaging_newUnit(u)
}
if(GetUnitAbilityLevel(u,'A07M')>=1){ //gobbos and assasins
GroupAddUnit(SpecialUnitsGroup,u)
}
}
int ProdT
void ResetTrain(unit u){
int tobuild = trainOrder[GetUnitPointValue(u)]
IssueImmediateOrderById(u,851976) //CANCEL! (may cancel upgrade???)
IssueImmediateOrderById(u,851976)
IssueImmediateOrderById(u,851976)
IssueImmediateOrderById(u,851976)
IssueImmediateOrderById(u,851976)
IssueImmediateOrderById(u,851976)
IssueImmediateOrderById(u,851976)
IssueImmediateOrderById(u,tobuild)
//IssueImmediateOrderById(u,tobuild)
}
void SyncTask(){
trigger t=GetTriggeringTrigger()
unit u
unit su
lightning l
if(t!=null) {
u = LoadUnitHandle(tableIN,htSyncTmrKey,GetHandleId(t))
if(u!=null) { //reset production here
su = LoadUnitHandle(tableIN,htSyncUnitKey,GetHandleId(u))
SaveUnitHandle(tableIN,htSyncTmrKey,GetHandleId(t),null)
if(su!=null and GetWidgetLife(su)>.405) {
ResetTrain(u)
//DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Items\\ResourceItems\\ResourceEffectTarget.mdl",GetUnitX(u),GetUnitY(u)))
l = AddLightning("LEAS", true,GetUnitX(u),GetUnitY(u),GetUnitX(su),GetUnitY(su))
SetLightningColor(l,1.0,1.0,1.0,0.7)
TriggerSleepAction(0.5)
DestroyLightning(l)
l=null
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"Sync: "+GetUnitName(u)+R2S(ProdX)+":"+R2S(ProdY))
}
u = null
su = null
}
DestroyTrigger(t)
t = null
}
}
boolean MustResetProducer
public void RunSyncTask() {
trigger t
unit u = GetEnumUnit()
real dt
if(GetWidgetLife(u)>0.405) {
dt = I2R(ProdT-GetUnitBuildTime(trainOrder[GetUnitPointValue(u)]))
if(dt>0) {
t = CreateTrigger()
TriggerAddAction(t,function SyncTask)
SaveUnitHandle(tableIN,htSyncTmrKey,GetHandleId(t),u)
TriggerRegisterTimerEvent(t,dt-0.05,false)
t=null
} else {
ResetTrain(u)
MustResetProducer=true
}
}
u = null
}
void OnUnitProduced(unit u, unit producer)
{
player p=GetOwningPlayer(producer)
int pid=GetPlayerId(p)
int cc,lp
bool planted=GetUnitAbilityLevel(producer,'B01K')>0
group sg
if(planted){//if is near p.plant
UnitAddAbility(u,'A09M')
SetUnitAbilityLevel(u,'A09M',3)
UnitRemoveAbility(u,'A09M')
UnitAddAbility(u,'A09Q')
UnitAddAbility(u,'A09R')
}
if (GetUnitAbilityLevel(producer,'A0K9') > 0) //corrupted
{
UnitRemoveAbility(producer,'A0K9')
SetUnitScale(u, 0.6,0.6,0.6)
UnitAddAbility(u,'A0KA')
}
if(mode_cc and not IsUnitType(u,UNIT_TYPE_FLYING) ){
AntiCaging_newUnit(u)
}
if(GetUnitAbilityLevel(u,'A07M')>=1){
GroupAddUnit(SpecialUnitsGroup,u)
}elseif(GetUnitAbilityLevel(u,'A09H')>0) {//murlok,spider
UnitProduceTwin(CreateUnit(p,GetUnitTypeId(u),GetUnitX(u),GetUnitY(u),0.),producer)
} elseif(GetUnitTypeId(u)=='n024'){
GroupAddUnit(grAdamants,u)
}
//Humans shrine
if(pid<6){pid=0;lp=2} else {pid=6;lp=8} //3x3!!!
if(GetUnitAbilityLevel(u,'A07H')<=0) { //not legendary
loop
cc=chanceToCloneUnit[pid]
if( cc>0 ){ // and GetUnitAbilityLevel(u,'xxxx')<=0 not legend
if(CloneCnt[pid]>=CloneCap[pid]-cc and GetRandomReal(0.0,100.0) > 33.0){
UnitProduceTwin(CreateUnit(Player(pid),GetUnitTypeId(u),GetUnitX(u),GetUnitY(u),0.),producer)
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\ResourceItems\\ResourceEffectTarget.mdl",producer,"overhead"))
CloneCnt[pid] = 0
if(CloneCap[pid]<MaxCloneCap) {CloneCap[pid]++}
} else { CloneCnt[pid] ++ }
}
pid++
exitwhen pid>lp
endloop
}
/*
if(true) { //run sync tasks
sg = LoadGroupHandle(tableIN,htSyncGrKey,GetHandleId(producer))
if(sg!=null) {
ProdT = GetUnitBuildTime(GetUnitTypeId(u))
MustResetProducer = false
ForGroup(sg,function RunSyncTask)
sg=null
if(MustResetProducer) {
TriggerSleepAction(0.05)
ResetTrain(producer)
}
}
}*/
}
public void init()
{
filterEnemyUnit=Filter(function FilterEnemyUnit)
orderGiverFilter=Filter(function OrderGiverFilter)
filterEnemyGroundUnit=Filter(function FilterEnemyGroundUnit)
filterVisibleEnemyGroundUnit=Filter(function FilterVisibleEnemyGroundUnit)
filterLivingEnemy = Filter(function FilterLivingEnemy)
filterOwnedPeon=Filter(function FilterOwnedPeon)
filterEnemyUnitWMana=Filter(function FilterEnemyUnitWMana)
filterEnemySpecialWMana=Filter(function FilterEnemySpecialWMana)
}
endlibrary
library_once LPreloader initializer init
define private PreloadUnit(u)=RemoveUnit(CreateUnit(Player(13),u,0.,0.,0.))
define private PreloadUnit(from,to)={
i=from
loop
PreloadUnit(i)
i++
exitwhen i>to
endloop
}
private void action()
{
//effects
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\NightElf\\Barkskin\\BarkSkinTarget.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Other\\HowlOfTerror\\HowlCaster.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Units\\NightElf\\Wisp\\WispExplode.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Items\\AIam\\AIamTarget.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Orc\\AncestralSpirit\\AncestralSpiritCaster.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Resurrect\\ResurrectCaster.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Undead\\DeathPact\\DeathPactTarget.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Undead\\ReplenishHealth\\ReplenishHealthCasterOverhead.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\Naga\\NagaDeath\\NagaDeath.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Orc\\FeralSpirit\\feralspiritdone.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Avatar\\AvatarCaster.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\NightElf\\BattleRoar\\RoarCaster.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Polymorph\\PolyMorphTarget.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\ControlMagic\\ControlMagicTarget.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Items\\AIda\\AIdaCaster.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Feedback\\SpellBreakerAttack.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Avatar\\AvatarCaster.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Items\\AIvi\\AIviTarget.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Other\\Transmute\\PileofGold.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Items\\AIil\\AIilTarget.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosDone.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\NightElf\\NEDeathMedium\\NEDeath.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\NightElf\\EntBirthTarget\\EntBirthTarget.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("mdx\\sfx\\sin2.mdx",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("mdx\\sfx\\]TrapUp.mdx",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Undead\\ReplenishMana\\ReplenishManaCasterOverhead.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Other\\Volcano\\VolcanoDeath.mdl",0.,0.))
//DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Other\\ForkedLightning\\ForkedLightningTarget.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("mdx\\sfx\\FireTrapUp.mdx",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Heal\\HealTarget.mdl",0.,0.))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Undead\\DeathPact\\DeathPactCaster.mdl",0.,0.))
//common dummy
KillUnit(CreateUnit(Player(13),'e008',0.,0.,0.))
//peasants
KillUnit(CreateUnit(Player(13),'h00O',0.,0.,0.))
KillUnit(CreateUnit(Player(13),'u006',0.,0.,0.))
KillUnit(CreateUnit(Player(13),'h00C',0.,0.,0.))
KillUnit(CreateUnit(Player(13),'h019',0.,0.,0.))
KillUnit(CreateUnit(Player(13),'h00E',0.,0.,0.))
KillUnit(CreateUnit(Player(13),'h017',0.,0.,0.))
KillUnit(CreateUnit(Player(13),'h089',0.,0.,0.))
KillUnit(CreateUnit(Player(13),'h00P',0.,0.,0.))
KillUnit(CreateUnit(Player(13),'h018',0.,0.,0.))
KillUnit(CreateUnit(Player(13),'h06P',0.,0.,0.))
KillUnit(CreateUnit(Player(13),'h01A',0.,0.,0.))
KillUnit(CreateUnit(Player(13),'h051',0.,0.,0.))
KillUnit(CreateUnit(Player(13),'h06N',0.,0.,0.))
//ExecuteFunc(SCOPE_PRIVATE+"loadUnits")
}
public void init()
{
action()
}
endlibrary
library AIPaths// uses DebugLog
define private buildingSize=128.
define private cpMaxY=2172.
define private cpMinX=1664.
define private startPlaceX=5508.
define private startPlaceY=512.
public real array cpX
public real array cpY
private real array cvDX
private real array cvDY
private real pathStep
public void reset(bool fill)
{
if(mode_na or fill){
pathStep=buildingSize
}else{
pathStep=buildingSize*2.
}
cvDX[0]=-1.*pathStep; cvDY[0]=1.*pathStep
cvDX[1]=-1.*pathStep; cvDY[1]=1.*pathStep
cvDX[2]=1.*pathStep; cvDY[2]=1.*pathStep
cvDX[3]=1.*pathStep; cvDY[3]=1.*pathStep
cpX[0]=startPlaceX
cpY[0]=startPlaceY
cpX[1]=startPlaceX
cpY[1]=1.*startPlaceY
cpX[2]=-1.*startPlaceX
cpY[2]=1.*startPlaceY
cpX[3]=-1.*startPlaceX
cpY[3]=startPlaceY
}
public void next(int aipath)
{
cpY[aipath]+=cvDY[aipath]
if(RAbsBJ(cpY[aipath])>cpMaxY){
cpX[aipath]+=cvDX[aipath]
if (cpY[aipath]>0) {cpY[aipath]=startPlaceY}
else {cpY[aipath]=-1*startPlaceY}
if(RAbsBJ(cpX[aipath])<cpMinX){
reset(true)
return
}
}
}
endlibrary
library AIStrikeAbility uses Utils
public bool rsAction(unit caster, unit source)
{
local real x = rsX
local real y = rsY
local real d
filterPlayer=GetOwningPlayer(source)
if(IsPlayerInForce(filterPlayer,leftPlayers)){
DisplayTextToForce(leftPlayers,GetColoredName(GetPlayerId(GetOwningPlayer(caster)))+": I'm going to Strike!!!")
}elseif(IsPlayerInForce(filterPlayer,rightPlayers)){
DisplayTextToForce(rightPlayers,GetColoredName(GetPlayerId(GetOwningPlayer(caster)))+": I'm going to Strike!!!")
}
Utils_Tele2PT(caster,x,y,900.)
return IssuePointOrderById(caster,852488,x,y)
}
endlibrary
library AINamesPool
private string array n //names
private int c //count
public string get()
{
int i=GetRandomInt(0,c)
string s=n[i]
n[i]=n[c]
c--
return s
}
public void init()
{
n[ 0]="General"
n[ 1]="FanToMace"
n[ 2]="antiPOD"
n[ 3]="ADMIN"
n[ 4]="Mr.Jack"
n[ 5]="C|c00ff008000l|r"
n[ 6]="O|c00ff00ff:|r"
n[ 7]=":|c00ff8040O|r"
n[ 8]="INqUSitor"
n[ 9]="Your_Death"
n[10]="NanYanoi"
n[11]="Impale"
n[12]="Proxima"
n[13]="13|c00ff0000th|r"
n[14]="Dumb"
n[15]="Pro-Fan"
n[16]="IWin"
n[17]="Master"
n[18]="JustNiceGuy"
n[19]="Kasr'Kin"
n[20]="Pr0"
n[21]="Imperor"
n[22]="FBI"
n[23]="Scheemer"
n[24]="WTFG0D"
n[25]="Dude"
n[26]="YourDaddy"
n[27]="GreatWarrior"
n[28]="Shadow"
n[29]="No_Ob"
n[30]="Shurf"
n[31]="ImAI"
n[32]="Grrr!"
n[33]="Brain"
n[34]="L|c0000ff40ord|r"
n[35]="Princess"
c=35
}
endlibrary
library AILibrary uses Main, Data, AIPaths, AIStrikeAbility, AINamesPool
public bool array isPlayerAFK // used also in PlayerAFKControl
private int countAFK=0
private timer reminderAFK
private int array buildSide
//buildings definitions
private int array B2ArmT //building2armorType
private int array B2AtkT //building2attack
private real array B2Hps //building2HPn
private int array B2Dps //building2HPn
private int array B2SpDp //building2SplashDmg
private int array B2FL //building2HPn
int array SB2WPrice
private bool array SB2FoodR
private int array SB2FL
private real array SB2V
hashtable RBT
define attackTypesCount=7
define AT_PIERCE=0
define AT_SIEGE=1
define AT_NORMAL=2
define AT_MAGIC=3
define AT_HERO=4
define AT_CHAOS=5
define AT_SPELLS=6
//armors
define private AR_LIGHT=0
define private AR_NORMAL=1
define private AR_HEAVY=2
define private AR_FORT=3
define private AR_HERO=4
define private AR_DIVINE=5
define private AR_NONE=6
define private N_ARMORS=7
define private N_ATTYPES=7
define private FL_AIR=1
define private FL_AA=2
define private FL_AG=4
define private FL_AOE=1
define IsAA(ufl) = (ufl==2 or ufl==3 or ufl==6 or ufl==7)
define IsAG(ufl) = (ufl==4 or ufl==5 or ufl==6 or ufl==7)
define IsFlying(ufl) = (ufl==1 or ufl==3 or ufl==5 or ufl==7)
define private GCCI='tmp1'
define GCCS='uiss'
//1111111
//define BT_Registred(bid)=HaveSavedInteger(RBT,bid,0)
define private registerSpecial(bid,reqFood,afl,sv)={
i=GetUnitPointValueByType(bid)
SB2WPrice[i] = GetUnitWoodCost(bid)
SB2FoodR[i] = reqFood
SB2FL[i] = afl
SB2V[i] = sv
}
private void RegisterBuildingProp(int bid,int attackt,int armort,int hp,int defp,int dps,int spDps,int fl,int prodt) {
int i=GetUnitPointValueByType(bid)
int ufl
int ut
if(HaveSavedInteger(RBT,GCCI,i)) {
debug LogAdd(GetObjectName(bid)+": PV doubled "+GetObjectName(LoadInteger(RBT,GCCI,i)))
}
B2ArmT[i]=armort
B2AtkT[i]=attackt
B2Hps[i]=(hp*(1+0.06*I2R(defp))/I2R(prodt)) //effective hp
B2Dps[i]=dps
B2SpDp[i]=spDps
SaveInteger(RBT,GCCI,i,bid)
ut=trainOrder[i]
if(ut!=0){
ufl=fl
if(IsUnitIdType(ut,UNIT_TYPE_ATTACKS_FLYING)) {ufl+=FL_AA}
if(IsUnitIdType(ut,UNIT_TYPE_ATTACKS_GROUND)) {ufl+=FL_AG}
if(ufl==0) {
debug LogAdd(GetObjectName(bid)+": "+GetObjectName(ut)+" can't attack?")
}
if(IsUnitIdType(ut,UNIT_TYPE_FLYING)) {ufl+=FL_AIR}
SaveInteger(RBT,GCCS,ut,attackt)//unit id <-> attackType
}
B2FL[i] = ufl
//LogAdd(GetObjectName(ut)+";"+I2S(ufl)+";"+R2S(B2Hps[i])+";"+I2S(B2Dps[i])+";"+I2S(GetUnitGoldCost(bid)))
//LogAdd(Utils_RawCode2S(ut)+";"+GetObjectName(ut))
}
public real array D2A
private int ATI
private void S2AT(string s){
int i = 0
loop
D2A[ATI] = S2R(SubString(s,i*5,i*5+5))
ATI++
i++
exitwhen i>=N_ARMORS
endloop
}
private void SetArmorTable()
{
ATI=0
//Lig Med Hvy Fort*HERO DIVI UNAR 7x7
S2AT("1.75 1.00 0.70 0.45 0.60 0.25 1.05") //pierce
S2AT("0.70 0.70 0.70 1.60 0.40 0.20 1.00") //siege
S2AT("0.70 1.75 1.00 0.50 0.60 0.25 1.05") //norm
S2AT("1.00 0.70 1.75 0.40 0.60 0.25 1.05")//mag
S2AT("1.10 1.10 1.10 0.60 0.60 0.40 1.10")//hero
S2AT("1.00 1.00 1.00 1.00 1.00 1.00 1.00")//chaos
S2AT("1.00 1.00 1.00 1.00 0.70 0.25 1.00")//spells
}
private unit array uBuilders
private int array playerRace
private bool array isAIControled
private unit array lastDmgStructure
private force array strikeStack
private timer array strikeActivator
private bool array strikeEnable
private player array strikePlayer
private bool aiSleep=true
private bool inited=false
public trigger trgStructDmg=CreateTrigger()
define RegisterStructDmg(u)=TriggerRegisterUnitEvent(AILibrary_trgStructDmg,u,EVENT_UNIT_ATTACKED)
///////////////////////////////////////////////////////////////////
// HELPER FUNCTIONS
///////////////////////////////////////////////////////////////////
//structures
//max len = 40
private real array sHPxDt
private real array sDPxAt
public void StructureDied(int ut, int fid){ //force id 0-1
int i=GetUnitPointValueByType(ut)
i = i+ fid*MaxPV
BldNum[i]--
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"StructureDied "+GetObjectName(ut))
//AILibrary_actual = false
}
public void ResetStructCnt() {
int i=0
loop
BldNum[i] = 0
i++
exitwhen i > MaxPV*2
endloop
}
private bool NoBuildings
public void DumpC(){
int i=0
string s1="WGH "
string s2="WAH "
string s3="EGH "
string s4="EAH "
string s5="EGA "
string s6="EAA "
string s7="WGA "
string s8="WAA "
loop
s1+=R2SW(sHPxDt[i],5,1)
s2+=R2SW(sHPxDt[i+10],5,1)
s3+=R2SW(sHPxDt[i+20],5,1)
s4+=R2SW(sHPxDt[i+30],5,1)
s5+=R2SW(sDPxAt[i],5,1)
s6+=R2SW(sDPxAt[i+10],5,1)
s7+=R2SW(sDPxAt[i+20],5,1)
s8+=R2SW(sDPxAt[i+30],5,1)
i++
exitwhen i >= 7
endloop
DisplayTextToPlayer(GetLocalPlayer(),0.,0.,s1)
DisplayTextToPlayer(GetLocalPlayer(),0.,0.,s2)
DisplayTextToPlayer(GetLocalPlayer(),0.,0.,s3)
DisplayTextToPlayer(GetLocalPlayer(),0.,0.,s4)
DisplayTextToPlayer(GetLocalPlayer(),0.,0.,s5)
DisplayTextToPlayer(GetLocalPlayer(),0.,0.,s6)
DisplayTextToPlayer(GetLocalPlayer(),0.,0.,s7)
DisplayTextToPlayer(GetLocalPlayer(),0.,0.,s8)
debug LogAdd(s1);debug LogAdd(s2);debug LogAdd(s3);debug LogAdd(s4)
debug LogAdd(s5);debug LogAdd(s6);debug LogAdd(s7);debug LogAdd(s8)
}
public void RegConstructed(int ut, int pid){
int pv
int ofs
int fl
int j
int cco
int ppv
real k = 0.0;
//if (!BT_Registred(ut)){;return}
//LogAdd(GetObjectName(ut)+"/"+I2S(pid))
NoBuildings=false
pv=GetUnitPointValueByType(ut)
if(IsUnitIdType(ut,UNIT_TYPE_MELEE_ATTACKER))
{
k = 0.2;
}
ppv = BldReqId[pv]
ofs=forceId[pid]*20
fl = B2FL[pv] //HP
j = ofs + B2AtkT[pv] //attack type
if(IsAG(fl)) {sDPxAt[j]+=B2Dps[pv]*(1.0+k)}
if(IsAA(fl)) {j+=10; sDPxAt[j]+=B2Dps[pv]*(1.0+k)}
j = 20-ofs+B2ArmT[pv] //reverse offset for hp!
if(IsFlying(fl)) {j+=10}
sHPxDt[j]+=B2Hps[pv]*(1.0-k)
//store counter for each type
cco = forceId[pid]*MaxPV
if(BldReqId[pv]!=0) { //it was upgrade
//decr hps\dps
ppv = GetUnitPointValueByType(BldReqId[pv])
fl = B2FL[ppv]
j = ofs + B2AtkT[ppv]
if(IsAG(fl)) {sDPxAt[j]-=B2Dps[ppv]*(1.0+k)}
if(IsAA(fl)) {j+=10; sDPxAt[j]-=B2Dps[ppv]*(1.0+k)}
j = 20-ofs+B2ArmT[ppv] //reverse offset for hp!
if(IsFlying(fl)) {j+=10}
sHPxDt[j]-=B2Hps[ppv]*(1.0-k)
//decr preq num
BldNum[cco+ppv]--
}
cco+=pv
BldNum[cco]++
AILibrary_actual = false
AILibrary_planned_c[pid]=0
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"Constructed:"+GetObjectName(ut)+":"+I2S(B2ArmT[pv]))
//DumpC()
}
private int tctid
private boolexpr fltConstrOfType
private bool FltConstrOfType(){
return GetUnitTypeId(GetFilterUnit())==tctid
}
private unit GetConstr4Upgrade(int idfrom, player p)
{
tctid=idfrom
GroupEnumUnitsOfPlayer(pickgroup,p,fltConstrOfType)
return FirstOfGroup(pickgroup)
}
private void ReactivateStrike()
{
if(GetExpiredTimer()==strikeActivator[0]){
strikeEnable[0]=true
}else{
strikeEnable[1]=true
}
}
private bool StrikeOrder(int pid)
{
if(GetUnitAbilityLevel(uBuilders[pid],'A005')<=0){
strikePlayer[forceId[pid]]=Player(14)
ForceRemovePlayer(strikeStack[forceId[pid]],Player(pid))
}else{
strikeEnable[forceId[pid]]=false
strikePlayer[forceId[pid]]=Player(pid)
TimerStart(strikeActivator[forceId[pid]],8.,false,function ReactivateStrike) //next RS timeouted
return AIStrikeAbility_rsAction(uBuilders[pid],lastDmgStructure[forceId[pid]])
}
return false
}
private real EnHP
private real AlHP
private int Ecnt
real rsX
real rsY
private boolexpr fltEnemyUnitC
private bool FltEnemyUnitC()
{
unit u=GetFilterUnit()
real uh = GetWidgetLife(u)
bool res= uh>50.0 and IsUnitType(u,UNIT_TYPE_SAPPER) and GetUnitAbilityLevel(u,'Avul')<=0 and GetUnitAbilityLevel(u,'A08H')<=0
if(res)
{
if(IsUnitEnemy(u,filterPlayer)){
EnHP+=uh
Ecnt++
rsX += GetUnitX(u)
rsY += GetUnitY(u)
} else{AlHP+=uh}
}
u=null
return false
}
private bool OnDmgStructure() //"structure attacked" event handler
{
unit u
int fid
player p
real shr
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"RS::"+I2S(Ticks)+"//"+I2S(RStrikeNextTicks))
if(Ticks < RStrikeNextTicks) { return false }
if(IsUnitType(GetAttacker(),UNIT_TYPE_SAPPER)){
RStrikeNextTicks = Ticks + 2 //! common variable (for both teams)
u=GetTriggerUnit()
filterPlayer=GetOwningPlayer(u)
fid=forceId[GetPlayerId(filterPlayer)]
if (mpRsCount[fid] <= 0) {
u=null
return false
}
shr = GetWidgetLife(u)/GetUnitState(u,UNIT_STATE_MAX_LIFE)
lastDmgStructure[fid]=u
EnHP = 500.
AlHP = 1000.*shr
Ecnt = 0
rsX = 0.
rsY = 0.
GroupEnumUnitsInRange(pickgroup,GetUnitX(u),GetUnitY(u),1400.,fltEnemyUnitC)
if (Ecnt > 0){
rsX /= I2R(Ecnt)
rsY /= I2R(Ecnt)
}
p=FirstOfForce(strikeStack[fid])
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"RS::"+R2S(EnHP/AlHP))
if(p!=null and (Ecnt>4) and (shr<.30 or EnHP/AlHP > 6.0 ) and (strikeEnable[fid] or strikePlayer[fid]==p)){
//LogDebug("AI","STRIKE_ORDER_TARGET",GetPlayerName(p))
RStrikeNextTicks = Ticks + 7
StrikeOrder(GetPlayerId(p))
}
}
u=null
return false
}
private boolexpr filterRepairTargetBuilding
private unit MostDamagedU
private real MostDamagedHP
private bool FilterRepairTargetBuilding()
{
unit u=GetFilterUnit()
real r=GetWidgetLife(u)
bool res=r>.405 and IsUnitAlly(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_STRUCTURE)
if(res){
if(GetUnitState(u,UNIT_STATE_MAX_LIFE)-r > 150. and r < MostDamagedHP) {
MostDamagedHP = r; MostDamagedU = u
}
}
u=null
return false
}
//declaration
///////////////////////////////////////////////////////////////////
// AI COMMANDER
///////////////////////////////////////////////////////////////////
private void RepairOrderer()
{
int i=0
unit u
if(aiSleep){return}
loop
if(isAIControled[i] and uBuilders[i]!=null and GetWidgetLife(uBuilders[i])>.405){
u = lastDmgStructure[forceId[i]]
if(u!=null and GetWidgetLife(u)>.405 and GetUnitState(u,UNIT_STATE_MAX_LIFE)-GetWidgetLife(u)>150.){
Utils_Tele2PT(uBuilders[i],GetUnitX(u),GetUnitY(u),500.)
IssueTargetOrderById(uBuilders[i],852024,u)
}else{
filterPlayer=Player(i)
MostDamagedU = null; MostDamagedHP = 9999.
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterRepairTargetBuilding)
lastDmgStructure[forceId[i]]=MostDamagedU
}
}
i++
exitwhen i>11
endloop
u=null
}
private int Peon2AIRace(int uid)
{
if( uid ==peon_chaos ) {return RACE_CHAOS}
if( uid ==peon_corrupted ) {return RACE_CORRUPTED}
if( uid ==peon_human ) {return RACE_HUMAN}
if( uid ==peon_orc ) {return RACE_ORC}
if( uid ==peon_naga ) {return RACE_NAGA}
if( uid ==peon_northern ) {return RACE_NORTH}
if( uid ==peon_nelf ) {return RACE_NELF}
if( uid ==peon_helf ) {return RACE_HELF}
if( uid ==peon_undead ) {return RACE_DEAD}
if( uid ==peon_mech ) {return RACE_MECH}
if( uid ==peon_nature ) {return RACE_NATURE}
if( uid ==peon_magic ) {return RACE_ELEMENT}
if( uid ==peon_desert ) {return RACE_DESERT}
DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"Uknown builder!")
return -1
}
private int array av_bid
public int array planned_c
private trigger array trgAIBuild
private boolean array AICPrgr
private int CheckPlId(int p){
if(p<0) {return 0} elseif(p>11) { return 11} else {return p}
}
//333333
private void TryConstruct() {
int pid=CheckPlId(LoadInteger(tableIN,htKeyAIBTRG,GetHandleId(GetTriggeringTrigger())))
int ofs=buildSide[pid]
int n=2
int m=6
int uid
unit bu=null
real g = GetPlayerState(Player(pid),PLAYER_STATE_RESOURCE_GOLD)
real w = GetPlayerState(Player(pid),PLAYER_STATE_RESOURCE_LUMBER)
int bid
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,GetPlayerName(Player(pid))+" TC0 "+I2S(GetHandleId(GetTriggeringTrigger())))
if(planned_c[pid]==0) {return}
bid=GetUnitPointValueByType(planned_c[pid])
if (BuildingPrice[bid]>g or SB2WPrice[bid]>w) {
return
}
uid = BldReqId[bid]
if(uid!=0) {
bu=GetConstr4Upgrade(uid,Player(pid)) //todo: wait for completion
if(bu!=null)
{
SetUnitOwner(bu,Player(15),false)
SetUnitOwner(bu,Player(pid),false)
IssueImmediateOrderById(bu,planned_c[pid])
} else {
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"Can't upgrade "+GetObjectName(uid))
//planned_c[pid]=0//uid
}
}
else {
AICPrgr[pid] = true
bu=uBuilders[pid]
g = AIPaths_cpX[ofs]; w = AIPaths_cpY[ofs]
Utils_Tele2PT(bu,g,w,300.)
loop
g = AIPaths_cpX[ofs]; w = AIPaths_cpY[ofs]
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,GetPlayerName(Player(pid))+" build "+R2S(g)+" x "+R2S(w)+" "+GetObjectName(planned_c[pid]))
if(IssueBuildOrderById(bu,planned_c[pid],g,w)){
m = 6
loop
TriggerSleepAction(0.35)
m--
exitwhen (m <=0 or planned_c[pid]==0) //GetUnitCurrentOrder(bu)==0 or
endloop
}
AIPaths_next(ofs)
TriggerSleepAction(0.3)
n--
exitwhen n<=0 or planned_c[pid]==0
endloop
IssuePointOrderByIdLoc(bu,852525,startPosition[pid]) //TP back
}
AICPrgr[pid] = false
//planned_c[pid]=0
bu=null
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,I2S(pid)+" TC done")
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"TryConstruct: "+I2S(pid)+" fin")
}
private real array ACV //E10AAr E10GAr W10AAr W10GAr
private real array NAV //E10AtG E10AtA W10AtG W10AtG
public bool actual=true
define DefCounteredRate = 0.05
private real Air2GrRatioE
private real Air2GrRatioW
// calculate ArmoredHp_countered vector
// W10HpG W10HpA / E10HpG E10HpA
// E10AtG E10AtA / W10AtG W10AtA
private void UpdateTactData() {
int ari=0
int ati
real eva
real evg
real wva
real wvg
real d2ak
string s
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"UTD@:")
//DumpC()
loop //armors 49
ati=0
eva=1.;evg=1.;wva=1.;wvg=1.
loop //apply all attacks 2 ari armor
d2ak = D2A[ati*N_ARMORS+ari]
evg+=sDPxAt[ati]*d2ak
eva+=sDPxAt[ati+10]*d2ak
wvg+=sDPxAt[ati+20]*d2ak
wva+=sDPxAt[ati+30]*d2ak
ati++
exitwhen ati >= N_ATTYPES
endloop//attacks
ACV[ari] = sHPxDt[ari]/(evg);
ACV[ari+10] = sHPxDt[ari+10]/(eva);
ACV[ari+20] = sHPxDt[ari+20]/(wvg);
ACV[ari+30] = sHPxDt[ari+30]/(wva);
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"ACV:"+I2S(ari)+R2SW(ACV[ari],5,1)+R2SW(ACV[ari+10],5,1)+R2SW(ACV[ari+20],5,1)+R2SW(ACV[ari+30],5,1))
if(ACV[ari]<DefCounteredRate) {ACV[ari]=0.}
if(ACV[ari+10]<DefCounteredRate) {ACV[ari+10]=0.}
if(ACV[ari+20]<DefCounteredRate) {ACV[ari+20]=0.}
if(ACV[ari+30]<DefCounteredRate) {ACV[ari+30]=0.}
ari++
exitwhen ari >= N_ARMORS
endloop
//normalize attacks 7+7
ati=0
eva=0.01;evg=0.01;wva=0.01;wvg=0.01
loop
evg+=sDPxAt[ati]
eva+=sDPxAt[ati+10]
wvg+=sDPxAt[ati+20]
wva+=sDPxAt[ati+30]
ati++
exitwhen ati >= N_ATTYPES
endloop
ati=0
loop
NAV[ati]=sDPxAt[ati]/evg
NAV[ati+10]=sDPxAt[ati+10]/eva
NAV[ati+20]=sDPxAt[ati+20]/wvg
NAV[ati+30]=sDPxAt[ati+30]/wva
ati++
exitwhen ati >= N_ATTYPES
endloop
//normalize armors 7x2
ati=0
eva=0.01;evg=0.01;wva=0.01;wvg=0.01
loop
evg+=ACV[ati]
eva+=ACV[ati+10]
wvg+=ACV[ati+20]
wva+=ACV[ati+30]
ati++
exitwhen ati >= N_ARMORS
endloop
//experimental - normalize 2 TOTAL(A+G)
evg+=eva; eva=evg
wvg+=wva; wva=wvg
//experimental
ati=0
loop
ACV[ati]=ACV[ati]/evg
ACV[ati+10]=ACV[ati+10]/eva
ACV[ati+20]=ACV[ati+20]/wvg
ACV[ati+30]=ACV[ati+30]/wva
ati++
exitwhen ati >= N_ARMORS
endloop
debug LogAdd("THP: "+R2SW(evg,5,1)+R2SW(eva,5,1)+R2SW(wvg,5,1)+R2SW(wva,5,1))
Air2GrRatioE = eva/(eva+evg)
Air2GrRatioW = wva/(wva+wvg)
actual=true
}
//ACV E10AAr E10GAr W10AAr W10GAr
//NAV E10AtG E10AtA W10AtG W10AtG
//4444
//TODO: cache it?
private real EstimateAt(int ati, int ofs){
int i=0
real r=0.0 //
loop
r+=ACV[ofs+i]*D2A[ati*N_ARMORS+i]
i++;
exitwhen i >= N_ARMORS
endloop
return r
}
private real EstimateDefT(int dti, int ofs){ //ofs to ENEMIES attacks!
int i=0
real r=0.
real r1
//string s="DT:"+I2S(dti)
loop
r1=NAV[ofs+i]*D2A[dti + N_ATTYPES*i]
//s+=R2SW(r1,5,2)
r+=r1
i++;
exitwhen i >= N_ATTYPES
endloop
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,s)
return r
}
private real av
private real dv
//0,AG,AA,AoE
private real EstimateSpcl(int bid, int side){
int cpv=GetUnitPointValueByType(bid)
int fl=SB2FL[cpv]
real v = SB2V[cpv]
if(IsAA(fl)) {
if(side==1) {v = v * Air2GrRatioW}
else {v = v * Air2GrRatioE}
}
if(IsAG(fl)) {
if(side==1) {v = v * (1.-Air2GrRatioW)}
else {v = v * (1.-Air2GrRatioE)}
}
if(IsFlying(fl)) { v = v * SplashW}
av = Air2GrRatioE; dv=SplashW
return v / (1.+0.06*BldNum[side*MaxPV+cpv])
}
private real EstimateConstr(int bid, int side){
int cpv=GetUnitPointValueByType(bid)
int fl=B2FL[cpv]
int ofs=side*20
av=0.;dv=0.
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"Est:"+GetObjectName(bid))
if(IsAG(fl)) { av+=EstimateAt(B2AtkT[cpv],ofs)
//debug LogAdd(GetObjectName(bid)+" Gr:"+R2S(av))
}
if(IsAA(fl)) { av+=EstimateAt(B2AtkT[cpv],ofs+10)
//debug LogAdd(GetObjectName(bid)+" Air+Gr:"+R2S(av))
}
if(av<0.1) {return 0.}
if(av>2.2) {av=2.4} //cap ranged ~_~
av*=(B2Dps[cpv]+SplashW*B2SpDp[cpv])
ofs=20-ofs
if(IsFlying(fl)) {ofs+=10}
dv=EstimateDefT(B2ArmT[cpv],ofs)
if(dv>0.) {dv=B2Hps[cpv]/dv} else {dv=B2Hps[cpv]*2.}
return (av+dv)/(1.+0.05*BldNum[side*MaxPV+cpv]) //dont mass the same units
}
//7777
private void SelConstruct(int pid, int ff)
{
int ofs = playerRace[pid]*RACE_OFFSET
int n = RaceBldId[ofs]
int bid=0
int i
int j
int pv
int fl
real gld = GetPlayerState(Player(pid),PLAYER_STATE_RESOURCE_GOLD)
real lmb = GetPlayerState(Player(pid),PLAYER_STATE_RESOURCE_LUMBER)
real uv=0.
real bv
real ik
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"AI choose "+I2S(pid))
if (gld<95.) {return}
debug LogAdd(GetPlayerName(Player(pid))+ " G"+R2SW(gld,5,0)+"/W"+R2SW(lmb,5,0)+"/F"+I2S(ff))
if(NoBuildings){ //choose random at the start
if(GetRandomInt(0,99)>70) {return}
i=n; j=0
loop
bid = RaceBldId[ofs+i]
pv = GetUnitPointValueByType(bid)
gld+=Income_mCachedIncome[pid]*GetRandomReal(2.,5.)/mode_incomeTime
fl = B2FL[pv]
if(BuildingPrice[pv] <= gld and SgivesLumber[pv]>0 and BldReqId[pv]==0 and IsAG(fl)) { //skip Air-only attackers
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"AI "+I2S(pid)+" ? "+GetObjectName(bid)+"="+R2S(gld)+"-"+R2S(BuildingPrice[pv]))
av_bid[j]=bid;j++
if(IsFlying(fl)) {av_bid[j]=bid;j++} //TODO:
}
i--
exitwhen i==0
endloop
if(j>0) {
bid=av_bid[GetRandomInt(0,j-1)]
planned_c[pid]=bid
}
return
}
i=n;j=forceId[pid];n=0
ik=mode_incomeTime*0.012/(0.01+Income_mCachedIncome[pid])
bv = 28. //min points
loop
bid = RaceBldId[ofs+i]
pv = GetUnitPointValueByType(bid)
if((SgivesLumber[pv]>0 or BWCost[pv] <= lmb) and ((BldReqId[pv]==0) or (BldNum[j*MaxPV+GetUnitPointValueByType(BldReqId[pv])]>0)) and (!SB2FoodR[pv] or ff>0) ) {
if(SB2V[pv]!=0.) { //special
uv = EstimateSpcl(bid,j)
} else {
uv = EstimateConstr(bid,j)
}
if(BuildingPrice[pv]>gld) {uv=uv/(1.+(BuildingPrice[pv]-gld)*ik)}
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"::"+R2SW(uv,4,1)+":"+R2SW(av,4,1)+"/"+R2SW(dv,4,1)+" "+GetObjectName(bid)+"/"+I2S(BldReqId[pv]))
debug LogAdd(":"+R2SW(uv,4,1)+"="+R2SW(av,4,1)+"+"+R2SW(dv,4,1)+" "+GetObjectName(bid))
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,GetPlayerName(Player(pid))+ " : "+GetObjectName(bid)+"/"+R2S(uv)+":"+I2S(BldNum[j*MaxPV+GetUnitPointValueByType(BldReqId[pv])]))
if(uv/bv > 1.1 or (uv/bv>0.75 and GetRandomInt(0,99)<25)) {bv=uv; n=bid}
}
i--
exitwhen i==0
endloop
if(n!=0) {
planned_c[pid]=n
}
//DisplayTextToPlayer(GetLocalPlayer(),0.,0., "Nothing choosen "+I2S(pid))
}
//5555
private void MainOrderer()
{
int i=0
int co=0
int ff
int j=0
if(aiSleep){return}
if(GetRandomInt(0,99)>70) { FillRPID() }
loop
i = RandPlID[j]
if(isAIControled[i]){
if(!actual) { UpdateTactData() }
filterPlayer=Player(i)
if(uBuilders[i]==null or GetWidgetLife(uBuilders[i])<=.405){
GroupEnumUnitsOfPlayer(pickgroup,filterPlayer,filterOwnedPeon)//filterPeonLocator
uBuilders[i]=FirstOfGroup(pickgroup)
if(uBuilders[i]!=null){
playerRace[i]=Peon2AIRace(GetUnitTypeId(uBuilders[i]))
if(GetUnitAbilityLevel(uBuilders[i],'A005')>0){
ForceAddPlayer(strikeStack[forceId[i]],filterPlayer)
}
}
} else {
co = GetUnitCurrentOrder(uBuilders[i])
if((co==0 or co==852024) and GetRandomInt(0,99)<75){ //no order or repair
ff = GetPlayerState(filterPlayer,PLAYER_STATE_RESOURCE_FOOD_CAP)-GetPlayerState(filterPlayer,PLAYER_STATE_RESOURCE_FOOD_USED)
if(planned_c[i]==0 or GetRandomInt(0,99)>86) {
SelConstruct(i,ff)
if(planned_c[i]!=0){
if(i<=5){
DisplayTextToForce(leftPlayers,GetPlayerName(Player(i))+" waits for |cffFF8204"+GetObjectName(planned_c[i])+"|r")
} else {
DisplayTextToForce(rightPlayers,GetPlayerName(Player(i))+" waits for |cffFF8204"+GetObjectName(planned_c[i])+"|r")
}
if(!AICPrgr[i]){
TriggerRegisterTimerEvent(trgAIBuild[i], GetRandomReal(0.,0.3), false)
}
//LogAdd(GetPlayerName(Player(i))+"->"+GetObjectName(planned_c[i]))
}
}
elseif(!AICPrgr[i]){
TriggerRegisterTimerEvent(trgAIBuild[i], GetRandomReal(0.,0.3), false)
}
}
}
}
j++
exitwhen j>11
endloop
}
public void PrepareAI()
{
ExecuteFunc(SCOPE_PRIVATE+"init")
}
public void ResetBuildPlaces()
{
int i=0
if(!inited){return}
loop
if(isAIControled[i]){
if(IsPlayerInForce(Player(i),leftPlayers)){
buildSide[i]=ModuloInteger(i,2)+2
}elseif(IsPlayerInForce(Player(i),rightPlayers)){
buildSide[i]=ModuloInteger(i,2)
}
}
i++
exitwhen i>11
endloop
}
public void StartAI(int pid)
{
string s
ExecuteFunc(SCOPE_PRIVATE+"init")
if(IsPlayerInForce(Player(pid),leftPlayers)){
buildSide[pid]=ModuloInteger(pid,2)+2
}elseif(IsPlayerInForce(Player(pid),rightPlayers)){
buildSide[pid]=ModuloInteger(pid,2)
}
s=AINamesPool_get()
SetPlayerName(Player(pid),s)
names[pid]=s
Main_UpdatePlayerName(pid)
isAIControled[pid]=true
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(pid)+" (AI) joined to game")
}
public bool StopAI(int pid)
{
if(not isAIControled[pid]){return false}
isAIControled[pid]=false
ForceRemovePlayer(strikeStack[forceId[pid]],Player(pid))
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,I2S(CountPlayersInForceBJ(strikeStack[forceId[pid]])))
return true
}
private void remindAFK()
{
int i=0
loop
if(isPlayerAFK[i]){
DisplayTextToPlayer(Player(i),0.,0.,"|cffCA0000WARNING|r: AI took control over your builder! Type -afk to disable AI.")
}
i++
exitwhen i>11
endloop
}
public void SwitchPlayerAFK(int pid)
{
if(isPlayerAFK[pid]){
isPlayerAFK[pid]=false
StopAI(pid)
SetPlayerName(Player(pid),names[pid])
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(pid)+"|cffCA0000 is no longer AFK!|r")
countAFK--
if(countAFK==0){
PauseTimer(reminderAFK)
DestroyTimer(reminderAFK)
reminderAFK=null
}
}else{
isPlayerAFK[pid]=true
gameAutoTrain[pid]=true // activation of auto train
ExecuteFunc(SCOPE_PRIVATE+"init")
if(IsPlayerInForce(Player(pid),leftPlayers)){
buildSide[pid]=ModuloInteger(pid,2)+2
}elseif(IsPlayerInForce(Player(pid),rightPlayers)){
buildSide[pid]=ModuloInteger(pid,2)
}
SetPlayerName(Player(pid),"[AFK] "+names[pid])
isAIControled[pid]=true
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(pid)+"|cffCA0000 is AFK!|r AI took control over his units.")
if(countAFK==0){
reminderAFK=CreateTimer()
TimerStart(reminderAFK,15.,true,function remindAFK)
}
countAFK++
}
}
public void StartAllAI()
{
int i=0
bool b=false
loop
if(GetPlayerController(Player(i))==MAP_CONTROL_COMPUTER){
StartAI(i)
b=true
}
i++
exitwhen i>11
endloop
if(b){DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"AI may work improperly: you are playing with computer slots.\nIn future use command -fill.")}
}
public void Reset()
{
//clear counters
//DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"AI_Reset()")
int i=0
int h
int ii
loop
sHPxDt[i]=0.
sDPxAt[i]=0.
i++
exitwhen i>40
endloop
FillRPID()
i=0
loop
planned_c[i]=0
if(trgAIBuild[i] == null) {
trgAIBuild[i] = CreateTrigger()
TriggerAddAction(trgAIBuild[i],function TryConstruct)
}
ResetTrigger(trgAIBuild[i])
h = GetHandleId(trgAIBuild[i])
SaveInteger(tableIN,htKeyAIBTRG,h,i) //restore idxs
//ii = LoadInteger(tableIN,htKeyAIBTRG,h)
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,I2S(h)+" CTH "+I2S(ii))
AICPrgr[i] = false
i++
exitwhen i>11
endloop
ResetStructCnt()
AIPaths_reset(false)
ForceClear(strikeStack[0])
ForceClear(strikeStack[1])
PauseTimer(strikeActivator[0])
PauseTimer(strikeActivator[1])
strikeEnable[0]=true
strikeEnable[1]=true
strikePlayer[0]=Player(14)
strikePlayer[1]=Player(14)
aiSleep=false
NoBuildings = true
}
public void Sleep()
{
//if(!inited){return}
aiSleep=true
}
///////////////////////////////////////////////////////////////////
// INITIALIZER
///////////////////////////////////////////////////////////////////
private void init()
{
int i
int ut
int ufl
if(inited){
return
}
RBT = InitHashtable()
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"AI_Init()")
SetArmorTable()
AINamesPool_init()
AIPaths_reset(false)
//filterPeonLocator=Filter(function FilterPeonLocator)
filterRepairTargetBuilding=Filter(function FilterRepairTargetBuilding)
TimerStart(CreateTimer(),2.,true,function MainOrderer)
TimerStart(CreateTimer(),7.,true,function RepairOrderer)
TriggerAddCondition(trgStructDmg,Condition(function OnDmgStructure))
fltEnemyUnitC = Filter(function FltEnemyUnitC)
fltConstrOfType = Filter(function FltConstrOfType)
//
strikeStack[0]=CreateForce()
strikeStack[1]=CreateForce()
strikeActivator[0]=CreateTimer()
strikeActivator[1]=CreateTimer()
strikeEnable[0]=true
strikeEnable[1]=true
strikePlayer[0]=Player(14)
strikePlayer[1]=Player(14)
//
//chaos
//(bid,attackt,armort,hp,defp,dps,spDps)
RegisterBuildingProp('h025',AT_CHAOS, AR_NONE, 570, 5, 46, 0 ,0,29) // fiend
RegisterBuildingProp('h009',AT_CHAOS, AR_HEAVY, 850, 5, 46, 30 ,0,32) // dragon
RegisterBuildingProp('h007',AT_CHAOS, AR_HEAVY, 1600, 7, 92, 10,0,40) // golem
RegisterBuildingProp('h01C',AT_MAGIC, AR_LIGHT, 450, 2, 33, 0,0,26) // succub
RegisterBuildingProp('h01I',AT_NORMAL, AR_LIGHT, 250, 3, 20, 0,0,21) // satyr
RegisterBuildingProp('h026',AT_NORMAL, AR_LIGHT, 700, 4, 56, 20,0,32) // satyr2
RegisterBuildingProp('h01D',AT_NORMAL, AR_NORMAL, 400, 5, 27, 5,0,23) // warrior
RegisterBuildingProp('h03G',AT_NORMAL, AR_NORMAL, 850, 8, 60, 15,0,32) // warrior2
//specials
registerSpecial('h01M',true,FL_AA+FL_AG+FL_AOE,350) // Eraser 'h01W','h01X'
registerSpecial('h01W',false,FL_AA+FL_AG+FL_AOE,400)
registerSpecial('h01X',false,FL_AA+FL_AG+FL_AOE,500)
registerSpecial('h01E',true,FL_AA+FL_AG,350) // SoD
registerSpecial('h01F',false,FL_AG+FL_AOE,250) // Volcano
registerSpecial('h05I',false,FL_AA+FL_AG,125) // ruin
//human
RegisterBuildingProp('h000',AT_NORMAL, AR_HEAVY, 250, 4, 20, 0,0,20 ) // footman
RegisterBuildingProp('h039',AT_NORMAL, AR_HEAVY, 575, 8, 38, 0,0,29 ) // footman2
RegisterBuildingProp('h003',AT_PIERCE, AR_NORMAL, 270, 0, 22, 0,0,22 ) // sniper
RegisterBuildingProp('h05D',AT_PIERCE, AR_NORMAL, 500, 3, 50, 20,0,31 ) // sniperg
RegisterBuildingProp('h0A1',AT_PIERCE, AR_NORMAL, 450, 1, 45, 0,0,30 ) // snipera
RegisterBuildingProp('h004',AT_SIEGE, AR_LIGHT, 280, 0, 20, 15,0,25 ) // mortires
RegisterBuildingProp('h015',AT_MAGIC, AR_NORMAL, 500, 2, 23, 0,0,27 ) // gryphon
RegisterBuildingProp('h037',AT_HERO, AR_HEAVY, 600, 6, 42, 5,0,28 ) // knight
RegisterBuildingProp('h038',AT_HERO, AR_HEAVY, 820, 9, 65, 15,0,41 ) // knight2
RegisterBuildingProp('h00K',AT_SPELLS, AR_NONE, 320, 1, 32, 25,0,30 ) // warlock
RegisterBuildingProp('h072',AT_HERO, AR_HEAVY, 1400, 12, 100, 25,0,52) // H.warrior
//specials
registerSpecial('h05G',true,0,150) // Shrine
registerSpecial('h072',true,0,140) // Warrior
registerSpecial('h001',false,FL_AOE,50) // Art
//corrupted
RegisterBuildingProp('h04S',AT_PIERCE, AR_NORMAL, 650, 7, 37, 8,0,27 ) // felhound
RegisterBuildingProp('h04V',AT_NORMAL, AR_HEAVY, 320, 4, 19, 5,0,21 ) // ent1
RegisterBuildingProp('h04W',AT_NORMAL, AR_HEAVY, 640, 5, 38, 10,0,27 ) // ent2
RegisterBuildingProp('h09Y',AT_NORMAL, AR_HEAVY, 1800, 8, 120, 15,0,52) // ent3
RegisterBuildingProp('h04L',AT_MAGIC, AR_LIGHT, 375, 2, 30, 5,0,24 ) // void
RegisterBuildingProp('h04N',AT_MAGIC, AR_LIGHT, 740, 4, 55, 10,0,34 ) // void2
RegisterBuildingProp('h04O',AT_MAGIC, AR_NORMAL, 425, 2, 27, 5,0,26 ) // nether
RegisterBuildingProp('h04M',AT_MAGIC, AR_NORMAL, 700, 4, 45, 10,0,35 ) // nether2
RegisterBuildingProp('h04Q',AT_SIEGE, AR_HEAVY, 600, 3, 45, 8,0,30 ) // siedge
RegisterBuildingProp('h04P',AT_SIEGE, AR_HEAVY, 850, 4, 60, 24,0,37 ) // siedge2
RegisterBuildingProp('h04U',AT_CHAOS, AR_NORMAL, 1000, 4, 65, 15,0,41 ) // incub
//specials
registerSpecial('h09Y',true,0,0) // mega tree
registerSpecial('h04T',true,FL_AOE,185) // Eye of Cor
registerSpecial('h04K',false,FL_AA+FL_AG,95) // Well
registerSpecial('h04R',false,FL_AG,90) // Forgotten
//orc
RegisterBuildingProp('h02K',AT_PIERCE, AR_LIGHT, 1000, 6, 24, 0,0,28) // codo
RegisterBuildingProp('h092',AT_PIERCE, AR_LIGHT, 1200, 7, 36, 0,0,33) // resist codo1
RegisterBuildingProp('h035',AT_PIERCE, AR_LIGHT, 1200, 7, 36, 5,0,33) // offenc codo2
RegisterBuildingProp('h036',AT_PIERCE, AR_LIGHT, 1200, 7, 36, 5,0,33) // def codo3
RegisterBuildingProp('h02P',AT_PIERCE, AR_NONE, 440, 2, 31, 0,0,26) // vyvern
RegisterBuildingProp('h029',AT_NORMAL, AR_HEAVY, 325, 4, 18, 0,0,20) // orc1
RegisterBuildingProp('h02U',AT_NORMAL, AR_HEAVY, 575, 6, 30, 0,0,25) // orc2
RegisterBuildingProp('h031',AT_NORMAL, AR_HEAVY, 1000, 10, 90, 10,0,37) // orc3
RegisterBuildingProp('h02H',AT_NORMAL, AR_NORMAL, 450, 3, 30, 0,0,25) // troll
RegisterBuildingProp('h05E',AT_NORMAL, AR_NORMAL, 600, 4, 38, 0,0,29) // troll2
RegisterBuildingProp('h02B',AT_MAGIC, AR_NONE, 340, 1, 28, 0,0,23) // shaman
RegisterBuildingProp('h06E',AT_MAGIC, AR_NONE, 450, 3, 45, 0,0,28) // upg shaman
RegisterBuildingProp('h02I',AT_SIEGE, AR_NORMAL, 480, 5, 45, 45,0,34) // cata
//specials
registerSpecial('h02O',true,0,250) // Statis
registerSpecial('h02R',false,0,60) // Totem
registerSpecial('h02N',false,FL_AA+FL_AG+FL_AOE,220) // Serpent
//naga
RegisterBuildingProp('h00F',AT_PIERCE, AR_HEAVY, 625, 6, 51, 10,0,27) // guardian
RegisterBuildingProp('h032',AT_PIERCE, AR_HEAVY, 1100, 9, 71, 20,0,37) // guardian2
RegisterBuildingProp('h020',AT_NORMAL, AR_NONE, 650, 4, 48, 0,0,23) // murl2
RegisterBuildingProp('h021',AT_NORMAL, AR_NONE, 1100, 6, 68, 10,0,32) // murl3
RegisterBuildingProp('h022',AT_NORMAL, AR_NONE, 1500, 8, 100, 20,0,41) // murl4
RegisterBuildingProp('h01B',AT_SIEGE, AR_HEAVY, 700, 8, 55, 0,0,29) // reptile
RegisterBuildingProp('h01Z',AT_CHAOS, AR_NONE, 750, 4, 70, 10,0,32) // siren+lobsters?
RegisterBuildingProp('h01Y',AT_MAGIC, AR_LIGHT, 450, 2, 34, 10,0,26) // serpent
RegisterBuildingProp('h00J',AT_NORMAL, AR_NORMAL, 325, 3, 28, 0,0,23) // swamp
RegisterBuildingProp('h05F',AT_CHAOS, AR_NORMAL, 1650, 9, 130, 50,0,57) // Hydra
//specials
registerSpecial('h05F',true,0,0)
registerSpecial('h00N',true,FL_AG+FL_AOE,205) // Tidal
registerSpecial('h00I',false,FL_AG+FL_AOE,160) // Pyramid
registerSpecial('h00M',false,0,95) // Oracl
registerSpecial('h00G',false,0,70) // Coral
//northern
RegisterBuildingProp('h03U',AT_PIERCE, AR_HEAVY, 325, 2, 33, 0,0,23) // igloo
RegisterBuildingProp('h03T',AT_PIERCE, AR_NORMAL, 800, 5, 46, 0,0,28) // wendigo
RegisterBuildingProp('h043',AT_PIERCE, AR_NORMAL, 1500, 7, 80, 10,0,39) // wendigo2
RegisterBuildingProp('h049',AT_NORMAL, AR_NONE, 280, 4, 20, 0,0,21) // magnotaur1
RegisterBuildingProp('h04F',AT_NORMAL, AR_NONE, 550, 5, 43, 10,0,27) // magnotaur2
RegisterBuildingProp('h03W',AT_NORMAL, AR_NONE, 1200, 8, 95, 25,0,39) // magnotaur3
RegisterBuildingProp('h03K',AT_MAGIC, AR_LIGHT, 350, 1, 27, 0,0,23) // ice troll
RegisterBuildingProp('h03J',AT_MAGIC, AR_LIGHT, 650, 3, 50, 0,0,30) // ice troll2
RegisterBuildingProp('h03I',AT_CHAOS, AR_HEAVY, 650, 4, 33, 20,0,29) // dragon
RegisterBuildingProp('h03S',AT_CHAOS, AR_NONE, 650, 4, 58, 0,0,35) // crystal
RegisterBuildingProp('h076',AT_CHAOS, AR_HEAVY, 1600, 6, 73, 30,0,55) // leg.dragon
//specials
registerSpecial('h03O',true,FL_AOE,180) // Freezer
registerSpecial('h076',true,0,0) // Dragon
registerSpecial('h048',false,0,70) // Frostlauncher
registerSpecial('h03L',false,FL_AOE,125) // G.Frostlauncher
registerSpecial('h047',false,FL_AA,100) // Mushroom
//undead
RegisterBuildingProp('h01P',AT_MAGIC, AR_LIGHT, 250, 2, 17, 0,0, 25 ) // skeleton *!spawn rate*
RegisterBuildingProp('h056',AT_HERO, AR_LIGHT, 500, 4, 33, 0,0, 30 ) // skeleton2 *
RegisterBuildingProp('h01K',AT_MAGIC, AR_NONE, 320, 1, 31, 0,0, 25) // necromancer1
RegisterBuildingProp('h04B',AT_MAGIC, AR_NONE, 550, 3, 47, 5,0, 33) // necromancer2
RegisterBuildingProp('h055',AT_MAGIC, AR_NONE, 900, 5, 75, 10,0, 53) // necromancer3
RegisterBuildingProp('h01S',AT_NORMAL, AR_LIGHT, 1200, 5, 74, 25,0, 40) // dragon
RegisterBuildingProp('h01N',AT_PIERCE, AR_HERO, 425, 3, 36, 5,0, 26) // vampire
RegisterBuildingProp('h054',AT_PIERCE, AR_HERO, 650, 4, 53, 10,0, 38) // vampire2
RegisterBuildingProp('h01L',AT_MAGIC, AR_DIVINE, 310, 2, 48, 5,0, 29) // banshee
RegisterBuildingProp('h01T',AT_SIEGE, AR_NORMAL, 1200, 8, 74, 10,0,33 ) // golem
RegisterBuildingProp('h01R',AT_CHAOS, AR_NORMAL, 265, 3, 22, 2,0, 21 ) // zombie1
RegisterBuildingProp('h04Z',AT_CHAOS, AR_NORMAL, 500, 5, 38, 7,0, 26 ) // zombie2
RegisterBuildingProp('h03M',AT_CHAOS, AR_NORMAL, 1050, 6, 67, 15,0, 36 ) // zombie3
//specials
registerSpecial('h055',true,0,0) // Necr3
registerSpecial('h01Q',true,0,350) // Decay
registerSpecial('h00A',false,0,95) // Death pit
//nelf
//(bid,attackt,armort,hp,defp,dps,spDps)
RegisterBuildingProp('h00S',AT_PIERCE, AR_LIGHT, 350, 1, 21, 0,0,22 ) // archer1
RegisterBuildingProp('h03D',AT_PIERCE, AR_LIGHT, 500, 3, 70, 20,0,32 ) // archer2
RegisterBuildingProp('h03E',AT_PIERCE, AR_LIGHT, 900, 5, 90, 60,0,52 ) // archer3
RegisterBuildingProp('h07M',AT_PIERCE, AR_NORMAL, 375, 1, 32, 0,0,25 ) // assassin
RegisterBuildingProp('h07L',AT_PIERCE, AR_NORMAL, 575, 2, 65, 0,0,31 ) // assassin2
RegisterBuildingProp('h07O',AT_MAGIC, AR_LIGHT, 425, 5, 38, 0,0,26 ) // vengeance
RegisterBuildingProp('h07N',AT_MAGIC, AR_LIGHT, 700, 8, 78, 0,0,37 ) // vengeance2
RegisterBuildingProp('h00B',AT_MAGIC, AR_LIGHT, 460, 2, 28, 0,0,28 ) // faerie
RegisterBuildingProp('h011',AT_SIEGE, AR_HEAVY, 400, 2, 32, 20,0,33 ) // ballista
RegisterBuildingProp('h088',AT_CHAOS, AR_NONE, 375, 1, 28, 5,0,24 ) // druid
RegisterBuildingProp('h07D',AT_CHAOS, AR_NONE, 550, 3, 50, 15,0,30 ) // druid2
//specials
registerSpecial('h03E',true,0,0)//amaz
registerSpecial('h07I',true,FL_AA+FL_AG+FL_AOE,280) // Starfall
registerSpecial('h07H',false,0,33) // Armor
registerSpecial('h08P',false,FL_AOE,41) // Health
//helf
RegisterBuildingProp('h08X',AT_PIERCE, AR_NONE, 320, 2, 28, 0,0,24) // archer
RegisterBuildingProp('h08Y',AT_PIERCE, AR_NONE, 550, 4, 85, 0,0,34) // archer2
RegisterBuildingProp('h06Y',AT_PIERCE, AR_HEAVY, 650, 3, 46, 5,0,30) // hawk
RegisterBuildingProp('h00T',AT_NORMAL, AR_HEAVY, 450, 7, 38, 0,0,26) // blademaster
RegisterBuildingProp('h03F',AT_NORMAL, AR_HEAVY, 760, 10, 120, 0,0,38) // blademaster2
RegisterBuildingProp('h00V',AT_MAGIC, AR_NORMAL, 525, 3, 38, 10,0,28) // bloodthister
RegisterBuildingProp('h09X',AT_SPELLS, AR_NONE, 550, 2, 48, 10,0,33) // mage *
RegisterBuildingProp('h00X',AT_CHAOS, AR_NONE, 800, 4, 65, 40,0,54) // mage2
RegisterBuildingProp('h070',AT_SIEGE, AR_NORMAL, 500, 3, 32, 30,0,32) // ballista
//specials
registerSpecial('h00X',true,0,0) // Shrine
registerSpecial('h059',true,0,240) // Shrine
registerSpecial('h00Z',false,0,65) // Hex
registerSpecial('h005',false,0,70) // Laser
//mech
RegisterBuildingProp('h05X',AT_NORMAL, AR_HEAVY, 450, 5, 33, 0,0,24 ) // tank
RegisterBuildingProp('h09I',AT_CHAOS, AR_HEAVY, 750, 8, 48, 15,0,34 ) // tank-a
RegisterBuildingProp('h06G',AT_SIEGE, AR_NORMAL, 550, 5, 30, 30,0,33 ) // tank-s
RegisterBuildingProp('h09B',AT_NORMAL, AR_HEAVY, 900, 12, 62, 0,0,34 ) // tank-h
RegisterBuildingProp('h09J',AT_NORMAL, AR_HEAVY, 650, 7, 44, 0,0,31 ) // tank-m
RegisterBuildingProp('h05T',AT_CHAOS, AR_LIGHT, 500, 4, 36, 10,0,26 ) // flamegunner
RegisterBuildingProp('h09P',AT_CHAOS, AR_LIGHT, 700, 7, 65, 15,0,33) // flamegunner2
RegisterBuildingProp('h05U',AT_PIERCE, AR_NORMAL, 1000, 9, 58, 15,0,36 ) // shreder
RegisterBuildingProp('h05M',AT_SPELLS, AR_NONE, 300, 0, 36, 30,0,25 ) // suicide goblin
RegisterBuildingProp('h06D',AT_SPELLS, AR_NONE, 400, 0, 45, 36,0,30 ) // suicide goblin rockt
RegisterBuildingProp('h09H',AT_NORMAL, AR_HEAVY, 950, 12, 76, 0,FL_AA,41 ) // tank-h AA !
RegisterBuildingProp('h05J',AT_PIERCE, AR_LIGHT, 300, 4, 28, 0,0, 23) // heli
RegisterBuildingProp('h09L',AT_PIERCE, AR_LIGHT, 625, 6, 50, 0,0, 32) // heli2
RegisterBuildingProp('h078',AT_SIEGE, AR_HEAVY, 1400, 8, 80, 15,0, 35) // heli3
RegisterBuildingProp('h05V',AT_HERO, AR_NORMAL, 550, 12, 47, 0,0, 28) // golem
RegisterBuildingProp('h097',AT_HERO, AR_DIVINE, 950, 15, 95, 5,0, 53) // golem2
//specials
registerSpecial('h097',true,0,0)
registerSpecial('h078',true,0,0)
registerSpecial('h06J',false,0,50) // Shield
registerSpecial('h05R',false,0,75) // Shield2
registerSpecial('h069',false,0,40) // Repair
//nature
RegisterBuildingProp('h002',AT_PIERCE, AR_NONE, 500, 1, 36, 0,0,23 ) // spider2
RegisterBuildingProp('h00Q',AT_PIERCE, AR_NONE, 800, 3, 75, 5,0,33 ) // spider3
RegisterBuildingProp('h00R',AT_PIERCE, AR_NONE, 1200, 6, 100, 10,0,45 ) // spider4
RegisterBuildingProp('h028',AT_SIEGE, AR_FORT, 1100, 8, 85, 5,0,40 ) // stone giant
RegisterBuildingProp('h00Y',AT_MAGIC, AR_LIGHT, 450, 1, 37, 0,0,25 ) // furbolg
RegisterBuildingProp('h012',AT_MAGIC, AR_LIGHT, 650, 3, 51, 0,0,35 ) // furbolg2
RegisterBuildingProp('h013',AT_PIERCE, AR_NORMAL, 500, 3, 37, 0,0,26 ) // dryad1
RegisterBuildingProp('h01H',AT_PIERCE, AR_NORMAL, 950, 5, 60, 5,0,37 ) // dryad2
RegisterBuildingProp('h01J',AT_CHAOS, AR_NORMAL, 1500, 4, 100, 0,0,57 ) // dryad3
RegisterBuildingProp('h027',AT_CHAOS, AR_HEAVY, 700, 5, 45, 15,0,30 ) // dragon
RegisterBuildingProp('h023',AT_NORMAL, AR_NONE, 680, 6, 48, 5,0,28 ) // bear
RegisterBuildingProp('h024',AT_NORMAL, AR_NONE, 1250, 8, 74, 0,0,41 ) // bear2
//specials
registerSpecial('h01J',true,0,0)
registerSpecial('h02D',true,FL_AA+FL_AG+FL_AOE,250) // Wisps
registerSpecial('h02C',false,0,65) // Banish
registerSpecial('h02A',false,FL_AOE,95) // Cyclone
//elemental
//(bid,attackt,armort,hp,defp,dps,spDps)
RegisterBuildingProp('h045',AT_CHAOS, AR_LIGHT, 480, 3, 38, 0,0,27) // fire
RegisterBuildingProp('h046',AT_CHAOS, AR_LIGHT, 900, 6, 65, 10,0,39) // fire2
RegisterBuildingProp('h040',AT_SIEGE, AR_NONE, 700, 5, 50, 5,0,27) // earth
RegisterBuildingProp('h041',AT_SIEGE, AR_NONE, 1350, 10, 85, 12,0,42) // earth2
RegisterBuildingProp('h03Y',AT_NORMAL, AR_NORMAL, 385, 4, 28, 0,0,23) // water2
RegisterBuildingProp('h03Z',AT_NORMAL, AR_NORMAL, 660, 7, 48, 5,0,31) // water3
RegisterBuildingProp('h042',AT_MAGIC, AR_HEAVY, 450, 3, 40, 5,0,26) // Light
RegisterBuildingProp('h044',AT_MAGIC, AR_HEAVY, 800, 9, 65, 15,0,40) // Light2
//RegisterBuildingProp('h04A',AT_PIERCE, AR_NONE, 325, 2, 30, 0,0,23) // wind
RegisterBuildingProp('h04C',AT_CHAOS, AR_NONE, 450, 1, 35, 30,0,35) // wind2
//RegisterBuildingProp('h04D',AT_CHAOS, AR_NONE, 910, 1, 55, 0,0,37) // wind3
RegisterBuildingProp('h04E',AT_CHAOS, AR_NORMAL, 950, 6, 70, 25,0,54) // master
//specials
registerSpecial('h04E',true,0,0)
registerSpecial('h063',true,0,170) // linker
registerSpecial('h060',false,0,60) // buffer
registerSpecial('h05Z',false,FL_AOE,160) //spell shrine
// Desert
//gnoll cc atkt armtp HP def dps spl fl prodt
RegisterBuildingProp('n02O', AT_NORMAL, AR_LIGHT, 320, 2, 25, 0,0,23)
//gnoll-amb
RegisterBuildingProp('n02I', AT_NORMAL, AR_LIGHT, 510, 4, 50, 0,0,32)
//2 harpy
RegisterBuildingProp('n02K', AT_PIERCE, AR_NONE, 400, 1, 33, 0,0,27)
//harpy-witch
RegisterBuildingProp('n031', AT_PIERCE, AR_NONE, 680, 3, 50, 0,0,35)
//Matriarch
RegisterBuildingProp('n033', AT_HERO, AR_NONE, 1250, 6, 70, 0,0,56)
//3 ogre
RegisterBuildingProp('n02L', AT_SIEGE, AR_HEAVY, 650, 5, 55, 5,0,27)
//ogrelord
RegisterBuildingProp('n02R', AT_SIEGE, AR_HEAVY, 1200, 9, 75, 0,0,35)
//4 Quillboar
RegisterBuildingProp('n02J', AT_PIERCE, AR_NONE, 350, 1, 27, 10,0,24)
//Razor
RegisterBuildingProp('n02N', AT_PIERCE, AR_NONE, 750, 4, 58, 15,0,32)
//5 Salamander
RegisterBuildingProp('n02M', AT_CHAOS, AR_HEAVY, 850, 6, 55, 30,0,36)
//6 Sandkin
RegisterBuildingProp('n02P', AT_MAGIC, AR_NORMAL, 600, 6, 37, 0,0,26)
// m.sandkin
RegisterBuildingProp('n036', AT_MAGIC, AR_NORMAL, 1000, 8, 65, 0,0,37)
//specials
registerSpecial('n033',true,0,0) //matr
registerSpecial('h06L',false,FL_AG,130) //qsand
registerSpecial('h06I',false,0,75) //peyote
registerSpecial('h06M',true,0,245) //Temple of Sand
inited=true
}
endlibrary
library DamageControl initializer init uses Nature
private constant trigger registrator=CreateTrigger()
public trigger execution=null
public trigger trgSpcAtk=null
define RegisterUnitOnDmg(u)=TriggerRegisterUnitEvent(DamageControl_execution,u,EVENT_UNIT_DAMAGED)
define RegisterUnitOnAtk(u)=TriggerRegisterUnitEvent(DamageControl_trgSpcAtk,u,EVENT_UNIT_ACQUIRED_TARGET)
////////////////////////////////////////////////////////////////////////////////////////////////////
// ABILITIES
////////////////////////////////////////////////////////////////////////////////////////////////////
public void FeralRage1(unit v)
{
if(GetRandomInt(0,99)<15){
unit u=CreateUnit(GetOwningPlayer(v),'e008',GetUnitX(v),GetUnitY(v),0.)
UnitAddAbility(u,'A0B7')
IssueTargetOrderById(u,852066,v)
UnitApplyTimedLife(u,'BTLF',2.)
u=CreateUnit(GetOwningPlayer(v),'e008',GetUnitX(v),GetUnitY(v),0.)
UnitAddAbility(u,'A0B5')
IssueTargetOrderById(u,852101,v)
UnitApplyTimedLife(u,'BTLF',2.)
u=null
}
}
private void FeralRage2(unit v)
{
if(GetRandomInt(0,99)<20){
unit u=CreateUnit(GetOwningPlayer(v),'e008',GetUnitX(v),GetUnitY(v),0.)
UnitAddAbility(u,'A0B8')
IssueTargetOrderById(u,852066,v)
UnitApplyTimedLife(u,'BTLF',2.)
u=CreateUnit(GetOwningPlayer(v),'e008',GetUnitX(v),GetUnitY(v),0.)
UnitAddAbility(u,'A0B6')
IssueTargetOrderById(u,852101,v)
UnitApplyTimedLife(u,'BTLF',2.)
u=null
}
}
private void AbolishMagic1(unit u)
{
if(GetRandomInt(0,99)<15){
UnitRemoveBuffsEx(u,true,false,true,false,false,false,false)
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosDone.mdl",u,"overhead"))
}
}
private void AbolishMagic2(unit u)
{
if(GetRandomInt(0,99)<20){
UnitRemoveBuffsEx(u,true,false,true,false,false,false,false)
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosDone.mdl",u,"overhead"))
}
}
private void AbolishMagic3Personal()
{
unit u=GetEnumUnit()
UnitRemoveBuffsEx(u,true,false,true,false,false,false,false)
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosDone.mdl",u,"overhead"))
u=null
}
private void AbolishMagic3(unit u, unit t)
{
filterPlayer=GetOwningPlayer(u)
if(GetRandomInt(0,99)<25){
GroupEnumUnitsInRange(pickgroup,GetUnitX(t),GetUnitY(t),100.,filterEnemyUnit)
ForGroup(pickgroup,function AbolishMagic3Personal)
}
}
private void ElectroShieldElemental(unit s, unit u)
{
int lvl=GetUnitLevel(u)
if(IsUnitType(s,UNIT_TYPE_MELEE_ATTACKER) and GetRandomInt(0,99)<=15*lvl){
unit c=CreateUnit(GetOwningPlayer(u),'e008',GetUnitX(u),GetUnitY(u),0.)
UnitAddAbility(c,'A0D5')
SetUnitAbilityLevel(c,'A0D5',lvl)
IssueTargetOrderById(c,852095,s)
UnitApplyTimedLife(c,'BTLF',2.)
c=null
}
}
private void WaterIllusion(unit u)
{
if(GetRandomInt(0,99)<20){
//unit c=CreateUnit(GetOwningPlayer(u),'e008',GetUnitX(u),GetUnitY(u),0.)
//UnitAddAbility(c,'A0CU')
//IssueTargetOrderById(c,852274,u)
//UnitApplyTimedLife(c,'BTLF',1.)
//c=null
IssueImmediateOrderById(u,852123)
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// END ABILITIES
////////////////////////////////////////////////////////////////////////////////////////////////////
//tower handling
private void OnSpcAtk()
{
unit u=GetTriggerUnit()
unit t=GetEventTargetUnit()
int ut = GetUnitTypeId(u)
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"SpcAtk:"+GetUnitName(GetEventTargetUnit())+"<<"+GetUnitName(u))
if ( ut == 'u00D' ) { //lich
SaveUnitHandle(tableIN, HT_LichTargId, GetHandleId(u), t)
}
elseif(ut == 'n02T' and not IsUnitType(u,UNIT_TYPE_STRUCTURE)) { //ambusher
if(IssueImmediateOrderById(u,852129)) {
TriggerSleepAction(.1)
IssuePointOrderById(u, 851986, GetUnitX(u)+GetRandomReal(-160.,160.),GetUnitY(u)+GetRandomReal(-160.,160.))
TriggerSleepAction(GetRandomReal(0.35,0.8))
IssueTargetOrderById(u, 851983, t)
}
}
else {
IssueTargetOrderById(u, 851983, t) //attack order
}
u=null
t=null
}
define htChkDmg='DCTm'
private void action()
{
unit s=GetEventDamageSource()
unit u=GetTriggerUnit()
int sid
if (LoadInteger(tableIN,htChkDmg,GetHandleId(u)) > Ticks){
s=null
u=null
return
}
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"SpcTakeDmg:"+GetUnitName(u)+"->"+GetUnitName(s))
if(GetWidgetLife(u)>.405 ){ //GetUnitAbilityLevel(u,'A0C5')>0
sid=GetUnitTypeId(u)
if(sid=='n029') { //bear
FeralRage1(u)
}elseif(sid=='n02B') { //elder bear
FeralRage2(u)
}elseif(GetUnitAbilityLevel(u,'A0DX')>0) { // lightning elemental
ElectroShieldElemental(GetEventDamageSource(),u)
}
SaveInteger(tableIN,htChkDmg,GetHandleId(u),Ticks+1)
}
u=null
s=null
}
public void init()
{
if(execution!=null){
TriggerClearActions(execution)
DestroyTrigger(execution)
}
execution=CreateTrigger()
TriggerAddAction(execution,function action)
if(trgSpcAtk!=null){
TriggerClearActions(trgSpcAtk)
DestroyTrigger(trgSpcAtk)
}
trgSpcAtk=CreateTrigger()
TriggerAddAction(trgSpcAtk,function OnSpcAtk)
}
endlibrary
library_once EndRoundScenario initializer init uses Income, AutoAFKControl //, PlayersAdvStats
public bool enabled=false
public trigger OnLeftCastleDies
public trigger OnRightCastleDies
public trigger OnDraw
private boolexpr saveNetrals
public int victory=0
void Victory()
{
MMD_FlagPlayer(GetEnumPlayer(), MMD_FLAG_WINNER)
CustomVictoryBJ(GetEnumPlayer(),true,true)
}
void Defeat()
{
MMD_FlagPlayer(GetEnumPlayer(), MMD_FLAG_LOSER)
CustomDefeatBJ(GetEnumPlayer(),"You were defeated!")
}
private void RemovePersonal()
{
RemoveUnit(GetEnumUnit())
}
private void HidenKillPersonal()
{
unit u=GetEnumUnit()
ShowUnit(u,false)
KillUnit(u)
RemoveUnit(u)
u=null
}
private void ItemClearPersonal()
{
RemoveItem(GetEnumItem())
}
private void FinalizeRound()
{
enabled=false
AILibrary_Sleep()
SpecialTimersControl_InternalControl(false)
AutoAFKControl_Suspend()
FogEnable(false)
PauseTimer(Functions_SpecialControls)
PauseTimer(Functions_CommonControls)
PauseTimer(Income_Timer)
PauseTimer(GameTime)
Coins_Stop(false)
DestroyFogModifier(Common_leftCastle)
DestroyFogModifier(Common_rightCastle)
TriggerClearActions(OnLeftCastleDies)
DestroyTrigger(OnLeftCastleDies)
TriggerClearActions(OnRightCastleDies)
DestroyTrigger(OnRightCastleDies)
//CinematicFadeBJ
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"The Score is |cffFF0000West|r: |cffFFCC00"+I2S(wins[0])+" |cff00FF00East|r:|cffFFCC00 "+I2S(wins[1])+"|r. Number of wins for overall victory: |cffFFCC00"+I2S(mode_rounds)+"|r")
Income_EndOfRound()
NatureWispControl_Reset()
///
TriggerSleepAction(4.)
CinematicFadeBJ(1,2,"ReplaceableTextures\\CameraMasks\\Black_mask.blp",0,0,0,6.)
TriggerSleepAction(2.)
//FogMaskEnable(true)
IsMapAllVisible=false
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"!")
CountBuildingDeaths=false
int i=0
int j=0
unit u
DisableTrigger(gg_trg_UnitDeathReleaser)
loop
loop
GroupEnumUnitsOfPlayer(pickgroup,Player(j),saveNetrals)
loop
u=FirstOfGroup(pickgroup)
exitwhen (u==null)
//ShowUnit(u,false)
RemoveUnit(u)
GroupRemoveUnit(pickgroup,u)
endloop
i++
TriggerSleepAction(0.02)
exitwhen i >=4
endloop
chanceToCloneUnit[j]=0
chanceToReviveUnit[j]=0
chanceToGetElSpirit[j]=0
j++
exitwhen(j>12)
endloop
EnableTrigger(gg_trg_UnitDeathReleaser)
CountBuildingDeaths=true
FlushChildHashtable(tableIN,htKeyIncome)
FlushChildHashtable(tableIN,htKeyCagTmID)
FlushChildHashtable(tableIN,htKeyTrgID)
FlushChildHashtable(tableIN,htSyncUnitKey)
FlushChildHashtable(tableIN,htKeyUnitBnt)
UnitMostKills = 0
//
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"HT flushed")
EnumItemsInRect(ST_GLOBAL_MAP_RECT,null,function ItemClearPersonal)
if(victory>0){
TriggerSleepAction(11.)
if(victory==2){
ForForce(leftPlayers,function Victory)
ForForce(rightPlayers,function Defeat)
}else{
ForForce(rightPlayers,function Victory)
ForForce(leftPlayers,function Defeat)
}
}else{
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,10.,"Preparing for new round...")
TriggerSleepAction(7.)
TriggerExecute(Common_Launcher)
}
}
private bool SaveNetrals()
{
unit u=GetFilterUnit()
bool res=GetPlayerId(GetOwningPlayer(u))<=12 and GetUnitAbilityLevel(u,'A02E')<1
u=null
return res
}
public void TrActOnLeft()
{
if(not enabled){return}
wins[1]++
SetMBValue(5,2,I2S(wins[1]))
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cff00FF00Eastern Forces|r have won the round!")
if(wins[1]>=mode_rounds){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffFFFF00Congratulations! |cff00FF00Eastern Forces|r|cffFFFF00 have won the match! Game ends in one minute.|r")
victory=1
IsGameEnding=true
WriteLog()
//PlayersAdvStats_OnRoundEnd(-1,false)
//PlayersAdvStats_OnGameEnd(false)
}else{
//PlayersAdvStats_OnRoundEnd(-1,true)
}
FinalizeRound()
}
public void TrActOnRight()
{
if(not enabled){return}
wins[0]++
SetMBValue(5,1,I2S(wins[0]))
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffFF0000Western Forces|r have won the round!")
if(wins[0]>=mode_rounds){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffFFFF00Congratulations! |cffFF0000Western Forces|r|cffFFFF00 have won the match! Game ends in one minute.|r")
victory=2
IsGameEnding=true
WriteLog()
//PlayersAdvStats_OnRoundEnd(1,false)
//PlayersAdvStats_OnGameEnd(true)
}else{
//PlayersAdvStats_OnRoundEnd(1,true)
}
FinalizeRound()
}
private void TrActOnDraw()
{
if(not enabled){return}
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffFFAC00All players have voted for a draw, round will restart!|r")
//PlayersAdvStats_OnRoundEnd(0,true)
FinalizeRound()
}
public void init()
{
saveNetrals=Filter(function SaveNetrals)
OnDraw=CreateTrigger()
TriggerAddAction(OnDraw,function TrActOnDraw)
}
endlibrary
void SimplePlayerPeonRemove(int pid)
{
unit u
GroupEnumUnitsOfPlayer(pickgroup,Player(pid),filterOwnedPeon)
u=FirstOfGroup(pickgroup)
if(u==null){return}
if(GetUnitAbilityLevel(u,'A005')>0){
mpRsCount[forceId[pid]]--
if(mpRsCount[forceId[pid]]==0){
SetMBValue(1,forceId[pid]+1,"|cffFF00000|r")
}else{
SetMBValue(1,forceId[pid]+1,I2S(mpRsCount[forceId[pid]]))
}
}
RemoveUnit(u)
u=null
}
force tempExForceOnPlayerLeft
void SendUnitToPlayerPersonal()
{
unit u=GetEnumUnit()
if(IsUnitType(u,UNIT_TYPE_STRUCTURE)){
SetUnitOwner(u,ForcePickRandomPlayer(tempExForceOnPlayerLeft),true)
int tobuild=Data_GetUnitTypeByB(u)
if(tobuild>0){
IssueImmediateOrderById(u,tobuild)
IssueImmediateOrderById(u,tobuild)
}
tobuild=GetPlayerId(GetOwningPlayer(u))
Income_UpIncome(tobuild,u)
if(SgivesLumber[GetUnitPointValue(u)]<0){
statisticSpecials[tobuild]++
}
//}
}else{
SetUnitOwner(u,ForcePickRandomPlayer(tempExForceOnPlayerLeft),true)
AttackCreepOrderCommon(u)
}
u=null
}
void OnBalance0Enum()
{
player p=GetEnumPlayer()
int pid=GetPlayerId(p)
int i=CountPlayersInForceBJ(tempExForceOnPlayerLeft)
int g=GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)/i
int l=GetPlayerState(p,PLAYER_STATE_RESOURCE_LUMBER)/i
string s="You received |cffFFFF00"+I2S(g)+"|r gold and |cffFFFF00"+I2S(l)+"|r lumber from "+GetColoredName(pid)
ReleaseStatisticByPid(pid)
SimplePlayerPeonRemove(pid)
StartPosition_ReleaseRespawn(startPosition[pid])
ForceAddPlayer(quotaPlayers,p)
GroupEnumUnitsOfPlayer(pickgroup,p,null)
ForGroup(pickgroup,function SendUnitToPlayerPersonal)
i=0
loop
p=Player(i)
if(IsPlayerInForce(p,tempExForceOnPlayerLeft)){
AdjustPlayerStateBJ(g,p,PLAYER_STATE_RESOURCE_GOLD)
AdjustPlayerStateBJ(l,p,PLAYER_STATE_RESOURCE_LUMBER)
DisplayTextToPlayer(p,0.,0.,s)
}
i++
exitwhen i>11
endloop
}
void OnBalance0(int pid)
{
player p=Player(pid)
ForceRemovePlayer(tempExForceOnPlayerLeft,p)
ForceRemoveForce(tempExForceOnPlayerLeft,relayedForces[pid])
ForceAddPlayer(relayedForces[pid],p)
ForForce(relayedForces[pid],function OnBalance0Enum)
DestroyForce(relayedForces[pid])
relayedForces[pid]=null
}
void OnBalance1(int pid)
{
string resourses=GetLocalizedString("TEAM_RESOURCES")+":"
int i=0
unit u
player p=Player(pid)
force relayedLefted=relayedForces[pid]
ForceAddPlayer(relayedLefted,p)
relayedForces[pid]=null
loop
if(IsPlayerInForce(Player(i),tempExForceOnPlayerLeft) and relayedForces[i]!=null){
p=FirstOfForce(relayedLefted)
exitwhen p==null
ForceRemovePlayer(relayedLefted,p)
ForceAddPlayer(relayedForces[i],p)
SetPlayerName(p,names[i])
Main_UpdatePlayerName(GetPlayerId(p))
GroupEnumUnitsOfPlayer(pickgroup,p,filterOwnedPeon)
u=FirstOfGroup(pickgroup)
if(u!=null and GetUnitAbilityLevel(u,'A0A5')<=0){
UnitAddAbility(u,'A0A5')
}
Multiboard_AddDependedPlayersToPlayer(i,resourses)
}
//DisplayTextToForce(bj_FORCE_ALL_PLAYERS,I2S(i))
i++
if(i>11){i=0}
//exitwhen false
endloop
//restructureAlliesRequered=true
RestructAlliances()
Multiboard_ReShowAllMulti()
//Multiboard_init()
u=null
}
void Trig_OnPlayerLeft_ActionsExecuter(player p) {
int pid=GetPlayerId(p)
if(IsGameEnding){return}
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(pid)+" |cffCA0000has left the game!|r")
DrawControl_PlayerDraw(pid)
if(AILibrary_isPlayerAFK[pid]){ AILibrary_SwitchPlayerAFK(pid) }
if(mode_autobalance==0){
MMD_UpdateValueInt("Loses", p, MMD_OP_ADD, 1)
MMD_FlagPlayer(p, MMD_FLAG_LEAVER)
if(IsPlayerInForce(p,leftPlayers)){
if(CalculateLeftPlayers()<=0){
EndRoundScenario_victory=1
IsGameEnding=true
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,60.,"All players of |cffFF0000Western Forces|r left. |cff00FF00Eastern Forces|r have won!")
ForForce(leftPlayers,function Defeat)
ForForce(rightPlayers,function Victory)
return
}
}elseif(IsPlayerInForce(p,rightPlayers)){
MMD_UpdateValueInt("Loses", p, MMD_OP_ADD, 1)
MMD_FlagPlayer(p, MMD_FLAG_LEAVER)
if(CalculateRightPlayers()<=0){
EndRoundScenario_victory=2
IsGameEnding=true
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,60.,"All players of |cff00FF00Eastern Forces|r left. |cffFF0000Western Forces|r have won!")
ForForce(leftPlayers,function Victory)
ForForce(rightPlayers,function Defeat)
return
}
}else{return}
OnBalance0(pid)
}elseif(mode_autobalance==1){
OnBalance1(pid)
}else{
AILibrary_StartAI(pid)
}
}
debug void TestEventPlayerLeft() {
debug Trig_OnPlayerLeft_ActionsExecuter(Player(6))
debug }
function Trig_OnPlayerLeft_Actions takes nothing returns nothing
Trig_OnPlayerLeft_ActionsExecuter(GetTriggerPlayer())
endfunction
//===========================================================================
function InitTrig_OnPlayerLeft takes nothing returns nothing
set gg_trg_OnPlayerLeft = CreateTrigger( )
call TriggerRegisterPlayerEventLeave( gg_trg_OnPlayerLeft, Player(0) )
call TriggerRegisterPlayerEventLeave( gg_trg_OnPlayerLeft, Player(1) )
call TriggerRegisterPlayerEventLeave( gg_trg_OnPlayerLeft, Player(2) )
call TriggerRegisterPlayerEventLeave( gg_trg_OnPlayerLeft, Player(3) )
call TriggerRegisterPlayerEventLeave( gg_trg_OnPlayerLeft, Player(4) )
call TriggerRegisterPlayerEventLeave( gg_trg_OnPlayerLeft, Player(5) )
call TriggerRegisterPlayerEventLeave( gg_trg_OnPlayerLeft, Player(6) )
call TriggerRegisterPlayerEventLeave( gg_trg_OnPlayerLeft, Player(7) )
call TriggerRegisterPlayerEventLeave( gg_trg_OnPlayerLeft, Player(8) )
call TriggerRegisterPlayerEventLeave( gg_trg_OnPlayerLeft, Player(9) )
call TriggerRegisterPlayerEventLeave( gg_trg_OnPlayerLeft, Player(10) )
call TriggerRegisterPlayerEventLeave( gg_trg_OnPlayerLeft, Player(11) )
call TriggerAddAction( gg_trg_OnPlayerLeft, function Trig_OnPlayerLeft_Actions )
debug trigger t=CreateTrigger()
debug TriggerAddAction(t,function TestEventPlayerLeft)
debug TriggerRegisterPlayerChatEvent(t,Player(0),"kick",true)
endfunction
void MessageCoins(int pid)
{
Coins_lastPicker[forceId[pid]+4]++
SetMBValue(2,forceId[pid]+1,I2S(Coins_lastPicker[forceId[pid]+4]))
if(Coins_lastPicker[forceId[pid]]==pid){
Coins_lastPicker[forceId[pid]+2]++
if(Coins_lastPicker[forceId[pid]+2]==3){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(pid)+"|cffFFFF80 just collected |cffFFFF003|cffFFFF80 coins in a row for the "+forceName[forceId[pid]]+"|cffFFFF00! Very nice!")
}elseif(Coins_lastPicker[forceId[pid]+2]==5){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(pid)+"|cffFFFF80 just collected|cffFFFF00 5|cffFFFF80 coins in a row for the "+forceName[forceId[pid]]+"|cffFFFF00! Impressive!")
}elseif(Coins_lastPicker[forceId[pid]+2]==10){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(pid)+"|cffFFFF80 just collected|cffFFFF00 10|cffFFFF80 coins in a row for the "+forceName[forceId[pid]]+"|cffFFFF00! Sick!")
}
}else{
Coins_lastPicker[forceId[pid]]=pid
Coins_lastPicker[forceId[pid]+2]=1
}
}
int NItemsOfType(unit whichUnit, integer itemId){
integer index = 0
integer count = 0
loop
if (GetItemTypeId(UnitItemInSlot(whichUnit, index)) == itemId) {
count++
}
index++
exitwhen index >= 5
endloop
//DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetUnitName(whichUnit)+" has "+I2S(count)+" "+I2S(itemId))
return count
}
void ReplaceItemsOfType(unit whichUnit, integer itemId,integer itemId2, integer NewItemId){
integer index = 0
integer count = 0
integer rc = 0
integer iid
//DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetUnitName(whichUnit)+" check "+I2S(itemId)+" "+I2S(itemId2))
loop
iid = GetItemTypeId(UnitItemInSlot(whichUnit, index))
if ( iid == itemId or iid == itemId2) {
RemoveItem(UnitRemoveItemFromSlot(whichUnit,index))
if(rc==0) { UnitAddItemById(whichUnit,NewItemId) }
rc++
}
index++
exitwhen index >= 6
endloop
}
function Trig_OnGetItem_Actions takes nothing returns nothing
unit u=GetTriggerUnit()
player p=GetOwningPlayer(u)
item it=GetManipulatedItem()
int tid=GetItemTypeId(it)
if(tid=='I004'){
RemoveItem(it)
if(mode_la){
pGoldItems[GetPlayerId(p)]+=1500
AdjustPlayerStateBJ(1,p,PLAYER_STATE_RESOURCE_FOOD_CAP)
}else{
AdjustPlayerStateBJ(1500,p,PLAYER_STATE_RESOURCE_GOLD)
DisplayTextToPlayer(p,0.,0.,"|cffFF0000You can't increase your Legendaries limit! No Legendaries is activated!|r")
}
}elseif(tid=='I008'){
pGoldItems[GetPlayerId(p)]+=600
u=CreateUnitAtLoc(p,'e008',dummyAreaCenter,0.)
UnitAddAbility(u,'A06D')
UnitApplyTimedLife(u,'BTLF',29.)
}elseif(tid=='I007'){
pGoldItems[GetPlayerId(p)]+=1400
u=CreateUnitAtLoc(p,'e008',dummyAreaCenter,0.)
UnitAddAbility(u,'A06C')
UnitApplyTimedLife(u,'BTLF',29.)
}elseif(tid=='I001'){
pGoldItems[GetPlayerId(p)]+=150
if(NItemsOfType(u,'I001')==2) {
ReplaceItemsOfType(u,'I001','I001','I031')
if(NItemsOfType(u,'I031')==2) { ReplaceItemsOfType(u,'I031','I031','I032') }
}
} elseif(tid=='I002'){ //dev.strike
pGoldItems[GetPlayerId(p)]+=1750
if(GetUnitAbilityLevel(u,'A005')<=0){
UnitAddAbility(u,'A005')
UnitAddAbility(u,'A06E')
mpRsCount[forceId[GetPlayerId(GetOwningPlayer(u))]]++
}
}elseif(tid=='I003'){ //+dmg
pGoldItems[GetPlayerId(p)]+=650
if(NItemsOfType(u,'I003')>=2) { ReplaceItemsOfType(u,'I003','I003','I013') }
elseif(NItemsOfType(u,'I013')==1) { ReplaceItemsOfType(u,'I013','I003','I014') }
}elseif(tid=='I005'){
pGoldItems[GetPlayerId(p)]+=150
}elseif(tid=='I00A'){
pGoldItems[GetPlayerId(p)]+=600
}elseif(tid=='I009'){
pGoldItems[GetPlayerId(p)]+=500
}elseif(tid=='I006'){
pGoldItems[GetPlayerId(p)]+=550
}elseif(tid=='I000'){
Coins_OnCoin(p)
RemoveItem(it)
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Transmute\\PileofGold.mdl",u,"origin"))
MessageCoins(GetPlayerId(p))
}
it=null
u=null
endfunction
//===========================================================================
function InitTrig_OnItemBuy takes nothing returns nothing
gg_trg_OnItemBuy=CreateTrigger()
TriggerAddAction(gg_trg_OnItemBuy,function Trig_OnGetItem_Actions)
TriggerRegisterAnyUnitEventBJ(gg_trg_OnItemBuy,EVENT_PLAYER_UNIT_PICKUP_ITEM)
endfunction
function OnUnitLeaveR_Conditions takes nothing returns boolean
unit u=GetTriggerUnit()
if(IsUnitType(u,UNIT_TYPE_PEON)){
player p=GetOwningPlayer(u)
PingMinimapForPlayer(p,GetUnitX(u),GetUnitY(u),1.)
SetUnitPositionLoc(u,startPosition[GetPlayerId(p)])
DisplayTextToPlayer(p,0.,0.,"|cffFF0000Your worker may not leave your castle!|r")
}
if(mode_cc){
GroupRemoveUnit(gr_cc,u) //caging
}
u=null
return false
endfunction
//===========================================================================
function InitTrig_OnUnitLeaveReg takes nothing returns nothing
set gg_trg_OnUnitLeaveReg = CreateTrigger( )
call TriggerRegisterLeaveRectSimple( gg_trg_OnUnitLeaveReg, gg_rct_LeftPlayers )
call TriggerRegisterLeaveRectSimple( gg_trg_OnUnitLeaveReg, gg_rct_RightPlayers )
call TriggerAddCondition( gg_trg_OnUnitLeaveReg, Condition( function OnUnitLeaveR_Conditions ) )
endfunction
library TreeDeath// initializer init
private constant trigger tr = CreateTrigger()
private bool inited=false
private void revive()
{
destructable d = GetTriggerDestructable()
timer t = CreateTimer()
TimerStart(t,30.,false,null)
loop
TriggerSleepAction(1.)
exitwhen TimerGetRemaining(t)<.5
endloop
PauseTimer(t)
DestroyTimer(t)
t=null
DestructableRestoreLife(d,GetDestructableMaxLife(d),true)
d=null
}
private void registration()
{
TriggerRegisterDeathEvent(tr,GetEnumDestructable())
}
private bool filter()
{
destructable d = GetFilterDestructable()
int t = GetDestructableTypeId(d)
bool res = t=='ATtc' or t=='ATtr' or t=='B001' or t=='B000' or t=='ITtw' or t=='ITtc'
d=null
return res
}
public void init()
{
boolexpr f
if(inited){return}
inited=true
f=Filter(function filter)
EnumDestructablesInRect(bj_mapInitialPlayableArea,f,function registration)
DestroyBoolExpr(f)
f=null
TriggerAddAction(tr,function revive)
}
endlibrary
function Trig_UnitConstructControl_Actions takes nothing returns nothing
unit u=GetTriggerUnit()
player p=GetOwningPlayer(u)
int tobuild=GetPlayerId(p)
int uid=GetUnitPointValue(u)
int tor
//Data_KillJoinedUnits(u)
Data_ExecuteAttaching(u)
pGoldBuildings[tobuild]+=BuildingPrice[uid]
if(SgivesLumber[uid]>0) {
if(SArtilleryProduction[uid]){
PrintAndAddLumber(u,(BuildingPrice[uid]*3)/4)
}else{
PrintAndAddLumber(u,BuildingPrice[uid])
}
}else{
statisticSpecials[tobuild]++
if(SgivesLumber[uid]==0) {
DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"Unregistered special:"+GetUnitName(u))
}
}
Income_AddIncome(tobuild,u)
//GroupEnumUnitsOfPlayer(pickgroup,p,filterOwnedPeon)
//ForGroup(pickgroup,function EnumResetAnimation)
tor=Data_GetUnitTypeByB(u) //train order
if(tor!=0){
AILibrary_RegConstructed(GetUnitTypeId(u),tobuild)
if(gameAutoTrain[GetPlayerId(p)]){
IssueImmediateOrderById(u,tor)
IssueImmediateOrderById(u,tor)
}
if(GetUnitTypeId(u)=='h056'){//autocast
IssueImmediateOrderById(u,852602)
TriggerSleepAction(0.5)
IssueTargetOrderById(u,852601,GroupPickRandomUnit(flowers))
}
//UnitSmartBlocker_ResetBuildingSync(u,p)
}else{
uid=GetUnitTypeId(u)
if(uid=='h001'){
Human_CorrectArtillery(u)
GroupAddUnit(Human_Artillery,u)
}elseif(uid=='h05G'){
Human_InvokeShrineActions(u)
}elseif(uid=='h059'){
HighElf_InvokeShrineActions(p)
}elseif(uid=='h02D'){ // natures wake upper
NatureWispControl_StartCalling()
}elseif(uid=='h00G'){//coral
UnitAddAbility(u,'A008') //bldngs
//UnitAddAbility(u,'A007')
}elseif(uid=='h061'){ // elemental tower
Elementals_acceptTower(u)
}elseif(uid=='h056' or uid=='h03L' or uid=='h01W' or uid=='h01X' or uid=='h05R'){//autocast
IssueImmediateOrderById(u,852602)
TriggerSleepAction(0.5)
IssueTargetOrderById(u,852601,GroupPickRandomUnit(flowers))
}elseif(uid=='h09T'){//plant
UnitAddAbility(u,'A09S')
UnitAddAbility(u,'A09P')
UnitAddAbility(u,'A09V')
GroupAddUnit(PowerPlant,u)
}elseif(uid=='h01O'){//turret
UnitAddAbility(u,'A01V')
}elseif(uid=='h008'){
uid=GetPlayerId(p)
GoldBoxM[uid]=GoldBoxM[uid]+0.24/GoldBoxM[uid]
}
}
u=null
p=null
endfunction
//===========================================================================
function InitTrig_UnitConstructControl takes nothing returns nothing
set gg_trg_UnitConstructControl = CreateTrigger( )
TriggerRegisterAnyUnitEventBJ( gg_trg_UnitConstructControl, EVENT_PLAYER_UNIT_CONSTRUCT_FINISH )
TriggerRegisterAnyUnitEventBJ( gg_trg_UnitConstructControl, EVENT_PLAYER_UNIT_UPGRADE_FINISH )
call TriggerAddAction( gg_trg_UnitConstructControl, function Trig_UnitConstructControl_Actions )
endfunction
function Trig_ConstructInvokeBuild_Actions takes nothing returns nothing
unit u=GetTriggerUnit()
Data_KillJoinedUnits(u)
u=null
endfunction
//===========================================================================
function InitTrig_ConstructInvokeUpgrade takes nothing returns nothing
set gg_trg_ConstructInvokeUpgrade = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_ConstructInvokeUpgrade, EVENT_PLAYER_UNIT_UPGRADE_START )
call TriggerAddAction( gg_trg_ConstructInvokeUpgrade, function Trig_ConstructInvokeBuild_Actions )
endfunction
function Trig_ConstructInvokeStopUpg_Actions takes nothing returns nothing
Data_ExecuteAttaching(GetTriggerUnit())
endfunction
//===========================================================================
function InitTrig_ConstructInvokeStopUpg takes nothing returns nothing
set gg_trg_ConstructInvokeStopUpg = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_ConstructInvokeStopUpg, EVENT_PLAYER_UNIT_UPGRADE_CANCEL )
call TriggerAddAction( gg_trg_ConstructInvokeStopUpg, function Trig_ConstructInvokeStopUpg_Actions )
endfunction
// FIX http://castle-fight.net.ru/forum/viewtopic.php?f=40&t=474
library SmartEventUnitAttacked initializer init uses AttackOrders
private constant trigger t = CreateTrigger()
private void action() {
unit source = GetAttacker()
unit target
if(GetUnitAbilityLevel(source,'A0EZ')>0) { // common variant // warlock
target=GetTriggerUnit()
UnitRemoveAbility(source,'A0EZ')
TriggerSleepAction(.0)
if(not IssueTargetOrderById(source,852601,target)){
AttackCreepOrder(source)
}
target=null
}
source=null
}
private void init() {
TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ATTACKED)
TriggerAddAction(t, function action)
}
public void SetMode(bool state) {
if(state){
EnableTrigger(t)
}else{
DisableTrigger(t)
}
}
endlibrary
function Trig_UnitSimpleConstruct_Actions takes nothing returns bool
unit u=GetTriggerUnit()
if(Data_GetUnitTypeByB(u)>0){
int pid=GetPlayerId(GetOwningPlayer(u))
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"OnConsrtuct: "+GetUnitName(Common_workers[pid]))
SetUnitAnimation(Common_workers[pid],"stand")
//IssueImmediateOrderById(,order_holdposition)
statisticBuildings[pid]++
}
u=null
return false
endfunction
//===========================================================================
function InitTrig_UnitSimpleConstruct takes nothing returns nothing
set gg_trg_UnitSimpleConstruct = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_UnitSimpleConstruct, EVENT_PLAYER_UNIT_CONSTRUCT_FINISH )
call TriggerAddCondition( gg_trg_UnitSimpleConstruct, Condition(function Trig_UnitSimpleConstruct_Actions))
endfunction
bool CountBuildingDeaths=true
bool VampControl(unit k, unit d)
{
return((GetUnitTypeId(k)=='h01U')or(GetUnitTypeId(k)=='h05H'))and(not IsUnitType(d,UNIT_TYPE_UNDEAD))and(not IsUnitType(d,UNIT_TYPE_MECHANICAL))and(GetUnitAbilityLevel(d,'A07G')<=0)
}
boolexpr filterELHEAL
bool FilterELHEAL()
{
unit u=GetFilterUnit()
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,I2S(bj_forLoopAIndex))
if(GetWidgetLife(u)>.405 and IsUnitAlly(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER)){
if(GetUnitTypeId(u)==bj_forLoopAIndex){
SetWidgetLife(u,GetWidgetLife(u)+bj_forLoopAIndexEnd)
}else{
SetWidgetLife(u,GetWidgetLife(u)+.30*bj_forLoopAIndexEnd)
}
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Heal\\HealTarget.mdl",u,"overhead"))
}
u=null
return false
}
function Trig_UnitDeathReleaser_Actions takes nothing returns nothing
unit u=GetDyingUnit()
unit k=GetKillingUnit()
int t,ut
int fid
//stats
if(IsUnitType(u,UNIT_TYPE_SAPPER)){
if(k!=null){
fid = GetUnitTypeId(k)
t = LoadInteger(tableIN,htKeyUnitBnt,fid) + 1
SaveInteger(tableIN,htKeyUnitBnt,fid,t) //kills by units
if(t>UnitMostKills){
UnitMostKills = t
UnitMostKillsId = fid
}
if(IsUnitType(k,UNIT_TYPE_STRUCTURE)==false){
t=GetPlayerId(GetOwningPlayer(k))
statisticKills[t]++
if(GetUnitTypeId(u)=='e00A'){ //vengeance
UnitDamageTarget(u,k,350.,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
}
t=GetUnitTypeId(k)
if(t=='n00V' or t=='n01O'){ //troll
IssueImmediateOrderById(k,852100)
AttackCreepOrder(k)
}elseif(t=='e00B'){//vengeance1
SetUnitLifePercentBJ(k,GetUnitLifePercent(k)+15.)
}elseif(t=='e00A'){//vengeance2
SetUnitLifePercentBJ(k,GetUnitLifePercent(k)+20.)
}elseif(t=='h01U' and GetUnitAbilityLevel(u,'A08H')<=0 and (IsUnitType(u,UNIT_TYPE_MECHANICAL)==false) and (IsUnitType(u,UNIT_TYPE_UNDEAD)==false)){//vamp1
Undead_CallVampire(k,u,'h01V', 25.0)
u=null
}elseif(t=='h05H' and GetUnitAbilityLevel(u,'A08H')<=0 and (IsUnitType(u,UNIT_TYPE_MECHANICAL)==false) and (IsUnitType(u,UNIT_TYPE_UNDEAD)==false)){//vamp2
Undead_CallVampire(k,u,'h01U', 40.0)
u=null
}elseif(GetUnitAbilityLevel(k,'A07M')>=1){
SpecialAttackOrder(k)
}
}
t=chanceToReviveUnit[forceId[GetPlayerId(GetOwningPlayer(u))]]
if(t>0 and GetRandomInt(0,99)<t){
if(u!=null and GetWidgetLife(u)<.405 and GetUnitAbilityLevel(u,'A07G')<=0 and GetUnitAbilityLevel(u,'A07H')<=0 and not IsUnitType(u,UNIT_TYPE_SUMMONED) and GetUnitAbilityLevel(u,'A0GS')<=0 and not IsUnitType(u,UNIT_TYPE_MECHANICAL)){
//DisplayTextToPlayer(GetLocalPlayer(),0.,0., "Reviving")
k=CreateUnit(GetOwningPlayer(u),GetUnitTypeId(u),GetUnitX(u),GetUnitY(u),0.)
UnitAddAbility(k,'A0GS')
ShowUnit(k,false)
RemoveUnit(u)
u=null
TriggerSleepAction(GetRandomReal(0.3,0.6))
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIam\\AIamTarget.mdl",k,"origin"))
SetUnitState(k,UNIT_STATE_MANA,1)
ShowUnit(k,true)
if(GetUnitAbilityLevel(k,'A07M')>=1){
GroupAddUnit(SpecialUnitsGroup,k)
}
//AttackCreepOrder()
//DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Resurrect\\ResurrectCaster.mdl",GetUnitX(u),GetUnitY(u)))
}
}
}
}elseif(IsUnitType(u,UNIT_TYPE_STRUCTURE)){
Data_KillJoinedUnits(u)
t=GetPlayerId(GetOwningPlayer(u))
Income_DecIncome(t,u)
ut=GetUnitTypeId(u)
fid = forceId[t]
AILibrary_StructureDied(ut,fid)
if(ut=='h05G'){
Human_OnShrineDeath(u)
}elseif(ut=='h059'){
HighElf_OnShrineDeath(u)
}elseif(ut=='h063'){
Elementals_OnShrineDeath(u)
}elseif(ut=='h068' or ut=='h06A'){ //castle gate
Common_OnGateDeath(fid)
}
elseif(ut=='h008'){
GoldBoxM[t]=GoldBoxM[t]-0.24/GoldBoxM[t]
}
FlushChildHashtable(tableJU,GetHandleId(u)) //attachments?
GroupRemoveUnit(Human_Artillery,u) //not necessary
GroupRemoveUnit(PowerPlant,u)
u=GetKillingUnit()
if(u!=null and CountBuildingDeaths){
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,I2S(t) + " destroyed!")
mpDestrCount[fid]++
if(t<7) {t=2} else {t=1}
SetMBValue(3,t,I2S(mpDestrCount[fid]))
}
}
k=null
u=null
endfunction
//===========================================================================
function InitTrig_UnitDeathReleaser takes nothing returns nothing
set gg_trg_UnitDeathReleaser = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_UnitDeathReleaser, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddAction( gg_trg_UnitDeathReleaser, function Trig_UnitDeathReleaser_Actions )
filterELHEAL=Filter(function FilterELHEAL)
endfunction
library UnitSmartBlocker uses Functions, Human
private trigger t=null
private int array clicks
public int array lastMinute // AFK detection
public void ResetBuildingSync(unit u, player p) {
unit su = LoadUnitHandle(tableIN,htSyncUnitKey,GetHandleId(u))
group sg
if(su!=null) { //remove from the sync group
sg = LoadGroupHandle(tableIN,htSyncGrKey,GetHandleId(su))
if(sg!=null) {
GroupRemoveUnit(sg,u)
SaveUnitHandle(tableIN,htSyncUnitKey,GetHandleId(u),null)
DisplayTextToPlayer(p,0.,0.,"|cffA0A0A0"+GetUnitName(u)+" is no longer synchronised!|r")
sg=null
}
su=null
}
}
public void CheckSyncBuildings(unit u,unit tu) {
int i
int j
unit z
group sg
player p
if(u==tu) {return }
p = GetOwningPlayer(u)
ResetBuildingSync(u,p)
if(tu==null) {return}
i = GetUnitPointValue(u)
j = GetUnitPointValue(tu)
if(trainOrder[i]!=0 and trainOrder[j]!=0) { //both can train something
i=GetUnitBuildTime(trainOrder[i])
j=GetUnitBuildTime(trainOrder[j])
//if(i==j) {return}
if(i>j) {z=u;u=tu;tu=z;z=null} //sync faster 2 slower
sg = LoadGroupHandle(tableIN,htSyncGrKey,GetHandleId(tu))
if(sg==null) {sg=CreateGroup(); SaveGroupHandle(tableIN,htSyncGrKey,GetHandleId(tu),sg) }
GroupAddUnit(sg,u)
SaveUnitHandle(tableIN,htSyncUnitKey,GetHandleId(u),tu)
DisplayTextToPlayer(p,0.,0.,"|cffA0C0A0"+GetUnitName(u)+" is synced with "+GetUnitName(tu)+"|r")
sg=null
}
}
private bool OnSmartA()
{
unit u=GetTriggerUnit()
int oid
if(u!=null)
{
oid = GetIssuedOrderId()
if(GetUnitTypeId(u)=='h001' and oid==0){
Human_CorrectArtillery(u)
}
elseif(oid==851971){ //order_smart
lastMinute[GetPlayerId(GetOwningPlayer(u))]=GameTimeMinutes //afk detection?
if(IsUnitType(u,UNIT_TYPE_SAPPER)){
AttackCreepOrderCommon(u)
}
}
else
{
//DisplayTextToPlayer(Player(0),0.,0.,"|cffA0C0A0"+GetUnitName(u)+" :: "+OrderId2String(oid)+" * " + I2S(oid) + "|r")
}
u=null
}
//elseif(GetIssuedOrderId()==order_setrally) { //SYNC HELPER
// CheckSyncBuildings(u,GetOrderTargetUnit())
//}
return false
}
private bool OnStartTrain(){
unit u=GetTriggerUnit()
unit b
real r
b = LoadUnitHandle(tableJU,GetHandleId(u),GetUnitUserData(u)-1)
//DisplayTextToPlayer(Player(0),0.,0.,GetUnitName(b)+" started training! "+I2S(GetHandleId(b))+" / "+I2S(GetUnitUserData(u)))
if(b!=null){
r = 10.1/(I2R(BuildingFullPrice[GetUnitPointValue(u)])*0.05 + 15.1)
//DisplayTextToPlayer(Player(0),0.,0.,GetUnitName(u)+" ts="+R2S(r))
ShowUnit(b,true)
UnitRemoveAbility(b,'Aloc')
UnitAddAbility(b,'Aloc')
SetUnitTimeScale(b,r)
SetUnitAnimation(b,"stand")
SetUnitVertexColor(b,240,200,50,255)
b=null
}
u = null
return false
}
public void Start()
{
if(t!=null){return}
t=CreateTrigger()
TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER)
TriggerAddCondition(t,Condition(function OnSmartA))
gg_trg_OrderNoTarg=CreateTrigger()
TriggerRegisterAnyUnitEventBJ(gg_trg_OrderNoTarg,EVENT_PLAYER_UNIT_TRAIN_START)
TriggerAddCondition(gg_trg_OrderNoTarg,Condition(function OnStartTrain))
}
endlibrary
void RsCast(unit u, real tx, real ty)
{
player p=GetOwningPlayer(u)
int pid=GetPlayerId(p)
int n=5
unit c
if(RsActive[forceId[pid]]>0){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(pid)+" almost wasted its Devastating Strike!")
p=null
return
}
RsActive[forceId[pid]]=1
c=CreateUnit(p,'h04X',tx,ty,0.)
SetUnitVertexColor(c,0,0,0,0)
UnitRemoveAbility(u,'A005')
UnitRemoveAbility(u,'A06E')
//DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Flare\\FlareCaster.mdl",u,"origin"))
DestroyEffect(AddSpecialEffectTarget("Units\\NightElf\\Wisp\\WispExplode.mdl",c,"origin"))
DestroyEffect(AddSpecialEffectTarget("Units\\NightElf\\Wisp\\WispExplode.mdl",c,"origin"))
DestroyEffect(AddSpecialEffect("MeteorStrike2.mdl",tx,ty))
TriggerSleepAction(.2)
filterPlayer=p
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,I2S(CountUnitsInGroup(pickgroup)))
real dmg=0.
int count=0
unit j
bool uais=mode_uai // UnitsAI Pause
mode_uai=false
//filterELHEAL=falseCondition // disable Linker
loop
GroupEnumUnitsInRange(ugr,tx,ty,RS_radius,null)
loop
j=FirstOfGroup(ugr)
exitwhen j==null
GroupRemoveUnit(ugr,j)
if(IsUnitEnemy(j,p) and GetWidgetLife(j)>.405 and GetUnitAbilityLevel(j,'Avul')<=0 and not IsUnitType(j,UNIT_TYPE_STRUCTURE)){
count++
dmg+=GetWidgetLife(j)
UnitDamageTarget(u,j,10000.,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_DEATH,WEAPON_TYPE_WHOKNOWS)
UnitDamageTarget(u,j,10000.,true,false,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_DEATH,WEAPON_TYPE_WHOKNOWS)
}
endloop
TriggerSleepAction(.2)
n--
exitwhen(n==0)
endloop
IssueImmediateOrderById(c,852526)
//TriggerSleepAction(0.) // allow death releazer to kill all units
//filterELHEAL=Condition(function FilterELHEAL) // enable Linker
mode_uai=uais // Resuming UnitsAI if required
TriggerSleepAction(1.5)
RemoveUnit(c)
c=null
RsActive[forceId[pid]]=0
statisticRSDamage[pid]=R2I(dmg)
statisticRSKills[pid]=count
mpRsCount[forceId[pid]]--
if(mpRsCount[forceId[pid]]==0){
SetMBValue(1,forceId[pid]+1,"|cffFF00000|r")
}else{
SetMBValue(1,forceId[pid]+1,I2S(mpRsCount[forceId[pid]]))
}
AssignSpectatorMultiboard(spectatorPosition[pid],forceId[pid]*6+1," ")
if(count==0){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(pid)+" wasted his Devastating Strike, killing no unit! Epic Fail!")
}elseif(count==1){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(pid)+" wasted his Devastating Strike, killing only one unit!")
}else{
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(pid)+" dealt |cffFFFF00"+I2S(statisticRSDamage[pid])+"|r damage with his Devastating Strike and killed |cffFFFF00"+I2S(count)+"|r units!")
}
}
void ScrollCast(unit u, real tx, real ty)
{
unit c=CreateUnit(GetOwningPlayer(u),'e008',tx,ty,0.)
UnitAddAbility(c,'A02G')
IssueImmediateOrderById(c,852269)
UnitApplyTimedLife(c,'BTLF',1.)
c=null
}
void BuyDispatcher(unit u,int itd)
{
player p=GetOwningPlayer(u)
if(itd==0){
itd='I008'
}elseif(itd==1){
itd='I007'
}elseif(itd==2){
itd='I006'
}elseif(itd==3){
itd='I003'
}elseif(itd==4){
itd='I004'
}elseif(itd==5){
itd='I005'
}elseif(itd==6){
itd='I00A'
}elseif(itd==7){
itd='I001'
}elseif(itd==8){
itd='I009'
}elseif(itd==9){
itd='I002'
}
//IssueBuyItemOrder()
IssueNeutralImmediateOrderById(p,forcedCastle[forceId[GetPlayerId(p)]],itd)
}
function Trig_UnitCastAbility_Actions takes nothing returns nothing
unit u=GetTriggerUnit()
int abil=GetSpellAbilityId()
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"::UnitCast:"+GetUnitName(u)+":"+Utils_RawCode2S(abil))
if(IsUnitType(u,UNIT_TYPE_STRUCTURE)){
if(abil=='A09A'){
ShowTowerRange(u,Data_GetTowerRange(u))
}else{
Data_ExecuteBuildingSpell(u)
}
}elseif (IsUnitType(u,UNIT_TYPE_SAPPER)){
Data_ExecuteUnitSpell(u,abil,GetSpellTargetUnit())
}
elseif(abil=='A005'){
RsCast(u,GetSpellTargetX(),GetSpellTargetY())
}elseif(abil=='A07C'){
Common_GateCtrl(forceId[GetPlayerId(GetOwningPlayer(u))])
}elseif(abil=='A08Y'){
ScrollCast(u,GetSpellTargetX(),GetSpellTargetY())
}elseif(abil>='IBA0' and abil<='IBA8'){
BuyDispatcher(u,abil-'IBA0')
}
elseif(abil=='A0K6'){
Common_TeleportUnits(u,GetSpellTargetX(),GetSpellTargetY() )
}
u=null
endfunction
//===========================================================================
function InitTrig_UnitCastAbility takes nothing returns nothing
set gg_trg_UnitCastAbility = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_UnitCastAbility, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddAction( gg_trg_UnitCastAbility, function Trig_UnitCastAbility_Actions )
endfunction
function Trig_UnitProduced_Actions takes nothing returns nothing
unit u=GetTrainedUnit()
unit j=GetTriggerUnit()
int tid=GetTrainedUnitType()//GetPlayerId(GetOwningPlayer(u))
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,GetUnitName(u)+" produced!")
if(GetUnitAbilityLevel(u,'A07J')>0){
u=Chaos_TranslateBlood(u)
}
OnUnitProduced(u,j)
//if(gameAutoTrain[GetPlayerId(GetOwningPlayer(j))]){}
u=LoadUnitHandle(tableJU,GetHandleId(u),GetUnitUserData(u)-1) //reset progress ind
if(u!=null) {
ShowUnit(u, false)
}
TriggerSleepAction(.05)
IssueImmediateOrderById(j,tid)
j=null
u=null
endfunction
void UnitTrainCanceled(){
unit j=GetTriggerUnit()
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,GetUnitName(j)+" canceled!")
j=LoadUnitHandle(tableJU,GetHandleId(j),GetUnitUserData(j)-1) //reset progress ind
if(j!=null) {
ShowUnit(j, false)
}
j=null
}
//===========================================================================
function InitTrig_UnitProduced takes nothing returns nothing
gg_trg_UnitProduced = CreateTrigger( )
gg_trg_UnitCanceled= CreateTrigger( )
TriggerRegisterAnyUnitEventBJ( gg_trg_UnitProduced, EVENT_PLAYER_UNIT_TRAIN_FINISH )
TriggerRegisterAnyUnitEventBJ( gg_trg_UnitCanceled, EVENT_PLAYER_UNIT_TRAIN_CANCEL )
TriggerAddAction( gg_trg_UnitProduced, function Trig_UnitProduced_Actions )
TriggerAddAction( gg_trg_UnitCanceled, function UnitTrainCanceled )
endfunction
boolexpr fltPartyUnit
int PartyCnt
real puX
player fltPlayer
bool FltPartyUnit()
{
unit u=GetFilterUnit()
bool res = IsUnitType(u,UNIT_TYPE_SAPPER) and IsUnitAlly(u,fltPlayer) and GetWidgetLife(u)>50.0
if(res)
{
PartyCnt++
}
u=null
return res
}
void CheckUnitParty(unit u){
int fid
if(GetUnitAbilityLevel(u,'A0IC')>0) {
AttackCreepOrderCommon(u)
return
}
PartyCnt = 0
fltPlayer = GetOwningPlayer(u)
GroupEnumUnitsInRange(ugr,GetUnitX(u),GetUnitY(u),800.,fltPartyUnit)
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"::Party cnt"+GetUnitName(u)+":"+I2S(PartyCnt))
if(PartyCnt<3) {
UnitAddAbility(u,'A0ID')
SetUnitFacing(u,GetRandomReal(0,6.28))
TriggerSleepAction(30.0)
UnitRemoveAbility(u,'A0ID')
AttackCreepOrderCommon(u)
} else {
fid = forceId[GetPlayerId(GetOwningPlayer(u))]
loop
u = FirstOfGroup(ugr)
exitwhen u == null
GroupRemoveUnit(ugr,u)
UnitRemoveAbility(u,'A0ID')
IssuePointOrderByIdLoc(u,851983,targetRectLoc[fid]) //attack
endloop
}
}
define htChkArtU = 'htAr'
trigger tatr
constant player NEUTRAL_PLAYER=Player(PLAYER_NEUTRAL_PASSIVE)
function OnAcquireTarg takes nothing returns nothing
unit au = GetTriggerUnit()
real r //= GetUnitAcquireRange(au)
real hp
real dr
//player pl = GetOwningPlayer(au)
unit u, nu
real x = GetUnitX(au)
real y = GetUnitY(au)
real dx,dy, rm = 999999.0;
integer ut
nu=null
if (LoadInteger(tableIN,htChkArtU,GetHandleId(au)) > Ticks){
au=null
return
}
/*
if(GetRandomInt(0,99)>40) {
ut = GetUnitTypeId(au)
if(IsUnitIdType(ut,UNIT_TYPE_MELEE_ATTACKER)) {r*=0.3}
GroupEnumUnitsInRange(ugr,x,y,r,null)
//look for the nearest structure
DisplayTextToPlayer(GetLocalPlayer(),0.,0.,GetUnitName(au)+"::"+R2S(r))
//TriggerSleepAction(GetRandomReal(0.1,0.2))
loop
u = FirstOfGroup(ugr)
exitwhen u==null
GroupRemoveUnit(ugr,u)
hp = GetWidgetLife(u)
if(IsUnitType(u,UNIT_TYPE_STRUCTURE) and IsUnitEnemy(u,pl) and hp > 1.0 and GetUnitAbilityLevel(u,'Avul')<=0) {
dx = x - GetUnitX(u); dy = y - GetUnitY(u);
r = (dx*dx+dy*dy)*0.001*hp;
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,GetUnitName(u)+" r:"+R2S(r))
if(r<rm) { nu=u;rm=r}
}
endloop
}*/
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,GetUnitName(tu))
if(nu!=null)
{
TriggerSleepAction(0.1)
IssueTargetOrderById(au,order_attack,nu)
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,GetUnitName(au)+"-->"+GetUnitName(nu))
nu=null; //pl = null;
}
else
{
SaveInteger(tableIN,htChkArtU,GetHandleId(au),Ticks+5)
nu = GetEventTargetUnit()
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,GetUnitName(au)+"-->"+GetUnitCurrentOrder(au))
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,GetUnitName(au)+"-->"+GetUnitName(nu)+" "+OrderId2String(GetUnitCurrentOrder(au)))
dx = GetUnitX(nu)
dy = GetUnitY(nu)
x = x - dx
y = y - dy
r = SquareRoot(x*x+y*y);
if(r>420.0)
{
dr = r * GetRandomReal(0.08,0.16)
if(GetRandomInt(0,100) > 50)
{
dr = -1.0 * dr
}
dx+=dr;
dr = r * GetRandomReal(0.10,0.17)
if(GetRandomInt(0,100) > 50)
{
dr = -1.0 * dr
}
dy+=dr
TriggerSleepAction(0.0)
if(GetWidgetLife(au)>.405)
{
nu=CreateUnit(NEUTRAL_PLAYER,'e00N',dx,dy,0.)
UnitApplyTimedLife(nu,'BTLF',1.5)
if(!IssueTargetOrderById(au,order_attack,nu))
{
DisplayTextToPlayer(GetOwningPlayer(au),0.,0.,GetUnitName(au) + " cannot attack grnd!")
}
}
TriggerSleepAction(1.8)
AttackCreepOrder(au)
}
nu=null
}
au=null
endfunction
function SetMaxHP takes unit u, real v returns nothing
integer a = 'A0K3'
integer hp = 640
integer i = 8
loop
if(v>=hp)
{
call UnitAddAbility( u, a )
call SetUnitAbilityLevel( u, a, i )
call UnitRemoveAbility( u, a )
v-=hp
}
hp /= 2;
i--
exitwhen i == 0
endloop
endfunction
function Trig_UnitEnters_Actions takes nothing returns bool
unit u=GetTriggerUnit()
int uid=GetUnitTypeId(u)
int at
if(IsUnitType(u,UNIT_TYPE_SAPPER)){
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"::UnitEnters:"+GetUnitName(u))
//SetUnitState(u,UNIT_STATE_LIFE,GetUnitState(u,UNIT_STATE_MAX_LIFE) * hpFactor)
if(hpFactor < 1.0)
{
SetMaxHP(u, GetUnitState(u,UNIT_STATE_MAX_LIFE) * (1.0 - hpFactor))
}
if(GetUnitAbilityLevel(u,'A0C5')>0){
RegisterUnitOnDmg(u)
}
if(uid=='u00D') {//Lich
RegisterUnitOnAtk(u)
Undead_NewLich(u)
}
elseif(uid=='n02T'){ //ambusher
RegisterUnitOnAtk(u)
}
elseif(uid=='e00F'){ // Gigant
Nature_DoGrabTree(u)
}
at = LoadInteger(RBT,GCCS,uid)
//AT==AT_SIEGE
if(uid=='hmtm' or uid=='e005' or uid=='o001' or uid=='h06F') {
TriggerRegisterUnitEvent(tatr,u,EVENT_UNIT_ACQUIRED_TARGET)
}
AttackCreepOrderCommon(u)
//CheckUnitParty(u)
}
elseif(IsUnitType(u,UNIT_TYPE_STRUCTURE))
{
RegisterStructDmg(u)
if(uid=='h061' or uid=='n02D') {
RegisterUnitOnAtk(u)
}
}elseif(uid=='n01U'){ //gobbo mech
UnitApplyTimedLife(u,'BTLF',GetRandomReal(40.,60.))
}
u=null
return false
endfunction
//===========================================================================
function InitTrig_UnitEnters takes nothing returns nothing
gg_trg_UnitEnters = CreateTrigger( )
tatr = CreateTrigger( )
TriggerAddAction(tatr,function OnAcquireTarg)
TriggerRegisterEnterRectSimple( gg_trg_UnitEnters, bj_mapInitialPlayableArea )
TriggerAddCondition( gg_trg_UnitEnters, Condition(function Trig_UnitEnters_Actions))
fltPartyUnit = Filter(function FltPartyUnit)
endfunction
function Trig_UnitOwned_Actions takes nothing returns nothing
unit u = GetTriggerUnit()
if(IsUnitType(GetTriggerUnit(),UNIT_TYPE_SAPPER) and not IsUnitType(GetTriggerUnit(),UNIT_TYPE_STRUCTURE)){
if(GetUnitAbilityLevel(u,'A07H')>0){
DisableTrigger(gg_trg_UnitOwned)
SetUnitOwner(u,GetChangingUnitPrevOwner(),true)
EnableTrigger(gg_trg_UnitOwned)
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl",u,"origin"))
}/*elseif(GetUnitTypeId(GetTriggerUnit())=='h03A'){
TriggerSleepAction(.1)
IssueImmediateOrderById(u,852055)
TriggerSleepAction(.1)
}*/
}
AttackCreepOrderCommon(u)
u=null
endfunction
//===========================================================================
function InitTrig_UnitOwned takes nothing returns nothing
set gg_trg_UnitOwned = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_UnitOwned, EVENT_PLAYER_UNIT_CHANGE_OWNER )
call TriggerAddAction( gg_trg_UnitOwned, function Trig_UnitOwned_Actions )
endfunction
library_once FirstBuild initializer init
public player first=null
private constant force check=CreateForce()
private constant trigger control=CreateTrigger()
private int award
private int number
private string N2S(int num)
{
if(num==1) {return "first"}
if(num==2) {return "second"}
if(num==3) {return "third"}
return "fourth"
}
private void process()
{
player p=GetTriggerPlayer()
if(!IsPlayerInForce(p,check)) {
if(first==null){first=p}
AdjustPlayerStateBJ(award,GetTriggerPlayer(),PLAYER_STATE_RESOURCE_GOLD)
DisplayTextToPlayer(p,0.,0.,"|cffFFFF80You receive |cffFFCC00"+I2S(award)+"|cffFFFF80 gold for being the "+N2S(number)+" player that finishes a structure!")
pGoldBonuses[GetPlayerId(p)]+=award
award-=5
number++
if(number>4){
DisableTrigger(control)
}else{
ForceAddPlayer(check,p)
}
}
}
public void Reset()
{
first=null
ForceClear(check)
award=20
number=1
EnableTrigger(control)
}
public void init()
{
TriggerAddAction(control,function process)
TriggerRegisterAnyUnitEventBJ(control,EVENT_PLAYER_UNIT_CONSTRUCT_FINISH)
DisableTrigger(control)
}
endlibrary
library AutoAFKControl uses AILibrary, UnitSmartBlocker
private timer t=null
private void OnTimer() {
int i=0
player p
loop
p=Player(i)
if(GetPlayerSlotState(p)==PLAYER_SLOT_STATE_PLAYING and GetPlayerController(p)==MAP_CONTROL_USER and not AILibrary_isPlayerAFK[i]){
if(GameTimeMinutes-UnitSmartBlocker_lastMinute[i]>4){
DisplayTextToPlayer(Player(i),0.,0.,"|cffCA0000WARNING|r: You did not move your worker for 5 minutes. AI will take control in 60 seconds!")
if(GameTimeMinutes-UnitSmartBlocker_lastMinute[i]>5){
AILibrary_SwitchPlayerAFK(i)
}
}
}
i++
exitwhen i>11
endloop
}
public void Suspend() {
if(t!=null) {
PauseTimer(t)
}
}
public void Reset() {
int i=0
loop
UnitSmartBlocker_lastMinute[i]=0
i++
exitwhen i>11
endloop
if(t!=null) {
TimerStart(t,60.,true,function OnTimer)
}
}
public void init() {
if(t==null) {
t=CreateTimer()
}
}
endlibrary
library SpecialTimersControl initializer init
define private ST_TICK_COUNTS=3
define private tick = gg_snd_Tick
define private tack = gg_snd_Tack
private timer array timers
private timer array wtimers
private timerdialog array dialogs
private real array alphatime // totaltime - 3sec
private int array betatime // for ticktack seconds
private string array labels
private void OnBetaTime(){
int id=LoadInteger(tableIN,htKeyTmrID,GetHandleId(GetExpiredTimer()))
betatime[id]--
if(betatime[id]<0){
if(GetLocalPlayer()==Player(id)){
StartSound(tack)
}
betatime[id]=ST_TICK_COUNTS
TimerDialogSetTitle(dialogs[id],labels[ST_TICK_COUNTS])
TimerStart(timers[id],alphatime[id],false,function OnBetaTime)
TimerStart(wtimers[id],alphatime[id]+ST_TICK_COUNTS,false,null)
return
}
if(GetLocalPlayer()==Player(id)){
StartSound(tick)
}
TimerDialogSetTitle(dialogs[id],labels[betatime[id]])
TimerStart(timers[id],1.,false,function OnBetaTime)
}
public void StartTime(int p, real time) {
if(timers[p]==null){
timers[p]=CreateTimer()
wtimers[p]=CreateTimer()
dialogs[p]=CreateTimerDialog(wtimers[p])
SaveInteger(tableIN,htKeyTmrID,GetHandleId(timers[p]),p)
}
TimerDialogDisplay(dialogs[p],GetLocalPlayer()==Player(p))
alphatime[p]=time-ST_TICK_COUNTS
betatime[p]=ST_TICK_COUNTS
TimerDialogSetTitle(dialogs[p],labels[ST_TICK_COUNTS])
TimerStart(timers[p],alphatime[p],false,function OnBetaTime)
TimerStart(wtimers[p],alphatime[p]+ST_TICK_COUNTS,false,null)
}
public bool StopTime(int p) {
if(alphatime[p]<=0.){
return false
}
PauseTimer(timers[p])
alphatime[p]=0.
PauseTimer(wtimers[p])
TimerDialogDisplay(dialogs[p],false)
return true
}
// allows to pause timers on start and finish rounds
public void InternalControl(bool flag) {
int i=0
if(flag){
loop
if(alphatime[i]>0.){
TimerDialogSetTitle(dialogs[i],labels[ST_TICK_COUNTS])
TimerStart(timers[i],alphatime[i],false,function OnBetaTime)
TimerStart(wtimers[i],alphatime[i]+ST_TICK_COUNTS,false,null)
}
i++
exitwhen i>11
endloop
return
}
loop
if(alphatime[i]>0.){
PauseTimer(timers[i])
PauseTimer(wtimers[i])
}
i++
exitwhen i>11
endloop
}
private void init() {
labels[0]="!!!"
labels[1]=".!!"
labels[2]="..!"
labels[3]="..."
}
endlibrary
library DrawControl
private bool executed=true
private bool array voteToPlay
private bool array voteToNuke
private bool array voteToSurr
define CanVote(i)=GetPlayerController(Player(i))==MAP_CONTROL_USER and GetPlayerSlotState(Player(i))==PLAYER_SLOT_STATE_PLAYING and (IsPlayerInForce(Player(i),leftPlayers) or IsPlayerInForce(Player(i),rightPlayers))
public void Reset()
{
int i=0
loop
if(CanVote(i)){
voteToPlay[i]=true
voteToNuke[i]=false
voteToSurr[i]=false
}
i++
exitwhen i>11
endloop
executed=false
}
private bool IsDraw()
{
int i=0
loop
if(voteToPlay[i]){return false}
i++
exitwhen i>11
endloop
executed=true
return true
}
private bool NukeVotePassed()
{
int i=0
loop
if(CanVote(i)) {
if(!voteToNuke[i]) {return false}
}
i++
exitwhen i>11
endloop
return true
}
private bool TeamSurrPassed(int pid){
int i=0
int j=6
if(pid>5) {i+=5;j+=5}
loop
if(CanVote(i)) {
if(!voteToSurr[i]) {return false}
}
i++
exitwhen i>j
endloop
return true
}
public void PlayerDraw(int pid){
if(executed){return}
if(voteToPlay[pid]){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(pid)+" has voted for a draw!")
voteToPlay[pid]=false
if(IsDraw()){
TriggerExecute(EndRoundScenario_OnDraw)
}
}else{
DisplayTextToPlayer(Player(pid),0.,0.,"|cffFF0000You have already voted for a draw!|r")
}
}
private void NukeUnit(){
if (IsUnitType(GetEnumUnit(),UNIT_TYPE_SAPPER)) { ExplodeUnitBJ(GetEnumUnit()) }
}
private void DoNuke() {
int i=0
loop
voteToNuke[i]=false
i++
exitwhen i>11
endloop
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,null)
ForGroup(pickgroup, function NukeUnit)
}
public void PlayerNuke(int pid){
if(!voteToNuke[pid]){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(pid)+" has voted for a nuke!")
voteToNuke[pid]=true
if(NukeVotePassed()){
DoNuke()
}
}else{
DisplayTextToPlayer(Player(pid),0.,0.,"|cffFF0000You have already voted for a nuke!|r")
}
}
public void PlayerSurrender(int pid){
if(!voteToSurr[pid]){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(pid)+" has voted for surrender!")
voteToSurr[pid]=true
if(TeamSurrPassed(pid)){
KillUnit(forcedCastle[forceId[pid]])
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,forceName[forceId[pid]]+" has voted for surrender!")
}
}else{
DisplayTextToPlayer(Player(pid),0.,0.,"|cffFF0000You have already voted for surrender!|r")
}
}
endlibrary
library XRControl initializer init uses DialogMainInit
private constant timer tim=CreateTimer()
private constant timerdialog timwin=CreateTimerDialog(tim)
private int value=-1
private int persRequired
private bool array canVote
private void StopVote()
{
value=-1
TimerDialogDisplay(timwin,false)
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"Time is up and not all players have agreed. Extra rounds declined!")
}
public void OnVote(int pid)
{
if(value==-1){return}
if(canVote[pid]){
canVote[pid]=false
persRequired--
if(persRequired>0){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(pid)+" has agreed, "+I2S(persRequired)+" more votes needed")
}else{
mode_rounds+=value
PauseTimer(tim)
TimerDialogDisplay(timwin,false)
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"All players have agreed, number of rounds is increased by "+I2S(value))
addingByXR=true
DialogMainInit_ReportPlayers(true)
value=-1
}
}else{
DisplayTextToPlayer(Player(pid),0.,0.,"You have already agreed!")
}
}
public void StartVote(int val)
{
if(val<1 or val>3){
DisplayTextToPlayer(Player(0),0.,0.,"Invalid number of rounds, must be between 1 and 3")
return
}
value=val
persRequired=0
int i=0
loop
if(GetPlayerController(Player(i))==MAP_CONTROL_USER and GetPlayerSlotState(Player(i))==PLAYER_SLOT_STATE_PLAYING and (IsPlayerInForce(Player(i),leftPlayers) or IsPlayerInForce(Player(i),rightPlayers))){
canVote[i]=true
persRequired++
}
i++
exitwhen i>11
endloop
TimerStart(tim,30.,false,function StopVote)
TimerDialogDisplay(timwin,true)
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,30.,"|cffC6FF00"+I2S(val)+" Extra Rounds|r vote has been started. You have 30 seconds to agree to it by typing |cffFFFF00-agree|r. If all players agree, the number of wins for overall victory will be increased by "+I2S(val))
}
public void init()
{
TimerDialogDisplay(timwin,false)
TimerDialogSetTitle(timwin,"Voting XR")
}
endlibrary
library_once Console initializer init uses Main, Income, DialogMainInit, XRControl
public boolean skipDelay=false
private string evaluteGameConfig_string=null
public string evaluteGameConfig()
{
string res
if(evaluteGameConfig_string!=null){return evaluteGameConfig_string}
//
if(mode_gamemode==1){res=" -r"}
elseif(mode_gamemode==2){res=" -m"}
elseif(mode_gamemode==3){res=" -d"}
else{res=" -p"}
if(mode_permamentRace){res+="p"}
else{res+="r"}
res+=I2S(mode_rounds)
//
if(mode_lines==0){res+="-dl"}
elseif(mode_lines==2){res+="-slb"}
//
if(mode_fogtime>0){res=res+"-fow"+I2S(mode_fogtime)}
elseif(mode_fogtime==0){res+="-nfow"}
//
if(mode_incomeTime!=10.){res=res+"-it"+R2SW(mode_incomeTime,2,1)}
if(mode_CI){res=res+"-si"}
//
if(mode_dualraces){res+="-du"}
//
if(mode_uai){res+="-ai"}
//
if(mode_na){res+="-na"}
//
if(mode_tb){res+="-ntb"}
//
if(mode_nb){res+="-nb"}
//
if(not mode_sb){res+="-ns"}
//
if(not mode_ia){res+="-ni"}
//
if(not mode_la){res+="-la"}
//
if(not mode_rse){res+="-nrs"}
//
if(mode_ur){res+="-ur"}
//
if(mode_dom){res+="-dom"}
//
if(mode_nafk){res+="-dafk"}
//
if(mode_taxes==1){res+="-nt"}
elseif(mode_taxes==2){res+="-ht"}
//
if(mode_lumberLimit>-1){res=res+"-ll"+I2S(mode_lumberLimit)}
//
if(mode_bans>0){res=res+"-ban"+I2S(mode_bans)}
//
if(mode_bans<0){res=res+"-rban"+I2S(-mode_bans)}
//
if(mode_mp>0){res=res+"-mp"+I2S(mode_mp)}
if(mode_emp>0){res=res+"-emp"+I2S(mode_emp)}
//
if(mode_coins==10){res+=res+"-cc"}
elseif(mode_coins==1){res+="-co"}
//
if(mode_gameLimit!=0){
if(mode_gameLimit>0){
res=res+"-glw"+I2S(mode_gameLimit)
}else{
res=res+"-gld"+I2S(IAbsBJ(mode_gameLimit))
}
}
if(hpFactor < 1.0){
res=res+"-hp"+R2SW(hpFactor,2,1)
}
//
if(not mode_cc){res+="-ca"}
if(mode_gates){res+="-cg"}
if(spawn_bstuff){res+="-bs"}
//
if(map_start_gold!=250){res+="-srg"+I2S(map_start_gold)}
if(map_start_lumb!='}'){res+="-srl"+I2S(map_start_lumb)}
if(map_start_legn!=1) {res+="-sru"+I2S(map_start_legn)}
//
if(mode_nfr>0){res+="-nfr"+I2S(mode_nfr)}
//
res=res+"-bal"+I2S(mode_autobalance)
evaluteGameConfig_string=res
return res
}
private bool isPaused=false
private void SwitchPause()
{
isPaused=not isPaused
if(isPaused){
PauseTimer(DialogMainInit_pretime)
}else{
ResumeTimer(DialogMainInit_pretime)
if(skipDelay){DialogMainInit_ConfigDialToRoundsSelection()}
}
}
public void SpecControlSendsResume()
{
if(not isPaused){
ResumeTimer(DialogMainInit_pretime)
if(skipDelay){DialogMainInit_ConfigDialToRoundsSelection()}
}
}
private int IndificatePlayer(string s)
{
int i=0
int len=StringLength(s)
if(len>0){
if(SubString(s,0,1)==" "){
s=SubString(s,1,len)
len--
}
}
loop
if(SubString(names[i],0,len)==s){
return i
}
i++
exitwhen i>11
endloop
return -1
}
/*
private void OnInfoCommand(int caller, string param)
{
int target=IndificatePlayer(param)
if(target==-1){
DisplayTextToPlayer(Player(caller),0.,0.,"Sorry, but required player are not found.")
return
}
if(IsPlayerAlly(Player(caller),Player(target)))
{
DisplayTimedTextToPlayer(Player(caller),0.,0.,10.,PlayersAdvStats_GetInfo2(target))
}else{
DisplayTimedTextToPlayer(Player(caller),0.,0.,10.,PlayersAdvStats_GetInfo(target))
}
}
*/
private void Fill(player caller,int value)
{
int i=0
player p
debug LogAdd("Fill: entered")
if(value>6){value=6}
if(CountPlayersInForceBJ(leftPlayers)+CountPlayersInForceBJ(rightPlayers)+CountPlayersInForceBJ(quotaPlayers)<value*2){
DisplayTextToPlayer(caller,0.,0.,"Command [|c00ff0000Fill|r] coudn't be executed. There are small count of quota players.")
return
}
debug LogAdd("Fill: first cicle")
loop
exitwhen CountPlayersInForceBJ(leftPlayers)>=value
p=AllocateFreeSlot(true)
ForceRemovePlayer(quotaPlayers,p)
ForceAddPlayer(leftPlayers,p)
CreateFogModifierRectBJ(true,p,FOG_OF_WAR_VISIBLE,dummyArea)
startPosition[GetPlayerId(p)]=StartPosition_GiveMeRespawn(true)//GetPlayerStartLocationLoc(p)
relayedForces[GetPlayerId(p)]=CreateForce()
AILibrary_StartAI(GetPlayerId(p))
i++
endloop
debug LogAdd("Fill: second cicle")
loop
exitwhen CountPlayersInForceBJ(rightPlayers)>=value
p=AllocateFreeSlot(false)
ForceRemovePlayer(quotaPlayers,p)
ForceAddPlayer(rightPlayers,p)
CreateFogModifierRectBJ(true,p,FOG_OF_WAR_VISIBLE,dummyArea)
startPosition[GetPlayerId(p)]=StartPosition_GiveMeRespawn(false)//GetPlayerStartLocationLoc(p)
relayedForces[GetPlayerId(p)]=CreateForce()
AILibrary_StartAI(GetPlayerId(p))
i++
endloop
debug LogAdd("Fill: RestructAlliances")
RestructAlliances()
DisplayTextToPlayer(caller,0.,0.,"There are added "+I2S(i)+" players.")
debug LogAdd("Fill: exit")
}
private bool SetRoundsCount(string s)
{
int i=S2I(s)
if(i<=0) {return false}
mode_rounds=IMinBJ(i,6)
return true
}
private bool SetRaceSelection(string s)
{
if(s=="g"){
mode_permamentRace=true
return true
}elseif(s=="r"){
mode_permamentRace=false
return true
}
return false
}
private void SetFogTime(int t)
{
if(t<0){return}
if(t==0){
if(mode_fogtime==-1){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cff808080Deprecated activation of Permanent Fog of War has been encountered. Ignored.|r")
return
}
mode_fogtime=-1
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"Permanent |cffC6FF00Fog of War|r has been chosen")
return
}
mode_fogtime=t
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Fog of War|r time has been set to |cffFFFF00"+I2S(t)+"|r seconds.")
}
private void StopFogTime()
{
mode_fogtime=0
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Fog of War|r has been removed. All map will be visible.")
}
private void Roll(int size)
{
if(size==0){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,I2S(GetRandomInt(0,99)))
}else{
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,I2S(GetRandomInt(0,size)))
}
}
private void PersonalTimer(int p, int value) {
if(value==0){
if(SpecialTimersControl_StopTime(p)){
DisplayTextToPlayer(Player(p),0.,0.,"Your |cffC6FF00Personal Timer|r has been disabled")
}else{
DisplayTextToPlayer(Player(p),0.,0.,"Your |cffC6FF00Personal Timer|r is already disabled!")
}
return
}
if(value<4){
DisplayTextToPlayer(Player(p),0.,0.,"The value for Personal Timer must be more that |c00ff00003|r!")
return
}
SpecialTimersControl_StartTime(p,value)
DisplayTextToPlayer(Player(p),0.,0.,"Your |cffC6FF00Personal Timer|r has been started")
}
private void SwitchAutoTrain(int index) {
gameAutoTrain[index]=not gameAutoTrain[index]
if(gameAutoTrain[index]){
DisplayTextToPlayer(Player(index),0.,0.,"|cffC6FF00Auto Training|r has been activated")
}else{
DisplayTextToPlayer(Player(index),0.,0.,"|cffC6FF00Auto Training|r has been deactivated")
}
}
private void SetStartResources(string restype, int value) {
if(restype=="g" or restype=="G"){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Start Resources|r has been changed. The amount of start |c00ffdc00Gold|r is |cffFFFF00"+I2S(value)+"|r.")
map_start_gold=value
}elseif(restype=="l" or restype=="L"){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Start Resources|r has been changed. The amount of start |c0000c850Lumber|r is |cffFFFF00"+I2S(value)+"|r.")
map_start_lumb=value
}elseif(restype=="u" or restype=="U"){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Start Resources|r has been changed. The amount of start |c008000ffLegendaries limit|r is |cffFFFF00"+I2S(value)+"|r.")
map_start_legn=value
}else{
DisplayTextToPlayer(Player(0),0.,0.,"Resource [|c00ff0000"+restype+"|r] couldn't be identified.")
}
}
private void ExecuteConsoleCommand(string s,int index)
{
if(StringLength(s)<=2){return}
//LogAdd("Console: operating command string: "+s)
if(IsGameLoading and index==0 and SubString(s, 1, 3)=="na"){
SetArtilleryStatus(false)
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="ai"){
SetUnitAIStatus(true)
//}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="fp"){
// SetProductionStatus(true)
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="co"){
SetCoinsStatus()
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="cc"){
SetCCoinsStatus()
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="du"){
SetDRStatus(true)
}/*elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="uo"){
SetUOStatus(true)
}*/elseif(IsGameLoading and index==0 and SubString(s, 1, 4)=="ntb"){
SetTBStatus(false)
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="nb"){
SetNBStatus(false)
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="ns"){
SetSBStatus(false)
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="ni"){
SetIAStatus(false)
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="la"){
SetLAStatus(false)
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="sr" and StringLength(s)>4) {
SetStartResources(SubString(s, 3, 4),S2I(SubString(s, 4, StringLength(s))))
}elseif(IsGameLoading and index==0 and SubString(s, 1, 4)=="nrs"){
SetRSEStatus(false)
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="dl"){ // and mode_lines==0
mode_lines=0 //both
Main_SetBottomLanePathable(true)
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="ur"){
SetURStatus(true)
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="it"){
SetITStatus(S2R(SubString(s, 3, StringLength(s))))
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="si"){
mode_CI=true;mode_itm=1.0/mode_incomeTime;
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Streaming Income|r has been enabled|r.")
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="hp"){
hpFactor = S2R(SubString(s, 3, StringLength(s)))
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Hitpoints factor|r has been set to"+R2SW(hpFactor,2,1)+"|r.")
}
elseif(IsGameLoading and index==0 and SubString(s, 1, 4)=="glw"){
SetGRLStatus(S2I(SubString(s, 4, StringLength(s))))
}elseif(IsGameLoading and index==0 and SubString(s, 1, 4)=="gld"){
SetGRLStatus(-1*S2I(SubString(s, 4, StringLength(s))))
}elseif((not IsGameLoading) and index==0 and SubString(s, 1, 3)=="xr"){
XRControl_StartVote(S2I(SubString(s, 3, StringLength(s))))
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="mp"){
SetMPStatus(S2I(SubString(s, 3, StringLength(s))))
}elseif(IsGameLoading and index==0 and SubString(s, 1, 4)=="emp"){
SetEMPStatus(S2I(SubString(s, 4, StringLength(s))))
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="ll"){
SetLLStatus(S2I(SubString(s, 3, StringLength(s))))
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="ht"){
SetTStatus(2)
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="nt"){
SetTStatus(1)
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="ca"){
SetCCStatus(false)
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="cg"){
mode_gates = true
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffC6FF00Castle gates|r have been enabled. You can control castle gates.")
}elseif(IsGameLoading and index==0 and SubString(s, 1, 4)=="dom"){
SetDOMStatus(true)
}elseif(IsGameLoading and index==0 and SubString(s, 1, 4)=="fow"){
SetFogTime(S2I(SubString(s, 4, StringLength(s))))
}elseif(IsGameLoading and index==0 and SubString(s, 1, 5)=="nfow"){
StopFogTime()
}elseif(IsGameLoading and index==0 and SubString(s, 1, 5)=="rban"){
SetRBANStatus(S2I(SubString(s, 5, StringLength(s))))
}elseif(IsGameLoading and index==0 and SubString(s, 1, 4)=="ban"){
SetBANStatus(S2I(SubString(s, 4, StringLength(s))))
}elseif(IsGameLoading and index==0 and SubString(s, 1, 4)=="bal"){
SetBALStatus(S2I(SubString(s, 4, StringLength(s))))
}elseif(IsGameLoading and index==0 and SubString(s, 1, 3)=="bs"){
spawn_bstuff = true
}
elseif(IsGameLoading and index==0 and SubString(s, 1, 4)=="nfr"){
SetNFRStatus(S2I(SubString(s, 4, StringLength(s))))
//}elseif(IsGameLoading and index==0 and SubString(s, 1, 4)=="env"){
// startEnv(SubString(s, 4, StringLength(s)))
}elseif(IsGameLoading and index==0 and SubString(s, 1, 5)=="fill"){
Fill(Player(index),S2I(SubString(s, 5, StringLength(s))))
}elseif(IsGameLoading and index==0 and SubString(s, 1, 5)=="dafk"){
SetNAFKStatus(true)
}elseif(IsGameLoading and index==0 and SubString(s, 1, 6)=="pause"){
SwitchPause()
}elseif(IsGameLoading and index==0 and SubString(s, 1, 5)=="skip"){
if(/*SpectatorController_isInDial or*/ isPaused){
skipDelay=true
}else{
DialogMainInit_ConfigDialToRoundsSelection()
}
}elseif(index==0 and SubString(s, 1, 4)=="dm0"){
//parseCommands("-rr2-ur-ca-cg-it9-fill2",0)
ExecuteConsoleCommand("-rr2",0);ExecuteConsoleCommand("-ur",0);
ExecuteConsoleCommand("-ca",0);ExecuteConsoleCommand("-cg",0);
ExecuteConsoleCommand("-it9",0);ExecuteConsoleCommand("-fill2",0);
//ExecuteConsoleCommand("-skip",0);
}elseif(IsGameLoading and index==0 and SubString(s, 1, 2)=="r" and SetRaceSelection(SubString(s, 2, 3)) and SetRoundsCount(SubString(s, 3, 4))){
mode_gamemode=1
peonCreator="Random_Peon"
DialogMainInit_ReportPlayers(true)
}elseif(IsGameLoading and index==0 and SubString(s, 1, 2)=="p" and SetRaceSelection(SubString(s, 2, 3)) and SetRoundsCount(SubString(s, 3, 4))){
mode_gamemode=0
peonCreator="Pick_Peon"
DialogMainInit_ReportPlayers(true)
}elseif(IsGameLoading and index==0 and SubString(s, 1, 2)=="m" and SetRaceSelection(SubString(s, 2, 3)) and SetRoundsCount(SubString(s, 3, 4))){
mode_gamemode=2
peonCreator="Mirror_Peon"
DialogMainInit_ReportPlayers(true)
}elseif(IsGameLoading and index==0 and SubString(s, 1, 2)=="d" and SetRaceSelection(SubString(s, 2, 3)) and SetRoundsCount(SubString(s, 3, 4))){
mode_gamemode=3
peonCreator="Draft_Peon"
DialogMainInit_ReportPlayers(true)
}elseif(SubString(s, 1, 6)=="stats" and not IsGameLoading){
Income_ViewStats(Player(index))
}elseif(SubString(s, 1, 4)=="afk" and (not IsGameLoading) and not mode_nafk){
AILibrary_SwitchPlayerAFK(index)
}elseif(SubString(s, 1, 3)=="at"){
SwitchAutoTrain(index)
}elseif(SubString(s, 1, 5)=="mode" and (not IsGameLoading)){
DisplayTimedTextToPlayer(Player(index),0.,0.,10.,"|cffFFFF00Game-config-string|r:")
DisplayTimedTextToPlayer(Player(index),0.,0.,10.,evaluteGameConfig())
}elseif(SubString(s, 1, 7)=="income" and not IsGameLoading){
Income_ViewIncome(Player(index))
}elseif(SubString(s, 1, 6)=="armor"){
player p=Player(index)
DisplayTimedTextToPlayer(p,0.,0.,10.,"|cffFFFF00Armor table:")
DisplayTimedTextToPlayer(p,0.,0.,10.,"|cffFFCC00Chaos damage: |cffFFFF00neutral against all|r")
DisplayTimedTextToPlayer(p,0.,0.,10.,"|cffFFCC00Normal damage: |cff00FF00good against:|r medium |cffFF0000bad against:|r light")
DisplayTimedTextToPlayer(p,0.,0.,10.,"|cffFFCC00Pierce damage: |cff00FF00good against:|r light |cffFF0000bad against:|r heavy")
DisplayTimedTextToPlayer(p,0.,0.,10.,"|cffFFCC00Magic damage: |cff00FF00good against:|r heavy |cffFF0000bad against:|r medium")
DisplayTimedTextToPlayer(p,0.,0.,10.,"|cffFFCC00Siege damage: |cff00FF00good against:|r fortified |cffFF0000bad against:|r all others")
DisplayTimedTextToPlayer(p,0.,0.,10.,"|cffFFCC00Note:|r All attack types are |cffFF0000bad|r against divine besides chaos!")
}elseif(index==0 and SubString(s, 1, 5)=="roll"){
Roll(S2I(SubString(s, 5, StringLength(s))))
}elseif(SubString(s, 1, 5)=="draw"){
DrawControl_PlayerDraw(index)
}
elseif(SubString(s, 1, 5)=="nuke"){
DrawControl_PlayerNuke(index)
}
elseif(SubString(s, 1, 10)=="surrender"){
DrawControl_PlayerSurrender(index)
}
elseif(SubString(s, 1, 5)=="zoom"){
if(GetLocalPlayer()==Player(index)) {
SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 100.0+S2I(SubString(s, 5, StringLength(s))), 0.5)
}
}
elseif(SubString(s, 1, 3)=="mt"){
PersonalTimer(index,S2I(SubString(s, 3, StringLength(s))))
}elseif(SubString(s, 1, 6)=="agree"){
XRControl_OnVote(index)
}else{
DisplayTextToPlayer(Player(index),0.,0.,"Command [|c00ff0000"+SubString(s,1,StringLength(s))+"|r] coudn't be executed. You are not allowed to use it or syntax is wrong.")
}
}
private void parseCommands(string ent,integer id)
{
string s=StringCase(ent, false)
integer pos1=0
integer pos2=0
integer len=StringLength(s)
integer i=0
string ch
debug LogAdd("CE: "+ent)
loop
ch=SubString(s,i,i+1)
if ch=="-" {
if pos1!=i {
if pos2>0 {
ExecuteConsoleCommand(SubString(s,pos1,pos2)+SubString(ent,pos2,i),id)
}else{
ExecuteConsoleCommand(SubString(s,pos1,i),id)
}
}
pos1=i
pos2=0
}elseif pos2==0 and ch==" " {
pos2=i
}
i++
exitwhen i>=len
endloop
if pos2>0 {
ExecuteConsoleCommand(SubString(s,pos1,pos2)+SubString(ent,pos2,i),id)
}else{
ExecuteConsoleCommand(SubString(s,pos1,i),id)
}
}
private bool OnConsoleCommand_Conditions()
{
return SubString(GetEventPlayerChatString(), 0, 1) == "-"
}
private void OnConsoleCommand_Actions()
{
string ent=GetEventPlayerChatString()
integer id=GetPlayerId(GetTriggerPlayer())
parseCommands(ent,id)
}
public void postinit()
{
trigger t=CreateTrigger()
PauseTimer(GetExpiredTimer())
DestroyTimer(GetExpiredTimer())
TriggerRegisterPlayerChatEvent( t, Player(0), "-", false )
TriggerRegisterPlayerChatEvent( t, Player(1), "-", false )
TriggerRegisterPlayerChatEvent( t, Player(2), "-", false )
TriggerRegisterPlayerChatEvent( t, Player(3), "-", false )
TriggerRegisterPlayerChatEvent( t, Player(4), "-", false )
TriggerRegisterPlayerChatEvent( t, Player(5), "-", false )
TriggerRegisterPlayerChatEvent( t, Player(6), "-", false )
TriggerRegisterPlayerChatEvent( t, Player(7), "-", false )
TriggerRegisterPlayerChatEvent( t, Player(8), "-", false )
TriggerRegisterPlayerChatEvent( t, Player(9), "-", false )
TriggerRegisterPlayerChatEvent( t, Player(10), "-", false )
TriggerRegisterPlayerChatEvent( t, Player(11), "-", false )
TriggerAddCondition( t, Condition( function OnConsoleCommand_Conditions ) )
TriggerAddAction( t, function OnConsoleCommand_Actions )
t=null
//DisplayTextToPlayer(Player(0),0.,0.,"Now you may enter mode...")
debug LogAdd("Console: ready")
}
public void init()
{
TimerStart(CreateTimer(),.2,false,function postinit)
}
endlibrary
library_once RoundLimiter
private timer t=null
private void onReset()
{
PlaySoundBJ(gg_snd_Warnning)
if(mode_gameLimit>0 and FirstBuild_first!=null){
if(IsPlayerInForce(FirstBuild_first,leftPlayers)){
TriggerExecute(EndRoundScenario_OnRightCastleDies)
}else{
TriggerExecute(EndRoundScenario_OnLeftCastleDies)
}
return
}
TriggerExecute(EndRoundScenario_OnDraw)
}
private void onElasped1Minutes()
{
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,10.,"1 minute before round ends!")
TimerStart(t,60.,false,function onReset)
PlaySoundBJ(gg_snd_Warnning)
}
private void onElasped3Minutes()
{
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,10.,"3 minutes before round ends!")
TimerStart(t,120.,false,function onElasped1Minutes)
PlaySoundBJ(gg_snd_Warnning)
}
private void onElasped5Minutes()
{
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,10.,"Warnning! 5 minutes before round ends!")
TimerStart(t,120.,false,function onElasped3Minutes)
PlaySoundBJ(gg_snd_Warnning)
}
public void init()
{
if(t!=null){
PauseTimer(t)
}
if(mode_gameLimit!=0){
if(t==null){
t=CreateTimer()
}
TimerStart(t,(IAbsBJ(mode_gameLimit)-5)*60.,false,function onElasped5Minutes)
}
}
endlibrary
library_once Common initializer init uses Income, EndRoundScenario, UnitSmartBlocker, Console, AILibrary//, SpectatorController
private constant timer fowTimer=CreateTimer()
private bool canStartNewRound=false
public constant trigger Launcher=CreateTrigger()
public fogmodifier leftCastle
public fogmodifier rightCastle
public unit array workers
//public force awaitingPlayers=null
private void WakeUpSun()
{
FogEnable(false)
IsMapAllVisible=true
}
private void CreateGate(int gid){
int p
real x = -1440.
real y = 835.
unit u
if(gid==0) {p=0} else {p=6;x=0-x}
u = CreateUnit(Player(p),'h06A',x,y,0.)//open
SetUnitAnimation(u, "stand alternate")
Gates[gid+2] = u
SetUnitInvulnerable(u,true)
u = CreateUnit(Player(p),'h068',x,y,0.) //closed
SetUnitAnimation(u, "stand alternate")
ShowUnit(u,false)
Gates[gid]=u
u=null
}
private constant sound GateSnd=CreateSound("Sound\\Interface\\BattlenetDeath1.wav", false, false, false, 10, 10, "DefaultEAXON")
public void OnGateDeath(int fid)
{
GatesIM[fid] = 1.0
}
private void GateMsg(int gid, string s){
if(gid==0) { DisplayTextToForce(leftPlayers,s) }
else { DisplayTextToForce(rightPlayers,s) }
}
public void TeleportUnits(unit u, float x, float y)
{
unit j
player p = GetOwningPlayer(u);
group g = CreateGroup()
int n = 12;
GroupEnumUnitsInRange(g,GetUnitX(u),GetUnitY(u),850.,null)
loop
j=FirstOfGroup(g)
exitwhen (j==null or n <= 0)
GroupRemoveUnit(g,j)
if(IsUnitAlly(j,p) and GetWidgetLife(j)>.405 and not IsUnitType(j,UNIT_TYPE_STRUCTURE)){
n--
SetUnitX(j,x + GetRandomReal(-80,80))
SetUnitY(j,y + GetRandomReal(-80,80))
SetUnitFacing(j, GetRandomReal(-3.14,3.14))
TriggerSleepAction(0.06);
}
endloop
DestroyGroup(g)
g = null;
p = null;
j = null;
}
public void GateCtrl(int gid) { //toggles current gates
unit u = Gates[gid]
real hp = GetWidgetLife(u)
real mp
string s
if(hp < 0.405 or GatesPr[gid]) {u=null;return}
if( GatesIM[gid]<1.0 ) { //OPEN
GatesPr[gid] = true
SetUnitAnimation(u, "stand alternate")
StartSound(GateSnd)
TriggerSleepAction(2.2)
hp = GetWidgetLife(u)
ShowUnit(u,false)
u = Gates[gid+2]
SetUnitState(u, UNIT_STATE_LIFE,hp)
SetUnitState(u, UNIT_STATE_MANA,GetUnitState(Gates[gid],UNIT_STATE_MANA))
ShowUnit(u,true)
GateMsg(gid,"|cffFFCC00The Gates|r are opened!")
GatesIM[gid] = 1.0
GatesPr[gid] = false
} elseif(GetUnitState(Gates[gid+2],UNIT_STATE_MANA)>80.) { //CLOSE
GatesPr[gid] = true
hp = GetWidgetLife(Gates[gid+2])
ShowUnit(Gates[gid+2],false)
ShowUnit(u,true)
SetUnitState(u, UNIT_STATE_LIFE,hp)
SetUnitAnimation(u, "birth")
GatesIM[gid] = 0.3
StartSound(GateSnd)
SetUnitState(u, UNIT_STATE_MANA,GetUnitState(Gates[gid+2],UNIT_STATE_MANA))
TriggerSleepAction(5.0)
GateMsg(gid,"|cffFFCC00The Gates|r are closed!")
GatesPr[gid] = false
loop
TriggerSleepAction(1.0)
hp = GetWidgetLife(u)
if ( GetUnitState(u,UNIT_STATE_MANA) < 10.) {
GateCtrl(gid)
exitwhen true
}
exitwhen (hp < 0.405) or GatesPr[gid]
endloop
}
u=null
}
private void ProcessNewRound()
{
int i
unit u
player pl
player pr
real tv
bool hereHuman = false
currentRound++
RStrikeNextTicks = -1
UnitMostKills = 0
SplashW = 0
LogAdd("Round: "+I2S(currentRound))
/*if(isReplay){
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,10.,"Replay:"+Console_evaluteGameConfig())
}*/
//ClearTextMessages()
//SpectatorController_Apply()
FogEnable(true)
//
pl=ForcePickRandomPlayer(leftPlayers)
pr=ForcePickRandomPlayer(rightPlayers)
if(currentRound==1){
AILibrary_StartAllAI()
}
if(pl==null){pl=Player(0)}
if(pr==null){
pr=Player(6)
if(currentRound==1){
//p=ForcePickRandomPlayer(quotaPlayers)
ForceRemovePlayer(quotaPlayers,pr)
ForceAddPlayer(rightPlayers,pr)
CreateFogModifierRectBJ(true,pr,FOG_OF_WAR_VISIBLE,dummyArea)
startPosition[6]=StartPosition_GiveMeRespawn(false)//GetPlayerStartLocationLoc(p)
relayedForces[6]=CreateForce()
AILibrary_StartAI(6)
}
}
//
Multiboard_init()
AntiCaging_init()
DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,9.5,"Get ready for round |cffFFCC00"+I2S(currentRound)+"|r!")
CinematicFadeBJ(0,4.,"ReplaceableTextures\\CameraMasks\\Black_mask.blp",0,0,0,6.)
leftCastle=CreateFogModifierRectBJ(true,ForcePickRandomPlayer(leftPlayers),FOG_OF_WAR_VISIBLE,gg_rct_LeftPlayers)
rightCastle=CreateFogModifierRectBJ(true,ForcePickRandomPlayer(rightPlayers),FOG_OF_WAR_VISIBLE,gg_rct_RightPlayers)
EndRoundScenario_OnLeftCastleDies=CreateTrigger()
EndRoundScenario_OnRightCastleDies=CreateTrigger()
forcedCastle[0]=CreateUnitAtLoc(pl,'hcas',targetRectLoc[1],270.)
RegisterStructDmg(forcedCastle[0])
SetUnitX(forcedCastle[0],GetLocationX(targetRectLoc[1]))
SetUnitY(forcedCastle[0],GetLocationY(targetRectLoc[1]))
SetUnitColor(forcedCastle[0],PLAYER_COLOR_RED)
if(not mode_ia){
UnitRemoveAbility(forcedCastle[0],'Aall')
UnitRemoveAbility(forcedCastle[0],'Apit')
}
TriggerRegisterDeathEvent(EndRoundScenario_OnLeftCastleDies,forcedCastle[0])
forcedCastle[1]=CreateUnitAtLoc(pr,'hcas',targetRectLoc[0],270.)
RegisterStructDmg(forcedCastle[1])
SetUnitX(forcedCastle[1],GetLocationX(targetRectLoc[0]))
SetUnitY(forcedCastle[1],GetLocationY(targetRectLoc[0]))
SetUnitColor(forcedCastle[1],PLAYER_COLOR_GREEN)
if(not mode_ia){
UnitRemoveAbility(forcedCastle[1],'Aall')
UnitRemoveAbility(forcedCastle[1],'Apit')
}
TriggerRegisterDeathEvent(EndRoundScenario_OnRightCastleDies,forcedCastle[1])
TriggerAddAction(EndRoundScenario_OnLeftCastleDies, function EndRoundScenario_TrActOnLeft)
TriggerAddAction(EndRoundScenario_OnRightCastleDies, function EndRoundScenario_TrActOnRight)
if(mode_dom){Domination_init()}
TriggerSleepAction(3.)
TreeDeath_init()
NatureWispControl_init()
DamageControl_init()
UnitShareVision(forcedCastle[0],pr,true)
UnitShareVision(forcedCastle[1],pl,true)
TriggerSleepAction(1.)
UnitShareVision(forcedCastle[0],pr,false)
UnitShareVision(forcedCastle[1],pl,false)
UnitSmartBlocker_Start()
if(not mode_permamentRace or currentRound==1){
if(not mode_nafk){
AutoAFKControl_init()
}
RaceSelector_Reset()
if(mode_bans!=0){
if(mode_bans>0){
ExecuteFunc("Banner_Peon")
}else{
ExecuteFunc("RBanner_Peon")
}
loop
TriggerSleepAction(0.5)
exitwhen canStartNewRound
endloop
canStartNewRound=false
}
i=0
loop
peonsUID[i]=0
i++
exitwhen i>11
endloop
RaceSelector_ResetSaveRestrictions()
ExecuteFunc(peonCreator)
loop
TriggerSleepAction(0.5)
exitwhen canStartNewRound
endloop
canStartNewRound=false
RaceSelector_Finally()
}
mpRsCount[0]=0
mpRsCount[1]=0
RsActive[0]=0
RsActive[1]=0
mpDestrCount[0]=0
mpDestrCount[1]=0
//SetMBValue(3,1,"0")
//SetMBValue(3,2,"0")
/*mpIncomeCount[0]=0
mpIncomeCount[1]=0*/
//SetMBValue(4,1,"0")
//SetMBValue(4,2,"0")
i=0
loop
if(peonsUID[i]!=0){
DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\Resurrect\\ResurrectTarget.mdl",startPosition[i]))
LogAdd(I2S(i)+": "+RaceSelector_GetRaceName(peonsUID[i]))
}
i++
exitwhen i>11
endloop
TriggerSleepAction(0.5)
i=0
loop
if(peonsUID[i]!=0){
if(peonsUID[i]==peon_human){
hereHuman=true
}
//peonsUID[i]=GetUnitTypeId(peon[i])
//GroupAddUnit(peons,peon[i])
//create builders
u=CreateUnitAtLoc(Player(i),peonsUID[i],startPosition[i],180.*forceId[i])
workers[i]=u
//RemoveUnit(u)
//ShowUnit(peon[i],true)
//SetUnitPathing(peon[i],false)
GatesIM[0] = 1.0;GatesIM[1] = 1.0
if(mode_gates) {
GatesIM[0] = 0.99;GatesIM[1] = 0.99
UnitAddAbility(u,'A07C')
if (i == 0) {
CreateGate(0)
}
elseif (i == 6) {
CreateGate(1)
}
}
if(spawn_bstuff){
if (i == 0) { CreateItemLoc('I001',startPosition[0]) }
elseif (i == 6) { CreateItemLoc('I001',startPosition[6])}
}
if(not mode_rse){
UnitRemoveAbility(u,'A005')
UnitRemoveAbility(u,'A06E')
}else{
mpRsCount[forceId[i]]++
AssignSpectatorMultiboard(spectatorPosition[i],forceId[i]*6+1,"V")
}
//SelectUnitForPlayerSingle(peon[i],Player(i))
PanCameraToTimedLocForPlayer(Player(i),startPosition[i],.01)
SetPlayerState(Player(i),PLAYER_STATE_RESOURCE_GOLD,map_start_gold)
SetPlayerState(Player(i),PLAYER_STATE_RESOURCE_LUMBER,map_start_lumb)
if(mode_la){
SetPlayerState(Player(i),PLAYER_STATE_RESOURCE_FOOD_CAP,map_start_legn)
}else{
SetPlayerState(Player(i),PLAYER_STATE_RESOURCE_FOOD_CAP,0)
}
if(mpMBoard[i]!=null){
UnitAddAbility(u,'A0A5')
}
PrepareStatisticByPid(i)
}else{
ReleaseStatisticByPid(i)
}
i++
exitwhen i>11
endloop
//PlayersAdvStats_OnRoundStart()
SetMBValue(1,1,I2S(mpRsCount[0]))
SetMBValue(1,2,I2S(mpRsCount[1]))
//SetMBValue(2,1,"0")
//SetMBValue(2,2,"0")
if(mode_CI) {tv=1.0} else {tv=mode_incomeTime}
TimerStart(Income_Timer,tv,true,function Income_Action)
Coins_Start()
if(mode_fogtime!=-1){TimerStart(fowTimer,mode_fogtime,false,function WakeUpSun)}
//999999
GameTimeMinutes=0
GameTimeSeconds=0
Ticks = 0
NextTicks = 4
SpecialControl_lastRepGrUpd = -1
TimerStart(GameTime,0.25,true,function GameTimeExec)
TimerStart(tmrUpdCloneCap,CloneCapUpdInterval,true,function UpdCloneCap)
Functions_CheckAndStartSpecials()
Functions_CheckAndStartCommon()
FirstBuild_Reset()
//u=null
DrawControl_Reset()
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"Round |cffFFCC00"+I2S(currentRound)+"|r started! gl & hf!")
PlaySoundBJ(gg_snd_ToWar)
AILibrary_Reset()
RoundLimiter_init()
EndRoundScenario_enabled=true
u=null
SmartEventUnitAttacked_SetMode(hereHuman)
SpecialTimersControl_InternalControl(true)
AutoAFKControl_Reset()
if(mode_gates) { //open gates
//GateCtrl(0); GateCtrl(1)
GatesIM[0] = 1.0;GatesIM[1] = 1.0;
}
AssignSpectatorMultiboard(spectatorMultiboardClockPosition+1,0,"|cffFFCC00Modes:|r"+Console_evaluteGameConfig())
}
public void InitPools()
{
UnitPool_FillUnitPools()
}
public void RelisePoolsAndResume()
{
//clear builder avail a
canStartNewRound=true
}
public void RemoveUnitFromPools(int id, bool leftOwner)
{
if(mode_dualraces){
if(mode_ur){
UnitPool_remove(id,not leftOwner)
}
}else{
if(mode_ur){
UnitPool_remove(id,true)
UnitPool_remove(id,false)
}else{
UnitPool_remove(id,leftOwner)
}
}
}
public void init()
{
TriggerAddAction(Launcher,function ProcessNewRound)
}
endlibrary
library_once Banner uses Common
//define private second=Common_second
define private InitPools=Common_InitPools
//define private RemoveUnitFromPools=Common_RemoveUnitFromPools
define private RelisePoolsAndResume=Common_RelisePoolsAndResume
public void Peon()
{
timer pickTime
timerdialog pickTimerWindow
int variant
int banExecutions
player p
int peonId
int pid
InitPools()
pickTime=CreateTimer()
pickTimerWindow=CreateTimerDialog(pickTime)
TimerDialogSetTitle(pickTimerWindow,"Time to ban:")
TimerDialogDisplay(pickTimerWindow,true)
variant=GetRandomInt(0,1)
banExecutions=mode_bans*2
loop
if(variant==0){
p=FirstOfForce(leftPlayers)
variant=1
}else{
p=FirstOfForce(rightPlayers)
variant=0
}
pid=GetPlayerId(p)
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(pid)+", your turn to ban race now...")
TimerStart(pickTime,10.,false,null)
peonId=RaceSelector_GetRaceRefWithWaitTimeLimited(CreateUnit(p,'h09W',GetLocationX(startPosition[pid]),GetLocationY(startPosition[pid]),270.),15.)
if(peonId==peon_random){peonId=UnitPool_getRandom(pid<7)}
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(pid)+" has banned |cffFFFF00"+RaceSelector_GetRaceName(peonId))
UnitPool_remove(peonId,pid<7)
RaceSelector_ChangePossabilityFlagAll(peonId,false)
banExecutions--
exitwhen banExecutions<=0
endloop
DestroyTimerDialog(pickTimerWindow)
pickTimerWindow=null
PauseTimer(pickTime)
DestroyTimer(pickTime)
pickTime=null
Common_RelisePoolsAndResume()
}
endlibrary
library_once RBanner uses Common
define private InitPools=Common_InitPools
//define private RemoveUnitFromPools=Common_RemoveUnitFromPools
define private RelisePoolsAndResume=Common_RelisePoolsAndResume
public void Peon()
{
int banExecutions=IAbsBJ(mode_bans)
string s = ""
int peonId
InitPools()
loop
peonId=UnitPool_getRandom(true)
UnitPool_remove(peonId,true)
RaceSelector_ChangePossabilityFlagAll(peonId,false)
if(s==""){
s=RaceSelector_GetRaceName(peonId)
}else{
s=s+", "+RaceSelector_GetRaceName(peonId)
}
banExecutions--
exitwhen banExecutions<=0
endloop
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,s+" have banned by Random.")
Common_RelisePoolsAndResume()
}
endlibrary
library_once Random uses Common
define private first=Common_first
define private second=Common_second
define private InitPools=Common_InitPools
define private RemoveUnitFromPools=Common_RemoveUnitFromPools
define private RelisePoolsAndResume=Common_RelisePoolsAndResume
//zzz
public void Peon()
{
InitPools()
FillRPID()
int i=0
int plid
int rr
int n
int bidx
player p
if(currentRound==0) {
n=0
loop
SidePlayedCnt[n]=0
exitwhen n > 39
n++
endloop
}
loop
plid = RandPlID[i]
p=Player(plid)
n=0
if(IsPlayerInForce(p,leftPlayers)){
loop
rr=UnitPool_getRandom(true)
bidx = RaceSelector_BuilderId(rr)
exitwhen SidePlayedCnt[bidx]==0 or GetRandomInt(0,99)>89 or n>=24
n++
TriggerSleepAction(0.01)
endloop
RemoveUnitFromPools(rr,true)
SidePlayedCnt[bidx]++
peonsUID[plid]=rr
}elseif(IsPlayerInForce(p,rightPlayers)){
loop
rr=UnitPool_getRandom(false)
bidx = RaceSelector_BuilderId(rr)
exitwhen SidePlayedCnt[bidx+20]==0 or GetRandomInt(0,99)>89 or n>=24
n++
TriggerSleepAction(0.01)
endloop
RemoveUnitFromPools(rr,false)
SidePlayedCnt[bidx+20]++
peonsUID[plid]=rr
}
i++
exitwhen i>11
endloop
RelisePoolsAndResume()
}
endlibrary
library_once Draft uses Common
define private first=Common_first
define private second=Common_second
define private InitPools=Common_InitPools
define private RemoveUnitFromPools=Common_RemoveUnitFromPools
define private RelisePoolsAndResume=Common_RelisePoolsAndResume
private int history=-1
private void RemoveThisFromPool(int caller)
{
RemoveUnitFromPools(peonsUID[caller],IsPlayerInForce(Player(caller),leftPlayers))
if(mode_dualraces){
if(mode_ur){
RaceSelector_ChangePossabilityFlagTeam(peonsUID[caller],false,ModuloInteger(forceId[caller]+1,2))
}else{
}
}else{
if(mode_ur){
RaceSelector_ChangePossabilityFlagAll(peonsUID[caller],false)
}else{
RaceSelector_ChangePossabilityFlagTeam(peonsUID[caller],false,forceId[caller])
}
}
}
private void PeonExecuter()
{
trigger t=GetTriggeringTrigger()
timer pickTime
timerdialog pickTimerWindow
int leftq=0
int rightq=0
int variant
player varianted
int i=0
int pid
InitPools()
pickTime=CreateTimer()
pickTimerWindow=CreateTimerDialog(pickTime)
TimerDialogSetTitle(pickTimerWindow,"Time to select:")
TimerDialogDisplay(pickTimerWindow,true)
if(history<0){history=GetRandomInt(0,1)}
history=ModuloInteger(history+1,2)
variant=1+2*history
loop
peonsUID[i]=0
i++
exitwhen i>11
endloop
loop
varianted=null
if(variant<2){
loop
if(IsPlayerInForce(Player(leftq),leftPlayers)){
varianted=Player(leftq)
}
leftq++
exitwhen varianted!=null or leftq>11
endloop
}else{
loop
if(IsPlayerInForce(Player(rightq),rightPlayers)){
varianted=Player(rightq)
}
rightq++
exitwhen varianted!=null or rightq>11
endloop
}
variant++
if(variant>=4){variant=0}
exitwhen varianted==null and leftq>11 and rightq>11
if(varianted!=null){
pid=GetPlayerId(varianted)
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(pid)+" is selecting now...")
TimerStart(pickTime,15.,false,null)
peonsUID[pid]=RaceSelector_GetRaceRefWithWaitTimeLimited(CreateUnit(varianted,'h033',GetLocationX(startPosition[pid]),GetLocationY(startPosition[pid]),270.),15.)
if(peonsUID[pid]==peon_random){
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(pid)+" skipped selection.")
}else{
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(pid)+" controls |cffFFFF00"+RaceSelector_GetRaceName(peonsUID[pid])+"|r.")
RemoveThisFromPool(pid)
}
}
endloop
i=0
loop
if(peonsUID[i]==peon_random){
varianted=Player(i)
if(IsPlayerInForce(varianted,leftPlayers)){
peonsUID[i]=UnitPool_getRandom(true)
RemoveThisFromPool(i)
}elseif(IsPlayerInForce(varianted,rightPlayers)){
peonsUID[i]=UnitPool_getRandom(false)
RemoveThisFromPool(i)
}
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,GetColoredName(i)+" controls |cffFFFF00"+RaceSelector_GetRaceName(peonsUID[i])+"|r.")
}
i++
exitwhen i>11
endloop
DestroyTimerDialog(pickTimerWindow)
pickTimerWindow=null
PauseTimer(pickTime)
DestroyTimer(pickTime)
pickTime=null
Common_RelisePoolsAndResume()
TriggerClearActions(t)
DestroyTrigger(t)
t=null
}
public void Peon()
{
trigger t=CreateTrigger()
TriggerAddAction(t,function PeonExecuter)
TriggerExecute(t)
t=null
}
endlibrary
library_once Mirror uses Common
define private first=Common_first
define private second=Common_second
define private InitPools=Common_InitPools
define private RemoveUnitFromPools=Common_RemoveUnitFromPools
define private RelisePoolsAndResume=Common_RelisePoolsAndResume
public void Peon()
{
int i=0
int j=0
int array units
force f1
force f2
InitPools()
if(CountPlayersInForceBJ(leftPlayers)>=CountPlayersInForceBJ(rightPlayers)){
f1=leftPlayers
f2=rightPlayers
}else{
f1=rightPlayers
f2=leftPlayers
}
loop
if(IsPlayerInForce(Player(i),f1)){
//peon[i]=PlaceRandomUnit(first,Player(i),GetLocationX(startPosition[i]),GetLocationY(startPosition[i]),180.*forceId[i])
peonsUID[i]=UnitPool_getRandom(true)
//ShowUnit(peon[i],false)
if(not mode_dualraces){
//UnitPoolRemoveUnitType(first,GetUnitTypeId(peon[i]))
UnitPool_remove(peonsUID[i],true)
}
units[j]=peonsUID[i]
j++
}
i++
exitwhen i>11
endloop
i=0
j=0
loop
if(IsPlayerInForce(Player(i),f2)){
peonsUID[i]=units[j]
//ShowUnit(peon[i],false)
j++
}
i++
exitwhen i>11
endloop
f1=null
f2=null
RelisePoolsAndResume()
}
endlibrary
library_once Pick uses Common
define private first=Common_first
define private second=Common_second
define private InitPools=Common_InitPools
define private RemoveUnitFromPools=Common_RemoveUnitFromPools
define private RelisePoolsAndResume=Common_RelisePoolsAndResume
private int inSelect
private trigger onSelect
private void RemoveThisFromPool(int caller)
{
RemoveUnitFromPools(RaceSelector_selection[caller],IsPlayerInForce(Player(caller),leftPlayers))
if(mode_dualraces){
if(mode_ur){
RaceSelector_ChangePossabilityFlagTeam(RaceSelector_selection[caller],false,ModuloInteger(forceId[caller]+1,2))
}else{
}
}else{
if(mode_ur){
RaceSelector_ChangePossabilityFlagAll(RaceSelector_selection[caller],false)
}else{
RaceSelector_ChangePossabilityFlagTeam(RaceSelector_selection[caller],false,forceId[caller])
}
}
}
private bool OnSelect()
{
inSelect--
if(RaceSelector_selection[RaceSelector_callBackCode]==peon_random){
return false
}
RemoveThisFromPool(RaceSelector_callBackCode)
return false
}
private void PeonExecuter()
{
trigger t=GetTriggeringTrigger()
timer pickTime
timerdialog pickTimerWindow
unit array pickers
int i=0
player p
int peonId
int pid
InitPools()
pickTime=CreateTimer()
pickTimerWindow=CreateTimerDialog(pickTime)
TimerDialogSetTitle(pickTimerWindow,"Time to select:")
TimerDialogDisplay(pickTimerWindow,true)
onSelect=CreateTrigger()
TriggerAddCondition(onSelect,Condition(function OnSelect))
RaceSelector_callBack=onSelect
inSelect=0
loop
p=Player(i)
if(IsPlayerInForce(p,leftPlayers) or IsPlayerInForce(p,rightPlayers)){
pickers[i]=RaceSelector_GetRaceRef(CreateUnit(p,'h033',GetLocationX(startPosition[i]),GetLocationY(startPosition[i]),270.))
inSelect++
}
i++
exitwhen i>11
endloop
TimerStart(pickTime,10.,false,null)
loop
TriggerSleepAction(.33)
exitwhen TimerGetRemaining(pickTime)<.33 or inSelect<=0
endloop
TriggerClearConditions(onSelect)
DestroyTrigger(onSelect)
i=0
loop
p=Player(i)
if(IsPlayerInForce(p,leftPlayers) or IsPlayerInForce(p,rightPlayers)){
if(RaceSelector_selection[i]==peon_random or RaceSelector_selection[i]==0){
if(IsPlayerInForce(p,leftPlayers)){
RaceSelector_selection[i]=UnitPool_getRandom(true)
}elseif(IsPlayerInForce(p,rightPlayers)){
RaceSelector_selection[i]=UnitPool_getRandom(false)
}
RemoveThisFromPool(i)
}
peonsUID[i]=RaceSelector_selection[i]
}else{
peonsUID[i]=0
}
RemoveUnit(pickers[i])
pickers[i]=null
i++
exitwhen i>11
endloop
DestroyTimerDialog(pickTimerWindow)
pickTimerWindow=null
PauseTimer(pickTime)
DestroyTimer(pickTime)
pickTime=null
Common_RelisePoolsAndResume()
TriggerClearActions(t)
DestroyTrigger(t)
t=null
}
public void Peon()
{
trigger t=CreateTrigger()
TriggerAddAction(t,function PeonExecuter)
TriggerExecute(t)
t=null
}
endlibrary
//TESH.scrollpos=31
//TESH.alwaysfold=0
library DebugLog initializer DebugLogInit{
private string array DebugLog //8192 max
private int CurrentString = 0
private int LogN = 0
private int LL = 0
private constant int StringLimit = 200
void LogAdd(string s){
int l=StringLength(s)
int lp=0
loop
if(l+LL>StringLimit) {
DebugLog[CurrentString] = DebugLog[CurrentString] + SubString(s,lp,lp+StringLimit-LL)
lp +=StringLimit-LL
l-=StringLimit-LL
CurrentString++
LL=0
} else {
DebugLog[CurrentString] = DebugLog[CurrentString] + SubString(s,lp,8192)+ "\n"
LL+=l
l=0
}
exitwhen(l==0)
endloop
}
private int fn
void WriteLog(){
//if(CurrentString<=0) { return }
PreloadGenClear()
PreloadGenStart()
int i = 0
loop
exitwhen (i > CurrentString)
Preload("\")\r\n" + DebugLog[i] + "\r\n(\"")
//DebugLog[i] = ""
i++
endloop
PreloadGenEnd("Replay\\CF"+I2S(fn)+".log")
//LogN++
//LL=0
//CurrentString=0
}
private void DebugLogOnTimer(){
WriteLog()
}
private void DebugLogInit()
{
fn = GetRandomInt(0,100000)
//TimerStart(CreateTimer(), 15., true, function DebugLogOnTimer)
LogAdd("Castle Fight log")
WriteLog()
//LogAdd("Map compilation: " + `DATE` + " " + `TIME`)
}
}
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_OnUnitRevive_Actions takes nothing returns nothing
unit u=GetSummonedUnit()
int uid=GetUnitTypeId(u)
int sid=GetUnitTypeId(GetSummoningUnit())
real hp
//DisplayTextToPlayer(Player(0),0.,0.,"Revive evt:"+GetUnitName(u)+" < "+GetUnitName(su))
if(uid=='h03C'){ //paladin
SetUnitState(u,UNIT_STATE_MANA,GetRandomReal(20.,40.))
}elseif(GetUnitAbilityLevel(u,'A07M')>0){
GroupAddUnit(SpecialUnitsGroup,u)
}elseif(GetUnitAbilityLevel(u,'A07H')>0){ //legendaries cant be revived
if(sid!='n01P'){ //Hydra
RemoveUnit(u)
}
}elseif(sid=='h02X' or sid=='h02Y') { //Water elem summon
hp = 50.+GetUnitState(u,UNIT_STATE_MAX_LIFE)
//SetUnitState(u,UNIT_STATE_LIFE,hp*GetRandomReal(0.4,0.7))
SetUnitVertexColor(u,180,180,255,120)
TriggerSleepAction(0.5)
UnitApplyTimedLife(u,'BTLF',GetRandomReal(3.,5.))
}
AttackCreepOrderCommon(u)
u=null
endfunction
//===========================================================================
function InitTrig_OnUnitRevive takes nothing returns nothing
set gg_trg_OnUnitRevive = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_OnUnitRevive, EVENT_PLAYER_UNIT_SUMMON )
call TriggerAddAction( gg_trg_OnUnitRevive, function Trig_OnUnitRevive_Actions )
endfunction
//TESH.scrollpos=42
//TESH.alwaysfold=0
library_once Corrupted initializer init uses Functions
int tentacleType='n01C'//'n021'
define private Attached=Data_buildingAttacher
define private buildingCaster=Data_buildingCaster
define private unitCaster=Data_unitCaster
define private unitCasterTarget=Data_unitCasterTarget
/*
private void SpellEye()
{
unit c=CreateUnit(GetOwningPlayer(buildingCaster),'e008',GetUnitX(buildingCaster),GetUnitY(buildingCaster),0.)
UnitAddAbility(c,'A04S')
UnitApplyTimedLife(c,'BTLF',20.)
c=null
}*/
/*
private void SpellTentacle()
{
player p = GetOwningPlayer(buildingCaster)
unit u
filterPlayer = p
GroupEnumUnitsInRect(pickgroup,gg_rct_Area,filterVisibleEnemyGroundUnit) //bj_mapInitialPlayableArea or gg_rct_NCreg
bj_groupRandomConsidered = 0
bj_groupRandomCurrentPick = null
bj_groupRandomCurrentPick=GetRandomUnit(pickgroup)
if(bj_groupRandomCurrentPick==null){return}
if(UnitDispelMagic(bj_groupRandomCurrentPick)){return}
//'A0JG' //-25%AS
//'A0JH' //-5Armor
//'A0JI' //-30dmg
//'A0JJ' //-100MS
//'A0JK' //-200HP
UnitAddAbility(bj_groupRandomCurrentPick,'A0JG'+GetRandomInt(0,4))
UnitAddAbility(bj_groupRandomCurrentPick,'A0JL')
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\SpellSteal\\SpellStealTarget.mdl",bj_groupRandomCurrentPick,"overhead"))
u=null
}*/
private void SpellTentacle()
{
player p = GetOwningPlayer(buildingCaster)
unit u
filterPlayer = p
GroupEnumUnitsInRect(pickgroup,gg_rct_Area,filterVisibleEnemyGroundUnit) //bj_mapInitialPlayableArea or gg_rct_NCreg
bj_groupRandomConsidered = 0
bj_groupRandomCurrentPick = null
bj_groupRandomCurrentPick=GetRandomUnit(pickgroup)
if(bj_groupRandomCurrentPick==null){return}
if(GetUnitAbilityLevel(bj_groupRandomCurrentPick,'A06V')>0 or GetUnitAbilityLevel(bj_groupRandomCurrentPick,'Apit')>0){return}
int i=0
real x=GetUnitX(bj_groupRandomCurrentPick)
real y=GetUnitY(bj_groupRandomCurrentPick)
//real dx=GetUnitX(buildingCaster)-x
//real dy=GetUnitY(buildingCaster)-y
//real r = 150.0/(1.0+SquareRoot(dx*dx+dy*dy)*0.01*0.01)
TriggerSleepAction(GetRandomReal(0,0.5))
real an = GetRandomReal(0,6.28)
loop
u = CreateUnit(p,tentacleType,x+64.*Cos(an),y+64.*Sin(an),GetRandomReal(0,6.28))
//SetUnitState(u,UNIT_STATE_LIFE,r)
UnitApplyTimedLife(u,'BTLF',6.1)
an=an+1.257
i++
exitwhen i>=1
endloop
}
private void SpellWell()
{
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemyUnit)
bj_groupRandomConsidered = 0
bj_groupRandomCurrentPick = null
ForGroup(pickgroup, function GroupPickRandomUnitEnum)
if(bj_groupRandomCurrentPick==null){return}
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DeathPact\\DeathPactTarget.mdl",bj_groupRandomCurrentPick,"origin"))
if not UnitDispelMagic(bj_groupRandomCurrentPick){
UnitDamageTarget(buildingCaster,bj_groupRandomCurrentPick,GetRandomReal(120.,180.),true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_SONIC,WEAPON_TYPE_WHOKNOWS)
}
}
private void SpellAnnihilator()
{
player p=GetOwningPlayer(unitCaster)
real x=GetUnitX(unitCaster)
real y=GetUnitY(unitCaster)
real an=bj_RADTODEG*Atan2(GetUnitY(unitCasterTarget)-y,GetUnitX(unitCasterTarget)-x)-30.
int i=0
unit c
loop
c=CreateUnit(p,'e008',x,y,an)
UnitAddAbility(c,'A0AF')
IssuePointOrderById(c,852555,x+25.*Cos(an*bj_DEGTORAD),y+25.*Sin(an*bj_DEGTORAD))
UnitApplyTimedLife(c,'BTLF',1.8)
an+=15.
i++
exitwhen i>3
endloop
c=null
}
private bool Animationh04U()
{
Data_JoinUnitUnit(Attached,'h04J',191.,0.,0.)
return false
}
private bool Animationh09Y()
{
Data_JoinUnitUnit(Attached,'h09Z',270.,0.,0.)
return false
}
private bool Animationh04M()
{
SetUnitVertexColor(Attached,82,0,135,102)
return false
}
private bool Animationh04K()
{
Data_JoinUnitUnit(Attached,'h08I',0.,0.,0.)
return false
}
private void RegisterBuildings()
{
//tower
Data_RegisterTowerRange('n01J',800.)
//ents
Data_RegisterTrainOrder('h04V','n01I')
Data_RegisterTrainOrder('h04W','n01H')
Data_RegisterTrainOrder('h09Y','n027')
Data_RegisterAttachEffects('h09Y',function Animationh09Y)
//incub
Data_RegisterTrainOrder('h04U','h04I')
Data_RegisterAttachEffects('h04U',function Animationh04U)
//eye
//Data_RegisterBuildingSpell('h04T',function SpellEye)
//felhound
Data_RegisterTrainOrder('h04S','n01G')
//forgotten
Data_RegisterBuildingSpell('h04R',function SpellTentacle)
//gates
Data_RegisterTrainOrder('h04Q','n01F')
Data_RegisterTrainOrder('h04P','n01E')
//nether
Data_RegisterTrainOrder('h04O','n01D')
Data_RegisterTrainOrder('h04M','n01B')
Data_RegisterAttachEffects('h04M',function Animationh04M)
//void
Data_RegisterTrainOrder('h04L','n019')
Data_RegisterTrainOrder('h04N','n01A')
//well
Data_RegisterBuildingSpell('h04K',function SpellWell)
Data_RegisterAttachEffects('h04K',function Animationh04K)
}
private void RegisterLumberIncome()
{
Data_SetRace(RACE_CORRUPTED)
Data_RegisterBuilding('h04V',.2,true,0,false)
Data_RegisterBuilding('h04W',.2,true,'h04V',false)
Data_RegisterBuilding('h09Y',.2,false,'h04W',false)
Data_RegisterBuilding('h04U',.2,true,0,false)
Data_RegisterBuilding('h04S',.2,true,0,false)
Data_RegisterBuilding('h04Q',.18,true,0,true)
Data_RegisterBuilding('h04P',.18,true,'h04Q',true)
Data_RegisterBuilding('h04O',.2,true,0,false)
Data_RegisterBuilding('h04M',.2,true,'h04O',false)
Data_RegisterBuilding('h04L',.2,true,0,false)
Data_RegisterBuilding('h04N',.2,true,'h04L',false)
//
Data_RegisterBuilding('n01J',.10,false,0,false)
Data_RegisterBuilding('h04T',.12,false,0,false)
Data_RegisterBuilding('h04R',.09,false,0,false)
Data_RegisterBuilding('h04K',.09,false,0,false)
Data_RegisterBuilding('h008',.05,false,0,false) //TB
}
private void RegisterUnitCasts()
{
Data_RegisterUnitSpell('n027','A0AE',function SpellAnnihilator)
}
public void init()
{
RegisterBuildings()
RegisterLumberIncome()
RegisterUnitCasts()
}
endlibrary
//TESH.scrollpos=45
//TESH.alwaysfold=0
library_once Human initializer init uses Functions
public constant group Artillery = CreateGroup()
define private Attached=Data_buildingAttacher
define private buildingCaster=Data_buildingCaster
define private unitCaster=Data_unitCaster
define private unitCasterTarget=Data_unitCasterTarget
private boolexpr filterAlliedUnit
private void SpellHorn()
{
real x=GetUnitX(buildingCaster)
real y=GetUnitY(buildingCaster)
unit u
unit c
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Other\\HowlOfTerror\\HowlCaster.mdl",x,y))
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRange(pickgroup,x,y,510.,filterAlliedUnit)
loop
u = FirstOfGroup(pickgroup)
exitwhen(u==null)
GroupRemoveUnit(pickgroup,u)
c=CreateUnit(filterPlayer,'e008',GetUnitX(u),GetUnitY(u),0.)
UnitAddAbility(c,'A016')
if(GetUnitAbilityLevel(u,'B039')>0) {SetUnitAbilityLevel(c,'A016',2)}
else { if(GetUnitAbilityLevel(u,'B03A')>0 or GetUnitAbilityLevel(u,'B03B')>0) {SetUnitAbilityLevel(c,'A016',3)} }
IssueTargetOrderById(c,852101,u)
UnitApplyTimedLife(c,'BTLF',1.)
endloop
u = null
c = null
}
private void SpellRiderBuff()
{
unit u=unitCaster
IssueTargetOrderById(u,852066,unitCasterTarget)
TriggerSleepAction(1.)
AttackCreepOrder(u)
u=null
}
private boolexpr spellRiderBuffATargets
private bool SpellRiderBuffATargets()
{
unit u=GetFilterUnit()
bool res=IsUnitAlly(u,filterPlayer) and GetWidgetLife(u)<=.405 and not IsUnitType(u,UNIT_TYPE_MECHANICAL)
u=null
return res
}
private void SpellPrayer()
{
unit u=unitCaster
unit c
int i = 4
player p=GetOwningPlayer(u)
c=CreateUnit(p,'e008',GetUnitX(u),GetUnitY(u),0.)
UnitAddAbility(c,'A0I1')
UnitAddAbility(c,'A0I2')
UnitAddAbility(c,'A0I3')
SetUnitAbilityLevel(c,'A0I3',GetRandomInt(1,3))
IssueImmediateOrderById(c,order_roar)
TriggerSleepAction(0.1)
IssueImmediateOrderById(u,852282)
TriggerSleepAction(0.1)
filterPlayer=p
GroupEnumUnitsInRange(pickgroup,GetUnitX(c),GetUnitY(c),450.,spellRiderBuffATargets)
if(FirstOfGroup(pickgroup)!=null){
IssueImmediateOrderById(c,order_resurrection)
}
UnitApplyTimedLife(c,'BTLF',1.2)
TriggerSleepAction(1.0)
AttackCreepOrder(u)
u=null
c=null
}
private void SpellRiderBuffA()
{
unit u=unitCaster
IssueTargetOrderById(u,852066,unitCasterTarget)
UnitAddAbility(unitCasterTarget,'A03L')//+100hp
TriggerSleepAction(0.8)
filterPlayer=GetOwningPlayer(u)
GroupEnumUnitsInRange(pickgroup,GetUnitX(u),GetUnitY(u),650.,spellRiderBuffATargets)
if(FirstOfGroup(pickgroup)!=null){
IssueImmediateOrderById(u,852094)
TriggerSleepAction(0.8)
}
AttackCreepOrder(u)
u=null
}
private void SpellWarlock()
{
//unit u=unitCaster
//filterPlayer=GetOwningPlayer(u)
//GroupEnumUnitsInRange(pickgroup,GetUnitX(u),GetUnitY(u),370.,filterWST)
//ForGroup(pickgroup,function wsDmg)
unit u=CreateUnit(GetOwningPlayer(unitCaster),'e008',GetUnitX(unitCaster),GetUnitY(unitCaster),0.)
UnitAddAbility(u,'A0EU')
//DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"ws2")
//IssueImmediateOrderById(u,852226)//852526
IssueTargetOrderById(u,852226,unitCasterTarget)
UnitApplyTimedLife(u,'BTLF',1.)
u=unitCaster
UnitRemoveAbility(u,'A00F') // that warlock have spell
UnitAddAbility(u,'A07I') // now unit will ignore re-order
SetUnitState(u,UNIT_STATE_LIFE,GetUnitState(u,UNIT_STATE_LIFE)-35.)
TriggerSleepAction(GetRandomReal(0.3,0.5))
FleeCreepOrder(u)
TriggerSleepAction(6.5)
if(GetUnitAbilityLevel(u,'A00F')<=0){ // FIX http://castle-fight.net.ru/forum/viewtopic.php?f=40&t=474
IssueImmediateOrderById(u,851993)
TriggerSleepAction(7.5)
if(GetUnitAbilityLevel(u,'A00F')<=0){
UnitAddAbility(u,'A00F')
UnitRemoveAbility(u,'A07I') // unit will be ordered
UnitAddAbility(u,'A0EZ') // forcing ability strike for future
AttackCreepOrder(u)
}
}
u=null
}
private bool Animationh0A1()
{
SetUnitVertexColor(Attached,255,255,255,0)
Data_JoinUnitUnit(Attached,'h0A0',170.,31.25,-43.)
Data_JoinUnitUnit(Attached,'h0A0',80.,-38.,-40.25)
Data_JoinUnitUnit(Attached,'h0A0',350.,-30.25,30.)
Data_JoinUnitUnit(Attached,'h08Z',220.,43.,27.5)
return false
}
private void RegisterBuildings()
{
//footmans
Data_RegisterTrainOrder('h000','hfoo')
Data_RegisterTrainOrder('h039','h03A')
//snipers
Data_RegisterTrainOrder('h003','hrif')
Data_RegisterTrainOrder('h0A1','h05C')
Data_RegisterAttachEffects('h0A1',function Animationh0A1)
Data_RegisterTrainOrder('h05D','h0A2')
//mortires
Data_RegisterTrainOrder('h004','hmtm')
//tower
Data_RegisterTowerRange('h006',950.)
//warlocks
Data_RegisterTrainOrder('h00K','n005')
//horn
Data_RegisterTowerRange('h010',500.)
Data_RegisterBuildingSpell('h010',function SpellHorn)
//gryphons
Data_RegisterTrainOrder('h015','h016')
//chapel
Data_RegisterTrainOrder('h037','h03B')
Data_RegisterTrainOrder('h038','h03C')
Data_RegisterTrainOrder('h072','h074')
}
private void RegisterLumberIncome()
{
Data_SetRace(RACE_HUMAN)
Data_RegisterBuilding('h037',.2,true,0,false)
Data_RegisterBuilding('h038',.2,true,'h037',false)
Data_RegisterBuilding('h072',.2,true,'h038',false)
Data_RegisterBuilding('h015',.2,true,0,false)
Data_RegisterBuilding('h00K',.2,true,0,false)
Data_RegisterBuilding('h004',.18,true,0,true)
Data_RegisterBuilding('h003',.2,true,0,false) //snip
Data_RegisterBuilding('h000',.2,true,0,false) //foot
Data_RegisterBuilding('h039',.2,true,'h000',false)
Data_RegisterBuilding('h0A1',.2,true,'h003',false)
Data_RegisterBuilding('h05D',.2,true,'h003',false)
//
Data_RegisterBuilding('h001',.09,false,0,false)
Data_RegisterBuilding('h006',.10,false,0,false)
Data_RegisterBuilding('h010',.12,false,0,false)
Data_RegisterBuilding('h05G',.12,false,0,false)
Data_RegisterBuilding('h008',.05,false,0,false) //TB
}
private void RegisterUnitCasts()
{
Data_RegisterUnitSpell('h03B','A03K',function SpellRiderBuff)
Data_RegisterUnitSpell('h03C','A03K',function SpellRiderBuffA)
Data_RegisterUnitSpell('h074','A0I0',function SpellPrayer)
Data_RegisterUnitSpell('n005','A00K',function SpellWarlock)
}
public void CorrectArtillery(unit u)
{
real x = GetRandomReal(2000.0,5700.0)
real y = GetRandomReal(-2200.0,2200.0)
if(GetPlayerId(GetOwningPlayer(u))>5) {x=-x}
IssuePointOrderById(u,order_attackground,x,y)
}
private void artilleryFire()
{
CorrectArtillery(GetEnumUnit())
}
private void artilleryFireTimer()
{
ForGroup(Artillery,function artilleryFire)
}
public void InvokeShrineActions(unit u)
{
//GroupAddUnit(chanceToCloneUnit[forceId[GetPlayerId(GetOwningPlayer(u))]],u)
int f=GetPlayerId(GetOwningPlayer(u))
chanceToCloneUnit[f]++
}
public void OnShrineDeath(unit u)
{
//GroupRemoveUnit(chanceToCloneUnit[forceId[GetPlayerId(GetOwningPlayer(u))]],u)
int f=GetPlayerId(GetOwningPlayer(u))
chanceToCloneUnit[f]--
}
private bool FilterAlliedUnit()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>.405 and IsUnitAlly(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER) and not IsUnitType(u,UNIT_TYPE_MECHANICAL) and not IsUnitType(u,UNIT_TYPE_UNDEAD)
u=null
return res
}
public void init()
{
RegisterBuildings()
RegisterLumberIncome()
RegisterUnitCasts()
TimerStart(CreateTimer(),11.,true, function artilleryFireTimer)
//filterShrine=Filter(function FilterShrine)
spellRiderBuffATargets=Filter(function SpellRiderBuffATargets)
filterAlliedUnit=Filter(function FilterAlliedUnit)
}
endlibrary
//TESH.scrollpos=71
//TESH.alwaysfold=0
library_once Orc initializer init uses Utils
define private Attached=Data_buildingAttacher
define private buildingCaster=Data_buildingCaster
define private unitCaster=Data_unitCaster
define private unitCasterTarget=Data_unitCasterTarget
private bool filterAlliedUnitParamA
private boolexpr filterAlliedUnit
private bool FilterAlliedUnit()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>.405 and IsUnitAlly(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER) and (filterAlliedUnitParamA or GetUnitAbilityLevel(u,'A0F1')<=0)
u=null
return res
}
//A0F1
private void SpellTotem()
{
filterPlayer=GetOwningPlayer(buildingCaster)
filterAlliedUnitParamA=false
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterAlliedUnit)
bj_groupRandomCurrentPick=GetRandomUnit(pickgroup)
if(bj_groupRandomCurrentPick==null){
filterAlliedUnitParamA=true
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterAlliedUnit)
bj_groupRandomCurrentPick=GetRandomUnit(pickgroup)
if(bj_groupRandomCurrentPick==null){
return
}
}
UnitAddAbility(bj_groupRandomCurrentPick,'A03B') //IaS
UnitAddAbility(bj_groupRandomCurrentPick,'A03A') //+Dmg
if(GetUnitAbilityLevel(bj_groupRandomCurrentPick,'A03D')<=0) {
UnitAddAbility(bj_groupRandomCurrentPick,'A03D') //+HP
}
UnitAddAbility(bj_groupRandomCurrentPick,'A08L') //+4Armor
int i=GetRandomInt(1,3)
if(i==1){
UnitAddAbility(bj_groupRandomCurrentPick,'A05I') //+crit
UnitAddAbility(bj_groupRandomCurrentPick,'A06W')
}elseif(i==2){
UnitAddAbility(bj_groupRandomCurrentPick,'A0JA')//+evade30% was 'A08M'
UnitAddAbility(bj_groupRandomCurrentPick,'A06Y')
}else{
UnitAddAbility(bj_groupRandomCurrentPick,'A08R')//+
UnitAddAbility(bj_groupRandomCurrentPick,'A06X')
}
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\ReplenishHealth\\ReplenishHealthCasterOverhead.mdl",bj_groupRandomCurrentPick,"overhead"))
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl",GetUnitX(buildingCaster),GetUnitY(buildingCaster)))
}
private void SpellStatis()
{
unit b = buildingCaster
unit c
SetUnitAnimation(b,"stand alternate")
TriggerSleepAction(GetRandomReal(0.1,11.1))
c=CreateUnit(GetOwningPlayer(b),'e008',GetUnitX(b),GetUnitY(b),0.)
UnitAddAbility(c,'A031')
IssueImmediateOrderById(c,852127)
UnitApplyTimedLife(c,'BTLF',1.)
SetUnitState(b,UNIT_STATE_MANA,GetUnitState(b,UNIT_STATE_MANA)+GetRandomReal(1.,6.))
SetUnitAnimation(b,"stand")
c=null; b=null
}
private void SpellSerpent()
{
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemyUnit)
bj_groupRandomConsidered = 0
bj_groupRandomCurrentPick = null
ForGroup(pickgroup, function GroupPickRandomUnitEnum)
if(bj_groupRandomCurrentPick==null){return}
unit c=CreateUnit(GetOwningPlayer(buildingCaster),'e008',GetUnitX(buildingCaster),GetUnitY(buildingCaster),0.)
UnitAddAbility(c,'A030')
UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,true)
IssueTargetOrderById(c,852662,bj_groupRandomCurrentPick)
UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,false)
UnitApplyTimedLife(c,'BTLF',30.)
c=buildingCaster
TriggerSleepAction(.5)
SetUnitAnimation(c,"attack")
TriggerSleepAction(1.)
SetUnitAnimation(c,"stand")
c=null
}
private void SpellTroll()
{
unit c
c=CreateUnit(GetOwningPlayer(unitCaster),'e008',GetUnitX(unitCaster),GetUnitY(unitCaster),0.)
UnitAddAbility(c,'A06H')
if(GetUnitAbilityLevel(unitCasterTarget,'A07H')>0){SetUnitAbilityLevel(c,'A06H',2)}
IssueTargetOrderById(c,852106,unitCasterTarget)
UnitApplyTimedLife(c,'BTLF',1.0)
c=null
}
private void SpellVooDoo(){
real k = 0.5
if(GetUnitAbilityLevel(unitCasterTarget,'A07H')>0) { k = 0.8 }
SetUnitState(unitCasterTarget,UNIT_STATE_LIFE,GetUnitState(unitCasterTarget,UNIT_STATE_LIFE)*k-70.)
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Orc\\AncestralSpirit\\AncestralSpiritCaster.mdl",unitCasterTarget,"overhead"))
UnitAddAbility(unitCasterTarget,'A0J9')
}
private void RegisterBuildings()
{
//totem
Data_RegisterBuildingSpell('h02R',function SpellTotem)
//fly
Data_RegisterTrainOrder('h02P','o009')
//codo
Data_RegisterTrainOrder('h02K','o007')
Data_RegisterTrainOrder('h092','o00B')
Data_RegisterTrainOrder('h035','o008')
Data_RegisterTrainOrder('h036','o006')
//statis
Data_RegisterBuildingSpell('h02O',function SpellStatis)
//serpent
Data_RegisterBuildingSpell('h02N',function SpellSerpent)
//grunt
Data_RegisterTrainOrder('h029','o002')
Data_RegisterTrainOrder('h02U','o004')
Data_RegisterTrainOrder('h031','o005')
//shamans
Data_RegisterTrainOrder('h02B','o003')
Data_RegisterTrainOrder('h06E','o00F')
//catapult
Data_RegisterTrainOrder('h02I','o001')
//tower
Data_RegisterTowerRange('o000',900.)
//troll
Data_RegisterTrainOrder('h02H','n00V')
Data_RegisterTrainOrder('h05E','n01O')
}
private void RegisterLumberIncome()
{
Data_SetRace(RACE_ORC)
Data_RegisterBuilding('h02P',.2,true,0,false)
Data_RegisterBuilding('h02K',.2,true,0,false)//kodo
Data_RegisterBuilding('h092',.2,true,'h02K',false)
Data_RegisterBuilding('h035',.2,true,'h02K',false)
Data_RegisterBuilding('h036',.2,true,'h02K',false)
Data_RegisterBuilding('h029',.2,true,0,false)//gru
Data_RegisterBuilding('h02U',.2,true,'h029',false)
Data_RegisterBuilding('h031',.2,true,'h02U',false)
Data_RegisterBuilding('h02B',.2,true,0,false)
Data_RegisterBuilding('h06E',.2,true,'h02B',false)
Data_RegisterBuilding('h02I',.18,true,0,true)
Data_RegisterBuilding('h02H',.2,true,0,false)
Data_RegisterBuilding('h05E',.2,true,'h02H',false)
//
Data_RegisterBuilding('h02R',.12,false,0,false)
Data_RegisterBuilding('h02O',.12,false,0,false)
Data_RegisterBuilding('o000',.10,false,0,false)
Data_RegisterBuilding('h02N',.09,false,0,false)
Data_RegisterBuilding('h008',.05,false,0,false) //TB
}
private void RegisterUnitCasts()
{
Data_RegisterUnitSpell('n01O','A06I',function SpellTroll)
Data_RegisterUnitSpell('o00F','A0J8',function SpellVooDoo)
}
public void init()
{
RegisterBuildings()
RegisterLumberIncome()
RegisterUnitCasts()
filterAlliedUnit=Filter(function FilterAlliedUnit)
}
endlibrary
//TESH.scrollpos=24
//TESH.alwaysfold=0
library_once Naga initializer init uses Functions
define private Attached=Data_buildingAttacher
define private buildingCaster=Data_buildingCaster
define private unitCaster=Data_unitCaster
define private unitCasterTarget=Data_unitCasterTarget
private void SpellTidal()
{
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemyUnit)
bj_groupRandomConsidered = 0
bj_groupRandomCurrentPick = null
//ForGroup(pickgroup, function GroupPickRandomUnitEnum)
bj_groupRandomCurrentPick=GetRandomUnit(pickgroup)
if(bj_groupRandomCurrentPick==null){return}
unit c=CreateUnit(GetOwningPlayer(buildingCaster),'e008',GetUnitX(buildingCaster),GetUnitY(buildingCaster),0.)
UnitAddAbility(c,'A00P')
UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,true)
IssueTargetOrderById(c,852218,bj_groupRandomCurrentPick)
UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,false)
UnitApplyTimedLife(c,'BTLF',15.)
c=null
}
private void SpellOracl()
{
unit u
player pl
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemyUnit)
bj_groupRandomConsidered = 0
bj_groupRandomCurrentPick = null
//ForGroup(pickgroup, function GroupPickRandomUnitEnum)
bj_groupRandomCurrentPick=GetRandomUnit(pickgroup)
if(bj_groupRandomCurrentPick==null or UnitDispelMagic(bj_groupRandomCurrentPick)){return}
u = bj_groupRandomCurrentPick
pl = GetOwningPlayer(u)
SetUnitOwner(u,filterPlayer,true)
DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Naga\\NagaDeath\\NagaDeath.mdl",u,"overhead"))
if(GetRandomReal(0, 99) > 85 - GetWidgetLife(u)*0.030){
//SetUnitState(buildingCaster,UNIT_STATE_MANA, GetRandomReal(1.,5.))
TriggerSleepAction(GetRandomReal(2.0,6.0))
DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Naga\\NagaDeath\\NagaDeath.mdl",u,"overhead"))
SetUnitOwner(u,pl,true)
}
u = null
//DisplayTextToPlayer(filterPlayer,0,0,"Oracle controls "+GetUnitName(bj_groupRandomCurrentPick))
//unit c=CreateUnit(GetOwningPlayer(buildingCaster),'e008',GetUnitX(bj_groupRandomCurrentPick),GetUnitY(bj_groupRandomCurrentPick),0.)
//UnitAddAbility(c,'A00N')
//UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,true)
//IssueTargetOrderById(c,852581,bj_groupRandomCurrentPick)
//UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,false)
//UnitApplyTimedLife(c,'BTLF',1.5)
//c=null
}
private bool AttachCoralCaster(){
Data_JoinUnitUnit(Attached,'e00K',0.,0.,40.)
return false
}
private void SpellRestore(){
unit u //= CreateUnit(GetOwningPlayer(buildingCaster),'e008',GetUnitX(buildingCaster),GetUnitY(buildingCaster),0.)
u = LoadUnitHandle(tableJU,GetHandleId(buildingCaster),0)
//UnitAddAbility(u,'A0IO')
IssueTargetOrderById(u,order_healingwave,GetSpellTargetUnit())
//UnitApplyTimedLife(u,'BTLF',1.)
u=null
}
private void SpellPyramid()
{
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemyGroundUnit)
bj_groupRandomConsidered = 0
bj_groupRandomCurrentPick = null
//ForGroup(pickgroup, function GroupPickRandomUnitEnum)
bj_groupRandomCurrentPick=GetRandomUnit(pickgroup)
if(bj_groupRandomCurrentPick==null){return}
unit c=CreateUnit(filterPlayer,'e008',GetUnitX(bj_groupRandomCurrentPick),GetUnitY(bj_groupRandomCurrentPick),0.)
UnitAddAbility(c,'A00B')
IssueImmediateOrderById(c,852096)
UnitApplyTimedLife(c,'BTLF',1.)
c=null
}
private void SpellSirena()
{
unit c=CreateUnit(GetOwningPlayer(unitCaster),'e008',GetUnitX(unitCaster),GetUnitY(unitCaster),0.)
UnitAddAbility(c,'A02T')
IssueTargetOrderById(c,852111,unitCasterTarget)
UnitApplyTimedLife(c,'BTLF',2.)
c=unitCaster
TriggerSleepAction(1.)
if(IssueImmediateOrderById(c,852126)){
TriggerSleepAction(1.)
}
AttackCreepOrder(c)
c=null
}
private void RegisterBuildings()
{
//sirena
Data_RegisterTrainOrder('h01Z','n00S')
//tidal
Data_RegisterBuildingSpell('h00N',function SpellTidal)
//oracl
Data_RegisterBuildingSpell('h00M',function SpellOracl)
//coral
Data_RegisterAttachEffects('h00G',function AttachCoralCaster)
Data_RegisterBuildingSpell('h00G',function SpellRestore)
//swamp
Data_RegisterTrainOrder('h00J','n004')
Data_RegisterTrainOrder('h05F','n01P')
//reptile
Data_RegisterTrainOrder('h01B','n007')
//pyramid
Data_RegisterBuildingSpell('h00I',function SpellPyramid)
//murlocks
//Data_RegisterTrainOrder('h00H','n003')
Data_RegisterTrainOrder('h020','n00I')
Data_RegisterTrainOrder('h021','n00J')
Data_RegisterTrainOrder('h022','n00K')
//coral
Data_RegisterTowerRange('h00G',650.)
//serpent
Data_RegisterTrainOrder('h01Y','n00H')
//naga
Data_RegisterTrainOrder('h00F','n002')
Data_RegisterTrainOrder('h032','n00X')
}
private void RegisterLumberIncome()
{
Data_SetRace(RACE_NAGA)
Data_RegisterBuilding('h01Z',.2,true,0,false)
Data_RegisterBuilding('h00J',.2,true,0,false)//sump
Data_RegisterBuilding('h05F',.2,false,'h00J',false)
Data_RegisterBuilding('h01B',.18,true,0,true)
Data_RegisterBuilding('h020',.2,true,0,false)//mur
Data_RegisterBuilding('h021',.2,true,'h020',false)
Data_RegisterBuilding('h022',.2,true,'h021',false)
Data_RegisterBuilding('h01Y',.2,true,0,false)
Data_RegisterBuilding('h00F',.2,true,0,false)
Data_RegisterBuilding('h032',.2,true,'h00F',false)
//
Data_RegisterBuilding('h00N',.09,false,0,false)
Data_RegisterBuilding('h00I',.18,false,0,false)
Data_RegisterBuilding('h00M',.18,false,0,false)
Data_RegisterBuilding('h00G',.00,false,0,false)
Data_RegisterBuilding('h008',.05,false,0,false) //TB
}
private void RegisterUnitCasts()
{
Data_RegisterUnitSpell('n00S','A02U',function SpellSirena)
}
public void init()
{
RegisterBuildings()
RegisterLumberIncome()
RegisterUnitCasts()
}
endlibrary
//TESH.scrollpos=13
//TESH.alwaysfold=0
library_once Nothern initializer init uses Functions
define private Attached=Data_buildingAttacher
define private buildingCaster=Data_buildingCaster
define private unitCaster=Data_unitCaster
define private unitCasterTarget=Data_unitCasterTarget
private boolexpr filterEnemyAirUnit
private bool FilterEnemyAirUnit()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>.405 and IsUnitEnemy(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER) and IsUnitType(u,UNIT_TYPE_FLYING)
u=null
return res
}
private void SpellMushroom()
{
unit c
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemyAirUnit)
bj_groupRandomConsidered = 0
bj_groupRandomCurrentPick = null
ForGroup(pickgroup, function GroupPickRandomUnitEnum)
if(bj_groupRandomCurrentPick==null or UnitDispelMagic(bj_groupRandomCurrentPick)){return}
c=CreateUnit(filterPlayer,'e008',GetUnitX(buildingCaster),GetUnitY(buildingCaster),0.)
UnitAddAbility(c,'A0AK')
UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,true)
UnitApplyTimedLife(c,'BTLF',6.)
IssueTargetOrderById(c,852095,bj_groupRandomCurrentPick)
c=bj_groupRandomCurrentPick
TriggerSleepAction(2.0)
UnitShareVision(c,filterPlayer,false)
c=null
}
boolexpr filterEnemyBuildingUnit
//private constant player impPlayer = Player(12)
private bool FilterEnemyBuildingUnit()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>.405 and IsUnitEnemy(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_STRUCTURE) and GetPlayerId(GetOwningPlayer(u))<12 and GetUnitTypeId(u)!='hcas'
u=null
return res
}
private void SpellFrost()
{
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemyBuildingUnit)
bj_groupRandomCurrentPick = null
bj_groupRandomCurrentPick = GetRandomUnit(pickgroup)
//ForGroup(pickgroup, function GroupPickRandomUnitEnum)
if(bj_groupRandomCurrentPick==null){return}
real x=GetUnitX(bj_groupRandomCurrentPick)
real y=GetUnitY(bj_groupRandomCurrentPick)
DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\Naga\\NagaDeath\\NagaDeath.mdl",GetUnitX(buildingCaster),GetUnitY(buildingCaster)))
unit c=CreateUnit(filterPlayer,'h04G',x,y,0.)
UnitApplyTimedLife(c,'BTLF',1.0)
/*
if(IsMapAllVisible){
IssueTargetOrderById(c,851983,bj_groupRandomCurrentPick)
}else{
fogmodifier f=CreateFogModifierRadius(filterPlayer,FOG_OF_WAR_VISIBLE,GetUnitX(bj_groupRandomCurrentPick),GetUnitY(bj_groupRandomCurrentPick),130.,true,false)
FogModifierStart(f)
IssueTargetOrderById(c,851983,bj_groupRandomCurrentPick)
TriggerSleepAction(.2)
DestroyFogModifier(f)
f=null
}*/
c=null
}
private void SpellFrostGreater()
{
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemyBuildingUnit)
bj_groupRandomConsidered = 0
bj_groupRandomCurrentPick = null
bj_groupRandomCurrentPick = GetRandomUnit(pickgroup)
if(bj_groupRandomCurrentPick==null){return}
real x=GetUnitX(bj_groupRandomCurrentPick)
real y=GetUnitY(bj_groupRandomCurrentPick)
DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\Naga\\NagaDeath\\NagaDeath.mdl",GetUnitX(buildingCaster),GetUnitY(buildingCaster)))
unit c=CreateUnit(filterPlayer,'h04H',x,y,0.)
UnitApplyTimedLife(c,'BTLF',1.0)
/*
if(IsMapAllVisible){
IssueTargetOrderById(c,851983,bj_groupRandomCurrentPick)
}else{
fogmodifier f=CreateFogModifierRadius(filterPlayer,FOG_OF_WAR_VISIBLE,GetUnitX(bj_groupRandomCurrentPick),GetUnitY(bj_groupRandomCurrentPick),128.,true,false)
FogModifierStart(f)
IssueTargetOrderById(c,851983,bj_groupRandomCurrentPick)
TriggerSleepAction(.1)
DestroyFogModifier(f)
f=null
}*/
c=null
}
private constant timer SpellWorldFreezerTimer=CreateTimer()
private unit array WF_Balls
private real array FB_dx
private real array FB_dy
private int WF_BallsCnt=0
private weathereffect SpellWorldFreezerWeather
private real mminx
private real mmaxx
private real mminy
private real mmaxy
private void FlyIceBall()
{
int i=0
real x
real y
unit u
unit c
loop
exitwhen i>=WF_BallsCnt
u=WF_Balls[i]
x=GetUnitX(u)+FB_dx[i]
if(x>=mmaxx or x<=mminx or GetWidgetLife(u)<.405){
//GroupRemoveUnit(dummyGroupContainer,u)
RemoveUnit(u)
WF_BallsCnt--
WF_Balls[i]=WF_Balls[WF_BallsCnt]
}else{
y=GetUnitY(u)+FB_dx[i]*Sin(FB_dy[i])
if(y > 1300.) {y=y-15.}
elseif(y < -1300.) {y=y+15.}
FB_dy[i] = FB_dy[i] + 0.033
SetUnitX(u,x)
SetUnitY(u,y)
if(GetRandomInt(0,100)>96){ //freeze something
filterPlayer=GetOwningPlayer(u)
GroupEnumUnitsInRange(pickgroup,x,y,450.,filterEnemyUnit)
bj_groupRandomConsidered = 0
bj_groupRandomCurrentPick = null
ForGroup(pickgroup, function GroupPickRandomUnitEnum)
if(bj_groupRandomCurrentPick!=null){
if(IsUnitType(bj_groupRandomCurrentPick,UNIT_TYPE_FLYING)){
c=CreateUnit(GetOwningPlayer(buildingCaster),'e008',GetUnitX(bj_groupRandomCurrentPick),GetUnitY(bj_groupRandomCurrentPick),0.)
UnitAddAbility(c,'A082')
UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,true)
IssueTargetOrderById(c,852095,bj_groupRandomCurrentPick)
UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,false)
UnitApplyTimedLife(c,'BTLF',2.)
}else{
c=CreateUnit(GetOwningPlayer(buildingCaster),'e008',GetUnitX(bj_groupRandomCurrentPick),GetUnitY(bj_groupRandomCurrentPick),0.)
UnitAddAbility(c,'A083')
UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,true)
IssueTargetOrderById(c,852095,bj_groupRandomCurrentPick)
UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,false)
UnitApplyTimedLife(c,'BTLF',2.)
c=CreateUnit(GetOwningPlayer(buildingCaster),'e008',GetUnitX(bj_groupRandomCurrentPick),GetUnitY(bj_groupRandomCurrentPick),0.)
UnitAddAbility(c,'A04H')
UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,true)
IssueTargetOrderById(c,852171,bj_groupRandomCurrentPick)
UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,false)
UnitApplyTimedLife(c,'BTLF',4.5)
}
}
}
i++
}
endloop
if(WF_BallsCnt==0){
PauseTimer(SpellWorldFreezerTimer)
}
u=null
c=null
}
private void SpellWorldFreezer()
{
unit u=buildingCaster
real x=GetUnitX(u)
real y=GetUnitY(u)
player p=GetOwningPlayer(u)
int an=1-forceId[GetPlayerId(p)]*2
int i=0
unit c
SetUnitAnimation(u,"death")
TriggerSleepAction(1.5)
TimerStart(SpellWorldFreezerTimer,.06,true,function FlyIceBall)
loop
c=CreateUnit(p,'h08U',x,y,0.)
if(mode_na){
UnitRemoveAbility(c,'A080')
UnitAddAbility(c,'A084')
}
//GroupAddUnit(dummyGroupContainer,c)
WF_Balls[WF_BallsCnt]=c
FB_dx[WF_BallsCnt] = GetRandomReal(19.,29.) * R2I(an)
FB_dy[WF_BallsCnt] = I2R(i-1)+GetRandomReal(-0.36,0.36)
WF_BallsCnt++
i++
exitwhen i>2
endloop
c=null
EnableWeatherEffect(SpellWorldFreezerWeather,true)
TriggerSleepAction(3.7)
SetUnitAnimation(u,"stand")
TriggerSleepAction(2.6)
EnableWeatherEffect(SpellWorldFreezerWeather,false)
u=null
}
private bool Animationh03S()
{
SetUnitVertexColor(Attached,0,166,255,'s')
return false
}
private void SpellStun()
{
unit c=CreateUnit(GetOwningPlayer(unitCaster),'e008',GetUnitX(unitCaster),GetUnitY(unitCaster),0.)
UnitAddAbility(c,'A05D')
IssueImmediateOrderById(c,852127)
UnitApplyTimedLife(c,'BTLF',1.)
c=null
}
private void SpellIce()
{
unit c=CreateUnit(GetOwningPlayer(unitCaster),'e008',GetUnitX(unitCaster),GetUnitY(unitCaster),0.)
UnitAddAbility(c,'A043')
IssueTargetOrderById(c,852226,unitCasterTarget)
UnitApplyTimedLife(c,'BTLF',1.)
c=null
}
private void SpellRoar()
{
unit c=CreateUnit(GetOwningPlayer(unitCaster),'e008',GetUnitX(unitCaster),GetUnitY(unitCaster),0.)
UnitAddAbility(c,'A05B')
IssueImmediateOrderById(c,852588)
UnitApplyTimedLife(c,'BTLF',1.)
c=null
}
private void RegisterBuildings()
{
//mushroom
Data_RegisterBuildingSpell('h047',function SpellMushroom)
//frostlauncher
Data_RegisterBuildingSpell('h048',function SpellFrost)
Data_RegisterBuildingSpell('h03L',function SpellFrostGreater)
//world freezer
Data_RegisterBuildingSpell('h03O',function SpellWorldFreezer)
//magnotavr
Data_RegisterTrainOrder('h049','n017')
Data_RegisterTrainOrder('h04F','n018')
Data_RegisterTrainOrder('h03W','n016')
//wendigo
Data_RegisterTrainOrder('h03T','n012')
Data_RegisterTrainOrder('h043','n013')
//crystal
Data_RegisterTrainOrder('h03S','n014')
Data_RegisterAttachEffects('h03S',function Animationh03S)
//troll
Data_RegisterTrainOrder('h03K','n015')
Data_RegisterTrainOrder('h03J','o00A')
//tower
Data_RegisterTowerRange('h03Q',750.)
//igloo
Data_RegisterTrainOrder('h03U','n011')
//dragon
Data_RegisterTrainOrder('h03I','n010')
//leg. dragon
Data_RegisterTrainOrder('h076','n03A')
}
private void RegisterLumberIncome()
{
Data_SetRace(RACE_NORTH)
Data_RegisterBuilding('h049',.2,true,0,false)//wolf
Data_RegisterBuilding('h04F',.2,true,'h049',false)
Data_RegisterBuilding('h03W',.2,true,'h04F',false)
Data_RegisterBuilding('h03T',.2,true,0,false)//wan
Data_RegisterBuilding('h043',.2,true,'h03T',false)
Data_RegisterBuilding('h03S',.2,true,0,false)
Data_RegisterBuilding('h03K',.2,true,0,false) //sham
Data_RegisterBuilding('h03J',.2,true,'h03K',false)
Data_RegisterBuilding('h03U',.2,true,0,false)
Data_RegisterBuilding('h03I',.2,true,0,false) //drake
Data_RegisterBuilding('h076',.2,true,'h03I',false) //leg. drake
//
Data_RegisterBuilding('h047',.12,false,0,false)
Data_RegisterBuilding('h03Q',.10,false,0,false)
Data_RegisterBuilding('h048',.09,false,0,false)
Data_RegisterBuilding('h03L',.09,false,'h048',false)
Data_RegisterBuilding('h03O',.09,false,0,false)
Data_RegisterBuilding('h008',.05,false,0,false) //TB
}
private void RegisterUnitCasts()
{
Data_RegisterUnitSpell('n016','A05E',function SpellStun)
Data_RegisterUnitSpell('n013','A05C',function SpellRoar)
Data_RegisterUnitSpell('n014','A044',function SpellIce)
}
public void init()
{
RegisterBuildings()
RegisterLumberIncome()
RegisterUnitCasts()
filterEnemyAirUnit=Filter(function FilterEnemyAirUnit)
filterEnemyBuildingUnit=Filter(function FilterEnemyBuildingUnit)
mminx=GetRectMinX(bj_mapInitialPlayableArea)
mmaxx=GetRectMaxX(bj_mapInitialPlayableArea)
mminy=GetRectMinY(bj_mapInitialPlayableArea)
mmaxy=GetRectMaxY(bj_mapInitialPlayableArea)
SpellWorldFreezerWeather=AddWeatherEffect(bj_mapInitialPlayableArea,'SNhs')
EnableWeatherEffect(SpellWorldFreezerWeather,false)
}
endlibrary
//TESH.scrollpos=21
//TESH.alwaysfold=0
library_once Chaos initializer init uses Functions
int volcanoType='A01I'//'A05H'
define private Attached=Data_buildingAttacher
define private buildingCaster=Data_buildingCaster
define private unitCaster=Data_unitCaster
define private unitCasterTarget=Data_unitCasterTarget
private void SpellTower()
{
unit c
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemyUnit)
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Orc\\FeralSpirit\\feralspiritdone.mdl",GetUnitX(buildingCaster),GetUnitY(buildingCaster)))
//bj_groupRandomConsidered = 0
//bj_groupRandomCurrentPick = null
//ForGroup(pickgroup, function GroupPickRandomUnitEnum)
bj_groupRandomCurrentPick=GetRandomUnit(pickgroup)
if(bj_groupRandomCurrentPick==null){return}
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Orc\\FeralSpirit\\feralspiritdone.mdl",bj_groupRandomCurrentPick,"origin"))
if(UnitDispelMagic(bj_groupRandomCurrentPick)){return}
int i=GetRandomInt(0,8)
if(i==0){
ExplodeUnitBJ(bj_groupRandomCurrentPick)
i=GetPlayerId(filterPlayer)
statisticKills[i]++
}elseif(i==1){
UnitDamageTarget(buildingCaster,bj_groupRandomCurrentPick,50000.,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_DEATH,WEAPON_TYPE_WHOKNOWS)
}elseif(i==2){
UnitDamageTarget(buildingCaster,bj_groupRandomCurrentPick,500.,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_DEATH,WEAPON_TYPE_WHOKNOWS)
}elseif(i==3){
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Avatar\\AvatarCaster.mdl",bj_groupRandomCurrentPick,"origin"))
if(GetRandomInt(0,99) > 50) { UnitAddAbility(bj_groupRandomCurrentPick,'A06T') }
if(GetRandomInt(0,99) > 50) { UnitAddAbility(bj_groupRandomCurrentPick,'A06U') }
if(GetRandomInt(0,99) > 50) { SetUnitState(bj_groupRandomCurrentPick,UNIT_STATE_LIFE,GetUnitState(bj_groupRandomCurrentPick,UNIT_STATE_MAX_LIFE)) }
}elseif(i==4){
c=CreateUnit(filterPlayer,'e008',GetUnitX(bj_groupRandomCurrentPick),GetUnitY(bj_groupRandomCurrentPick),0.)
UnitAddAbility(c,'A018')
UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,true)
IssueTargetOrderById(c,852502,bj_groupRandomCurrentPick)
UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,false)
UnitApplyTimedLife(c,'BTLF',1.)
c=bj_groupRandomCurrentPick
TriggerSleepAction(1.)
AttackCreepOrder(c)
if(GetUnitTypeId(c)=='h03A'){
TriggerSleepAction(44.5) //hex duration
IssueImmediateOrderById(c,852055)
TriggerSleepAction(.5)
AttackCreepOrder(c)
}
c=null
}elseif(i==5){ //stun
c=CreateUnit(filterPlayer,'e008',GetUnitX(bj_groupRandomCurrentPick),GetUnitY(bj_groupRandomCurrentPick),0.)
UnitAddAbility(c,'A06S')
UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,true)
IssueTargetOrderById(c,852095,bj_groupRandomCurrentPick)
UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,false)
UnitApplyTimedLife(c,'BTLF',1.2)
c=null
}elseif(i==6){ //
i=GetPlayerId(filterPlayer)
statisticKills[i]++
ShowUnit(bj_groupRandomCurrentPick,false)
real x=GetUnitX(bj_groupRandomCurrentPick)
real y=GetUnitY(bj_groupRandomCurrentPick)
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Orc\\FeralSpirit\\feralspiritdone.mdl",x,y))
AttackCreepOrder(CreateUnit(filterPlayer,'n01S',x,y,GetUnitFacing(bj_groupRandomCurrentPick)))
RemoveUnit(bj_groupRandomCurrentPick)
}
}
private int EraserPickType
private boolexpr eraserPick
private bool EraserPick()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>.405 and IsUnitEnemy(u,filterPlayer) and GetUnitTypeId(u)==EraserPickType
u=null
return res
}
private void SpellEraser()
{
unit u
int c=0
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemyUnit)
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(buildingCaster),GetUnitY(buildingCaster)))
bj_groupRandomCurrentPick=GetRandomUnit(pickgroup)
if(bj_groupRandomCurrentPick==null){return}
if(GetUnitAbilityLevel(bj_groupRandomCurrentPick,'A07H')>0) {return}
EraserPickType=GetUnitTypeId(bj_groupRandomCurrentPick)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,eraserPick)
loop
u = FirstOfGroup(pickgroup)
exitwhen u == null
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIil\\AIilTarget.mdl",u,"origin"))
KillUnit(u)
GroupRemoveUnit(pickgroup,u)
c++
endloop
if(c==1) {DisplayTextToPlayer(filterPlayer,0.,0.,"Eraser removed only one "+GetObjectName(EraserPickType)+"!")}
else {
DisplayTextToPlayer(filterPlayer,0.,0.,"Eraser removed "+I2S(c)+" "+GetObjectName(EraserPickType)+"(s)!") }
if(c>0){ //add gold
c=R2I(I2R(c)*GetRandomReal(1.0,2.0))
SetPlayerState(filterPlayer,PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(filterPlayer,PLAYER_STATE_RESOURCE_GOLD)+c)
SetPlayerState(filterPlayer,PLAYER_STATE_GOLD_GATHERED,GetPlayerState(filterPlayer,PLAYER_STATE_GOLD_GATHERED)+c)
}
}
private void SpellVolcano()
{
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemyGroundUnit)
//bj_groupRandomConsidered = 0
//bj_groupRandomCurrentPick = null
//ForGroup(pickgroup, function GroupPickRandomUnitEnum)
bj_groupRandomCurrentPick=GetRandomUnit(pickgroup)
if(bj_groupRandomCurrentPick==null){return}
real x=GetUnitX(bj_groupRandomCurrentPick)+GetRandomReal(80.0,80.0)
real y=GetUnitY(bj_groupRandomCurrentPick)+GetRandomReal(80.0,80.0)
unit c=CreateUnit(filterPlayer,'e008',x,y,0.)
UnitAddAbility(c,volcanoType)
IssuePointOrderById(c,order_rainoffire,x,y)
UnitApplyTimedLife(c,'BTLF',5.5)
c=null
}
private boolexpr filterEnemyBuildingUnit
//private constant player impPlayer = Player(12)
private bool FilterEnemyBuildingUnit()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>.405 and IsUnitEnemy(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_STRUCTURE) and GetPlayerId(GetOwningPlayer(u))<12 and GetUnitTypeId(u)!='hcas' and GetUnitAbilityLevel(u,'A06V')<=0
u=null
return res
}
private void SpellDestruction()
{
boolean success = true
filterPlayer=GetOwningPlayer(buildingCaster)
int c = GetRandomInt(0,99)
if ( c < 14){
if ( c < 7){ return; }
if (GetPlayerId(filterPlayer) >= 6) {filterPlayer = Player(1)}
else {filterPlayer = Player(7)}
success = false
}
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemyBuildingUnit)
bj_groupRandomCurrentPick=GetRandomUnit(pickgroup)
if(bj_groupRandomCurrentPick==null){return}
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl",GetUnitX(bj_groupRandomCurrentPick),GetUnitY(bj_groupRandomCurrentPick)))
KillUnit(bj_groupRandomCurrentPick)
if (success)
{
int t=forceId[GetPlayerId(filterPlayer)]
mpDestrCount[t]++
SetMBValue(3,t+1,I2S(mpDestrCount[t]))
}
}
private void SpellRoar()
{
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\NightElf\\BattleRoar\\RoarCaster.mdl",unitCaster,"origin"))
unit c=CreateUnit(GetOwningPlayer(unitCaster),'e008',GetUnitX(unitCaster),GetUnitY(unitCaster),0.)
UnitAddAbility(c,'A03R')
IssueImmediateOrderById(c,852164)
UnitApplyTimedLife(c,'BTLF',1.)
c=null
}
private bool Animationh03G()
{
Data_JoinUnitUnit(Attached,'h094',74.,38.5,28.)
Data_JoinUnitUnit(Attached,'h093',160.,-42.,-18.75)
Data_JoinUnitUnit(Attached,'h093',250.,3.75,-55.5)
Data_JoinUnitUnit(Attached,'h08Z',220.,43.,27.5)
return false
}
private void RegisterBuildings()
{
//magic tower
Data_RegisterBuildingSpell('h05I',function SpellTower)
//fiends
Data_RegisterTrainOrder('h025','n00L')
//eraser
Data_RegisterBuildingSpell('h01M',function SpellEraser)
Data_RegisterBuildingSpell('h01W',function SpellEraser)
Data_RegisterBuildingSpell('h01X',function SpellEraser)
//demon
Data_RegisterTrainOrder('h01I','n00A')
Data_RegisterTrainOrder('h026','z000')
//volcano
Data_RegisterBuildingSpell('h01F',function SpellVolcano)
//destruction
Data_RegisterBuildingSpell('h01E',function SpellDestruction)
//succubus
Data_RegisterTrainOrder('h01C','n008')
//chaos warrior
Data_RegisterTrainOrder('h01D','n009')
Data_RegisterTrainOrder('h03G','n00Z')
Data_RegisterAttachEffects('h03G',function Animationh03G)
//dragon
Data_RegisterTrainOrder('h009','n001')
//infernal
Data_RegisterTrainOrder('h007','n000')
}
private void RegisterLumberIncome()
{
Data_SetRace(RACE_CHAOS)
Data_RegisterBuilding('h025',.2,true,0,false)//blood
Data_RegisterBuilding('h01I',.2,true,0,false)//sat
Data_RegisterBuilding('h026',.2,true,'h01I',false)
Data_RegisterBuilding('h01C',.2,true,0,false)//suc
Data_RegisterBuilding('h01D',.2,true,0,false)//ChW
Data_RegisterBuilding('h03G',.2,true,'h01D',false)
Data_RegisterBuilding('h009',.2,true,0,false)
Data_RegisterBuilding('h007',.2,true,0,false)
//
Data_RegisterBuilding('h05I',.09,false,0,false)
Data_RegisterBuilding('h01M',.09,false,0,false)
Data_RegisterBuilding('h01W',.09,false,'h01M',false)
Data_RegisterBuilding('h01X',.09,false,'h01W',false)
Data_RegisterBuilding('h01F',.09,false,0,false)
Data_RegisterBuilding('h01E',.12,false,0,false)
Data_RegisterBuilding('h008',.05,false,0,false) //TB
}
private void RegisterUnitCasts()
{
Data_RegisterUnitSpell('n00Z','A03S',function SpellRoar)
}
private unit ReplaceUnit(unit u, int uid)
{
unit n
ShowUnit(u,false)
n=CreateUnit(GetOwningPlayer(u),uid,GetUnitX(u),GetUnitY(u),GetUnitFacing(u))
//KillUnit(u)
RemoveUnit(u)
return n
}
public unit TranslateBlood(unit u)
{
int i=GetRandomInt(0,99)
if(i<7){
u=ReplaceUnit(u,'n00M')
}elseif(i<15){
u=ReplaceUnit(u,'n00R')
}else{
i=GetRandomInt(0,3)
if(i==0){
u=ReplaceUnit(u,'n00Q')
}elseif(i==1){
u=ReplaceUnit(u,'n00N')
}elseif(i==2){
u=ReplaceUnit(u,'n00O')
}else{
u=ReplaceUnit(u,'n00P')
}
}
//abilities
set i=GetRandomInt(0,110)
if(i<25)then
call UnitAddAbility(u,'A009')
elseif(i<50)then
call UnitAddAbility(u,'A01F')
endif
set i=GetRandomInt(0,100)
if(i<20)then
call UnitAddAbility(u,'A01B')
elseif(i>75)then
call UnitAddAbility(u,'A07L') //FeedBack
endif
set i=GetRandomInt(0,110)
if(i<15)then
call UnitAddAbility(u,'A00U')
elseif(i<30)then
call UnitAddAbility(u,'A00T')
elseif(i<45)then
call UnitAddAbility(u,'A05J')
endif
set i=GetRandomInt(0,99)
if(i<25)then
call UnitAddAbility(u,'A01A')
endif
set i=GetRandomInt(0,99)
if(i<15)then
call UnitAddAbility(u,'A00V')
elseif(i<40)then
call UnitAddAbility(u,'A00D')
endif
set i=GetRandomInt(0,110)
if(i<10)then
call UnitAddAbility(u,'A01U')
elseif(i<20)then
call UnitAddAbility(u,'A010')
elseif(i<30)then
call UnitAddAbility(u,'A01P')
elseif(i<40)then
call UnitAddAbility(u,'A006')
elseif(i<50)then
call UnitAddAbility(u,'A01R')
elseif(i<60)then
call UnitAddAbility(u,'A012')
endif
return u
}
public void init()
{
RegisterBuildings()
RegisterLumberIncome()
RegisterUnitCasts()
eraserPick=Filter(function EraserPick)
filterEnemyBuildingUnit=Filter(function FilterEnemyBuildingUnit)
}
endlibrary
//TESH.scrollpos=249
//TESH.alwaysfold=0
library_once Undead initializer init uses Functions
//define private Attached=Data_buildingAttacher
define private buildingCaster=Data_buildingCaster
define private unitCaster=Data_unitCaster
define private unitCasterTarget=Data_unitCasterTarget
private boolexpr filterAnyDeadUnit
private bool FilterAnyDeadUnit()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)<.405 and IsUnitType(u,UNIT_TYPE_SAPPER) and not IsUnitType(u,UNIT_TYPE_UNDEAD) and not IsUnitType(u,UNIT_TYPE_MECHANICAL)
u=null
return res
}
private int array sceletons
/*
sceletons[0]='u002' //- melee
sceletons[1]='n00D' //archer
sceletons[2]='u00A' //mage
sceletons[3]='n00C' //-hero
sceletons[4]='u00B' //-greater melee
sceletons[5]='n01L' //greater archer
sceletons[6]='u003' //greater mage
sceletons[7]='n01M' //-general
*/
define HT_LichId = 'lich'
define HT_LichTargId = 'lict'
private group grLich = CreateGroup()
private void RaiseSkely(player p, unit tu, int rgsc) //min chance to create greater
{
real hp = GetUnitState(tu,UNIT_STATE_MAX_LIFE)
int st
unit su
boolean r = GetRandomInt(0,99)<rgsc
boolean r2 = GetRandomInt(0,99)<rgsc
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"Skelly Raise!")
if(IsUnitType(tu,UNIT_TYPE_RANGED_ATTACKER)){
if(GetUnitState(tu,UNIT_STATE_MAX_MANA) > 50.){
if((hp>460. and r) or r2) { st='u003' }
else { st = 'u00A' }
} else {
if((hp>460. and r) or r2) { st='n01L' }
else { st = 'n00D' }
}
} else { //melee
if(((hp>840. and r) or r2) and (GetRandomInt(0,99)>60)){ //Sk.General
st = 'n01M'
}elseif((hp>680. and r) or r2){
if(GetRandomInt(0,99)<60) {
st = 'u00B'
} else {
st='n00C'
}
}
else { st='u002' }
}
su = CreateUnit(p,st,GetUnitX(tu),GetUnitY(tu),GetRandomReal(0.,360.))
UnitApplyTimedLife(su,'BTLF',GetRandomReal(20.,30.))
AttackCreepOrder(su)
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"Skelly Raised:"+GetUnitName(su) +" from "+GetUnitName(tu)+" "+R2S(hp))
su = null
}
private void LichCastDnD(unit u, real x, real y)
{
unit c=CreateUnit(GetOwningPlayer(u),'e008',x,y,0.)
UnitAddAbility(c,'A086')
IssuePointOrderById(c,852221,x,y)
UnitApplyTimedLife(c,'BTLF',6.)
c=null
}
private void LichPresence()
{
timer t = GetExpiredTimer()
int id = GetHandleId(t)
unit u = LoadUnitHandle(tableIN,HT_LichId,id)
unit tu
if(u!=null and GetWidgetLife(u)>.405 ) {
id = GetRandomInt(0,99)
if(id<40)
{
GroupEnumUnitsInRange(grLich,GetUnitX(u),GetUnitY(u),520.,filterAnyDeadUnit)
tu = FirstOfGroup(grLich)
if(tu!=null and IssueTargetOrderById(u,852197,tu)) {
RaiseSkely(GetOwningPlayer(u),tu,30)
}
} else{
tu = LoadUnitHandle(tableIN,HT_LichTargId,GetHandleId(u))
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"Lich target:"+GetUnitName(tu))
if(tu!=null and GetWidgetLife(tu)>.405){
if(id>90){
//IssuePointOrderById(u,852221,GetUnitX(tu),GetUnitY(tu)) //DnD
LichCastDnD(u,GetUnitX(tu),GetUnitY(tu))
} elseif(id>70) {
IssueTargetOrderById(u,852487,tu) //lifeleach
}
}
}
TimerStart(t,3.0,false, function LichPresence)
} else { PauseTimer(t);DestroyTimer(t) }
t=null
u=null
tu=null
}
public void NewLich(unit u)
{
timer t = CreateTimer()
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"New Lich")
SaveUnitHandle(tableIN,HT_LichId,GetHandleId(t),u)
TimerStart(t,2.0,false, function LichPresence)
t=null
}
private void SpellVampireStrike(){
unit c=unitCaster
unit t=unitCasterTarget
IssuePointOrderById(c,852525,GetUnitX(t),GetUnitY(t)) //blink
TriggerSleepAction(0.1)
UnitAddAbility(c,'A0JC')
IssueTargetOrderById(c,order_attack,t)
TriggerSleepAction(0.7)
UnitRemoveAbility(c,'A0JC')
}
private void SpellSceletonSimple()
{
unit u
player p = GetOwningPlayer(buildingCaster)
TriggerSleepAction(GetRandomReal(0.0,2.0))
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterAnyDeadUnit)
u =GetRandomUnit(pickgroup)
if(u==null){return}
real x=GetUnitX(u)
real y=GetUnitY(u)
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Items\\AIam\\AIamTarget.mdl",x,y))
RaiseSkely(p,u,3)
RemoveUnit(u)
u=null
}
private void SpellSceletonGreater()
{
unit u
player p = GetOwningPlayer(buildingCaster)
TriggerSleepAction(GetRandomReal(0.0,2.0))
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterAnyDeadUnit)
u =GetRandomUnit(pickgroup)
if(u==null){return}
real x=GetUnitX(u)
real y=GetUnitY(u)
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Items\\AIam\\AIamTarget.mdl",x,y))
RaiseSkely(p,u,40)
RemoveUnit(u)
u=null
}
private void SpellDeath()
{
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemyUnit)
bj_groupRandomConsidered = 0
bj_groupRandomCurrentPick = null
ForGroup(pickgroup, function GroupPickRandomUnitEnum)
if(bj_groupRandomCurrentPick==null){return}
if not UnitDispelMagic(bj_groupRandomCurrentPick){
KillUnit(bj_groupRandomCurrentPick);
//UnitDamageTarget(buildingCaster,bj_groupRandomCurrentPick,50000.,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_DEATH,WEAPON_TYPE_WHOKNOWS)
}
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl",GetUnitX(bj_groupRandomCurrentPick),GetUnitY(bj_groupRandomCurrentPick)))
unit u=buildingCaster
SetUnitAnimation(u,"work")
TriggerSleepAction(1.)
SetUnitAnimation(u, "stand")
u=null
}
private void RegisterBuildings()
{
//temple of bone
Data_RegisterTrainOrder('h01K','u005')
Data_RegisterTrainOrder('h04B','u009')
Data_RegisterTrainOrder('h055','u00D')
//tower
Data_RegisterTowerRange('h01O',800.)
//golem
Data_RegisterTrainOrder('h01T','n00E')
//SceletonRaiser
Data_RegisterBuildingSpell('h01P',function SpellSceletonSimple)
Data_RegisterBuildingSpell('h056',function SpellSceletonGreater)
Data_RegisterTrainOrder('h01P','u002')//suppose it's melee/archer
Data_RegisterTrainOrder('h056','n01L')
//Vampire
Data_RegisterTrainOrder('h01N','h01U')
Data_RegisterTrainOrder('h054','h05H')
//banshee
Data_RegisterTrainOrder('h01L','u001')
//dragon
Data_RegisterTrainOrder('h01S','u000')
//DeathPit
Data_RegisterBuildingSpell('h00A',function SpellDeath)
//zombie
Data_RegisterTrainOrder('h01R','n00B')
Data_RegisterTrainOrder('h04Z','n01K')
Data_RegisterTrainOrder('h03M','u007')
}
private void RegisterLumberIncome()
{
Data_SetRace(RACE_DEAD)
Data_RegisterBuilding('h01K',.2,true,0,false)//necr
Data_RegisterBuilding('h04B',.2,true,'h01K',false)
Data_RegisterBuilding('h055',.2,false,'h04B',false)
Data_RegisterBuilding('h01T',.18,true,0,true)
Data_RegisterBuilding('h01P',.12,true,0,false)//pile
Data_RegisterBuilding('h056',.12,true,'h01P',false)
Data_RegisterBuilding('h01N',.2,true,0,false)//vamp
Data_RegisterBuilding('h054',.2,true,'h01N',false)
Data_RegisterBuilding('h01L',.2,true,0,false)//ban
Data_RegisterBuilding('h01S',.2,true,0,false)//drag
Data_RegisterBuilding('h01R',.2,true,0,false)//zom
Data_RegisterBuilding('h04Z',.2,true,'h01R',false)
Data_RegisterBuilding('h03M',.2,true,'h04Z',false)
//
Data_RegisterBuilding('h01O',.10,false,0,false)
Data_RegisterBuilding('h00A',.09,false,0,false)
Data_RegisterBuilding('h01Q',.09,false,0,false)
Data_RegisterBuilding('h008',.05,false,0,false) //TB
}
private void RegisterUnitCasts()
{
Data_RegisterUnitSpell('h05H','A0JB',function SpellVampireStrike)
}
//necromancers
private void ConvertSummoned()
{
unit u=GetSummonedUnit()
int uid=GetUnitTypeId(u)
if(uid=='u004'){
AttackCreepOrder(ReplaceUnitBJ(u,sceletons[GetRandomInt(0,2)],2))
}elseif(uid=='u008'){
AttackCreepOrder(ReplaceUnitBJ(u,sceletons[GetRandomInt(0,6)],2))
}elseif(uid=='u00E'){
uid=GetRandomInt(0,7)
if(uid==0){uid=7}else{uid=GetRandomInt(3,6)}
AttackCreepOrder(ReplaceUnitBJ(u,sceletons[uid],2))
UnitAddAbility(bj_lastReplacedUnit,'A088')
UnitAddAbility(bj_lastReplacedUnit,'A089')
}
u=null
}
public void CallVampire(unit k, unit d, int tid, real ttl)
{
real x=GetUnitX(d)
real y=GetUnitY(d)
UnitApplyTimedLife(CreateUnit(GetOwningPlayer(k),tid,x,y,0.),'BTLF',ttl)
RemoveUnit(d)
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Items\\AIam\\AIamTarget.mdl",x,y))
}
public void init()
{
RegisterBuildings()
RegisterLumberIncome()
RegisterUnitCasts()
filterAnyDeadUnit=Filter(function FilterAnyDeadUnit)
sceletons[0]='u002'
sceletons[1]='n00D'
sceletons[2]='u00A'
sceletons[3]='n00C'
sceletons[4]='u00B'
sceletons[5]='n01L'
sceletons[6]='u003'
sceletons[7]='n01M'
trigger t=CreateTrigger()
TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SUMMON)
TriggerAddAction(t,function ConvertSummoned)
}
endlibrary
//TESH.scrollpos=134
//TESH.alwaysfold=0
library_once HighElf initializer init uses Functions
define private Attached=Data_buildingAttacher
define private buildingCaster=Data_buildingCaster
define private unitCaster=Data_unitCaster
define private unitCasterTarget=Data_unitCasterTarget
private boolexpr filterAirEnemyUnit
private bool FilterAirEnemyUnit()
{
unit u=GetFilterUnit()
bool res=IsUnitType(u,UNIT_TYPE_FLYING) and GetWidgetLife(u)>.405 and IsUnitEnemy(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER) and not IsUnitType(u,UNIT_TYPE_MECHANICAL)
u=null
return res
}
private void SpellRiderStrike()
{
filterPlayer=GetOwningPlayer(unitCaster)
real x=GetUnitX(unitCaster)
real y=GetUnitY(unitCaster)
GroupEnumUnitsInRange(pickgroup,GetUnitX(unitCasterTarget),GetUnitY(unitCasterTarget),400.,filterAirEnemyUnit)
int i=0
unit t
unit c
loop
t=FirstOfGroup(pickgroup)
i++
exitwhen i>3 or t==null
GroupRemoveUnit(pickgroup,t)
if(GetUnitAbilityLevel(t,'A07H')<=0){ //skip legends
c=CreateUnit(GetOwningPlayer(unitCaster),'e008',x,y,0.)
UnitAddAbility(c,'A08U')
IssueTargetOrderById(c,852095,t)
UnitApplyTimedLife(c,'BTLF',3.)
}
endloop
t=null
c=null
}
private void SpellHex()
{
real sc
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemyUnit)
bj_groupRandomConsidered = 0
bj_groupRandomCurrentPick = null
ForGroup(pickgroup, function GroupPickRandomUnitEnum)
if(bj_groupRandomCurrentPick==null or UnitDispelMagic(bj_groupRandomCurrentPick)){return}
unit c=CreateUnit(filterPlayer,'e008',GetUnitX(bj_groupRandomCurrentPick),GetUnitY(bj_groupRandomCurrentPick),0.)
int r = GetRandomInt(0,99)
if(r<33) {
UnitAddAbility(c,'A018') } elseif(r>66) { UnitAddAbility(c,'A0GY') }
else {UnitAddAbility(c,'A0GX')}
UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,true)
IssueTargetOrderById(c,852502,bj_groupRandomCurrentPick)
UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,false)
UnitApplyTimedLife(c,'BTLF',1.)
c=bj_groupRandomCurrentPick
//sc = GetUnitState(c,UNIT_STATE_MAX_LIFE)*0.002 - 1.0;
//if(sc<1.0) {sc=1.0}
//SetUnitScale(c,sc,sc,sc);
TriggerSleepAction(0.7)
AttackCreepOrder(c)
c=null
}
private void SpellHeallingWave()
{
unit c=CreateUnit(GetOwningPlayer(unitCaster),'e008',GetUnitX(unitCaster),GetUnitY(unitCaster),0.)
UnitAddAbility(c,'A0A8')
IssueTargetOrderById(c,852501,unitCasterTarget)
UnitApplyTimedLife(c,'BTLF',1.1)
c=unitCaster
TriggerSleepAction(.5)
AttackCreepOrder(c)
c=null
}
private void SpellHeallingWaveGreater()
{
unit c=CreateUnit(GetOwningPlayer(unitCaster),'e008',GetUnitX(unitCaster),GetUnitY(unitCaster),0.)
UnitAddAbility(c,'A00Y')
IssueTargetOrderById(c,852501,unitCasterTarget)
UnitApplyTimedLife(c,'BTLF',2.)
c=unitCaster
TriggerSleepAction(.8)
AttackCreepOrder(c)
c=null
}
private bool Animationh08X()
{
SetUnitVertexColor(Attached,255,255,255,0)
Data_JoinUnitUnit(Attached,'h08Z',250.,46.,33.5)
Data_JoinUnitUnit(Attached,'h090',270.,-17.,18.)
return false
}
private bool Animationh08Y()
{
SetUnitVertexColor(Attached,255,255,255,0)
Data_JoinUnitUnit(Attached,'h08Z',250.,46.,33.5)
Data_JoinUnitUnit(Attached,'h091',270.,-17.,18.)
Data_JoinUnitUnit(Attached,'h08Z',350.,-22.,-40.)
return false
}
private void RegisterBuildings()
{
Data_RegisterBuildingSpell('h00Z',function SpellHex)
Data_RegisterTowerRange('h014',675.)
//magic
Data_RegisterTrainOrder('h09X','h07B')
Data_RegisterTrainOrder('h00X','h00W')
//bloodthisters
Data_RegisterTrainOrder('h00V','h00U')
//blademasters
Data_RegisterTrainOrder('h00T','n006')
Data_RegisterTrainOrder('h03F','n00Y')
//archers
Data_RegisterTrainOrder('h08X','n022')
Data_RegisterAttachEffects('h08X',function Animationh08X)
Data_RegisterTrainOrder('h08Y','n023')
Data_RegisterAttachEffects('h08Y',function Animationh08Y)
//ballista
Data_RegisterTrainOrder('h070','e005')
//dragonhawk
Data_RegisterTrainOrder('h06Y','n01Y')
}
private void RegisterLumberIncome()
{
Data_SetRace(RACE_HELF)
Data_RegisterBuilding('h09X',.2,true,0,false)//sorc
Data_RegisterBuilding('h00X',.2,false,'h09X',false)
Data_RegisterBuilding('h00V',.2,true,0,false)
Data_RegisterBuilding('h00T',.2,true,0,false)//blade
Data_RegisterBuilding('h03F',.2,true,'h00T',false)
Data_RegisterBuilding('h08X',.2,true,0,false)//arch
Data_RegisterBuilding('h08Y',.2,true,'h08X',false)
Data_RegisterBuilding('h070',.18,true,0,true)
Data_RegisterBuilding('h06Y',.2,true,0,false)
//
Data_RegisterBuilding('h00Z',.12,false,0,false)
Data_RegisterBuilding('h059',.12,false,0,false)
Data_RegisterBuilding('h005',.12,false,0,false)
Data_RegisterBuilding('h014',.10,false,0,false)
Data_RegisterBuilding('h008',.05,false,0,false) //TB
}
private void RegisterUnitCasts()
{
Data_RegisterUnitSpell('n01Y','A08V',function SpellRiderStrike)
Data_RegisterUnitSpell('h07B','A0A7',function SpellHeallingWave)
Data_RegisterUnitSpell('h00W','A00X',function SpellHeallingWaveGreater)
}
private int array ShrineNum
private int ReviveUnitPerc(int id){
if(ShrineNum[id]==0) {return 0} else {
return 12 + 3*ShrineNum[id]
}
}
public void InvokeShrineActions(player p)
{
int id=forceId[GetPlayerId(p)]
ShrineNum[id]+=1
chanceToReviveUnit[id] = ReviveUnitPerc(id)
}
public void OnShrineDeath(unit u)
{
int id=forceId[GetPlayerId(GetOwningPlayer(u))]
ShrineNum[id]-=1
chanceToReviveUnit[id] = ReviveUnitPerc(id)
}
public void init()
{
RegisterBuildings()
RegisterLumberIncome()
RegisterUnitCasts()
filterAirEnemyUnit=Filter(function FilterAirEnemyUnit)
}
endlibrary
//TESH.scrollpos=321
//TESH.alwaysfold=0
library_once NightElf initializer init uses Functions
int starfallType='A0GD'//'A08T'-na 'A07T'
define private Attached=Data_buildingAttacher
define private buildingCaster=Data_buildingCaster
define private unitCaster=Data_unitCaster
define private unitCasterTarget=Data_unitCasterTarget
private constant group pickgroup2 = CreateGroup() // used for druid 2 spell
private boolexpr filterAlliedUnitArmor
private bool FilterAlliedUnitArmor()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>.405 and IsUnitAlly(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER) and GetUnitAbilityLevel(u,'A08C')<=0
u=null
return res
}
private void SpellArmor()
{
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterAlliedUnitArmor)
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Polymorph\\PolyMorphTarget.mdl",GetUnitX(buildingCaster),GetUnitY(buildingCaster)))
bj_groupRandomConsidered = 0
bj_groupRandomCurrentPick = null
ForGroup(pickgroup, function GroupPickRandomUnitEnum)
if(bj_groupRandomCurrentPick==null){return}
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\ControlMagic\\ControlMagicTarget.mdl",bj_groupRandomCurrentPick,"overhead"))
UnitAddAbility(bj_groupRandomCurrentPick,'A08C')
UnitAddAbility(bj_groupRandomCurrentPick,'A08D')
UnitAddAbility(bj_groupRandomCurrentPick,'A08F')
}
private boolexpr filterAlliedUnitH
private int huCnt
private bool FilterAlliedUnitH()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>.405 and IsUnitAlly(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER) and (not IsUnitType(u,UNIT_TYPE_MECHANICAL))
if(res) {huCnt++}
u=null
return res
}
private void OnTryToHeal(unit tu,player p)
{
real maxH = 200
real x=GetUnitX(tu)+GetRandomReal(-100.,100.)
real y=GetUnitY(tu)+GetRandomReal(-100.,100.)
//PingMinimapEx(x,y,0.1,160,255,160,false)
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Items\\AIda\\AIdaCaster.mdl",x,y))
unit u=CreateUnit(p,'e008',x,y,0.)
UnitAddAbility(u,'A08A')
//UnitAddAbility(u,'A0JO')
IssueImmediateOrderById(u,852269)
//TriggerSleepAction(0.2)
//IssueTargetOrderById(u,852501,tu)
UnitApplyTimedLife(u,'BTLF',1.0)
/*
filterPlayer = p
huCnt = 0
GroupEnumUnitsInRange(pickgroup,x,y,350.,filterAlliedUnitH)
if(huCnt>4) {huCnt = 4}
loop
u=FirstOfGroup(pickgroup)
exitwhen u==null or huCnt<=0
GroupRemoveUnit(pickgroup,u)
if(IsUnitType(u, UNIT_TYPE_UNDEAD))
{ SetUnitState(u,UNIT_STATE_LIFE,GetWidgetLife(u)+maxH*0.5) }
else {SetUnitState(u,UNIT_STATE_LIFE,GetWidgetLife(u)+maxH)}
maxH = maxH * 0.6
huCnt--
endloop
*/
u=null
}
private unit array hc
private unit array hdc
private void SpellInvokeHeal()
{
unit u
real dr, mdr=0
int c=0,d=0,e=0
player p = GetOwningPlayer(buildingCaster)
int id=forceId[GetPlayerId(p)]
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(buildingCaster),GetUnitY(buildingCaster)))
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,null)
loop
u = FirstOfGroup(pickgroup)
exitwhen (u == null or c > 25 or d > 25 or e>50)
if(GetWidgetLife(u)>.405 and IsUnitAlly(u,p) and IsUnitType(u,UNIT_TYPE_SAPPER) and (not IsUnitType(u,UNIT_TYPE_MECHANICAL)) ){
dr = GetUnitState(u,UNIT_STATE_LIFE)/GetUnitState(u,UNIT_STATE_MAX_LIFE)
if dr < 0.7{
hdc[c] = u; c++ }
else {hc[d]=u;d++}
}
e++
GroupRemoveUnit(pickgroup,u)
endloop
if(c==0 and d==0) {u=null;return}
if(c>0) {u=hdc[GetRandomInt(0,c-1)]}
else {u=hc[GetRandomInt(0,d-1)]}
OnTryToHeal(u,p)
u=null
}
private void SpellStarfall()
{
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemyUnit)
bj_groupRandomConsidered = 0
bj_groupRandomCurrentPick = null
ForGroup(pickgroup, function GroupPickRandomUnitEnum)
if(bj_groupRandomCurrentPick==null){return}
effect e=AddSpecialEffect("Abilities\\Spells\\NightElf\\Starfall\\StarfallCaster.mdl",GetUnitX(buildingCaster),GetUnitY(buildingCaster))
fogmodifier f
real x=GetUnitX(bj_groupRandomCurrentPick)
real y=GetUnitY(bj_groupRandomCurrentPick)
bool fl=not IsMapAllVisible
if(fl){
f=CreateFogModifierRadius(filterPlayer,FOG_OF_WAR_VISIBLE,x,y,1050.,true,false)
FogModifierStart(f)
}
unit c=CreateUnit(filterPlayer,'e008',x,y,0.)
if(mode_na) {
UnitAddAbility(c,'A0HV')
} else{
UnitAddAbility(c,'A0HT')
}
IssuePointOrderById(c,order_rainofchaos,x,y)
UnitApplyTimedLife(c,'BTLF',8.0)
c=null
TriggerSleepAction(8.5)
if(fl){
DestroyFogModifier(f)
f=null
}
DestroyEffect(e)
e=null
}
private void SpellDruid1()
{
unit c=CreateUnit(GetOwningPlayer(unitCaster),'e008',GetUnitX(unitCasterTarget),GetUnitY(unitCasterTarget),0.)
UnitAddAbility(c,'A07A')
IssueTargetOrderById(c,852171,unitCasterTarget)
UnitApplyTimedLife(c,'BTLF',6.)
c=null
}
/*
boolexpr filterEnemyGroundUnitNotEntangled
private bool FilterEnemyGroundUnitNotEntangled()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>.405 and IsUnitEnemy(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER) and IsUnitType(u,UNIT_TYPE_GROUND) and GetUnitAbilityLevel(u,'Avul')<=0 and GetUnitAbilityLevel(u,'A08H')<=0 and GetUnitAbilityLevel(u,'BEer')<=0
u=null
return res
}*/
// FIX http://castle-fight.net.ru/forum/viewtopic.php?f=40&t=487
private boolexpr filterEnemyGroundSpellDruid2Ex
private bool FilterEnemyGroundSpellDruid2Ex()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>.405 and IsUnitEnemy(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER) and IsUnitType(u,UNIT_TYPE_GROUND) and GetUnitAbilityLevel(u,'Avul')<=0 and GetUnitAbilityLevel(u,'A08H')<=0
if(res and GetUnitAbilityLevel(u,'BEer')<=0 and GetUnitAbilityLevel(u,'B00M')<=0){
GroupAddUnit(pickgroup2,u)
u=null
return false
}
u=null
return res
}
private void SpellDruid2()
{
filterPlayer=GetOwningPlayer(unitCaster)
real x=GetUnitX(unitCasterTarget)
real y=GetUnitY(unitCasterTarget)
unit t
unit c
//bj_lastCreatedUnit=unitCaster
bj_forLoopAIndex=3
GroupClear(pickgroup2)
GroupEnumUnitsInRange(pickgroup,x,y,300.,filterEnemyGroundSpellDruid2Ex)
loop
t=FirstOfGroup(pickgroup2)
exitwhen bj_forLoopAIndex<=0 or t==null
bj_forLoopAIndex--
GroupRemoveUnit(pickgroup2,t)
c=CreateUnit(filterPlayer,'e008',x,y,0.)
if(GetRandomInt(0,99)<50){ UnitAddAbility(c,'A07Q') }
elseif(GetRandomInt(0,99)<55) { UnitAddAbility(c,'A07A') }
else { UnitAddAbility(c,'A0A6') }
UnitShareVision(t,filterPlayer,true)
IssueTargetOrderById(c,852171,t)
UnitShareVision(t,filterPlayer,false)
UnitApplyTimedLife(c,'BTLF',7.)
endloop
t=null
c=null
}
private void SpellProcess()
{
unit u=unitCaster
real mp = GetUnitState(unitCasterTarget, UNIT_STATE_MANA)
if(mp>0.0) {SetUnitState(unitCasterTarget, UNIT_STATE_MANA, mp+25.0)}
else {
if(!IsUnitType(unitCasterTarget, UNIT_TYPE_UNDEAD)) {SetUnitState(unitCasterTarget, UNIT_STATE_LIFE, GetUnitState(unitCasterTarget, UNIT_STATE_LIFE)+80.0)}
}
TriggerSleepAction(0.7)
AttackCreepOrder(u)
u=null
}
private bool Animationh07H()
{
Data_JoinUnitUnit(Attached,'h08L',32.,12.,-11.5)
return false
}
private bool Animationh08P()
{
Data_JoinUnitUnit(Attached,'h08D',116.,-3.,-10.5)
Data_JoinUnitUnit(Attached,'h08N',323.,20.,5.75)
return false
}
private bool Animationh07I()
{
Data_JoinUnitUnit(Attached,'h08A',.0,.0,.0)
return false
}
private bool Animationh088()
{
Data_JoinUnitUnit(Attached,'h08K',.0,.0,.0)
return false
}
private bool Animationh07D()
{
Data_JoinUnitUnit(Attached,'h08K',.0,.0,.0)
Data_JoinUnitUnit(Attached,'h08S',.0,.0,.0)
return false
}
private bool Animationh07M()
{
Data_JoinUnitUnit(Attached,'h08N',226.,37.75,-41.5)
return false
}
private bool Animationh07L()
{
Data_JoinUnitUnit(Attached,'h08O',318,43.5,-41.75)
Data_JoinUnitUnit(Attached,'h08N',226,-38.25,40.25)
return false
}
private bool Animationh07O()
{
Data_JoinUnitUnit(Attached,'h08K',.0,15.,.0)
Data_JoinUnitUnit(Attached,'h08R',.0,.0,.0)
return false
}
private bool Animationh07N()
{
Data_JoinUnitUnit(Attached,'h08M',.0,.0,.0)
Data_JoinUnitUnit(Attached,'h08Q',.0,.0,.0)
return false
}
private void RegisterBuildings()
{
//obelisk armor
Data_RegisterBuildingSpell('h07H',function SpellArmor)
Data_RegisterAttachEffects('h07H',function Animationh07H)
//obelisk heal
Data_RegisterBuildingSpell('h08P',function SpellInvokeHeal)
Data_RegisterAttachEffects('h08P',function Animationh08P)
//tower
Data_RegisterTowerRange('h073',850.)
//obelisk starfall
Data_RegisterBuildingSpell('h07I',function SpellStarfall)
Data_RegisterAttachEffects('h07I',function Animationh07I)
//druids
Data_RegisterTrainOrder('h088','e007')
Data_RegisterAttachEffects('h088',function Animationh088)
Data_RegisterTrainOrder('h07D','e00J')
Data_RegisterAttachEffects('h07D',function Animationh07D)
//assassins
Data_RegisterTrainOrder('h07M','n01Z')
Data_RegisterAttachEffects('h07M',function Animationh07M)
Data_RegisterTrainOrder('h07L','n020')
Data_RegisterAttachEffects('h07L',function Animationh07L)
//vengeance
Data_RegisterTrainOrder('h07O','e00B')
Data_RegisterAttachEffects('h07O',function Animationh07O)
Data_RegisterTrainOrder('h07N','e00A')
Data_RegisterAttachEffects('h07N',function Animationh07N)
//ballista
Data_RegisterTrainOrder('h011','e002')
//archers
Data_RegisterTrainOrder('h00S','e001')
Data_RegisterTrainOrder('h03D','e003')
Data_RegisterTrainOrder('h03E','e004')
//flies
Data_RegisterTrainOrder('h00B','e000')
}
private void RegisterLumberIncome()
{
Data_SetRace(RACE_NELF)
Data_RegisterBuilding('h088',.2,true,0,false)
Data_RegisterBuilding('h07D',.2,true,'h088',false)
Data_RegisterBuilding('h07M',.2,true,0,false)
Data_RegisterBuilding('h07L',.2,true,'h07M',false)
Data_RegisterBuilding('h07O',.2,true,0,false)
Data_RegisterBuilding('h07N',.2,true,'h07O',false)
Data_RegisterBuilding('h011',.18,true,0,true)
Data_RegisterBuilding('h00S',.2,true,0,false)
Data_RegisterBuilding('h03D',.2,true,'h00S',false)
Data_RegisterBuilding('h03E',.2,true,'h03D',false)
Data_RegisterBuilding('h00B',.2,true,0,false)
//
Data_RegisterBuilding('h07H',.12,false,0,false)
Data_RegisterBuilding('h08P',.12,false,0,false)
Data_RegisterBuilding('h073',.10,false,0,false)
Data_RegisterBuilding('h07I',.09,false,0,false)
Data_RegisterBuilding('h008',.05,false,0,false) //TB
}
private void RegisterUnitCasts()
{
Data_RegisterUnitSpell('e007','A07P',function SpellDruid1)
Data_RegisterUnitSpell('e00J','A07R',function SpellDruid2)
Data_RegisterUnitSpell('e000','A0CG',function SpellProcess)
}
public void init()
{
RegisterBuildings()
RegisterLumberIncome()
RegisterUnitCasts()
filterAlliedUnitArmor=Filter(function FilterAlliedUnitArmor)
filterAlliedUnitH=Filter(function FilterAlliedUnitH)
filterEnemyGroundSpellDruid2Ex=Filter(function FilterEnemyGroundSpellDruid2Ex)
}
endlibrary
//TESH.scrollpos=313
//TESH.alwaysfold=0
library_once Mechanical initializer init uses Functions
constant group PowerPlant = CreateGroup()
constant group grAdamants=CreateGroup()
timer tmrDispel
define private Attached=Data_buildingAttacher
define private buildingCaster=Data_buildingCaster
define private unitCaster=Data_unitCaster
define private unitCasterTarget=Data_unitCasterTarget
private boolexpr filterAlliedUnitArmor
private bool FilterAlliedUnitArmor()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>50. and IsUnitAlly(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER) and GetUnitAbilityLevel(u,'Avul')<=0 and GetUnitAbilityLevel(u,'A09L')<=0
u=null
return res
}
private boolexpr filterAlliedUnit
private bool FilterAlliedUnit()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>50. and IsUnitAlly(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER) and GetUnitAbilityLevel(u,'Avul')<=0
u=null
return res
}
private void SpellArmor()
{
unit u
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterAlliedUnit)
bj_groupRandomCurrentPick=GetRandomUnit(pickgroup)
if(bj_groupRandomCurrentPick==null){return}
UnitAddAbility(bj_groupRandomCurrentPick,'A09L')
UnitAddAbility(bj_groupRandomCurrentPick,'A09Q')
u=buildingCaster
SetUnitAnimation(u,"death")
TriggerSleepAction(.3)
SetUnitAnimation(u,"stand")
u=null
}
private void SpellArmor2()
{
unit u
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterAlliedUnit)
bj_groupRandomCurrentPick=GetRandomUnit(pickgroup)
if(bj_groupRandomCurrentPick==null){return}
UnitAddAbility(bj_groupRandomCurrentPick,'A09L')
UnitAddAbility(bj_groupRandomCurrentPick,'A09Q')
//UnitRemoveAbility(bj_groupRandomCurrentPick,'A0H7')
//UnitAddAbility(bj_groupRandomCurrentPick,'A0H7') //1 shot spell protection
SetUnitAbilityLevel(bj_groupRandomCurrentPick,'A09L',2)
SetUnitAbilityLevel(bj_groupRandomCurrentPick,'A09Q',2)
u=buildingCaster
SetUnitAnimation(u,"death")
TriggerSleepAction(.3)
SetUnitAnimation(u,"stand")
u=null
}
private void SpellGrenade()
{
player p=GetOwningPlayer(unitCaster)
real x=GetUnitX(unitCasterTarget)
real y=GetUnitY(unitCasterTarget)
real sx=GetUnitX(unitCaster)
real sy=GetUnitY(unitCaster)
unit c=CreateUnit(p,'h09Q',sx,sy,0.)
IssuePointOrderById(c,851984,x,y)
UnitApplyTimedLife(c,'BTLF',3.)
sx-=x
sy-=y
TriggerSleepAction(SquareRoot(sx*sx+sy*sy)/700.)
c=CreateUnit(p,'e008',x,y,0.)
UnitAddAbility(c,'A09E')
IssueImmediateOrderById(c,852096)
UnitApplyTimedLife(c,'BTLF',3.)
filterPlayer=p
GroupEnumUnitsInRange(pickgroup,x,y,300.,filterEnemyGroundUnit)
unit t
loop
t=FirstOfGroup(pickgroup)
exitwhen t==null
GroupRemoveUnit(pickgroup,t)
sy=GetUnitState(t,UNIT_STATE_MANA)
if(sy>0.){
if(sy<100.) {sx=sy} else {sx=100.}
SetUnitState(t,UNIT_STATE_MANA,sy-sx)
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Feedback\\SpellBreakerAttack.mdl",t,"origin"))
UnitDamageTarget(c,t,1.0+sx,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
}
endloop
c=null
}
private void SpellMine()
{
player p=GetOwningPlayer(unitCaster)
real sx=GetUnitX(unitCaster)
real sy=GetUnitY(unitCaster)
real r = GetRandomReal(220.,400.)
real a = GetRandomReal(-3.14,3.14)
unit c=CreateUnit(p,'h09M',sx,sy,0.)
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,"SpellMine::")
sx=sx+r*Cos(a)
sy=sy+r*Sin(a)
SetUnitState(unitCaster,UNIT_STATE_MANA,GetUnitState(unitCaster,UNIT_STATE_MANA)+GetRandomReal(-15.,20.))
IssuePointOrderById(c,851984,sx,sy)
UnitApplyTimedLife(c,'BTLF',3.)
TriggerSleepAction(r/550.)
UnitApplyTimedLife(CreateUnit(p,'n025',sx,sy,0.),'BTLF',300.)
c=null
p=null
}
private void BombGround(){
unit u = unitCaster
real sx=GetUnitX(unitCasterTarget)
real sy=GetUnitY(unitCasterTarget)
/*int i = 4
loop
IssuePointOrderById(u,order_attackground,sx+GetRandomReal(-220.,220.),sy+GetRandomReal(-220.,220.))
TriggerSleepAction(0.45)
i--
exitwhen i <=0
endloop*/
//A0KL
TriggerSleepAction(0.05)
IssuePointOrderById(u,order_dreadlordinferno,sx+GetRandomReal(-40.,40.),sy+GetRandomReal(-40.,40.))
TriggerSleepAction(0.5)
AttackCreepOrder(u)
u=null
}
private bool AddChargedDummy()
{
Data_JoinUnitUnit(Attached,'e00L',0.,0.,0.)
return false
}
private void SpellDischarge(){
unit c
if(GetRandomInt(0,99)>75){
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,GetUnitName(unitCaster)+"<="+GetUnitName(unitCasterTarget))
//c=CreateUnit(GetOwningPlayer(buildingCaster),'e008',GetUnitX(buildingCaster),GetUnitY(buildingCaster),0.)
//UnitAddAbility(c,'A09T')
c=LoadUnitHandle(tableJU,GetHandleId(buildingCaster),0)
IssueTargetOrderById(c,order_chainlightning,GetSpellTargetUnit())
//UnitApplyTimedLife(c,'BTLF',0.4)
c=null
}
}
private bool Animationh09T()
{
Data_JoinUnitUnit(Attached,'h09V',270.,0.,0.)
Data_JoinUnitUnit(Attached,'h09U',90.,20.,.0)
Data_JoinUnitUnit(Attached,'h09U',.0,.0,-20.)
Data_JoinUnitUnit(Attached,'h09U',270.,-20.,.0)
Data_JoinUnitUnit(Attached,'h09U',180.,.0,20.)
return false
}
private bool Animationh069()
{
Data_JoinUnitUnit(Attached,'h09R',300.,3.5,65.25)
Data_JoinUnitUnit(Attached,'h09R',70.,-16.5,-51.)
Data_JoinUnitUnit(Attached,'h09N',238.,36.,53.)
Data_JoinUnitUnit(Attached,'h09O',314.,-38.,-39.5)
return false
}
private bool Animationh09P()
{
Data_JoinUnitUnit(Attached,'h09O',279.,-45.5,24.75)
Data_JoinUnitUnit(Attached,'h09N',300.,31.,-32.25)
return false
}
private bool Animationh09L()
{
Data_JoinUnitUnit(Attached,'h09K',238.,0.,0.)
return false
}
private bool Animationh09J()
{
Data_JoinUnitUnit(Attached,'h09F',2.,36.25,41.)
Data_JoinUnitUnit(Attached,'h09F',2.,33.25,-33.5)
Data_JoinUnitUnit(Attached,'h09F',2.,-46.25,10.75)
Data_JoinUnitUnit(Attached,'h09A',45.,-5.25,17.)
return false
}
private bool Animationh09I()
{
Data_JoinUnitUnit(Attached,'h09D',225.,35.,-29.75)
Data_JoinUnitUnit(Attached,'h09D',45.,20.,22.5)
Data_JoinUnitUnit(Attached,'h09D',225.,-31.,26.25)
Data_JoinUnitUnit(Attached,'h09G',23.,-25.25,-36.)
return false
}
private bool Animationh077()
{
SetUnitFacing(Attached,0.7)
Data_JoinUnitUnit(Attached,'h09D',45.,35.,-29.75)
Data_JoinUnitUnit(Attached,'h09D',45.,20.,22.5)
Data_JoinUnitUnit(Attached,'h09D',-45.,-31.,26.25)
Data_JoinUnitUnit(Attached,'h09G',23.,-25.25,-36.)
return false
}
private bool Animationh09B()
{
Data_JoinUnitUnit(Attached,'h09C',33.,36.25,36.5)
Data_JoinUnitUnit(Attached,'h09C',13.,21.,-47.5)
Data_JoinUnitUnit(Attached,'h09C',319.,-46.25,11.75)
return false
}
private bool Animationh09H()
{
Data_JoinUnitUnit(Attached,'h09C',33.,36.25,36.5)
Data_JoinUnitUnit(Attached,'h09C',13.,21.,-47.5)
Data_JoinUnitUnit(Attached,'h09C',319.,-46.25,11.75)
Data_JoinUnitUnit(Attached,'h09E',348.,-6.5,9.)
return false
}
private bool Animationh05L()
{
Data_JoinUnitUnit(Attached,'h09K',45.,0.,0.)
return false
}
private bool Animationh097()
{
Data_JoinUnitUnit(Attached,'h096',180.,-45.75,21.75)
Data_JoinUnitUnit(Attached,'h096',110.,9.,-62.5)
return false
}
private void DispelAdamant(){
unit u = GetEnumUnit()
if(GetRandomInt(0,99)<33+GetUnitAbilityLevel(u,'A09R')*33) {
UnitRemoveBuffs(u,false,true)
}
u=null
//DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl",u,"origin"))
}
private void DoDispel(){
ForGroup(grAdamants,function DispelAdamant)
}
private void RegisterBuildings()
{
//plant
Data_RegisterAttachEffects('h09T',function Animationh09T)
Data_RegisterTowerRange('h09T',180.)
//repairs bots
Data_RegisterTrainOrder('h069','n01U')
Data_RegisterAttachEffects('h069',function Animationh069)
//shield
Data_RegisterBuildingSpell('h06J',function SpellArmor)
Data_RegisterBuildingSpell('h05R',function SpellArmor2)
//flamethrower
Data_RegisterTrainOrder('h05T','z002')
Data_RegisterTrainOrder('h09P','z003')
Data_RegisterAttachEffects('h09P',function Animationh09P)
//shreder
Data_RegisterTrainOrder('h05U','n01T')
//lunatic
Data_RegisterTrainOrder('h05M','n01V')
Data_RegisterTrainOrder('h06D','n02G')
//helicopter
Data_RegisterTrainOrder('h05J','h06Q')
Data_RegisterTrainOrder('h09L','h06R')
Data_RegisterAttachEffects('h09L',function Animationh09L)
//golem
Data_RegisterTrainOrder('h05V','n01X')
Data_RegisterTrainOrder('h097','n024')
Data_RegisterAttachEffects('h097',function Animationh097)
//tanks
Data_RegisterTrainOrder('h05X','h06T')
Data_RegisterTrainOrder('h09J','h06U')
Data_RegisterAttachEffects('h09J',function Animationh09J)
Data_RegisterTrainOrder('h09I','h099')
Data_RegisterAttachEffects('h09I',function Animationh09I)
Data_RegisterTrainOrder('h06G','h06F')
Data_RegisterTrainOrder('h078','h075')
Data_RegisterAttachEffects('h078',function Animationh077)
Data_RegisterTrainOrder('h09B','h06S')
Data_RegisterAttachEffects('h09B',function Animationh09B)
Data_RegisterTrainOrder('h09H','h098')
Data_RegisterAttachEffects('h09H',function Animationh09H)
//tower
Data_RegisterTowerRange('h05L',600.)
Data_RegisterAttachEffects('h05L',function AddChargedDummy)
//
}
private void RegisterLumberIncome()
{
Data_SetRace(RACE_MECH)
Data_RegisterBuilding('h05T',.2,true,0,false)
Data_RegisterBuilding('h09P',.2,true,'h05T',false)
Data_RegisterBuilding('h05U',.2,true,0,false)
Data_RegisterBuilding('h05M',.2,true,0,false)
Data_RegisterBuilding('h06D',.2,true,'h05M',false)
Data_RegisterBuilding('h05J',.2,true,0,false)
Data_RegisterBuilding('h09L',.18,true,'h05J',false)
Data_RegisterBuilding('h078',.18,false,'h09L',false) //leg ship
Data_RegisterBuilding('h05V',.2,true,0,false)
Data_RegisterBuilding('h097',.2,false,'h05V',false) //adamant
Data_RegisterBuilding('h05X',.2,true,0,false)
Data_RegisterBuilding('h09J',.2,true,'h05X',false)
Data_RegisterBuilding('h09I',.2,true,'h05X',false) //assault
Data_RegisterBuilding('h06G',.18,true,'h05X',true) //siege
Data_RegisterBuilding('h09B',.2,true,'h05X',false)
Data_RegisterBuilding('h09H',.2,true,'h09B',false)
//
Data_RegisterBuilding('h09T',.12,false,0,false)
Data_RegisterBuilding('h069',.12,false,0,false)
Data_RegisterBuilding('h06J',.12,false,0,false)
Data_RegisterBuilding('h05R',.12,false,'h06J',false)
Data_RegisterBuilding('h05L',.10,false,0,false)
Data_RegisterBuilding('h008',.05,false,0,false) //TB
}
private void RegisterUnitCasts()
{
Data_RegisterUnitSpell('z003','A09D',function SpellGrenade)
Data_RegisterUnitSpell('h06U','A095',function SpellMine)
Data_RegisterUnitSpell('h075','A0JM',function BombGround)
Data_RegisterBuildingSpell('h05L',function SpellDischarge)
}
public void init()
{
RegisterBuildings()
RegisterLumberIncome()
RegisterUnitCasts()
filterAlliedUnit=Filter(function FilterAlliedUnit)
filterAlliedUnitArmor=Filter(function FilterAlliedUnitArmor)
tmrDispel = CreateTimer()
TimerStart(tmrDispel,1.13,true, function DoDispel)
}
endlibrary
//TESH.scrollpos=190
//TESH.alwaysfold=0
library_once NatureWispControl
define private ST_WISP_ID='h06B'
//define private ST_WISP_START_HEIGHT=1024.
define private ST_WISP_END_HEIGHT=30.
define private ST_WISP_TIMER=6.
define private MaxWisps = 24
private constant player ST_NETRAL_PLAYER=Player(PLAYER_NEUTRAL_PASSIVE)
private constant timer t=CreateTimer()
private destructable array trees
private unit array wisps
private bool inited = false
private void WispCall(){
int i=0
unit u
loop
if(wisps[i]==null){
u=CreateUnit(ST_NETRAL_PLAYER,ST_WISP_ID,GetDestructableX(trees[i]),GetDestructableY(trees[i]),270.)
SetUnitFlyHeight(u,ST_WISP_END_HEIGHT,85.)
IssueTargetOrderById(u,851971,trees[i])
wisps[i]=u
}
i++
exitwhen i>=MaxWisps
endloop
u=null
}
private unit retu
public unit GetWisp(int f){ //0 - 1
int i=0
int j
real x = f - 0.5
loop
j = GetRandomInt(0,23)
if(wisps[j]!=null and GetUnitX(wisps[j])*x > 0){
retu=wisps[j]
wisps[j]=null
return retu
}
i++
exitwhen i>=10
endloop
return null
}
public void StartCalling(){
TimerStart(t,ST_WISP_TIMER,true,function WispCall)
}
public void Reset(){
int i=0
PauseTimer(t)
loop
if(wisps[i]!=null){
RemoveUnit(wisps[i])
wisps[i]=null
}
i++
exitwhen i>=MaxWisps
endloop
}
private int di
private int dmax
private void EnumDestr(){
destructable d=GetEnumDestructable()
int id=GetDestructableTypeId(d)
if(di<dmax and (id=='ATtc' or id=='ATtr' or id=='B001' or id=='B000' or id=='ITtw' or id=='ITtc') and GetRandomInt(0,99) < 85){
SetDestructableInvulnerable(d,true)
trees[di]=d
di++
}
d=null
}
public void init(){
if(inited){return}
inited=true
rect r=Rect(Utils_map_maxx,-2300.,-Utils_map_maxx,-Utils_map_maxy)
di=0
dmax=12
EnumDestructablesInRect(r,null,function EnumDestr)
RemoveRect(r)
r=Rect(Utils_map_maxx,2300.,-Utils_map_maxx,Utils_map_maxy)
dmax=24
EnumDestructablesInRect(r,null,function EnumDestr)
RemoveRect(r)
r=null
}
endlibrary
library_once Nature initializer init uses Functions
int tornadoType='A0BD'
define private Attached=Data_buildingAttacher
define private buildingCaster=Data_buildingCaster
define private unitCaster=Data_unitCaster
define private unitCasterTarget=Data_unitCasterTarget
private int array forestUnits
private weathereffect SpellManaDrainWeather
private boolexpr filterAnyGroundUnit
private bool FilterAnyGroundUnit()
{
unit u=GetFilterUnit()
bool b=GetWidgetLife(u)>.405 and IsUnitType(u,UNIT_TYPE_GROUND) and IsUnitType(u,UNIT_TYPE_SAPPER)
u=null
return b
}
private void SpellTreantSprout()
{
player p=GetOwningPlayer(unitCaster)
int i=0
real x=GetUnitX(unitCaster)
real y=GetUnitY(unitCaster)
destructable array trees
real an
real r
unit u//=unitCaster
real x2
real y2
GroupEnumUnitsInRange(pickgroup,x,y,144.,filterAnyGroundUnit)
loop
u=FirstOfGroup(pickgroup)
exitwhen u==null
GroupRemoveUnit(pickgroup,u)
if(u!=unitCaster){
r=GetRandomReal(160.,218.)
an=(GetRandomReal(135.,234.)+180.*forceId[GetPlayerId(GetOwningPlayer(u))])*bj_DEGTORAD
x2=x+r*Cos(an)
y2=y+r*Sin(an)
SetUnitX(u,x2)
SetUnitY(u,y2)
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl",x2,y2))
}
endloop
u=unitCaster
loop
an=72.*I2R(i)
trees[i]=CreateDestructable('YTct',x+120.*Cos(an*bj_DEGTORAD),y+120.*Sin(an*bj_DEGTORAD),an,1.,0)
i++
exitwhen i>=5
endloop
TriggerSleepAction(3.)
if(GetWidgetLife(u)>.405){
i=0
loop
if(GetWidgetLife(trees[i])>.405){
KillDestructable(trees[i])
an=72.*I2R(i)
x2=x+112.*Cos(an*bj_DEGTORAD)
y2=y+112.*Sin(an*bj_DEGTORAD)
UnitApplyTimedLife(CreateUnit(p,'e00D',x2,y2,an),'B021',20.)
DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\NightElf\\EntBirthTarget\\EntBirthTarget.mdl",x2,y2))
}
i++
exitwhen i>=5
endloop
AttackCreepOrder(u)
}else{
i=0
loop
KillDestructable(trees[i])
i++
exitwhen i>=5
endloop
}
TriggerSleepAction(3.)
i=0
loop
RemoveDestructable(trees[i])
trees[i]=null
i++
exitwhen i>=5
endloop
u=null
}
private void SpellRejuvenation()
{
unit c=CreateUnit(GetOwningPlayer(unitCaster),'e008',GetUnitX(unitCaster),GetUnitY(unitCaster),0.)
UnitAddAbility(c,'A0AW')
if(IsUnitType(unitCasterTarget, UNIT_TYPE_UNDEAD)) { SetUnitAbilityLevel(c,'A0AW',2) }
IssueTargetOrderById(c,852160,unitCasterTarget)
UnitApplyTimedLife(c,'BTLF',2.)
c=unitCaster
TriggerSleepAction(.8)
AttackCreepOrder(c)
c=null
}
private void SpellRejuvenationGreater()
{
unit c=CreateUnit(GetOwningPlayer(unitCaster),'e008',GetUnitX(unitCaster),GetUnitY(unitCaster),0.)
UnitAddAbility(c,'A0AX')
if(IsUnitType(unitCasterTarget, UNIT_TYPE_UNDEAD)) { SetUnitAbilityLevel(c,'A0AX',2) }
IssueTargetOrderById(c,852160,unitCasterTarget)
UnitApplyTimedLife(c,'BTLF',2.)
c=unitCaster
TriggerSleepAction(.8)
AttackCreepOrder(c)
c=null
}
private void SpellTaunt()
{
unit u=unitCaster
IssueImmediateOrderById(u,852520)
TriggerSleepAction(.33)
AttackCreepOrder(u)
u=null
}
private boolexpr filterAlliedHeal
private bool FilterAlliedHeal()
{
unit u=GetFilterUnit()
real r=GetWidgetLife(u)
bool res=r>.405 and IsUnitAlly(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER) and GetUnitAbilityLevel(u,'A08C')<=0 and GetUnitAbilityLevel(u,'Bhea')<=0 and GetUnitState(u,UNIT_STATE_MAX_LIFE)-r>200.
u=null
return res
}
private void SpellHealing()
{
unit u=unitCaster
//SetWidgetLife(unitCasterTarget,GetWidgetLife(unitCasterTarget)+75.)
UnitAddAbility(unitCasterTarget,'AId2')
DestroyEffect(AddSpecialEffectTarget("mdx\\sfx\\sin2.mdx",unitCasterTarget,"overhead"))
TriggerSleepAction(.5)
AttackCreepOrder(u)
u=null
}
private void SpellHealingGreater()
{
unit u=unitCaster
//SetWidgetLife(unitCasterTarget,GetWidgetLife(unitCasterTarget)+150.)
UnitAddAbility(unitCasterTarget,'AId3')
DestroyEffect(AddSpecialEffectTarget("mdx\\sfx\\sin2.mdx",unitCasterTarget,"overhead"))
TriggerSleepAction(.5)
if(IssueImmediateOrderById(u,852126)){
TriggerSleepAction(1.)
}
//filterPlayer=GetOwningPlayer(u)
//GroupEnumUnitsInRange(pickgroup,GetUnitX(u),GetUnitY(u),300.,filterAlliedHeal)
//unit j=FirstOfGroup(pickgroup)
//if(j!=null and IssueTargetOrderById(u,852063,j)){
// UnitAddAbility(j,'AId3')
// TriggerSleepAction(1.)
// j=null
//}
AttackCreepOrder(u)
u=null
}
/*private void SpellHealingUltra()
{
SetWidgetLife(unitCasterTarget,GetWidgetLife(unitCasterTarget)+200.)
if(GetUnitAbilityLevel(unitCaster,'A0C4')>0){
UnitRemoveAbility(unitCaster,'A0C4')
SpellTreantSprout()
}
}
*/
private void SpellWebActivator()
{
unit u=unitCaster
TriggerSleepAction(3.)
IssueImmediateOrderById(u,852212)
TriggerSleepAction(3.)
IssueImmediateOrderById(u,852602)
AttackCreepOrder(u)
u=null
}
private group g = CreateGroup()
public void WispDied(unit w)
{
unit u
real r
real x = GetUnitX(w)
real y = GetUnitY(w)
filterPlayer = GetOwningPlayer(w)
GroupEnumUnitsInRange(g,x,y,280.,filterEnemyUnit)
loop
u = FirstOfGroup(g)
exitwhen (u == null)
r = 150.0+32000./(160.+Dist(x-GetUnitX(u),y-GetUnitY(u)))
//DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl",u,"head"))
//SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MANA)-100.)
if(GetUnitAbilityLevel(u,'A07H')>0) {r*=0.3}
UnitDamageTarget(w,u,r,true,false,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_UNIVERSAL,WEAPON_TYPE_WHOKNOWS)
GroupRemoveUnit(g,u)
endloop
u=CreateUnit(filterPlayer,'e008',GetUnitX(w),GetUnitY(w),0.)
//ShowUnit(u,false)
//UnitAddAbility(u,'A0ES')
UnitApplyTimedLife(u,'BTLF',0.3)
u=null
}
/*
private void SpellWispStrike()
{
player p=GetOwningPlayer(buildingCaster)
int f=forceId[GetPlayerId(p)]
int i=0
unit u
loop
u=NatureWispControl_GetWisp(f)
UnitRemoveAbility(u,'Awha')
SetUnitOwner(u,p,false)
UnitAddType(u,UNIT_TYPE_SAPPER) //could be buffed!
AttackCreepOrder(u)
UnitApplyTimedLife(u,'BTLF',42.)
i++
TriggerSleepAction(.3)
exitwhen i>=6
endloop
u=null
}
*/
private player fp
private int bb
private boolexpr filterConvertToCreature
private bool FilterConvertToCreature()
{
unit u=GetFilterUnit()
real r=GetWidgetLife(u)
bool b = r>.405 and IsUnitEnemy(u,fp) and IsUnitType(u,UNIT_TYPE_SAPPER) and not IsUnitType(u,UNIT_TYPE_MECHANICAL) and GetUnitAbilityLevel(u,'A07H')<=0
if(b){
b = GetRandomInt(0,99)<60
}
u=null
return b
}
private group cg
private void SpellForestCall(){
unit u
real hp,x,y,a
int ut,n
bb=0
fp=GetOwningPlayer(buildingCaster)
PlaySoundBJ(gg_snd_CallForest)
GroupEnumUnitsInRect(cg,bj_mapInitialPlayableArea,filterConvertToCreature)
loop
u = FirstOfGroup(cg)
exitwhen u == null
hp = GetWidgetLife(u)
if(hp>.405){
if(IsUnitType(u,UNIT_TYPE_FLYING) ){
ut = forestUnits[GetRandomInt(0,1)]
} else {
if(hp<600.) {
ut = forestUnits[GetRandomInt(2,6)]
} else {ut = forestUnits[GetRandomInt(7,9)]}
}
x = GetUnitX(u);y=GetUnitY(u);a=GetUnitFacing(u)
GroupRemoveUnit(cg,u)
fp=GetOwningPlayer(u)
RemoveUnit(u)
CreateUnit(fp,ut,x,y,a)
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\NightElf\\TargetArtLumber\\TargetArtLumber.mdl",x,y))
TriggerSleepAction(0.15)
}
endloop
}
void SpellForestSpirit() {
IssueTargetOrderById(unitCaster, order_attack, unitCasterTarget)
}
/*
private void SpellManaDecrease()
{
unit c = null
real x = 0.
real y = 0.
group g = CreateGroup()
integer i = 0
player p = GetOwningPlayer(buildingCaster)
loop
x = GetRandomReal(-384., 384.)
y = GetRandomReal(-256., 256.)
DestroyEffect(AddSpecialEffect("Units\\NightElf\\Wisp\\WispExplode.mdl",x,y))
c = CreateUnit(p,'h06B',x,y,0.)
GroupAddUnit(g, c)
PauseUnit(c, true)
UnitApplyTimedLife(c,'BTLF',22.)
exitwhen i == 19
i++
endloop
TriggerSleepAction(2.)
loop
c = FirstOfGroup(g)
exitwhen c == null
PauseUnit(c, false)
AttackCreepOrder(c)
GroupRemoveUnit(g, c)
endloop
DestroyGroup(g)
g = null
c = null
p = null
}
*/
/*private void SpellManaDecrease()
{
real x=GetUnitX(buildingCaster)
real y=GetUnitY(buildingCaster)
player p=GetOwningPlayer(buildingCaster)
unit c=CreateUnit(p,'e008',x,y,0.)
UnitAddAbility(c,'A0BR')
UnitApplyTimedLife(c,'BTLF',15.)
c=null
UnitApplyTimedLife(CreateUnit(p,'h02V',x,y,0.),'BTLF',2.)
EnableWeatherEffect(SpellManaDrainWeather,true)
TriggerSleepAction(6.)
EnableWeatherEffect(SpellManaDrainWeather,false)
}*/
private void SpellBanish()
{
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemyUnit)
bj_groupRandomConsidered = 0
bj_groupRandomCurrentPick = null
ForGroup(pickgroup, function GroupPickRandomUnitEnum)
if(bj_groupRandomCurrentPick==null or UnitDispelMagic(bj_groupRandomCurrentPick)){return}
unit c=CreateUnit(filterPlayer,'e008',GetUnitX(bj_groupRandomCurrentPick),GetUnitY(bj_groupRandomCurrentPick),0.)
UnitAddAbility(c,'A0BL')
UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,true)
IssueTargetOrderById(c,852486,bj_groupRandomCurrentPick)
UnitShareVision(bj_groupRandomCurrentPick,filterPlayer,false)
UnitApplyTimedLife(c,'BTLF',1.)
c=null
}
private void SpellTornado()
{
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemyUnit)
bj_groupRandomConsidered = 0
bj_groupRandomCurrentPick = null
ForGroup(pickgroup, function GroupPickRandomUnitEnum)
if(bj_groupRandomCurrentPick==null){return}
unit c=CreateUnit(filterPlayer,'e008',GetUnitX(bj_groupRandomCurrentPick),GetUnitY(bj_groupRandomCurrentPick),0.)
UnitAddAbility(c,tornadoType)
IssuePointOrderById(c,852597,GetUnitX(bj_groupRandomCurrentPick),GetUnitY(bj_groupRandomCurrentPick))
UnitApplyTimedLife(c,'BTLF',5.)
c=null
}
private bool Animationn02C(){
Data_JoinUnitUnit(Attached,'h02J',270.,0.,0.)
return false
}
private bool Animationh002(){
Data_JoinUnitUnit(Attached,'h02J',270.,0.,0.)
Data_JoinUnitUnit(Attached,'h02E',270.,0.,0.)
return false
}
private bool Animationh00Q(){
Data_JoinUnitUnit(Attached,'h02J',270.,0.,0.)
Data_JoinUnitUnit(Attached,'h02E',270.,0.,0.)
Data_JoinUnitUnit(Attached,'h02F',270.,-25.,-25.)
return false
}
private bool Animationh00R(){
Data_JoinUnitUnit(Attached,'h02J',270.,0.,0.)
Data_JoinUnitUnit(Attached,'h02E',270.,0.,0.)
Data_JoinUnitUnit(Attached,'h02F',270.,-35.,-40.)
Data_JoinUnitUnit(Attached,'h02G',211.,-35.,35.)
return false
}
private bool Animationh012(){
Data_JoinUnitUnit(Attached,'h02Q',270.,-35.,30.)
return false
}
private bool Animationh024(){
Data_JoinUnitUnit(Attached,'h02L',270.,0.,0.)
Data_JoinUnitUnit(Attached,'h02M',270.,25,20.)
return false
}
private bool Animationh028(){
Data_JoinUnitUnit(Attached,'h02T',49.,-40.,20.)
//Data_JoinUnitUnit(Attached,'h02S',270.,-45,40.)
return false
}
private void RegisterBuildings()
{
//spiders
//Data_RegisterTrainOrder('n02C','n00T')
//Data_RegisterAttachEffects('n02C',function Animationn02C)
Data_RegisterTrainOrder('h002','n00U')
Data_RegisterAttachEffects('h002',function Animationh002)
Data_RegisterTrainOrder('h00Q','n01N')
Data_RegisterAttachEffects('h00Q',function Animationh00Q)
Data_RegisterTrainOrder('h00R','n01W')
Data_RegisterAttachEffects('h00R',function Animationh00R)
//furbolg
Data_RegisterTrainOrder('h00Y','n026')
Data_RegisterTrainOrder('h012','n028')
Data_RegisterAttachEffects('h012',function Animationh012)
//dryad
Data_RegisterTrainOrder('h013','e006')
Data_RegisterTrainOrder('h01H','e009')
Data_RegisterTrainOrder('h01J','e00C')
//bear
Data_RegisterTrainOrder('h023','n029')
Data_RegisterTrainOrder('h024','n02B')
Data_RegisterAttachEffects('h024',function Animationh024)
//dragon
Data_RegisterTrainOrder('h027','n02A')
//gigant
Data_RegisterTrainOrder('h028','e00F')
Data_RegisterAttachEffects('h028',function Animationh028)
//tower
Data_RegisterTowerRange('n02D',700.)
//wonder
Data_RegisterBuildingSpell('h02D',function SpellForestCall)
//guardian
Data_RegisterBuildingSpell('h02C',function SpellBanish)
//tornado
Data_RegisterBuildingSpell('h02A',function SpellTornado)
}
private void RegisterLumberIncome()
{
Data_SetRace(RACE_NATURE)
Data_RegisterBuilding('h002',.2,true,0,false)
Data_RegisterBuilding('h00Q',.2,true,'h002',false)
Data_RegisterBuilding('h00R',.2,true,'h00Q',false)
Data_RegisterBuilding('h00Y',.2,true,0,false)
Data_RegisterBuilding('h012',.2,true,'h00Y',false)
Data_RegisterBuilding('h013',.2,true,0,false)
Data_RegisterBuilding('h01H',.2,true,'h013',false)
Data_RegisterBuilding('h01J',.2,false,'h01H',false)
Data_RegisterBuilding('h023',.2,true,0,false)
Data_RegisterBuilding('h024',.2,true,'h023',false)
Data_RegisterBuilding('h027',.2,true,0,false)
Data_RegisterBuilding('h028',.2,true,0,true)
//
Data_RegisterBuilding('n02D',.10,false,0,false)
Data_RegisterBuilding('h02A',.12,false,0,false)
Data_RegisterBuilding('h02C',.09,false,0,false)
Data_RegisterBuilding('h02D',.12,false,0,false)
Data_RegisterBuilding('h008',.05,false,0,false) //TB
}
private void RegisterUnitCasts()
{
Data_RegisterUnitSpell('n026','A0C0',function SpellRejuvenation)
Data_RegisterUnitSpell('n028','A0C1',function SpellRejuvenationGreater)
Data_RegisterUnitSpell('e006','A004',function SpellHealing)
Data_RegisterUnitSpell('e009','A0BT',function SpellHealingGreater)
Data_RegisterUnitSpell('e00C','A0BX',function SpellTreantSprout)
Data_RegisterUnitSpell('n01W','A0AV',function SpellWebActivator)
Data_RegisterUnitSpell('e00F','A0BJ',function SpellTaunt)
//random target for forest spirits
//Data_RegisterUnitSpell('n03E','A0IS',function SpellForestSpirit)
}
public void DoGrabTree(unit u)
{
real x=GetUnitX(u)
real y=GetUnitY(u)
real an=GetUnitFacing(u)*bj_DEGTORAD
destructable d=CreateDestructable('VTlt',x+32.*Cos(an),y+32.*Sin(an),0,1.0,0)
//DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\NightElf\\NEDeathMedium\\NEDeath.mdl",GetDestructableX(d),GetDestructableY(d)))
IssueTargetOrderById(u,852511,d)
TriggerSleepAction(0.5)
AttackCreepOrder(u)
TriggerSleepAction(0.3)
AttackCreepOrder(u)
RemoveDestructable(d)
d=null
}
public void init()
{
RegisterBuildings()
RegisterLumberIncome()
RegisterUnitCasts()
//filterAirEnemyUnit=Filter(function FilterAirEnemyUnit)
filterAlliedHeal=Filter(function FilterAlliedHeal)
filterAnyGroundUnit=Filter(function FilterAnyGroundUnit)
filterConvertToCreature=Filter(function FilterConvertToCreature)
//SpellManaDrainWeather=AddWeatherEffect(bj_mapInitialPlayableArea,'FDgh')
//EnableWeatherEffect(SpellManaDrainWeather,false)
forestUnits[0] = 'n03K' //air
forestUnits[1] = 'n03G' //air
forestUnits[2] = 'n03F'
forestUnits[3] = 'n03H'
forestUnits[4] = 'n03I'
forestUnits[5] = 'n03B'
forestUnits[6] = 'n03L'
forestUnits[7] = 'n03C'
forestUnits[8] = 'n03E'
forestUnits[9] = 'n03D'
cg = CreateGroup()
}
endlibrary
//TESH.scrollpos=25
//TESH.alwaysfold=0
library_once Elementals initializer init uses DebugLog, AttackOrders, Functions//LightningStrike,ColdOverforce,FireRiver //FabricLibrary
//int blizzardType='A0D1'//'A0D2'
int meteorType='A0I8'//'A0I9'
int monsoonType='A0I6'//'A0I7'
define private Attached=Data_buildingAttacher
define private buildingCaster=Data_buildingCaster
define private unitCaster=Data_unitCaster
define private unitCasterTarget=Data_unitCasterTarget
define private ST_ABILITY_ID_CANCEL = 'A0EO'
/////////////////////////////////////////////////////////////////////////////////////////////
// ELEMENTS API STARTS HERE
/////////////////////////////////////////////////////////////////////////////////////////////
public int array elements //per player
// !!! IF YOU CHANGE IT YOU SHOULD UPDATE UnitDeathReleaser !!!
private int array ElShrineCnt
/////////////////////////////////////////////////////////////////////////////////////////////
// ELEMENTS API ENDS HERE
/////////////////////////////////////////////////////////////////////////////////////////////
//TODO: create spells for Master of Elements
private void SpellTheSpell()
{
int i=GetRandomInt(0,3)
real a = GetUnitFacing(unitCaster)* bj_DEGTORAD
real x = GetUnitX(unitCaster) //+ 300.0*Cos(a)
real y = GetUnitY(unitCaster) //+ 300.0*Sin(a)
unit uc = unitCaster
a += GetRandomReal(-0.3,0.3)
if(i==0){
//UnitAddAbility(uc,'A0F7')
IssuePointOrderById(uc,852555,x+350.0*Cos(a),y+ 350.0*Sin(a))
}elseif(i==1){
//UnitAddAbility(uc,'A0F6') //lightning
IssuePointOrderById(uc,852125,x+350.0*Cos(a),y+ 350.0*Sin(a))
}
elseif(i==2)
{
//UnitAddAbility(uc,'A0F0')
IssuePointOrderById(uc,852218,x+350.0*Cos(a),y+ 350.0*Sin(a))
}
elseif(i==3)
{
//UnitAddAbility(uc,'A0F0')
IssueTargetOrderById(uc,order_creepthunderbolt,unitCasterTarget)
}
TriggerSleepAction(0.5)
AttackCreepOrder(uc)
SetUnitState(uc,UNIT_STATE_MANA,GetUnitState(uc,UNIT_STATE_MANA)+GetRandomReal(-3.0,3.0))
uc=null
}
private void SpellWaterShift(){
/*
unit u = GetTriggerUnit();
real a = (GetUnitFacing(u)+GetRandomReal(-45,45))*0.017
real r = GetRandomReal(120,200)
TriggerSleepAction(0.3)
SetUnitX(u,GetUnitX(u)+r*Cos(a))
SetUnitY(u,GetUnitY(u)+r*Sin(a))
u = null;*/
}
private void SpellShackles()
{
if (GetRandomReal(0.0,1.0) > 0.75)
{
return;
}
unit u = unitCaster
IssueTargetOrderById(unitCaster,order_magicleash,unitCasterTarget)
TriggerSleepAction(4.0)
AttackCreepOrder(u)
u = null
}
private void SpellGaleAttack(){
unit u = unitCaster;
unit tu
real dmg
TriggerSleepAction(0.1)
if(GetWidgetLife(u)<=.405){u=null;return}
filterPlayer=GetOwningPlayer(u)
GroupEnumUnitsInRange(pickgroup,GetUnitX(u),GetUnitY(u),380.,filterEnemyUnit)
tu=GetRandomUnit(pickgroup)
if(tu==null or GetWidgetLife(tu)<=.405){tu=null;u=null;return}
//DisplayTextToPlayer(Player(0),0.,0.,GetUnitName(u)+">>"+GetUnitName(tu))
real dx = GetUnitX(u)
real dy = GetUnitY(u)
real a = Atan2(GetUnitY(tu) - dy, GetUnitX(tu) - dx)
real r = 460;
IssueTargetOrderById(u,order_carrionswarm,tu)
TriggerSleepAction(0.01)
dx += r*Cos(a) + GetRandomReal(-70.0,70.0)
dy += r*Sin(a) + GetRandomReal(-70.0,70.0)
IssuePointOrderById(u,order_move,dx, dy)
if (GetRandomReal(0.0,1.0) > 0.62)
{
dmg = GetRandomReal(0.2,0.3)*GetUnitState(tu,UNIT_STATE_MAX_LIFE)
UnitRemoveAbility(tu,'A0JV')
UnitAddAbility(tu,'A0JV')
UnitDamageTarget(u,tu,dmg,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_SONIC,WEAPON_TYPE_WHOKNOWS)
//RemoveUnit(u)
}
SetUnitState(u,UNIT_STATE_LIFE,GetUnitState(u,UNIT_STATE_LIFE) - 17.)
u=null;tu=null;
}
private void SpiritSpell()
{
IssueTargetOrderById(unitCaster,852499,unitCaster)
}
private void EarthElemSpell(){
unit u = unitCaster
IssueTargetOrderById(unitCaster,order_creepthunderbolt,unitCasterTarget)
TriggerSleepAction(0.6)
AttackCreepOrder(u)
u = null
}
private void ElementalRain()
{
unit c
unit c1
filterPlayer=GetOwningPlayer(buildingCaster)
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemyUnit)
bj_groupRandomCurrentPick=GetRandomUnit(pickgroup)
if(bj_groupRandomCurrentPick==null){return}
int i=GetRandomInt(0,99)
real x = GetUnitX(bj_groupRandomCurrentPick)
real y = GetUnitY(bj_groupRandomCurrentPick)
real x1 = x + GetRandomReal(-250.0, 250.0)
real y1 = y + GetRandomReal(-200.0, 200.0)
x += GetRandomReal(-250.0, 250.0)
y += GetRandomReal(-200.0, 200.0)
c=CreateUnit(filterPlayer,'e008',x,y,0.)
c1=CreateUnit(filterPlayer,'e008',x1,y1,0.)
UnitAddAbility(c1,meteorType)
UnitAddAbility(c,monsoonType)
IssuePointOrderById(c1,order_rainofchaos,x1,y1)
IssuePointOrderById(c,order_rainofchaos,x1,y1)
UnitApplyTimedLife(c1,'BTLF',8.)
UnitApplyTimedLife(c,'BTLF',8.)
c=null
c1=null
}
private void SpellDistort()
{
unit u
real mp
real mpb
filterPlayer=GetOwningPlayer(buildingCaster)
boolean unitwm = GetRandomInt(0,99) > 21
if (unitwm)
{ GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemyUnitWMana) }
else { GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemySpecialWMana) }
bj_groupRandomCurrentPick=GetRandomUnit(pickgroup)
if(bj_groupRandomCurrentPick==null){return}
if(UnitDispelMagic(bj_groupRandomCurrentPick)){return}
mp = GetUnitState(bj_groupRandomCurrentPick,UNIT_STATE_MANA)
if(mp > 1.0 ){
mpb = GetRandomReal(20, 30)
if (mpb > mp) {mpb = mp}
SetUnitState(bj_groupRandomCurrentPick,UNIT_STATE_MANA, mp - mpb)
UnitDamageTarget(buildingCaster,bj_groupRandomCurrentPick,mpb * 4.0,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_SONIC,WEAPON_TYPE_WHOKNOWS)
}
if (unitwm)
{
UnitAddAbility(bj_groupRandomCurrentPick,'A0HJ') //-spell res
UnitAddAbility(bj_groupRandomCurrentPick,'A0IQ') //buf
}
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIam\\AIamTarget.mdl",bj_groupRandomCurrentPick,"origin"))
}
private boolexpr filterAlliedUnit
private bool FilterAlliedUnit()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>.405 and IsUnitAlly(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER) and GetUnitAbilityLevel(u,'A0F4')<=0
u=null
return res
}
private boolexpr filterAlliedNonMechUnit
private bool FilterAlliedNonMechUnit()
{
unit u=GetFilterUnit()
bool res=GetWidgetLife(u)>.405 and IsUnitAlly(u,filterPlayer) and IsUnitType(u,UNIT_TYPE_SAPPER) and not IsUnitType(u,UNIT_TYPE_MECHANICAL)
u=null
return res
}
//A0F4
private boolexpr filterAnyWeakCombatUnit
private bool FilterAnyWeakCombatUnit()
{
unit u=GetFilterUnit()
bool b=GetWidgetLife(u)>.405 and IsUnitType(u,UNIT_TYPE_SAPPER) and GetUnitState(u,UNIT_STATE_LIFE) <= 200.0
u=null
return b
}
private void SpellEnchant()
{
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea, filterAnyWeakCombatUnit)
bj_groupRandomCurrentPick=GetRandomUnit(pickgroup)
if(bj_groupRandomCurrentPick==null){
return
}
//DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl",bj_groupRandomCurrentPick,"overhead"))
DestroyEffect(AddSpecialEffect("UI\\Feedback\\GoldCredit\\GoldCredit.mdl",GetUnitX(buildingCaster),GetUnitY(buildingCaster)))
if(GetUnitAbilityLevel(bj_groupRandomCurrentPick,'A07H')>0 )
{
return
}
DestroyEffect(AddSpecialEffect("UI\\Feedback\\GoldCredit\\GoldCredit.mdl",GetUnitX(bj_groupRandomCurrentPick),GetUnitY(bj_groupRandomCurrentPick)))
SetPlayerState(filterPlayer,PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(filterPlayer,PLAYER_STATE_RESOURCE_GOLD) + 5);
KillUnit(bj_groupRandomCurrentPick)
//SetUnitState(bj_groupRandomCurrentPick,UNIT_STATE_LIFE, hp * GetRandomReal(0.05, 0.25));
//DisplayTextToPlayer(Player(0),0.,0.,GetUnitName(bj_groupRandomCurrentPick)+" +" +I2S(hpr));
//i = GetRandomInt(0,2)
//if (i==0) { ab = 'A0FG' }
//elseif (i==1) {ab='A0FI'}
//else {ab='A0FH'}
//UnitAddAbility(bj_groupRandomCurrentPick,ab)
//SetUnitState(bj_groupRandomCurrentPick, UNIT_STATE_LIFE, GetUnitState(bj_groupRandomCurrentPick,UNIT_STATE_LIFE)+100.0)
//UnitAddAbility(bj_groupRandomCurrentPick,'A0F4') // FLAG
//AttackCreepOrder(bj_groupRandomCurrentPick) //orb effect
}
private bool Animationh03X(){
Data_JoinUnitUnit(Attached,'h050',270.,0.,28.)
Data_JoinUnitUnit(Attached,'h050',90.,0.,-28.)
return false
}
private bool Animationh03Y(){
Data_JoinUnitUnit(Attached,'h04Y',270.,0.,28.)
Data_JoinUnitUnit(Attached,'h050',90.,0.,-28.)
return false
}
private bool Animationh03Z(){
Data_JoinUnitUnit(Attached,'h04Y',270.,0.,28.)
Data_JoinUnitUnit(Attached,'h04Y',90.,0.,-28.)
return false
}
private bool Animationh040(){
Data_JoinUnitUnit(Attached,'h04Y',270.,0.,28.)
Data_JoinUnitUnit(Attached,'h050',90.,0.,-28.)
return false
}
private bool Animationh041(){
Data_JoinUnitUnit(Attached,'h04Y',270.,0.,28.)
Data_JoinUnitUnit(Attached,'h04Y',90.,0.,-28.)
Data_JoinUnitUnit(Attached,'h058',270.,0.,0.)
return false
}
private bool Animationh042(){
Data_JoinUnitUnit(Attached,'h04Y',270.,0.,28.)
Data_JoinUnitUnit(Attached,'h050',90.,0.,-28.)
Data_JoinUnitUnit(Attached,'h052',270.,0.,0.)
return false
}
private bool Animationh044(){
Data_JoinUnitUnit(Attached,'h04Y',270.,0.,28.)
Data_JoinUnitUnit(Attached,'h04Y',90.,0.,-28.)
Data_JoinUnitUnit(Attached,'h053',270.,0.,0.)
return false
}
private bool Animationh045(){
Data_JoinUnitUnit(Attached,'h04Y',270.,0.,28.)
Data_JoinUnitUnit(Attached,'h050',90.,0.,-28.)
Data_JoinUnitUnit(Attached,'h05O',270.,0.,0.)
return false
}
private bool Animationh046(){
Data_JoinUnitUnit(Attached,'h04Y',270.,0.,28.)
Data_JoinUnitUnit(Attached,'h04Y',90.,0.,-28.)
Data_JoinUnitUnit(Attached,'h057',270.,0.,0.)
Data_JoinUnitUnit(Attached,'h05P',270.,0.,0.)
return false
}
private bool Animationh04A(){
Data_JoinUnitUnit(Attached,'h050',270.,0.,28.)
Data_JoinUnitUnit(Attached,'h050',90.,0.,-28.)
return false
}
private bool Animationh04C(){
Data_JoinUnitUnit(Attached,'h04Y',270.,0.,28.)
Data_JoinUnitUnit(Attached,'h050',90.,0.,-28.)
Data_JoinUnitUnit(Attached,'h05K',90.,0.,0.)
return false
}
private bool Animationh04D(){
Data_JoinUnitUnit(Attached,'h04Y',270.,0.,28.)
Data_JoinUnitUnit(Attached,'h04Y',90.,0.,-28.)
Data_JoinUnitUnit(Attached,'h05B',90.,0.,0.)
return false
}
private bool Animationh04E(){
Data_JoinUnitUnit(Attached,'h04Y',270.,0.,28.)
Data_JoinUnitUnit(Attached,'h04Y',90.,0.,-28.)
Data_JoinUnitUnit(Attached,'h05Y',270.,0.,0.)
Data_JoinUnitUnit(Attached,'h05Q',270.,0.,0.)
Data_JoinUnitUnit(Attached,'h05S',270.,0.,0.)
Data_JoinUnitUnit(Attached,'h05W',270.,0.,0.)
return false
}
private bool Animationh060(){
Data_JoinUnitUnit(Attached,'h065',300.,0.,0.)
return false
}
private bool Animationh05Z(){
Data_JoinUnitUnit(Attached,'h066',270.,0.,0.)
return false
}
private bool Animationh061(){
Data_JoinUnitUnit(Attached,'h067',270.,0.,0.)
return false
}
private bool Animationh063(){
Data_JoinUnitUnit(Attached,'h064',270.,0.,0.)
return false
}
private void RegisterBuildings()
{
Data_RegisterTrainOrder('h03Y','h02X')
Data_RegisterTrainOrder('h03Z','h02Y')
Data_RegisterTrainOrder('h040','h034')
Data_RegisterTrainOrder('h041','h03N')
Data_RegisterTrainOrder('h042','h03P')
Data_RegisterTrainOrder('h044','h03R')
Data_RegisterTrainOrder('h045','h02Z')
Data_RegisterTrainOrder('h046','h030')
//Data_RegisterTrainOrder('h04A','o00C')
Data_RegisterTrainOrder('h04C','o00G') //air
//Data_RegisterTrainOrder('h04D','o00H')
// Master
Data_RegisterTrainOrder('h04E','h03V')
//Data_RegisterAttachEffects('h03X',function Animationh03X)
//Data_RegisterAttachEffects('h03Y',function Animationh03Y)
Data_RegisterAttachEffects('h03Z',function Animationh03Z)
Data_RegisterAttachEffects('h040',function Animationh040)
Data_RegisterAttachEffects('h041',function Animationh041)
Data_RegisterAttachEffects('h042',function Animationh042)
Data_RegisterAttachEffects('h044',function Animationh044)
Data_RegisterAttachEffects('h045',function Animationh045)
Data_RegisterAttachEffects('h046',function Animationh046)
//Data_RegisterAttachEffects('h04A',function Animationh04A)
Data_RegisterAttachEffects('h04C',function Animationh04C)
Data_RegisterAttachEffects('h04D',function Animationh04D)
Data_RegisterAttachEffects('h04E',function Animationh04E)
Data_RegisterAttachEffects('h05Z',function Animationh05Z)
Data_RegisterAttachEffects('h060',function Animationh060)
Data_RegisterAttachEffects('h061',function Animationh061)
Data_RegisterAttachEffects('h063',function Animationh063)
// Obelisk of Elements
Data_RegisterBuildingSpell('h060',function SpellEnchant)
// Book of Conjuration
Data_RegisterBuildingSpell('h05Z',function ElementalRain)
//Distorter
Data_RegisterBuildingSpell('h062',function SpellDistort)
// tower
Data_RegisterTowerRange('h061',850.)
//Linker
//Data_RegisterBuildingSpell('h063',function SpellSpiritLink) //A0KC
}
private void RegisterLumberIncome()
{
Data_SetRace(RACE_ELEMENT)
Data_RegisterBuilding('h03Y',.2,true,0,false) //w
Data_RegisterBuilding('h03Z',.2,true,'h03Y',false)
Data_RegisterBuilding('h042',.2,true,0,false)//l
Data_RegisterBuilding('h044',.2,true,'h042',false)
Data_RegisterBuilding('h045',.2,true,0,false) //fire
Data_RegisterBuilding('h046',.2,true,'h045',false)
Data_RegisterBuilding('h04E',.2,false,'h046',false)
//Data_RegisterBuilding('h04A',.2,true,0,false)
Data_RegisterBuilding('h04C',.2,true,0,false)
//Data_RegisterBuilding('h04D',.2,true,'h04C',false)
Data_RegisterBuilding('h040',.18,true,0,true)
Data_RegisterBuilding('h041',.18,true,'h040',true)
//
Data_RegisterBuilding('h061',.10,false,0,false)
Data_RegisterBuilding('h060',.12,false,0,false)
Data_RegisterBuilding('h05Z',.09,false,0,false)
Data_RegisterBuilding('h062',.12,false,0,false)
Data_RegisterBuilding('h008',.05,false,0,false) //TB
}
private void RegisterUnitCasts()
{
Data_RegisterUnitSpell('h03V','A0E1',function SpellTheSpell) //Master of Elements
Data_RegisterUnitSpell('e00G','A0F9',function SpiritSpell) //Elemental spirit
Data_RegisterUnitSpell('h03N','A0IV',function EarthElemSpell)
Data_RegisterUnitSpell('h02X','A0JP',function SpellWaterShift)
Data_RegisterUnitSpell('h02Y','A0JP',function SpellWaterShift)
Data_RegisterUnitSpell('o00G','A0IX',function SpellGaleAttack)
Data_RegisterUnitSpell('h030','A0KG',function SpellShackles) //fire elem
}
public void acceptTower(unit u)
{
int i=GetRandomInt(0,99)
if(i<33){
UnitAddAbility(u,'A0D8')
}elseif(i<66){
UnitAddAbility(u,'A0D9')
UnitAddAbility(u,'A0EX')
}else{
UnitAddAbility(u,'A0FM')
//UnitAddAbility(u,'A0EV')
}
}
private int GetShrChance(int id)
{
if(ElShrineCnt[id]==0) {return 0}
else
{return 43+R2I(SquareRoot(300.*I2R(ElShrineCnt[id])))}
}
public void InvokeShrineActions(player p)
{
//int id=forceId[GetPlayerId(p)]
//ElShrineCnt[id]+=1
//chanceToGetElSpirit[id] = GetShrChance(id)
}
public void OnShrineDeath(unit u)
{
int id=forceId[GetPlayerId(GetOwningPlayer(u))]
ElShrineCnt[id]-=1
chanceToGetElSpirit[id] = GetShrChance(id)
}
void ElementDies(unit du,unit ku)
{
real x = GetUnitX(du)
real y = GetUnitY(du)
unit d=ku
int dut = GetUnitTypeId(du)
unit c
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Flare\\FlareCaster.mdl",x,y))
TriggerSleepAction(GetRandomReal(0.3,0.6))
RemoveUnit(du)
c=CreateUnit(GetOwningPlayer(du),'e008',x,y,0.)
if(dut=='h034') {//earth - stomp
UnitAddAbility(c,'A0IY')
if(not IssueImmediateOrderById(c,852127) ){ DisplayTextToPlayer(GetLocalPlayer(),0.,0., "A0IY" ) }
} elseif( dut=='h03N') {
UnitAddAbility(c,'A0IY')
SetUnitAbilityLevel(c,'A0IY',2)
if(not IssueImmediateOrderById(c,852127) ){ DisplayTextToPlayer(GetLocalPlayer(),0.,0., "A0IY2" ) }
} elseif(dut=='h02X'){//water - heal
UnitAddAbility(c,'A0IZ')
if(not IssueImmediateOrderById(c,852282) ){ DisplayTextToPlayer(GetLocalPlayer(),0.,0., "A0IZ" ) }
}elseif(dut=='h02Y') {
UnitAddAbility(c,'A0IZ')
SetUnitAbilityLevel(c,'A0IZ',2)
if(not IssueImmediateOrderById(c,852282) ){ DisplayTextToPlayer(GetLocalPlayer(),0.,0., "A0IZ2" ) }
} elseif(dut=='h02Z'){//fire - volcanolike?
UnitAddAbility(c,'A0J0')
if(not IssuePointOrderById(c,order_rainoffire,x,y) ){ DisplayTextToPlayer(GetLocalPlayer(),0.,0., "A0J0" ) }
} elseif(dut=='h030') {
UnitAddAbility(c,'A0J0')
SetUnitAbilityLevel(c,'A0J0',2)
if(not IssuePointOrderById(c,order_rainoffire,x,y) ){ DisplayTextToPlayer(GetLocalPlayer(),0.,0., "A0J02" ) }
} elseif(dut=='h03P'){//lightning - forklightning
UnitAddAbility(c,'A0J1')
IssueTargetOrderById(c,order_forkedlightning,d)
if(not IssueTargetOrderById(c,order_forkedlightning,d) ){ //DisplayTextToPlayer(GetLocalPlayer(),0.,0., "A0J1" )
}
} elseif(dut=='h03R') {
UnitAddAbility(c,'A0J1')
SetUnitAbilityLevel(c,'A0J1',2)
if(not IssueTargetOrderById(c,order_forkedlightning,d) ){ //DisplayTextToPlayer(GetLocalPlayer(),0.,0., "A0J12" )
}
}
//UnitApplyTimedLife(c,'BTLF',1.0)
d=null
}
public void init()
{
RegisterBuildings()
RegisterLumberIncome()
RegisterUnitCasts()
filterAlliedUnit=Filter(function FilterAlliedUnit)
filterAlliedNonMechUnit=Filter(function FilterAlliedNonMechUnit)
filterAnyWeakCombatUnit = Filter(function FilterAnyWeakCombatUnit)
}
endlibrary
//TESH.scrollpos=254
//TESH.alwaysfold=0
library_once Desert initializer init uses Functions
define private Attached=Data_buildingAttacher
define private buildingCaster=Data_buildingCaster
define private unitCaster=Data_unitCaster
define private unitCasterTarget=Data_unitCasterTarget
private player NeutralAggressive
image CreateGroundTex(string tex, real x,real y, real scale)
{
image i = CreateImage( tex, scale,scale,0, x - ( scale * 0.5 ) , y - ( scale * 0.5 ) , 0 , 0 , 0 , 0 , 2)
SetImageRenderAlways( i, true )
ShowImage( i, true)
return i
}
private void SpellQuickSand()
{
unit c
int i=12
player p=GetOwningPlayer(buildingCaster)
filterPlayer = p
real x = GetUnitX(buildingCaster)
real y = GetUnitY(buildingCaster)
unit u
image im
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",x,y))
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterEnemyGroundUnit)
bj_groupRandomCurrentPick = null
bj_groupRandomCurrentPick=GetRandomUnit(pickgroup)
if(bj_groupRandomCurrentPick==null or UnitDispelMagic(bj_groupRandomCurrentPick)){return}
x=GetUnitX(bj_groupRandomCurrentPick)
y=GetUnitY(bj_groupRandomCurrentPick)
c=CreateUnit(GetOwningPlayer(buildingCaster),'e00I',x,y,0.0)
UnitApplyTimedLife(c,'BTLF',12.0)
im = CreateGroundTex("qs.blp",x,y,240.0)
loop
TriggerSleepAction(1.0)
filterPlayer = p
GroupEnumUnitsInRange(pickgroup,x,y,128.0,filterEnemyGroundUnit)
loop
u = FirstOfGroup(pickgroup)
exitwhen(u==null)
GroupRemoveUnit(pickgroup,u)
if(GetUnitAbilityLevel(u,'A07H')<=0) {
UnitAddAbility(u,'A0IL') //animation
IssueTargetOrderById(u,order_impale,u)
TriggerSleepAction(2.8)
ShowUnit(u,false)
RemoveUnit(u)
i=0
exitwhen true
}
endloop
i--
exitwhen i<=0
endloop
DestroyImage(im)
im=null
u=null
c=null
}
private void SpellPeyote()
{
unit c
unit t
int i = 4
player pl=GetOwningPlayer(buildingCaster)
filterPlayer = pl
player oo
DestroyEffect(AddSpecialEffect("Abilities\\Weapons\\ChimaeraAcidMissile\\ChimaeraAcidMissile.mdl",GetUnitX(buildingCaster),GetUnitY(buildingCaster)))
GroupEnumUnitsInRect(pickgroup,bj_mapInitialPlayableArea,filterLivingEnemy)
bj_groupRandomCurrentPick=GetRandomUnit(pickgroup)
if(bj_groupRandomCurrentPick==null){return}
c=bj_groupRandomCurrentPick
if(c==null or UnitDispelMagic(c)) {return}
t = CreateUnit(pl,'e008',GetUnitX(c),GetUnitY(c),0.) ///sleep "NeutralAggressive"
oo = GetOwningPlayer(c)
UnitAddAbility(t,'A0JD')
IssueTargetOrderById(t,order_acidbomb,c)
UnitAddAbility(t,'A00N')
TriggerSleepAction(4.0)
if(GetRandomInt(0,99)>76) { //mad
//UnitShareVision(c,pl,true)
//IssueTargetOrderById(t,852581,c)
//UnitShareVision(c,pl,false)
SetUnitOwner(c,pl,false)
TriggerSleepAction(GetRandomReal(0.8,3.5))
SetUnitOwner(c,oo,true)
}
UnitApplyTimedLife(t,'BTLF',1.)
//
c=null
t=null
}
private weathereffect weSS
private void SpellSandStorm()
{
unit c
EnableWeatherEffect(weSS, true)
c=CreateUnit(GetOwningPlayer(buildingCaster),'e008',0.,3500.,0.)
UnitAddAbility(c,'A02B') //sandstorm
IssuePointOrderById(c,852592,16.,3500.)//"cloudoffog"
UnitAddAbility(c,'A0GC') //+damage aura
UnitApplyTimedLife(c,'BTLF',8.0)
c=buildingCaster
SetUnitAnimation(c,"stand work")
TriggerSleepAction( 6.0 )
EnableWeatherEffect(weSS, false)
SetUnitAnimation(c,"stand")
c=null
}
private void SpellSandCloud()
{
unit ca=CreateUnit(GetOwningPlayer(unitCaster),'e008',GetUnitX(unitCasterTarget),GetUnitY(unitCasterTarget),0.)
int i = 0
if(GetUnitTypeId(unitCaster)=='n035') { UnitAddAbility(ca,'A0HP') }
else { UnitAddAbility(ca,'A00I') }
UnitApplyTimedLife(ca,'BTLF',5.7)
AttackCreepOrder(unitCaster)
loop
if(not IssuePointOrderById(ca,852592,GetUnitX(unitCasterTarget),GetUnitY(unitCasterTarget)) ) {
//failed
//DisplayTextToPlayer(GetLocalPlayer(),0.,0.,GetUnitName(unitCaster)+"->"+GetUnitName(unitCasterTarget)+":"+GetUnitName(ca))
}
TriggerSleepAction(1.0)
i++
exitwhen (i>4)
endloop
ca=null
}
private void OgreLordsSpell()
{
unit u = unitCaster
AttackCreepOrder(u)
TriggerSleepAction(GetRandomReal(0.1,0.3))
IssueImmediateOrderById(unitCaster,852100)
TriggerSleepAction(0.1)
AttackCreepOrder(unitCaster)
u=null
}
private void GnollsSpell()
{
IssueTargetOrderById(unitCaster, 851983, unitCasterTarget)
}
private void HarpyStealLifeSpell()
{
real HP,thp
unit u = unitCasterTarget
unit cu = unitCaster
TriggerSleepAction(GetRandomReal(0.1,0.6))
HP = GetRandomReal(60.0,90.0)
thp = GetWidgetLife(u)
if(HP>thp) {HP = thp}
UnitDamageTarget(cu,u,HP,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
SetUnitState(cu,UNIT_STATE_LIFE,GetWidgetLife(cu)+HP)
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIma\\AImaTarget.mdl",cu,"origin"))
DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIma\\AImaTarget.mdl",u,"overhead"))
u=null
cu=null
}
private void MatriarchSpell()
{
unit ca
int abil
int r=GetRandomInt(0,99)
if(r<18) { //Swarm
ca=unitCaster
abil = 'A0HB'+GetRandomInt(0,2)
UnitAddAbility(ca,abil)
IssueImmediateOrderById(ca,order_elementalfury)
TriggerSleepAction(5.0)
UnitRemoveAbility(ca,abil)
AttackCreepOrder(ca)
ca=null
} elseif(r>69) { //boulders
ca=CreateUnit(GetOwningPlayer(unitCaster),'e008',GetUnitX(unitCasterTarget),GetUnitY(unitCasterTarget),0.)
UnitAddAbility(ca,'A0H0')
IssueTargetOrderById(ca,852593,unitCasterTarget)
UnitApplyTimedLife(ca,'BTLF',2.1)
ca=null
AttackCreepOrder(unitCaster)
}
}
private bool AnimationToS() {
Data_JoinUnitUnit(Attached,'h03H',0.,0.,0.)
return false
}
private void RegisterBuildings()
{
Data_SetRace(RACE_DESERT)
//1 gnoll
Data_RegisterTrainOrder('n02O','n02S');
Data_RegisterBuilding('n02O',.2,true,0,false)
//gnoll-amb
Data_RegisterTrainOrder('n02I','n02T');
Data_RegisterBuilding('n02I',.2,true,'n02O',false)
//2 harpy
Data_RegisterTrainOrder('n02K','n02W');
Data_RegisterBuilding('n02K',.2,true,0,false)
//harpy-witch
Data_RegisterTrainOrder('n031','n032');
Data_RegisterBuilding('n031',.2,true,'n02K',false)
//Harpy-Matr
Data_RegisterTrainOrder('n033','n034');
Data_RegisterBuilding('n033',.2,true,'n031',false)
//3 ogre
Data_RegisterTrainOrder('n02L','n02X');
Data_RegisterBuilding('n02L',.18,true,0,true)
//ogrelord
Data_RegisterTrainOrder('n02R','n02Y');
Data_RegisterBuilding('n02R',.18,true,'n02L',true)
//4 Quillboar
Data_RegisterTrainOrder('n02J','n02V');
Data_RegisterBuilding('n02J',.2,true,0,false)
//Razor
Data_RegisterTrainOrder('n02N','n02U');
Data_RegisterBuilding('n02N',.2,true,'n02J',false)
//5 Rhino
Data_RegisterTrainOrder('n02M','n02Z');
Data_RegisterBuilding('n02M',.2,true,0,false)
//6 Sandkin
Data_RegisterTrainOrder('n02P','n030');
Data_RegisterBuilding('n02P',.2,true,0,false)
//6 Mon.Sandkin
Data_RegisterTrainOrder('n036','n035');
Data_RegisterBuilding('n036',.2,true,'n02P',false)
//tower
Data_RegisterTowerRange('h06H',800.);
Data_RegisterBuilding('h06H',.10,false,0,false)
//Snakes
Data_RegisterBuildingSpell('h06L',function SpellQuickSand);
Data_RegisterBuilding('h06L',.12,false,0,false)
//Peyote
Data_RegisterBuildingSpell('h06I',function SpellPeyote);
Data_RegisterBuilding('h06I',.12,false,0,false)
//ToS
Data_RegisterBuildingSpell('h06M',function SpellSandStorm);
Data_RegisterBuilding('h06M',.09,false,0,false)
Data_RegisterAttachEffects('h06M',function AnimationToS)
Data_RegisterBuilding('h008',.05,false,0,false) //TB
}
private void RegisterUnitCasts()
{
Data_RegisterUnitSpell('n030','A0G8',function SpellSandCloud) //sandkin
Data_RegisterUnitSpell('n035','A0G8',function SpellSandCloud) //m.sandkin
Data_RegisterUnitSpell('n02Y','A0GB',function OgreLordsSpell) //ogre
Data_RegisterUnitSpell('n02S','A0HK',function GnollsSpell) //gnoll
Data_RegisterUnitSpell('n02T','A0HK',function GnollsSpell) //gnoll-a
Data_RegisterUnitSpell('n034','A0H1',function MatriarchSpell)
Data_RegisterUnitSpell('n032','A0G9',function HarpyStealLifeSpell) //witch
}
private bool Animation_n033(){
Data_JoinUnitUnit(Attached,'h071',45.,0.,0.)
return false
}
public void init()
{
//preload?
/*unit ca=CreateUnit(Player(0),'e008',0.,0.,0.)
UnitAddAbility(ca,'A0DA')
IssuePointOrderById(ca,852473,0.,0.)
UnitApplyTimedLife(ca,'BTLF',0.4)
ca=CreateUnit(Player(0),'e008',0.,0.,0.)
UnitAddAbility(ca,'A0GI')
IssuePointOrderById(ca,852473,0.,0.)
UnitApplyTimedLife(ca,'BTLF',0.4)
ca=null*/
RegisterBuildings()
RegisterUnitCasts()
weSS = AddWeatherEffect(bj_mapInitialPlayableArea, 'WNcw')
EnableWeatherEffect(weSS,false)
Data_RegisterAttachEffects('n033',function Animation_n033)
NeutralAggressive = Player(12)
}
endlibrary