Constant global variable check framework

Started by Glenjamin, Tue 17/07/2018 17:47:40

Previous topic - Next topic

Glenjamin

I'm currently designing a game with many variables that change events in-game. I want to get the framework right at the start, let me know what you think.

Variable sets:


  • 12 hour day/night cycle based on in-game ticks.
  • Several NPC's throughout the map, each with a "behavior set" unique to each in-game hour.
  • These behavior sets are also modified by player-based variables. Is the player liked, has the player killed someone, what is the player wearing? (All controlled by int variables)

Day/night cycle seem pretty simple enough. After a certain amount of ticks, Hour += 1;. Once the hour reaches 12, hour = 0;.

I'm thinking of having a script that runs in every room, which checks the hour. The hour then determines the NPC script. Within the NPC script, it checks player-based variables, which then chooses the behavior.

This can get messy VERY quickly, so what do you think is the most efficient way of going about this?

Snarky

It doesn't sound all that daunting, but I would suggest isolating the logic in a module (or several modules, if there are separable elements of it). Also:

Quote from: Glenjamin on Tue 17/07/2018 17:47:40
  • These behavior sets are also modified by player-based variables. Is the player liked, has the player killed someone, what is the player wearing? (All controlled by int variables)

This sounds like a job for enums!

SMF spam blocked by CleanTalk