I've been having some problems spawning a party member within the Ebon Hawk in K1. Mainly the fact that the party member only appears in the intended spot if the game is saved and then reloaded.
I use this script...
void main(){
int nTest = GetGlobalNumber("TAR_CALOBARFIGHT");
object oEntering = GetEnteringObject();
if (GetIsPC(oEntering))
{
if (nTest == 50)
{
vector vPosition=Vector(23.03,52.95,1.80);
location lWhereToSpawn=Location(vPosition,270.0);
object oNPC = SpawnAvailableNPC(NPC_BASTILA, lWhereToSpawn);
}
}
ExecuteScript("k_pebo_skybox2", GetArea(OBJECT_SELF));
}
The Party Member occupies Bastila's spot, so naturally the standard ebo_m12aa onenter script (which is executed after under the name "k_pebo_skybox2") is going to spawn the party member in Bastila's normal position.
But I think this custom script should override that by default, as it's run before it. And it does, but the script only takes effect should the game be saved and reloaded within the module. Then the NPC is moved the correct spot.
I have an on why this is happening though. Looking at what KOTOR Tool tells me... the SpawnAvailableNPC function spawns a NPC from the list of available creatures... so for the script to actually work, the NPC needs to be present in the module in the first place... which makes sense, because when you save and load it, the npc has already been spawned in by the normal onenter script that is RUN after the custom script. And so it takes effect, and the NPC is spawned in the right place.
Just a guess though...
Also, I'm using the SpawnAvailableNPC function because it's the only way I know of spawning the NPC which reflects it's current appearance (aka, weapons equipped, armour and so on...)
Does anybody have any ideas on how I would spawn the NPC into the correct place without having to do the save/load routine?
Nevermind, I've figured out an alternative solution.