Using the NPC AI Escort Setting

Post » Sun Nov 22, 2009 10:25 pm

I have the player enter into a hallway through a loading door. Immediately after the door, there are a few skeleton guards. One of them gestures to the player to follow. What I would like to do is have the skeleton's greeting forced upon the player as soon as he/she comes through the door. After issuing the greeting, the skeleton begins to escort the player to wherever it's going. I have the greeting set up in the skeleton's dialog and in the Remarks section, i've put this:

ForceGreeting
"THM_skltn escort"->ForceGreeting

I also have the Escort package selected in the AI section of the skeleton. What's actually happening is the player walks through the door, and rather than force a greeting, the skeleton starts escorting the player without saying anything. How do I get the skeleton to do what I want?

Another thing i'd like to add is I know there's a small script to detect whether an NPC/Creature is in combat, and if so, any followers with this script added will attack along with the NPC/Creature. I can't think of what the script is at the moment, but I have it written down somewhere. For example, there are a few skeleton guards along with the escorting skeleton mentioned above. These other skeletons will follow the player to his/her destination, keeping a close eye on their actions. As the group goes further into the ruins, they will come across other guards of different types. All in all, within this group, there are about 3 or 4 different ID's. My question is this: Can I have all of these guards set up so that if any guard is attacked by the player, ALL guards will join in the fight?
User avatar
Sxc-Mary
 
Posts: 3536
Joined: Wed Aug 23, 2006 12:53 pm

Post » Mon Nov 23, 2009 12:39 am

I missed this earlier - I was experiencing my own scripting crisis.

First I would recommend not adding the AIEscort package as part of the creature's ID. I think you will find it easier to control if you run it from a script (attached to the skeleton).

Since this is a load door the skeleton's local script will not run until the player enters the cell, but you could place a distance check (or check x- y-coordinates) for the player's position in the cell. If this is the first time the player will enter the cell, then no further check is necessary.

The forced greeting needs to be in a do-once block on the skeleton's script. I suggest running a timer to create a 1 second (more or less) delay so the greeting is not so abrupt, then trigger the greeting. You can start the AIEscort package either from dialog results, or have dialog results toggle a flag to trigger it from the skeleton's script

For detecting combat, take a look at http://planetelderscrolls.gamespy.com/View.php?view=Mods.Detail&id=4085.

Once combat has started you can script other guards to join it using StartCombat.

If you are uncertain about how to script any of these elements post again.
User avatar
ILy- Forver
 
Posts: 3459
Joined: Sun Feb 04, 2007 3:18 am

Post » Mon Nov 23, 2009 5:28 am

Yeah, that all makes sense. But unfortunately i've never got the hang of scripting. This will be used the first time the player enters through the doorway. After that, they will be allowed to walk where they please. Basically, if the player attacks anyone within the cell (it is underground with a few different types of guards around plus a leader), everyone will attack the player on sight. I wonder if there's an easy way to do that since it's all contained within the same cell.
User avatar
pinar
 
Posts: 3453
Joined: Thu Apr 19, 2007 1:35 pm

Post » Sun Nov 22, 2009 7:41 pm

Sorry. I was out of town for several days and lost track of this thread.

I suggest creating a hidden activator with the following script attached:

Begin THM_CellScriptshort doOncefloat timerif ( doOnce == 1 )    returnendifset timer to ( timer + GetSecondsPassed )if ( timer < 1 )    returnendifset doOnce to 1"THM_skltn escort"->ForceGreetingEnd THM_CellScript

This code has not been tested. You can change the duration of the timer delay.

The greeting you want your skeleton to use must be very narrowly filtered - you want it to be used only once. If there it a journal associated with these events, filter the greeting for the expected journal index and then update that the journal in the greeting's dialog results. That will prevent it from being used again. Also in dialog results you will assign the AIPackage. AIEscort requires the destination coordinates that I do not know so I will illustrate using variables. You will need to determine the coordinates of the destination and update the instructions:

AIEscort player 0 x y z

You describe that the other skeletons will follow the player (escorting from behind). To achieve this you need lines in dialog results that look like this:

"THM_skltn_ID" AIFollow player 0 0 0 0

I do not know how far a journey this is or if there are any obstructions. A pathgrid will greatly improve the chances of success. Since this appears to be a new interior cell you can add a pathgrid without concern for how it would be affected by other mods.

The attack AI is also difficult for me to construct for you since I do not know the exact circumstances that you would have this happen. Detecting combat is problematic as I first posted. Also if combat should break out between the player and the escorting skeleton the other skeletons (because they are following the player) will ally with the player against the escorting skeleton.

You might dabble with OnPCHitMe, GetAttacked and GetTarget. A script on the escorting skeleton would need to include code like this:

short OnPCHitMeif ( OnPCHitMe == 1 ) ; player has attacked skeleton    set OnPCHitMe to 0 ; makes this action do-once    SetFight 100 ; for skeleton that is attacked    SetFlee 0 ; for skeleton that is attacked    StartCombat player ; for skeleton that is attacked    "THM_skltn_ID"->SetFight 100 ; for each other skeleton    "THM_skltn_ID"->SetFlee 0 ; for each other skeleton    "THM_skltn_ID"->StartCombat player ; for each other skeletonendif

or…

short doOnceif ( doOnce == 0 )    if ( GetAttacked == 1 ) ; player has attacked skeleton        set doOnce to 1 ; do not repeated start combat        SetFight 100 ; for skeleton that is attacked        SetFlee 0 ; for skeleton that is attacked        StartCombat player ; for skeleton that is attacked        "THM_skltn_ID"->SetFight 100 ; for each other skeleton        "THM_skltn_ID"->SetFlee 0 ; for each other skeleton        "THM_skltn_ID"->StartCombat player ; for each other skeleton    endifendif

or…

short doOnceif ( doOnce == 0 )    if ( ( GetTarget player ) == 1 ) ; skeleton has targeted player (presumably attacked)        set doOnce to 1 ; do not repeated start combat        SetFight 100 ; for skeleton that is attacked        SetFlee 0 ; for skeleton that is attacked        StartCombat player ; for skeleton that is attacked        "THM_skltn_ID"->SetFight 100 ; for each other skeleton        "THM_skltn_ID"->SetFlee 0 ; for each other skeleton        "THM_skltn_ID"->StartCombat player ; for each other skeleton    endifendif

None of these scripts have been tested. You may require a version of whichever one of the three scripts you choose to be attached to the 'guard' skeletons since the player could attack on of them first. Otherwise the remaining skeletons will not react to the player's attack.
User avatar
Jerry Jr. Ortiz
 
Posts: 3457
Joined: Fri Nov 23, 2007 12:39 pm

Post » Sun Nov 22, 2009 7:46 pm

Ok. I'll definitely test those out once I get some sleep and feel more refreshed to do anything complicated. I'll let you know how things go.
User avatar
Sarah Unwin
 
Posts: 3413
Joined: Tue Aug 01, 2006 10:31 pm


Return to III - Morrowind

cron