Another one

Here is another one for you guys.

I have a PC and NPC henchmen in party. I’d like to jump the npc to the ‘belly’ of a lurker for example and keep the NPC at original location. I know how to do all this, but I was wondering how do I keep the NPC at original location fighting the lurker for example? Don’t I have to raise the AI level?

You can use SetAILevel to improve the chances of NPC actions being completed when the PC is absent.

AI_LEVEL_HIGH works fine in single player on today’s hardware, without noticeably degrading performance.

I’ve only used this to a very limited extent.

SetAILevel following by a series of actions works reliably for things like setting up a new scene (e.g. NPC moves to exit, jumps to a different area, changes costume, sits down / plays animation / walks waypoints etc). By the time the PC arrives at the new area, all those actions will be complete.

This works for multiple NPCs.

Without SetAILevel, actions issued to NPCs in areas with no PC either execute very slowly (minutes rather than seconds) or not at all.

I’ve noticed that movement actions tend to be instant if there’s no PC around.

I’ve no experience of running combat in the PC’s absence, though. I imagine that would be much more complicated, as it requires coordination of at least two creatures, over an extended time period, during which AI level might drop. Not sure whether the engine is designed to do it.

Once the PC is “swallowed” there are emulation options, for example

  • Brief cutscene of the PC in the belly, then cut to NPC fight using invisible PC as a camera
  • Move the PC to the belly, stop the actual fight, issue feedback messages to the PC as though the fight was continuing

Thank you for helping me. My understanding is AI does determine allocation of engine time slice as you stated, but if you look closely at some of the default scripts what you see is if AI is below a certain level the script just returns.

any comments on this?

That’s how it’s implemented. At least partially. When the game drops the AI level of NPCs (last PC leaves area say) then they will stop doing some of their AI scripts. That check you mentioned is how that’s done.

The problem with setting the AI level yourself is that once you do I believe the game will no longer auto adjust that NPC. This can lead to issues with combat.

There is some useful discussion of AI level here but it doesn’t entirely answer the question.

I have cases where an NPC executes a set of actions at elevated AI level in the absence of a PC, then, much later, engages in conversation and/or combat when the PC enters. In that special scenario, all appears to work normally.

All the same, I share your unease.

We know for sure that AI level must be raised to ensure actions are executed promptly in the absence of a PC, not least because of the cutout in the default scripts.

What could be established experimentally (using GetAILevel) is whether the engine drops the AI level normally on completion of the actions, and subsequently adjusts the AI as expected on PC entry and combat.

And for the same reasons you did not want to figure why assigncommand() from placeables sometimes fails… :slight_smile:

Fair point, but in that case, we had a seemingly-infallible alternative, whereas here we have something that kinda works, but might be risky.

After several tests, I find that’s true, but there is a simple remedy. After assigning actions at some elevated AI level,

  AssignCommand(oNPC, ActionDoCommand(SetAILevel(oNPC, AI_LEVEL_DEFAULT)));

That effectively hands control back to the engine (whereas setting any other value does not).

1 Like

Incidentally, I find that the Lexicon definition of AI_Level_* is reliable, with one exception - NPCs in the PC’s area, visible or otherwise, all seem to be LOW unless they are in combat, which is NORMAL.

I hesitate to edit the page, as I’ve only done limited tests, excluding associates, and it probably doesn’t matter much.

Where there are minor differences between the constant definition and the narrative under GetAILevel, the constant definitions seem to be correct.

Thank you all for your comments. NO, once you set a AI level the game does not auto assign AI. You have to re issue the DEFAULT -1 level for autoassign on the creature

FYI. A good example is I have a module I’m messing with (S4) pnp module which as a full area which has placed creatures and placed NPC(s). once the player enters, they start fighting. Before the player enter they just stand there. Now they are technically hostile to each other! It’ the play arriving which changes the AI level and starts the combat by the ‘return’ not occurring on the heartbeat script.

Anyone wanna try this module with me? I’m re witting it to work properly.

You can make the inside of the lurker to be the same area as the outside, just different rooms?