Aller au contenu

Photo

Trying to make a script for dice game in conversation


  • Veuillez vous connecter pour répondre
14 réponses à ce sujet

#1
andysks

andysks
  • Members
  • 1 645 messages

Hi all. What I want to do is have the PC and an NPC play some dice in convo. Something like that.

 

PC: (Roll the dice)

 

And after that depending on the standard two dice probability results have a conditional script on twelve NPC responses saying something like:

 

NPC: 12. I cannot roll higher than that, you win.

NPC: 11. Oh, I only need a twelve to win.

NPC: 5. Now, that's not tough to beat. Let's see.

 

Then he rolls, and same thing happens. Checking who has the higher wins.

 

Suggestion two, if this proves impossible or too difficult to achieve.

 

The NPC says: Roll a number higher than 8, and you get your money double. Roll a 2, and you triple. Anything else, I win.

 

This way the NPC doesn't have to roll at all, and I only need to check the PC's results.

 

Any way this could be possible?

 

Note: If both of these are tough to achieve, I can always go for the gc_rand_1of, going for complete randomness on the nodes regardless of probability of two dice rolling.



#2
Psionic-Entity

Psionic-Entity
  • Members
  • 195 messages

Why not roll the dice on the PC line, store it as a variable on the PC, and then check it when the NPC responds?

 

If not, you could use a script that checks "1dX > Y" to simulate the right probabilities. 1/36 of a 12, then 2/35 for an 11, 3/33 for a 10, etc. until your last one is an "else" for the 2.



#3
Tchos

Tchos
  • Members
  • 5 042 messages

Your ideal choice can be done entirely using the gc_rand_1of script, 12 nodes for the NPC roll, and 12 nodes for the PC roll.  Or, it can be done with 1 node for each roll and a custom token for the responses.  In either case, as Psionic-Entity suggests, you should store the results as variables temporarily.



#4
Tchos

Tchos
  • Members
  • 5 042 messages

However, if you want to go more in depth, there is a real dice-rolling mod available for use in the Neverwinter Lights Casino.  It's attached to a Craps game, but perhaps you could extract just the dice-rolling visuals part.



#5
PJ156

PJ156
  • Members
  • 2 982 messages

I have a dice game in TLOS, in that I used rand which is fine with two dice. If you want more you are going to have to go with Tchos thoughts or perhaps generate a random integer.

 

If it's just two dice it need not be scripted though.

 

PJ



#6
Claudius33

Claudius33
  • Members
  • 256 messages

There are several dices games in Sarmates! (16 Cygni has also some).

 

For instance you can find a mini craps game in the module SM_Ulpia_Traiana.

 

Associated script : sm_craps

Associated convo : cv_coson



#7
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages

If you're comfortable with scripting, you can use the Set Custom Token function to re-write your conversations at runtime, using parameters passed along to an attached conversation script. 

 

Tokens are those strings used in conversation that vary according to the situation, like <lad/lass> or <quarterday>. Custom tokens are set using a 4-digit number, and then inserted in to conversations with something like <CUSTOM1234>. 

 

So instead of writing out twelve separate nodes for each roll, you create one node and attach a script that generates the roll and sets a custom token string with the generated number.

 

With some effort, you can do some pretty complex things with the custom tokens.  The Danaan Unvanquished has a crude poker game, some barter scripts, and a rough interrogation script written using custom tokens.  The Last of the Danaan v2.0 has some more polished barter/haggling scripts, if you want to take a look.



#8
andysks

andysks
  • Members
  • 1 645 messages

Good options. I'm afraid my scripting knowledge is not enough to do the thing Lugaid and Tchos suggest, and even though it could be the least time effort for you, the amount of time I would spend trying to make this script work, or even understand how to is not worth it. I will take a look now to the PJ and Claudius modules and probably go that way.

 

I will look into the custom tokens for future uses though. I already use some for journal on the quest system invented by Tchos, but that's as far as it goes, and I just follow the instructions there. I think I don't even understand what I'm really doing half the time :).



#9
andysks

andysks
  • Members
  • 1 645 messages

Claudius' script work perfect. Good job there. Had to study it a bit because I don't even know how one plays craps. Now I do.

 

Anyway, I encountered another problem on the same convo and I'll post it here rather than starting a new thread. I believe it's because I'm trying to play dice with a companion.

When I ga_take_gold, say 300, it takes it and gives it back. One the chat window I see.

 

Gold lost 300

Gold acquired 300

 

I tried changing the parameter of the script to 1, where it says for all party MP only, but nothing happened. Any ideas or workarounds here?

 

ps: I know companions and PC share stash, but I don't care. I just want the sum to reduce there if the PC loses.



#10
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages
Hi,

I know this comes a bit late, but I wrote a script for Quillmaster once for his NWN dice game. I tried looking for it, but I could not find it. However, I did find a couple of other scripts at the new Vault that you may want to look at:-

http://neverwinterva...script/dice-cup

http://neverwinterva...ice-ingame-game

I have not seen these myself, but they may give you some extra info.

Lance.

#11
Psionic-Entity

Psionic-Entity
  • Members
  • 195 messages

Claudius' script work perfect. Good job there. Had to study it a bit because I don't even know how one plays craps. Now I do.

 

Anyway, I encountered another problem on the same convo and I'll post it here rather than starting a new thread. I believe it's because I'm trying to play dice with a companion.

When I ga_take_gold, say 300, it takes it and gives it back. One the chat window I see.

 

Gold lost 300

Gold acquired 300

 

I tried changing the parameter of the script to 1, where it says for all party MP only, but nothing happened. Any ideas or workarounds here?

 

ps: I know companions and PC share stash, but I don't care. I just want the sum to reduce there if the PC loses.

Who is the PC in conversation with? I think the script you're using has to be called from an NPC because the command transfers gold instead of destroying it, if there's no NPC speaker or if the PC is in conversation with themself it will take and return the gold. If you want to keep it as is you need a new take gold script that has the "bDestroy" function in TakeGoldFromCreature set to TRUE.



#12
andysks

andysks
  • Members
  • 1 645 messages

Right on. The PC converses with a companion, so the gold actually makes a loop and returns, because PC and companion share the gold. I'll make another version to destroy it instead for this one occasion. Thanks.



#13
Tchos

Tchos
  • Members
  • 5 042 messages

This is what I was talking about before, for if you wanted to go more in-depth and include these dice-rolling visuals:

 


  • Lance Botelle aime ceci

#14
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages
Tchos,

Wow! That's impressive!

Lance.

#15
Claudius33

Claudius33
  • Members
  • 256 messages

Impressive, indeed.