r/howdidtheycodeit • u/ah7madaj3 • Nov 16 '23
Question How did they code Npc routine
In games like harvest moon each character have multiple places and routine like drinking in the bar between 6_7 cut the woods 4 days in the week they might go to they pathfind to thier target and most importantly they react to whats going on (rain,events,seasons,time of day, place activities and gifts) what kind of system can be made to manage all of these things.
6
Upvotes
View all comments
Show parent comment
2
u/SuperSathanas Nov 16 '23
No problem. I'll say again, though, that this is just a real quick and dirty, naïve example. For smaller projects, where you're not hitting CPU bottlenecks, worried about cache lines or trying really hard to organize your data well, you can take something like this and make it work well enough. When actually implementing something like a scheduling or task system, I'd think harder about what you actually want to live in those structs/classes. That "isActive" bool in the NPCSchedule class is better implemented more like a flag in a bit field separate from the objects and lists of objects themselves that you can iterate over.