Jump to content

Home

Scripting animations: How to...


T7nowhere

Recommended Posts

I need some help with scripting animations.

 

The first thing I would like to know is it possible to script a fake fight with just the PC. I know that sounds strange, But I would like to be able to trigger a script via an Armband (Or something) that will make the PC start fighting the air for about a minute.

 

The second is Scripting a sequence of animations. What I would like is for the npc to walk up to an placable ( I haven't been able to find a way to do this yet. I can make the npc run to a waypoint that is created first But the npc doesn't get close enough to the placable) in this case a workbench Fake building a weapon and then equipe and flourish it.

 

I have managed to sorta do this But the npc runs (seems to ignore the USE_COMPUTER animation and just equipes the weapon and flourishes it. So I suppose its the timming But I have been playing with it for a few days now and I still don't have it right.

Link to comment
Share on other sites

Originally posted by T7nowhere

The first thing I would like to know is it possible to script a fake fight with just the PC. I know that sounds strange, But I would like to be able to trigger a script via an Armband (Or something) that will make the PC start fighting the air for about a minute.

If you know the id #s of the attack animations that you want, then you can just use ActionPlayAnimation. Check out a_master_teach.nss (global script) for an example showing how the Jedi Masters demonstrate special moves to you when they teach you a form.

 

 

Originally posted by T7nowhere

The second is Scripting a sequence of animations. What I would like is for the npc to walk up to an placable ( I haven't been able to find a way to do this yet. I can make the npc run to a waypoint that is created first But the npc doesn't get close enough to the placable) in this case a workbench Fake building a weapon and then equipe and flourish it.

Have you tried specifying a location instead of an object? I had the same issue when trying to use a waypoint or the workbench itself as the destination, but when I specified a location right next to the workbench, my PC managed to walk close enough. Specifically, this was the specific command I threw into an armband script to make my PC walk up to the workbench in 906MAL:

AssignCommand( GetFirstPC(), ActionForceMoveToLocation( Location( Vector( 99.9922, -39.9754, 3.0 ), -93.7575 ), FALSE, 0.0 ) );

 

 

 

Originally posted by T7nowhere

I have managed to sorta do this But the npc runs (seems to ignore the USE_COMPUTER animation and just equipes the weapon and flourishes it. So I suppose its the timming But I have been playing with it for a few days now and I still don't have it right.

I guess it might help if you posted what you have. I've actually been having some trouble with the computer usage animation as well for a cutscene (it won't play the second time).

Link to comment
Share on other sites

Originally posted by T7nowhere

I need some help with scripting animations.

 

The first thing I would like to know is it possible to script a fake fight with just the PC. I know that sounds strange, But I would like to be able to trigger a script via an Armband (Or something) that will make the PC start fighting the air for about a minute.

 

You could probably use CutsceneAttack() and an invisible target dummy for this. See for example the cutscene on the Ebon Hawk where the Handmaiden punches air in the cargo hold while arguing with Atton.

 

Here's that script she uses as an example:

 

// ST: a_atthand.nss (a_atthand.ncs in 003EBO_s.rim)

#include "k_inc_generic"

void main() {
   int nParam = GetScriptParameter(1);
   object oMaiden = GetObjectByTag("Handmaiden");
   object oInvis = GetObjectByTag("MaidInvis");
   object oAtton = GetObjectByTag("Atton");

   switch (nParam) {
       case 1:
           ChangeToStandardFaction(oInvis, STANDARD_FACTION_FRIENDLY_1);
           ChangeToStandardFaction(oMaiden, STANDARD_FACTION_FRIENDLY_2);
           AssignCommand(oMaiden, ActionDoCommand(CutsceneAttack(oInvis, 479, ATTACK_RESULT_MISS, 0)));
           break;
       case 2:
           break;
   }
}

 

Originally posted by T7nowhere

The second is Scripting a sequence of animations. What I would like is for the npc to walk up to an placable ( I haven't been able to find a way to do this yet. I can make the npc run to a waypoint that is created first But the npc doesn't get close enough to the placable) in this case a workbench Fake building a weapon and then equipe and flourish it.

 

I have managed to sorta do this But the npc runs (seems to ignore the USE_COMPUTER animation and just equipes the weapon and flourishes it. So I suppose its the timming But I have been playing with it for a few days now and I still don't have it right.

 

Wouldn't something like this work? I don't know what's supposed to run your script, or where it is going to be run, so I've tried to be a bit general. Give it a waypoint that's somewhere within a clear line of sight of the workbench to start...

 

#include "k_inc_generic"

void ST_FaceObject(object oTarget, object oSource=OBJECT_SELF) {
   AssignCommand(oSource, SetFacingPoint(GetPosition(oTarget)));
}

void DoWorkbenchScene() {
   object oWorkbench = GetObjectByTag("Workbench");
   object oItem = CreateItemOnObject("weap_to_create", OBJECT_SELF, 1,TRUE);

   GN_SetSpawnInCondition(SW_FLAG_AI_OFF, TRUE);

   ClearAllActions();
   ActionForceMoveToLocation( GetLocation(oWorkbench), FALSE, 6.0 );
   ActionDoCommand(ST_FaceObject(oWorkbench));
   ActionWait(0.5);
   ActionPlayAnimation( ANIMATION_LOOPING_USE_COMPUTER, 1.0, 6.0 );
   ActionWait(0.5);
   ActionEquipItem( oItem, INVENTORY_SLOT_RIGHTWEAPON );
   ActionWait(0.5);
   ActionDoCommand( CreatureFlourishWeapon(OBJECT_SELF) );

   ActionDoCommand(GN_SetSpawnInCondition( SW_FLAG_AI_OFF, FALSE ));
}

void main() {
   object oPC = GetObjectByTag("npctag");
   object oWP = GetObjectByTag("waypoint");

   AssignCommand(oPC, JumpToLocation(GetLocation(oWP)));
   DelayCommand(1.0, AssignCommand(oPC, DoWorkbenchScene()));
}

 

This should, at least in theory, move the npc somewhere in front of the workbench, make them walk up to it, play some animation for 6 seconds, equip the weapon and flourish it. In theory. :)

Link to comment
Share on other sites

Ok the workbench script worked and I'm assuming that the npc should jump to the workbench.

 

Stoffe in your script there is the line #include "k_inc_generic" odd thing happend with the include nss, I got a bunch of "Error: Undeclared identifier". SO I tried it with out the include in my compile folder and the script seems to be ok without it.

 

Should the npc have walked to the workbench? Its not a big deal I could use a fade.

 

Thanks for supplying the Handmaiden script source. I'll have to play with that tommorrow. :)

 

Oh btw, Do you know what makes the npc's (when on the ebon hawk) resume what they were doing after you talk to them.

Link to comment
Share on other sites

Originally posted by T7nowhere

Stoffe in your script there is the line #include "k_inc_generic" odd thing happend with the include nss, I got a bunch of "Error: Undeclared identifier". SO I tried it with out the include in my compile folder and the script seems to be ok without it.

 

The k_inc_generic script includes a whole bunch of other include files on its own, more specifically "k_inc_gensupport", "k_inc_walkways" and "k_inc_drop". You'll need those as well to compile.

 

That said, the handmaiden script does not need anything from those includes, I guess it's just some leftover junk from a previous version of that script.

 

The script I wrote however use it for the GN_SetSpawnInCondition() function and the SW_FLAG_AI_OFF global. It's used to block out the creature AI to make sure your action queue remains undisturbed. (Though since that function is just a wrapper for SetLocalBoolean I suppose you could set it directly if for some reason you can't get the includes to work.)

 

Originally posted by T7nowhere

Ok the workbench script worked and I'm assuming that the npc should jump to the workbench.

 

Should the npc have walked to the workbench? Its not a big deal I could use a fade.

 

It should jump to the waypoint somewhere near the workbench and then walk up to the workbench. If it can't reach it within 6 seconds it should jump there instead.

 

Originally posted by T7nowhere

Oh btw, Do you know what makes the npc's (when on the ebon hawk) resume what they were doing after you talk to them. [/b]

 

You mean T3M4 rolling around and Kreia/Visas meditating? It's handled by their UserDefined heartbeat scripts, which fire automatically when they are no longer in conversation or have their AI blocked. IN T3's case he (it?) is simply walking waypoints using the standard waypoint handling script.

 

The code that makes them do what they are doing is in the include file "k_oei_hench_inc" in Scripts.bif if you want to check it out.

Link to comment
Share on other sites

Originally posted by Xcom

There is a bug in k_ai_master (or maybe it was k_inc_generic) that prevents creatures from resuming walking their waypoints after a conversation.

 

T3M4 has it's own fix for that though in "k_oei_hench_inc", restarting waypoint walking (if appropriate) to continue repairs on the Hawk after ending a conversation.

 

It probably wouldn't be that hard to fix, though personally I prefer it this way, since getting scenery NPCs to stop walking around (by talking to them) makes some unbearably slow areas of the game run much smoother (for example the Residential area on Citadel Station). The pathfinding in the Aurora/Odyssey engines is atrociously heavy on the CPU, at least on my computer. :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...