112 lines
6.0 KiB
Plaintext
112 lines
6.0 KiB
Plaintext
#include "x4_inc_functions"
|
|
#include "mpoker_include"
|
|
int StartingConditional()
|
|
{
|
|
object oStool1 = GetNearestObjectByTag("mpoker_stool1");
|
|
object oStool2 = GetNearestObjectByTag("mpoker_stool2");
|
|
|
|
object oP1 = GetSittingCreature(oStool1);
|
|
object oP2 = GetSittingCreature(oStool2);
|
|
|
|
SetLocalObject(OBJECT_SELF, "oP1", oP1);
|
|
SetLocalObject(OBJECT_SELF, "oP2", oP2);
|
|
|
|
if (GetLocalInt(OBJECT_SELF, "STAGE") == 8)
|
|
{
|
|
//Retrieve PC's message
|
|
string sMessage = GetLocalString(OBJECT_SELF, "SPOKEN");
|
|
if (sMessage == "#no")
|
|
{
|
|
//Next stage
|
|
SetLocalInt(OBJECT_SELF, "STAGE", 1);
|
|
|
|
//Set tokens
|
|
int nStarter = GetLocalInt(OBJECT_SELF, "STARTER");
|
|
string sCurrent;
|
|
if (nStarter == 1) sCurrent = "oP2";
|
|
else sCurrent = "oP1";
|
|
object oPlayer = GetLocalObject(OBJECT_SELF, sCurrent);
|
|
SetCustomToken(917, GetName(oPlayer));
|
|
SetLocalString(OBJECT_SELF, "CURRENT", sCurrent);
|
|
|
|
//Choose new starter
|
|
if (GetLocalInt(OBJECT_SELF, "STARTER") != 1) SetLocalInt(OBJECT_SELF, "STARTER", 1);
|
|
else SetLocalInt(OBJECT_SELF, "STARTER", 2);
|
|
|
|
//Show hands
|
|
SendMessageToPC(oPlayer, ShowMHandAndScores("PLAYER2"));
|
|
SendMessageToPC(oPlayer, ShowMHandAndScores("PLAYER1"));
|
|
|
|
if (sCurrent == "oP1") sCurrent = "oP2";
|
|
else sCurrent = "oP1";
|
|
oPlayer = GetLocalObject(OBJECT_SELF, sCurrent);
|
|
SendMessageToPC(oPlayer, ShowMHandAndScores("PLAYER1"));
|
|
SendMessageToPC(oPlayer, ShowMHandAndScores("PLAYER2"));
|
|
|
|
//Find a winner!
|
|
object oPlayer1 = GetLocalObject(OBJECT_SELF, "oP"+IntToString(nStarter));
|
|
object oPlayer2;
|
|
if (nStarter == 1) oPlayer2 = GetLocalObject(OBJECT_SELF, "oP2");
|
|
else oPlayer2 = GetLocalObject(OBJECT_SELF, "oP1");
|
|
if(GetLocalInt(OBJECT_SELF, "PLAYER1_SCORE_MAIN") > GetLocalInt(OBJECT_SELF, "PLAYER2_SCORE_MAIN")) {
|
|
//Player wins. Main score is higher than dealer main score.
|
|
//SpeakString("My, my, you win sir, fine game.");
|
|
GiveGoldToCreature(oPlayer1, GetLocalInt(OBJECT_SELF, "POT"));
|
|
SetCustomToken(916, GetName(oPlayer1));
|
|
}
|
|
else if(GetLocalInt(OBJECT_SELF, "PLAYER2_SCORE_MAIN") > GetLocalInt(OBJECT_SELF, "PLAYER1_SCORE_MAIN")) {
|
|
//Dealer wins. Main score is higher than player main score.
|
|
//SpeakString("I do believe I win. How fortuitous.");
|
|
GiveGoldToCreature(oPlayer2, GetLocalInt(OBJECT_SELF, "POT"));
|
|
SetCustomToken(916, GetName(oPlayer2));
|
|
}
|
|
else if(GetLocalInt(OBJECT_SELF, "PLAYER2_SCORE_MAIN") == GetLocalInt(OBJECT_SELF, "PLAYER1_SCORE_MAIN")) {
|
|
//Tie. Main scores are tied, proceed to check first scores.
|
|
if(GetLocalInt(OBJECT_SELF, "PLAYER1_SCORE_FIRST") > GetLocalInt(OBJECT_SELF, "PLAYER2_SCORE_FIRST")) {
|
|
//Player wins. First score is higher than dealer main score.
|
|
//SpeakString("How strange, you win. My congratulations.");
|
|
GiveGoldToCreature(oPlayer1, GetLocalInt(OBJECT_SELF, "POT"));
|
|
SetCustomToken(916, GetName(oPlayer1));
|
|
}
|
|
else if(GetLocalInt(OBJECT_SELF, "PLAYER2_SCORE_FIRST") > GetLocalInt(OBJECT_SELF, "PLAYER1_SCORE_FIRST")) {
|
|
//Dealer wins. First score is higher than player main score.
|
|
//SpeakString("You came close my friend, but I do believe the game is mine.");
|
|
GiveGoldToCreature(oPlayer2, GetLocalInt(OBJECT_SELF, "POT"));
|
|
SetCustomToken(916, GetName(oPlayer2));
|
|
}
|
|
else if(GetLocalInt(OBJECT_SELF, "PLAYER2_SCORE_FIRST") == GetLocalInt(OBJECT_SELF, "PLAYER1_SCORE_FIRST")) {
|
|
//Tie. First scores are tied, proceed to check second scores.
|
|
if(GetLocalInt(OBJECT_SELF, "PLAYER1_SCORE_SECOND") > GetLocalInt(OBJECT_SELF, "PLAYER2_SCORE_SECOND")) {
|
|
//Player wins. Second score is higher than dealer main score.
|
|
//SpeakString("A close one, you win.");
|
|
GiveGoldToCreature(oPlayer1, GetLocalInt(OBJECT_SELF, "POT"));
|
|
SetCustomToken(916, GetName(oPlayer1));
|
|
}
|
|
else if(GetLocalInt(OBJECT_SELF, "PLAYER2_SCORE_SECOND") > GetLocalInt(OBJECT_SELF, "PLAYER1_SCORE_SECOND")) {
|
|
//Dealer wins. Second score is higher than player main score.
|
|
//SpeakString("A close one, but my skill prevails.");
|
|
GiveGoldToCreature(oPlayer2, GetLocalInt(OBJECT_SELF, "POT"));
|
|
SetCustomToken(916, GetName(oPlayer2));
|
|
}
|
|
else if(GetLocalInt(OBJECT_SELF, "PLAYER2_SCORE_SECOND") == GetLocalInt(OBJECT_SELF, "PLAYER1_SCORE_SECOND")) {
|
|
//Tie. Main, First and Second scores all tied. Game is a tie!
|
|
//SpeakString("A tie? My, my, we shall have to play again my friend.");
|
|
GiveGoldToCreature(oPlayer1, GetLocalInt(OBJECT_SELF, "POT")/2);
|
|
GiveGoldToCreature(oPlayer2, GetLocalInt(OBJECT_SELF, "POT")/2);
|
|
SetCustomToken(916, GetName(oPlayer1)+" and "+GetName(oPlayer2));
|
|
}
|
|
}
|
|
}
|
|
|
|
//Reset the pot.
|
|
SetLocalInt(OBJECT_SELF, "POT", 0);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|