Skip to content

Acting on time change without heartbeat?

fot1fot1 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.

Comments

  • FreshLemonBunFreshLemonBun Member Posts: 909
    You could prepare an action ahead of time by using delay command. I don't think that would really be a good system if you have so many scripts things queued up like that.

    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.
  • ProlericProleric Member Posts: 1,316
    Heartbeat processing is rarely a problem on today's hardware, as long as you're sensible.

    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.
Sign In or Register to comment.