My question is related to understanding when and how LUA scripts are called by the game engine.
Sooner or later I'll need to know more, but for the moment I have a specific scenario, which I've explained below.
All I know at the moment (due to testing a few years ago) is that I can associate a LUA script with game objects (I think I coded a button that opened a door), and that monster scripts are executed when a player gets close enough (IIRC I modified an existing custom monster so it said something different
For my current scenario I'll definitely need to run scripts that are not called because a player is nearby (as I remember it, but from long ago, this is how think() is called?), nor by an action (like my simple "door-opening" script), nor by being called from a different script that's initiated due to player presence or an action (see the "members vs Alpha" scenario below.
If there's documentation that explains all this somewhere, a link would be a good answer. I don't mind reading first, and then returning to ask better questions.
The scenario I have in mind:
I'm considering writing a "Pack AI" script for monsters like wolves that should be in a group. The idea is to have:
Changing pack members location (so they patrol a large area) is (I think) a clear example where I'd need to be running code every tick.
For most ticks it wouldn't do much though (e.g. the game wouldn't have to execute much LUA code to move the pack around within a known territory).
Sooner or later I'll need to know more, but for the moment I have a specific scenario, which I've explained below.
All I know at the moment (due to testing a few years ago) is that I can associate a LUA script with game objects (I think I coded a button that opened a door), and that monster scripts are executed when a player gets close enough (IIRC I modified an existing custom monster so it said something different
For my current scenario I'll definitely need to run scripts that are not called because a player is nearby (as I remember it, but from long ago, this is how think() is called?), nor by an action (like my simple "door-opening" script), nor by being called from a different script that's initiated due to player presence or an action (see the "members vs Alpha" scenario below.
If there's documentation that explains all this somewhere, a link would be a good answer. I don't mind reading first, and then returning to ask better questions.
The scenario I have in mind:
I'm considering writing a "Pack AI" script for monsters like wolves that should be in a group. The idea is to have:
- A component (LUA script) that models an "Alpha" member that decides the pack's strategy, shares it via global "wolfpack state" variables, and updates it based on information from pack members
- Pack members that react normally - e.g. their AI script would be triggered by things like a Player Character being a certain distance away. Pack members would do things like:
- Share a possible target's location, so the rest of the pack could execute the current Alpha strategy (e.g. get together and attack as a group)
- Execute the current strategy, - which might be ignore, retreat, follow, or any one of a set of active combat strategies
Changing pack members location (so they patrol a large area) is (I think) a clear example where I'd need to be running code every tick.
For most ticks it wouldn't do much though (e.g. the game wouldn't have to execute much LUA code to move the pack around within a known territory).