ID:149370
 
I have tryed continually to make my enemies attack any usrs in a 3 range radius. I am using a turn based combat system which is a bit like runescape. Ok i am trying to get my monster to move and if he sees a player he will charge and get into battle. here is my monster code. If you need more code tell me.

mob/horse
icon = 'npcs.dmi'
icon_state = "horse"
health = 50
mindamage = 2
maxdamage = 10
lvl = 1
isnpc = 0

Att = 60
DEF = 3
DEX = 20
AGI = 12
gold = 35
EXPgive = 25
New()
// Start my action cycle at a random point, to keep cycles spread out.
next_action_time = world.time + rand(10)
return ..()


base_EventCycle(world_time)
/*
This function is called by the EventLoop library once per tick (1/10th a second)
to give me a chance to do something if I want.

I only want to do something if we've reached my next_action_time.
*/
if (next_action_time <= world_time)

// Time to do whatever.
TakeAction()

// Set the next walk time.
next_action_time = world_time + action_delay


proc/TakeAction()
// If this is a player, do nothing.
if (client)
return

// By default just have them walk around.
if (prob(movement_probability))
step_rand(src)
M.PCattacking(src)
return

attack()
if(src.opponent == usr)
usr.movement_probability = 0
src.movement_probability = 0
var/hitpercent = 50 + src.DEX
var/hitpercent2 = hitpercent - usr.AGI
if(hitpercent2 > 100)
hitpercent2 = 100
if(hitpercent2 < 0)
hitpercent = 0
var/hitpercent3 = rand(1,100)
var/damagefirst = rand(src.mindamage,src.maxdamage)
var/damagecount = damagefirst - usr.DEF
if(hitpercent3 <= hitpercent2)
if(damagecount > 0)
view() << "[src] attacks [usr]([damagecount])"
flick("4",src)
usr.health -= damagecount
usr.Deathcheck(src)
else
view() << "[src]'s attack didn't harm [usr]"
else
view() << "[src] attacks [usr], but misses"
if(src == null)
return
if(usr == null)
src.opponent = ""
return
else
if(src.opponent == usr)
sleep(10)
usr.attacking(src)</0>