ID:171000
 
Ok here is my problem, I have cars coded in and when I coded in my Monster A.I (for monsters), my cars start going crazy and attack players along with the monsters.
Any suggestions?
Are the monsters and cars mobs?
Show us the coding, we can't really help if we don't know anything.
In response to Hell Ramen
Yes they are and Ok.


mob
proc

ai_random_wander()
if(src.key)
return
else
walk_rand(src,5)
src.ai_run_away()
spawn(10)
ai_random_wander()


ai_run_away()/
if(src.client)
return
else
for(var/mob/M in oview(5,src))
if(M.client)
if(get_dist(src,M) <= 5 && src.health < M.health)
walk_away(src,M,5,5)
else
src.ai_walk_to()
else
continue

ai_walk_to()
if(src.client)
return 0
else
for(var/mob/M in oview(5,src))
if(M.client)
if(get_dist(src,M) <= 5)
walk_to(src,M,1,5)
ai_check_dist(src,M)
break
else
continue
else
continue

ai_check_dist(mob/attacker,mob/defender)
if(attacker.client)
return
else
if(get_dist(attacker,defender) <= 1)
attacker.attack(defender)
else
return

attack(mob/defender)
var/damage = rand(1,10)
defender << "You take [damage] damage!"
src << "You attack for [damage] damage!"
if(defender.health <= 0)
src.death(defender)
if(!src.client)
sleep(10)
src.ai_random_wander()

death(mob/player)
src << "You kill [player]!"
player << "You have been killed!"
player.loc = locate(rand(1,world.maxx),rand(1,world.maxy),rand(1,world.maxz))
player.health = initial(health)















mob
New()
sleep(20)
if(isnull(usr.client))
ai_random_wander()
evil = 1
return..()
else
return..()



mob
monster
Bump()
//took out for temporary reason becouse i wuz trying something and didn't have time to put back in.


wolf
health = 150
evil = 1
icon = 'Evil.dmi'
icon_state = "null"
In response to Chwgt
Are the cars mobs?
In response to Chwgt
Try making what you want each different mob type, a different thing.

Example:

mob
player
Click()
usr << "[src] is a player"
car
Click()
usr << "You enter car"

monster
Click()
usr << "Attack!!!!!"


By the way...its
 and
 ... not (DM) and (/DM)
In response to Hell Ramen
yes
In response to N1ghtW1ng
The verb is in the battle system dm i made and i want you to attack monsters same way you would attack a player do you want to see my battle system?
In response to Chwgt
Make it like.
/mob/monster/<insert stuff here>
/mob/car/<insert stuff here>
In response to Hell Ramen
Hell Ramen wrote:
Make it like.
/mob/monster/<insert stuff here>
/mob/car/<insert stuff here>





How do you mean like
/mob/car/<?>
In response to Chwgt
Know how you did mob/monster?
Move the New() proc into it.
In response to Hell Ramen
so it would be
mob/monster/<mob
New()
sleep(20)
if(isnull(usr.client))
ai_random_wander()
evil = 1
return..()
else
return..()>


If not plz fix - -"
In response to Chwgt
...
Take the "<" and ">" and the "mob" part(the second one)
In response to Hell Ramen
K fixed but now it's giving me proc definetion allowed inside another on this right here.
        ai_random_wander()
if(src.key)
return
else
walk_rand(src,5)
src.ai_run_away()
spawn(10)
ai_random_wander()




Any suggestion's to this newb coder?
In response to Chwgt
ai_random_wander()
if(src.key)
return
else
walk_rand(src,5)
src.ai_run_away()
spawn(10)ai_random_wander()

Try that, I really don't know though.
In response to Chwgt
Should be:
mob/monster
New()
..()//Avoid overriding mob/monster/New()
evil=1
sleep(20)//Not quite sure why you want it to sleep, but w/e
ai_random_wander()//Call the proc


You don't need to check for "if(!client)"(The "!" operator basically means not), unless you're planning on making players into mob/monster types.
In response to Hell Ramen
Yeah..those errors are caused by indentation errors, you called a proc, and then indented the next line wrong(is what is usually wrong)
In response to Chwgt
Well, first of all, you need to prevent an infinite loop, so you'd better add while(src):
mob/proc/ai_random_wander()
if(src.client) return
else
while(src)
walk_rand(src,5)
src.ai_run_away()
sleep(10)


Of course, since you're using mob/monster, I'd suggest:

mob/monster/proc/ai_random_wander()
if(src.client) return
else
while(src)
walk_rand(src,5)
src.ai_run_away()
sleep(10)
In response to Lenox
Ok guys if you can read this and try and correct it for me I have to work on another game and if I cant get this A.I system im probally gonna give up on the game im working on it for. (Sorry if there are grammer errors I wuz typing fast becouse im rushing)


mob/monster
New()
..()//Avoid overriding mob/monster/New()
evil=1
sleep(20)//Not quite sure why you want it to sleep, but w/e
ai_random_wander()//Call the proc



mob/monster/proc/ai_random_wander()
if(src.client)
return
else
while(src)
walk_rand(src,5)
src.ai_run_away()
sleep(10)



ai_run_away()
if(src.client)
return
else
for(var/mob/M in oview(5,src))
if(M.client)
if(get_dist(src,M) <= 5 && src.health < M.health)
walk_away(src,M,5,5)
else
src.ai_walk_to()
else
continue

ai_walk_to()
if(src.client)
return 0
else
for(var/mob/M in oview(5,src))
if(M.client)
if(get_dist(src,M) <= 5)
walk_to(src,M,1,5)
ai_check_dist(src,M)
break
else
continue
else
continue

ai_check_dist(mob/attacker,mob/defender)
if(attacker.client)
return
else
if(get_dist(attacker,defender) <= 1)
attacker.attack(defender)
else
return

attack(mob/defender)
var/damage = rand(1,10)
defender << "You take [damage] damage!"
src << "You attack for [damage] damage!"
if(defender.health <= 0)
src.death(defender)
if(!src.client)
sleep(10)
src.ai_random_wander()

death(mob/player)
src << "You kill [player]!"
player << "You have been killed!"
player.loc = locate(rand(1,world.maxx),rand(1,world.maxy),rand(1,world.maxz))
player.health = initial(health)


















mob
monster
Bump()
//took out for temporary reason becouse i wuz trying something and didn't have time to put back in.


wolf
health = 150
evil = 1
icon = 'Evil.dmi'
icon_state = "null"
In response to Chwgt
Look, you can't just post code like that and expect us to correct it. If you don't tell us what's wrong, we can't help. Still, just browsing through the code, I see ways to improve it, and a couple errors to be fixed. Here's the correct code:

mob/monster//These procs will only be used by mob/monsters, so these should obviously be mob/monster procs.
proc
ai_random_wander()
if(src.client) return
else
while(src)
walk_rand(src,5)
src.ai_run_away()
sleep(10)
ai_run_away()
if(src.client) return
else
for(var/mob/M in oview(5,src))
if(M.client)
if(get_dist(src,M) <= 5 && src.health < M.health)
walk_away(src,M,5,5)
else src.ai_walk_to()

ai_walk_to()
if(src.client) return 0
else for(var/mob/M in oview(5,src))
if(M.client&&get_dist(src,M) <= 5)
walk_to(src,M,1,5)
ai_check_dist(src,M)


ai_check_dist(mob/attacker,mob/defender)
if(attacker.client) return
else
if(get_dist(attacker,defender) <= 1) attacker.attack(defender)

mob/proc//These procs can be used by all mobs.
attack(mob/defender)
var/damage = rand(1,10)
defender << "You take [damage] damage!"
src << "You attack for [damage] damage!"
if(defender.health <= 0) src.death(defender)

death(mob/player)
src << "You kill [player]!"
player << "You have been killed!"
player.loc = locate(rand(1,world.maxx),rand(1,world.maxy),rand(1,world.maxz))
player.health = initial(health)//Wouldn't that set it to null, or 1, maybe?
//Haven't seen your health system though; can't tell.


Keep in mind that I haven't fully checked for functionality, but just for correct coding. In other words, it's organized, and won't output runtimes, but I didn't look at it thouroughly enough to prevent runtimes. If you coded it right in the first place, however, there won't be any runtimes.

If there are, this time, I want you to try and fix it yourself before you post on the forum. If you've tried and you honestly can't, then post the error and we'll see what we can do.
In response to Wizkidd0123
Argh, Wizkidd, you beat me to it, I was still trying to fix the stupid indentations >_<. But your indentations seemed off(directed towards the creator of the code). One proc, the proc name was "further indented" past the actual proc(which I believe would cause an error). At first, I couldn't tell if it was actually a proc, or if you were just calling a proc named that until you posted the full code and I saw that there was nothing before it >_<.
Page: 1 2