|
|
|
 |
 |
 |
 |
|
 |
 |
|
 |
 |
|
 |
|
| Quests::Custom Custom Quests here |
 |
|
 |

01-19-2017, 04:50 PM
|
 |
Dragon
|
|
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
|
|
Code:
#############
#Quest Name: Black Jack's Blackjack
#Author: Cisyouc
#################
sub DealCard
{
return quest::ChooseRandom(1,2,3,4,5,6,7,8,9,10,11);
}
sub EVENT_SAY
{
my $permissions = $qglobals{"permissions"};
my $serverTotal = $qglobals{"serverTotal"};
my $clientTotal = $qglobals{"clientTotal"};
if($text=~/hail/i)
{
quest::say("Greetings! Want to play balackjack? Hand me your bet to begin! All games return double on win! $permissions");
return; #return on each say
}
if($permissions < 1)
{ #easier to escape than than heavily nested if/else conditions
quest::say("Have you bet?");
return;
}
if($text=~/deal/i)
{
my $card1 = DealCard();
my $card2 = DealCard();
$clientTotal = $card1 + $card2;
$serverTotal = DealCard() + DealCard();
if($serverTotal < 16)
{
$serverTotal = $serverTotal + DealCard();
}
quest::say("The dealer passes you a $card1 and a $card2 giving you a total of $clientTotal. The dealer is showing a $serverTotal. Say [ ". quest::saylink("yes")." ] for another card or [ ". quest::saylink("no")." ] to stay.");
quest::setglobal("permissions", 2, 0, "F"); #set permissions
quest::setglobal("clientTotal", $clientTotal, 0, "F"); #set permissions
quest::setglobal("serverTotal", $serverTotal, 0, "F"); #set permissions
return;
}
if($text=~/yes/i)
{
if($permissions != 2)
{
quest::say("You must [ ". quest::saylink("deal")." ] first!");
return;
}
my $card1 = DealCard();
$clientTotal = $clientTotal + $card1;
quest::setglobal("clientTotal", $clientTotal, 0, "F"); #set permissions
if ($clientTotal > 21) {
quest::say("The dealer has handed you a $card1, giving you a total of $clientTotal. You bust, and lose the game.");
quest::setglobal("bet", 0, 0, "F"); #reset
quest::setglobal("permissions", 0, 0, "F"); #reset
return;
}
quest::say("The dealer has handed you a $card1, giving you a total of $clientTotal. The deal is showing a $serverTotal. Say [ ". quest::saylink("yes")." ] for another card or [ ". quest::saylink("no")." ] to stay.");
return;
}
if($text=~/no/i)
{
if($permissions != 2)
{
quest::say("You must [ ". quest::saylink("deal")." ] first!");
return;
}
my $iWon = 0;
if ($clientTotal > 21 && $serverTotal < 21)
{ #client went over, server didn't
} elsif ($serverTotal > 21 && $clientTotal < 21)
{ #server went over, client didn't
$iWon = 1;
} elsif ($clientTotal < $serverTotal && $serverTotal <= 21)
{ #server won fair
} elsif ($serverTotal < $clientTotal && $clientTotal <= 21)
{ #client won fair
$iWon = 1;
}
if (!$iWon)
{
quest::say("Dealer wins with $serverTotal. Thanks for playing.");
} else
{
quest::say("You win with $clientTotal. Thanks for playing.");
my $cash = $qglobals{"bet"};
$copper = ($cash % 10);
$silver = (int ($cash / 10) % 10);
$gold = (int ($cash / 100) % 10);
$platinum = int ($cash / 1000);
quest::givecash($copper, $silver, $gold, $platinum); #Give money
}
quest::setglobal("bet", 0, 0, "F"); #reset
quest::setglobal("permissions", 0, 0, "F"); #reset
return;
}
}
sub EVENT_ITEM
{
my $cash = $copper + ($silver * 10) + ($gold * 100) + ($platinum * 1000);
if ($cash < 1) {
quest::say("You must give me money to bet");
return;
}
if ($qglobals{"permissions"} > 0) {
quest::say("You still have a deal going on.");
return;
}
$cash = $cash * 2; #double the bet
quest::say("Your bet of $platinum platinum, $gold gold, $silver silver, $copper copper has been saved. You may [ ". quest::saylink("deal")." ] the cards now.");
quest::setglobal("bet", $cash, 0, "F"); #easier to just set all money.
quest::setglobal("permissions", 1, 0, "F"); #set permissions
}
I'd probably use entity variables to reduce the read/writes to DB, but try the above.
|
 |
|
 |
 |
|
 |

01-19-2017, 09:32 PM
|
|
Hill Giant
|
|
Join Date: Dec 2004
Location: Pittsburgh, PA
Posts: 128
|
|
That' beautiful Shin. Just for laughs I will show you what I've been doing for the last 24 hours and still had not figured it out. I found myself in a loop trying to fix one issue then creating another. lol I appreciate your time. Thanks again.
Code:
#############
#Quest Name: Black Jack's Blackjack
#Author: Cisyouc
#################
sub DealCard
{
return quest::ChooseRandom(1,2,3,4,5,6,7,8,9,10,11);
}
sub EVENT_SAY
{
my $permissions = $qglobals{"permissions"};
my $serverTotal = $qglobals{"serverTotal"};
my $clientTotal = $qglobals{"clientTotal"};
if($text=~/hail/i)
{
quest::say("Greetings $name! Would you like to play some Blackjack? The closest to 21 without going over wins. Dealer wins on a tie. I only accept PLATINUM as a wager and 40pp is the maximum bet. All games return double your wager on win. Dealer must draw atleast one card when showing 16 or lower on the deal to win, dealer only will only hit on 17 and above when losing. Just hand me your bet between 1pp and 40pp to begin! !");
return; #return on each say
}
if($permissions < 1)
{ #easier to escape than than heavily nested if/else conditions
quest::say("Have you bet?");
return;
}
if($text=~/deal/i)
{
if($permissions > 1)
{ #easier to escape than than heavily nested if/else conditions
quest::say("This round has already been dealt, The dealer passes you a $card1 and a $card2 giving you a total of $clientTotal. The dealer is showing a $serverTotal. Say [ ". quest::saylink("hit")." ] for another card or [ ". quest::saylink("stay")." ].");
return;
}
my $card1 = DealCard();
my $card2 = DealCard();
my $card3 = DealCard();
my $card4 = DealCard();
$clientTotal = $card1 + $card2;
$serverTotal = $card3 + $card4;
if ($clientTotal > 21) {
quest::say("The dealer has handed you a $card1, giving you a total of $clientTotal. You bust, and lose the game.");
quest::setglobal("bet", 0, 0, "F"); #reset
quest::setglobal("permissions", 0, 0, "F"); #reset
return;
}
if ($serverTotal > 20 && $serverTotal < 22) {
quest::say("The dealer has a BLACKJACK. You lose the game.");
quest::setglobal("bet", 0, 0, "F"); #reset
quest::setglobal("permissions", 0, 0, "F"); #reset
return;
}
if ($serverTotal > 21) {
quest::say("The dealer has busted with a total of $clientTotal. You win the game.");
{$iWon = 1;
}
if (!$iWon)
{
quest::say("Dealer wins with $serverTotal. Thanks for playing.");
} else
{
quest::say("The dealer continues to draw and has busted. You win with $clientTotal. Thanks for playing.");
my $cash = $qglobals{"bet"};
$copper = ($cash % 1);
$cash -= $copper;
$silver = ($cash % 1);
$cash -= $silver;
$gold = ($cash % 1);
$cash -= $gold;
$platinum = ($cash % 100)/10;
quest::givecash($copper, $silver, $gold, $platinum * 10); #Give money
}
quest::setglobal("bet", 0, 0, "F"); #reset
quest::setglobal("permissions", 0, 0, "F"); #reset
return;
}
quest::say("The dealer passes you a $card1 and a $card2 giving you a total of $clientTotal. The dealer is showing a $serverTotal. Say [ ". quest::saylink("hit")." ] for another card or [ ". quest::saylink("stay")." ].");
quest::setglobal("permissions", 2, 0, "F"); #set permissions
quest::setglobal("clientTotal", $clientTotal, 0, "F"); #set permissions
quest::setglobal("serverTotal", $serverTotal, 0, "F"); #set permissions
return;
}
if ($serverTotal < 17)
{
$serverTotal = $serverTotal + $card4;
}
if ($serverTotal > 21 && $clientTotal < 22) {
quest::say("The dealer has drawn another card and busted. You win the game.");
{$iWon = 1;
}
if (!$iWon)
{
quest::say("Dealer wins with $serverTotal. Thanks for playing.");
} else
{
my $cash = $qglobals{"bet"};
$copper = ($cash % 1);
$cash -= $copper;
$silver = ($cash % 1);
$cash -= $silver;
$gold = ($cash % 1);
$cash -= $gold;
$platinum = ($cash % 100)/10;
quest::givecash($copper, $silver, $gold, $platinum * 10); #Give money
}
quest::setglobal("bet", 0, 0, "F"); #reset
quest::setglobal("permissions", 0, 0, "F"); #reset
return;
}
if($text=~/hit/i)
{
if($permissions != 2)
{
quest::say("You must [ ". quest::saylink("deal")." ] first!");
return;
}
my $card3 = DealCard();
$clientTotal = $clientTotal + $card3;
quest::setglobal("clientTotal", $clientTotal, 0, "F"); #set permissions
if ($clientTotal > 21) {
quest::say("The dealer has handed you a $card3, giving you a total of $clientTotal. You bust, and lose the game.");
quest::setglobal("bet", 0, 0, "F"); #reset
quest::setglobal("permissions", 0, 0, "F"); #reset
return;
}
quest::say("The dealer has handed you a $card3, giving you a total of $clientTotal. The dealer continues and is now showing a $serverTotal. Say [ ". quest::saylink("hit")." ] for another card or [ ". quest::saylink("stay")." ].");
return;
}
if($text=~/stay/i)
{
if($permissions != 2)
{
quest::say("You must [ ". quest::saylink("deal")." ] first!");
return;
}
my $iWon = 0;
if ($clientTotal > 21 && $serverTotal < 21)
{ #client went over, server didn't
} elsif ($serverTotal > 21 && $clientTotal < 21)
{ #server went over, client didn't
$iWon = 1;
} elsif ($clientTotal < $serverTotal && $serverTotal <= 21)
{ #server won fair
} elsif ($serverTotal < $clientTotal && $clientTotal <= 21)
{ #client won fair
$iWon = 1;
}
if (!$iWon)
{
quest::say("Dealer continues and wins with $serverTotal. Thanks for playing.");
} else
{
quest::say("The dealer continues to draw and busted. You win with $clientTotal. Thanks for playing.");
my $cash = $qglobals{"bet"};
$copper = ($cash % 1);
$cash -= $copper;
$silver = ($cash % 1);
$cash -= $silver;
$gold = ($cash % 1);
$cash -= $gold;
$platinum = ($cash % 100)/10;
quest::givecash($copper, $silver, $gold, $platinum * 10); #Give money
}
quest::setglobal("bet", 0, 0, "F"); #reset
quest::setglobal("permissions", 0, 0, "F"); #reset
return;
}
}
sub EVENT_ITEM
{
my $cash = $platinum;
if ($cash < 1) {
quest::say("I only accept PLATINUM as a wager!");
return;
}
if ($qglobals{"permissions"} > 0) {
quest::say("You still have a deal going on.");
return;
}
$cash = $cash * 2; #double the bet
quest::say("Your wager of $platinum platinum has been saved. You may [ ". quest::saylink("deal")." ] the cards now.");
quest::setglobal("bet", $cash, 0, "F"); #easier to just set all money.
quest::setglobal("permissions", 1, 0, "F"); #set permissions
}
|
 |
|
 |

01-19-2017, 11:55 PM
|
|
Hill Giant
|
|
Join Date: Dec 2004
Location: Pittsburgh, PA
Posts: 128
|
|
Blackjack in action
Love the new Blackjack, addicting. I got a new dealer in town.  Also added, if the dealer gets a blackjack the game ends in a loss. Tried to make it as close to casino Blackjack as possible. Thanks again for the help.

|

01-20-2017, 12:14 AM
|
|
Hill Giant
|
|
Join Date: Dec 2004
Location: Pittsburgh, PA
Posts: 128
|
|
Added the profit to the dialog when you win. Took some big losses on this one. lol

|
| Thread Tools |
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 02:50 AM.
|
|
 |
|
 |
|
|
|
 |
|
 |
|
 |