Npcs and Fashion

Posted by Pirate-rob on June 14, 2012, 6:40 a.m.

Today I started on something I've been avoidng: Npcs. They are probably one of the biggest parts of the game and require the most code (in my opinion). So far I having been working on what actions they can do: moving, stabbing, shooting. I also have started to work on the pathfinding system. So far my Npc is running back and forth in a straight line.

You cannot see it but he is running back and forth non-stop

I have also added the code that can change clothes! Why? Because green is fashionable!

Green FTW!

Also I'm going to be making different armours for the defence stat.

Comments

DFortun81 11 years, 10 months ago

I posted an example on randomly moving NPCs back in '07. If anything, you should check it out. My logic style has changed a great deal from then, but it may prove useful to you.

Charlie Carlo 11 years, 10 months ago

This is the kind of thing I use for wandering

{
if round(random(100)) = 1{
            direction = round(random(3))*90;
            speed = 2;
            }
else
if round(random(80)) = 1{
            speed = 0;
            }
}

(Sorry if that doesn't make sense, I don't usually use GML)

Pathfinding, however, is a completely different story.

For a top-down game like this, you could use AI nodes.

Green is win.

Polystyrene Man 11 years, 10 months ago

With that code, your NPCs could potentially just walk in one direction forever… never to be seen again.

Pirate-rob 11 years, 10 months ago

I actually won't be using random wandering in this game. Most of the NPCs will have a predetermined path.

DFortun81 11 years, 10 months ago

Just be sure to have them check if their pathing location is not blocked. Can't tell you how many times a static npc has broken my movement logic with its automatic static pathing.

Cpsgames 11 years, 10 months ago

Step Event:
image_angle = random(360);

Done. It's perfect.