ON=@TARGON_GROUND
IF (<serv.map(<src.targp.x>,<src.targp.y>,<src.targp.z>,<src.targp.m>).type>==t_rock)
RETURN 0
ENDIF
IF (<serv.map(<src.targp.x>,<src.targp.y>,<src.targp.z>,<src.targp.m>).type>==t_sand)
IF (<DISTANCE <SRC.TARGP>> >= 3)
SRC.SYSMESSAGE That is too far away, try mining closer
RETURN 1
ENDIF
IF !<SRC.CANSEELOS <SRC.TARGP>>
SRC.SYSMESSAGE I cannot see that, how am i supposed to mine it?
RETURN 1
ENDIF
LOCAL.MINE=(<SRC.MINING>/100)
IF (<R2> < <EVAL <LOCAL.MINE>>)
src.f_sand_success
ELSE
src.f_sand_fail
ENDIF
RETURN 1
ENDIF
[FUNCTION f_sand_success]
SRC.TIMERF 1, f_check_sand_resources
IF !(<SRC.CTAG0.RESOURCE>)
SRC.ANIM 11
sfx 0340
NEWITEM=i_coin_copper
NEW.ATTR=attr_move_never|attr_invis|attr_decay
NEW.MORE2=i_sand
NEW.AMOUNT=<EVAL {3 6}>
NEW.TIMER=60*10
NEW.P=<SRC.TARGP>
SRC.CTAG.RESOURCE=<NEW.UID>
RETURN 1
ENDIF
IF (<UID.<SRC.CTAG0.RESOURCE>.AMOUNT> > 0)
SRC.TIMERF 1, f_sand_mine_action
RETURN 1
ELSE
SRC.SYSMESSAGE There is nothing here to mine.
ENDIF
[FUNCTION f_check_sand_resources]
SRC.ANIM 11
sfx 0340
CTAG.RESOURCE=
VAR.RESOURCE=
VAR.OLD_ACT=<ACT.UID>
NEWITEM=i_memory
NEW.P=<TARGP>
NEW.f_check_sand_resources_p
NEW.REMOVE
IF (<VAR0.RESOURCE>)
CTAG.RESOURCE=<VAR0.RESOURCE>
ENDIF
VAR.RESOURCE=
[FUNCTION f_check_sand_resources_p]
FORITEMS 0
IF (<BASEID>==i_coin_copper)
IF (<MORE2>==i_sand)
VAR.RESOURCE=<UID>
ENDIF
ENDIF
ENDFOR
[FUNCTION f_sand_mine_action]
IF (<SRC.CTAG0.anim> <= 3)
SRC.ANIM 11
SRC.SFX 0340
SRC.CTAG0.anim += 1
TIMERF 1, f_sand_mine_action
ELSE
SRC.CTAG.ANIM=
f_sand_mine
ENDIF
[FUNCTION f_sand_mine]
TRY UID.<SRC.CTAG0.RESOURCE>.AMOUNT=<UID.<SRC.CTAG0.RESOURCE>.AMOUNT> +-1
TRY UID.<SRC.CTAG0.RESOURCE>.UPDATE
SRC.ANIM 11
sfx 0340
NEWITEM=<UID.<SRC.CTAG0.RESOURCE>.MORE2>
NEW.BOUNCE
ENDIF