1. Bones Gambling Script
2. This is a simple gambling game initiated through a conversation with an
NPC. The rules are such that the player bets a set amount (defined through
the conversation and set through SetLocalInt("BonesWager", #). The NPC rolls
2 dice and the PC has to match the number to win. The payout is 3x the wager
amount. The script is attached as an Actions Taken after the wager is
placed.
NWScript:
void main()
{
object oPC = GetPCSpeaker();
int nPCwin = 0;
int nWager = GetLocalInt(oPC, "BonesWager");
int nWinnings = (nWager*3);
int nGold = GetGold(oPC);
if (nGold - nWager >= 0)
{
int nNPCROLL = (Random(5)+1)+(Random(5)+1);
ActionSpeakString("I rolled a " + IntToString(nNPCROLL), TALKVOLUME_TALK);
int nPCROLL = (Random(5)+1)+(Random(5)+1);
DelayCommand (2.0, ActionSpeakString("You rolled a " + IntToString(nPCROLL), TALKVOLUME_TALK));
if (nNPCROLL == nPCROLL)
{
DelayCommand (2.0, ActionSpeakString("You win " + IntToString(nWinnings) + " gold pieces!", TALKVOLUME_TALK));
DelayCommand (2.5, GiveGoldToCreature(oPC, nWinnings));
}
else
{
DelayCommand (2.0, ActionSpeakString("You lose", TALKVOLUME_TALK));
DelayCommand (2.5, TakeGoldFromCreature(nWager, oPC, TRUE));
}
}
else
{
ActionSpeakString("You don't have enough gold.");
}
}
There are variations that can be added, I believe, like allowing a Dex check
to help influence the outcome. I'm trying to design a House of Games and am
even thinking about having 'loaded dice' in the game that could be used
during this game. I'm not sure how to fully implement them, though.
If you use it or modify it, I would like to know. Actual credit isn't
necessary as it isn't that original of a script.
sdf2008@stygianlabyrinth.net
|