Jump to content

Home

Little help with a script [K1]


sekan

Recommended Posts

Hi ,

 

I'm trying to make a script that spawns two npcs and start a conversation when i open a door. But i get a failure in my script that says: Error Unexpected end of file.

 

This is the script I'm trying to make.

 

void main()
{
object oEntering = GetEnteringObject();
object oPC=GetFirstPC();
if (GetIsPC(oEntering))
       {


       vector vPos;
       float fAngle;

       vPos.x = 84.76; 
       vPos.y = 68.72; 
       vPos.z = 5.03;
       fAngle = 0.0; 

       CreateObject(OBJECT_TYPE_CREATURE, "dan13_tareelok", Location(vPos, fAngle));



       vector vPos;
       float fAngle;

       vPos.x = 79.67; 
       vPos.y = 68.86; 
       vPos.z = 5.03;
       fAngle = 0.0; 

       CreateObject(OBJECT_TYPE_CREATURE, "dan13_garrum", Location(vPos, fAngle));


       ActionStartConversation(GetFirstPC(),"dan13_cort");


       DestroyObject(OBJECT_SELF);


}

 

Can anybody tell me where the error is or give me a script that is working?

Link to comment
Share on other sites

I'm not sure if this is the problem but something doesn't look right with the conditional part of the script, try this and see if it works

void main()
{
object oPC = GetFirstPC();

if (GetEnteringObject() == oPC)
return;


       vector vPos;
       float fAngle;

       vPos.x = 84.76; 
       vPos.y = 68.72; 
       vPos.z = 5.03;
       fAngle = 0.0; 

       CreateObject(OBJECT_TYPE_CREATURE, "dan13_tareelok", Location(vPos, fAngle));



       vector vPos;
       float fAngle;

       vPos.x = 79.67; 
       vPos.y = 68.86; 
       vPos.z = 5.03;
       fAngle = 0.0; 

       CreateObject(OBJECT_TYPE_CREATURE, "dan13_garrum", Location(vPos, fAngle));


       ActionStartConversation(GetFirstPC(),"dan13_cort");


}

 

I'm not sure what object you were wanting to destroy but it's probably best if you write a new script to fire at the end of the conversation, something like this should work;

void main() {


DestroyObject(GetObjectByTag("[b]INSERT_TAG_HERE[/b]", 0), 0.0, 0, 0.0, 0);

}

 

I hope this helps.

 

Kind Regards

--Stream

Link to comment
Share on other sites

void main()
{
object oPC = GetFirstPC();

if (GetEnteringObject() == oPC)
return;


       vector vPos;
       float fAngle;

       vPos.x = 84.76; 
       vPos.y = 68.72; 
       vPos.z = 5.03;
       fAngle = 0.0; 

       CreateObject(OBJECT_TYPE_CREATURE, "dan13_tareelok", Location(vPos, fAngle));



       vector vPos;
       float fAngle;

       vPos.x = 79.67; 
       vPos.y = 68.86; 
       vPos.z = 5.03;
       fAngle = 0.0; 

       CreateObject(OBJECT_TYPE_CREATURE, "dan13_garrum", Location(vPos, fAngle));


       ActionStartConversation(GetFirstPC(),"dan13_cort");


}

 

When i compile this it says: Error varible "vpos" defined multiple times in same scope and Error varible "fAngle" defined multiple times in same scope

 

Then when i add a { between them i get: Error Unexpected end of file

Hmm what if i... Yes i manged to fix it thanks for the help.

Link to comment
Share on other sites

You are declaring vpos and fangle more than once in your script. Check lines 9 and 21. You do the same thing with fAngle.

 

In any event, it can be simplified to: (also, you stop the execution of the script by doing a return when the pc enters the area: you will not spawn anything if this is an onenter script). Just make sure to insert the proper npc tags where indicated

 

void main()
{


 object oEntering = GetEnteringObject();
 object oPC=GetFirstPC();
 if (GetIsPC(oEntering))
     {
[color=green]// prevent clones to be created each time the pc enters the area - ( edit: this
// version checks if the npc already exists or use a local boolean as in stoffe's
// example below. Mine is good only if you don't destroy the npc afterwards.)
//You can use the tag of any of the two npcs...you do not need both[/color]

     if   (!GetIsObjectValid(GetObjectByTag("[color=skyblue]my_npc_tag[/color]")))
           {
             	CreateObject(OBJECT_TYPE_CREATURE, "dan13_tareelok", Location(Vector(84.76,68.72,5.03), 0.0)); 
	CreateObject(OBJECT_TYPE_CREATURE, "dan13_garrum", Location(Vector(79.67,68.86,5.03), 0.0)); 
               AssignCommand ((GetObjectByTag("[color=skyblue]npcwhoshouldspeak_tag[/color]")), ActionDoCommand(ActionStartConversation(oPC,"dan13_cort")));
           }
    }

}

Link to comment
Share on other sites

Hi ,

 

I'm trying to make a script that spawns two npcs and start a conversation when i open a door. But i get a failure in my script that says: Error Unexpected end of file.

 

There are three problems with your script as I can see:

The first one, causing the Unexpected End of File error, is caused by not having a closing } at the end of your If-statement checking if the entering object is is a player.

 

The second is caused by re-declaring the vPos and fAngle variables multiple times in the script. You should only declare them once, then you can change their values as needed in the script.

 

The third problem is that you are trying to make the door start a conversation with the player and then immediately destroy the door from the game world. Presumably you want to start conversation with one of the NPCs you just spawned instead of the door.

 

You likely also want a blocker condition to ensure this is only done once. In the case of a door it might not be that necessary since players can't close or interact with a door they've opened in KotOR, but just in case. :)

void main() {
   object oEntering = GetEnteringObject();
   object oPC=GetFirstPC();

   if ((oEntering == oPC) && !GetLocalBoolean(OBJECT_SELF, 40)) {
       vector vPos;
       float fAngle = 0.0;

       vPos.x = 84.76; 
       vPos.y = 68.72; 
       vPos.z = 5.03;
       object oNPC = CreateObject(OBJECT_TYPE_CREATURE, "dan13_tareelok", Location(vPos, fAngle));


       vPos.x = 79.67; 
       vPos.y = 68.86; 
       vPos.z = 5.03;
       CreateObject(OBJECT_TYPE_CREATURE, "dan13_garrum", Location(vPos, fAngle));

       SetLocalBoolean(OBJECT_SELF, 40, TRUE);
       DelayCommand(0.5, AssignCommand(oNPC, ActionStartConversation(oPC, "dan13_cort", FALSE, 0, TRUE)));
   }
}

Link to comment
Share on other sites

Can just somebody explain how to make a npc start a dialog when your just walking towards the npc?

 

You want an NPC to start talking to you when he sees you I think?

 

This should work:

 

void main()
{
ActionStartConverstaion(GetFirstPC(), "dlghere", 0, 0, 0, "", "", "", "", "", "", 0);
}

 

Replace the dlghere with the name of the conversation and set it as thw NPC's on notice script.

 

Hope this helped :)

Link to comment
Share on other sites

You want an NPC to start talking to you when he sees you I think?

 

Yes that right

 

void main()
{
ActionStartConverstaion(GetFirstPC(), "dlghere", 0, 0, 0, "", "", "", "", "", "", 0);
}

 

I get an error: Undeclered identifer "ActionstartConversation"

Link to comment
Share on other sites

Yes that right

 

void main()
{
ActionStartConverstaion(GetFirstPC(), "dlghere", 0, 0, 0, "", "", "", "", "", "", 0);
}

 

I get an error: Undeclered identifer "ActionstartConversation"

 

Well that's odd...

 

It compiled for me...

 

Try this one instead:

 

void main()
{

object oPC = GetLastPerceived();

if (!GetIsPC(oPC)) return;

if (!GetLastPerceptionSeen()) return;
object oTarget;
oTarget = GetObjectByTag("NPC_TAG");

AssignCommand(oTarget, ActionStartConversation(oPC, "DLG_NAME"));

}

Link to comment
Share on other sites

I get an error: Undeclered identifer "ActionstartConversation"

 

Try using the following script:

 

void main() 
{
ActionStartConversation(GetFirstPC(),"dlghere");
}

 

I dunno why the other won't work for you, however this should compile very nicely.

 

EDIT: Unless DDD posted as I made this post.

Link to comment
Share on other sites

Try using the following script:

 

void main() 
{
ActionStartConversation(GetFirstPC(),"dlghere");
}

 

I dunno why the other won't work for you, however this should compile very nicely.

 

EDIT: Unless DDD posted as I made this post.

 

Thanks it works now

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...