How to make NPC move and turn end in turn-based game

I made a turn-based game. If playerTurn is True, the player can move. If player-turn is False, the NPC moves, and playerTurn toggles to true. However, the NPC does not move, and thus, the player’s controls are not restored, thus ending the entire game. How do I fix this?




As you can see, I have provided examples for most the code – it’s all in external events. There is one potentially essential screenshot I didn’t think to include until now: “pathfinders” only includes one event, which says that all pathfinders (NPCs and Player) are snapped to a virtual grid. Besides how their movement is performed, which isn’t entirely different, really, the player is different from the NPC in that it has a 3x3 grid set to its position, which hides every time it moves, and reappears each time it is done moving, and this grid may or may not effect the player’s movement if pathfinding is somehow disabled by snapping to a grid.

Your NPC is never choosing random directions or distances. The red boxes in the image below are only event conditions, of the subevent. They are the “If this is true” component of the event. All they are doing is checking if the direction and the 2distance values of NPC are the same as the random numbers generated.

You want to put the distance and direction variable assignment in the actions.

image

You are, unfortunately, absolutely right. By default, the value is 0, which isnt between 0 and 9, and thus, is not one of the 8 directions. This might not be a problem if I had not linked the change of turns strictly to movement in one of the 8 directions. Which I did. Maybe if I add the condition of their being hostile to all of this, I can make them do other stuff as well, or else, assign their activity to their unique ID number, but I’m starting out with the simplest basics, so I think I’ll save that for later. Thank you for using your brain.

1 Like