• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Mod Release Three new locations in Colombia (including Gambling House)

Here's my version of "gamble.c", and also "Habitue_dialog.h", containing an extra line for when you score 21 by drawing more cards and the gambler tries to draw to match it.

The logic is already scattered through various parts of "gamble.c" - start the game, add a card, update the table, show the end result. A natural 21 is an ace plus 10 or face card at the start of the game, so that's where I've put the code to detect it. It then sets "bStop" to true because the game won't continue if anyone got a natural 21, and also sets variable "iNatural21" to note who got it. Function 'UpdateTable()' then detects "bStop", checks "iNatural21", and ends the game appropriately.

I've played a lot of hands of vingt-un recently, partly to test the game and also when testing the new drinker/gambler characters in Santiago and Havana. It seems to work correctly.

And the earlier question still stands - do we want such characters in Cartagena taverns too? That gives players the choice of normal stakes or the casino's high stakes. (Besides, all the casino characters have "Sneak" skill 10, though they're not protected by "questchar" which means the levelling system will scramble their skills. ;))
 

Attachments

  • gamble.c
    107.2 KB · Views: 120
  • Habitue_dialog.h
    5.8 KB · Views: 121
Last edited:
Here's my version of "gamble.c", and also "Habitue_dialog.h", containing an extra line for when you score 21 by drawing more cards and the gambler tries to draw to match it.

I will stick with your earlier gamble.c since I have already placed new code in there (plus re-adding poker shuffle and allowing 3 raise levels). When I looked earlier most of the differences to @Levis later post seem to be tidying the trace facility anyway (well apart from your individual code aesthetic differences). I haven't even bothered to look at your latest . I am sure you will be able to merge any differences later.
do we want such characters in Cartagena taverns too?
I would say place one in the tavern that otherwise has least use as a possible further incentive to go there, no idea which that would be.

I still want to do more with this but imo at this point it's at a point where it can be included. At a later point I want to look at making the roulette actually work :) . I'm also thinking of adding another gambling house in another location which could use some love (tortuga?) where a small reskin should be enough :) .

When @Jack Rackham and I started on our gambler trophy quest it would have been the only place not a tavern in which to gamble, the only place for higher stakes, the only place where you could continue to gamble once the tavern players thought you were too good AND only for the Gambler type. Plus playing poker would be reworked in the process.

Now a lot of the uniqueness is undermined. However given all the work already put in (mostly by JRH) we will persevere although personally I am less inclined to spend the extra time coding a repeating competition scenario rather than a one off tournament since you will now be able to gamble elsewhere for high stakes.

Our location is in Grand Turk so a little close to Tortuga - so maybe that casino could exclude poker? Although ONLY a gambler will be able to enter our gaming room that is a very watered down distinction from where we started and much less of an incentive to try the player type. I guess since, as been pointed out, the Gambler already has a unique quest it doesn't really matter - you get that quest and then the chance to win the trophy.
 
When @Jack Rackham and I started on our gambler trophy quest it would have been the only place not a tavern in which to gamble, the only place for higher stakes, the only place where you could continue to gamble once the tavern players thought you were too good AND only for the Gambler type. Plus playing poker would be reworked in the process.

Now a lot of the uniqueness is undermined. However given all the work already put in (mostly by JRH) we will persevere although personally I am less inclined to spend the extra time coding a repeating competition scenario rather than a one off tournament since you will now be able to gamble elsewhere for high stakes.

Our location is in Grand Turk so a little close to Tortuga - so maybe that casino could exclude poker? Although ONLY a gambler will be able to enter our gaming room that is a very watered down distinction from where we started and much less of an incentive to try the player type. I guess since, as been pointed out, the Gambler already has a unique quest it doesn't really matter - you get that quest and then the chance to win the trophy.

I'm totally fine with remove poker from the casino and only have vingt-un in it. I mostly want to get the roulette working later. If you want I could even remove the higher stakes from the casino, it was mostly to give it some use. the code is still there so it's easy for you to use. From what I understood first you wanted to make your competition even more high stakes. in the casino it's only a slight bump.

I sugested tortuga because it's one of the locations with still a lot of doors which lead nowhere, but anyone is good for me. And I'm also fine with only having one in cartagena
 
I'm totally fine with remove poker from the casino and only have vingt-un in it. I mostly want to get the roulette working later.
I really hope you can get a version of roulette to work - lots of different bet options to cover in programming there. If you do then perhaps removing poker from them both (or all if you decide to place more) would be an option. That way high stakes poker play would be restricted to the trophy quest [except see below].


If you want I could even remove the higher stakes from the casino, it was mostly to give it some use. the code is still there so it's easy for you to use.
No I think it's best to see both elements in game, compare them and their feel and then consider if tweaks somewhere would enhance game play.

From what I understood first you wanted to make your competition even more high stakes. in the casino it's only a slight bump.
Yes but it isn't really high stakes in a hand by hand sense. You have an entry fee (at the moment 20000) and a potential winners pot of 60000 so it's a big win (could even be 30000 in and 90000 pot by the time it emerges) but unless you have the perk the hand limit is still 2000 (per player) and you, of course, have to win all the chips on the table (however many I allocate to each player). So actually a different challenge in reality. I would like to add some AI for the NPC to raise based on their hand, or fold too (well it remains an ambition for now - certainly won't see the light of day in the first release).

I sugested tortuga because it's one of the locations with still a lot of doors which lead nowhere, but anyone is good for me. And I'm also fine with only having one in cartagena
I agree the more life these places have the more use they may see. Tortuga sounds a perfect place for effectively unlicensed = untaxed gambling to get established.
 
The logic is already scattered through various parts of "gamble.c" - start the game, add a card, update the table, show the end result. A natural 21 is an ace plus 10 or face card at the start of the game, so that's where I've put the code to detect it. It then sets "bStop" to true because the game won't continue if anyone got a natural 21, and also sets variable "iNatural21" to note who got it. Function 'UpdateTable()' then detects "bStop", checks "iNatural21", and ends the game appropriately.
I just took a look at your version again and I seriously would recommend to use the version I made (with some of the spelling errors you caught). Doing the natural 21 like this imo doesn't make much sense. you now have the check in a function called StartGame which just isn't logical at all. You are saying the logic is scattered trough the file but it is not. All the logic for determining the outcome of the game is set in the updatetable function, that was one of the goals or making this better.
This is only adding another global variable, and global variable aren't the best thing to have, they could very easily conflict with other stuff. In my version the exact same outcome is done but it checks at the same place as it does the other checks, it just checks if you have 2 cards in hand or not. I understand you like cases, that is something I could look into but because of the fact that the potc scripting language doesn't work with if cases which have and and or statements together it's very hard to define them properly in cases, thats why it's done with nested if statements. Also you are using an int which have a certain value but this value is not really explained. if you do something like this imo it would be better to define the different int's as constants so you can refer to those to make it easier to comprehend.
At the moment there still is the bstop variable which is used to stop the game if limits are reached (so to many cards in hand) or if the gambler has a bigger hand. I think that last case can actually be removed and it would still work. I do think it would help the file if the whole bstop would be removed to make it even easier to read and I think that should be dooable. If you want I could look into that and make a better version somewhere before this weekend with some cleaned up logic. I could look into using some switches for the logic because I also like switches. But I will pull back the natural 21 to the updatetable function, so if you are going to put it back in the way you want anyways I don't see any reason to try to improve the logic of the file more to make it easier for others to edit later.

Also for some reason you keep remove the ClearDiscardImage function from your function and I don't see why you do that. imo having that as a function makes the whole code easier to read and makes it easier to find what to change when needed. I mean if you are looking at this
Code:
case "Poker":
            if(DEBUG_GAMBLING>1) trace("GAMBLING: Set Game to Poker");
            CreateImage("LEFT_01",imageGroup, "",285,269,360,364);
            CreateImage("LEFT_02",imageGroup, "",290,269,365,364);
            CreateImage("LEFT_03",imageGroup, "",293,269,394,369);
            CreateImage("LEFT_04",imageGroup, "",295,269,374,365);
            CreateImage("LEFT_05",imageGroup, "",297,269,392,369);
            CreateImage("LEFT_06",imageGroup, "",280,269,350,357);
            CreateImage("LEFT_07",imageGroup, "",270,269,362,329);
            CreateImage("LEFT_08",imageGroup, "",275,274,367,334);
            CreateImage("LEFT_09",imageGroup, "",260,250,360,335);
            CreateImage("LEFT_10",imageGroup, "",270,255,378,352);
        break;

or this
Code:
case "Poker":
            if(DEBUG_GAMBLING>1) trace("GAMBLING: Set Game to Poker");
            ClearDiscardImages();
        break;
imo the second one is a lot easier to determin what is happening without knowing what the different images actually mean. Especially because the naming isn't that great either.

I really hope you can get a version of roulette to work - lots of different bet options to cover in programming there. If you do then perhaps removing poker from them both (or all if you decide to place more) would be an option. That way high stakes poker play would be restricted to the trophy quest [except see below].

From what I read the gambler trophie will take a bit longer so give me a bit of time on this too but I'll promise that once I got the roulette to work I will change the card player in the gambling house to only play vingt-un so you can use poker in your tournament :) .

Yes but it isn't really high stakes in a hand by hand sense. You have an entry fee (at the moment 20000) and a potential winners pot of 60000 so it's a big win (could even be 30000 in and 90000 pot by the time it emerges) but unless you have the perk the hand limit is still 2000 (per player) and you, of course, have to win all the chips on the table (however many I allocate to each player). So actually a different challenge in reality. I would like to add some AI for the NPC to raise based on their hand, or fold too (well it remains an ambition for now - certainly won't see the light of day in the first release).

I was also considering adding "chips" to the gambling house before. I didn't implement it yet. It would require some more work on the gambling files but it should be dooable, it would just be a matter of everywhere where gold is added or subtracted to change that to chips. If you are going to use them in your tournament I think it would be nice if they aren't in the gambling house, but I would like your opinion on it :) .
 
I just took a look at your version again and I seriously would recommend to use the version I made (with some of the spelling errors you caught). Doing the natural 21 like this imo doesn't make much sense. you now have the check in a function called StartGame which just isn't logical at all.
On the contrary, it is extremely logical. If the game starts with someone having a natural 21, it should not continue any further.

There should be no problem with global variables. They should not conflict with anything else unless someone isn't looking at the definitions and tries to use the same variable name for something else, in which case they'll soon find out about it when the game crashes with an error about a duplicate variable. They have not been a problem in the past; there is no reason not to continue using them when needed.

Also for some reason you keep remove the ClearDiscardImage function from your function and I don't see why you do that. imo having that as a function makes the whole code easier to read and makes it easier to find what to change when needed. I mean if you are looking at this
Code:
case "Poker":
            if(DEBUG_GAMBLING>1) trace("GAMBLING: Set Game to Poker");
            CreateImage("LEFT_01",imageGroup, "",285,269,360,364);
            CreateImage("LEFT_02",imageGroup, "",290,269,365,364);
            CreateImage("LEFT_03",imageGroup, "",293,269,394,369);
            CreateImage("LEFT_04",imageGroup, "",295,269,374,365);
            CreateImage("LEFT_05",imageGroup, "",297,269,392,369);
            CreateImage("LEFT_06",imageGroup, "",280,269,350,357);
            CreateImage("LEFT_07",imageGroup, "",270,269,362,329);
            CreateImage("LEFT_08",imageGroup, "",275,274,367,334);
            CreateImage("LEFT_09",imageGroup, "",260,250,360,335);
            CreateImage("LEFT_10",imageGroup, "",270,255,378,352);
        break;

or this
Code:
case "Poker":
            if(DEBUG_GAMBLING>1) trace("GAMBLING: Set Game to Poker");
            ClearDiscardImages();
        break;
imo the second one is a lot easier to determin what is happening without knowing what the different images actually mean. Especially because the naming isn't that great either.
Whereas I find it easier to see exactly what is happening without having to trace through to a function somewhere else in the file. Functions are useful for preventing the same piece of code being duplicated. This one isn't being duplicated.

In any case, there are far more serious issues than just a choice of programming style:
Poll - Renaming Blackjack
 
Whereas I find it easier to see exactly what is happening without having to trace through to a function somewhere else in the file. Functions are useful for preventing the same piece of code being duplicated. This one isn't being duplicated.
In that case, a simple comment could be added to explain what that code does.
That's always a good strategy anyway. :doff
 
From what I read the gambler trophie will take a bit longer so give me a bit of time on this too but I'll promise that once I got the roulette to work I will change the card player in the gambling house to only play vingt-un so you can use poker in your tournament :) .
Thanks for the kind consideration. It may be that, since as you gambling level goes over 100 you can't play in a tavern, play in the gambling houses may be the only normally available place. So it may be a case of see how it feels in-game. It could also be possible to add in some cross fertilisation with, for example, the gambling house recognizing pchar as the tournament winner in some way(for as long as they hold the title).



I was also considering adding "chips" to the gambling house before. I didn't implement it yet. It would require some more work on the gambling files but it should be dooable,
We've already done it. We had to get the gaming mechanisms altered first, because if that didn't work right there was little point in the rest

it would just be a matter of everywhere where gold is added or subtracted to change that to chips. If you are going to use them in your tournament I think it would be nice if they aren't in the gambling house, but I would like your opinion on it :) .
A lot simpler than that, just store away both players money and give them an amount of chips in the same variable for use through gamble.c, give them their money back after the game - leave the code alone. Oh and put some new text in place in game to mention "out of chips" for example. I did the same with changing the name in the interface, change it, start the interface, change it back so all the switches in the code still work - much easier than changing all the uses in the code (or writing new code for another game variant). The chips themselves are part of @Jack Rackham 's work so his opinion is key. I would prefer not seeing chips in card games in the gambling houses -yes, but am relaxed about their use in the new roulette. What do you think @Jack Rackham ?
 
About gambling in taverns: have you ever tried to match dice or cards with the old admiral in Pointe a Pitre tavern, Guadeloupe? That one has a lot higher "Sneak" skill than most. There's going to be one in Havana as well. Perhaps set an attribute on these characters which can be recognised by "Habitue_dialog.c" so that they will gamble with you if your "quest.gambling" has passed the 100 limit.

(My idea for Havana is to have two gamblers. One, who sits near the back downstairs, is there all the time, is a professional gambler, and will fleece you unless you're also well skilled. The other, who sits near the entrance, only shows up at night; he's a manual worker who goes to the tavern to relax after a day's work, and is an easier mark for less skilled player gamblers.)
 
A lot simpler than that, just store away both players money and give them an amount of chips in the same variable for use through gamble.c, give them their money back after the game - leave the code alone.
HA!
Clever.
I love simple solutions like that. :cheeky
 
There may be a bug in function 'GetMaxRaises()' in "gamble.c":
Code:
int GetMaxRaises()
{
   if(DEBUG_GAMBLING>0) trace("GAMBLING: Called function GetMaxRaises");
   int MaxRaises = 0;
   bool QuestBet = false;
   //Quest related best
   if(CheckAttribute(playerChar,"quest.Contraband.CardsBet"))
   {
       MaxRaises = 0; //We don't want the player raising during this game.
   }
  
   if(!QuestBet)
   {
       switch(playerChar.location)
       {  
           case "Cartagena Casino":
               MaxRaises = 2;
           break;
          
           //default:
           MaxRaises = 3;
       }
   }
   return MaxRaises;
}
It sets variable "QuestBet" to be false and never changes the variable. If you're playing for a smuggling timetable then it sets "MaxRaises" to 0. Then, if "QuestBet" is false, which it will be because it hasn't changed, the function sets "MaxRaises" to 2 or 3 depending on where you're playing. If I read this correctly, that means it will change "MaxRaises" even if you're playing for the smuggling timetable. Should there perhaps be a line 'QuestBet = true;' inside the check for "quest.Contraband.CardsBet"?
 
There may be a bug in function 'GetMaxRaises()' in "gamble.c":

If you're playing for a smuggling timetable then it sets "MaxRaises" to 0. Then, if "QuestBet" is false, which it will be because it hasn't changed, the function sets "MaxRaises" to 2 or 3 depending on where you're playing.

Is this for @Levis, @pedrwyth or @Jack Rackham...?
Either way, looks like some follow-up is required.

Not my code but the analysis seems correct.
Elsewhere in an analogous situation (in function UpdateBetImages) there is indeed a reset of QuestBet inside the if(CheckAttribute(playerChar,"quest.Contraband.CardsBet")) check to avoid subsequent undoing of the stuff within the check.

however rather than more code I would suggest less

if(CheckAttribute(playerChar,"quest.Contraband.CardsBet")) QuestBet = true;

since MaxRaises is already set to 0 at the start of the function the set to 0 is redundant and this would then avoid it changing.
 
Back
Top