ID:156101
 
This is what i have for the walking part of my monster Ai.


                    while(target in oview(7))
if(target.x == src.x&&target.y != src.y && target.y > src.y) step(src,NORTH)
else if(target.x == src.x&&target.y != src.y && target.y < src.y) step(src,SOUTH)
else if(target.x != src.x&&target.y == src.y && target.x < src.x) step(src,WEST)
else if(target.x != src.x&&target.y == src.y && target.x > src.x) step(src,EAST)
else if(target.x> src.x&&target.y > src.y)
switch(rand(1,2))
if(1) step(src,EAST)
if(2) step(src,NORTH)
else if(target.x < src.x && target.y < src.y)
switch(rand(1,2))
if(1) step(src,WEST)
if(2) step(src,SOUTH)
else if(target.x < src.x&&target.y > src.y)
switch(rand(1,2))
if(1) step(src,WEST)
if(2) step(src,NORTH)
else if(target.x > src.x && target.y < src.y)
switch(rand(1,2))
if(1) step(src,EAST)
if(2) step(src,SOUTH)
var/mob/b = ""
if(src.dir==NORTH && target.y == src.y +1 &&target.x == src.x) b = target
else if(src.dir==SOUTH && target.y==src.y -1 &&target.x == src.x) b = target
else if(src.dir==WEST && target.x == src.x -1 &&target.y == src.y) b = target
else if(src.dir==EAST && target.x == src.x +1 &&target.y == src.y) b = target


Can someone help me make monsters shoot a projectile, when they are facing the player, but not right in front of them. Thanks.

LaNuiit
I'd recommend not using Zeta's artificial intelligence module. It's a terrible way of performing a simple method.
In response to DarkeWarrior (#1)
then how should i do it ?
In response to LaNuiit (#2)
Here's a simple way to keep your monster in movement.

mob/Monster
New()
..()
spawn() src.Monster_AI()
proc
Monster_AI()
step(pick(NORTH,SOUTH,EAST,WEST)) // pick a random direction to step in
sleep(20) // wait two seconds
src.Monster_AI() // call the proc again, to keep the monster moving


If you want to go further into projectile shooting, you'll have to look up certain functions like get_dir(), and take a look at a projectile lib I personally like.

Projectile Demo
In response to DarkeWarrior (#3)
                switch(rand(1,4))
if(1) step(src,NORTH)
if(2) step(src,SOUTH)
if(3) step(src,EAST)
if(4) step(src,WEST)


This is the code for random walking i have.My other code i post it before makes npc come to player while in oview 7
In response to LaNuiit (#4)
What did I just show you? You can do that in a much simpler form.

step(src,pick(NORTH,SOUTH,EAST,WEST))


Instead of five lines of programming, you can fit it all into one line.
In response to DarkeWarrior (#3)
Aside from the obvious mistake, recursively calling the proc is a non-stop train to crashville. You need to be using a while() loop.

Additionally, the AI is supposed to actually move towards players it seems. In that case, you'd want:

var/D = get_dir(src,target)
// If diagonal, fix to cardinal:
if(D&(D-1))
// Pick the N/S or E/W component
D &= pick(NORTH|SOUTH, EAST|WEST)

step(src,D)
In response to DarkeWarrior (#5)
Ty, but i wuld realy like to know how to make a make monsters shoot a projectile, when they are facing the player, but not right in front of them...
In response to LaNuiit (#7)
LaNuiit wrote:
Ty, but i wuld realy like to know how to make a make monsters shoot a projectile, when they are facing the player,

get_dir()

but not right in front of them...

get_dist()
In response to Garthor (#8)
oh lol yea ty :)