//############
// Player's vendors
//############

// 06.11.2001, MoNK: temporary disable "advertising"
// 10.10.2001, MoNK: i_market_mark_new, return 1 for 'hire'
// 15.08.2001, MoNK: 200 gp per day and "advertizing"
// 14.05.2001, MoNK: free vendor can be hire anyone and cannot be removed by previous owner
// 01.05.2001, MoNK: 'Give' command
// 28.04.2001, MoNK: Market Place telepads
// 28.04.2001, MoNK: spk_vendor_csd, other speeches and events removed
// 27.04.2001, MoNK: STR increased
// 25.04.2001, MoNK: some changes in i_deed_vendor (weight, type etc.)

[TYPEDEF t_market_place_out]
On=@Step
	if <src.restest i_market_mark_new>
		if <src.restest i_market_mark>
			src.consume i_market_mark
		endif
		src.go <src.findid(i_market_mark_new).morep>
		src.consume 1000 i_market_mark_new
	elseif <src.restest i_market_mark>
		src.go <src.findlayer(layer_pack).findid(i_market_mark).morep>
		src.consume 1000 i_market_mark
	elseif (<morex> != 0) && (<morey> != 0)
		src.go <morep>
	else
		src.message Market Place exit teleport is broken. Please, call GM now.
	endif

[TYPEDEF t_market_place_in]
On=@DClick
	if <distance> > 2
		src.sysmessage You are too far away
		return 1
	endif
	if <src.restest i_market_mark>
		src.consume 1000 i_market_mark
	endif
	if <src.restest i_market_mark_new>
		src.consume 1000 i_market_mark_new
	endif
	src.newitem i_market_mark_new
	src.act.morep = <src.p>
	src.act.timer = -1
	src.act.cont = <src.serial>
	src.go <morep>
	src.message To leave the market place just step on 'Exit' pad.
	return 1

[ITEMDEF i_market_mark_new]
NAME=Oskom Market Ticket
ID=i_deed
TYPE=t_eq_script
LAYER=layer_special
WEIGHT=0

On=@Create
	attr = attr_invis | attr_newbie

[ITEMDEF i_market_mark]
NAME=Market Ticket
ID=i_deed
TYPE=t_normal

On=@Create
	attr = attr_newbie | attr_move_never

On=@DClick
	message Target same market ticket to remove it
	target
	return 1

On=@Targon_item
	if <src.targ.serial>==<serial>
		src.targ.remove
		return 1
	else
		src.message Wrong target
		return 1
	endif

[SPEECH spk_vendor_csd]

On=*hire*
	if <typedef.hiredaywage>
		hire
		return 1
	endif

On=*buy*
On=*supplies*
On=*wares*
	BUY

On=Hi
On=Hello
On=Hail
On=Greet
	SAY=Greetings, adventurer.

On=Bye
On=Goodbye
On=Farewell
	SAY=Fare thee well.
	BYE
	return 1

On=Give
	if <ismypet>
		if <findlayer(layer_pack).findcont(0)>
			findlayer(layer_pack).findcont(0).attr = <findlayer(layer_pack).findcont(0).attr> & (attr_identified | attr_newbie | attr_move_always | attr_magic | attr_cursed | attr_cursed2 | attr_blessed | attr_blessed2 | attr_can_decay)
			findlayer(layer_pack).findcont(0).drop
		endif
	else
		say Sorry, you are not my master
	endif

[EVENTS e_vendor_csd]
On=@NPCSeeNewPlayer
	if <ismypet>
		return 0
	endif
	if <distance> > 3
		return 1
	endif

	face
//	tag.itemnumber = <eval(rand(20))>
//	if <findlayer(layer_vendor_stock).findcont(<tag.itemnumber>)>
//		dorand 4
//			say Only here and only now: <findlayer(layer_vendor_stock).findcont(<tag.itemnumber>).name> for <findlayer(layer_vendor_stock).findcont(<tag.itemnumber>).price> gp only!
//			say Hey, <src.name>! The wonderful <findlayer(layer_vendor_stock).findcont(<tag.itemnumber>).name> for <findlayer(layer_vendor_stock).findcont(<tag.itemnumber>).price> gp only!
//			say Look at this, <src.sex Milord/Milady> <src.name>! <findlayer(layer_vendor_stock).findcont(<tag.itemnumber>).name> for <findlayer(layer_vendor_stock).findcont(<tag.itemnumber>).price> gold pieces!
//			say There is <findlayer(layer_vendor_stock).findcont(<tag.itemnumber>).name> for <findlayer(layer_vendor_stock).findcont(<tag.itemnumber>).price> gp on my stock!
//		enddo
//	endif
	return 0

[TYPEDEF t_vendor_display_case]
//more - serial of vendor
On=@DClick
	if <more>==0
		if <src.targ.distance> > 1
			src.sysmessage You must stay closer by Display Case.
			return 1
		endif
		if <src.restest 1 i_deed_vendor>
			src.consume 1 i_deed_vendor
			dorand 2
				src.newnpc c_h_vendor
				src.newnpc c_h_vendor_f
			enddo
			src.targ.more = <src.act.serial>
			src.act.food = 9999
		else
			src.sysmessage You do not have vendor deed.
		endif
		return 1
	endif

	if <src.uid.<more>.memoryfindtype.memory_ipet>
		if <src.uid.<more>.memoryfindtype.memory_ipet.link> == <src.serial>
			src.targ.dialog d_vendor_owner
		else
			message This Display Case is rented by <src.uid.<more>.memoryfindtype.memory_ipet.link.name> with vendor <src.uid.<more>.name>
		endif
	else
		message This Display Case is free because <src.uid.<more>.name> is not hired anyone
	endif	
	return 1

On=@Click
	if <more>==0
		message Free Display Case
	else
		if <src.uid.<more>.memoryfindtype.memory_ipet>
			message This Display Case is rented by <src.uid.<more>.memoryfindtype.memory_ipet.link.name> with vendor <src.uid.<more>.name>
		else
			message This Display Case is free because <src.uid.<more>.name> is not hired anyone
		endif
	endif
	return 1

[DIALOG d_vendor_owner]
100 100
resizepic 0 0 3500 235 220
text 30 30 37 0
text 30 50 1152 1
text 30 70 1152 2
text 30 90 1152 3
text 30 120 1152 4
text 30 140 1152 5
button 80 180 249 248 1 1 101

[DIALOG d_vendor_owner TEXT]
Warning!
When you choose OKAY
vendor will be removed
with ALL stocked items!
Free this display case 
and redeed vendor?

[DIALOG d_vendor_owner BUTTON]
ONBUTTON=101
	if <src.uid.<more>.brain>!=brain_vendor
		src.uid.<more2>.message ERROR: This Display Case is broken! Call GM now!
	endif
	src.newitem i_deed_vendor
	src.act.bounce
	link = <more>
	link.remove
	link = 04fffffff
	more = 0
	more2 = 0

[ITEMDEF i_deed_vendor]
NAME=Vendor deed
ID=i_deed
VALUE=50000
WEIGHT=1
TYPE=t_normal

CATEGORY=Provisions - Deeds
SUBSECTION=Vendor deed
DESCRIPTION=Player's vendor deed

On=@DClick
	src.sysmessage To place vendor on market place choose free display case and click double on it.
	return 1

[CHARDEF c_h_vendor]
NAME=#NAMES_HUMANMALE the Vendor
ID=c_man
HIREDAYWAGE=200
DESIRES=i_gold,e_notoriety
AVERSIONS=t_trap,t_eerie_stuff

TSPEECH=spk_vendor_csd
//TSPEECH=spk_human_prime
//TSPEECH=spk_shopkeep
//TSPEECH=spk_needs
//TSPEECH=spk_human_default

TEVENTS=e_vendor_csd
//TEVENTS=e_Human_HearUnk
//TEVENTS=e_Human_ConvInit
//TEVENTS=e_Human_Needs
//TEVENTS=e_Human_Greet
//TEVENTS=e_Human_Space
//TEVENTS=e_Human_Refuse
//TEVENTS=e_Human_Environ

//FOODTYPE=
CAN=0

ON=@Create
	NPC=brain_vendor
	COLOR=colors_skin
	FLAGS=028000005
	NEED=i_gold
	FOOD=32767

	STR=300	//=200
	DEX=100
	INT=100

	FENCING={15.0 38.0}
	PARRYING={45.0 68.0}
	SWORDSMANSHIP={15.0 38.0}
	WRESTLING={15.0 38.0}
	MACEFIGHTING={15.0 38.0}
	MAGICRESISTANCE={45.0 68.0}
	TACTICS={45.0 68.0}

	ITEM=equip_vendor

On=@GetHit
	return 1

CATEGORY=Civilized
SUBSECTION=Tradesmen
DESCRIPTION=Vendor

[CHARDEF c_h_vendor_f]
NAME=#NAMES_HUMANFEMALE the Vendor
ID=c_woman
CAN=0
HIREDAYWAGE=200
//FOODTYPE=

TSPEECH=spk_vendor_csd
//TSPEECH=spk_human_prime
//TSPEECH=spk_shopkeep
//TSPEECH=spk_needs
//TSPEECH=spk_human_default

TEVENTS=e_vendor_csd
//TEVENTS=e_Human_HearUnk
//TEVENTS=e_Human_ConvInit
//TEVENTS=e_Human_Needs
//TEVENTS=e_Human_Greet
//TEVENTS=e_Human_Space
//TEVENTS=e_Human_Refuse
//TEVENTS=e_Human_Environ

ON=@Create
	NPC=brain_vendor
	COLOR=colors_skin
	FLAGS=028000005
	NEED=i_gold
	FOOD=32767

	STR=300	//=200
	DEX=100
	INT=100

	FENCING={15.0 38.0}
	PARRYING={45.0 68.0}
	SWORDSMANSHIP={15.0 38.0}
	WRESTLING={15.0 38.0}
	MACEFIGHTING={15.0 38.0}
	MAGICRESISTANCE={45.0 68.0}
	TACTICS={45.0 68.0}

	ITEM=equip_vendor_f

On=@GetHit
	return 1

CATEGORY=Provisions - Deeds
SUBSECTION=Vendor Deeds
DESCRIPTION=Player Vendor Female