//#####################################
// CSD UO: House menu and hotel system
//#####################################

// 26.11.2001, Eidolon: transfer house - morex = 3
// 24.11.2001, Eidolon: ship menu removed
// 22.11.2001, Eidolon: blank copper key needed to change door locks; ship menu added
// 06.11.2001, MoNK: removing houses which is registered on items or NPCs EVERY HOUR
// 23.10.2001, MoNK: door kit for new houses; house removing
// 21.10.2001, MoNK: new houses added into "demolish house" menu
// 19.10.2001, MoNK: removing houses which is registered on items or NPCs
// 13.10.2001, MoNK: housestones
// 26.08.2001, MoNK: recolorize house sign within 720 hours
// 17.08.2001, MoNK: 48 hours delay before demolish house
// 20.07.2001, MoNK: timers on house brass signs and porters
// 15.07.2001, MoNK: change brass sign type before removing the house, remove brass sign after removing the house
// 12.07.2001, MoNK: door kit error fixed: wizards tower door kit is working now
// 12.06.2001, MoNK: fix error in f_hotel_pay
// 21.05.2001, MoNK: removing of magic keys from hotel apartments



[TYPEDEF t_key_blank]
On=@Click
	type=t_key
	
[function f_key_type_blank]
	if !(<src.findtype.t_key>)
		return 1
	endif
	if (<src.findtype(t_key).baseid>==i_key_copper)&&(!<src.findtype.t_key.more>)&&(!(<src.findtype.t_key.attr>&04))
		src.findtype.t_key.type = t_key_blank
	else
		src.findtype.t_key.type = t_key_fixer
	endif
	f_key_type_blank

[function f_key_type_key]
	if (!<src.findtype.t_key_fixer>)&&(!<src.findtype.t_key_blank>)
		return 1
	endif
	if <src.findtype.t_key_fixer>
		src.findtype.t_key_fixer.type = t_key
	endif
	if <src.findtype.t_key_blank>
		src.findtype.t_key_blank.type = t_key
	endif
	f_key_type_key




[TYPEDEF t_housestone]
On=@DClick
	if <src.account.plevel> > 1
		dialog d_housestone
	else
		dialog d_housestone_player
	endif
	return 1

On=@Timer
	more2 = <more2> + 1
	timer = 3600
	return 1

[ITEMDEF i_housestone]
NAME=House Stone
ID=i_gravestone_7
TYPE=t_housestone

On=@Create
	attr = attr_static | attr_move_never
	timer = 3600
	more2 = 0

[DIALOG d_housestone]
130 100
resizepic 0 0 5170 320 330	// 5054
page 0
gumppic 35 250 92
gumppic 75 250 93
gumppic 175 250 93
gumppic 255 250 94
text 35 50 1152 0
text 35 85 0 1
text 35 105 0 2
text 35 125 0 3
text 35 145 0 4
text 35 165 0 5
text 135 185 0 6
text 55 245 100 7

[DIALOG d_housestone TEXT]
<name>
This building was <eval(<morex>)> hours old.
Because it was not visited by its
owner longer than 30 days it was
removed!	// <eval(<more2>)> hours ago!
Previous housekeeper: <src.uid.<more>.name>.
(serial: <hval(<more>)>)
Lord British's Official Architect

[DIALOG d_housestone BUTTON]

[DIALOG d_housestone_player]
130 100
resizepic 0 0 5170 320 330	// 5054
page 0
gumppic 35 250 92
gumppic 75 250 93
gumppic 175 250 93
gumppic 255 250 94
text 35 50 1152 0
text 35 85 0 1
text 35 105 0 2
text 35 125 0 3
text 35 145 0 4
text 35 165 0 5
//text 135 185 0 6
text 55 245 100 7

[DIALOG d_housestone_player TEXT]
<name>
This building was <eval(<morex>)> hours old.
Because it was not visited by its
owner longer than 30 days it was
removed!	// <eval(<more2>)> hours ago!
Previous housekeeper: <src.uid.<more>.name>.
(serial: <hval(<more>)>)
Lord British's Official Architect

[DIALOG d_housestone_player BUTTON]

[SPEECH spk_house_base]
On=*may i come in?*
	if <src.serial> == <more>
		src.go <p.x>, <p.y>, <eval(<p.z> + 7)>
	else
		src.sysmessage Only housekeeper can be teleported into house
	endif

On=*may i come out?*
	if <src.serial> != <more>
		src.sysmessage Only housekeeper can be teleported out from house
	else
		if (<id>==04064) || (<id>==04066) || (<id>==04068) || (<id>==0406a) || (<id>==0406c) || (<id>==0406e)
			// smal houses
			src.go <p.x>, <eval(<p.y> + 4>, <eval(<p.z> + 7)>
		endif
	endif

[FUNCTION f_door_change_count]
	// argn = <src.targ.link.id>
	if (<argn>==04064) || (<argn>==04066) || (<argn>==04068) || (<argn>==0406a) || (<argn>==0406c) || (<argn>==0406e) ||  (<argn>==0409a) || (<argn>==0409c) || (<argn>==040a0) || (<argn>==040a2) || (<argn>==04098)
		// small houses, sandstone patio, wizards tower, small shops, two story log cabin
		src.act.morez = 1
	elseif (<argn>==0407c) || (<argn>==04096)
		// keep, marble patio house
		src.act.morez = 2
	elseif (<argn>==04074) || (<argn>==04076) || (<argn>==04078) || (<argn>==0409e) || (<argn>==0407e)
		// three room, two story, two story villa, castle
		src.act.morez = 4
	elseif (<argn>==0407a) || (<argn>==04087) || (<argn>==0408c)
		// tower, blacksmith
		src.act.morez = 5
	elseif (<argn>==04290) || (<argn>==04301) || (<argn>==04302) || (<argn>==04303) || (<argn>==04304) || (<argn>==04305) || (<argn>==04306) || (<argn>==0432e)
		// cottages
		src.act.morez = 1
	elseif (<argn>==04296)
		// stone and plaster mill house
		src.act.morez = 6
	elseif (<argn>==04299)
		// brick stronghold
		src.act.morez = 1
	elseif (<argn>==0429a)
		// marble stronghold
		src.act.morez = 8
	elseif (<argn>==0429b)
		// sandstone stronghold
		src.act.morez = 10
	elseif (<argn>==0429c)
		// stone and plaster stronghold
		src.act.morez = 10
	elseif (<argn>==0429d)
		// stone and plaster stronghold with yellow stone
		src.act.morez = 8
	elseif (<argn>==0429e)
		// wood and plaster stronghold
		src.act.morez = 6
	elseif (<argn>==0429f) || (<argn>==042a0) || (<argn>==042a1) || (<argn>==042a2) || (<argn>==042a3)
		// townholds
		src.act.morez = 1
	elseif (<argn>==042a4)
		// sandstone two story villa
		src.act.morez = 1
	elseif (<argn>==042b7)
		// brick house
		src.act.morez = 2
	elseif (<argn>==042b9)
		// wood and plaster two story house
		src.act.morez = 3
	elseif (<argn>==04322)
		// stone and plaster townhall
		src.act.morez = 5
	elseif (<argn>==04323)
		// wood and plaster townhall
		src.act.morez = 4
	elseif (<argn>==04324)
		// hold
		src.act.morez = 8
	elseif (<argn>==04329)
		// wood and plaster mill house
		src.act.morez = 4
	elseif (<argn>==0432d)
		// marble palazzo
		src.act.morez = 5
	elseif (<argn>==04330)
		// workshop
		src.act.morez = 4
	elseif (<argn>==0433e)
		src.act.morez = 2
	elseif (<argn>==0433f)
		src.act.morez = 5
	elseif (<argn>==04340)
		src.act.morez = 4
	else
		src.act.morez = 0
	endif
	return 1

[ITEMDEF i_door_change]
NAME=Door kit
ID=i_toolkit
WEIGHT=10.0

On=@Create
	attr = attr_static|attr_move_never|attr_newbie

On=@Click
	if <morez>==1
		message One more door left to change
		return 1
	elseif <morez> > 0
		message <morez> doors left to change
		return 1
	else
		message This <name> is broken
		return 1
	endif

On=@DClick
	if <morez>==0
		src.message This <name> is broken
		return 1
	endif

	target Which door do you want to change?
	return 1

On=@Targon_item
	if (<src.targ.type>!=t_door) && (<src.targ.type>!=t_door_locked)
		src.sysmessage You can't think of a way to use this item
		return 1
	endif
	if <src.targ.distance> > 1
		src.sysmessage You are too far away
		return 1
	endif
	if (<src.targ.region.flags> & 01092) != 01092
		src.sysmessage This door is not in player's house. You can't change it.
		return 1
	endif
	if <src.targ.more>==0
		src.sysmessage This door has no lock. You can't change it.
		return 1
	endif
	if (<src.targ.link>==0) || (<src.targ.link>==04fffffff)
		src.sysmessage This door is not placed properly. Call GM to fix this problem.
		return 1
	endif
	if <src.targ.link.type>!=t_multi
		src.sysmessage This door is not linked to house. Call GM to fix this problem.
		return 1
	endif
	if <src.targ.link>!=<link>
		src.sysmessage This door kit is not for this house!
		return 1
	endif

	if (<more>!=0) && (<more>!=<src.targ.more>)
		src.sysmessage Wrong lock install into this door. You cannot change it.
		return 1
	endif

	morey = <src.targ.dispid>

	// left front door
	if (<morey>==0675) || (<morey>==0685) || (<morey>==0695) || (<morey>==06a5) || (<morey>==06d5) || (<morey>==06e5) || (<morey>==0824)
		doswitch <morex>
			morey = 0675		// 0 metal door
			morey = 0685		// 1 barred metal door
			morey = 0695		// 2 bamboo door
			morey = 06a5		// 3 dark wooden door
			morey = 06d5		// 4 light wooden door
			morey = 06e5		// 5 wooden door
			morey = 0824		// 6 iron gate
		enddo
	// right front door
	elseif (<morey>==0677) || (<morey>==0687) || (<morey>==0697) || (<morey>==06a7) || (<morey>==06d7) || (<morey>==06e7) || (<morey>==0826)
		doswitch <morex>
			morey = 0677		// 0 metal door
			morey = 0687		// 1 barred metal door
			morey = 0697		// 2 bamboo door
			morey = 06a7		// 3 dark wooden door
			morey = 06d7		// 4 light wooden door
			morey = 06e7		// 5 wooden door
			morey = 0826		// 6 iron gate
		enddo
	// near inside door
	elseif (<morey>==067d) || (<morey>==068d) || (<morey>==069d) || (<morey>==06ad) || (<morey>==06dd) || (<morey>==06ed) || (<morey>==082c)
		doswitch <morex>
			morey = 067d		// 0 metal door
			morey = 068d		// 1 barred metal door
			morey = 069d		// 2 bamboo door
			morey = 06ad		// 3 dark wooden door
			morey = 06dd		// 4 light wooden door
			morey = 06ed		// 5 wooden door
			morey = 082c		// 6 iron gate
		enddo
	// far inside door
	elseif (<morey>==067f) || (<morey>==068f) || (<morey>==069f) || (<morey>==06af) || (<morey>==06df) || (<morey>==06ef) || (<morey>==082e)
		doswitch <morex>
			morey = 067f		// 0 metal door
			morey = 068f		// 1 barred metal door
			morey = 069f		// 2 bamboo door
			morey = 06af		// 3 dark wooden door
			morey = 06df		// 4 light wooden door
			morey = 06ef		// 5 wooden door
			morey = 082e		// 6 iron gate
		enddo
	elseif (<morey>==0683) || (<morey>==0693) || (<morey>==06a3) || (<morey>==06b3) || (<morey>==06e3) || (<morey>==06f3) || (<morey>==0832)
		doswitch <morex>
			morey = 0683		// 0 metal door
			morey = 0693		// 1 barred metal door
			morey = 06a3		// 2 bamboo door
			morey = 06b3		// 3 dark wooden door
			morey = 06e3		// 4 light wooden door
			morey = 06f3		// 5 wooden door
			morey = 0832		// 6 iron gate
		enddo
	else
		morey = 0
	endif

	if <morey>==0
		src.sysmessage You cannot change this kind of doors
	else
		src.newitem <morey>
		src.act.attr = 010
		src.act.timer = -1
		src.act.p = <src.targ.p>

		if <more>==0
			// first door
			more2 = <src.act.serial>	// new "lock"
			more = <src.targ.more>	// old "lock"
			src.act.more = <more2>
			src.act.link = <src.targ.link>

			src.newitem i_key_copper
			src.act.timer = -1
			src.act.more = <more2>
			src.act.bounce
		else
			// not first door
			src.act.more = <more2>
			src.act.link = <src.targ.link>
		endif

		src.targ.remove
		src.sfx 0ec
		morez = (<morez> - 1)
		if <morez>==0
			src.sysmessage All doors was changed. Do not forget to lock your home!
			src.sfx 02c
			remove
		endif
	endif
	return 1

[TYPEDEF 3004]
DEFNAME t_house_brass_sign
On=@Click
	if <timer> == -1
		timer = 3600
		if <src.isgm>
			message <name>: timer was started!
			return 1
		endif
	elseif <src.isgm>
		message <name> is <morex> hours old
		return 1
	endif

On=@DClick
	if <timer> == -1
		timer = 3600
	endif
	if <link>==04fffffff
		return 1
	endif
	if <link.link>!=04fffffff
		link.link = 04fffffff
	endif
	if !(<morez>&1)	// no stairs was builded
		if (<link.id>==04064) || (<link.id>==04066) || (<link.id>==04068) || (<link.id>==0406a) || (<link.id>==0406c) || (<link.id>==0406e)
			src.newitem 0758
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> - 1
			src.act.morey = <src.act.morey> + 4
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0751
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex>
			src.act.morey = <src.act.morey> + 4
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0756
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> + 1
			src.act.morey = <src.act.morey> + 4
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010
		elseif <link.id>==04074	// three room house
			src.newitem 0758
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> - 2
			src.act.morey = <src.act.morey> + 7
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0751
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> - 1
			src.act.morey = <src.act.morey> + 7
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0751
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex>
			src.act.morey = <src.act.morey> + 7
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0756
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> + 1
			src.act.morey = <src.act.morey> + 7
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010
		elseif (<link.id>==04076) || (<link.id>==04078)	// two story houses
			src.newitem 0758
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> - 4
			src.act.morey = <src.act.morey> + 7
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0751
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> - 3
			src.act.morey = <src.act.morey> + 7
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0751
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> - 2
			src.act.morey = <src.act.morey> + 7
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0756
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> - 1
			src.act.morey = <src.act.morey> + 7
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010
		elseif <link.id>==0407a	// tower
			src.newitem 0790
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> - 1
			src.act.morey = <src.act.morey> + 8
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0789
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex>
			src.act.morey = <src.act.morey> + 8
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0789
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> + 1
			src.act.morey = <src.act.morey> + 8
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 078e
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> + 2
			src.act.morey = <src.act.morey> + 8
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 078c
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> - 1
			src.act.morey = <src.act.morey> + 7
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0788
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex>
			src.act.morey = <src.act.morey> + 7
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0788
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> + 1
			src.act.morey = <src.act.morey> + 7
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 078a
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> + 2
			src.act.morey = <src.act.morey> + 7
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010
		elseif <link.id>==0407c	// keep
			src.newitem 0790
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> - 1
			src.act.morey = <src.act.morey> + 11
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0789
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex>
			src.act.morey = <src.act.morey> + 11
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0789
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> + 1
			src.act.morey = <src.act.morey> + 11
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 078e
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> + 2
			src.act.morey = <src.act.morey> + 11
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010
		elseif <link.id>==0407e	// castle
			src.newitem 0790
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> - 1
			src.act.morey = <src.act.morey> + 6
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0789
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex>
			src.act.morey = <src.act.morey> + 6
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0789
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> + 1
			src.act.morey = <src.act.morey> + 6
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 078e
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> + 2
			src.act.morey = <src.act.morey> + 6
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0790
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> - 2
			src.act.morey = <src.act.morey> - 10
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0789
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> - 1
			src.act.morey = <src.act.morey> - 10
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0789
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex>
			src.act.morey = <src.act.morey> - 10
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 078e
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> + 1
			src.act.morey = <src.act.morey> - 10
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0790
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> - 1
			src.act.morey = <src.act.morey> + 16
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0789
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex>
			src.act.morey = <src.act.morey> + 16
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0789
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> + 1
			src.act.morey = <src.act.morey> + 16
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 078e
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> + 2
			src.act.morey = <src.act.morey> + 16
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010
		elseif (<link.id>==04087) || (<link.id>==0408c)	// large blacksmithy shop
			src.newitem 0758
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> - 5
			src.act.morey = <src.act.morey> + 7
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0751
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> - 4
			src.act.morey = <src.act.morey> + 7
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0751
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> - 3
			src.act.morey = <src.act.morey> + 7
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010

			src.newitem 0756
			src.act.morep = <link.p>
			src.act.link = <link>
			src.act.morex = <src.act.morex> - 2
			src.act.morey = <src.act.morey> + 7
			src.act.morez = <src.act.morez> + 1
			src.act.p = <src.act.morep>
			src.act.attr=08010
		endif
		morez = <morez>|1
	endif

	if <src.serial>==<link.more>
		morey = 0
		color = 0
		update
		link.dialog d_housekeeper_menu
	elseif <link.more>!=0
		link.dialog d_houseguest_menu
	endif

	return 1

On=@Timer
	timer = 3600
	morex = (<morex> + 1)
	morey = (<morey> + 1)

	if <morey> > 720
		id = 0bd2
		color = color_o_magma
		update
	endif

	// remove house if it's owner is not a player
	link.link = <link.more>
	if !<link.link.ischar>
		link.remove
		return 1
	elseif <link.link.brain>
		link.remove
		return 1
	endif
	link.link = 04fffffff

	if <morey> > 1440
		// remove player's house
		// to prevent house removing just uncomment next string:
//		return 1

		link.id = i_housestone
		link.update
		link.morex = <morex>
		link.morey = <morey>
		link.color = color_o_magma
		link.attr = attr_move_never | attr_static
		link.timer = 3600
		link.name = The <name>
		link.dupe
		link.remove
		return 1
	endif
	return 1

//##############
// Housekeeper menu
//##############

[DIALOG d_housekeeper_menu]
30 30
resizepic 0 0 5054 510 330
page 0
resizepic 170 10 83 315 44
resizepic 170 65 83 315 44
gumppic 10 10 100
text 50 35 52 0
text 40 55 52 1
text 185 20 1152 2
text 185 75 1152 3		// housekeeper
page 1
text 35 130 52 4		// change locks
text 35 150 52 5		// change brass sign
button 15 154 1209 1210 1 1 102
text 35 220 55 8		// lock
button 15 224 1209 1210 1 1 110
text 35 240 55 9		// unlock
button 15 244 1209 1210 1 1 111
text 35 260 55 10		// transfer house
button 15 264 1209 1210 1 1 112
text 35 280 37 6		// demolish house
button 15 284 1209 1210 1 1 103

// doors
tilepic 260 160 1653	// metal door
button 265 284 1209 1210 1 1 201
tilepic 290 160 1669	// 
button 295 284 1209 1210 1 1 202
tilepic 320 160 1685	// bamboo door
button 325 284 1209 1210 1 1 203
tilepic 350 160 1701	// dark wooden door
button 355 284 1209 1210 1 1 204
tilepic 380 160 1749	// light wooden door
button 385 284 1209 1210 1 1 205
tilepic 410 160 1765	// wooden door
button 415 284 1209 1210 1 1 206
tilepic 430 170 2124	// iron gate
button 445 284 1209 1210 1 1 207
text 260 130 1153 7	// Select new door type

[DIALOG d_housekeeper_menu TEXT]
CSD UO
House menu
<src.targ.name>
Housekeeper: <src.uid.<more>.name>
Change doors and locks
Change sign
Demolish house
Select new doors:
Lockdown item
Unlock item
Transfer house

[DIALOG d_housekeeper_menu BUTTON]
ONBUTTON=0

ONBUTTON=102
	src.targ.link.dialog d_housekeeper_menu1

ONBUTTON=103
	src.targ.link.dialog d_housekeeper_menu2

ONBUTTON=110	// lock
	morex = 1
	target What item do you want to lockdown in your house?

ONBUTTON=111	// unlock
	morex = 2
	target What item do you want to unlock?

ONBUTTON=112	// transfer house
	morex = 3
	target Whom do you wish to transfer your house?

ONBUTTON=201	// metal door
	f_key_type_blank
	if <src.restest 1 t_key_blank>
		src.consume 1 t_key_blank
	else
		src.sysmessage You need 1 blank copper key.
		f_key_type_key
		src.update
		return 1
	endif
	f_key_type_key
	src.update
	if <src.restest 1 i_door_change>
		src.sysmessage You can't get new Door kit because you already have one
		return 1
	endif
	src.newitem i_door_change
	src.act.timer = -1
	src.act.morex = 0
	f_door_change_count <src.targ.link.id>
	src.act.link = <src.targ.link.serial>	// of house
	src.act.bounce

ONBUTTON=202
	f_key_type_blank
	if <src.restest 1 t_key_blank>
		src.consume 1 t_key_blank
	else
		src.sysmessage You need 1 blank copper key.
		f_key_type_key
		src.update
		return 1
	endif
	f_key_type_key
	src.update
	if <src.restest 1 i_door_change>
		src.sysmessage You can't get new Door kit because you already have one
		return 1
	endif
	src.newitem i_door_change
	src.act.timer = -1
	src.act.morex = 1
	f_door_change_count <src.targ.link.id>
	src.act.link = <serial>	// of house
	src.act.bounce

ONBUTTON=203	// bamboo door
	f_key_type_blank
	if <src.restest 1 t_key_blank>
		src.consume 1 t_key_blank
	else
		src.sysmessage You need 1 blank copper key.
		f_key_type_key
		src.update
		return 1
	endif
	f_key_type_key
	src.update
	if <src.restest 1 i_door_change>
		src.sysmessage You can't get new Door kit because you already have one
		return 1
	endif
	src.newitem i_door_change
	src.act.timer = -1
	src.act.morex = 2
	f_door_change_count <src.targ.link.id>
	src.act.link = <serial>	// of house
	src.act.bounce

ONBUTTON=204	// dark wooden door
	f_key_type_blank
	if <src.restest 1 t_key_blank>
		src.consume 1 t_key_blank
	else
		src.sysmessage You need 1 blank copper key.
		f_key_type_key
		src.update
		return 1
	endif
	f_key_type_key
	src.update
	if <src.restest 1 i_door_change>
		src.sysmessage You can't get new Door kit because you already have one
		return 1
	endif
	src.newitem i_door_change
	src.act.timer = -1
	src.act.morex = 3
	f_door_change_count <src.targ.link.id>
	src.act.link = <serial>	// of house
	src.act.bounce

ONBUTTON=205	// light wooden door
	f_key_type_blank
	if <src.restest 1 t_key_blank>
		src.consume 1 t_key_blank
	else
		src.sysmessage You need 1 blank copper key.
		f_key_type_key
		src.update
		return 1
	endif
	f_key_type_key
	src.update
	if <src.restest 1 i_door_change>
		src.sysmessage You can't get new Door kit because you already have one
		return 1
	endif
	src.newitem i_door_change
	src.act.timer = -1
	src.act.morex = 4
	f_door_change_count <src.targ.link.id>
	src.act.link = <serial>	// of house
	src.act.bounce

ONBUTTON=206	// wooden door
	f_key_type_blank
	if <src.restest 1 t_key_blank>
		src.consume 1 t_key_blank
	else
		src.sysmessage You need 1 blank copper key.
		f_key_type_key
		src.update
		return 1
	endif
	f_key_type_key
	src.update
	if <src.restest 1 i_door_change>
		src.sysmessage You can't get new Door kit because you already have one
		return 1
	endif
	src.newitem i_door_change
	src.act.timer = -1
	src.act.morex = 5
	f_door_change_count <src.targ.link.id>
	src.act.link = <serial>	// of house
	src.act.bounce

ONBUTTON=207	// iron gate
	f_key_type_blank
	if <src.restest 1 t_key_blank>
		src.consume 1 t_key_blank
	else
		src.sysmessage You need 1 blank copper key.
		f_key_type_key
		src.update
		return 1
	endif
	f_key_type_key
	src.update
	if <src.restest 1 i_door_change>
		src.sysmessage You can't get new Door kit because you already have one
		return 1
	endif
	src.newitem i_door_change
	src.act.timer = -1
	src.act.morex = 6
	f_door_change_count <src.targ.link.id>
	src.act.link = <serial>	// of house
	src.act.bounce

[DIALOG d_housekeeper_menu1]
30 30
resizepic 0 0 5054 510 330
page 0
resizepic 170 10 83 315 44
resizepic 170 65 83 315 44
gumppic 10 10 100
text 50 35 52 0
text 40 55 52 1
text 185 20 1152 2
text 185 75 1152 3		// housekeeper
page 1
text 35 130 52 4		// change locks
button 15 134 1209 1210 1 1 101
text 35 150 52 5		// change brass sign

text 35 220 55 9		// lock
button 15 224 1209 1210 1 1 110
text 35 240 55 10		// unlock
button 15 244 1209 1210 1 1 111
text 35 260 55 11		// transfer house
button 15 264 1209 1210 1 1 112
text 35 280 37 6		// demolish house
button 15 284 1209 1210 1 1 103

// brass signs

tilepic 260 160 3024
button 265 160 1209 1210 1 1 201
tilepic 290 160 3026
button 295 160 1209 1210 1 1 202
tilepic 320 160 3028
button 325 160 1209 1210 1 1 203
tilepic 350 160 3030
button 355 160 1209 1210 1 1 204
tilepic 380 160 3032
button 385 160 1209 1210 1 1 205
tilepic 410 160 3034
button 415 160 1209 1210 1 1 206
tilepic 440 160 3036
button 445 160 1209 1210 1 1 207

tilepic 260 200 3038
button 265 200 1209 1210 1 1 208
tilepic 290 200 3040
button 295 200 1209 1210 1 1 209
tilepic 320 200 3042
button 325 200 1209 1210 1 1 210
tilepic 350 200 3044
button 355 200 1209 1210 1 1 211
tilepic 380 200 3046
button 385 200 1209 1210 1 1 212
tilepic 410 200 3048
button 415 200 1209 1210 1 1 213
tilepic 440 200 3050
button 445 200 1209 1210 1 1 214

tilepic 260 240 3052
button 265 240 1209 1210 1 1 215
tilepic 290 240 3054
button 295 240 1209 1210 1 1 216
tilepic 320 240 3056
button 325 240 1209 1210 1 1 217
tilepic 350 240 3058
button 355 240 1209 1210 1 1 218
tilepic 380 240 3060
button 385 240 1209 1210 1 1 219
tilepic 410 240 3062
button 415 240 1209 1210 1 1 220
tilepic 440 240 3064
button 445 240 1209 1210 1 1 221

tilepic 260 280 3066
button 265 280 1209 1210 1 1 222
tilepic 290 280 3068
button 295 280 1209 1210 1 1 223
tilepic 320 280 3070
button 325 280 1209 1210 1 1 224
tilepic 350 280 3072
button 355 280 1209 1210 1 1 225
tilepic 380 280 3074
button 385 280 1209 1210 1 1 226
tilepic 410 280 3076
button 415 280 1209 1210 1 1 227
tilepic 440 280 3078
button 445 280 1209 1210 1 1 228

text 260 130 1153 7
text 435 130 1153 8
button 415 134 1209 1210 1 1 104

[DIALOG d_housekeeper_menu1 TEXT]
CSD UO
House menu
<src.targ.name>
Housekeeper: <src.uid.<more>.name>
Change doors and locks
Change sign
Demolish house
Select new sign:
page 2
Lockdown item
Unlock item
Transfer house

[DIALOG d_housekeeper_menu1 BUTTON]
ONBUTTON=0

ONBUTTON=101
	src.targ.link.dialog d_housekeeper_menu

ONBUTTON=103
	src.targ.link.dialog d_housekeeper_menu2

ONBUTTON=104
	src.targ.link.dialog d_housekeeper_menu3

ONBUTTON=110	// lock
	morex = 1
	target What item do you want to lockdown in your house?

ONBUTTON=111	// unlock
	morex = 2
	target What item do you want to unlock?

ONBUTTON=112	// transfer house
	morex = 3
	target Whom do you wish to transfer your house?

ONBUTTON=201
	src.targ.id=0bd0
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=202
	src.targ.id=0bd2
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=203
	src.targ.id=0bd4
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=204
	src.targ.id=0bd6
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=205
	src.targ.id=0bd8
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=206
	src.targ.id=0bda
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=207
	src.targ.id=0bdc
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=208
	src.targ.id=0bde
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=209
	src.targ.id=0be0
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=210
	src.targ.id=0be2
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=211
	src.targ.id=0be4
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=212
	src.targ.id=0be6
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=213
	src.targ.id=0be8
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=214
	src.targ.id=0bea
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=215
	src.targ.id=0bec
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=216
	src.targ.id=0bee
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=217
	src.targ.id=0bf0
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=218
	src.targ.id=0bf2
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=219
	src.targ.id=0bf4
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=220
	src.targ.id=0bf6
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=221
	src.targ.id=0bf8
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=222
	src.targ.id=0bfa
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=223
	src.targ.id=0bfc
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=224
	src.targ.id=0bfe
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=225
	src.targ.id=0c00
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=226
	src.targ.id=0c02
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=227
	src.targ.id=0c04
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=228
	src.targ.id=0c06
	src.targ.type=t_house_brass_sign
	src.targ.update

[DIALOG d_housekeeper_menu2]
30 30
resizepic 0 0 5054 510 330
page 0
resizepic 170 10 83 315 44
resizepic 170 65 83 315 44
gumppic 10 10 100
text 50 35 52 0
text 40 55 52 1
text 185 20 1152 2
text 185 75 1152 3		// housekeeper
page 1
text 35 130 52 4		// change locks
button 15 134 1209 1210 1 1 101
text 35 150 52 5		// change brass sign
button 15 154 1209 1210 1 1 102
text 35 220 55 14		// lock
button 15 224 1209 1210 1 1 110
text 35 240 55 15		// unlock
button 15 244 1209 1210 1 1 111
text 35 260 55 16		// transfer house
button 15 264 1209 1210 1 1 112
text 35 280 37 6		// demolish house

// warning
text 260 130 37 7
text 260 150 54 8
text 260 170 54 9
text 260 190 54 10
text 260 210 54 11
text 260 230 54 12
text 260 250 54 13
button 270 285 2143 2142 1 1 201
button 320 285 2121 2120 1 1 202

[DIALOG d_housekeeper_menu2 TEXT]
CSD UO
House menu
<src.targ.name>
Housekeeper: <src.uid.<more>.name>
Change doors and locks
Change sign
Demolish house
Warning!
When you press OKAY
button your house will be
deleted within ALL locked
down items! Proceed to
demolish this house and
bring to you a house deed?
Lockdown item
Unlock item
Transfer house

[DIALOG d_housekeeper_menu2 BUTTON]
ONBUTTON=0
ONBUTTON=202

ONBUTTON=101
	src.targ.link.dialog d_housekeeper_menu

ONBUTTON=102
	src.targ.link.dialog d_housekeeper_menu1

ONBUTTON=110	// lock
	morex = 1
	target What item do you want to lockdown in your house?

ONBUTTON=111	// unlock
	morex = 2
	target What item do you want to unlock?

ONBUTTON=112	// transfer house
	morex = 3
	target Whom do you wish to transfer your house?

ONBUTTON=201
	if <src.targ.morex> < 48
		if !<src.isgm>
			src.sysmessage You cannot demolish house yet. You must wait for <eval(48 - <src.targ.morex>)> hours more.
			return 1
		endif
	endif
	if <id>==04064	// Small Stone and Plaster House
		src.newitem 04200
	elseif <id>==04066	// Small Stone House
		src.newitem 04202
	elseif <id>==04068	// Small Brick House
		src.newitem 04204
	elseif <id>==0406a	// Small Wood House
		src.newitem 04206
	elseif <id>==0406c	// Small Wood and Plaster House
		src.newitem 04208
	elseif <id>==0406e	// Small Wood House Thatched Roof
		src.newitem 04210
	elseif <id>==04074	// Three Room House
		src.newitem 04216
	elseif <id>==04076	// Two Story Wood and Plaster House
		src.newitem 04218
	elseif <id>==04078	// Two Story Stone and Plaster House
		src.newitem 04220
	elseif <id>==0407a	// Tower
		src.newitem 04222
	elseif <id>==0407c	// Keep
		src.newitem 04224
	elseif <id>==0407e	// Castle
		src.newitem 04226
	elseif <id>==04087 // Large Blacksmithy Shop
		src.newitem 04228
	elseif <id>==0408c // Large Blacksmithy Shop
		src.newitem 04228
	elseif <id>==04096 // Large Marble Patio House
		src.newitem 04229
	elseif <id>==04098 // Wizards Tower
		src.newitem 0422a
	elseif <id>==0409a // Two Story Log Cabin
		src.newitem 0422b
	elseif <id>==0409c // Sandstone Patio House
		src.newitem 0422c
	elseif <id>==0409e // Two Story Villa
		src.newitem 0422d
	elseif <id>==040a0 // Small Stone Shop
		src.newitem 0422e
	elseif <id>==040a2 // Small Marble Shop
		src.newitem 0422f

// --- New house deeds ---

	elseif <id>==04299 // Brick Stonghold
		src.newitem i_deed_stronghold_brick
	elseif <id>==0429a // Marble Stonghold
		src.newitem i_deed_stronghold_marble
	elseif <id>==0429b // Sandstone Stonghold
		src.newitem i_deed_stronghold_sandstone
	elseif <id>==0429c // Stone and Plaster Stonghold
		src.newitem i_deed_stronghold_stonep
	elseif <id>==0429d // Stone and Plaster Stonghold
		src.newitem i_deed_stronghold_stonep2
	elseif <id>==0429e // Wood and Plaster Stonghold
		src.newitem i_deed_stronghold_woodp
	elseif <id>==0429f // Brick Townhold
		src.newitem i_deed_townhold_brick
	elseif <id>==042a0 // Marble Townhold
		src.newitem i_deed_townhold_marble
	elseif <id>==042a1 // Sandstone Townhold
		src.newitem i_deed_townhold_sandstone
	elseif <id>==042a2 // Stone and Plaster Townhold
		src.newitem i_deed_townhold_stonep
	elseif <id>==042a3 // Wood and Plaster Townhold
		src.newitem i_deed_townhold_woodp
	elseif <id>==042a4 // Two Story Sandstone Villa
		src.newitem i_deed_2story_sand
	elseif <id>==042b7 // Brick House
		src.newitem i_deed_brickhouse
	elseif <id>==042b9 // Wood and Plaster Villa
		src.newitem i_deed_villa_woodp
	elseif <id>==04301 // Brick Cottage
		src.newitem i_deed_cott_brick
	elseif <id>==04302 // Stone Cottage
		src.newitem i_deed_cott_stone
	elseif <id>==04303 // Stone and Plaster Cottage
		src.newitem i_deed_cott_stonep
	elseif <id>==04304 // Dark Wooden Cottage
		src.newitem i_deed_cott_wood_d
	elseif <id>==04305 // Light Wooden Cottage
		src.newitem i_deed_cott_wood_l
	elseif <id>==04306 // Wood and Plaster Cottage
		src.newitem i_deed_cott_woodp
	elseif <id>==04290 // Yellow Stone Cottage
		src.newitem i_deed_cott_yellow
	elseif <id>==04322 // Stone and Plaster Townhall
		src.newitem i_deed_th_stonep
	elseif <id>==04323 // Wood and Plaster Townhall
		src.newitem i_deed_th_woodp
	elseif <id>==04324 // Wood and Plaster Hold
		src.newitem i_deed_hold
	elseif <id>==04325 // Brick Outfit House (South)
		src.newitem i_deed_o_brick_s
	elseif <id>==04326 // Brick Outfit House (East)
		src.newitem i_deed_o_brick_e
	elseif <id>==04329 // Wood and Plaster Millhouse
		src.newitem i_deed_mill_woodp
	elseif <id>==04296 // Stone and Plaster Millhouse
		src.newitem i_deed_mill_stonep
	elseif <id>==0432d // Marble Palazzo
		src.newitem i_deed_palazzo
	elseif <id>==0432e // Village Cottage
		src.newitem i_deed_village
	elseif <id>==04330 // Wood and Plaster Workshop
		src.newitem i_deed_shop_woodp
	elseif <id>==0433e // One story Stone and Plaster House
		src.newitem i_deed_1story_sp
	elseif <id>==0433f // Three story Stone and Plaster House
		src.newitem i_deed_3story_sp
	elseif <id>==04340 // Wood and Plaster Villa
		src.newitem i_deed_wood_p
	else
		src.newitem i_gold
		src.act.name Strange house
		// some strange house
	endif
	src.act.bounce
	src.act.timer -1
	src.targ.type = t_normal
	src.targ.link.remove
	src.targ.remove

[DIALOG d_housekeeper_menu3]
30 30
resizepic 0 0 5054 510 330
page 0
resizepic 170 10 83 315 44
resizepic 170 65 83 315 44
gumppic 10 10 100
text 50 35 52 0
text 40 55 52 1
text 185 20 1152 2
text 185 75 1152 3		// housekeeper
page 1
text 35 130 52 4		// change locks
button 15 134 1209 1210 1 1 101
text 35 150 52 5		// change brass sign
//button 15 154 1209 1210 1 1 102
text 35 220 55 9		// lock
button 15 224 1209 1210 1 1 110
text 35 240 55 10		// unlock
button 15 244 1209 1210 1 1 111
text 35 260 55 11		// transfer house
button 15 264 1209 1210 1 1 112
text 35 280 37 6		// demolish house
button 15 284 1209 1210 1 1 103

// brass signs

tilepic 260 160 3080
button 265 160 1209 1210 1 1 201
tilepic 290 160 3082
button 295 160 1209 1210 1 1 202
tilepic 320 160 3084
button 325 160 1209 1210 1 1 203
tilepic 350 160 3086
button 355 160 1209 1210 1 1 204
tilepic 380 160 3140
button 385 160 1209 1210 1 1 205
tilepic 410 160 2966
button 415 160 1209 1210 1 1 206
tilepic 440 160 2980
button 445 160 1209 1210 1 1 207

tilepic 260 200 2982
button 265 200 1209 1210 1 1 208
tilepic 290 200 2984
button 295 200 1209 1210 1 1 209
tilepic 320 200 2986
button 325 200 1209 1210 1 1 210
tilepic 350 200 2988
button 355 200 1209 1210 1 1 211
tilepic 380 200 2990
button 385 200 1209 1210 1 1 212
tilepic 410 200 2992
button 415 200 1209 1210 1 1 213
tilepic 440 200 2994
button 445 200 1209 1210 1 1 214

tilepic 260 240 2996
button 265 240 1209 1210 1 1 215
tilepic 290 240 2998
button 295 240 1209 1210 1 1 216
tilepic 320 240 3000
button 325 240 1209 1210 1 1 217
tilepic 350 240 3002
button 355 240 1209 1210 1 1 218
tilepic 380 240 3004
button 385 240 1209 1210 1 1 219
tilepic 410 240 3006
button 415 240 1209 1210 1 1 220
tilepic 440 240 3022
button 445 240 1209 1210 1 1 221

tilepic 260 280 3008
button 265 280 1209 1210 1 1 222
tilepic 290 280 3010
button 295 280 1209 1210 1 1 223
tilepic 320 280 3012
button 325 280 1209 1210 1 1 224
tilepic 350 280 3014
button 355 280 1209 1210 1 1 225
tilepic 380 280 3016
button 385 280 1209 1210 1 1 226
tilepic 410 280 3018
button 415 280 1209 1210 1 1 227
tilepic 440 280 3020
button 445 280 1209 1210 1 1 228

text 260 130 1153 7
text 435 130 1153 8
button 415 134 1209 1210 1 1 104

[DIALOG d_housekeeper_menu3 TEXT]
CSD UO
House menu
<src.targ.name>
Housekeeper: <src.uid.<more>.name>
Change doors and locks
Change sign
Demolish house
Select new sign:
page 1
Lockdown item
Unlock item
Transfer house

[DIALOG d_housekeeper_menu3 BUTTON]
ONBUTTON=0

ONBUTTON=101
	src.targ.link.dialog d_housekeeper_menu

ONBUTTON=103
	src.targ.link.dialog d_housekeeper_menu2

ONBUTTON=104
	src.targ.link.dialog d_housekeeper_menu1

ONBUTTON=110	// lock
	morex = 1
	target What item do you want to lockdown in your house?

ONBUTTON=111	// unlock
	morex = 2
	target What item do you want to unlock?

ONBUTTON=112	// transfer house
	morex = 3
	target Whom do you wish to transfer your house?

ONBUTTON=201
	src.targ.id=0c08
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=202
	src.targ.id=0c0a
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=203
	src.targ.id=0c0c
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=204
	src.targ.id=0coe
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=205
	src.targ.id=0c44
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=206
	src.targ.id=0b96
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=207
	src.targ.id=0ba4
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=208
	src.targ.id=0ba6
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=209
	src.targ.id=0ba8
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=210
	src.targ.id=0baa
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=211
	src.targ.id=0bac
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=212
	src.targ.id=0bae
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=213
	src.targ.id=0bb0
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=214
	src.targ.id=0bb2
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=215
	src.targ.id=0bb4
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=216
	src.targ.id=0bb6
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=217
	src.targ.id=0bb8
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=218
	src.targ.id=0bba
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=219
	src.targ.id=0bbc
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=220
	src.targ.id=0bbe
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=221
	src.targ.id=0bce
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=222
	src.targ.id=0bc0
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=223
	src.targ.id=0bc2
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=224
	src.targ.id=0bc4
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=225
	src.targ.id=0bc6
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=226
	src.targ.id=0bc8
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=227
	src.targ.id=0bca
	src.targ.type=t_house_brass_sign
	src.targ.update

ONBUTTON=228
	src.targ.id=0bcc
	src.targ.type=t_house_brass_sign
	src.targ.update

//##############
// House guest menu
//##############

[DIALOG d_houseguest_menu]
30 30
resizepic 0 0 5054 510 160
page 0
resizepic 170 10 83 315 44
resizepic 170 65 83 315 44
gumppic 10 10 100
text 50 35 52 0
text 40 55 52 1
text 185 20 52 2
text 185 75 52 3		// housekeeper

[DIALOG d_houseguest_menu TEXT]
CSD UO
House menu
<src.targ.name>
Housekeeper: <src.uid.<more>.name>

[DIALOG d_houseguest_menu BUTTON]
ONBUTTON=0

//######################
// CSD UO: Hotel system
//######################

// link  - serial number of player
// more  - serial number of apartment door
// more2 - link to key				// sub timer - count for 2-hours invtervals
// morex - sub timer - count for 2-hours invtervals	// calculator 1
// morey - cost per day (real)
// morez - calculator 2

[TYPEDEF t_porter]
On=@Click
	if (<timer> == -1) && (<morex> != 0)
		timer = 7200
	endif
	if <link>==04fffffff
		message This apartment is free and you can rent it at <morey> gp per day.
	else
		message <link.name>'s apartment. Rent for <eval (<morex> / 12)> days more.
	endif
	return 1

On=@DClick
	if (<timer> == -1) && (<morex> != 0)
		timer = 7200
	endif
	if <link> == 04fffffff
		dialog d_hotel_rent
		return 0
	elseif <link> == <src.serial>
		morez = (<morex> / 12)
		dialog d_hotel_pay
		return 0
	else
		dialog d_hotel_busy
		return 0
	endif
	return 0

On=@Timer
	if <morex> == 0
		link = <more>
		link = <link.more>
		if <link.type> == t_key
			link.remove
		endif
		link = <more>
		link.more = <link.serial>
		if <link.type> != t_door_locked
			link.type = t_door_locked
		endif
		link = 04fffffff
		timer = -1
	else
		morex = (<morex> - 1)
		timer = 7200
	endif
	return 1

[FUNCTION f_hotel_rent]
//	morex=(<argn>*<morey>)
	if <src.restest <eval(<argn>*<morey>)> i_gold>
		src.consume <eval(<argn>*<morey>)> i_gold
		link = <more>
		link.type = t_door_locked
		morex = (<argn>*12)	// amount of 2-hours intervals in selected rent period
		timer = 7200
		src.newitem i_key_magic
		link.more = <src.act.serial>
		src.act.more = <src.act.serial>
		src.act.link = <link.serial>
		src.act.timer = -1
		src.act.bounce
		src.message That is <eval(<argn>*<morey>)> gold coins worth of apartment for <argn> days. Welcome to <name>!
		link = <src.serial>
	else
		src.message You lack <eval(<argn>*<morey>)> gold coins to pay for apartment.
	endif
	return 1

[FUNCTION f_hotel_pay]
	morez = (<morex> / 12)	// days left
	if <morez> > 20
		src.message You can't pay more yet!
	else
//		morex = (<argn> * <morey>)
		if <src.restest <eval(<argn>*<morey>)> i_gold>
			src.consume <eval(<argn>*<morey>)> i_gold
			morex = (<morex> + (<argn> * 12))
			src.message That is <eval(<argn>*<morey>)> gold coins worth of apartment for <argn> days.
		else
			src.message You lack <eval(<argn>*<morey>)> gold coins to pay for apartment.
		endif
	endif
	return 1

[DIALOG d_hotel_rent]
30 30
resizepic 0 0 5054 510 230
page 0
resizepic 170 10 83 315 44
gumppic 10 10 100
text 50 35 52 0
text 40 55 52 1
text 185 20 52 2	// hotel name

text 180 65 52 3
text 200 90 52 4
button 180 94 1209 1210 1 1 1
text 200 110 52 5
button 180 114 1209 1210 1 1 2
text 200 130 52 6
button 180 134 1209 1210 1 1 3
text 200 150 52 7
button 180 154 1209 1210 1 1 4
text 200 170 52 8
button 180 174 1209 1210 1 1 5
text 200 190 52 9
button 180 194 1209 1210 1 1 6

[DIALOG d_hotel_rent TEXT]
CSD UO
Hotel menu
<name>
Rent the apartment at <eval(<morey>)> gp per day:
for 1 day at <eval (<morey>)> gp
for 2 days at <eval (<morey>*2)> gp
for 3 days at <eval (<morey>*3)> gp
for 5 days at <eval (<morey>*5)> gp
for 10 days at <eval (<morey>*10)> gp
for 30 days at <eval (<morey>*30)> gp

[DIALOG d_hotel_rent BUTTON]
ONBUTTON=0

ONBUTTON=1	// rent for 1 day
	f_hotel_rent 1

ONBUTTON=2
	f_hotel_rent 2

ONBUTTON=3
	f_hotel_rent 3

ONBUTTON=4
	f_hotel_rent 5

ONBUTTON=5
	f_hotel_rent 10

ONBUTTON=6
	f_hotel_rent 30

[DIALOG d_hotel_pay]
30 30
resizepic 0 0 5054 510 260
page 0
resizepic 170 10 83 315 44
resizepic 10 205 83 140 44
gumppic 10 10 100
text 50 35 52 0
text 40 55 52 1
text 185 20 52 2	// hotel name
text 25 215 52 11

text 180 65 52 3
text 200 90 52 4
button 180 94 1209 1210 1 1 1
text 200 110 52 5
button 180 114 1209 1210 1 1 2
text 200 130 52 6
button 180 134 1209 1210 1 1 3
text 200 150 52 7
button 180 154 1209 1210 1 1 4
text 200 170 52 8
button 180 174 1209 1210 1 1 5
text 200 190 52 9
button 180 194 1209 1210 1 1 6
text 200 215 52 10
button 180 219 1209 1210 1 1 7

[DIALOG d_hotel_pay TEXT]
CSD UO
Hotel menu
<name>
Pay for the apartment at <morey> per day:
for 1 day at <eval (<morey>)> gp
for 2 days at <eval (<morey>*2)> gp
for 3 days at <eval (<morey>*3)> gp
for 5 days at <eval (<morey>*5)> gp
for 10 days at <eval (<morey>*10)> gp
for 30 days at <eval (<morey>*30)> gp
Free the apartment (<eval ((<morex> / 12) * <morey>)> gp back)
<eval (<morex>/12)> days left
[DIALOG d_hotel_pay BUTTON]
ONBUTTON=0

ONBUTTON=1	// pay for 1 day
	f_hotel_pay 1

ONBUTTON=2
	f_hotel_pay 2

ONBUTTON=3
	f_hotel_pay 3

ONBUTTON=4
	f_hotel_pay 5

ONBUTTON=5
	f_hotel_pay 10

ONBUTTON=6
	f_hotel_pay 30

ONBUTTON=7
	// free apartment
	// return cash
	morex = (<morex> / 12)
	morex = (<morex> * <morey>)
	src.newitem i_gold
	src.act.amount = <morex>
	src.act.timer = -1
	src.act.bounce
	link = <more>
	link = <link.more>
	if <link.type> == t_key
		link.remove
	endif
	link = <more>
	link.more = <link.serial>
	if <link.type> != t_door_locked
		link.type = t_door_locked
	endif
	link = 04fffffff
	timer = -1
	src.message That is your <morex> gold coins. Get back <src.name>...

[DIALOG d_hotel_busy]
30 30
resizepic 0 0 5054 510 123
page 0
resizepic 170 10 83 315 44
resizepic 170 65 83 315 44
gumppic 10 10 100
text 50 35 52 0
text 40 55 52 1
text 185 20 52 2	// hotel name
text 185 75 52 3	// Logher

[DIALOG d_hotel_busy TEXT]
CSD UO
Hotel menu
<name>
Logher: <link.name>

[DIALOG d_hotel_busy BUTTON]
ONBUTTON=0

[EOF]