NPC behaviours / animations

Scripted ALFA systems & related tech discussions (ACR)

Moderators: ALFA Administrators, Staff - Technical

Locked
User avatar
AcadiusLost
Chosen of Forumamus, God of Forums
Posts: 5061
Joined: Tue Oct 19, 2004 8:38 am
Location: Montara, CA [GMT -8]
Contact:

NPC behaviours / animations

Post by AcadiusLost »

Ran into some of OE/Bioware's code for these while hunting through their default script handlers for on_spawn() - they have things set up for a number of options in addition to the scripted waypoints- there are also "mobile animations" or "immobile animations" which keep your mobs or townsfolk from standing like statuaries. It would be pretty easy to adapt these to our purposes, but at what level do we want to have the builder specify it?

1. On the spawn point, as Local Variable settings, along with the other settings like spawn times and such.

2. On the spawn point, by choosing a particular spawn_in script which applies the animations to the spawned children.

3. On the creature blueprint itself, as local variables defined in the toolset.

Thinking about it again, we could make all of these work, though we should have an order of precedence for them, in case they disagree.

I'd also like to make flocking an option, though I've not had a chance to look at that code yet. That will be on my list of "if we have time" for this update.
User avatar
Teric neDhalir
Githyanki
Posts: 1495
Joined: Mon Jan 05, 2004 10:04 pm
Location: Manchester UK

Post by Teric neDhalir »

Well at the moment, with the default spawn-in script inside a wrapper of the ACR default spawn-in it's a bit tricky altering any of the settings. Unless adding lines from the default into a script based on the alfa default works?

I would prefer variables on the creature blueprint, personally, because I don't spawn everything.

TnD
User avatar
AcadiusLost
Chosen of Forumamus, God of Forums
Posts: 5061
Joined: Tue Oct 19, 2004 8:38 am
Location: Montara, CA [GMT -8]
Contact:

Post by AcadiusLost »

For the update I'm pulling some of the default AI code out of our events- the question is which parts to leave in, in one way or another. Currently as I remember it, the default scripts all check for variables on the blueprint anyway- potentially you could set those in a customized version of the acf_cre_onspawn or on the blueprint itself, though you have to hunt for their (very minimal) documentation to do so currently.

Is it worth coding some handling to offer greater ease of use? ex: commented settings inside the acf_cre_onspawn which get applied to the creature by the ACR's functions?

For that matter, is having builders make alternate versions of acf_cre_onspawn.nss for use with some of their blueprints going to be our recommended method of setting AI & behaviour preferences (as we did in NWN1), or are we trying to keep the default acf_cre_onspawn in place, and have builders define a local string on the blueprint to point at their customizing script?
User avatar
indio
Ancient Red Dragon
Posts: 2810
Joined: Sat Jan 03, 2004 10:40 am

Post by indio »

Easiest way would be to create an importable variable to the NPC properties with the line:

X2_L_SPAWN_USE_AMBIENT_IMMOBILE

or

X2_L_SPAWN_USE_AMBIENT

Set that to 1 and it all works fine.
Image
User avatar
ç i p h é r
Retired
Posts: 2904
Joined: Fri Oct 21, 2005 4:12 pm
Location: US Central (GMT - 6)

Post by ç i p h é r »

With the HotU expansion, Bioware finally got smart and converted all their AI behavior options into a single integer bitmask. It's a vastly more effective way to implement boolean spawn in options than requiring custom script sets for every creature. The latter can lead to enormous clutter in the toolset and module bloat. IMO, it would be wise not to go down that road again.
Thangorn
Haste Bear
Posts: 2081
Joined: Fri Oct 01, 2004 1:00 pm
Location: Queenstown, New Zealand

Post by Thangorn »

1. On the spawn point, as Local Variable settings, along with the other settings like spawn times and such.
That would be my preference..

Putting stuff like animations automatically in onspawn scripts leads to oddities and immersion breaking when DMing..

Having the ability to turn on looping and fireforget animations on your NPCs with a DM wand/GUI function would be awesome though.
Every time your PCs logged in to sit around in the inn and RP (which, lets face it is at least 30-50% of ALFA PCs behaviour) you could have completely new NPCs talking, a new bard on stage, that sort of thing..
On indefinite real life hiatus

[22:52] <Veilan> obviously something sinister must be afoot if a DM does not have his social security number in his avatar name!
User avatar
ç i p h é r
Retired
Posts: 2904
Joined: Fri Oct 21, 2005 4:12 pm
Location: US Central (GMT - 6)

Post by ç i p h é r »

There was a system called NPC Activities which allowed a builder to configure NPC behaviors (fire animations, scripts, etc) at various waypoints. It was a really neat system that I thought OE was going to package in with NWN2, but I forgot about it until now.
User avatar
indio
Ancient Red Dragon
Posts: 2810
Joined: Sat Jan 03, 2004 10:40 am

Post by indio »

I currently get persistent animation the following way:

Load gb_heartbeat_sp into the onSpawn

Then add this to your OnUserdefined:
#include "ginc_wp"

const int EVENT_USER_DEFINED_PRESPAWN = 1510;
const int EVENT_USER_DEFINED_POSTSPAWN = 1511;

void main()
{

string sAnim1 = GetLocalString(OBJECT_SELF, "sAnim1");

int nUser = GetUserDefinedEventNumber();

if(nUser == EVENT_HEARTBEAT ) //HEARTBEAT
{

int iCurrentWP = GetCurrentWaypoint();
//ActionSpeakString("Debug", TALKVOLUME_TALK);
FaceAndPause(iCurrentWP, 10.0);
PlayCustomAnimation(OBJECT_SELF, sAnim1, 1, 0.5);
}
}
Add sAnim1 to your NPC's variables and then include the animation name: forge01 (I've got a full list I'll post later).

Place down 2 waypoints and set them as walkable for the PC. Now put the 2 waypoints directly on top of each other.

The NPC will spawn in and perform their animation on the spot for as long as they are spawned.

This is the only way I could get animations to work,
Image
User avatar
indio
Ancient Red Dragon
Posts: 2810
Joined: Sat Jan 03, 2004 10:40 am

Post by indio »

ç i p h é r wrote:There was a system called NPC Activities which allowed a builder to configure NPC behaviors (fire animations, scripts, etc) at various waypoints. It was a really neat system that I thought OE was going to package in with NWN2, but I forgot about it until now.
NPC Activities doesn't work in NWN2 and probably won't be updated given the author's other commitments (no longer working on NWN stuff at all). We've got scripted waypoints though:

http://nwn2forums.bioware.com/forums/vi ... &forum=114
Image
Locked