</ Monster
var/mob/target
var/SightRange=5
var/AttackRange=1
var/WanderDelay=5
proc/Wander()
for(var/mob/m in oview(src,SightRange))
if(!target) target=m
if(get_dist(target,src)<get_dist(target,m)) target=m
if(target)
if(target in oview(src,AttackRange))
attack() //Assumes there is a mob/proc/Attack() defined. Change as needed
spawn(WanderDelay) Wander()
return
else
step_to(src,target)
spawn(WanderDelay) Wander()
return
else
step_rand(src)
spawn(WanderDelay) Wander()
return
proc/Fight(mob/M)
var/damage = rand(1,10)
M.HP -= damage
M << "[src] attacks you for [damage] damage!!"//This tells "M" they have been attacked
src<<"You attack [M] for [damage] damage!!" //This tells you that you atttack M for how many damage
DeathCheck(M) // Run Death Check>
<b>:</b>
tried to use this code and it didn't work with my game btw i got this code from another topic
ID:264608
Jan 4 2010, 2:00 pm
|
|
Code:
|
This is because copying and pasting code from the forum is not the way to make anything.
http://www.byond.com/developer/articles/start |
In response to Garthor
|
|
thanks i wont copy code anymore
|
You can check out this example (or many others in the Libraries and Demo's) section to play around with. As Garthor recommended, don't copy and paste code into your game. Write it yourself after (and as) you understand what it does. If you try to copy/paste your way into a game, you'll end up with a big pile of troublesome bugs which end up driving your game into the mud.
If you don't understand how something works, create a new project and play around with concepts until you get an understanding of how you can spawn stuff or how you can kill stuff. :) ts |
i tryed to use this code with my game and it didn't work with my game
btw i got this from another topic