Skip to content

Npc_ExchangeRoutine: clear state if in daily routine - #1005

Open
thokkat wants to merge 1 commit into
Try:masterfrom
thokkat:exchange-routine
Open

thokkat wants to merge 1 commit into
Try:masterfrom
thokkat:exchange-routine

Conversation

@thokkat

@thokkat thokkat commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

In mod Npc_ExchangeRoutine is called in zs loop of daily routine and player state is immediately updated but not for non-routines states like ZS_Attack. Basically the same behavior we observed for routine end times. Git blame showed Npc_ExchangeRoutine used to be an immediate routine change but caused trouble with ZS_Talk.

I made the check for non-routine a function and added some extra checks to have more robustness. Old line is left as last decider. currentTarget==nullptr seems useful to track other states like ZS_ObservePlayer but actually don't know what's the difference between isTalk() and outputPipe->isFinished().

@Try

Try commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Hi, @thokkat !

Generally, yes makes sense. I'm bit worried, that this patch exposes even more usage isUnconscious() / isDead() / isAttack(). My general assumption, if we need to look directly into state type/name - then engine does something wrong.

Would it still achieve the purpose, if we keep isInDailyRoutine simplistic (check only for fn.isValid() && aiState.funcIni==fn) and reset state eTime, if excRoutine called at daily routine scope?

@thokkat
thokkat force-pushed the exchange-routine branch 2 times, most recently from 6cb9b7b to 28a7aad Compare November 19, 2026 15:57
@thokkat

thokkat commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

Removed explicit state check. Added a comment that states like ZS_Sleep are critical.

State end function would now still be called but shouldn't have great effect.

@Try

Try commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Added a comment that states like ZS_Sleep are critical.

  // TA_Sleep is bound to ZS_GotoBed which starts ZS_Sleep
  // ZS_Sleep inherits daily routine status

... do you mean "ZS_Sleep does not inherits daily routine status"?

@thokkat

thokkat commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator Author

I took the wording from AI_StartState comment to make clear vanilla behavior is not exactly matched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants