Acting on time change without heartbeat?
fot1
Member Posts: 74
I understand that we should avoid heartbeat events as much as possible to improve the performance. Is it possible for creatures do an specific action without relying on the heartbeat script? By action I mean, for instance, equip a torch, or move to a waypoint.
If is not possible, I think would be great to have `onDawn`, `onNight`, `onDusk` and `onDay` events to avoid heartbeats.
If is not possible, I think would be great to have `onDawn`, `onNight`, `onDusk` and `onDay` events to avoid heartbeats.
0
Comments
Otherwise you could just use division and modulo for timed events on heartbeat since you cannot avoid heartbeats, it's probably superior to everything else you could come up with. If you don't check a time change event but want the engine to do it, then the engine checks the time change event. You can't get around the fact that something has to check and fire the event, there's no way to make it magically have zero cost, on the other hand the cost you do incur by making that check in the module heartbeat is not going to be significant at all.
The reason to avoid heartbeats is not at all a reason to never use them, but instead a reason to use them appropriately.
For example, a module heartbeat that sets a switch at dawn and dusk costs nothing. A heartbeat on every NPC that detects that probably won't break you, but you could restrict it to areas that actually contain a PC using area heartbeat. After all, equipping torches that no one can see is a waste of time.
Note that the official WalkWayPoints system already allows you to send NPCs to a different location at night.