[FUNCTION HASTOOMANYSTABLED]
REF2=<ARGN1>
LOCAL.STABLED=<REF2.TAG0.STABLEDPETS>
IF (<EVAL <REF2.TAMING>+<REF2.ANIMALLORE>+<REF2.VETERINARY>> < 160.0)
LOCAL.MAXPETSALLOWED=2
ELIF (<EVAL <REF2.TAMING>+<REF2.ANIMALLORE>+<REF2.VETERINARY>> < 199.9)
LOCAL.MAXPETSALLOWED=3
ELIF (<EVAL <REF2.TAMING>+<REF2.ANIMALLORE>+<REF2.VETERINARY>> < 239.9)
LOCAL.MAXPETSALLOWED=4
ELSE
LOCAL.MAXPETSALLOWED=5
ENDIF
IF (<REF2.ANIMALLORE> >= 100.0)
LOCAL.MAXPETSALLOWED += 1
ENDIF
IF (<REF2.ANIMALLORE> >= 110.0)
LOCAL.MAXPETSALLOWED += 1
ENDIF
IF (<REF2.ANIMALLORE> >= 120.0)
LOCAL.MAXPETSALLOWED += 1
ENDIF
IF (<REF2.TAMING> >= 100.0)
LOCAL.MAXPETSALLOWED += 1
ENDIF
IF (<REF2.TAMING> >= 110.0)
LOCAL.MAXPETSALLOWED += 1
ENDIF
IF (<REF2.TAMING> >= 120.0)
LOCAL.MAXPETSALLOWED += 1
ENDIF
IF (<LOCAL.STABLED> >= <LOCAL.MAXPETSALLOWED>)
RETURN 1
ENDIF
RETURN 0

[FUNCTION STABLEISFULL]
FORCONTTYPE T_SHRINK_FIX
LOCAL.STABLED += 1
ENDFOR
IF (<LOCAL.STABLED> >= 400)
RETURN 1
ENDIF
RETURN 0

[FUNCTION F_NEW_PETSTABLE]
REF1=<ARGN1> //animal trainer
IF (<REF1.STABLEISFULL>)
REF1.SAY @,,2 502670
ELIF (<REF1.HASTOOMANYSTABLED <UID>>)
REF1.SAY @,,2 1042565
ELIF ((<ARGO.ISPLAYER>) || (<ARGO.ISITEM>))
SYSMESSAGELOC -1,1048053
ELIF (<ARGO.FLAGS>&STATF_CONJURED)
REF1.SAY @,,2 502673
ELIF (!(<ARGO.FLAGS>&STATF_PET))
REF1.SAY @,,2 502674
ELIF (!(<ARGO.ISMYPET>))
REF1.SAY @,,2 502676
ELIF (<ARGO.DISTANCE <REF1.UID>> > 10)
SYSMESSAGELOC -1,502803
ELIF (<ARGO.ACTION> != 064) && (<ARGO.ACTION> != 065)
REF1.SAY @,,2 1042564
ELSE
ARGO.SHRINK2
REF2=<VAR0.SHRINK> //shrinked icon
REF2.TAG.STABLE.OWNER=<UID>
REF2.TAG.STABLE.TIME=<EVAL ((((<SERV.TIME>/10)/60)/60)/24)>
REF2.TIMERF <EVAL 60*60*24*30>,REMOVE
REF1.BOUNCE <REF2>
REF1.SAY @,,2 1049677
SYSMESSAGELOC -1,1049677
TAG0.STABLEDPETS += 1
ENDIF

[FUNCTION F_NEW_PETRETRIEVE]
FORCONTTYPE T_SHRINK_FIX
	IF (<SRC> == <TAG0.STABLE.OWNER>)
	LOCAL.HASMYPETSTABLED=1
		IF ((((<SERV.CHARDEF.<TAG.ID>.TAG0.FOLLOWERCONSUME>) && (<EVAL <SRC.CURFOLLOWER>+<SERV.CHARDEF.<TAG.ID>.TAG0.FOLLOWERCONSUME>> > 5))) || ((!(<SERV.CHARDEF.<TAG.ID>.TAG0.FOLLOWERCONSUME>)) && (<EVAL <SRC.CURFOLLOWER>+1> > 5)))
		src.sysmessageloc -1,1049612,"<NAME>"
		ELSE
		SRC.BOUNCE <UID>
		LOCAL.TIME=<EVAL ((((<SERV.TIME>/10)/60)/60)/24)-<TAG0.STABLE.TIME>>
			IF (<LOCAL.TIME> > 3)
			LOCAL.TIME=3
			ELIF (!(<LOCAL.TIME>))
			LOCAL.TIME=1
			ENDIF
			IF (!(<TAG0.BONDED>))
				DOSWITCH <EVAL <LOCAL.TIME>-1>
				REF1.TAG.BONDEDTIME=49
				REF1.TAG.BONDEDTIME=41
				REF1.TAG.BONDED=1 //REF1.TAG.BONDEDTIME=33
				REF1.TAG.BONDED=1 //REF1.TAG.BONDEDTIME=25
				REF1.TAG.BONDED=1 //REF1.TAG.BONDEDTIME=17
				REF1.TAG.BONDED=1 //REF1.TAG.BONDEDTIME=9
				REF1.TAG.BONDED=1
				ENDDO
			ENDIF
		TIMERF CLEAR
		SRC.USEITEM <UID>
		SRC.TAG0.STABLEDPETS -= 1
			IF (!(<SRC.TAG0.STABLEDPETS>))
			SRC.TAG.STABLEDPETS=
			ENDIF
		ENDIF
	ENDIF
ENDFOR
IF (!(<LOCAL.HASMYPETSTABLED>))
SAY @,,2 502671
ENDIF

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

[DIALOG d_pet_retrieve]
200,200
src.closealldialogs

PAGE 1
IF (<SRC.TAG0.STABLEDPETS>)
resizepic 10 10 3600 350 <EVAL 65+(<SRC.TAG0.STABLEDPETS>*25)>
	FOR <SRC.TAG0.STABLEDPETS>
	button 30 <EVAL (<LOCAL._FOR>*20)+40> 4005 4006 1 0 <dLOCAL._FOR>
		IF (<UID.<SRC.CTAG0.PETSTABLED.<dLOCAL._FOR>>.TAG0.STABLE.TIME>)
		LOCAL.TIME=<EVAL ((((<SERV.TIME>/10)/60)/60)/24)-<UID.<SRC.CTAG0.PETSTABLED.<dLOCAL._FOR>>.TAG0.STABLE.TIME>>
			IF (<LOCAL.TIME> > 3)
			LOCAL.TIME=3
			ENDIF
		ENDIF
		IF (!(<UID.<SRC.CTAG0.PETSTABLED.<dLOCAL._FOR>>.TAG0.BONDED>))
		dtext 70 <EVAL (<LOCAL._FOR>*20)+40> <QVAL (<LOCAL.TIME> == 3) ? 55:88> <UID.<SRC.CTAG0.PETSTABLED.<dLOCAL._FOR>>.NAME> (<dLOCAL.TIME> days after stabled)
		ELSE
		dtext 70 <EVAL (<LOCAL._FOR>*20)+40> 55 <UID.<SRC.CTAG0.PETSTABLED.<dLOCAL._FOR>>.NAME> (Bonded)
		ENDIF
	ENDFOR
ELSE
resizepic 10 10 3600 350 65
ENDIF
dtext 30 30 33 Select the pet you wish to retrieve from the list:

[DIALOG d_pet_retrieve BUTTON]
ON=0
FOR <SRC.TAG0.STABLEDPETS>
TRY SRC.CTAG.PETSTABLED.<dLOCAL._FOR>=
ENDFOR

ON=1 100
REF1=<SRC.CTAG.PETSTABLED.<ARGN1>>
IF ((((<SERV.CHARDEF.<REF1.TAG.ID>.TAG0.FOLLOWERCONSUME>) && (<EVAL <SRC.CURFOLLOWER>+<SERV.CHARDEF.<REF1.TAG.ID>.TAG0.FOLLOWERCONSUME>> > 5))) || ((!(<SERV.CHARDEF.<REF1.TAG.ID>.TAG0.FOLLOWERCONSUME>)) && (<EVAL <SRC.CURFOLLOWER>+1> > 5)))
src.sysmessageloc -1,1049612,"<REF1.NAME>"
ELSE
SRC.BOUNCE <REF1.UID>
LOCAL.TIME=<EVAL ((((<SERV.TIME>/10)/60)/60)/24)-<REF1.TAG0.STABLE.TIME>>
	IF (<LOCAL.TIME> > 3)
	LOCAL.TIME=3
	ELIF (!(<LOCAL.TIME>))
	LOCAL.TIME=1
	ENDIF
	IF (!(<TAG0.BONDED>))
		DOSWITCH <EVAL <LOCAL.TIME>-1>
		REF1.TAG.BONDEDTIME=49
		REF1.TAG.BONDEDTIME=41
		REF1.TAG.BONDED=1 //REF1.TAG.BONDEDTIME=33
		REF1.TAG.BONDED=1 //REF1.TAG.BONDEDTIME=25
		REF1.TAG.BONDED=1 //REF1.TAG.BONDEDTIME=17
		REF1.TAG.BONDED=1 //REF1.TAG.BONDEDTIME=9
		REF1.TAG.BONDED=1
		ENDDO
	ENDIF
REF1.TIMERF CLEAR
SRC.USEITEM <REF1.UID>
SRC.TAG0.STABLEDPETS -= 1
	IF (!(<SRC.TAG0.STABLEDPETS>))
	SRC.TAG.STABLEDPETS=
	ENDIF
ENDIF
FOR <SRC.TAG0.STABLEDPETS>
TRY SRC.CTAG.PETSTABLED.<dLOCAL._FOR>=
ENDFOR

[EOF]