<firmly planting...>
Background: Trying to build a little ambient behavior into the Rogues demo mod. In this case, the Mistress of Mischief will choose a random target (from an eligible list), go into stealth mode, walk to a position directly behind them (which was a real pita, btw. pathfinding to locations sucks). Then she executes this little gem.
Originally, this script fired from onEnter when she entered a specific trigger placed behind the target. But targets move/get moved. Didn't like that. So I have a dynamically generated WP drop on the location and she moves to object instead. Works great.
Problem: When the script was fired from trigger, it worked correctly as long as target was within 3m of trigger. Specifically, the target spoke his lines and spasmed. Now, with the exact same code on those lines, only 2 out of 5 targets spasm. They all speak their lines, so I know the oTarget is valid and correct. But on the dwarf, elf and ogre, no spasm. On the half-elf and dragon, spasm.
Eh?
// Executing a noogie
void main()
{
// Get Mistress
object oOwner = GetObjectByTag("Mistress");
object oTarget = GetLocalObject(oOwner,"oTarget");
if (GetDistanceBetween(oOwner, oTarget)<=3.0f) // Noogie if close enough
{
// Make Owner yell "Noogie!" and stop hiding
AssignCommand(oOwner, SpeakString("NOOGIE!",TALKVOLUME_SHOUT));
SetActionMode(oOwner,ACTION_MODE_STEALTH,FALSE);
// Make target spasm and say "Stop that!"
AssignCommand(oTarget, ActionPlayAnimation(ANIMATION_LOOPING_SPASM,1.0f,2.0f));
AssignCommand(oTarget, SpeakString("Gah! STOP that!",TALKVOLUME_TALK));
// Make Owner giggle
AssignCommand(oOwner, SpeakString("Teehee!",TALKVOLUME_TALK));
AssignCommand(oOwner, PlaySound("as_pl_laughingf3"));
}
// Make run back to POST_(owner)
string sTagName = "POST_"+GetTag(oOwner);
AssignCommand(oOwner, ActionMoveToObject(GetObjectByTag(sTagName),TRUE, 1.0f));
}
I had hoped to put in some variation (different responses, an opposed spot-check to stop the noogie, a couple other little things), but I simply can't spend any more time on this :-(
Can anyone tell me why the ActionPlayAnimation is inconsistent?
Edit: And even cut and pasted from the NwN script editor, this board still mangles it. Now I have a headache <yes?>
No, I mean a real headache. <oh, sorry, boss>
Edit 2: Moved the "Abandon Stealth" bit above the distance check. She'll abandon stealth regardless of success and run back to POST.
<...his hat on his head>
Modifié par Rolo Kipp, 12 février 2012 - 10:40 .