Im trying to make a code so that after you chop a tree down and its a stump you cannot chop it anymore...Here's what I've dont so far:
turf
obj
small_tree
icon = 'turfs.dmi'
icon_state = "small_tree"
var
stump = 0
verb
Cut()
if(locate(/obj/Bronze_axe) in usr)
set src in oview(1)
set category = "Wood Cutting"
var/cut = rand(1,4)
if(cut == 1)
usr << "You Miss The Tree!"
return
if(cut == 2)
usr << "You Miss The Tree!"
return
if(cut == 3)
usr << "You Miss The Tree!"
return
if(cut == 4)
usr << "You Get Some Lumber!"
src.icon_state = "small_tree_stump"
new/obj/Lumber(usr.loc)
else if(locate(/obj/Iron_axe) in usr)
set src in oview(1)
set category = "Wood Cutting"
var/cut = rand(1,4)
if(cut == 1)
usr << "You Miss The Tree!"
return
if(cut == 2)
usr << "You Miss The Tree!"
return
if(cut == 3)
usr << "You Miss The Tree!"
return
if(cut == 4)
usr << "You Get Some Lumber!"
src.icon_state = "small_tree_stump"
new/obj/Lumber(usr.loc)
else
usr << "You need an axe!"
return
THanks in advance!
-Crio
ID:176556
![]() Jan 3 2003, 9:40 am
|
|
I think its best to make some kind of spawner.
I am using this spawner: obj Tree_spawnpoint spawntype = turf/obj/small_tree obj Spawner name = "Spawner" var spawned = 0 max_spawned = 2 spawntype New() ..() spawn while (1) src.check_spawn() var time = rand(100,300) sleep(time) proc check_spawn() if(spawned < max_spawned) var/mob/M = new spawntype(src.loc) M.owner = src spawned ++ mob var/atom/owner Del() if(owner && istype(owner, /obj/Spawner)) var/obj/Spawner/O = owner O.spawned -= 1 ..() It sould spawn your tree 10 or 30 sec after chopping it down. Originally the code is for spawning rabits so i dunno if it works for your tree but you can use it as a example. I hope it can help you a bit. BTW: You are using: var/cut = rand (1,4) You can just use: if(cut == 4) usr << you got some wood else usr << you got no wood and you can also just delete the var thing and use: if(prob(25)) usr << you got some wood else usr << you got no wood Greetz Fint |
if(cut == 4) I was thinking the same thing, but i didnt want to say anything in fear the lummox is around **scanning the crouds of byondians** |
Oh, i though he just wanted to check to see if there was wood there or now, he could have also replaced the object with a tree stump object when it was cut down, but your code is more complicated...urrr...simple...
[edit] I reread his post, all he wanted was a code to check to see if they can chop the wood or not, he never said anything about removing the verb, my way was a lot simpler for what he wanted. So :P |
Yes and i am scarred for life now, i will never get a job, never finish a game, never be the same. lol, i cant even finish this post.
|
he wrote:
Im trying to make a code so that after you chop a tree down and its a stump you cannot chop it anymore So the verb has do be gone when the stump appears |
Heres another idea. Make the tree stump a separate obj. then do this
obj/tree/verb/Cut() //whatever the cut does new/obj/tree/stump in src.loc del(src) then tree stump obj/tree/stump New() spawn() Respawn() proc/respawn() spawn(600)//this waits one minute new/obj/tree in src.loc del(src) How would this do to solve your problem? |
if(src.icon_state == "small_tree")
//whatever it does when you have a full tree
else if (src.icon_state = "small_tree_stump")
//Tell them it has no wood left
It would also be a good idea to make the tree grow back after a while.