Please write me a script?
#1
Posté 03 décembre 2010 - 05:39
Here's what I need:
When the PC talks to an NPC, 2 random numbers between 1 and 3 are chosen. The PC then gets to pick 2 numbers from the conversation window. Each number is 1 through 3 for choices. If they get 1 number wrong, they don't get anything. If they get both right, they receive and item from the NPC.
This is going to be a quest I'd like to make for a PW I'm working on.
Thanks in advance folks!
#2
Posté 03 décembre 2010 - 08:12
#3
Posté 03 décembre 2010 - 08:30
#4
Posté 03 décembre 2010 - 09:58
#5
Posté 03 décembre 2010 - 11:23
The quest story is simple & kind of silly you may think (if that is what you're referring to), but I needed a filler quest.Elishiva wrote...
and if you need someone else to this for you what istopic of conversation that the diollogue is set upon?or is it random topic? Elishiva
The player will come across stuff in the world (books, notes etc) that will make reference to a magical creature that grants a wish of sorts to the person who can beat it in a guessing game. After the player discovers enough info, a quest journal entry will be initialized, and the player can then pursue the creature.
Then, the number game comes into play after some dialogue stuff.
#6
Posté 03 décembre 2010 - 11:47
#7
Posté 04 décembre 2010 - 01:35
PC -#1: Action ga_local_int "int_name1",=1,"npc_tag".
-link- NPC Response: -Guess a Second Number.
PC -#2: Action ga_local_int "int_name1",=1",npc_tag".
-link- NPC Response: -Guess a Second Number.
PC -#3: Action ga_local_int "int_name1",=1",npc_tag".
NPC Response: -Guess a Second Number.
PC #1: Condition gc_local_int (not) "int_name1", =1, "npc_tag": Action ga_local_int "int_name1",=1,"npc_tag".
-link to NPC responses-
PC #2: Condition gc_local_int (not) "int_name1", =1, "npc_tag": Action ga_local_int "int_name1",=1,"npc_tag".
-link to NPC responses-
PC #3: Condition gc_local_int (not) "int_name1", =1, "npc_tag": Action ga_local_int "int_name1",=1,"npc_tag".
NPC Response: Correct. Condition gc_local_int "int_name1", =1, "npc_tag"
and gc_local_int "int_name2", =1, "npc_tag"
NPC Response: Incorrect, you lose.
The number guess conversation starts with the NPC asking the player to choose a number. The PC responses allow the player to choose 1 thru 3. When they choose one the ga_local_int will set a local int on the npc or anything you choose. There are three different int one for each number. Once the player makes a choice the NPC ask player to choose a second number. These PC responses all have a condition that make sure that the int associated with that choice isn't equal to one. The player can only choose a number once. With choosing the second number the player has now set two different local int. The next NPC response requires that the two correct int are set to one (the player chose the right numbers). If the player didn't choose the right numbers that line will fail and the fall through line Incorrect will happen. With the correct answer you can have a ga_ script(s) give an item, xp, gold etc.
Hope this helps. To set the scripts you have the tabs in the conversation. Pink is the action scripts ga_ and green is the conditional scripts gc_. Not is done with a check box.
Modifié par Shaughn78, 04 décembre 2010 - 01:40 .
#8
Posté 05 décembre 2010 - 01:23
Ok thanks for the idea, but I could not get it to work right. It would prompt me for the second number, but the convo. would stop before I could pick the second number.Shaughn78 wrote...
NPC response: -Guess a number.
PC -#1: Action ga_local_int "int_name1",=1,"npc_tag".
-link- NPC Response: -Guess a Second Number.
PC -#2: Action ga_local_int "int_name1",=1",npc_tag".
-link- NPC Response: -Guess a Second Number.
PC -#3: Action ga_local_int "int_name1",=1",npc_tag".
NPC Response: -Guess a Second Number.
PC #1: Condition gc_local_int (not) "int_name1", =1, "npc_tag": Action ga_local_int "int_name1",=1,"npc_tag".
-link to NPC responses-
PC #2: Condition gc_local_int (not) "int_name1", =1, "npc_tag": Action ga_local_int "int_name1",=1,"npc_tag".
-link to NPC responses-
PC #3: Condition gc_local_int (not) "int_name1", =1, "npc_tag": Action ga_local_int "int_name1",=1,"npc_tag".
NPC Response: Correct. Condition gc_local_int "int_name1", =1, "npc_tag"
and gc_local_int "int_name2", =1, "npc_tag"
NPC Response: Incorrect, you lose.
The number guess conversation starts with the NPC asking the player to choose a number. The PC responses allow the player to choose 1 thru 3. When they choose one the ga_local_int will set a local int on the npc or anything you choose. There are three different int one for each number. Once the player makes a choice the NPC ask player to choose a second number. These PC responses all have a condition that make sure that the int associated with that choice isn't equal to one. The player can only choose a number once. With choosing the second number the player has now set two different local int. The next NPC response requires that the two correct int are set to one (the player chose the right numbers). If the player didn't choose the right numbers that line will fail and the fall through line Incorrect will happen. With the correct answer you can have a ga_ script(s) give an item, xp, gold etc.
Hope this helps. To set the scripts you have the tabs in the conversation. Pink is the action scripts ga_ and green is the conditional scripts gc_. Not is done with a check box.
As far as an actual script goes, could it be done by (added new idea):
1.) At start of conversation, set the 2 random numbers by rolling a 3-sided die then...
2.) Store the numbers on the NPC, then...
3.) Allow the PC to pick 2 numbers between 1 & 3, then...
4.) Compare stored numbers with what the PC picked, then...
5.) If both numbers are correct, give messege "You win the greater prize" & give greater prize. Else, give message "You won a lesser prize!" & give lesser prize.
???
#9
Posté 05 décembre 2010 - 10:41
Setting the numbers to be different each time and checking at the end is doable, it will require 2 custom scripts but nothing too complicated..
I am away from the toolset right now, but you can set 2 local int with an initial script at the start of the conversation. Have the player choose their 2 numbers setting two additional local int.
Once the 2 int have been set run another action script. This script will check the player's two choices against the randomly created 2 numbers. This will create another local int. If both the numbers are the same int = 2, if only 1 is correct the int = 1 if none the int will remain 0.
The end conversation would have 3 NPC responses
-(int == 2)Greater Prize
-(int == 1)Lesser Prize
- You won nothing
Modifié par Shaughn78, 05 décembre 2010 - 10:42 .
#10
Posté 05 décembre 2010 - 11:51
Modifié par Kaldor Silverwand, 05 décembre 2010 - 11:57 .
#11
Posté 05 décembre 2010 - 11:59
First script - ga_bb_local_int_random - is an action script used to assign a random integer value to a local integer variable. Use this on the first conversation node to assign two variables - Secret1 and Secret2 - to random values. Note that like the Random function and gc_rand_1of script this will assign a value from zero to the number specified minus 1. So specifying ga_bb_local_int_random ("Secret1", 3) would set a local variable named Secret1 to 0, 1, or 2.
// ga_bb_local_int_random(string sVariable, int nMax, string sTarget)
// by Brendan Bellina
// Dec, 2010
/*
This script sets a local int variable to a random value from 0 to nMax-1, inclusive.
Parameters:
string sVariable = Name of variable to change
int nMax = Upper limit of random function. Random value will be from 0 to nMax-1, inclusive.
string sTarget = Target tag or identifier. If blank then use OBJECT_SELF
*/
#include "ginc_param_const"
void main(string sVariable, int nMax, string sTarget)
{
object oTarg = GetTarget(sTarget, TARGET_OBJECT_SELF);
if (GetIsObjectValid(oTarg) == FALSE)
PrintString("ga_bb_local_int_random: " + sTarget + " is invalid");
int nNewValue = Random(nMax);
SetLocalInt(oTarg, sVariable, nNewValue);
//PrintString(sTarget + "'s variable " + sVariable + " is now set to " + IntToString(nNewValue) );
}
Next in the conversation ask the player to enter the two integers. Store each entered integer into a local variable (Guess1 and Guess2) using the standard ga_local_int script. Note that the values you store should be one less than the value they choose. So give them values 1, 2, and 3 to choose from, but store 0, 1, and 2, respectively.
Then use the following condition script - gc_bb_compare_local_int - to check if Secret1 is equal to Guess1 and Secret2 is equal to Guess2.
// gc_bb_compare_local_int(string sVariable1, string sCheck, sVariable2, string sTarget1, string sTarget2)
// by Brendan Bellina
// Dec, 2010
/* This script compares two local integer variables.
Parameters:
string sVariable1 = The name of the first integer variable
string sOperator = The operation to use when comparing the two variables.
Must be = (or ==), ! (or != ) (for not equal), , ), >= (or !
string sVariable2 = The name of the second variable
string sTarget1 = Tag of object that has sVariable1. Default is owner.
string sTarget2 = Tag of object that has sVariable2. Default is whatever object is used for sVariable1.
*/
#include "ginc_param_const"
#include "ginc_var_ops"
int StartingConditional(string sVariable1, string sOperator, string sVariable2, string sTarget1 = "", string sTarget2 = "")
{
object oTarg1 = GetTarget(sTarget1, TARGET_OBJECT_SELF);
if (GetIsObjectValid(oTarg1) == FALSE)
PrintString("ga_bb_compare_local_int: " + sTarget1 + " is invalid");
object oTarg2;
if (sTarget2 != "")
oTarg2 = GetTarget(sTarget2, TARGET_OBJECT_SELF);
else
oTarg2 = oTarg1;
if (GetIsObjectValid(oTarg2) == FALSE)
PrintString("ga_bb_compare_local_int: " + sTarget2 + " is invalid");
int nValue1 = GetLocalInt(oTarg1, sVariable1);
int nValue2 = GetLocalInt(oTarg2, sVariable2);
int iRet = FALSE;
string sOperatorEval = sOperator;
if (sOperator == "!
sOperatorEval = ">=";
else if (sOperator == "!>")
sOperatorEval = "
else if (sOperator == "==")
sOperatorEval = "=";
else if (sOperator == "!=")
sOperatorEval = "!";
if (sOperatorEval == "" || sOperatorEval == "=" || sOperatorEval == "!")
iRet = CheckVariableInt(nValue1, sOperatorEval, nValue2);
else if (sOperatorEval == "
iRet = CheckVariableInt(nValue1, "
else if (sOperatorEval == ">=")
iRet = CheckVariableInt(nValue1, ">", (nValue2 - 1));
PrintString ("gc_bb_compare_local_int: Test" + IntToString(nValue1) + sOperator + IntToString(nValue2) + " -- return val: " + IntToString(iRet));
return (iRet);
}
The next NPC node should just fall through to the guesses being incorrect.
Note. These scripts compile fine, but I have not tested them myself.
Regards
Modifié par Kaldor Silverwand, 06 décembre 2010 - 12:05 .





Retour en haut






