Jump to content


Photo

How to check if NPC has already spawned


  • Please log in to reply
6 replies to this topic

#1 A Future Pilot

A Future Pilot

    Jedi Apprentice

  • Members
  • PipPip
  • 24 posts

Posted 15 April 2018 - 10:25 PM

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!



#2 A Future Pilot

A Future Pilot

    Jedi Apprentice

  • Members
  • PipPip
  • 24 posts

Posted 16 April 2018 - 01:42 AM

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!

 

 

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!



#3 LucyTheAlien

LucyTheAlien

    Jedi Master

  • Members
  • PipPipPipPipPip
  • 899 posts
  • LocationNorthern Ireland

Posted 16 April 2018 - 02:06 PM

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. 


One will make the choice- all will make the journey.

#4 Kexikus

Kexikus

    Jedi Master

  • Members
  • PipPipPipPipPip
  • 1,555 posts

Posted 16 April 2018 - 02:22 PM

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.



#5 LucyTheAlien

LucyTheAlien

    Jedi Master

  • Members
  • PipPipPipPipPip
  • 899 posts
  • LocationNorthern Ireland

Posted 16 April 2018 - 03:48 PM

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.


One will make the choice- all will make the journey.

#6 A Future Pilot

A Future Pilot

    Jedi Apprentice

  • Members
  • PipPip
  • 24 posts

Posted 16 April 2018 - 04:29 PM

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....editor/?p=36625



#7 LucyTheAlien

LucyTheAlien

    Jedi Master

  • Members
  • PipPipPipPipPip
  • 899 posts
  • LocationNorthern Ireland

Posted 16 April 2018 - 10:18 PM

Got it, thanks! 


One will make the choice- all will make the journey.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users