[FUNCTION F_CHECKALLGUILDS_ALLYPOINTS]
FORINSTANCES i_guildstone
	IF (<TAG0.ALLYPOINTS> > 100)
	TAG0.ALLYPOINTS -= <EVAL (<TAG0.ALLYPOINTS>*3)/100>
	ALLMEMBERS -1,sysmessage @0ad The guild now has <dTAG0.ALLYPOINTS> Alliance Points.
	ENDIF
ENDFOR

[DEFNAME guild_domination_stuff]
GUILDDOM_DIVISOR 5
guilddom_town_1 Britain
guilddom_town_2 Minoc
guilddom_town_3 Cove
guilddom_town_4 Jhelom
guilddom_town_5 Moonglow
guilddom_town_6 Nujelm
guilddom_town_7 Trinsic
guilddom_town_8 Vesper
guilddom_town_9 Yew
guilddom_townval_1 2100000
guilddom_townval_2 1900000
guilddom_townval_3 1200000
guilddom_townval_4 1200000
guilddom_townval_5 1800000
guilddom_townval_6 1600000
guilddom_townval_7 1900000
guilddom_townval_8 1400000
guilddom_townval_9 1100000

/////////////////////////////////////////////////

[FUNCTION F_GUILDDOM_GIVE_PRIZE]
IF (<TAG0.GUILDDOM.RECEIVEPRIZE>)
	IF (<FLOATVAL 0.75> > <RANDOMDOUBLE>)
	LOCAL.OLDNEW=<NEW>
		DORAND 13
			BEGIN
			SERV.NEWITEM=i_pet_armor_steed
			NEW.TYPE=T_SHRINK_FIX
			NEW.TAG.anatomy=75.6
			NEW.TAG.bonded=01
			NEW.TAG.bondedowner=011be6
			NEW.TAG.dex=130
			NEW.TAG.exp=00
			NEW.TAG.fame=0bb8
			NEW.TAG.hits=014a
			NEW.TAG.id=c_m_armor_steed
			NEW.TAG.int=0234
			NEW.TAG.jadropoustat=00
			NEW.TAG.karma=0fa0
			NEW.TAG.level=00
			NEW.TAG.magery=0.0
			NEW.TAG.magicresist=0.0
			NEW.TAG.mana=0234
			NEW.TAG.maxhits=200
			NEW.TAG.maxmana=0234
			NEW.TAG.maxstam=096
			NEW.TAG.stam=096
			NEW.TAG.str=100
			NEW.TAG.tactics=118.0
			NEW.TAG.wrestling=119.0
			END
		SERV.NEWITEM=i_sorcerer_chest
		SERV.NEWITEM=i_sorcerer_legs
		SERV.NEWITEM=i_sorcerer_hat
		SERV.NEWITEM=i_sorcerer_arms
		SERV.NEWITEM=i_sorcerer_gloves
		SERV.NEWITEM=i_sorcerer_gorget
		SERV.NEWITEM=i_Clainins_Spellbook
		SERV.NEWITEM=i_snowman
		SERV.NEWITEM=i_pet_chief_paroxysmus
		SERV.NEWITEM=i_pet_hydra
		SERV.NEWITEM=i_reward_globe_sosaria
		SERV.NEWITEM=i_reward_minitree
		ENDDO
	NEW.TAG.OWNEDTOWN=<ARGS>
	NEW.GIVEITEMEVENT T_FACTION_ITEM
	NEW.CONT=<FINDLAYER.<DEF.layer_bankbox>.UID>
	NEW.UPDATE
	NEW=<LOCAL.OLDNEW>
	ENDIF
TAG.GUILDDOM.RECEIVEPRIZE=
ENDIF

[FUNCTION F_GUILDDOM_ENTERING_MESSAGE]
LOCAL.ALIGN=<SRC.GUILD.ALIGN>
IF (<GUILD>)
	IF (<GUILD.ALIGN> != <LOCAL.ALIGN>)
		IF (<LOCAL.ALIGN> == 1)
		SYSMESSAGE @,3,1 Attention! Order is entering <ARGS>!
		ELIF (<LOCAL.ALIGN> == 2)
		SYSMESSAGE @,3,1 Attention! Chaos is entering <ARGS>!
		ENDIF
	ENDIF
ENDIF

[REGIONTYPE R_DOMINATED]
ON=@Enter
REF1=<TAG0.GUILDDOM.GUILD>
IF (<REF1.ALIGN> == 2)
SRC.SYSMESSAGE @04ac,3,1 This town is currently dominated by <UID.<TAG0.GUILDDOM.GUILD>.NAME> (Chaos)
SRC.SYSMESSAGE @33,3,1 WARNING: This town is currently out of guards!
ELIF (<REF1.ALIGN> == 1)
SRC.SYSMESSAGE @04ac,3,1 This town is currently dominated by <UID.<TAG0.GUILDDOM.GUILD>.NAME> (Order)
ENDIF
IF (<SRC.ISPLAYER>)
	IF (<SRC.GUILD>)
		IF (<REF1.ALIGN> != <SRC.GUILD.ALIGN>)
		SERV.ALLCLIENTS F_GUILDDOM_ENTERING_MESSAGE <NAME>
		ENDIF
	ENDIF
ENDIF

[TYPEDEF T_TOWNDOMINATED]
ON=@Timer
IF (<TAG0.ALIGN> == 2)
REGION.GUARDED=0
ENDIF
MORE1 --
IF (<MORE1> <= 0)
REGION.GUARDED=
SERV.B @55 The dominating forces at <REGION.NAME> have been driven back!
TRY VAR.GUILDDOM.<DEF.GUILDDOM_TOWN_<dTAG0.TOWN>>=
REGION.EVENTS -R_DOMINATED
REGION.TAG.GUILDDOM.GUILD
REMOVE
ELSE
TIMER=1
ENDIF
RETURN 1

[TYPEDEF T_ALLIANCE_PEDESTAL]
ON=@Timer
REGION.GUARDED=0
TIMER=60*1
RETURN 1

////////////////////////////////////

[DIALOG d_guild_domination]
40,55
src.closealldialogs

page 0
resizepic 0 0 5054 550 400
resizepic 10 10 3000 530 380
dhtmlgump 20 15 220 35 0 0 Guild: <name>
dhtmlgump 300 15 220 35 0 0 Alliance Points: <dtag0.allypoints>
FOR 9
	IF (!(<VAR0.GUILDDOM.<DEF.guilddom_town_<dLOCAL._FOR>>>))
	dhtmlgump 80 <EVAL (30*<LOCAL._FOR>)+40> 220 35 0 0 <DEF.guilddom_town_<dLOCAL._FOR>> : <dDEF.guilddom_townval_<dLOCAL._FOR>>
	ELIF (<VAR0.GUILDDOM.<DEF.guilddom_town_<dLOCAL._FOR>>> == 1)
	dhtmlgump 80 <EVAL (30*<LOCAL._FOR>)+40> 220 35 0 0 <DEF.BFONT_GREEN><DEF.guilddom_town_<dLOCAL._FOR>> : <dDEF.guilddom_townval_<dLOCAL._FOR>><DEF.BFONTE>
	ELIF (<VAR0.GUILDDOM.<DEF.guilddom_town_<dLOCAL._FOR>>> == 2)
	dhtmlgump 80 <EVAL (30*<LOCAL._FOR>)+40> 220 35 0 0 <DEF.BFONT_RED><DEF.guilddom_town_<dLOCAL._FOR>> : <dDEF.guilddom_townval_<dLOCAL._FOR>><DEF.BFONTE>
	ENDIF
button 40 <EVAL (30*<LOCAL._FOR>)+40> 4005 4007 1 0 <dLOCAL._FOR> 
ENDFOR
dhtmlgump 55 360 470 30 0 0 RETURN
button 20 360 4005 4007 1 0 1000

[DIALOG d_guild_domination BUTTON]
ON=1000
SDIALOG d_Guild_Main

ON=1 9
IF (<TAG0.ALLYPOINTS> >= <DEF.GUILDDOM_TOWNVAL_<ARGN1>>)
	IF (<ARGN1> == 1)
		IF (<VAR0.GUILDDOM.BRITAIN> == 0)
		TRY VAR.GUILDDOM.<DEF.GUILDDOM_TOWN_<ARGN1>>=1
		SERV.NEWITEM i_pedestal
		LOCAL.PEDESTAL=<NEW>
		NEW.EVENTS=T_ALLIANCE_PEDESTAL
		NEW.TIMER=60*1
		NEW.COLOR=33
		NEW.P=1475,1641,40
			IF (<ALIGN> == 1)
			SERV.NEWNPC C_PLATINUM_DRAGON
			ELSE
			SERV.NEWNPC C_CRIMSON_DRAGON
			ENDIF
		NEW.P=1428,1697
		NEW.TAG.GUILD=<UID>
		NEW.TAG.TOWN=<ARGN1>
		NEW.TAG.PEDESTAL=<LOCAL.PEDESTAL>
		NEW.EVENTS +E_ALLIANCE_DRAGONS
		NEW.HOME=1428,1697
		NEW.HOMEDIST=12
		NEW.UPDATE
		NEW.REGION.GUARDED=0
		SERV.B @55 Britain is currently being attacked by a <NEW.NAME>!
		TAG0.ALLYPOINTS -= <DEF.GUILDDOM_TOWNVAL_<ARGN1>>
		ELIF (<VAR0.GUILDDOM.BRITAIN> == 1)
		SRC.SYSMESSAGE @55,3,1 Britain is already being attacked.
		ELSE
		SRC.SYSMESSAGE @55,3,1 Britain has been dominated.
		ENDIF
	ELIF (<ARGN1> == 2)
		IF (<VAR0.GUILDDOM.MINOC> == 0)
		TRY VAR.GUILDDOM.<DEF.GUILDDOM_TOWN_<ARGN1>>=1
		SERV.NEWITEM i_pedestal
		LOCAL.PEDESTAL=<NEW>
		NEW.EVENTS=T_ALLIANCE_PEDESTAL
		NEW.TIMER=60*1
		NEW.COLOR=33
		NEW.P=2523,553
			IF (<ALIGN> == 1)
			SERV.NEWNPC C_PLATINUM_DRAGON
			ELSE
			SERV.NEWNPC C_CRIMSON_DRAGON
			ENDIF
		NEW.P=2516,556
		NEW.TAG.GUILD=<UID>
		NEW.TAG.TOWN=<ARGN1>
		NEW.TAG.PEDESTAL=<LOCAL.PEDESTAL>
		NEW.EVENTS +E_ALLIANCE_DRAGONS
		NEW.HOME=2516,556
		NEW.HOMEDIST=12
		NEW.UPDATE
		NEW.REGION.GUARDED=0
		SERV.B @55 Minoc is currently being attacked by a <NEW.NAME>!
		TAG0.ALLYPOINTS -= <DEF.GUILDDOM_TOWNVAL_<ARGN1>>
		ELIF (<VAR0.GUILDDOM.MINOC> == 1)
		SRC.SYSMESSAGE @55,3,1 Minoc is already being attacked.
		ELSE
		SRC.SYSMESSAGE @55,3,1 Minoc has been dominated.
		ENDIF
	ELIF (<ARGN1> == 3)
		IF (<VAR0.GUILDDOM.COVE> == 0)
		TRY VAR.GUILDDOM.<DEF.GUILDDOM_TOWN_<ARGN1>>=1
		SERV.NEWITEM i_pedestal
		LOCAL.PEDESTAL=<NEW>
		NEW.EVENTS=T_ALLIANCE_PEDESTAL
		NEW.TIMER=60*1
		NEW.COLOR=33
		NEW.P=2282,1209,20
			IF (<ALIGN> == 1)
			SERV.NEWNPC C_PLATINUM_DRAGON
			ELSE
			SERV.NEWNPC C_CRIMSON_DRAGON
			ENDIF
		NEW.P=2253,1210
		NEW.TAG.GUILD=<UID>
		NEW.TAG.TOWN=<ARGN1>
		NEW.TAG.PEDESTAL=<LOCAL.PEDESTAL>
		NEW.EVENTS +E_ALLIANCE_DRAGONS
		NEW.HOME=2253,1210
		NEW.HOMEDIST=12
		NEW.UPDATE
		NEW.REGION.GUARDED=0
		SERV.B @55 Cove is currently being attacked by a <NEW.NAME>!
		TAG0.ALLYPOINTS -= <DEF.GUILDDOM_TOWNVAL_<ARGN1>>
		ELIF (<VAR0.GUILDDOM.COVE> == 1)
		SRC.SYSMESSAGE @55,3,1 Cove is already being attacked.
		ELSE
		SRC.SYSMESSAGE @55,3,1 Cove has been dominated.
		ENDIF
	ELIF (<ARGN1> == 4)
		IF (<VAR0.GUILDDOM.JHELOM> == 0)
		TRY VAR.GUILDDOM.<DEF.GUILDDOM_TOWN_<ARGN1>>=1
		SERV.NEWITEM i_pedestal
		LOCAL.PEDESTAL=<NEW>
		NEW.EVENTS=T_ALLIANCE_PEDESTAL
		NEW.TIMER=60*1
		NEW.COLOR=33
		NEW.P=1399,3743,20
			IF (<ALIGN> == 1)
			SERV.NEWNPC C_PLATINUM_DRAGON
			ELSE
			SERV.NEWNPC C_CRIMSON_DRAGON
			ENDIF
		NEW.P=1399,3743,-21
		NEW.TAG.GUILD=<UID>
		NEW.TAG.TOWN=<ARGN1>
		NEW.TAG.PEDESTAL=<LOCAL.PEDESTAL>
		NEW.EVENTS +E_ALLIANCE_DRAGONS
		NEW.HOME=1399,3743,-21
		NEW.HOMEDIST=12
		NEW.UPDATE
		NEW.REGION.GUARDED=0
		SERV.B @55 Jhelom is currently being attacked by a <NEW.NAME>!
		TAG0.ALLYPOINTS -= <DEF.GUILDDOM_TOWNVAL_<ARGN1>>
		ELIF (<VAR0.GUILDDOM.JHELOM> == 1)
		SRC.SYSMESSAGE @55,3,1 Jhelom is already being attacked.
		ELSE
		SRC.SYSMESSAGE @55,3,1 Jhelom has been dominated.
		ENDIF
	ELIF (<ARGN1> == 5)
		IF (<VAR0.GUILDDOM.MOONGLOW> == 0)
		TRY VAR.GUILDDOM.<DEF.GUILDDOM_TOWN_<ARGN1>>=1
		SERV.NEWITEM i_pedestal
		LOCAL.PEDESTAL=<NEW>
		NEW.EVENTS=T_ALLIANCE_PEDESTAL
		NEW.TIMER=60*1
		NEW.COLOR=33
		NEW.P=4422,1143
			IF (<ALIGN> == 1)
			SERV.NEWNPC C_PLATINUM_DRAGON
			ELSE
			SERV.NEWNPC C_CRIMSON_DRAGON
			ENDIF
		NEW.P=4414,1151,-29
		NEW.TAG.GUILD=<UID>
		NEW.TAG.TOWN=<ARGN1>
		NEW.TAG.PEDESTAL=<LOCAL.PEDESTAL>
		NEW.EVENTS +E_ALLIANCE_DRAGONS
		NEW.HOME=4414,1151,-29
		NEW.HOMEDIST=12
		NEW.UPDATE
		NEW.REGION.GUARDED=0
		SERV.B @55 Moonglow is currently being attacked by a <NEW.NAME>!
		TAG0.ALLYPOINTS -= <DEF.GUILDDOM_TOWNVAL_<ARGN1>>
		ELIF (<VAR0.GUILDDOM.MOONGLOW> == 1)
		SRC.SYSMESSAGE @55,3,1 Moonglow is already being attacked.
		ELSE
		SRC.SYSMESSAGE @55,3,1 Moonglow has been dominated.
		ENDIF
	ELIF (<ARGN1> == 6)
		IF (<VAR0.GUILDDOM.NUJELM> == 0)
		TRY VAR.GUILDDOM.<DEF.GUILDDOM_TOWN_<ARGN1>>=1
		SERV.NEWITEM i_pedestal
		LOCAL.PEDESTAL=<NEW>
		NEW.EVENTS=T_ALLIANCE_PEDESTAL
		NEW.TIMER=60*1
		NEW.COLOR=33
		NEW.P=3768,1295
			IF (<ALIGN> == 1)
			SERV.NEWNPC C_PLATINUM_DRAGON
			ELSE
			SERV.NEWNPC C_CRIMSON_DRAGON
			ENDIF
		NEW.P=3764,1295
		NEW.TAG.GUILD=<UID>
		NEW.TAG.TOWN=<ARGN1>
		NEW.TAG.PEDESTAL=<LOCAL.PEDESTAL>
		NEW.EVENTS +E_ALLIANCE_DRAGONS
		NEW.HOME=3764,1295
		NEW.HOMEDIST=12
		NEW.UPDATE
		NEW.REGION.GUARDED=0
		SERV.B @55 Nujel'm is currently being attacked by a <NEW.NAME>!
		TAG0.ALLYPOINTS -= <DEF.GUILDDOM_TOWNVAL_<ARGN1>>
		ELIF (<VAR0.GUILDDOM.NUJELM> == 1)
		SRC.SYSMESSAGE @55,3,1 Nujel'm is already being attacked.
		ELSE
		SRC.SYSMESSAGE @55,3,1 Nujel'm has been dominated.
		ENDIF
	ELIF (<ARGN1> == 7)
		IF (<VAR0.GUILDDOM.TRINSIC> == 0)
		TRY VAR.GUILDDOM.<DEF.GUILDDOM_TOWN_<ARGN1>>=1
		SERV.NEWITEM i_pedestal
		LOCAL.PEDESTAL=<NEW>
		NEW.EVENTS=T_ALLIANCE_PEDESTAL
		NEW.TIMER=60*1
		NEW.COLOR=33
		NEW.P=2003,2754,30
			IF (<ALIGN> == 1)
			SERV.NEWNPC C_PLATINUM_DRAGON
			ELSE
			SERV.NEWNPC C_CRIMSON_DRAGON
			ENDIF
		NEW.P=2003,2758,30
		NEW.TAG.GUILD=<UID>
		NEW.TAG.TOWN=<ARGN1>
		NEW.TAG.PEDESTAL=<LOCAL.PEDESTAL>
		NEW.EVENTS +E_ALLIANCE_DRAGONS
		NEW.HOME=2003,2758,30
		NEW.HOMEDIST=12
		NEW.UPDATE
		NEW.REGION.GUARDED=0
		SERV.B @55 Trinsic is currently being attacked by a <NEW.NAME>!
		TAG0.ALLYPOINTS -= <DEF.GUILDDOM_TOWNVAL_<ARGN1>>
		ELIF (<VAR0.GUILDDOM.TRINSIC> == 1)
		SRC.SYSMESSAGE @55,3,1 Trinsic is already being attacked.
		ELSE
		SRC.SYSMESSAGE @55,3,1 Trinsic has been dominated.
		ENDIF
	ELIF (<ARGN1> == 8)
		IF (<VAR0.GUILDDOM.VESPER> == 0)
		TRY VAR.GUILDDOM.<DEF.GUILDDOM_TOWN_<ARGN1>>=1
		SERV.NEWITEM i_pedestal
		LOCAL.PEDESTAL=<NEW>
		NEW.EVENTS=T_ALLIANCE_PEDESTAL
		NEW.TIMER=60*1
		NEW.COLOR=33
		NEW.P=2914,675,40
			IF (<ALIGN> == 1)
			SERV.NEWNPC C_PLATINUM_DRAGON
			ELSE
			SERV.NEWNPC C_CRIMSON_DRAGON
			ENDIF
		NEW.P=2903,678
		NEW.TAG.GUILD=<UID>
		NEW.TAG.TOWN=<ARGN1>
		NEW.TAG.PEDESTAL=<LOCAL.PEDESTAL>
		NEW.EVENTS +E_ALLIANCE_DRAGONS
		NEW.HOME=2903,678
		NEW.HOMEDIST=12
		NEW.UPDATE
		NEW.REGION.GUARDED=0
		SERV.B @55 Vesper is currently being attacked by a <NEW.NAME>!
		TAG0.ALLYPOINTS -= <DEF.GUILDDOM_TOWNVAL_<ARGN1>>
		ELIF (<VAR0.GUILDDOM.VESPER> == 1)
		SRC.SYSMESSAGE @55,3,1 Vesper is already being attacked.
		ELSE
		SRC.SYSMESSAGE @55,3,1 Vesper has been dominated.
		ENDIF
	ELIF (<ARGN1> == 9)
		IF (<VAR0.GUILDDOM.YEW> == 0)
		TRY VAR.GUILDDOM.<DEF.GUILDDOM_TOWN_<ARGN1>>=1
		SERV.NEWITEM i_pedestal
		LOCAL.PEDESTAL=<NEW>
		NEW.EVENTS=T_ALLIANCE_PEDESTAL
		NEW.TIMER=60*1
		NEW.COLOR=33
		NEW.P=546,992
			IF (<ALIGN> == 1)
			SERV.NEWNPC C_PLATINUM_DRAGON
			ELSE
			SERV.NEWNPC C_CRIMSON_DRAGON
			ENDIF
		NEW.P=539,992
		NEW.TAG.GUILD=<UID>
		NEW.TAG.TOWN=<ARGN1>
		NEW.TAG.PEDESTAL=<LOCAL.PEDESTAL>
		NEW.EVENTS +E_ALLIANCE_DRAGONS
		NEW.HOME=539,992
		NEW.HOMEDIST=12
		NEW.UPDATE
		NEW.REGION.GUARDED=0
		SERV.B @55 Yew is currently being attacked by a <NEW.NAME>!
		TAG0.ALLYPOINTS -= <DEF.GUILDDOM_TOWNVAL_<ARGN1>>
		ELIF (<VAR0.GUILDDOM.YEW> == 1)
		SRC.SYSMESSAGE @55,3,1 Yew is already being attacked.
		ELSE
		SRC.SYSMESSAGE @55,3,1 Yew has been dominated.
		ENDIF
	ENDIF
ENDIF
SDIALOG d_guild_domination

[EOF]