I tried using (var/turf/tree/T in M.loc) but it still deletes the whole location.
I also thought about using a loop when the tree is created to check to see if it's out of resources to delete it, but I figured that would create lag.
Any way around this?
skills
var/NPC/soldier/owner
parent_type=/obj
Gather1
name="Gather"
icon='turfs.dmi'
icon_state="treeicon"
Click()
..()
var/NPC/soldier/P=owner
P.gathering=1
while(P.gathering)
var/turf/tree/M=locate(/turf/tree) in range(10,owner)
if(!M)
M=locate(/turf/tree) in range(10,owner)
if(!M) return
while(!(owner in orange(1,M)))
walk_to(owner,M,1,05)
sleep(05)
M.resources--
if(M.resources<=0)
del(M)
M=locate(/turf/tree) in range(10,owner)
if(!M) return
var/turf/Z=Castleproc(owner)[rand(1,4)]
sleep(10)
while(!(owner in orange(1,Z)))
walk_to(owner,Z,1,05)
sleep(05)
var/mob/player/O=owner.owner
var/turf/L=owner.loc
owner.loc=Z
sleep(10)
O.resources+=rand(10,20)
sleep(10)
owner.loc=L
This is horrible looking code, by the way. It looks so redundant and full of pointless checks. What exactly is it supposed to do?