Sign in to follow this  
Salk

[KotOR scripting] GetObjectSeen()

Recommended Posts

Hello!

I was wondering if anyone has ever used the GetObjectSeen() function successfully in the KotOR game. I am trying to use it as trigger in the following code:

  while (GetIsObjectValid(oCreature)) {
   if (((GetStandardFaction(oCreature) == STANDARD_FACTION_HOSTILE_1) || (GetStandardFaction(oCreature) == STANDARD_FACTION_HOSTILE_2) || (GetStandardFaction(oCreature) == STANDARD_FACTION_INSANE))  && ((GetDistanceBetween(oCreature, oLeader) < 17.5) || (GetDistanceBetween(oCreature, oNPC2) < 17.5) || (GetDistanceBetween(oCreature, oNPC1) < 17.5))) {
     nCombatZone = 1;
   }
   oCreature = GetNextObjectInArea(GetArea(oSelf), OBJECT_TYPE_CREATURE);
  }
  if (IsNPCPartyMember(NPC_MISSION)) {
    int nUndisturbed = 0;
    if ((oNPC2 == OBJECT_INVALID) || (!GetObjectSeen(oNPC2, oMission))) {
      if ((oNPC1 == OBJECT_INVALID) || (!GetObjectSeen(oNPC1, oMission))) {
        nUndisturbed = 1;
      }
    }
    if ((GetGlobalBoolean("SURVIVAL_INSTINCT")) && ((nUndisturbed == 0) || (nCombatZone == 1) || ((!GetSoloMode()) && (GetPartyMemberCount() > 1)))) {
      AssignCommand(oMission, ClearAllEffects());
      SetGlobalBoolean("SURVIVAL_INSTINCT", FALSE);
    }
    if ((!GetGlobalBoolean("SURVIVAL_INSTINCT")) && (nCombatZone == 0) && (nUndisturbed == 1) && (GetSoloMode() || GetPartyMemberCount() == 1)) {
      AssignCommand(oMission, SurvivalInstinct());
    }
  }

The goal is to verify Mission does not detect the presence of other party members so I thought of GetObjectSeen() for the purpose. There is GetLastPerceived() but it is said to be used in OnPerception scripts and that is not my case.

Cheers!

Share this post


Link to post
Share on other sites
Guest Qui-Gon Glenn

Custom OnPerception event? Seems like that would work essentially how you want it to.

Share this post


Link to post
Share on other sites

Hello, Qui-Gon Glenn!

13 hours ago, Qui-Gon Glenn said:

Custom OnPerception event? Seems like that would work essentially how you want it to.

I thought about it too and it may be worth a try but I think there might be an issue when saving/loading the game.

 

void main()
{
     int nEvent = GetUserDefinedEventNumber();
     if (nEvent == 2002)
     {
          object oTarget = GetLastPerceived();
          if ((GetLastPerceptionSeen()) && GetIsPC(oTarget))
          {
            // Bonus off
          }
          if ((GetLastPerceptionVanished()) && GetIsPC(oTarget))
          {
            // Bonus on
          }
    
     }
}

Let's say I save the game after a party member was perceived. If I am not mistaken, the OnPerception event won't run when loading it again.

Share this post


Link to post
Share on other sites

If you want to get a better idea of what is going on, edit all the includes to change the debug logging functions to use SendMessageToPC and then recompile k_ai_master with them. The only limitation is that the feedback screen has a very small back buffer, so you'll need to be pausing every second to check it due to the volume of stuff that will be piped to it.

  • Like 1

Share this post


Link to post
Share on other sites
Guest Qui-Gon Glenn

I didn't read your OP thoroughly enough. Your use case probably excludes that, making my post a little silly in retrospect.

That said, my rusty out of tune brain thinks of setting a boolean. This could turn into lots of booleans, so probably a bad idea.

If I knock any cobbwebs loose I'll toss an idea.

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.

Sign in to follow this