From c56e99943dc23212d9cc848562ead13aa1acb305 Mon Sep 17 00:00:00 2001 From: Lorenc Date: Wed, 21 Mar 2018 04:47:45 +1100 Subject: [PATCH] reconfigure comps with appropriate house edge --- gamemodes/sf-cnr.pwn | 50 +++++++++++++------ .../irresistible/{colours.inc => colors.inc} | 0 .../features/visage/blackjack.inc | 10 ++-- .../irresistible/features/visage/casino.inc | 4 +- .../irresistible/features/visage/poker.inc | 6 +-- .../irresistible/features/visage/roulette.inc | 4 +- pawno/include/irresistible/main.inc | 2 +- 7 files changed, 51 insertions(+), 25 deletions(-) rename pawno/include/irresistible/{colours.inc => colors.inc} (100%) diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 4695de3..c2aa002 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -2173,14 +2173,17 @@ new ; /* ** Casino Rewards Points ** */ -#define CASINO_REWARDS_DIVISOR 5000.0 // (for every X in $10K, they get Y points) -#define CASINO_REWARDS_COST_MP 15 // 10x the supa save costs +#define CASINO_REWARDS_PAYOUT_PERCENT 20.0 +#define CASINO_REWARDS_DIVISOR 10.0 // 1000 points becomes 1 point +#define CASINO_REWARDS_COST_MP 0.5 // half of the price (since it costs (1/payout_percent) times more) new g_casinoRewardsShopItems[ ] = { 5, 6, 7, 8, 9, 10, 11 }, - Float: p_CasinoRewardsPoints [ MAX_PLAYERS ] + Float: p_CasinoRewardsPoints [ MAX_PLAYERS ], + Text3D: p_RewardsLabel_4Drags [ MAX_PLAYERS ] = { Text3D: INVALID_3DTEXT_ID, ... }, + Text3D: p_RewardsLabel_Caligs [ MAX_PLAYERS ] = { Text3D: INVALID_3DTEXT_ID, ... } ; /* ** Easter Eggs ** */ @@ -3314,7 +3317,7 @@ main() public OnGameModeInit() { - SetGameModeText( "Cops And Robbers" ); + SetGameModeText( "Cops And Robbers/DM/Gangs" ); SetServerRule( "hostname", SERVER_NAME ); SetServerRule( "language", "All (English)" ); UsePlayerPedAnims( ); @@ -4953,6 +4956,10 @@ public OnServerUpdate( ) PlayerTextDrawSetString( playerid, p_LocationTD[ playerid ], GetPlayerArea( playerid ) ); PlayerTextDrawSetString( playerid, p_ExperienceTD[ playerid ], sprintf( "%08d", p_XP[ playerid ] ) ); + // Update casino labels + UpdateDynamic3DTextLabelText( p_RewardsLabel_Caligs[ playerid ], COLOR_GOLD, sprintf( "[CASINO REWARDS]\n\n"COL_WHITE"You have %0.2f rewards points!", p_CasinoRewardsPoints[ playerid ] ) ); + UpdateDynamic3DTextLabelText( p_RewardsLabel_4Drags[ playerid ], COLOR_GOLD, sprintf( "[CASINO REWARDS]\n\n"COL_WHITE"You have %0.2f rewards points!", p_CasinoRewardsPoints[ playerid ] ) ); + // Toggle total coin bar if ( !p_PlayerSettings[ playerid ] { SETTING_COINS_BAR } ) PlayerTextDrawSetString( playerid, p_CoinsTD[ playerid ], sprintf( "%05.3f", p_IrresistibleCoins[ playerid ] ) ); @@ -6034,6 +6041,12 @@ public OnPlayerConnect( playerid ) removeExcessiveBuildings( playerid ); initializePlayerInteriors( playerid ); + // Create casino label + DestroyDynamic3DTextLabel( p_RewardsLabel_Caligs[ playerid ] ); + DestroyDynamic3DTextLabel( p_RewardsLabel_4Drags[ playerid ] ); + p_RewardsLabel_Caligs[ playerid ] = CreateDynamic3DTextLabel( "[CASINO REWARDS]", COLOR_GOLD, 2157.6294, 1599.4355, 1006.1797, 20.0, .playerid = playerid ); + p_RewardsLabel_4Drags[ playerid ] = CreateDynamic3DTextLabel( "[CASINO REWARDS]", COLOR_GOLD, 1951.7191, 997.55550, 992.85940, 20.0, .playerid = playerid ); + // Reset some variables p_Spawned { playerid } = false; p_GangID [ playerid ] = INVALID_GANG_ID; @@ -19685,16 +19698,20 @@ public OnPlayerUseSlotMachine( playerid, slotid, first_combo, second_combo, thir // readjust casino pool data UpdateCasinoPoolData( poolid, .pool_increment = -iNetWin, .total_win = iNetWin ); + // alert user + if ( iNetWin >= 10000 ) { + SendGlobalMessage( -1, ""COL_GREY"[CASINO]{FFFFFF} %s(%d) has won "COL_GOLD"%s"COL_WHITE" from the %s casino slots!", ReturnPlayerName( playerid ), playerid, ConvertPrice( iNetWin ), g_slotmachineData[ slotid ] [ E_ENTRY_FEE ] == 10000 ? ( "Four Dragons" ) : ( "Caligulas" ) ); + } else { + SendServerMessage( playerid, "Congratulations, you've won "COL_GOLD"%s"COL_WHITE"!", ConvertPrice( iNetWin ) ); + } + // give the cash GivePlayerCash( playerid, iNetWin ); PlayerPlaySound( playerid, 4201, 0.0, 0.0, 0.0 ); // Coin fall - GameTextForPlayer( playerid, "~w~~h~winner!", 5000, 6 ); - return SendGlobalMessage( -1, ""COL_GREY"[CASINO]{FFFFFF} %s(%d) has won "COL_GOLD"%s"COL_WHITE" from the %s casino!", ReturnPlayerName( playerid ), playerid, ConvertPrice( iNetWin ), g_slotmachineData[ slotid ] [ E_ENTRY_FEE ] == 10000 ? ( "Four Dragons" ) : ( "Caligulas" ) ); - // return SendServerMessage( playerid, "Congratulations, you've won "COL_GOLD"%s"COL_WHITE"!", ConvertPrice( iNetWin ) ); + return 1; } - GivePlayerCasinoRewardsPoints( playerid, g_slotmachineData[ slotid ] [ E_ENTRY_FEE ] ); return GameTextForPlayer( playerid, "~w~~h~no win!", 2500, 6 ); } @@ -22484,7 +22501,7 @@ public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if ( x == listitem ) { - new Float: rewards_cost = float( g_shopItemData[ i ] [ E_PRICE ] * CASINO_REWARDS_COST_MP ) / CASINO_REWARDS_DIVISOR; + new Float: rewards_cost = ( float( g_shopItemData[ i ] [ E_PRICE ] ) * CASINO_REWARDS_COST_MP ) / CASINO_REWARDS_DIVISOR; if ( p_CasinoRewardsPoints[ playerid ] < rewards_cost ) return SendError( playerid, "You need %0.2f more rewards points for this item.", rewards_cost ); @@ -27484,8 +27501,6 @@ stock initializeCheckpoints( ) CreateDynamic3DTextLabel("[REFILL AMMO]", COLOR_GOLD, 1579.5439, -1635.5166, 13.5609, 20.0); #endif - CreateDynamic3DTextLabel("[CASINO REWARDS]", COLOR_GOLD, 2157.6294, 1599.4355, 1006.1797, 20.0); - CreateDynamic3DTextLabel("[CASINO REWARDS]", COLOR_GOLD, 1951.7191, 997.5555, 992.8594, 20.0); CreateDynamic3DTextLabel("[REFILL AMMO]", COLOR_GOLD, -1615.2600, 685.5120, 7.1875, 20.0); CreateDynamic3DTextLabel("[PAWNSHOP]", COLOR_GOLD, 1333.0847, -1080.0726, 968.0430, 20.0); CreateDynamic3DTextLabel("[SHOP]", COLOR_GOLD, -29.0409,-184.7446,1003.5469, 20.0); @@ -36049,6 +36064,7 @@ stock TriggerPlayerSlotMachine( playerid, machineid ) return SendError( playerid, "You must have at least %s to use this slot machine.", ConvertPrice( entryFee ) ), ( p_AutoSpin{ playerid } = false ), 1; // Update casino pool + GivePlayerCasinoRewardsPoints( playerid, g_slotmachineData[ machineid ] [ E_ENTRY_FEE ], .house_edge = g_slotmachineData[ machineid ] [ E_ENTRY_FEE ] == 10000 ? 10.0 : 25.0 ); UpdateCasinoPoolData( g_slotmachineData[ machineid ] [ E_POOL_ID ], .pool_increment = poolContribute, .total_win = 0, .total_gambled = entryFee ); // Charge the player @@ -37153,9 +37169,11 @@ stock GetBusinessAirModelIndex( modelid ) { return index; } -stock GivePlayerCasinoRewardsPoints( playerid, lost_amount ) { - if ( lost_amount < 0 ) print("[casino error] negative reward amount used"), lost_amount *= -1; - p_CasinoRewardsPoints[ playerid ] += lost_amount / CASINO_REWARDS_DIVISOR; +stock GivePlayerCasinoRewardsPoints( playerid, bet_amount, Float: house_edge ) { + if ( bet_amount < 0 ) bet_amount *= -1; // profit or loss, does not matter + // printf("(%f * ((%f * 100.0) * (%f / 100.0))) / %f\n",bet_amount, house_edge, CASINO_REWARDS_PAYOUT_PERCENT, CASINO_REWARDS_DIVISOR); + new Float: final_points = ( bet_amount * ( ( house_edge / 100.0 ) * ( CASINO_REWARDS_PAYOUT_PERCENT / 100.0 ) ) ) / CASINO_REWARDS_DIVISOR; + p_CasinoRewardsPoints[ playerid ] += final_points; mysql_single_query( sprintf( "UPDATE `USERS` SET `CASINO_REWARDS`=%f WHERE `ID`=%d", p_CasinoRewardsPoints[ playerid ], p_AccountID[ playerid ] ) ); return 1; } @@ -37168,7 +37186,7 @@ stock ShowPlayerRewardsMenu( playerid ) { strcat( szString, ""COL_WHITE"Item\t"COL_WHITE"Purpose\t"COL_WHITE"Rewards Points\n" ); for( new i; i < sizeof( g_shopItemData ); i++ ) if ( IsCasinoRewardsShopItem( i ) ) { - new Float: rewards_cost = float( g_shopItemData[ i ] [ E_PRICE ] * CASINO_REWARDS_COST_MP ) / CASINO_REWARDS_DIVISOR; + new Float: rewards_cost = ( float( g_shopItemData[ i ] [ E_PRICE ] ) * CASINO_REWARDS_COST_MP ) / CASINO_REWARDS_DIVISOR; format( szString, sizeof( szString ), "%s%s\t"COL_GREY"%s\t"COL_GOLD"%0.2f points\n", szString, g_shopItemData[ i ] [ E_NAME ], g_shopItemData[ i ] [ E_USAGE ], rewards_cost ); } } @@ -37194,6 +37212,8 @@ stock GetPlayerAccountID( playerid ) return p_AccountID[ playerid ]; stock GetPlayerVIPLevel( playerid ) return p_VIPLevel[ playerid ]; +stock GetPlayerAdminLevel( playerid ) return p_AdminLevel[ playerid ]; + stock IsPlayerSpawned( playerid ) return p_Spawned{ playerid }; stock UpdatePlayerEntranceExitTick( playerid, ms = 2500 ) { diff --git a/pawno/include/irresistible/colours.inc b/pawno/include/irresistible/colors.inc similarity index 100% rename from pawno/include/irresistible/colours.inc rename to pawno/include/irresistible/colors.inc diff --git a/pawno/include/irresistible/features/visage/blackjack.inc b/pawno/include/irresistible/features/visage/blackjack.inc index bac44f3..aa1a14a 100644 --- a/pawno/include/irresistible/features/visage/blackjack.inc +++ b/pawno/include/irresistible/features/visage/blackjack.inc @@ -567,6 +567,7 @@ stock CheckForBlackjack( tableid ) g_blackjackPlayerState[ tableid ] [ player_index ] = BLACKJACK_STATE_WIN; SendClientMessageToBlackjack( tableid, COLOR_GREY, "[BLACKJACK]"COL_WHITE" %s(%d) has been returned %s due to a push.", ReturnPlayerName( playerid ), playerid, ConvertPrice( payout ) ); GameTextForPlayer( playerid, sprintf( "~n~~n~~g~%s won!", ConvertPrice( payout ) ), 4000, 3 ); + GivePlayerCasinoRewardsPoints( playerid, g_blackjackData[ tableid ] [ E_PAYOUT ], .house_edge = 1.5 ); GivePlayerCash( playerid, payout ); } else if ( player_score == 21 ) { @@ -578,16 +579,17 @@ stock CheckForBlackjack( tableid ) SendClientMessageToBlackjack( tableid, COLOR_GREY, "[BLACKJACK]"COL_WHITE" %s(%d) has won %s due to a card count of 21!", ReturnPlayerName( playerid ), playerid, ConvertPrice( payout ) ); } GameTextForPlayer( playerid, sprintf( "~n~~n~~g~%s won!", ConvertPrice( payout ) ), 4000, 3 ); + GivePlayerCasinoRewardsPoints( playerid, g_blackjackData[ tableid ] [ E_PAYOUT ], .house_edge = 1.5 ); GivePlayerCash( playerid, payout ); } else if ( dealer_score == 21 ) { - GivePlayerCasinoRewardsPoints( playerid, g_blackjackData[ tableid ] [ E_PAYOUT ] ); + GivePlayerCasinoRewardsPoints( playerid, g_blackjackData[ tableid ] [ E_PAYOUT ], .house_edge = 1.5 ); g_blackjackPlayerState[ tableid ] [ player_index ] = BLACKJACK_STATE_BUST; SendClientMessageToBlackjack( tableid, COLOR_GREY, "[BLACKJACK]"COL_WHITE" %s(%d) has lost %s due to a dealer %s.", ReturnPlayerName( playerid ), playerid, ConvertPrice( g_blackjackData[ tableid ] [ E_PAYOUT ] ), IsDealerHandBlackjack( tableid, dealer_score ) ? ( "blackjack" ) : ( "21" ) ); GameTextForPlayer( playerid, "~n~~n~~r~No win!", 4000, 3 ); } else if ( player_score > 21 ) { - GivePlayerCasinoRewardsPoints( playerid, g_blackjackData[ tableid ] [ E_PAYOUT ] ); + GivePlayerCasinoRewardsPoints( playerid, g_blackjackData[ tableid ] [ E_PAYOUT ], .house_edge = 1.5 ); g_blackjackPlayerState[ tableid ] [ player_index ] = BLACKJACK_STATE_BUST; SendClientMessageToBlackjack( tableid, COLOR_GREY, "[BLACKJACK]"COL_WHITE" %s(%d) has lost %s due to a bust.", ReturnPlayerName( playerid ), playerid, ConvertPrice( g_blackjackData[ tableid ] [ E_PAYOUT ] ) ); GameTextForPlayer( playerid, "~n~~n~~r~No win!", 4000, 3 ); @@ -596,10 +598,11 @@ stock CheckForBlackjack( tableid ) g_blackjackPlayerState[ tableid ] [ player_index ] = BLACKJACK_STATE_WIN; SendClientMessageToBlackjack( tableid, COLOR_GREY, "[BLACKJACK]"COL_WHITE" %s(%d) has won %s due to a dealer bust.", ReturnPlayerName( playerid ), playerid, ConvertPrice( payout ) ); GameTextForPlayer( playerid, sprintf( "~n~~n~~g~%s won!", ConvertPrice( payout ) ), 4000, 3 ); + GivePlayerCasinoRewardsPoints( playerid, g_blackjackData[ tableid ] [ E_PAYOUT ], .house_edge = 1.5 ); GivePlayerCash( playerid, payout ); } else if ( player_score < dealer_score && dealer_score >= 17 ) { - GivePlayerCasinoRewardsPoints( playerid, g_blackjackData[ tableid ] [ E_PAYOUT ] ); + GivePlayerCasinoRewardsPoints( playerid, g_blackjackData[ tableid ] [ E_PAYOUT ], .house_edge = 1.5 ); g_blackjackPlayerState[ tableid ] [ player_index ] = BLACKJACK_STATE_BUST; SendClientMessageToBlackjack( tableid, COLOR_GREY, "[BLACKJACK]"COL_WHITE" %s(%d) has lost %s due to a bust.", ReturnPlayerName( playerid ), playerid, ConvertPrice( g_blackjackData[ tableid ] [ E_PAYOUT ] ) ); GameTextForPlayer( playerid, "~n~~n~~r~No win!", 4000, 3 ); @@ -608,6 +611,7 @@ stock CheckForBlackjack( tableid ) g_blackjackPlayerState[ tableid ] [ player_index ] = BLACKJACK_STATE_WIN; SendClientMessageToBlackjack( tableid, COLOR_GREY, "[BLACKJACK]"COL_WHITE" %s(%d) has won %s due to a dealer bust.", ReturnPlayerName( playerid ), playerid, ConvertPrice( g_blackjackData[ tableid ] [ E_PAYOUT ] ) ); GameTextForPlayer( playerid, sprintf( "~n~~n~~g~%s won!", ConvertPrice( payout ) ), 4000, 3 ); + GivePlayerCasinoRewardsPoints( playerid, g_blackjackData[ tableid ] [ E_PAYOUT ], .house_edge = 1.5 ); GivePlayerCash( playerid, payout ); } diff --git a/pawno/include/irresistible/features/visage/casino.inc b/pawno/include/irresistible/features/visage/casino.inc index 0556143..bd95df9 100644 --- a/pawno/include/irresistible/features/visage/casino.inc +++ b/pawno/include/irresistible/features/visage/casino.inc @@ -10,8 +10,8 @@ /* ** Constants ** */ stock VISAGE_ENTRANCE = ITER_NONE; -stock const VISAGE_INTERIOR = 10; -stock const VISAGE_WORLD = 30; +stock const VISAGE_INTERIOR = 15; +stock const VISAGE_WORLD = 79; /* ** Hooks ** */ hook OnGameModeInit( ) diff --git a/pawno/include/irresistible/features/visage/poker.inc b/pawno/include/irresistible/features/visage/poker.inc index 66b63d7..f9d3628 100644 --- a/pawno/include/irresistible/features/visage/poker.inc +++ b/pawno/include/irresistible/features/visage/poker.inc @@ -1956,7 +1956,7 @@ stock CheckShowdown(handle) new w_chips = floatround(float(TableData[handle][E_TABLE_POT_CHIPS][pot_id]) * (1.0 - T_POT_FEE_RATE)); new fee_earned = floatround((float(TableData[handle][E_TABLE_POT_CHIPS][pot_id]) / 1000.0) * T_POT_FEE_RATE); UpdateServerVariable( "poker_fees", 0, GetGVarFloat( "poker_fees" ) + fee_earned, "", GLOBAL_VARTYPE_FLOAT ); - GivePlayerCasinoRewardsPoints(high_id, fee_earned); + GivePlayerCasinoRewardsPoints(high_id, fee_earned, .house_edge = 100.0); SendTableMessage(handle, "{9FCF30}****************************************************************************************"); SendTableMessage(handle, "{9FCF30}Player {FF8000}%s {9FCF30}has won with a {377CC8}%s", ReturnPlayerName(high_id), HAND_RANKS[highest_rank >> 12]); SendTableMessage(handle, "{9FCF30}Prize: {377CC8}%s | -%0.0f%s percent fee.", ConvertPrice(w_chips), T_POT_FEE_RATE * 100.0, "%%"); @@ -1977,7 +1977,7 @@ stock CheckShowdown(handle) if(!Iter_Contains(IT_PlayersInGame, p)) continue; if(PlayerRanks[p] == highest_rank) { - GivePlayerCasinoRewardsPoints(p, floatround(float(fee_earned) / float(count))); + GivePlayerCasinoRewardsPoints(p, floatround(float(fee_earned) / float(count)), .house_edge = 100.0); SendTableMessage(handle, "{9FCF30}%s", ReturnPlayerName(p)); PlayerData[p][E_PLAYER_TOTAL_CHIPS] += amount; } @@ -2173,7 +2173,7 @@ stock bool: FoldPlayer(handle, playerid) new w_chips = floatround(float(TableData[handle][E_TABLE_POT_CHIPS][MAIN_POT]) * (1.0 - T_POT_FEE_RATE)); new fee_earned = floatround((float(TableData[handle][E_TABLE_POT_CHIPS][MAIN_POT]) / 1000.0) * T_POT_FEE_RATE); UpdateServerVariable( "poker_fees", 0, GetGVarFloat( "poker_fees" ) + fee_earned, "", GLOBAL_VARTYPE_FLOAT ); - GivePlayerCasinoRewardsPoints(winner, fee_earned); + GivePlayerCasinoRewardsPoints(winner, fee_earned, .house_edge = 100.0); SendTableMessage(handle, "{9FCF30}Prize: {377CC8}%s | -%0.0f%s percent fee", ConvertPrice(w_chips), T_POT_FEE_RATE * 100.0, "%%"); SendTableMessage(handle, "{9FCF30}****************************************************************************************"); PlayerData[winner][E_PLAYER_TOTAL_CHIPS] += w_chips; diff --git a/pawno/include/irresistible/features/visage/roulette.inc b/pawno/include/irresistible/features/visage/roulette.inc index 236a7e2..919b72c 100644 --- a/pawno/include/irresistible/features/visage/roulette.inc +++ b/pawno/include/irresistible/features/visage/roulette.inc @@ -672,13 +672,15 @@ public OnRouletteWheelStop( rouletteid, winner ) SendGlobalMessage( -1, ""COL_GREY"[CASINO]{FFFFFF} %s(%d) has won "COL_GOLD"%s"COL_WHITE" from roulette!", ReturnPlayerName( playerid ), playerid, ConvertPrice( profit ) ); } + // give user points + GivePlayerCasinoRewardsPoints( playerid, waged, .house_edge = 2.7 ); + // gametext if ( profit > 0 ) { GameTextForPlayer( playerid, sprintf( "~n~~n~~g~%s won!", ConvertPrice( profit ) ), 4000, 3 ); SendClientMessageFormatted( playerid, -1, ""COL_GREY"[ROULETTE]"COL_WHITE" You have bet a total of %s and profited %s! (winning no %d)", ConvertPrice( waged ), ConvertPrice( profit ), winner ); } else { profit *= -1; // to improve the client message - GivePlayerCasinoRewardsPoints( playerid, profit ); GameTextForPlayer( playerid, "~n~~n~~r~No win!", 4000, 3 ); SendClientMessageFormatted( playerid, -1, ""COL_GREY"[ROULETTE]"COL_WHITE" You have bet a total of %s and lost %s! (winning no %d)", ConvertPrice( waged ), ConvertPrice( profit ), winner ); } diff --git a/pawno/include/irresistible/main.inc b/pawno/include/irresistible/main.inc index c43e741..d7bd206 100644 --- a/pawno/include/irresistible/main.inc +++ b/pawno/include/irresistible/main.inc @@ -11,7 +11,7 @@ #include < irresistible\helpers > #include < irresistible\floodcontrol > #include < irresistible\mailer > -#include < irresistible\colours > +#include < irresistible\colors > #include < irresistible\attachments > #include < irresistible\lookup > #include < irresistible\servervars >