A Future Pilot

How to check if NPC has already spawned

Recommended Posts

Hey everyone!

 

So I'm working on fixing the griff not spawning bug, and I've decided the best way to do it is by changing the OnEnter script of the Sand People Enclave module. I couldn't get the script to decompile, so I've actually modified the .ar file to point to a new script which then executes the default script.

 

Here's my script currently:

 

 

void main(){
  ExecuteScript("k_ptat20aa_enter", OBJECT_SELF);
 
  object oEntering = GetEnteringObject();
  object griff = GetObjectByTag("tat20_griff");
  // If we've talked to the Czerka officer about Griff and Griff hasn't already spawned
  if((GetIsPC(oEntering)) && (GetGlobalNumber("tat_MissCaptive") == 1) && (GetIsObjectValid(griff) == FALSE)) { 
 
    vector vPos;
    vPos.x  = 42.87;
    vPos.y  = 66.82;
    vPos.z  =   14.61;
      
    // This is the angle the NPC should be facing
    float fAngle = 180.00;
 
    location test = Location(vPos, fAngle);
 
    CreateObject(OBJECT_TYPE_CREATURE, "tat20_griff", test);
  }
}

 

Now the issue I'm running into right now is that it's spawning him even if he's already spawned from the original script BUT not from this script. So if I walk in the first time there are two griffs. I leave and come back, there are still only two griffs (so the GetIsObjectValid function is working for griffs spawned by my script, just not for the original griff spawned when the bug doesn't happen).

 

Why is the GetIsObjectValid function not working when the bug doesn't occur and griff is already spawned when my script runs?

 

Thanks!

Share this post


Link to post
Share on other sites

I figured out what was happening...apparently the script was checking GetIsObjectValid before Griff had actually spawned, which caused it to then spawn him. I was able to work around this by putting the body of the script into another .nss file, and then calling ExecuteScript with DelayCommand. Is there a better way to make a script pause before setting a variable? (ActionWait didn't work).

 

Thanks again!

 

 

EDIT: I was having a serious derp moment when I wrote the above. You can just create a function and then call it with DelayCommand.

 

 

As a side note, this whole way of fixing this bug is very much a "treating the symptoms" kind of thing, but I haven't been able to trigger the bug again on my own to be able to figure out what's actually causing it. If anyone has a save with this bug demonstrated, I'd be very appreciative if you could send it to me!

Share this post


Link to post
Share on other sites
Guest

On a similar note, I was wondering if there's any way to fool the game via KSE or something to reload a module you've already entered, in terms of generating NPC's etc. 

 

If not, I must be outta luck. 

Share this post


Link to post
Share on other sites

On a similar note, I was wondering if there's any way to fool the game via KSE or something to reload a module you've already entered, in terms of generating NPC's etc.

 

If not, I must be outta luck.

Extract the modules .git file from the .mod or if that's unavailable from the .rim. Drop the .git in the Override, load the Module, everything will be reset. Save and take the .git out from the Override again, or the Module will be reset every time you load it.

Share this post


Link to post
Share on other sites
Guest

Extract the modules .git file from the .mod or if that's unavailable from the .rim. Drop the .git in the Override, load the Module, everything will be reset. Save and take the .git out from the Override again, or the Module will be reset every time you load it.

How would I do that? Can't seem to open it with KOTOR TOOL.

Share this post


Link to post
Share on other sites

How would I do that? Can't seem to open it with KOTOR TOOL.

For most modules there are two rim files, one with a "_s" on the end, and one without. In Kotor Tool, expand the one without the _s and then expand "Dynamic Area Info". You should see the .git file there. Click on it, and then click "Extract File" over on the right hand side.

 

To actually edit it, you'll need a gff editor. My favorite is kgff which I got from a link posted by Fair Strides here: http://deadlystream.com/forum/topic/3552-does-anyone-have-a-working-download-link-for-a-gff-editor/?p=36625

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.