Author Topic: Completely Lost  (Read 386 times)

Legacy_Urk

  • Sr. Member
  • ****
  • Posts: 253
  • Karma: +0/-0
Completely Lost
« on: May 31, 2014, 06:45:25 am »


               

I feel so stupid asking this, but I've been working on it for 3 days with absolutely no success. I've hit a brick wall. I know how stupid this is, but I just can't figure it out. 


Here's what I'm trying to do. 


 


PC asks bartender about jobs. Bartender says to go to quest door. Map pin enables at quest house. 


Here is the action script attached to the barkeeps covo node... 


 


#include "x0_i0_partywide"

 

 

void main()

{

    object oTarget;

 

    // Get the PC who is in this conversation.

    object oPC = GetPCSpeaker();

 

    // Set a local integer.

    SetLocalIntOnAll(oPC, "StachleyMapped", 1);

 

    // Unlock "WidowStachleyDoor".

    oTarget = GetObjectByTag("WidowStachleyDoor");

    SetLocked(oTarget, FALSE);

    SetMapPinEnabled(GetObjectByTag("WidowStanchleysHome"), 1);

}

 

As you can see I used LS-TK to generate it and modified it with the map pin command. 

 

It's not working. The script compiles but when I test the module no map pin appears, and the quest door stays locked. 

 

I know I must be doing something totally stupid because this isn't my first module. I'm no scripter, but I'm also not a complete noob. 


While researching I found a forum thread that suggested the map pin command needed to be in the same area as the pin waypoint so I tried enabling it in a separate script using the integer variable in an if/then. Nothing.

 


ARRRGHHHH. What am I doing wrong!



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Completely Lost
« Reply #1 on: May 31, 2014, 11:46:17 am »


               

When I get this sort of error, 99% of the time it's because the tag in the script doesn't exactly match the tag on the object. If you can't see a typo, check with statements like this:
 


oTarget = GetObjectByTag("WidowStachleyDoor");
SendMessageToPC(oPC, "Door=" + GetTag(oTarget));

That will display Door=WidowStachleyDoor if the tag is correct.

Note that the waypoint needs to have the "Waypoint Contains a Map Note" flag checked on the Advanced tab.

Also worth checking that you don't have more than one object with the same tag (as a result of copying waypoints, for example).

IIRC it is OK for a creature to issue these commands to objects in another area, rather than AssignCommand to the object in question, but if all else fails you could try that.


               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Completely Lost
« Reply #2 on: May 31, 2014, 11:52:11 am »


               
Looking at your script I would say that the issue is in the lines I have bolded. Instead of setting the variable on the PC, set it on the area where the map pin needs to be enabled. Then, create an OnEnter script for that area and execute the map pin command and the door unlock code in that script. I'll give an example of each below your original code.

 

#include "x0_i0_partywide"

void main()

{

    object oTarget;

 

    // Get the PC who is in this conversation.

    object oPC = GetPCSpeaker();

 

    // Set a local integer.

    SetLocalIntOnAll(oPC, "StachleyMapped", 1);

 

    // Unlock "WidowStachleyDoor".

    oTarget = GetObjectByTag("WidowStachleyDoor");

    SetLocked(oTarget, FALSE);

    SetMapPinEnabled(GetObjectByTag("WidowStanchleysHome"), 1);

}

 




#include "x0_i0_partywide"
void main()
{
    object oTarget;
 
    // Get the PC who is in this conversation.
    object oPC = GetPCSpeaker();
    object oArea = GetObjectByTag("Stachley"); //Just assuming you tagged the area with this name, change it to the actual tag
 
    // Set a local integer.
    SetLocalInt(oArea, "StachleyMapped", 1);
}
 
 
//::////////////////////////////////////////////////////////////////
// AREA OnEnter
//::////////////////////////////////////////////////////////////////
void main()

     if (GetLocalInt(OBJECT_SELF, "StachleyMapped") == 1)
     {   
          SetMapPinEnabled(GetObjectByTag("WidowStanchleysHome"), 1);
         
          // Unlock "WidowStachleyDoor".
          object oTarget = GetObjectByTag("WidowStachleyDoor");
          SetLocked(oTarget, FALSE);

     }
}



 


EDIT: GetAreaByTag() changed to GetObjectByTag()



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Completely Lost
« Reply #3 on: May 31, 2014, 05:56:24 pm »


               The original approach is correct - I just tested it.

Pstemarie's method will work, too, though it might seem over-complicated, unless you routinely follow the discipline of managing area objects on entry.
               
               

               
            

Legacy_Urk

  • Sr. Member
  • ****
  • Posts: 253
  • Karma: +0/-0
Completely Lost
« Reply #4 on: June 01, 2014, 04:26:20 am »


               

AH HA! I found it! And yes! I did something totally stupid.


Thanks for all your help!


There was a duplicate area! 


I have made a dreadful mess of both areas trying to work this out. Proleric put me on the right track when he mentioned duplicate tags. My initial reaction was "wtf this guy thinks I'm stupid."


Then it occurred to me that sometimes I CAN be...


 


Not before I tried everything though. I kinda liked Pstemarie's solution, although I couldn't get GetAreaByTag to work. I kept getting a parse error. Is that function really a thing? I couldn't find any reference to it in the script editor or the lexicon. If so, does it need an include? That would explain the error. 


I replaced it with GetObjectByTag and it worked, though. And I needed to declare oTarget an object in the second script. But it worked great. This is the solution I'll use. I've moved the area's old OnEnter script to a trigger at the areas entry point. 


 


Thanks so much for all your help!!!



               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Completely Lost
« Reply #5 on: June 01, 2014, 09:04:09 am »


               


AH HA! I found it! And yes! I did something totally stupid.


Thanks for all your help!


There was a duplicate area! 


I have made a dreadful mess of both areas trying to work this out. Proleric put me on the right track when he mentioned duplicate tags. My initial reaction was "wtf this guy thinks I'm stupid."


Then it occurred to me that sometimes I CAN be...


 


Not before I tried everything though. I kinda liked Pstemarie's solution, although I couldn't get GetAreaByTag to work. I kept getting a parse error. Is that function really a thing? I couldn't find any reference to it in the script editor or the lexicon. If so, does it need an include? That would explain the error. 


I replaced it with GetObjectByTag and it worked, though. And I needed to declare oTarget an object in the second script. But it worked great. This is the solution I'll use. I've moved the area's old OnEnter script to a trigger at the areas entry point. 


 


Thanks so much for all your help!!!




 


Sorry  URK, GetAreaByTag() is a custom function I use just to delineate exactly what I'm looking for. Its just a wrapper for GetObjectByTag() that returns the object with sTag, but only if the object is an Area else it returns OBJECT_INVALID.


 


object GetAreaByTag(string sTag ="")
{
     object oArea = GetObjectByTag(sTag);
     if (sTag == "" ||
         GetObjectType(oArea) == OBJECT_TYPE_CREATURE ||
         GetObjectType(oArea) == OBJECT_TYPE_DOOR ||
         GetObjectType(oArea) == OBJECT_TYPE_ENCOUNTER ||
         GetObjectType(oArea) == OBJECT_TYPE_ITEM ||
         GetObjectType(oArea) == OBJECT_TYPE_INVALID ||
         GetObjectType(oArea) == OBJECT_TYPE_PLACEABLE ||
         GetObjectType(oArea) == OBJECT_TYPE_STORE ||
         GetObjectType(oArea) == OBJECT_TYPE_TRIGGER ||
         GetObjectType(oArea) == OBJECT_TYPE_WAYPOINT )
     {
          return OBJECT_INVALID;
     }
     else return oArea;
}


               
               

               
            

Legacy_Urk

  • Sr. Member
  • ****
  • Posts: 253
  • Karma: +0/-0
Completely Lost
« Reply #6 on: June 04, 2014, 08:05:15 am »


               

And I'm back on track. In the end I placed the plot variable on the module, but otherwise I used Pstemarie's solution of using the OnEnter script to unlock the door and enable the map pin. Thanks to both of you for the help!