[ITEMDEF i_treasure_chest]
ID=i_chest_metal
NAME=Treasure Chest
CATEGORY=Addon
SUBSECTION=Tesouros
DESCRIPTION=Treasure Chest

ON=@Create
COLOR=04ec
ATTR=ATTR_MOVE_NEVER
TIMER=1

ON=@Timer
IF (<COUNT>)
TIMER=60
ELSE
MORE1=1
TAG.GAVESTEALING=
	DORAND 2
	SERV.NEWNPC=c_rotting_corpse
	SERV.NEWNPC=c_dragon_small_red
	ENDDO
NEW.TAMING=0
NEW.TAG.CHEST=<UID>
NEW.EVENTS +e_chestprotector
NEW.P=<P>
NEW.MOVENEAR <UID> 1
	WHILE (<NEW.ISSTUCK>)
	NEW.MOVENEAR <UID> 1
	ENDWHILE
NEW.HOME=<NEW.P>
NEW.HOMEDIST=5
TIMER=<EVAL 60*60*<R2,4>>
SERV.NEWITEM i_gold,{400 800},<UID>
	FOR <R1,2>
	RANDMAGICITEM
	ENDFOR
	IF (<FLOATVAL 0.0075> > <RANDOMDOUBLE>)
	SERV.NEWITEM i_osi_treasure_map,1,<UID>
	ENDIF
	IF (<FLOATVAL 0.001> > <FLOATVAL 1>)
	SERV.NEWITEM {i_colored_anvil 14 i_leather_gloves_mining 14 i_studded_gloves_mining 14 i_ringmail_gloves_mining 10 i_ancient_smithy_hammer 6 i_powder_Temperment 5 i_clothing_bless_deed 4}
	NEW.CONT=<UID>
	ENDIF
	IF (10 >= <R1,100>)
	RANDMAGICITEMGREAT
	ENDIF
	IF (<FLOATVAL 0.0001> > <FLOATVAL 1>)
	SERV.NEWITEM <HVAL <DEF.MINORARTIS>>,1,<UID>
	ENDIF
ENDIF
UPDATEX
RETURN 1

ON=@Dropon_Self
IF (<SRC.ISPLAYER>)
RETURN 1
ENDIF

ON=@Dclick
IF (<MORE1>) && !(<SRC.ISGM>)
SAY @946,3,1 You must first kill the guardians of the chest.
RETURN 1
ENDIF
IF (!(<TAG0.GAVESTEALING>))
	FOR <R1,3>
	SRC.SKILLGAIN STEALING <EVAL (<SRC.STEALING>/10)+1>
	ENDFOR
TAG.GAVESTEALING=1
ENDIF

[EVENTS e_chestprotector]
ON=@Death
REF1=<TAG0.CHEST>
REF1.MORE1 --
IF !(<REF1.MORE1>)
REF1.SAY @946,3,1 Lock opened.
ENDIF

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

[ITEMDEF i_treasure_chest_locked]
ID=i_chest_metal_brass
NAME=Locked Treasure Chest
TYPE=T_CONTAINER_LOCKED
CATEGORY=Addon
SUBSECTION=Tesouros
DESCRIPTION=Treasure Chest (locked)

ON=@Create
ATTR=ATTR_MOVE_NEVER
TYPE=T_CONTAINER_LOCKED
TIMER=1

ON=@Timer
IF (<TAG0.OPENED>)
SERV.NEWITEM i_treasure_chest_locked
NEW.P=<P>
NEW.UPDATE
REMOVE
ELSE
SERV.NEWITEM i_gold,{200 300},<UID>
DORAND 7
BEGIN
MORE2=0
NAME=Level 0 Treasure Chest
RANDMAGICITEM
END
BEGIN
MORE2=20.0
NAME=Level 1 Treasure Chest
SERV.NEWITEM i_gold,50,<UID>
FOR <R1,2>
RANDMAGICITEM
ENDFOR
END
BEGIN
MORE2=40.0
NAME=Level 2 Treasure Chest
SERV.NEWITEM i_gold,150,<UID>
FOR <R1,3>
RANDMAGICITEM
ENDFOR
END
BEGIN
MORE2=60.0
NAME=Level 3 Treasure Chest
SERV.NEWITEM i_gold,250,<UID>
RANDMAGICITEM
RANDMAGICITEM
	IF (<FLOATVAL 0.01> > <RANDOMDOUBLE>)
	SERV.NEWITEM i_osi_treasure_map,1,<UID>
	ENDIF
END
BEGIN
MORE2=80.0
NAME=Level 4 Treasure Chest
SERV.NEWITEM i_gold,380,<UID>
IF (<R100> == 1)
SERV.NEWITEM i_power_scroll,1,<UID>
NEW.MORE1=<HVAL {24 1 33 1}>
NEW.name=<NEW.POWERSCROLLNAME> Power Scroll of <SERV.SKILL.<NEW.MORE1>.NAME>
ENDIF
RANDMAGICITEM
RANDMAGICITEM
IF (<R2> == 1)
RANDMAGICITEMGREAT
ENDIF
	IF (<FLOATVAL 0.025> > <RANDOMDOUBLE>)
	SERV.NEWITEM i_osi_treasure_map,1,<UID>
	ENDIF
END
BEGIN
MORE2=100.0
NAME=Level 5 Treasure Chest
SERV.NEWITEM i_gold,550,<UID>
IF (<R50> == 1)
SERV.NEWITEM i_power_scroll,1,<UID>
NEW.MORE1=<HVAL {24 1 33 1}>
NEW.name=<NEW.POWERSCROLLNAME> Power Scroll of <SERV.SKILL.<NEW.MORE1>.NAME>
ENDIF
RANDMAGICITEMGREAT
SERV.NEWITEM i_sea_mapa_tesouro,1,<UID>
	IF (<FLOATVAL 0.0005> > <FLOATVAL 1>)
	SERV.NEWITEM <HVAL <DEF.MINORARTIS>>,1,<UID>
	ENDIF
END
BEGIN
MORE2=100.0
NAME=Level 6 Treasure Chest
SERV.NEWITEM i_gold,750,<UID>
IF (<R25> == 1)
SERV.NEWITEM i_power_scroll,1,<UID>
NEW.MORE1=<HVAL {24 1 33 1}>
NEW.name=<NEW.POWERSCROLLNAME> Power Scroll of <SERV.SKILL.<NEW.MORE1>.NAME>
ENDIF
RANDMAGICITEMGREAT
RANDMAGICITEMGREAT
SERV.NEWITEM i_sea_mapa_tesouro,1,<UID>
IF (<FLOATVAL 0.001> > <FLOATVAL 1>)
SERV.NEWITEM <HVAL <DEF.MINORARTIS>>,1,<UID>
ENDIF
IF (<FLOATVAL 0.001> > <RANDOMDOUBLE>)
SERV.NEWITEM <HVAL <DEF.RANDOM_ML_SETS_DROP_LIST>>,1,<UID>
ENDIF
END
ENDDO
UPDATEX
ENDIF
RETURN 1

ON=@Dropon_Self
IF (<SRC.ISPLAYER>)
RETURN 1
ENDIF

ON=@Dclick
IF (!(<MORE1>)) && (<TAG0.OPENED>)
SRC.DAMAGE 80 01 01
MORE1=1
ENDIF

[EOF]