ID:148710
 
Heres the code for the ai in my game(mind you this is just for testing.)

mob
enemy
icon = 'Monster.dmi'
orange_slime
icon_state = "Oslime"
New()
..()
AILoop()
proc/AILoop()
for(var/mob/players/M in oview())
if(!M)
del(src)
return
else
if(src.turn == 1)
spawn(1)
M<<"You have been attacked by Orange Slime!"
M.turn = 1
spawn(1) AILoop()


This all looks fine to me, but when I have it spawn one of these for the player to fight, the slime wont do anything, wether i set it to attack with turn 1 or 0, or wether the players turn is 1 or 0. Anyone see problems with this? Do I need to post more of my code?
You aren't even calling an attack proc so I see why it's not doing anything =P
In response to Super16
Well its not really supposed to attack just yet(ill get to that later when I implement the stats.) just supposed to tell the M he was attacked(for testing purposes.) Any input?
oview(src), not oview(). oview() defaults to oview(usr), and the usr would be the player, and since oview() doesn't include the player, then nothing is done.
In response to Garthor
Thank you.
I tried what you said Garthor but it didnt change a thing.
Heres the code with a few changes, I tried a different approach to making it attack, but it still wont do a thing.

mob
enemy
icon = 'Monster.dmi'
orange_slime
icon_state = "Oslime"
New()
..()
src.AILoop()
proc/AILoop()
var/mob/M
for(M in oview(src))
if(!M)
del(src)
return
else
if(src.turn == 1)
spawn(1)
src.attackE()
spawn(1) AILoop()
proc/attackE()
for(var/mob/players/M in oview(src))
if(M.client)
M<<"You have been attacked by [src]!"
M.turn = 1
src.turn = 0
return
else return

Thats the AI code, heres my attack that sets the enemies turn to 1:

Attack
icon_state = "Attack"
screen_loc = "12,3"
New(client/C)
C.screen += src
Click()
if(usr.turn == 1)
for(var/mob/enemy/M in oview())
usr<<"You have hit [M]!"
usr.turn = 0
M.turn = 1
return
if(usr.turn == 0)
usr<<"It is not your turn!!"


Now this all appears to be in good order to me, but when i click on the attack screen object, it tells me i have attacked and if i try again that its not my turn. Even after all this it still wont make the enemy attack me. Can anyone point out the err in my code?
In response to Jotdaniel
When you set up vars do you set the monster's turn to 1 by default?
In response to Super16
Hmm, no I had it set to 0. I just tried it on 1 and the monster attacks.....I wonder why it wont attack when I set it to 0 though?
In response to Jotdaniel
Jotdaniel wrote:
Hmm, no I had it set to 0. I just tried it on 1 and the monster attacks.....I wonder why it wont attack when I set it to 0 though?

because you have it set so if their turn was 1 then they attack.
In response to Super16
(im done with this, but anyway) When the person attacks them it sets their turn to 1, so then they should attack. BUT, they still dont, that was my question i guess.
In response to Jotdaniel
It's because you're only spawning the AI loop if it's their turn. You shouldn't even have it as a loop, simply call it at the end of every player's turn.
In response to Garthor
Damn. Wow I cant believe I didnt see that. Thanks man.