Jump to content

Home

What scripts are involved in rolls during dialog?


mobn

Recommended Posts

One of my biggest peeves with this game has always been that rolls during dialog (such as when trying to fix HK-47, or the Pazaak addicted droid on Nar Shaada) are determined by the PC's skill, rather than the highest skill in the active party. After all, your two buddies aren't just standing there for nothing, and the party leader shouldn't have to be a master of everything when s/he has friends around to help!

Because of this, I've decided to make a mod that would check in-conversation rolls against the highest skill in the active party instead of just the main PC's skill. Unfortunately, there's a whole tangle of scripts in the game, and I can't find which ones are used for this (BIOWARE, Comment your code better!). Can anyone be of any help? Thanks!

Link to comment
Share on other sites

One of my biggest peeves with this game has always been that rolls during dialog (such as when trying to fix HK-47, or the Pazaak addicted droid on Nar Shaada) are determined by the PC's skill, rather than the highest skill in the active party. After all, your two buddies aren't just standing there for nothing, and the party leader shouldn't have to be a master of everything when s/he has friends around to help!

Because of this, I've decided to make a mod that would check in-conversation rolls against the highest skill in the active party instead of just the main PC's skill. Unfortunately, there's a whole tangle of scripts in the game, and I can't find which ones are used for this (BIOWARE, Comment your code better!). Can anyone be of any help? Thanks!

 

I assume you mean it's for K2:TSL since you mention Nar Shaddaa. The scripts used for skill checks have the prefix c_sc_ in their name, followed by a 3 letter identifier for which skill they check, and a _gt ending if the skill need to be higher than the set parameter value, _eq if the skill must match the parameter, _lt if the skill has to be lower and _bet if the skill must be in the interval set by the two parameters.

 

To make all skill checks using all available party members, you could modify those scripts to replace the skill check against the dialog speaker with a skill check against the party member with the highest skill rank. For example, a modified c_sc_rep_gt script, checking if the repair skill rank is higher than the set parameter, might be changed as:

// ST: c_sc_rep_gt
int StartingConditional() {
   int nCompareAmt = GetScriptParameter(1);

   // ST: Only check the speaker if in solo mode...
   if (GetSoloMode()) {
       return (GetSkillRank(SKILL_REPAIR, GetPCSpeaker()) > nCompareAmt);
   }

   // ST: Get the highest skill rank in the active party...
   int iParty;
   int iRank = 0;
   for (iParty = 0; iParty < GetPartyMemberCount(); iParty++) {
       object oParty = GetPartyMemberByIndex(iParty);

       if (GetSkillRank(SKILL_REPAIR, oParty) > iRank) {
           iRank = GetSkillRank(SKILL_REPAIR, oParty);
       }
   }

   // ST: Compare the skill against the parameter value.
   return (iRank > nCompareAmt);
}

Link to comment
Share on other sites

Okay, now I see it. I just had to work out what all those extra KOTOR-specific functions were. This is awesome. I'll apply this change to all the scripts, and the package it and distribute it. Do you want your name on it? I had planned to write it myself once I knew which scripts to work on, but you've doen it for me. So, would you like top billing, and I just list myself as distributor?

 

Another question. What situations are the lower-than or equal-to scripts used in? I'm not sure whether I should fix those.

Link to comment
Share on other sites

Okay, I finally got some time to change the scripts, but I noticed something. It looks like these scripts all want a boolean value (TRUE or FALSE) returned, and not (iRank>nCompareAmt) returned.

My question is, will the game except the return values in the script you posted, or will the changes I've made here work better?:

// ST: c_sc_rep_gt
int StartingConditional() {
   int nCompareAmt = GetScriptParameter(1);

   // ST: Only check the speaker if in solo mode...
   if (GetSoloMode()) {
       if (GetSkillRank(SKILL_REPAIR, GetPCSpeaker()) > nCompareAmt){return TRUE;}
return FALSE;
   }

   // ST: Get the highest skill rank in the active party...
   int iParty;
   int iRank = 0;
   for (iParty = 0; iParty < GetPartyMemberCount(); iParty++) {
       object oParty = GetPartyMemberByIndex(iParty);

       if (GetSkillRank(SKILL_REPAIR, oParty) > iRank) {
           iRank = GetSkillRank(SKILL_REPAIR, oParty);
       }
   }

   // ST: Compare the skill against the parameter value.
   if (iRank > nCompareAmt){return TRUE;}
Return FALSE;
}

Link to comment
Share on other sites

That is a good observation and I'm glad you asked that question. :)

 

They will both work. Inequalities evalute to TRUE or FALSE. In stoffe -mkb-'s syntax, the (iRank>nComparAmt) is evaluated to TRUE or FALSE before it is returned. Your syntax is more explicit (or more wordy depending on your point of view).

Link to comment
Share on other sites

  • 2 weeks later...
TRUE and FALSE are merely const integer values, with TRUE being 1 and FALSE being 0. 1 and TRUE are interchangable; 0 and FALSE are interchangable. For instance:

if(nCheck == TRUE) {do_something();}
else if(nCheck == 0) {do_something_else();}

 

Keep in mind that this makes it somewhat risky to use TRUE in some conditional checks, since I've noticed that some functions that return true (the boolean value) does not return TRUE (the integer constant) for some odd reason.

 

The GetLocalBoolean() function is one such case. For example:

SetLocalBoolean(OBJECT_SELF, 120, TRUE);
int bBool = GetLocalBoolean(OBJECT_SELF, 120);

if (bBool == TRUE) {
// This will not run in most cases....
}

if (bBool) {
// This will run, on the other hand...
}

 

In the above case, testing the value of a LocalBoolean against TRUE is highly unreliable since it very, very rarely returns TRUE (the constant) when the LocalBoolean is set to true. It returns false or not false (i.e. a number higher than 0).

 

Worth keeping in mind since bugs resulting from the above can be hard to locate. :)

Link to comment
Share on other sites

I've been bitten by this bug before in other languages. Then I end up torturing some poor Ewok with a pair of hot pliers for hours while I try to figure out why my TRUE condition isn't processing. The best way I've found for this is to stick with only the conditionals (x==FALSE) and (x!=FALSE) for any language that doesn't have tightly defined booleans, but sometimes I slip up and do checks for TRUE. Then the Ewoks suffer...

 

Thank you all for the clarification on this.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...