In response to Chaorace
You already programmed in the zombie mob like above, lol.
It's probably something stupid, but I run the game and I the player run near a zombie, and nothing happens , they dont even move toward the car either which alarm variable is set to 1

        obj
car
icon = 'BodyPile3.dmi'
density = 1
var/alarm=0
proc
Alarm()
if(src.alarm==1)
var/sound/cA= sound()
world << cA
else
if(src.alarm==0)
//and its bumped into by a mob/obj, return






They just stand there. I feel like you guys are helping me more then you should haha. Just my lack of knowledge in this subject makes me seem stupid lol. Probably should of done the car alarm proc awhile ago to initiate the var alarm to turn active. I'm just trying to get it so the alarm goes when it's pretty much bumped into by a mob or obj. or shot by a projectile, which would be an object.

mob/Zombie
icon = 'Walker.dmi'
icon_state = "Walk"
proc/behavior()
var atom/movable/target
while(src)
target = findPrey()
if(istype(target))
pursuePrey(target)
sleep(50)
In response to Chaorace
Everything that's supposed to happen in the while(src) loop should be indented.
Oh okay, I indented everything, got 0 errors as expected, but nothing is happening still, it's probably because I'm missing something to make behavior initiate.

mob
left_state = 'Base.dmi'
right_state = 'Base Reverse.dmi'
bound_width = 10
bound_height = 26
step_size = 4


THat's the player(you)

mob/Zombie
icon = 'Walker.dmi'
icon_state = "Walk"
proc/behavior()
var atom/movable/target
while(src)
if(istype(target))
pursuePrey(target)
sleep(50)


New indented behavior proc


        obj
car
icon = 'BodyPile3.dmi'
density = 1
var/alarm
alarm=1
proc
Alarm()
if(src.alarm==1)
var/sound/cA= sound('CarAlarm1.ogg')
var/sound/cA2= sound('CarAlarm2.ogg')
world<< cA
New()
..()
if(prob(50)) world<< cA2
return
if(src.alarm==0)
//and is bumped into by an obj(bullet,bat,etc) or a mob(you/another zombie) then it'll return to the beginning
//and the alarms will go off.
return


Car alarm proc to go off when bumped into, with a probability of 50% to play CarAlarm2.ogg instead of CarAlarm1.ogg. I set the alarm variable to 1 to test it and nothing happens, I think this project has a bug somewhere not allowing anything to happen l0l
You gotta start the behavior() proc, add this onto the zombie mob

mob/Zombie
New()
..()
spawn() behavior()
I think it's calling everything in behavior, but not findPrey() proc maybe? I think that maybe findPrey() isn't doing what it's suppose to do in order for the other procs to work? Just my guess. THere's 0 errors and warning, but the zombies just stand there when I'm around and when there's a car there too.

mob/Zombie
icon = 'Walker.dmi'
icon_state = "Walk"
New()
..()
spawn() behavior()


proc/behavior()
var atom/movable/target
while(src)
if(istype(target))
pursuePrey(target)
sleep(50)

proc
findPrey()
var atom/movable/target
for(var/atom/movable/a in oview())
var/turf/FullBloodyCan/obj/car/o = a
if(get_dist(src, a) < get_dist(src, target))
if(istype(a, /turf/FullBloodyCan/obj/car))
o = a
if(o.alarm)
target = o
if(ismob(a))
target = a
return target


pursuePrey(atom/movable/a)
step_to(src,a)
if(get_dist(src, a)== 0)
attack(a)


attack(atom/movable/a))



Do you think it would be easier and more efficient to set a world sound variable, and the item with the highest sound in the zombies oview get attracted too, like a car alarm would have the highest sound, then next a grenade/bomb, then gun shots, etc. and humans(us) just get attracted to over everything else automatically. The sound can go from map to map, since its a sidescroller you'll be moving sideways so the zombies can run after you. It seems more efficient to me then just having an alarm variable just for 1 object. Would probably save me lots of time in programming these types of things.
In response to Chaorace
Chaorace wrote:
I think it's calling everything in behavior, but not findPrey() proc maybe? I think that maybe findPrey() isn't doing what it's suppose to do in order for the other procs to work? Just my guess. THere's 0 errors and warning, but the zombies just stand there when I'm around and when there's a car there too.

mob/Zombie
> icon = 'Walker.dmi'
> icon_state = "Walk"
> New()
> ..()
> spawn() behavior()
>
>
> proc/behavior()
> var atom/movable/target
> while(src)
> if(istype(target))
> pursuePrey(target)
> sleep(50)
>
> proc
> findPrey()
> var atom/movable/target
> for(var/atom/movable/a in oview())
> var/turf/FullBloodyCan/obj/car/o = a
> if(get_dist(src, a) < get_dist(src, target))
> if(istype(a, /turf/FullBloodyCan/obj/car))
> o = a
> if(o.alarm)
> target = o
> if(ismob(a))
> target = a
> return target
>
>
> pursuePrey(atom/movable/a)
> step_to(src,a)
> if(get_dist(src, a)== 0)
> attack(a)
>
>
> attack(atom/movable/a))

Do you think it would be easier and more efficient to set a world sound variable, and the item with the highest sound in the zombies oview get attracted too, like a car alarm would have the highest sound, then next a grenade/bomb, then gun shots, etc. and humans(us) just get attracted to over everything else automatically. The sound can go from map to map, since its a sidescroller you'll be moving sideways so the zombies can run after you. It seems more efficient to me then just having an alarm variable just for 1 object. Would probably save me lots of time in programming these types of things.

You never called findPrey()
You still have this car defined as a turf, which does not derive from /atom/movable, so findPrey() is going to fail. Just make the car an /obj

Edit: You could set a sound variable, but you can't create new variables under /world

You'd set it under /atom (realistically /atom/movable, but you seem to want to include /turf into this)
Ah good morning Kitsueki, woke up early just to try and get this working. Anyways, I've done what you just said, and still had no luck.

    proc
findPrey()
var atom/movable/target
for(var/atom/movable/a in oview())
var/obj/Vehicles/car/o = a
if(get_dist(src, a) < get_dist(src, target))
if(istype(a, /obj/Vehicles/car))
o = a
if(o.alarm)
target = o
if(ismob(a))
target = a
return target



This is the object car programming.

obj
Vehicles
car
icon = 'BodyPile3.dmi'
density = 1
var/alarm
alarm=1
proc
Alarm()
if(src.alarm==1)
var/sound/cA= sound('CarAlarm1.ogg')
var/sound/cA2= sound('CarAlarm2.ogg')
world<< cA
New()
..()
if(prob(50)) world<< cA2
return
if(src.alarm==0)
//and is bumped into by an obj(bullet,bat,etc) or a mob(you/another zombie) then it'll return to the beginning
//and the alarms will go off.
return


Maybe it's because I have an unfinished alarm proc on it?
Ah, make sure you're calling findPrey() in behavior() :)
Good morning.

>   proc/behavior()
> var atom/movable/target
> while(src)
> target = findPrey() <-----
> if(istype(target))
> pursuePrey(target)
> sleep(50)


Edit: Updated
Ah there we go, they're finally moving, but in a weird way I guess I can put it. I did a few test, to test their movements. If a car isn't close to them, like within like 2-3 16x16 tiles, they won't move at all. And when it is close to them, they move at the exact same time, in the same way, so I added step_rand in there but it still didn't change anything. Next I tested removing cars and having only me near them, and they don't move at all.

        pursuePrey(atom/movable/a)
step_rand(src,4)
step_to(src,a)
if(bounds_dist(src, a)== 0)
attack(a)


In response to Chaorace
step_rand() moves the target in a random direction, I don't think this is what you need. Try changing sleep(50) to sleep(rand(30, 50))

Also, I'm not really sure what that range issue.. what is your world.view set to?
In response to Kitsueki
Kitsueki wrote:
step_rand() moves the target in a random direction, I don't think this is what you need. Try changing sleep(50) to sleep(rand(30, 50))

Also, I'm not really sure what that range issue.. what is your world.view set to?
    view        = "15x10"
map_format = TOPDOWN_MAP
mob = /mob/player
mob
step_size = 4
obj
step_size = 4


Tested again with no cars, they must not like the taste of players, they don't want to move toward or eat us =[

Sidenote:

        defaultidle()
step_rand(src)
sleep(20)
spawn() behavior()


Quick idle proc I threw together, just have them something to do until provoked. I removed cars and they didn't walk around randomly, but I know it's reading through the code because I put cars back and they moved toward them, so I know it's reading and calling correctly. This isn't as important as the above, so I'll probably fiddle with it until it works.

mob/Zombie
icon = 'Walker.dmi'
icon_state = "Walk"
New()
..()
spawn() defaultidle()
Yes, you would use step_rand() for simplicity.

Also, you nested the conditions wrong.

    proc
findPrey()
var atom/movable/target
for(var/atom/movable/a in oview())
var/obj/Vehicles/car/o = a
if(get_dist(src, a) < get_dist(src, target))
if(istype(a, /obj/Vehicles/car))
o = a
if(o.alarm)
target = o
if(ismob(a)) <-- This should be one step back
target = a <-- and this
return target <-- and this
I wish there was a way to show you what happens on my screen.

I fixed it like you said and now they walk toward you, woot they may be a little hungry... UNTIL... you walk out of their view, and back into their view, they get stuck in place and move up a few pixels and back down a few pixels. Sigh , AI is much harder then I originally thought it would be.

Edit: I think they're actually walking toward themselves and not me now that I think about it. I put 2 zombies in the map and they look like they're walking toward me but they're walking toward themselves, that can explain why it looks like they're stuck. Because they are infact mobs, but not players. If I have 1 zombie though, it walks toward me fine. I think I'd have to create a way to make it recognize zombie from players.

Sidenote: Do you think using oheareres instead of oview will give the zombies more range, and keep following after you forever, until a car alarm goes off, something like left 4 dead 2 kinda
Indeed, they're going towards other zombies. Just do a check to stop that. if(istype(a, /mob/Zombie)) continue

If you want to play around with the range, range() is available to you.

For that last bit, it'll require a little trickiness with the alarms and zombies. Give the zombies a target variable that gets set in their AI, and just have them go towards that. If their target is no longer near a car with an alarm, have them untarget.
The check worked, I don't know why I didn't think of that, I thought it'd be more difficult haha. Only thing I can't figure out is the defaultidle proc above, I have it so that even if they have no target like an object or mob, they'll still just randomly walk around like zombies usually do. But they just stand there still, I checked this by doing this if(istype(a, /mob/player)) continue so it would ignore mobs (there were no cars on the map at this time) and they just didn't move, it's probably just something really simple though.

Yeah I'll probably just keep it how it is, the range stuff is confusing. I was just guessing because I thought maybe I could make Zombies follow you around the hole map and not just in their view so you can feel like you're getting flooded with Zombies aha, because the game is basically survival. Like the Zombies in that Z level can follow you the hole map, until you change to the next Z level. I'll probably just wait for a more advanced programmer to come along and join the project because I'm a pixel artist. We just want to get a few things in so we can test and push out a demo.
In response to Chaorace
Just check if they have a target period, that should work if I'm understanding you right. Always try out new things, even if you don't quite understand where you'll go with it. Often times once you get to coding it, you start figuring it out along the way.

The more you struggle, the more sure you can be that you're moving towards being capable of doing whatever you want :)
        defaultidle(atom/movable/a)
New(src)
..()
spawn(rand(10,20))
step_rand(src,4)
spawn() behavior()


So I was just testing things to get the zombies to move around randomly and voila this worked.. thing is the zombies look like they're teleporting instead of walking and it causes such lag 26-30 CPU with 2 zombies. Next i tried indenting it like this,
        defaultidle(atom/movable/a)
New(src)
..()
spawn(rand(10,20))
step_rand(src,4)
spawn() behavior()


Seems no matter how I ident I still get the error, proc defintion not allowed inside another proc. Which I understand because it's be defining sometihng new inside of another proc..
In response to Chaorace
New() is a proc defined for when an object is created. defaultidle() is a proc, it does not have procs attached to it, so you cannot over ride what isn't there.

If you're trying to add in behavior which makes the zombies roam when they don't have a target, do that in behavior(), else you'll run into conflicting AI.
Page: 1 2