[ITEMDEF 02252]
DEFNAME=i_book_chivalry
NAME=Book of Chivalry
TYPE=185
VALUE=250

ON=@Create
ATTR=attr_magic|attr_newbie
morez=200
more1=1023

ON=@EquipTest
RETURN 1

ON=@DClick
if (<cont.uid> != <src.findlayer.layer_pack.uid>) || (!(<cont>))
  src.sysmessageloc -1,500207
  return 1
endif

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

[TYPEDEF T_SHRINE]
ON=@ContextMenuRequest
SRC.AddContextEntry 300,6198
IF (<SRC.TAG0.KARMALOCKED>)
SRC.AddContextEntry 301,6197
ELSE
SRC.AddContextEntry 301,6196
ENDIF

ON=@ContextMenuSelect
IF (<ARGN> == 300)
DIALOG D_TITHING
ELIF (<ARGN> == 301)
	IF (<SRC.TAG0.KARMALOCKED>)
	SRC.TAG.KARMALOCKED=
	SRC.MESSAGE @,,2 1060191 //Your karma has been unlocked. Your karma can be raised again.
	ELSE
	SRC.TAG.KARMALOCKED=1
	SRC.MESSAGE @,,2 1060192 //Your karma has been locked. Your karma can no longer be raised.
	ENDIF
ENDIF

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

[FUNCTION ISBENEFICIAL]
//ARGV[0] = viewer
REF1=<ARGV[0]>
IF (!(<REF1>))
REF1=<SRC.UID>
ENDIF
IF (<REF1> == <UID>)
RETURN 1
ENDIF
IF (!(<ISPLAYER>)) && (!(<REF1.ISPLAYER>))
	IF (!(<FLAGS>&STATF_PET))
		IF (!(<ISFIGHTINGME <REF1>>))
		RETURN 1
		ENDIF
	ENDIF
ENDIF
IF (<ISPLAYER>) && (<REF1.ISPLAYER>)
	IF (<GUILD>) && (<REF1.GUILD>)
		IF (<GUILD> == <REF1.GUILD>)
		RETURN 1
		ENDIF
	ENDIF
	IF (<ISINPARTY>) && (<REF1.ISINPARTY>)
		IF (<PARTY.ISSAMEPARTYOF <REF1.UID>>)
		RETURN 1
		ENDIF
	ENDIF
ENDIF
IF (<FLAGS>&STATF_PET) && (<OWNER> == <REF1>)
RETURN 1
ENDIF
IF (<ISFIGHTINGME <REF1>>)
RETURN 0
ENDIF
IF (!(<ISPLAYER>))
	IF (((<NOTOGETFLAG <REF1>,0> == 1) && (<REF1.KARMA> <= 0)) || (<NOTOGETFLAG <REF1>,0> == 3))
	RETURN 0
	ENDIF
ENDIF
IF ((<NOTOGETFLAG <REF1>,0> == 1) || (<NOTOGETFLAG <REF1>,0> == 2) || (<NOTOGETFLAG <REF1>,0> == 3))
RETURN 1
ENDIF
RETURN 0

[FUNCTION F_COMPUTE_POWERLEVEL]
//int v = (int) Math.Sqrt( from.Karma + 20000 + (from.Skills.Chivalry.Fixed * 10) );
LOCAL.POWERLEVEL=<EVAL SQRT((<KARMA>+20000+(<CHIVALRY>*10)))>
LOCAL.POWERLEVEL /= <ARGN1>
RETURN <dLOCAL.POWERLEVEL>

[EOF]