Jump to content

Home

Ugh! More questions about scripting!


Exile007

Recommended Posts

Hello there Holowan,

 

I have NO idea why the hell this script is not working! It is fine as far as I can tell, yet for some reason it will not work!:firemad:

 

What I'm trying to do is fairly simple. I'm trying to start a conversation that will only fire off once, as soon as I enter a module. I have attached it to the OnEnter part of the .are file. :firemad:

 

void main()
{
int i = GetGlobalNumber("833_sith");

if(i==0) {

    object oPC=GetFirstPC();
    object oSith=GetObjectByTag("g_cradus");

    ActionDoCommand(SetCommandable(TRUE, oSith));
    AssignCommand(oSith, ActionStartConversation(oPC, "open"));

    SetGlobalNumber("833_sith", 1);
           }
}

 

If someone could tell me what I did wrong, I would greatly appreciate it. I probably missed something too.

 

Please excuse me if I sound too pissed off, you must understand I have been at trying to make this work for three days. :p

Link to comment
Share on other sites

What does not work? Does the dialogue fire as many times as you want while it's meant to fire once only, or just not at all?

 

If it's the latter, just a simple question, are you sure 833_sith is set to 0 by default? I'm not familiar with dialogue firing syntax yet, so the error could also be in the instructions, I can't tell.

Link to comment
Share on other sites

Don't think so. Perhaps it makes the code less conventional, but it should not be less functional. What would we put in the "else" anyway?

else {do(nothing);}

'^^

 

Here if the condition is not met (which happens any time 833_sith is not 0), the script will simply do nothing. And that's what we want.

Link to comment
Share on other sites

I have NO idea why the hell this script is not working! It is fine as far as I can tell, yet for some reason it will not work!:firemad:

 

 

This problem might be caused by the fact that you don't check who is entering the area before triggering the script. If some NPC is spawned into the area before the player character is, the script will trigger, the global var will be set, but the start conversation function will fail since the player character isn't present in the area yet.

 

(Also, areas have no action queue IIRC, so the ActionDoCommand() function will not be meaningful to use.)

 

Try checking that the character entering is the player character before executing the rest of the script. Like:

 

void main() {
   object oPC = GetFirstPC();
   if ((GetEnteringObject() == oPC) && (GetGlobalNumber("833_sith") == 0)) {
        object oSith = GetObjectByTag("g_cradus");

        SetCommandable(TRUE, oSith);
        DelayCommand(0.5, AssignCommand(oSith, ActionStartConversation(oPC, "open")));

        SetGlobalNumber("833_sith", 1);
   }
}

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...