Jump to content

Home

Two Scripts - Help?


Recommended Posts

I've written two scripts using Local Variables, one to set the variable from the OnOpen script slot on a door, one to fire after checking the variable from a trigger. The variable is set on the trigger itself, "hlc". But whenever I load the module and set the trigger, the second script doesn't fire. They compile fine though. I'm guessing there's something wrong with the trigger, but it seems fine. So could someone look over the scripts and ensure I'm not making a major mistake? Thanks.

 

The first, to set the local:

#include "k_inc_debug"
#include "k_inc_utility"

void main()

{

object oObject = GetObjectByTag("hlc");

SetLocalNumber(oObject, 1, 1);

}

 

The second, to check the local and, if set, spawn the item:

#include "k_inc_debug"
#include "k_inc_utility"

void main()

{

object oObject = GetObjectByTag("hlc");

if ( GetLocalNumber(oObject, 1))
{

       float x= 112.71f; 
   	float y= -20.09f;
   	float z= 9.87913f;
   	float r= 0.0f;
   	vector MyVec = Vector(x,y,z);
   	location MyLoc = Location(MyVec, r);
   	object oLocker=CreateObject( OBJECT_TYPE_PLACEABLE, "plc1", MyLoc);
      ActionStartConversation(GetFirstPC(),"plc1");
}
else
{}
}

 

Thanks.

Link to comment
Share on other sites

The first, to set the local:

#include "k_inc_debug"
#include "k_inc_utility"

void main() {
   SetLocalNumber(GetObjectByTag("hlc"), 1, 1);
}

 

There are no errors in this script from what I can see, but you don't need to include k_inc_debug and k_inc_utility. That will only make your script larger than it has to be for no benefit. Also, if you only intend to have the variable to either have the value 0 or 1 you should use a LocalBoolean instead of a LocalNumber. But those are just nitpicking and should have no bearing on your problem. :)

 

The second, to check the local and, if set, spawn the item:

void main() {
   object oObject = GetObjectByTag("hlc");
   if ( GetLocalNumber(oObject, 1)) {
   	location MyLoc = Location(Vector(112.71f, -20.09f, 9.88f), 0.0);
   	object oLocker = CreateObject( OBJECT_TYPE_PLACEABLE, "plc1", MyLoc);
      ActionStartConversation(GetFirstPC(),"plc1");
   }
}

 

Does nothing at all happen when you get to this point? If so, make sure the script fires at all by printing a debug message to the feedback log from the first line of the script, like:

   SendMessageToPC(GetPartyLeader(), "DEBUG: THE SCRIPT RUNS!!");

 

If that line does show in the Feedback log in-game when you trip the trigger, check that you really have a placeable template with the name plc1.utp in either the module or the override folder. Also make sure the faction of the trigger is set to Hostile (1).

 

If the placeable does show up, but the dialog does not start, that might be due to the fact that the trigger starts the conversation. I think only creatures and placeables can be participants in a conversation (but I'm not 100% sure). You could try to assign the dialog start and delay it a bit and see if that helps. If it's the placeable you just spawned that should "talk" with the player, you can modify the line like:

   DelayCommand(0.5, AssignCommand(oLocker, ActionStartConversation(GetFirstPC(),"plc1", FALSE, CONVERSATION_TYPE_CINEMATIC, TRUE)));

 

Also make sure that there is a plc1.dlg file in either your module or the override folder.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...