Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Custom Token Help [K2]

Page: 1 of 1
 Pavlos
01-07-2006, 6:01 AM
#1
void main()
{
nNPC=GetObjectByTag("Atton")
if (GetInfluence(nNPC) >= 80)
}

What I am trying to do is set a Token to different things depending on the influence you have with a character. I understand how to display your influence, or your strength, or something to that nature, with a custom token; however I am at a loss as to how I might get it to be set to something I have written.

So when you see my script above, if the character in question (In this case, Atton) does have +80 influence points with the PC then I would like to show something like "Loyal Companion." I am going to have others too such as:
if (GetInfluence(nNPC) >= 50)

I hope I have gotten across my meaning properly - I didn't really get much sleep last night.
 stoffe
01-07-2006, 7:24 AM
#2
What I am trying to do is set a Token to different things depending on the influence you have with a character.
(snip)
So when you see my script above, if the character in question (In this case, Atton) does have +80 influence points with the PC then I would like to show something like "Loyal Companion." I am going to have others too such as:
if (GetInfluence(nNPC) >= 50)


Something like this should work:


void main() {
int iInf = GetInfluence(NPC_ATTON);
string sToken;

if (iInf >= 80)
sToken = "Loyal Companion";
else if (iInf >= 50)
sToken = "Not Quite as Loyal Companion";
else if (iInf >= 20)
sToken = "Rather Disloyal Companion";
else if (iInf == -1)
sToken = "Noncommittal";
else
sToken = "I was an assassin, you know...";

SetCustomToken(2000, sToken);
}


Then you would use <CUSTOM2000> in the text wherever you wanted the token string to be displayed.

Remember that tokens are set on a per-module basis and not game-wide. So if you use them in a template or dialog that can be accessed from anywhere you must make sure the token is set before they are used in every module the player enters. (Or in the case of dialogs, either in the action script on the node above where the token is used, or in the conditional script of the node where it is used.)
 Pavlos
01-07-2006, 7:27 AM
#3
Excellent, thank you very much. As always, there is a simpler way to do it than the one a look for. Thanks again!

Edit: I like the "I was an assassin you know..." It made me laugh.
 Pavlos
01-07-2006, 8:04 AM
#4
void main() {
int iInf = GetInfluence(NPC_ATTON);
string sToken = "";

if (iInf >= 100)
sToken = "Fidus Achetes";
else if (iInf >= 90)
sToken = "Loyal Friend";
else if (iInf >= 80)
sToken = "Disciple of your ways";
else if (iInf >= 70)
sToken = "Friend";
else if (iInf >= 60)
sToken = "Travelling Companion";
else if (iInf >= 50)
sToken = "Indifferent";
else if (iInf >= 40)
sToken = "Calumniator";
else if (iInf >= 30)
sToken = "Opponent";
else if (iInf >= 20)
sToken = "Backstabber";
else if (iInf >= 10)
sToken = "Potential Assassin";
else
sToken = "I was an assassin, you know...";

SetCustomToken(2000, sToken);
}

I did that ^^ and all it comes up with is <UNRECOGNISED TOKEN>

Edit: It was just because I wasn't putting the script in the right place. It is fine now.
 stoffe
01-07-2006, 8:27 AM
#5
(snip)
I did that ^^ and all it comes up with is <UNRECOGNISED TOKEN>

That usually means that the token has not been set yet when you are trying to use it. Where do you run the script?

(BTW: You need a check for a value of -1 as well, unless you want him to start out at the bottom "Assassin" option. The Influence is returned as -1 while the character hasn't received any influence gains/losses yet.)
 Pavlos
01-07-2006, 8:31 AM
#6
See my edit above. I made a mistake in putting the script in the line where the token was, as opposed to the one before it.
Page: 1 of 1