// GO button on first part on (release) { gotoAndPlay("Scene 2", 1); game = false; ptotal = "N/A"; status = "Welcome!"; aces = 0; wins = 0; losses = 0; ties = 0; games = 0; hits = 0; ctotalb = "N/A"; betb = 10; cash = 500; crapstands = 0; } // NEW Button on (release) { bet = int(betb); if (cash == 0) { status = "Bankrupt! Here's 2 dollars."; cash = 2; } if (game == false && bet > 0 && bet <= cash) { games++; game = true; cards = 2; ccards = 2; ptotal = 0; textgen = number(random(20)); if (textgen == 0) status = "Think you can beat me?"; if (textgen == 1) status = "I will win."; if (textgen == 2) status = "You will lose."; if (textgen == 3) status = "You have no chance."; if (textgen == 4) status = "My AI is superior."; if (textgen == 5) status = "I can read your mind."; if (textgen == 6) status = "Luck is nonexistant."; if (textgen == 7) status = "Go ahead. Try."; if (textgen == 8) status = "You are quite unskilled."; if (textgen == 9) status = "I think faster than you."; if (textgen == 10) status = "You suck."; if (textgen == 11) status = "Praise The Snufuss."; if (textgen == 12) status = "David thinks I cheat. I don't."; if (textgen == 13) status = "Try to find the secret area."; if (textgen == 14) status = "Everyone is laughing at you."; if (textgen == 15) status = "Please."; if (textgen == 16) status = "Why do you persist?"; if (textgen == 17) status = "I think faster than you."; if (textgen == 18) status = "Just give up."; if (textgen == 19) status = "Fine, waste your time."; //RESET EVERYTHING aces = 0; caces = 0; climit = 18; p1 = number(random(52)) + 2; p2 = number(random(52)) + 2; p3 = number(random(52)) + 2; p4 = number(random(52)) + 2; p5 = number(random(52)) + 2; p6 = number(random(52)) + 2; c1 = number(random(52)) + 2; c2 = number(random(52)) + 2; c3 = number(random(52)) + 2; c4 = number(random(52)) + 2; c5 = number(random(52)) + 2; c6 = number(random(52)) + 2; while (p1 == p2) { p2 = number(random(52)) + 2; } while (p2 == p3) { p3 = number(random(52)) + 2; } while (p3 == p4) { p4 = number(random(52)) + 2;// <----- makes sure the numbers are not equal } while (p4 == p5) { p5 = number(random(52)) + 2; } while (p5 == p6) { p6 = number(random(52)) + 2; } while (p6 == c1) { c1 = number(random(52)) + 2; } while (p6 == c1) { c1 = number(random(52)) + 2; } while (p6 == c1) { c1 = number(random(52)) + 2; } while (c1 == c2) { c2 = number(random(52)) + 2; } while (c2 == c3) { c3 = number(random(52)) + 2; } while (c3 == c4) { c4 = number(random(52)) + 2; } while (c4 == c5) { c5 = number(random(52)) + 2; } while (c5 == c6) { c6 = number(random(52)) + 2; } tellTarget ("/p1") gotoAndStop (/:p1); tellTarget ("/p2") gotoAndStop (/:p2); tellTarget ("/p3") gotoAndStop (54); tellTarget ("/p4") gotoAndStop (54); tellTarget ("/p5") gotoAndStop (54); tellTarget ("/p6") gotoAndStop (54); tellTarget ("/c1") gotoAndStop (/:c1); tellTarget ("/c2") gotoAndStop (1); tellTarget ("/c3") gotoAndStop (54); tellTarget ("/c4") gotoAndStop (54); tellTarget ("/c5") gotoAndStop (54); tellTarget ("/c6") gotoAndStop (54); //CALCULATE TOTAL AND ACTUAL CARD VALUES FOR PLAYERS p1v = int((p1-1.1)/4+1); p2v = int((p2-1.1)/4+1); p3v = int((p3-1.1)/4+1); p4v = int((p4-1.1)/4+1); p5v = int((p5-1.1)/4+1); p6v = int((p6-1.1)/4+1); c1v = int((c1-1.1)/4+1); c2v = int((c2-1.1)/4+1); c3v = int((c3-1.1)/4+1); c4v = int((c4-1.1)/4+1); c5v = int((c5-1.1)/4+1); c6v = int((c6-1.1)/4+1); if (p1v > 10) p1v = 10; if (p2v > 10) p2v = 10; if (p3v > 10) p3v = 10; if (p4v > 10) p4v = 10; if (p5v > 10) p5v = 10; if (p6v > 10) p6v = 10; if (c1v > 10) c1v = 10; if (c2v > 10) c2v = 10; if (c3v > 10) c3v = 10; if (c4v > 10) c4v = 10; if (c5v > 10) c5v = 10; if (c6v > 10) c6v = 10; ptotal = p1v + p2v; ctotal = c1v + c2v; if (ptotal <= 11 && p1v == 1) { ptotal = ptotal + 10; aces++; } if (ptotal <= 11 && p2v == 1) { ptotal = ptotal + 10; aces++; } if (ctotal <= 11 && c1v == 1) { ctotal = ctotal + 10; caces++; } if (ctotal <= 11 && c2v == 1) { ctotal = ctotal + 10; caces++; } if (ptotal == 21 && ctotal != 21) { status = "Blackjack!"; game = false; ctotalb = ctotal; tellTarget ("/c2") gotoAndStop (/:c2); wins++; cash = cash + bet; } else if (ptotal == 21 && ctotal == 21) { status = "Push!"; game = false; ctotab = ctotal; tellTarget ("/c2") gotoAndStop (/:c2); ties++; } if (ctotal < climit) cstand = false; else cstand = true; ccards = 2; ctotalb = c1v; } } //HIT button on (release) { if (game == true) { hits++; if (cards == 5) { tellTarget ("/p6") gotoAndStop (/:p6); ptotal = ptotal + p6v; game = false; if (ptotal < 11 && p6v == 1) { ptotal = ptotal + 10; aces++; } if (ctotal < 11 && c6v == 1) { ctotal = ctotal + 10; caces++; } if (cstand == false && ctotal < climit) { ctotal = ctotal + c6v; tellTarget ("/c6") gotoAndStop (1); ccards++; } else cstand = true; } if (cards == 4) { tellTarget ("/p5") gotoAndStop (/:p5); ptotal = ptotal + p5v; cards++; if (ptotal < 11 && p5v == 1) { ptotal = ptotal + 10; aces++; } if (ctotal < 11 && c5v == 1) { ctotal = ctotal + 10; caces++; } if (cstand == false && ctotal < climit) { ctotal = ctotal + c5v; tellTarget ("/c5") gotoAndStop (1); ccards++ } else cstand = true; } if (cards == 3) { tellTarget ("/p4") gotoAndStop (/:p4); ptotal = ptotal + p4v; cards++; if (ptotal < 11 && p4v == 1) { ptotal = ptotal + 10; aces++; } if (ctotal < 11 && c4v == 1) { ctotal = ctotal + 10; caces++; } if (cstand == false && ctotal < climit) { ctotal = ctotal + c4v; tellTarget ("/c4") gotoAndStop (1); ccards++ } else cstand = true; } if (cards == 2) { tellTarget ("/p3") gotoAndStop (/:p3); ptotal = ptotal + p3v; cards++; if (ptotal < 11 && p3v == 1) { ptotal = ptotal + 10; aces++; } if (ctotal < 11 && c3v == 1) { ctotal = ctotal + 10; caces++; } if (cstand == false) { ctotal = ctotal + c3v; tellTarget ("/c3") gotoAndStop (1); ccards++; } } while (aces > 0 && ptotal > 21) { ptotal = ptotal - 10; aces--; } while (caces > 0 && ctotal > 21) { ctotal = ctotal - 10; caces--; } if (ptotal == 21) { status = "Good job!"; } if (ptotal > 21) { ctotalb = ctotal; tellTarget ("/c2") gotoAndStop (/:c2); if (ccards > 2) tellTarget ("/c3") gotoAndStop (/:c3); if (ccards > 3) tellTarget ("/c4") gotoAndStop (/:c4); if (ccards > 4) tellTarget ("/c5") gotoAndStop (/:c5); if (ccards > 5) tellTarget ("/c6") gotoAndStop (/:c6); game = false; if (ctotal > 21) { status = "Push!"; ties++; } else { status = "Bust! You lose!" losses++; cash = cash - bet; } } if (ctotal > 21) cstand = true; if (ptotal < 17) climit = ptotal + 2; else climit = 18; } } //STAND button on (release) { if (game == true) { if (ptotal < 17) climit = ptotal + 2; else climit = 18; if (ccards == 2 && cstand == false && ctotal < climit) { ctotal = ctotal + c3v; tellTarget ("/c3") gotoAndStop (1); ccards++; if (ctotal < 11 && c3v == 1) { ctotal = ctotal + 10; caces++; } } else cstand = true; if (ccards == 3 && cstand == false && ctotal < climit) { ctotal = ctotal + c4v; tellTarget ("/c3") gotoAndStop (1); ccards++; if (ctotal < 11 && c4v == 1) { ctotal = ctotal + 10; caces++; } } else cstand = true; if (ccards == 4 && cstand == false && ctotal < climit) { ctotal = ctotal + c5v; tellTarget ("/c3") gotoAndStop (1); ccards++; if (ctotal < 11 && c5v == 1) { ctotal = ctotal + 10; caces++; } } else cstand = true; if (ccards == 5 && cstand == false && ctotal < climit) { ctotal = ctotal + c6v; tellTarget ("/c3") gotoAndStop (1); ccards++; if (ctotal < 11 && c6v == 1) { ctotal = ctotal + 10; caces++; } } else cstand = true; while (caces > 0 && ctotal > 21) { ctotal = ctotal - 10; caces--; } ctotalb = ctotal; tellTarget ("/c2") gotoAndStop (/:c2); if (ccards > 2) tellTarget ("/c3") gotoAndStop (/:c3); if (ccards > 3) tellTarget ("/c4") gotoAndStop (/:c4); if (ccards > 4) tellTarget ("/c5") gotoAndStop (/:c5); if (ccards > 5) tellTarget ("/c6") gotoAndStop (/:c6); if (ptotal > ctotal) { status = "You win!"; game = false; wins++; cash = cash + bet * 1; } if (ptotal < ctotal && ctotal < 22) { status = "You lose!" game = false; losses++; cash = cash - bet; } if (ptotal == ctotal && ctotal < 22) { status = "Push!" game = false; ties++; } if (ctotal > 21) { status = "Computer busted!"; game = false; wins++; cash = cash + bet * 1; } } else { crapstands++; if (crapstands == 20) gotoAndStop ("Scene 3", 1); } } //SECRET AREA button (click stand a lot of times) on (release) { gotoAndPlay("Scene 2", 1); game = false; ptotal = "fish"; status = "fish"; aces = 99; wins = "fish"; losses = "fish"; ties = "fish"; games = "fish"; hits = "fish"; ctotalb = "fish"; betb = "fish"; cash = 1000000; crapstands = -10000; }