[PLEVEL 4]
ADDQUEST

[FUNCTION ADDQUEST]
IF (<ISCHAR>)
	IF (!(<ISTEVENT.e_questers>))
	EVENTS +E_QUESTERS
	ENDIF
ELSE
TYPE=T_QUEST_ITEM_GIVER
ENDIF
TAG0.QUESTS ++
TRY TAG.QUEST<dTAG0.QUESTS>.ID=<ARGN>
SRC.SYSMESSAGE @33,3,1 Quest added!

[FUNCTION openquestlog]
SDIALOG d_quest_log

[PLEVEL 1]
openquestlog

[DIALOG d_quest_log]
250,100
src.closealldialogs

PAGE 0
resizepic 30 15 5120 430 410

FOR 29
gumppic <EVAL (<LOCAL._FOR>*15)+15> 15 0280a
IF (<LOCAL._FOR> < 29)
gumppic <EVAL (<LOCAL._FOR>*15)+13> 420 0280a
ENDIF
ENDFOR
gumppic 445 420 0280a

gumppic 415 30 203
gumppic 415 75 203
gumppic 415 105 203
FOR 13
gumppic 415 <EVAL (<LOCAL._FOR>*30)+2> 10460
ENDFOR

gumppic 30 30 202
gumppic 30 75 202
gumppic 30 105 202
gumppic 29 105 0242f
FOR 13
gumppic 45 <EVAL (<LOCAL._FOR>*30)+2> 10460
ENDFOR

gumppic 425 300 028ac
gumppic 425 150 028ab
gumppic 425 0 028aa

gumppic -5 10 028b5
gumppic 25 0 028b4
gumppic 45 130 028ab
gumppic -22 280 028a2

gumppic 368 50 0589
gumppic 377 60 01580

gumppic 85 35 0232d
xmfhtmlgumpcolor 125 45 100 35 1046026 0 0 32767
gumppictiled 125 65 150 1 9101

button 310 400 02eec 02eed 1 0 0

PAGE 1

IF (<TAG0.QUESTS>)
	FOR <TAG0.QUESTS>
		IF (<EHNUM <DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_NAMELOCALIZED>>)
			IF !(<TAG0.QUEST<dLOCAL._FOR>.FAILED>)
			xmfhtmlgumpcolor 100 <EVAL (<LOCAL._FOR>*25)+105> 240 20 <EVAL <DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_NAMELOCALIZED>> 0 0 32767
			ELSE
			xmfhtmlgumpcolor 100 <EVAL (<LOCAL._FOR>*25)+105> 240 20 <EVAL <DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_NAMELOCALIZED>> 0 0 24673
			ENDIF
		ELSE
			IF !(<TAG0.QUEST<dLOCAL._FOR>.FAILED>)
			dhtmlgump 100 <EVAL (<LOCAL._FOR>*25)+105> 240 20 0 0 <DEF.BFONT_WHITE><DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_NAMELOCALIZED>
			ELSE
			dhtmlgump 100 <EVAL (<LOCAL._FOR>*25)+105> 240 20 0 0 <DEF.BFONT_DRED><DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_NAMELOCALIZED>
			ENDIF
		ENDIF
	button 360 <EVAL (<LOCAL._FOR>*25)+105> 026b0 026b1 1 0 <LOCAL._FOR>
	ENDFOR
ENDIF
xmfhtmlgumpcolor 90 400 50 20 3001024 0 0 26574
dtext 140 400 1153 <dTAG0.QUESTS>
dhtmlgump 160 401 50 20 0 0 <DEF.BFONT_WHITE>/ 10

PAGE 2
IF (<CTAG0.QUESTVIEWID>)
	IF (<EHNUM <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>>)
	xmfhtmlgumpcolor 155 105 200 20 <EVAL <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>> 0 0 7952
	ELSE
	dhtmlgump 155 105 200 20 0 0 <DEF.BFONT_QUESTODESC><DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>
	ENDIF
	IF (!(<ISEMPTY <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_ISCHAIN>>)) || (0<DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_CHAIN>)
	xmfhtmlgumpcolor 93 135 150 20 1075024 0 0 7952
	ELSE
	xmfhtmlgumpcolor 93 135 150 20 1072202 0 0 7952
	ENDIF
	IF (<EHNUM <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_TEXTLOCALIZED>>)
	xmfhtmlgumpcolor 93 150 317 190 <EVAL <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_TEXTLOCALIZED>> 0 1 26574
	ELSE
	dhtmlgump 93 150 317 190 0 1 <DEF.BFONT_QUESTTEXT><DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_TEXTLOCALIZED>
	ENDIF
button 125 370 02eef 02ef0 0 1 0
button 280 370 02ee9 02eeb 0 3 0
button 95 400 02ef5 02ef7 1 0 101
	IF (<TAG0.QUEST<dCTAG0.QUESTVIEWID>.FAILED>)
	xmfhtmlgumpcolor 250 120 50 20 500039 0 0 24673
	ENDIF
ENDIF

PAGE 3
IF (<CTAG0.QUESTVIEWID>)
	IF (<EHNUM <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>>)
	xmfhtmlgumpcolor 155 105 200 20 <EVAL <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>> 0 0 7952
	ELSE
	dhtmlgump 155 105 200 20 0 0 <DEF.BFONT_QUESTODESC><DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>
	ENDIF
xmfhtmlgumpcolor 93 135 70 20 1049073 0 0 7952
xmfhtmlgumpcolor 93 150 130 20 1072208 0 0 7952
	IF (<TAG0.QUEST<dCTAG0.QUESTVIEWID>.FAILED>)
	xmfhtmlgumpcolor 250 150 50 20 500039 0 0 24673
	ENDIF
	IF (!(0<DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_RIDDLE>))
		FOR <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVEAMOUNT>
			IF (<LOCAL.AUMENTAR> > 197)
			LOCAL.AUMENTAR=197
			ELIF (<LOCAL.AUMENTAR> > 182)
			LOCAL.AUMENTAR=182
			ELIF (<LOCAL.AUMENTAR> > 167)
			LOCAL.AUMENTAR=167
			ELIF (<LOCAL.AUMENTAR> > 152)
			LOCAL.AUMENTAR=152
			ELSE
			LOCAL.AUMENTAR=137
			ENDIF
			IF (0<DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_TYPE> == 1)
			xmfhtmlgumpcolor 93 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 70 20 1072205 0 0 26574
			dtext 135 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <STRARG <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>> <SERV.ITEMDEF.<STREAT <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>>.NAME>
			tilepichue 365 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> <SERV.ITEMDEF.<STREAT <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>>.ID> <ITEMTILEPICCOLOR <STREAT <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>>>
			LOCAL.AUMENTAR += 15
				IF (0<DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_TIME>)
				xmfhtmlgumpcolor 100 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 130 20 1062379 0 0 26574
				dtext 220 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <QUESTTIMEREMAINING <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>
				LOCAL.AUMENTAR += 15
				ENDIF
			xmfhtmlgumpcolor 100 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 70 20 3000152 0 0 26574
				IF (<RESTEST <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>>)
				LOCAL.QUANTLEFT=<STRARG <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>>
				ELSE
				LOCAL.QUANTLEFT=<RESCOUNT <STREAT <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>>>
				ENDIF
			dtext 220 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <EVAL <LOCAL.QUANTLEFT>>
			LOCAL.AUMENTAR += 15
			xmfhtmlgumpcolor 100 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 70 20 1074782 0 0 26574
			LOCAL.QUESTERNAME=<UID.<TAG0.QUEST<dCTAG0.QUESTVIEWID>.QUESTERUID>.NAME>
				IF (STRMATCH(* The*,<LOCAL.QUESTERNAME>))
				LOCAL.THEINDEX=<HVAL (StrIndexOf(<LOCAL.QUESTERNAME>,The,0))-1>
				LOCAL.SECONDTHEINDEX=<HVAL (StrIndexOf(<LOCAL.QUESTERNAME>,the,0))-1>
					IF (<LOCAL.THEINDEX> < 0)
					LOCAL.RIGHTINDEX=<LOCAL.SECONDTHEINDEX>
					ELSE
					LOCAL.RIGHTINDEX=<LOCAL.THEINDEX>
					ENDIF
				LOCAL.QUESTERNAME=<STRSUB 0 <LOCAL.RIGHTINDEX> <LOCAL.QUESTERNAME>>
				ENDIF
			dtext 220 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <LOCAL.QUESTERNAME> (<UID.<TAG0.QUEST<dCTAG0.QUESTVIEWID>.QUESTERUID>.REGION.NAME>)
			ELIF (0<DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_TYPE> == 2)
			xmfhtmlgumpcolor 93 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 70 20 3005010 0 0 26574
			dtext 125 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <STRARG <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>> <SERV.CHARDEF.<STREAT <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>>.NAME>
			LOCAL.AUMENTAR += 15
				IF (0<DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_TIME>)
				xmfhtmlgumpcolor 100 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 130 20 1062379 0 0 26574
				dtext 220 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <QUESTTIMEREMAINING <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>
				LOCAL.AUMENTAR += 15
				ENDIF
				IF !(<ISEMPTY <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_LOCATION>>)
				xmfhtmlgumpcolor 100 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 70 20 3005105 0 0 26574
				dtext 220 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_LOCATION>
				LOCAL.AUMENTAR += 15
				ENDIF
			xmfhtmlgumpcolor 100 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 70 20 3000152 0 0 26574
			dtext 220 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <EVAL <STRARG <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>>-<TAG0.QUEST<dCTAG0.QUESTVIEWID>.SLAY<STREAT <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>>>>
			LOCAL.AUMENTAR += 15
			xmfhtmlgumpcolor 100 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 70 20 1074782 0 0 26574
			LOCAL.QUESTERNAME=<UID.<TAG0.QUEST<dCTAG0.QUESTVIEWID>.QUESTERUID>.NAME>
				IF (STRMATCH(* The*,<LOCAL.QUESTERNAME>))
				LOCAL.THEINDEX=<HVAL (StrIndexOf(<LOCAL.QUESTERNAME>,The,0))-1>
				LOCAL.SECONDTHEINDEX=<HVAL (StrIndexOf(<LOCAL.QUESTERNAME>,the,0))-1>
					IF (<LOCAL.THEINDEX> < 0)
					LOCAL.RIGHTINDEX=<LOCAL.SECONDTHEINDEX>
					ELSE
					LOCAL.RIGHTINDEX=<LOCAL.THEINDEX>
					ENDIF
				LOCAL.QUESTERNAME=<STRSUB 0 <LOCAL.RIGHTINDEX> <LOCAL.QUESTERNAME>>
				ENDIF
			dtext 220 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <LOCAL.QUESTERNAME> (<UID.<TAG0.QUEST<dCTAG0.QUESTVIEWID>.QUESTERUID>.REGION.NAME>)
			ELIF (0<DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_TYPE> == 3)
			local.deliverquest=1
			xmfhtmlgumpcolor 93 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 70 20 1072207 0 0 26574
			dtext 140 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <STRARG <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>> <SERV.ITEMDEF.<STREAT <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>>.NAME>
			LOCAL.AUMENTAR += 15
				IF (0<DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_TIME>)
				xmfhtmlgumpcolor 100 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 130 20 1062379 0 0 26574
				dtext 220 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <QUESTTIMEREMAINING <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>
				LOCAL.AUMENTAR += 15
				ENDIF
			xmfhtmlgumpcolor 100 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 70 20 1072379 0 0 26574
			dtext 220 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_RECEIVER>
			ELIF (0<DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_TYPE> == 4)
			xmfhtmlgumpcolor 93 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 70 20 1072206 0 0 26574
			dtext 160 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>
			LOCAL.AUMENTAR += 15
				IF (0<DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_TIME>)
				xmfhtmlgumpcolor 100 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 130 20 1062379 0 0 26574
				dtext 220 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <QUESTTIMEREMAINING <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>
				LOCAL.AUMENTAR += 15
				ENDIF
			ENDIF
		ENDFOR
	ELSE
	dtext 220 172 1153 RIDDLE
	ENDIF
button 125 370 02eef 02ef0 0 2 0
button 280 370 02ee9 02eeb 0 4 0
button 95 400 02ef5 02ef7 1 0 101
ENDIF

PAGE 4
IF (<CTAG0.QUESTVIEWID>)
	IF (<EHNUM <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>>)
	xmfhtmlgumpcolor 155 105 200 20 <EVAL <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>> 0 0 7952
	ELSE
	dhtmlgump 155 105 200 20 0 0 <DEF.BFONT_QUESTODESC><DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>
	ENDIF
	xmfhtmlgumpcolor 93 135 70 20 1072842 0 0 7952
	FOR <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_PRIZES>
	gumppic 100 <EVAL (<LOCAL._FOR>*25)+135> 1210
	dhtmlgump 130 <EVAL (<LOCAL._FOR>*24)+135> 280 20 0 0 <DEF.BFONT_QUESTPRIZETEXTCOLOR><STREAT <DEF.QUEST_<EVAL <TAG0.QUEST<dCTAG0.QUESTVIEWID>.ID>>_PRIZEID<dLOCAL._FOR>>>
	ENDFOR
button 125 370 02eef 02ef0 0 3 0
button 95 400 02ef5 02ef7 1 0 101
	IF (<TAG0.QUEST<dCTAG0.QUESTVIEWID>.FAILED>)
	xmfhtmlgumpcolor 250 140 50 20 500039 0 0 24673
	ENDIF
ENDIF

[DIALOG d_quest_log BUTTON]
ON=1 10
CTAG.QUESTVIEWID=<ARGN1>
SDIALOG d_quest_log 2

ON=101
SDIALOG d_quest_resign

[DIALOG d_quest_resign] //10006
200,170
src.closealldialogs
PAGE 0
gumppic 0 0 2702
gumppic 70 0 2702
gumppic 0 46 2702
gumppic 70 46 2702
checkertrans 0 0 345 260

FOR 20
gumppic <EVAL (<LOCAL._FOR>*15)+5> 0 0280a
gumppic <EVAL (<LOCAL._FOR>*15)+5> 240 0280a
	IF (<LOCAL._FOR> <= 15)
	gumppic 0 <EVAL (<LOCAL._FOR>*15)> 027dd
	gumppic 325 <EVAL (<LOCAL._FOR>*15)> 027dd
	ENDIF
ENDFOR
gumppic 310 0 0280e
gumppic 310 240 0280e
gumppic 15 0 0280c
gumppic 15 240 0280c

gumppic 0 225 027dc
gumppic 325 225 027dc

gumppic 0 15 027da
gumppic 325 15 027da

gumppic 328 244 10006
gumppic 328 3 10006
gumppic 3 244 10006
gumppic 3 3 10006

button 260 215 247 248 1 0 1

xmfhtmlgumpcolor 20 20 200 20 1049000 0 0 24673
gumppictiled 20 40 240 3 9357

xmfhtmlgumpcolor 20 55 305 165 1060836 0 0 32767

xmfhtmlgumpcolor 55 180 250 20 1049005 0 0 32767
xmfhtmlgumpcolor 55 215 250 20 1049006 0 0 32767

radio 20 175 9722 9723 1 1
radio 20 210 9722 9723 0 2

[DIALOG d_quest_resign BUTTON]
ON=1
IF (<ARGCHK[1]>)
sysmessageloc -1,1049015
QUITQUEST <CTAG0.QUESTVIEWID>
ELIF (<ISONLINE>)
sysmessageloc -1,1049014
SDIALOG d_quest_log
ENDIF

ON=0
IF (<ISONLINE>)
sysmessageloc -1,1049014
SDIALOG d_quest_log
ENDIF

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

[TEMPLATE tm_questbagtrinketssmall]
CONTAINER=i_bag
NAME=A Small Bag of Trinkets
COLOR=0283
EVENTS=t_smallbagtrinkets
ITEM=i_gold,150
ITEM=i_arrow,20

[TYPEDEF t_smallbagtrinkets]
ON=@Clienttooltip
RANDMAGICITEM
EVENTS -t_smallbagtrinkets
UPDATE 1

[TEMPLATE tm_questbagtrinkets]
CONTAINER=i_bag
NAME=A Bag of Trinkets
COLOR=01bb
EVENTS=t_bagtrinkets
ITEM=i_gold,{250 400}
ITEM=i_arrow,100

[TYPEDEF t_bagtrinkets]
ON=@Clienttooltip
FOR <R1,2>
RANDMAGICITEM
ENDFOR
EVENTS -t_bagtrinkets
UPDATE 1

[TEMPLATE tm_questbagtreasure]
CONTAINER=i_bag
NAME=A Bag of Treasure
COLOR=55
EVENTS=t_bagtreasure
ITEM=i_gold,1300

[TYPEDEF t_bagtreasure]
ON=@Clienttooltip
FOR <R1,4>
RANDMAGICITEM
ENDFOR
EVENTS -t_bagtreasure
UPDATE 1

[TEMPLATE tm_questlargebagtreasure]
CONTAINER=i_bag
NAME=A Large Bag of Treasure
COLOR=04ac
EVENTS=t_largebagtreasure
ITEM=i_gold,{2500 4000}
ITEM=i_special_pigment,1,R30

[TYPEDEF t_largebagtreasure]
ON=@Clienttooltip
IF (!(<SRC.ISEVENT.e_young>))
	FOR <R1,2>
	RANDMAGICITEM
	ENDFOR
	IF (<FLOATVAL 0.5> > <RANDOMDOUBLE>)
		FOR <R1,2>
		RANDMAGICITEMGREAT
		ENDFOR
	ENDIF
	IF (<FLOATVAL 0.00575> > <RANDOMDOUBLE>)
	LOCAL.NEW=<NEW>
	SERV.NEWITEM={minorartis},1,<UID>
	NEW=<LOCAL.NEW>
	ENDIF
ENDIF
EVENTS -t_largebagtreasure
UPDATE 1

[TEMPLATE tm_queststrongbox]
CONTAINER=i_chest_metal_brass
NAME=A Strong Box
EVENTS=t_strongbox
ITEM=i_gold,{8000 12000}
ITEM=i_sea_mapa_tesouro
ITEM=i_osi_treasure_map
ITEM=i_special_pigment,1,R7

[TYPEDEF t_strongbox]
ON=@Clienttooltip
IF (!(<SRC.ISEVENT.e_young>))
	FOR <R2,4>
	RANDMAGICITEMGREAT
	ENDFOR
	IF (<FLOATVAL 0.125> > <RANDOMDOUBLE>)
	LOCAL.NEW=<NEW>
	SERV.NEWITEM={RANDOM_ML_SETS_DROP_LIST},1,<UID>
	NEW=<LOCAL.NEW>
	ENDIF
ENDIF
EVENTS -t_strongbox
UPDATE 1

[TYPEDEF t_craftsatchel]
ON=@Clienttooltip
RANDMAGICITEM
EVENTS -t_craftsatchel
UPDATE 1

[TEMPLATE tm_questtailorcraftsatchel]
CONTAINER=i_backpack
NAME=Craftman's Satchel - Tailoring.
EVENTS=t_craftsatchel
ITEM=i_white_pearl
ITEM=artifacts_recipes_tailor,1,R8

[TEMPLATE tm_questcarpentercraftsatchel]
CONTAINER=i_backpack
NAME=Craftman's Satchel - Carpentry.
EVENTS=t_craftsatchel
ITEM=i_white_pearl
ITEM=i_board,40

[TEMPLATE  tm_questblacksmithcraftsatchel]
CONTAINER=i_backpack
NAME=Craftman's Satchel - Blacksmithing.
EVENTS=t_craftsatchel
ITEM=i_white_pearl
ITEM={i_ingot_bronze 1 i_ingot_copper 1 i_ingot_agapite 1 i_ingot_gold 1 i_ingot_silver 1 i_ingot_dull_copper 1 i_ingot_old_copper 1},{1 2}
ITEM=artifacts_recipes_bs,1,R10

[TEMPLATE  tm_questtinkercraftsatchel]
CONTAINER=i_backpack
NAME=Craftman's Satchel - Tinkering.
EVENTS=t_craftsatchel
ITEM=i_white_pearl,1,R2
ITEM=random_jewel,{1 2}
ITEM=artifacts_recipes_tinker,1,R8

[TEMPLATE  tm_questbowcraftcraftsatchel]
CONTAINER=i_backpack
NAME=Craftman's Satchel - Bowcrafting.
EVENTS=t_craftsatchel
ITEM=i_white_pearl,1,R2
ITEM=i_log,{8 28}
ITEM=artifacts_recipes_bc,1,R10

[TEMPLATE  tm_questminingcraftsatchel]
CONTAINER=i_backpack
NAME=Craftman's Satchel - Mining.
EVENTS=t_craftsatchel
ITEM={i_ore_bronze 1 i_ore_copper 1 i_ore_agapite 1 i_ore_gold 1 i_ore_silver 1 i_ore_dull_copper 1 i_ore_old_copper 1},{1 2}

[TEMPLATE  tm_questalchemycraftsatchel]
CONTAINER=i_backpack
NAME=Craftman's Satchel - Alchemy.
EVENTS=t_craftsatchel
ITEM=random_reagents,{25 35}

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

[FUNCTION STARTQUEST]
IF (<SRC.TAG0.QUESTS> >= 10)
SAY @88 You're already doing too many tasks, come back when you have done some of them.
RETURN 1
ENDIF
IF (<ARGN1> == 92) && (<SRC.ISEVENT.e_young>)
SRC.SYSMESSAGE @946,3,1 You can't accept this quest!
RETURN 1
ENDIF
IF (<TAG0.ESCORTED>) && (!(<DEF0.QUEST_<ARGN1>_CHAIN>))
SAY @,,2 500897
RETURN 1
ENDIF
SRC.sysmessageloc -1,1049019
FOR 10
	IF (<SRC.TAG0.QUEST<dLOCAL._FOR>.ID> == <ARGN1>)
	SDIALOG d_QUEST_OFFER 6
	RETURN 1
	ELIF !(<SRC.TAG0.QUEST<dLOCAL._FOR>.ID>)
	SRC.TAG0.QUESTS ++
	TRY SRC.TAG.QUEST<dLOCAL._FOR>.ID=<ARGN1>
	TRY SRC.TAG.QUEST<dLOCAL._FOR>.QUESTERUID=<UID>
		IF (<DEF0.QUEST_<ARGN1>_ITEMTOGIVE>)
			FOR cx 1 <DEF.QUEST_<ARGN1>_ITEMTOGIVE>
			SRC.createitem <DEF.QUEST_<ARGN1>_ITEMTOGIVE<EVAL <LOCAL.CX>>>
			ENDFOR
		ENDIF
		FOR x 1 <DEF.QUEST_<ARGN1>_OBJECTIVEAMOUNT>
			IF (0<DEF.QUEST_<ARGN1>_OBJECTIVE<EVAL <LOCAL.X>>_TIME>)
			SERV.NEWITEM i_quest_timer
			NEW.MORE1=<ARGN1>
			NEW.TIMER=<DEF.QUEST_<ARGN1>_OBJECTIVE<EVAL <LOCAL.X>>_TIME>
			NEW.CONT=<SRC>
			ENDIF
			IF (0<DEF.QUEST_<ARGN1>_OBJECTIVE<EVAL <LOCAL.X>>_TYPE> == 3)
			SERV.NEWITEM <STREAT <DEF.QUEST_<ARGN1>_OBJECTIVE<EVAL <LOCAL.X>>>>
			NEW.AMOUNT=<STRARG <DEF.QUEST_<ARGN1>_OBJECTIVE<EVAL <LOCAL.X>>>>
			NEW.ATTR |= attr_newbie
			NEW.EVENTS +t_quest_deliver_item
			NEW.TAG.QUESTDELIVERID=<ARGN1>
			NEW.TAG.QUESTGIVER=<UID>
			NEW.BOUNCE
			ELIF (0<DEF.QUEST_<ARGN1>_OBJECTIVE<EVAL <LOCAL.X>>_TYPE> == 2)
			TRY SRC.TAG.QUEST<dLOCAL._FOR>.SLAY<STREAT <DEF.QUEST_<ARGN1>_OBJECTIVE<EVAL <LOCAL.X>>>>=<STRARG <DEF.QUEST_<ARGN1>_OBJECTIVE<EVAL <LOCAL.X>>>>
			ELIF (0<DEF.QUEST_<ARGN1>_OBJECTIVE<EVAL <LOCAL.X>>_TYPE> == 4)
			TAG.ESCORTED=1
			TAG.OLDHOME=<HOME>
			HOME=-1,-1
			HOMEDIST
			LOCAL.OLDNEW=<NEW>
			SERV.NEWITEM i_questsys_escorted,1,<UID>
			NEW.TIMER=1
			NEW.MORE1=<SRC>
			NEW.MORE2=<ARGN1>
			serv.newitem=i_memory
			new.color=02
			new.link=<src>
			new.cont=<uid>
			new.timer=-1
			new.name=<src.name>
			GOTO <SRC.P>
			NEW=<LOCAL.OLDNEW>
			ENDIF
		ENDFOR
	SDIALOG d_QUEST_OFFER 6
	SRC.SDIALOG d_QUESTUPDATE
	RETURN 1
	ENDIF
ENDFOR

[DIALOG d_QUESTUPDATE]
0,0
src.sound snd_questlog_update
PAGE 0
resizepic 0 120 5120 135 80
checkertrans 0 120 135 80
gumppic 0 50 0589
button 9 60 015c8 015c8 1 0 1
xmfhtmlgumpcolor 10 130 130 60 1049080 0 0 32767

[DIALOG d_QUESTUPDATE BUTTON]
ON=1
sDIALOG d_quest_log

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

[CHARDEF c_quester_humanm]
ID=c_man
NAME=quest dummy
TEVENTS=e_questers
CAN=MT_USEHANDS|MT_EQUIP|MT_WALK|MT_RUN
MOVERATE=30

ON=@Create
FLAGS=statf_invul
NPC=BRAIN_HUMAN
DEX=10
INT=10
STR=10

[CHARDEF c_quester_humanf]
ID=c_woman
NAME=quest dummy
TEVENTS=e_questers
CAN=MT_USEHANDS|MT_EQUIP|MT_WALK|MT_RUN|MT_FEMALE
MOVERATE=30

ON=@Create
FLAGS=statf_invul
NPC=BRAIN_HUMAN
DEX=10
INT=10
STR=10

[CHARDEF c_quester_elff]
ID=c_elf_female
NAME=quest dummy
TEVENTS=e_questers
CAN=MT_USEHANDS|MT_EQUIP|MT_WALK|MT_RUN|MT_FEMALE
MOVERATE=30

ON=@Create
FLAGS=statf_invul
NPC=BRAIN_HUMAN
DEX=10
INT=10
STR=10
ITEMNEWBIE=random_elf_female_hair
COLOR=colors_hair

[CHARDEF c_quester_elfm]
ID=c_elf_male
NAME=quest dummy
TEVENTS=e_questers
CAN=MT_USEHANDS|MT_EQUIP|MT_WALK|MT_RUN
MOVERATE=30

ON=@Create
FLAGS=statf_invul
NPC=BRAIN_HUMAN
DEX=10
INT=10
STR=10
ITEMNEWBIE=random_elf_male_hair
COLOR=colors_hair

[TYPEDEF T_QUEST_ITEM_GIVER]
ON=@ClientToolTip
SRC.ADDCLILOC 1072269

ON=@Dclick
IF !(<SRC.ISEVENT.e_tutorial>)
	IF (<CHECKCOMPLETEQUEST>)
	RETURN 1
	ENDIF
DIALOG d_quest_offer
ENDIF

[EVENTS e_questers]
ON=@GetHit
RETURN 1

ON=@Attack
ACTION -1
RETURN 1

ON=@HitTry
RETURN 1

ON=@ClientToolTip
SRC.ADDCLILOC 1072269

ON=@Dclick
IF (<TAG0.ESCORTED>)
	IF (<FINDID.i_questsys_escorted.MORE1> != <SRC>)
	SAY @,,2 500897
	RETURN 1
	ENDIF
ENDIF
IF !(<SRC.ISEVENT.e_tutorial>)
	IF (<CHECKCOMPLETEQUEST>)
	RETURN 1
	ENDIF
DIALOG d_quest_offer
ENDIF

ON=@NPCSEENEWPLAYER
DORAND 13
SAY @,,2 1074209
SAY @,,2 1074193
SAY @,,2 1074189
SAY @,,2 1074195
SAY @,,2 1074196
SAY @,,2 1074197
SAY @,,2 1074198
SAY @,,2 1074199
SAY @,,2 1074204
SAY @,,2 1074205
SAY @,,2 1074206
SAY @,,2 1074209
MESSAGE @,,2 1074212
ENDDO

ON=@Click
MESSAGE @,,2 1078400

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

[DIALOG d_quest_offer]
250,100
src.closealldialogs

PAGE 0
resizepic 30 15 5120 430 410
FOR 29
gumppic <EVAL (<LOCAL._FOR>*15)+15> 15 0280a
IF (<LOCAL._FOR> < 29)
gumppic <EVAL (<LOCAL._FOR>*15)+13> 420 0280a
ENDIF
ENDFOR
gumppic 445 420 0280a

gumppic 415 30 203
gumppic 415 75 203
gumppic 415 105 203
FOR 13
gumppic 415 <EVAL (<LOCAL._FOR>*30)+2> 10460
ENDFOR

gumppic 30 30 202
gumppic 30 75 202
gumppic 30 105 202
gumppic 29 105 0242f
FOR 13
gumppic 45 <EVAL (<LOCAL._FOR>*30)+2> 10460
ENDFOR

gumppic 425 300 028ac
gumppic 425 150 028ab
gumppic 425 0 028aa

gumppic -5 10 028b5
gumppic 25 0 028b4
gumppic 45 130 028ab
gumppic -22 280 028a2

gumppic 368 50 0589
gumppic 377 60 01580

gumppic 85 35 0232d
xmfhtmlgumpcolor 125 45 100 35 1046013 0 0 32767
gumppictiled 125 65 150 1 9101

PAGE 1

IF (<TAG0.QUESTS>)
LOCAL.POSICAODOBOTAO=1
	FOR <TAG0.QUESTS>
		IF ((<ISEMPTY <DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_ISCHAIN>>) && (!(<SRC.HASTHISCHAIN <TAG0.QUEST<dLOCAL._FOR>.ID>>)))
			IF (<EHNUM <DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_NAMELOCALIZED>>)
			xmfhtmlgumpcolor 100 <EVAL (<LOCAL.POSICAODOBOTAO>*25)+105> 240 20 <EVAL <DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_NAMELOCALIZED>> 0 0 32767
			ELSE
			dhtmlgump 100 <EVAL (<LOCAL.POSICAODOBOTAO>*25)+105> 240 20 0 0 <DEF.BFONT_WHITE><DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_NAMELOCALIZED>
			ENDIF
		button 360 <EVAL (<LOCAL.POSICAODOBOTAO>*25)+105> 026b0 026b1 1 0 <LOCAL._FOR>
		LOCAL.POSICAODOBOTAO ++
		ENDIF
	ENDFOR
ENDIF

PAGE 2
IF (<SRC.CTAG0.QUESTVIEWID>)
	IF (<EHNUM <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>>)
	xmfhtmlgumpcolor 155 105 200 20 <EVAL <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>> 0 0 7952
	ELSE
	dhtmlgump 155 105 200 20 0 0 <DEF.BFONT_QUESTODESC><DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>
	ENDIF
	IF (!(<ISEMPTY <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_ISCHAIN>>)) || (0<DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_CHAIN>)
	xmfhtmlgumpcolor 93 135 150 20 1075024 0 0 7952
	ELSE
	xmfhtmlgumpcolor 93 135 150 20 1072202 0 0 7952
	ENDIF
	IF (<EHNUM <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_TEXTLOCALIZED>>)
	xmfhtmlgumpcolor 93 150 317 190 <EVAL <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_TEXTLOCALIZED>> 0 1 26574
	ELSE
	dhtmlgump 93 150 317 190 0 1 <DEF.BFONT_QUESTTEXT><DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_TEXTLOCALIZED>
	ENDIF
	IF (<ISEMPTY <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_ISCHAIN>>)
	button 125 370 02eef 02ef0 0 1 0
	ENDIF
button 280 370 02ee9 02eeb 0 3 0
button 95 400 02ee0 02ee2 1 0 101
button 310 400 02ef2 02ef4 1 0 102
ENDIF

PAGE 3
IF (<SRC.CTAG0.QUESTVIEWID>)
	IF (<EHNUM <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>>)
	xmfhtmlgumpcolor 155 105 200 20 <EVAL <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>> 0 0 7952
	ELSE
	dhtmlgump 155 105 200 20 0 0 <DEF.BFONT_QUESTODESC><DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>
	ENDIF
xmfhtmlgumpcolor 93 135 70 20 1049073 0 0 7952
xmfhtmlgumpcolor 93 150 130 20 1072208 0 0 7952
	IF (!(0<DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_RIDDLE>))
		FOR <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVEAMOUNT>
			IF (<LOCAL.AUMENTAR> > 197)
			LOCAL.AUMENTAR=197
			ELIF (<LOCAL.AUMENTAR> > 182)
			LOCAL.AUMENTAR=182
			ELIF (<LOCAL.AUMENTAR> > 167)
			LOCAL.AUMENTAR=167
			ELIF (<LOCAL.AUMENTAR> > 152)
			LOCAL.AUMENTAR=152
			ELSE
			LOCAL.AUMENTAR=137
			ENDIF
			IF (0<DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_TYPE> == 1)
			xmfhtmlgumpcolor 93 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 70 20 1072205 0 0 26574
			dtext 135 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <STRARG <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>> <SERV.ITEMDEF.<STREAT <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>>.NAME>
				IF (0<DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_TIME>)
				LOCAL.AUMENTAR += 15
				xmfhtmlgumpcolor 100 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 130 20 1062379 0 0 26574
				dtext 220 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <EVAL <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_TIME>>
				ENDIF
			tilepichue 365 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> <SERV.ITEMDEF.<STREAT <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>>.ID> <ITEMTILEPICCOLOR <STREAT <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>>>
			ELIF (0<DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_TYPE> == 2)
			xmfhtmlgumpcolor 93 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 70 20 3005010 0 0 26574
			dtext 125 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <STRARG <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>> <SERV.CHARDEF.<STREAT <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>>.NAME>
				IF (0<DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_TIME>)
				LOCAL.AUMENTAR += 15
				xmfhtmlgumpcolor 100 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 130 20 1062379 0 0 26574
				dtext 220 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <EVAL <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_TIME>>
				ENDIF
				IF !(<ISEMPTY <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_LOCATION>>)
				LOCAL.AUMENTAR += 15
				xmfhtmlgumpcolor 100 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 70 20 3005105 0 0 26574
				dtext 220 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_LOCATION>
				ENDIF
			ELIF (0<DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_TYPE> == 3)
			local.deliverquest=1
			xmfhtmlgumpcolor 93 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 70 20 1072207 0 0 26574
			dtext 140 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <STRARG <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>> <SERV.ITEMDEF.<STREAT <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>>.NAME>
				IF (0<DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_TIME>)
				LOCAL.AUMENTAR += 15
				xmfhtmlgumpcolor 100 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 130 20 1062379 0 0 26574
				dtext 220 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <EVAL <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_TIME>>
				ENDIF
			LOCAL.AUMENTAR += 15
			xmfhtmlgumpcolor 100 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 70 20 1072379 0 0 26574
			dtext 220 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_RECEIVER>
			ELIF (0<DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_TYPE> == 4)
			xmfhtmlgumpcolor 93 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 70 20 1072206 0 0 26574
			dtext 160 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>>
				IF (0<DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_TIME>)
				LOCAL.AUMENTAR += 15
				xmfhtmlgumpcolor 100 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 130 20 1062379 0 0 26574
				dtext 220 <EVAL (<LOCAL._FOR>*28)+<LOCAL.AUMENTAR>> 1153 <EVAL <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_OBJECTIVE<dLOCAL._FOR>_TIME>>
				ENDIF
			LOCAL.AUMENTAR += 15
			ENDIF
		LOCAL.AUMENTAR += 15
		ENDFOR
	ELSE
	dtext 220 172 1153 RIDDLE
	ENDIF
button 125 370 02eef 02ef0 0 2 0
button 280 370 02ee9 02eeb 0 4 0
button 95 400 02ee0 02ee2 1 0 101
button 310 400 02ef2 02ef4 1 0 102
ENDIF

PAGE 4
IF (<SRC.CTAG0.QUESTVIEWID>)
	IF (<EHNUM <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>>)
	xmfhtmlgumpcolor 155 105 200 20 <EVAL <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>> 0 0 7952
	ELSE
	dhtmlgump 155 105 200 20 0 0 <DEF.BFONT_QUESTODESC><DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>
	ENDIF
xmfhtmlgumpcolor 93 140 70 20 1072842 0 0 7952
	FOR <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_PRIZES>
	gumppic 100 <EVAL (<LOCAL._FOR>*25)+140> 1210
	dhtmlgump 130 <EVAL (<LOCAL._FOR>*24)+140> 280 20 0 0 <DEF.BFONT_QUESTPRIZETEXTCOLOR><STREAT <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_PRIZEID<dLOCAL._FOR>>>
	ENDFOR
button 125 370 02eef 02ef0 0 3 0
button 95 400 02ee0 02ee2 1 0 101
button 310 400 02ef2 02ef4 1 0 102
ENDIF

PAGE 5
IF (<SRC.CTAG0.QUESTVIEWID>)
gumppic 135 107 1210
	IF !(0<ARGS>)
		IF (<EHNUM <DEF.QUEST_<EVAL <SRC.TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>>)
		xmfhtmlgumpcolor 155 105 200 20 <EVAL <DEF.QUEST_<EVAL <SRC.TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>> 0 0 7952
		ELSE
		dhtmlgump 155 105 200 20 0 0 <DEF.BFONT_QUESTODESC><DEF.QUEST_<EVAL <SRC.TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>
		ENDIF
		IF (<EHNUM <DEF.QUEST_<EVAL <SRC.TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_TEXTREFUSELOCALIZED>>)
		xmfhtmlgumpcolor 93 155 317 190 <EVAL <DEF.QUEST_<EVAL <SRC.TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_TEXTREFUSELOCALIZED>> 0 1 26574
		ELSE
		dhtmlgump 93 155 317 190 0 0 <DEF.BFONT_QUESTTEXT><DEF.QUEST_<EVAL <SRC.TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_TEXTREFUSELOCALIZED>
		ENDIF
	ELSE
		IF (<EHNUM <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>>)
		xmfhtmlgumpcolor 155 105 200 20 <EVAL <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>> 0 0 7952
		ELSE
		dhtmlgump 155 105 200 20 0 0 <DEF.BFONT_QUESTODESC><DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>
		ENDIF
		IF (<EHNUM <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_TEXTREFUSELOCALIZED>>)
		xmfhtmlgumpcolor 93 155 317 190 <EVAL <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_TEXTREFUSELOCALIZED>> 0 1 26574
		ELSE
		dhtmlgump 93 155 317 190 0 0 <DEF.BFONT_QUESTTEXT><DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_TEXTREFUSELOCALIZED>
		ENDIF
	ENDIF
button 310 400 02ee6 02ee8 1 0 0
ENDIF

PAGE 6
IF (<SRC.CTAG0.QUESTVIEWID>)
gumppic 135 107 1210
	IF (<EHNUM <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>>)
	xmfhtmlgumpcolor 155 105 200 20 <EVAL <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>> 0 0 7952
	ELSE
	dhtmlgump 155 105 200 20 0 0 <DEF.BFONT_QUESTODESC><DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>
	ENDIF
	IF (<EHNUM <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_TEXTUNCOMPLETELOCALIZED>>)
	xmfhtmlgumpcolor 93 155 317 190 <EVAL <DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_TEXTUNCOMPLETELOCALIZED>> 0 1 26574
	ELSE
	dhtmlgump 93 155 317 190 0 1 <DEF.BFONT_QUESTTEXT><DEF.QUEST_<EVAL <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_TEXTUNCOMPLETELOCALIZED>
	ENDIF
button 310 400 02ee6 02ee8 1 0 0
ENDIF

PAGE 7
IF (<SRC.CTAG0.QUESTVIEWID>)
gumppic 135 107 1210
	IF (<EHNUM <DEF.QUEST_<EVAL <SRC.TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>>)
	xmfhtmlgumpcolor 155 105 200 20 <EVAL <DEF.QUEST_<EVAL <SRC.TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>> 0 0 7952
	ELSE
	dhtmlgump 155 105 200 20 0 0 <DEF.BFONT_QUESTODESC><DEF.QUEST_<EVAL <SRC.TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_NAMELOCALIZED>
	ENDIF
	IF (<EHNUM <DEF.QUEST_<EVAL <SRC.TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_TEXTCOMPLETELOCALIZED>>)
	xmfhtmlgumpcolor 93 155 317 190 <EVAL <DEF.QUEST_<EVAL <SRC.TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_TEXTCOMPLETELOCALIZED>> 0 1 26574
	ELSE
	dhtmlgump 93 155 317 190 0 0 <DEF.BFONT_QUESTTEXT><DEF.QUEST_<EVAL <SRC.TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>>_TEXTCOMPLETELOCALIZED>
	ENDIF
button 310 400 02ee0 02ee2 1 0 201
ENDIF

[DIALOG d_quest_offer BUTTON]
ON=1 20
SRC.CTAG.QUESTVIEWID=<ARGN1>
FOR <SRC.TAG0.QUESTS>
	IF (<SRC.TAG0.QUEST<dLOCAL._FOR>.ID> == <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>)
		IF (<SRC.TAG0.QUEST<dLOCAL._FOR>.QUESTERUID> == <UID>)
		SDIALOG d_QUEST_OFFER 6
		RETURN 1
		ELSE
		SAY @88,3,1 It looks like you're already doing this task for someone else.
		RETURN 1
		ENDIF
	ENDIF
ENDFOR
SDIALOG d_quest_offer 2

ON=101
STARTQUEST <TAG0.QUEST<dSRC.CTAG0.QUESTVIEWID>.ID>

ON=102
IF (<SRC.ISONLINE>)
SDIALOG d_quest_offer 5 1
ENDIF

ON=201
LOCAL.QUESTID=<SRC.CTAG0.QUESTVIEWID>
IF (<SRC.TAG0.QUEST<dLOCAL.QUESTID>.FAILED>)
SAY @33,3,1 You have failed your quest objectives <SRC.NAME>!
RETURN 1
ENDIF
FOR j 1 <DEF.QUEST_<EVAL <SRC.TAG0.QUEST<dLOCAL.QUESTID>.ID>>_OBJECTIVEAMOUNT>
	IF (<DEF.QUEST_<EVAL <SRC.TAG0.QUEST<dLOCAL.QUESTID>.ID>>_OBJECTIVE<dLOCAL.J>_TYPE> == 1)
	LOCAL.NOTOK ++
		IF (<SRC.RESTEST <DEF.QUEST_<EVAL <SRC.TAG0.QUEST<dLOCAL.QUESTID>.ID>>_OBJECTIVE<dLOCAL.J>>>)
		LOCAL.OK ++
		VAR.OKCONSUME .= <DEF.QUEST_<EVAL <SRC.TAG0.QUEST<dLOCAL.QUESTID>.ID>>_OBJECTIVE<dLOCAL.J>>,
		ENDIF
	ENDIF
ENDFOR
IF (<LOCAL.OK> == <LOCAL.NOTOK>)
SRC.CONSUME <VAR.OKCONSUME>
VAR.OKCONSUME=
ELSE
SAY @33,3,1 You don't seem to actually have all those items <SRC.NAME>!
VAR.OKCONSUME=
RETURN 1
ENDIF
IF (<DEF.QUEST_<EVAL <SRC.TAG0.QUEST<EVAL <LOCAL.QUESTID>>.ID>>_PRIZES>)
	FOR z 1 <DEF.QUEST_<EVAL <SRC.TAG0.QUEST<EVAL <LOCAL.QUESTID>>.ID>>_PRIZES>
		IF (<DEF.QUEST_<EVAL <SRC.TAG0.QUEST<EVAL <LOCAL.QUESTID>>.ID>>_PRIZETYPE<EVAL <LOCAL.Z>>>==1)
		SERV.NEWITEM <STRARG <DEF.QUEST_<EVAL <SRC.TAG0.QUEST<EVAL <LOCAL.QUESTID>>.ID>>_PRIZEID<EVAL <LOCAL.Z>>>>
		NEW.BOUNCE
		ELIF (<DEF.QUEST_<EVAL <SRC.TAG0.QUEST<EVAL <LOCAL.QUESTID>>.ID>>_PRIZETYPE<EVAL <LOCAL.Z>>>==3)
		LOCAL.QUESTOLDOBJ=<OBJ>
		OBJ=<UID>
		TRY SRC.<STRARG <DEF.QUEST_<EVAL <SRC.TAG0.QUEST<EVAL <LOCAL.QUESTID>>.ID>>_PRIZEID<EVAL <LOCAL.Z>>>>
		OBJ=<LOCAL.QUESTOLDOBJ>
		ENDIF
	ENDFOR
ENDIF
SRC.QUITQUEST <LOCAL.QUESTID> <UID>
SRC.sysmessageloc -1,1046258

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

[FUNCTION QUITQUEST]
REF2=<UID> //PLAYER
REF3=<TAG0.QUEST<ARGN1>.QUESTERUID> //QUESTER
IF (<ISONLINE>)
CTAG.QUESTVIEWID=<ARGN1>
ENDIF
TRY TAG.QUEST<ARGN1>.FAILED
FOR j 1 <DEF.QUEST_<EVAL <TAG0.QUEST<ARGN1>.ID>>_OBJECTIVEAMOUNT>
	IF (0<DEF.QUEST_<EVAL <TAG0.QUEST<ARGN1>.ID>>_OBJECTIVE<dLOCAL.J>_TIME>)
		FORCONTID i_quest_timer
			IF (<MORE1> == <REF2.TAG0.QUEST<ARGN1>.ID>)
			REMOVE
			ENDIF
		ENDFOR
	ENDIF
	IF (<DEF.QUEST_<EVAL <TAG0.QUEST<ARGN1>.ID>>_OBJECTIVE<dLOCAL.J>_TYPE> == 2)
	TRY TAG.QUEST<ARGN1>.SLAY<STREAT <DEF.QUEST_<EVAL <TAG0.QUEST<ARGN1>.ID>>_OBJECTIVE<dLOCAL.J>>>
	ELIF (<DEF.QUEST_<EVAL <TAG0.QUEST<ARGN1>.ID>>_OBJECTIVE<dLOCAL.J>_TYPE> == 3)
	CONSUME <DEF.QUEST_<EVAL <TAG0.QUEST<ARGN1>.ID>>_OBJECTIVE<dLOCAL.J>>
	ELIF (<DEF.QUEST_<EVAL <TAG0.QUEST<ARGN1>.ID>>_OBJECTIVE<dLOCAL.J>_TYPE> == 4)
	REF3.FINDID.i_questsys_escorted.REMOVE
	REF3.TIMERF 4,SETNEWESCORTLOCATION
	REF3.TIMERF 5,TAG.ESCORTED
	REF3.HOME=<REF3.TAG0.OLDHOME>
	REF3.TAG.OLDHOME
	REF3.REMOVEESCORTOWNER
	REF3.GOTO <REF3.P>
		IF (!(STRMATCH(<HOME>,-1)))
		REF3.TIMERF 3,GO <REF3.HOME>
		REF3.TIMERF 3,HOMEDIST=3
		ENDIF
		IF (<ARGN2>)
			IF (<TAG0.VIRTUDES.COMPASSION>)
			TAG0.VIRTUDES.COMPASSION += 5000
			EFFECT 3,i_fx_bless_effect,1,20
			SYSMESSAGELOC -1,1053002
				IF (<TAG0.VIRTUDES.COMPASSION> >= 200000)
					IF !(<TAG0.VIRTUDES>&<DEF.COMPASSION_L1>)
					TAG0.VIRTUDES |= <DEF.COMPASSION_L1>
					TAG.VIRTUDES.COMPASSION=1
					ELIF !(<TAG0.VIRTUDES>&<DEF.COMPASSION_L2>)
					TAG0.VIRTUDES |= <DEF.COMPASSION_L2>
					TAG.VIRTUDES.COMPASSION=1
					ELIF !(<TAG0.VIRTUDES>&<DEF.COMPASSION_L3>)
					TAG0.VIRTUDES |= <DEF.COMPASSION_L3>
					TAG.VIRTUDES.COMPASSION
					ENDIF
				SYSMESSAGELOC -1,1053005
				ENDIF
			ENDIF
		ELSE
		REF3.SAY @,,2 500902
		ENDIF
	ENDIF
ENDFOR
IF (0<ARGN2>)
	IF (0<DEF.QUEST_<EVAL <TAG0.QUEST<ARGN1>.ID>>_CHAIN>)
		IF (<UID.<ARGN2>.TAG0.QUESTS>)
			FOR t 1 <UID.<ARGN2>.TAG0.QUESTS>
				IF (<UID.<ARGN2>.TAG0.QUEST<EVAL <LOCAL.t>>.ID> == <DEF.QUEST_<EVAL <TAG0.QUEST<ARGN1>.ID>>_CHAIN>)
				CTAG.QUESTVIEWID=<LOCAL.t>
				TRY UID.<ARGN2>.SDIALOG d_QUEST_OFFER 2
				LOCAL.STARTEDACHAIN=1
				ENDIF
			ENDFOR
		ENDIF
		IF !(<LOCAL.STARTEDACHAIN>)
			FOR u 1 <REF3.TAG0.QUESTS>
				IF (<DEF.QUEST_<EVAL <TAG0.QUEST<ARGN1>.ID>>_CHAIN> == <TAG0.QUEST<EVAL <LOCAL.u>>.ID>)
				CTAG.QUESTVIEWID=<LOCAL.U>
				ENDIF
			ENDFOR
		REF3.SDIALOG d_QUEST_OFFER 2
		ENDIF
	ENDIF
ENDIF
TRY TAG.QUEST<ARGN1>.ID
TRY TAG.QUEST<ARGN1>.QUESTERUID
TAG0.QUESTS --
IF !(<TAG0.QUESTS>)
TAG.QUESTS
RETURN 1
ENDIF
IF (<ARGN1>!=10)
	FOR <HVAL <ARGN1>+1> 11
		FOR z 1 <DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_OBJECTIVEAMOUNT>
			IF (0<DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_OBJECTIVE<EVAL <LOCAL.Z>>_TYPE> == 2)
			TRY TAG.QUEST<EVAL <LOCAL._FOR>-1>.SLAY<STREAT <DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_OBJECTIVE<EVAL <LOCAL.Z>>>>=<TAG.QUEST<dLOCAL._FOR>.SLAY<STREAT <DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_OBJECTIVE<EVAL <LOCAL.Z>>>>>
			TRY TAG.QUEST<dLOCAL._FOR>.SLAY<STREAT <DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_OBJECTIVE<EVAL <LOCAL.Z>>>>
			ENDIF
		ENDFOR
	TRY TAG.QUEST<EVAL <LOCAL._FOR>-1>.ID=<TAG.QUEST<dLOCAL._FOR>.ID>
	TRY TAG.QUEST<EVAL <LOCAL._FOR>-1>.QUESTERUID=<TAG.QUEST<dLOCAL._FOR>.QUESTERUID>
	ENDFOR
ENDIF

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

[FUNCTION QUESTTIMEREMAINING]
FORCONTID i_quest_timer
	IF (<MORE1> == <ARGN1>)
	RETURN <EVAL <TIMER>>
	ENDIF
ENDFOR

[FUNCTION REMOVEALLQUESTIMERS]
FORCONTID i_quest_timer
	IF (<MORE1> == <ARGN1>)
	REMOVE
	ENDIF
ENDFOR

[ITEMDEF i_quest_timer]
ID=i_memory
NAME=quest timer
TYPE=T_EQ_SCRIPT

ON=@Timer
FOR <CONT.TAG0.QUESTS>
	IF (<CONT.TAG0.QUEST<dLOCAL._FOR>.ID> == <MORE1>)
	TRY CONT.TAG.QUEST<dLOCAL._FOR>.FAILED=1
	CONT.sysmessageloc -1,1074777
	CONT.REMOVEALLQUESTIMERS <MORE1>
	RETURN 1
	ENDIF
ENDFOR
REMOVE
RETURN 1

[TYPEDEF t_quest_deliver_item]
ON=@Dropon_Ground
FOR <SRC.TAG0.QUESTS>
	IF !(<LOCAL.QUESTDELIVERID>)
		IF (<SRC.TAG0.QUEST<dLOCAL._FOR>.ID> == <TAG0.QUESTDELIVERID>)
		LOCAL.QUESTDELIVERID=<LOCAL._FOR>
		ENDIF
	ENDIF
ENDFOR
TRY SRC.TAG.QUEST<EVAL <LOCAL.QUESTDELIVERID>>.FAILED=1
SRC.sysmessageloc -1,1074777
REMOVE

ON=@Dropon_Item
IF (<ARGO.UID>!=<SRC.FINDLAYER.21>)
SRC.SYSMESSAGE @946,3,1 The item must stay on your main pack.
RETURN 1
ENDIF

ON=@EquipTest
SRC.SYSMESSAGE @946,3,1 The item must stay on your main pack.
RETURN 1

ON=@Dropon_Char
FOR <SRC.TAG0.QUESTS>
	IF !(<LOCAL.QUESTDELIVERID>)
		IF (<SRC.TAG0.QUEST<dLOCAL._FOR>.ID> == <TAG0.QUESTDELIVERID>)
		LOCAL.QUESTDELIVERID=<LOCAL._FOR>
		ENDIF
	ENDIF
ENDFOR
FOR <DEF.QUEST_<EVAL <SRC.TAG0.QUEST<EVAL <LOCAL.QUESTDELIVERID>>.ID>>_OBJECTIVEAMOUNT>
	IF !(STRCMPI(<ARGO.NAME>,<DEF.QUEST_<EVAL <SRC.TAG0.QUEST<EVAL <LOCAL.QUESTDELIVERID>>.ID>>_OBJECTIVE<dLOCAL._FOR>_RECEIVER>))
		IF (0<DEF.QUEST_<EVAL <TAG0.QUESTDELIVERID>>_CHAIN>)
			IF (<ARGO.TAG0.QUESTS>)
				FOR h 1 <ARGO.TAG0.QUESTS>
					IF (<ARGO.TAG0.QUEST<EVAL <LOCAL.h>>.ID> == <DEF.QUEST_<EVAL <TAG0.QUESTDELIVERID>>_CHAIN>)
					SRC.CTAG.QUESTVIEWID=<LOCAL.QUESTDELIVERID>
					ARGO.DIALOG d_QUEST_OFFER 7
					RETURN 1
					ENDIF
				ENDFOR
			ELSE
			SRC.CTAG.QUESTVIEWID=<LOCAL.QUESTDELIVERID>
			TRY UID.<TAG0.QUESTGIVER>.DIALOG d_QUEST_OFFER 7
			RETURN 1
			ENDIF
		ENDIF
	SRC.CTAG.QUESTVIEWID=<LOCAL.QUESTDELIVERID>
	SDIALOG d_QUEST_OFFER 7
	RETURN 1
	ENDIF
ENDFOR
TRY SRC.TAG.QUEST<EVAL <LOCAL.QUESTDELIVERID>>.FAILED=1
SRC.sysmessageloc -1,1074777
REMOVE
RETURN 1

ON=@ClientToolTip
SRC.ADDCLILOC 1072351

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

[FUNCTION CHECKCOMPLETEQUEST]
IF (<SRC.TAG0.QUESTS>)
	FOR <TAG0.QUESTS>
		FOR x 1 <SRC.TAG0.QUESTS>
			IF !(<SRC.TAG0.QUEST<EVAL <LOCAL.x>>.FAILED>)
				IF (<SRC.TAG0.QUEST<EVAL <LOCAL.x>>.ID> == <TAG0.QUEST<dLOCAL._FOR>.ID>)
					IF (<SRC.TAG0.QUEST<EVAL <LOCAL.x>>.QUESTERUID> == <UID>)
					LOCAL.COMPLETETASKS=0
						FOR y 1 <DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_OBJECTIVEAMOUNT>
							IF (<DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_OBJECTIVE<EVAL <LOCAL.Y>>_TYPE> == 1)
								IF (<SRC.RESTEST <DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_OBJECTIVE<dLOCAL.Y>>>)
								LOCAL.COMPLETETASKS ++
								ENDIF
							ELIF (<DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_OBJECTIVE<EVAL <LOCAL.Y>>_TYPE> == 2)
								IF (<SRC.TAG0.QUEST<EVAL <LOCAL.X>>.SLAY<STREAT <DEF.QUEST_<EVAL <SRC.TAG0.QUEST<EVAL <LOCAL.X>>.ID>>_OBJECTIVE<EVAL <LOCAL.Y>>>>> == 0)
								LOCAL.COMPLETETASKS ++
								ENDIF
							ELIF (<DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_OBJECTIVE<EVAL <LOCAL.Y>>_TYPE> == 4)
								IF (!(STRCMPI(<REGION.NAME>,<DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_OBJECTIVE<EVAL <LOCAL.Y>>>)))
								LOCAL.COMPLETETASKS ++
								ENDIF
							ENDIF
						ENDFOR
						IF (<LOCAL.COMPLETETASKS> == <DEF.QUEST_<dTAG0.QUEST<dLOCAL._FOR>.ID>_OBJECTIVEAMOUNT>)
						SRC.CTAG.QUESTVIEWID <LOCAL.X>
						SDIALOG d_QUEST_OFFER 7
						RETURN 1
						ENDIF
					ENDIF
				ENDIF
			ENDIF
		ENDFOR
	ENDFOR
ENDIF
RETURN 0

[FUNCTION HASTHISCHAIN]
FOR <TAG0.QUESTS>
	IF (!(<ISEMPTY <DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_ISCHAIN>>))
		IF (STRMATCH(*<ARGN1>;*,<DEF.QUEST_<EVAL <TAG0.QUEST<dLOCAL._FOR>.ID>>_ISCHAIN>))
		RETURN 1
		ENDIF
	ENDIF
ENDFOR
RETURN 0

[FUNCTION ITEMTILEPICCOLOR]
LOCAL.OLDNEW=<NEW>
SERV.NEWITEM <ARGS>
LOCAL.ITEMCOLOR=<NEW.COLOR>
NEW.REMOVE
NEW=<LOCAL.OLDNEW>
RETURN <EVAL <LOCAL.ITEMCOLOR>>

[ITEMDEF i_questsys_escorted]
ID=i_memory
NAME=questsys escorting
TYPE=T_EQ_SCRIPT
WEIGHT=0

ON=@Create
attr=attr_invis|attr_newbie|attr_move_never

ON=@Timer
REF1=<MORE1>
IF ((!(<REF1.ISONLINE>)) || (<REF1.TAG0.EVENT.ID>) || (<REF1.FLAGS>&STATF_DEAD))
	WHILE (<LOCAL.QUEST> != <MORE2>)
	LOCAL.QUEST=<REF1.TAG0.QUEST<dLOCAL._WHILE>.ID>
	LOCAL.QUESTRIGHT=<LOCAL._WHILE>
	ENDWHILE
REF1.QUITQUEST <LOCAL.QUESTRIGHT>
RETURN 1
ELIF (<CONT.DISTANCE <REF1>> >= 80)
CONT.REMOVEFROMVIEW
CONT.MOVETO <REF1.P>
CONT.UPDATE
ENDIF
TIMER=1
RETURN 1

[FUNCTION REMOVEESCORTOWNER]
FORCHARMEMORYTYPE MEMORY_IPET
REMOVE
ENDFOR
FORCHARMEMORYTYPE MEMORY_FOLLOW
REMOVE
ENDFOR

[FUNCTION HASQUEST]
FOR QUEST 1 10
	IF (<TAG0.QUEST<dLOCAL.QUEST>.ID> == <ARGN1>)
	RETURN 1
	ENDIF
ENDFOR
RETURN 0

[FUNCTION SETNEWESCORTLOCATION]
IF ((<BASEID> == c_escort_male) || (<BASEID> == c_escort_female))
	DORAND 13
	TAG.QUEST1.ID=135
	TAG.QUEST1.ID=136
	TAG.QUEST1.ID=137
	TAG.QUEST1.ID=138
	TAG.QUEST1.ID=139
	TAG.QUEST1.ID=140
	TAG.QUEST1.ID=141
	TAG.QUEST1.ID=142
	TAG.QUEST1.ID=143
	TAG.QUEST1.ID=144
	TAG.QUEST1.ID=145
	TAG.QUEST1.ID=146
	TAG.QUEST1.ID=147
	ENDDO
	WHILE (!(STRCMPI(<REGION.NAME>,<DEF.QUEST_<dTAG0.QUEST1.ID>_OBJECTIVE1>)))
		DORAND 13
		TAG.QUEST1.ID=135
		TAG.QUEST1.ID=136
		TAG.QUEST1.ID=137
		TAG.QUEST1.ID=138
		TAG.QUEST1.ID=139
		TAG.QUEST1.ID=140
		TAG.QUEST1.ID=141
		TAG.QUEST1.ID=142
		TAG.QUEST1.ID=143
		TAG.QUEST1.ID=144
		TAG.QUEST1.ID=145
		TAG.QUEST1.ID=146
		TAG.QUEST1.ID=147
		ENDDO
	ENDWHILE
ENDIF

[EOF]