ID:141946
 
Code:well this code is suppose to make mobs around then walk and attack them with the Fight()
mob/var
target
speed
Attacked
mob
proc
Fight()//Walk, this defines if he moves, cahses, or attacks.
set background = 1
while(1)//So it reactivates once done
if(!src.target||get_dist(src,src.target)>=10||src.target==src)//If there is no target, or if the target is attacked, or if its out of distance, or if you are the target.
src.target=null//set the target to nothing
for(var/mob/M in oview(src))//for ever orc in the world define it as M
if(M.Nation==src.Nation||M.Attacked)//if Your race, is the same as the enemies(So you dont attack other humans!
else//If not
src.target=M//then your target is M! The stupid orc!
if(!src.target)//If you dont have a target
if(prob(75))step_rand(src)//Step randomly
sleep(src.speed)//sleep your speed
continue//and contnue with the proc
else sleep(src.speed)//If you do have a target, sleep your speed
else//If you do have a target thats in range, and isnt you or is being attacked
if(src.target==src)return//If it is you return
step_towards(src,src.target)//step towards the target
if(get_dist(src,src.target)<=2)//If it is within 2 tiles
step_towards(src,src.target)//step closer so its within 1
spawn src.FireBall(src.target)//and call the attack proc on the target
sleep(src.speed)
mob/AI
Test
icon='WhiteBase.dmi'
Nation="Random"
health=20
speed=10
New()
..()
walk_rand(src,src.speed)
Del()
var/obj/S=new(src.loc)
del(src)
sleep(100)
var/mob/AI/Test/A=new(S.loc)
del(S)
walk_rand(A,A.speed)

mob
Human
icon='WhiteBase.dmi'//Its images
name="NP"
icon_state="TIME"
Nation="test"
health=20//Its health
speed=15//Its speed
New()
..()
Fight()


obj
Alarm
icon = 'Alarm.dmi'
screen_loc = "1,15"
layer = MOB_LAYER+100
Click()
var/mob/Human/A = new(loc)
A.loc=locate(usr.x, usr.y+1, usr.z)
A.dir=NORTH
var/mob/Human/B = new(loc)
B.loc=locate(usr.x, usr.y-1, usr.z)
var/mob/Human/C = new(loc)
C.loc=locate(usr.x+1, usr.y-1, usr.z)
C.dir=EAST
var/mob/Human/D = new(loc)
D.loc=locate(usr.x-1, usr.y-1, usr.z)
D.dir=WEST
var/mob/Human/E= new(loc)
E.loc=locate(usr.x-1, usr.y, usr.z)
E.dir=WEST
var/mob/Human/F = new(loc)
F.loc=locate(usr.x+1, usr.y+1, usr.z)
F.dir=EAST
var/mob/Human/G = new(loc)
G.loc=locate(usr.x+1, usr.y, usr.z)
G.dir=EAST
var/mob/Human/H = new(loc)
H.loc=locate(usr.x-1, usr.y+1, usr.z)
H.dir=WEST
A.Frozen=1
B.Frozen=1
C.Frozen=1
D.Frozen=1
E.Frozen=1
F.Frozen=1
G.Frozen=1
H.Frozen=1
sleep(10)
A.Frozen=0
B.Frozen=0
C.Frozen=0
D.Frozen=0
E.Frozen=0
F.Frozen=0
G.Frozen=0
H.Frozen=0


Problem description:The problem is that when i run the game they don't summon at all. but when i put this it works but it just walk()

mob
Human
icon='WhiteBase.dmi'//Its images
name="Test"
icon_state="TIME"
Nation="test"
health=20//Its health
speed=15//Its speed
New()
..()
walk_rand(src,src.speed)


No offense, but that code is hideous. Have you read the DM guide, at all?

The AI proc is rather...abstract and hard to read at best; it also seems to be your problem.

        Del()
var/obj/S=new(src.loc)
del(src) //this ends the proc so your sleep and everything
//below it won't be called. Look up garbage
//collection; it's an excellent feature, but sometimes
//it can be a little of a nuisance in cases
//like this. A workaround would be spawning and calling another proc
sleep(100)
var/mob/AI/Test/A=new(S.loc)
del(S)
walk_rand(A,A.speed)


                        if(M.Nation==src.Nation||M.Attacked)//What's the point of the else after this? 
//it can be shortened a lot
else
src.target=Mis M! The stupid orc!


                        if(M.Nation!=src.Nation||!M.Attacked)
src.target=Mis M! The stupid orc!


Also, your alarm code can be shortened as well with a little for(var/X in 1 to [number of things goes here]).
In response to Jeff8500
This doesn't solve my problem. It has something to do with mob/Human not Test. Thanks though
In response to Kurma
ok I added

A.Fight()

onto the bottom of Alarm all of a sudden I start doing whatever the proc does