Fair Strides

Fair Strides' Script Shack

168 posts in this topic

Or you could use TSLPatcher to apply the changes to the .dlg during the installation, thus not overwriting previous changes to the same file.

Share this post


Link to post
Share on other sites

Cool, thanks for your help guys, think I'll probably go with Kexikus method, as it seems the easier for me. Good to still see you around JC :)

Share this post


Link to post
Share on other sites

I'm not good at scripting... But how do I trigger a conversation when the PC approaches a certain area? 

Share this post


Link to post
Share on other sites

I would need to know the context of this "certain area" to be able to help more. Primarily, you'd set up a Trigger in the area's .git file or hijack one that already exists if it's in the right spot.

 

A Trigger is a .utt file that has several events that fire scripts, one of which is an On-enter event that activates whenever something enters the area. In this case, you'd do something like this (all marks are ignored; you want to pay attention to what's between them):

void main()
{
    // Get the object that triggered the event
    object oTarget = GetEnteringObject();
    object oTalker = GetObjectByTag("<tag of the object/person initiating the conversation>");

    if(oTarget == GetFirstPC()) // If the triggering object is the current player-controlled character
    {
        // Have oTalker start a conversation with the PC. The code looks long because we need the last three pieces to make the
        // game ignore the distance between oTalker and oTarget. Otherwise, the player would move to oTalker first...
        AssignCommand(oTalker, ActionStartConversation(oTarget, "<name of .dlg file, minus the extension>", FALSE, CONVERSATION_TYPE_CINEMATIC, FALSE));
    }
}

Share this post


Link to post
Share on other sites

 

I would need to know the context of this "certain area" to be able to help more. Primarily, you'd set up a Trigger in the area's .git file or hijack one that already exists if it's in the right spot.

 

A Trigger is a .utt file that has several events that fire scripts, one of which is an On-enter event that activates whenever something enters the area. In this case, you'd do something like this (all < > marks are ignored; you want to pay attention to what's between them):

void main()
{
    // Get the object that triggered the event
    object oTarget = GetEnteringObject();
    object oTalker = GetObjectByTag("<tag of the object/person initiating the conversation>");

    if(oTarget == GetFirstPC()) // If the triggering object is the current player-controlled character
    {
        // Have oTalker start a conversation with the PC. The code looks long because we need the last three pieces to make the
        // game ignore the distance between oTalker and oTarget. Otherwise, the player would move to oTalker first...
        AssignCommand(oTalker, ActionStartConversation(oTarget, "<name of .dlg file, minus the extension>", FALSE, CONVERSATION_TYPE_CINEMATIC, FALSE));
    }
}

Near both of the entrances of the Nar Shaddaa Landing Pad restored cantina. And if triggers once, that's it.

Share this post


Link to post
Share on other sites

Near both of the entrances of the Nar Shaddaa Landing Pad restored cantina. And if triggers once, that's it.

 

You could also tie the script to the door opening instead, if it's supposed to fire the first time you go there :)

Share this post


Link to post
Share on other sites

You could also tie the script to the door opening instead, if it's supposed to fire the first time you go there :D

Thanks! I'll keep that in mind.

Share this post


Link to post
Share on other sites

I have an item a_robe_47 and I'm trying to trigger my script to add it to the inventory. I tried with OnOpen and OnClosed on a corpse and a container, no luck. I can add the item with the cheats so that part should be fine.
 

void main()
{
   object oItem = GetItemPossessedBy (GetPartyLeader(),"a_robe_47");
   if (GetIsObjectValid(oItem)) {
      int nStackSize = GetItemStackSize(oItem);
      if (nStackSize < 1) 
        CreateItemOnObject("a_robe_47", GetFirstPC());
   }
}

It includes a check if the object is already owned, but it also doesn't work without that, what am I doing wrong?

Share this post


Link to post
Share on other sites

The problem in your script is that GetIsObjectValid(oItem) will return FALSE if the player doesn't have the item, thus the CreateItemOnObject is never called. If the player does have the item, then nStackSize < 1 returns FALSE and once again, the CreateItemOnObject is not called. Basically, all you need is a condition if(!(GetIsObjectValid(oItem))). That will return TRUE only if the player doesn't have the item, so it basically does what your second condition does, only that it works^^

  • Like 1

Share this post


Link to post
Share on other sites

Ok, cool, I thought GetIsObjectValid was to test if it was an existing object. That's even shorter than I thought was needed. I'll try that, many thanks!

Edit: Worked, thanks again.
Here's a cool puppet (like Bao-Dur's remote) script by Hangout Hermit:
http://z6.invisionfree.com/Mandalorian16965/ar/t61.htm
It never led to a mod but I played around with similar scripts that were included in Cati by Princess Artemis, I gave T3 a protocol droid that followed him :D



 

Share this post


Link to post
Share on other sites

Ok, cool, I thought GetIsObjectValid was to test if it was an existing object. That's even shorter than I thought was needed. I'll try that, many thanks!

 

It is a way to test for an existing object. But it really only checks that specific object and returns TRUE if it exists and FALSE if it doesn't. So checking if the object is NOT valid asks: "Is this item NOT in the player's inventory."

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for helping Effix out, Kex. I'm not always around, so it's nice that people don't have to wait too long.

Share this post


Link to post
Share on other sites

Oh wow, I haven't needed help in a whole month, yay me. Okay, so I have currently have two booleans

" Recruit_Atris_E " (Recruited Evil Atris)

" Recruit_Atris_G " (Recruited Good Atris)

 

Here's the script I used to inject the Booleans:

 

 

  void main() 

 
{
 
 // Once you have done the script, select the boolean to be true.
 SetGlobalBoolean("RECRUIT_ATRIS_E",TRUE);
}

 

void main() 

 
{
 
 // Once you have done the script, select the boolean to be true.
 SetGlobalBoolean("RECRUIT_ATRIS_G",TRUE);
}

 Here's where the issue lies, I am currently in a dialog where the party confronts Kreia. I made a separate version of the dialog that should only come available after recruiting Evil Atris. The conditional script I am using to check if the Boolean returned true so the dialog will be used is:

 

int StartingConditional() 

{
  int iResult;
 
  iResult = ((GetGlobalBoolean( "Recruit_Atris_E" ) == TRUE) );
 
  return iResult;  
 
}

 The conditional script also is not placed on a dialogue option from the PC, but from an NPC entry. Any suggestions? Thanks.

Share this post


Link to post
Share on other sites

The scripts are fine so we'll need a description of your actual issue to help you out.

Share this post


Link to post
Share on other sites

Try this instead:

int StartingConditional() 
{
    return GetGlobalBoolean("Recruit_Atris_E");
}

Share this post


Link to post
Share on other sites

 

Try this instead:

int StartingConditional() 
{
    return GetGlobalBoolean("Recruit_Atris_E");
}

Didn't work unfortunately.

 

Here's the exact problem, I put the conditional script "SeeRecruitE" on this node.

DwohHAcrRCilnsaRFLVJjA.png

 

I put the conditional script "SeeRecruitG" for good Atris on this node.

tQytlVgvSVuP_KVr1D8Iow.png

And I made a copy of the same node for Good Atris' conditional.. in case you don't have Atris at all..

zhl2hYpbRmWgp7U6UufTuw.png

This whole Boolean situation is so tiring, I feel like ripping my head off. 

Share this post


Link to post
Share on other sites

I just checked both your posts, it seems like you never mentioned what actually goes wrong, ie. what actually happens with your current setup :lol:

 

Anyway, I think I've had trouble in the past with using replies for directing cutscene flow like that, I don't remember the details, but you could try putting the scripts onto entry nodes instead.

Share this post


Link to post
Share on other sites

I just checked both your posts, it seems like you never mentioned what actually goes wrong, ie. what actually happens with your current setup :lol:

 

Anyway, I think I've had trouble in the past with using replies for directing cutscene flow like that, I don't remember the details, but you could try putting the scripts onto entry nodes instead.

Oh sorry, Well the game chooses the dialog with no conditional, I don't know why! I put both my booleans in the Globalcat file.

Row 999 = Recruit_Atris_E

Row 1000 = Recruit_Atris_G.

I made sure I used the correct set scripts, and conditions! I'm super confused. I'll attempt using entries, Let's hope it works.

 

EDIT: No dice, seems like me and Booleans just aren't friends.

Share this post


Link to post
Share on other sites

Okay, so then we need to make sure the globals are set correctly in the first place.

I'm not sure whether the globals are case-sensitive, but they could be, and you're setting them in all caps, while you're getting them with only the first letter of the word capitalized. Try fixing that.

Share this post


Link to post
Share on other sites

Okay, so then we need to make sure the globals are set correctly in the first place.

 

I'm not sure whether the globals are case-sensitive, but they could be, and you're setting them in all caps, while you're getting them with only the first letter of the word capitalized. Try fixing that.

Tried it, didn't work... I'm curious though.... Can I use a_global_set, and c_global_set, and use the string parameter??? Let me try that and I'll be back.

 

Edit: That didn't work either. I'm about to scrap this entire project.

Share this post


Link to post
Share on other sites

I think then you need to use a_glob_bool_set or something like that, check it out in kotor tool.

 

When and how do the scripts to set the booleans fire? Maybe the problem is that those scripts never fire. To diagnose, you could include this in your setting scripts, then check your feedback screen after they're supposed to have run.
 

void main(){
    SetGlobalBoolean("Recruit_Atris_E", TRUE);

    string sMessage = "Recruit_Atris_E setting script fired! Current value: ";
    if(GetGlobalBoolean("Recruit_Atris_E")) sMessage += "TRUE";
    else sMessage += "FALSE";

    SendMessageToPC(GetFirstPC(), sMessage);
}

Share this post


Link to post
Share on other sites

 

I think then you need to use a_glob_bool_set or something like that, check it out in kotor tool.

 

When and how do the scripts to set the booleans fire? Maybe the problem is that those scripts never fire. To diagnose, you could include this in your setting scripts, then check your feedback screen after they're supposed to have run.

 

void main(){
    SetGlobalBoolean("Recruit_Atris_E", TRUE);

    string sMessage = "Recruit_Atris_E setting script fired! Current value: ";
    if(GetGlobalBoolean("Recruit_Atris_E")) sMessage += "TRUE";
    else sMessage += "FALSE";

    SendMessageToPC(GetFirstPC(), sMessage);
}

The setting scripts fire just before the dialog that says "Atris has joined your party" dialog. I got a message! It says "Recruit_Atris_E setting script fired! Current Value: FALSE" I guess I need that to be true. It's one thing on top of another

Share this post


Link to post
Share on other sites

Yeah, so then the setting of the global is failing, make sure that the globals are named EXACTLY as in globalcat.2da, and that the global variable type is set to Boolean. Also make sure you don't have another globalcat.2da lying around somewhere in an override subfolder or something.

Share this post


Link to post
Share on other sites

Yeah, so then the setting of the global is failing, make sure that the globals are named EXACTLY as in globalcat.2da, and that the global variable type is set to Boolean. Also make sure you don't have another globalcat.2da lying around somewhere in an override subfolder or something.

THAT was the problem! There was a globalcat.2da file in my movies folder O_O, I don't know how that got there! Permission to beat me up is all the way granted! thank you!

Share this post


Link to post
Share on other sites

THAT was the problem! There was a globalcat.2da file in my movies folder O_O, I don't know how that got there! Permission to beat me up is all the way granted! thank you!

lol I almost didn't mention that because I was like "what are the odds of that!" :lol:  Anyway, glad it's working now! :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now