[ITEMDEF i_repair_contract]
ID=i_deed
NAME=Repair Contract
TYPE=T_NORMAL
VALUE=100

ON=@Create
COLOR=01ba

ON=@Dclick
IF (<MORE1> == 7)
	IF (!(<SRC.ISNEARSHOP blacksmith>))
	SRC.SYSMESSAGELOC -1,1047013
	RETURN 1
	ENDIF
ELIF (<MORE1> == 34)
	IF (!(<SRC.ISNEARSHOP tailor>))
	SRC.SYSMESSAGELOC -1,1061132
	RETURN 1
	ENDIF
ELIF (<MORE1> == 8)
	IF (!(<SRC.ISNEARSHOP bowyer>))
	SRC.SYSMESSAGELOC -1,1061134
	RETURN 1
	ENDIF
ELIF (<MORE1> == 11)
	IF (!(<SRC.ISNEARSHOP carpenter>))
	SRC.SYSMESSAGELOC -1,1061135
	RETURN 1
	ENDIF
ENDIF
IF (<CONT.UID> == <SRC.FINDLAYER.layer_pack.UID>)
TARGET
SRC.SYSMESSAGELOC -1,500436
ELSE
SRC.SYSMESSAGELOC -1,1047012
ENDIF
RETURN 1

ON=@Targon_Item
IF (<MORE1> == 7)
	IF (!(<SRC.ISNEARSHOP blacksmith>))
	SRC.SYSMESSAGELOC -1,1047013
	RETURN 1
	ENDIF
ELIF (<MORE1> == 34)
	IF (!(<SRC.ISNEARSHOP tailor>))
	SRC.SYSMESSAGELOC -1,1061132
	RETURN 1
	ENDIF
ELIF (<MORE1> == 8)
	IF (!(<SRC.ISNEARSHOP bowyer>))
	SRC.SYSMESSAGELOC -1,1061134
	RETURN 1
	ENDIF
ELIF (<MORE1> == 11)
	IF (!(<SRC.ISNEARSHOP carpenter>))
	SRC.SYSMESSAGELOC -1,1061135
	RETURN 1
	ENDIF
ENDIF
LOCAL.SKILL=<DEF.<SERV.ITEMDEF.<ARGO.ID>.SKILLMAKE.1.KEY>>
LOCAL.SKILL &= ~0c0000000
IF (!(<ARGO.MAXHITS>)) || (<ARGO.HITS> == <ARGO.MAXHITS>) || (<ARGO.TOPOBJ.UID> != <SRC.UID>)
SRC.SYSMESSAGELOC -1,1047014
ELIF (<LOCAL.SKILL> != <MORE1>)
SRC.SYSMESSAGELOC -1,1061136
ELSE
	IF (<R<dMORE2>> < <R<EVAL (<ARGO.MAXHITS>*10)/<ARGO.HITS>)>>)
	ARGO.MAXHITS --
		IF (<ARGO.MAXHITS> <= 0)
		ARGO.REMOVE
		SRC.SYSMESSAGELOC -1,500424
		ELSE
		ARGO.HITS=<ARGO.MAXHITS>
		SRC.SYSMESSAGELOC -1,1062782
		ENDIF
	ELSE
	ARGO.HITS=<ARGO.MAXHITS>
	SRC.SYSMESSAGELOC -1,500425
	ENDIF
ARGO.RESENDTOOLTIP 1
CONSUME 1
ENDIF
RETURN 1

[FUNCTION f_create_repair_contract]
IF (<BASEID> == i_scroll_blank)
LOCAL.OLDNEW=<NEW>
SERV.NEWITEM i_repair_contract
NEW.MORE1=<ARGN1>
LOCAL.SKILLVALUE=<SRC.<ARGN1>>
	IF (<LOCAL.SKILLVALUE> >= 120.0)
	NEW.NAME=A repair service contract from a Legendary <SERV.SKILL.<ARGN1>.TITLE>
	NEW.MORE2=120
	ELIF (<LOCAL.SKILLVALUE> >= 110.0)
	NEW.MORE2=110
	NEW.NAME=A repair service contract from an Elder <SERV.SKILL.<ARGN1>.TITLE>
	ELIF (<LOCAL.SKILLVALUE> >= 100.0)
	NEW.MORE2=100
	NEW.NAME=A repair service contract from a Grandmaster <SERV.SKILL.<ARGN1>.TITLE>
	ELIF (<LOCAL.SKILLVALUE> >= 90.0)
	NEW.MORE2=90
	NEW.NAME=A repair service contract from a Master <SERV.SKILL.<ARGN1>.TITLE>
	ELIF (<LOCAL.SKILLVALUE> >= 80.0)
	NEW.MORE2=80
	NEW.NAME=A repair service contract from an Adept <SERV.SKILL.<ARGN1>.TITLE>
	ELIF (<LOCAL.SKILLVALUE> >= 70.0)
	NEW.MORE2=70
	NEW.NAME=A repair service contract from an Expert <SERV.SKILL.<ARGN1>.TITLE>
	ELIF (<LOCAL.SKILLVALUE> >= 60.0)
	NEW.MORE2=60
	NEW.NAME=A repair service contract from a Journeyman <SERV.SKILL.<ARGN1>.TITLE>
	ELIF (<LOCAL.SKILLVALUE> >= 50.0)
	NEW.MORE2=60
	NEW.NAME=A repair service contract from an Apprentice <SERV.SKILL.<ARGN1>.TITLE>
	ENDIF
SRC.BOUNCE <NEW>
CONSUME 1
ENDIF

[FUNCTION ISNEARSHOP]
FORCHARS 7
IF (STRMATCH(*<ARGS>*,<BASEID>)) && (<CANSEELOS>)
RETURN 1
ENDIF
ENDFOR
RETURN 0

[EOF]