• 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!

Trophies in the Free Play mode

I have changed so the books can be sold now. If you manage to steal all books you'll
get a reward - but with a twist...
 
Given the possible developments elsewhere I think we need to give an outline of what the gambler trophy quest is intended to contain. Basically it is an opportunity to enter a Pan-Caribbean invitation poker tournament at a new location

If you're not a Gambler this may well be you only opportunity to glimpse the location

4-poker-jpg.38788

(it would have been more casino like but that ship seems to have sailed in the interim - so the drawing board had to be revisited!).


The quest is given as an additional bonus to "a girl won in a card game" - if you are a gambler and actually win the girl by dicing (no it's not a card game -but adapted dialogue deals with that minor issue) otherwise if you just kill the npc what kind of a gambler are you? Competition consists of a number of games of poker against different opponents (poker has been altered in functionality to allow increasing your bet depending on your improved hand strength - other tweaks may be included). The competition could prove to be a regular invitational event (if you are that gambler type) although it's run by a couple of desperados.


rr-jpg.38755

Can you win and then next tournament defend the title?

Some of the functionality of this is delivered by changes in habitue_dialogue and gamble.c. This means that @Jack Rackham and I have a vested interest (and a number of changes both made and in progress) to at least these files involved in the gambling sequence.
 
Last edited:
Given the possible developments elsewhere I think we need to give an outline of what the gambler trophy quest is intended to contain. Basically it is an opportunity to enter a Pan-Caribbean invitation poker tournament at a new location

If you're not a Gambler this may well be you only opportunity to glimpse the location

4-poker-jpg.38788

(it would have been more casino like but that ship seems to have sailed in the interim - so the drawing board had to be revisited!).
I only added the casino (now renamed "gambling house"), I haven't worked on an actual quest yet, just brainstorming for idea's. So if you want to use the location feel free to ask and you could. Or if you want you can use some of the assets I made for it in your location. I mean it's not that weird to have two big gambling locations in the Caribbean, especially with this one being on the main land. I was hoping on adding another one somewhere else, so if you want to feel free to do that.
 
@pedrwyth here is a WIP version of the gamble.c interface file I've been working on. Still need to finish up some of the debug strings but I think this should be a lot more clear.
If you look in the GetGameBet function you'll that the functionality you where talking about is already build in. So probably this file will make it easier for you :) .

Some other fixes done to it
- the code for showing the card images is cleaned up so it should be understandable now
- you can easily add stuff to the gamebet (like text etc) like being done for the smuggling poker game (search for quest stuff in the file)
- the shuffling of cards is now better, I noticed that if you did like 20 games in a row there was a small chance (in poker) of a card not showing up because the substring function sometimes did a bit weird)
- you can now have more then 1 card pack be shuffled (for now it's everywhere still default on 1 because the parameters are there already so should be very easy to implement), for games like blackjack having more card decks in the game increases the chance for the dealer to win.
- the AI for poker now also detects if it almost has a flush and if you have no pair it will try to go for a flush.
- High card scores now also work for poker, so if you both have no pair or anything the person with the highest card wins
- The AI will keep the highest card it has if this is a jack or higher when it has no pair at all and would normally change the whole hand. Just to increase the chance on a higher pair or else a high card.
- You can set bets based on the locations of the character
- Some fixes concerning edge cases
- For blackjack it now shows the first card of the dealer face up while the rest is face down so you as a player have more descissions to make
- If you've done a gamble for the patrol time and won the game will automaticly close if you try to start a new game (this might also be usefull for you to use as you might want to limit the amount of games).
- For both poker and blackjack the pack of cards is only reshuffled after you depleted it. So if you got an a three of a kind for aces in the first game and you get an ace in the next hand too you know it's not possible to get another aces unless the deck has been reshuffled (it now only gives an audio que, I still working on making sure this is communicated more clearly). It will also not reshuffle the cards already in play if the reshuffle happens during a game. So there is no possebility of getting two the same cards (unless you add more decks to the game ;) ).

--- Still working on---
There is an error (which has been there for a while alraeady about a dialog file problem when opening the gamling interface, still trying to fix that

I want to clean up the code which determines which remarks are being done by the oponent so it's easier to add stuff here too

The AI and game should be in a state where you could add more than 1 round of changing cards. I haven't implemented it yet but as far as I see al functions and stuff should now work that it should be possible to have the turn go back to the player after changing cards. This might be interesting for you too
 

Attachments

  • gamble.c
    93.9 KB · Views: 127
Last edited:
@pedrwyth here is a WIP version of the gamble.c interface file I've been working on. Still need to finish up some of the debug strings but I think this should be a lot more clear.
If you look in the GetGameBet function you'll that the functionality you where talking about is already build in. So probably this file will make it easier for you :) .
Thanks for the file. I have looked at it and tried a number of hands - had two hands where king high was said to beat Ace high (i have the compile log for at least one if you haven't seen that behaviour).

However I have altered where the gambler shows his poker hand and placed a further UpdateBetButtons(BetIndex) to allow betting on a changed hand. I can't quite see how to do that for an unchanged (ie pat, high value hand), yet - I think I need a console command to set up that type of hand because it takes forever if you're waiting on a clean deal to produce it . Here is the file as I currently have it (my changes tagged PW), you can probably make a more elegant code solution for that functionality.

I had also earlier got rid of the laughter /sound effects and changed most of the in game messages (for a tournament setting) since the swearing and gloating is out of place there. I can easily add all that back in when your code is finalised together with the change to chips, hand count etc.
- For both poker and blackjack the pack of cards is only reshuffled after you depleted it.
I can understand that for blackjack/twenty one but not for poker consequently I have added in a shuffle before each poker hand is dealt.
 

Attachments

  • gamble.c
    96.1 KB · Views: 135
Thanks for the file. I have looked at it and tried a number of hands - had two hands where king high was said to beat Ace high (i have the compile log for at least one if you haven't seen that behaviour).

However I have altered where the gambler shows his poker hand and placed a further UpdateBetButtons(BetIndex) to allow betting on a changed hand. I can't quite see how to do that for an unchanged (ie pat, high value hand), yet - I think I need a console command to set up that type of hand because it takes forever if you're waiting on a clean deal to produce it . Here is the file as I currently have it (my changes tagged PW), you can probably make a more elegant code solution for that functionality.

I had also earlier got rid of the laughter /sound effects and changed most of the in game messages (for a tournament setting) since the swearing and gloating is out of place there. I can easily add all that back in when your code is finalised together with the change to chips, hand count etc.
I can understand that for blackjack/twenty one but not for poker consequently I have added in a shuffle before each poker hand is dealt.
I saw the bug for the highcard also yesterday.
I will take a look at your code later :).
 
Today I tried playing poker for the very first time ever. The first thing that I come to think of
was the possibility to bet on a changed hand. At the same time just that was changed by @pedrwyth. :onya
 
@pedrwyth: Your new version has this:
Code:
               if(ValidateCombination(playerChar)>=16)
                   //UpdateBetButtons(BetIndex);//PW would placing this here allow betting on pat hand before enemy turn? not tested
                   if(ValidateCombination(playerChar)!=19)
                   {
                       SetNodeUsing("ENFACE",true);
                       SetSelectable("ENFACE",true);
                       bGambleMove = true;
                       bStart = true;
                   }
                   
               }
There seems to be a '{' missing after the first line, which is present in @Levis' version.
 
I do like the idea of betting on your hand. I does make me wonder, should we change poker so that it just has a default blind bet (and you can set this for the occasion, so for a tournament the blind cloud be larger for example). and if you think your hand is good you can raise the bet.
But should the opponent then also be able to raise their bet? And if you don't want it you can fold to give up the bet money instead of potentionally lose more?
 
@pedrwyth: There seems to be a '{' missing after the first line, which is present in @Levis' version.
Very true somehow tidying up my comment there I must have overwritten it - it should be
Code:
 if(ValidateCombination(playerChar)>=16)
               {
                   //UpdateBetButtons(BetIndex);//PW would placing this here allow betting on pat hand before enemy turn? not tested
                   if(ValidateCombination(playerChar)!=19)
                   {
                       SetNodeUsing("ENFACE",true);
                       SetSelectable("ENFACE",true);
                       bGambleMove = true;
                       bStart = true;
                   }
                 
               }
if it is not to fail and drop the gambling interface as a result.
 
I do like the idea of betting on your hand. I does make me wonder, should we change poker so that it just has a default blind bet (and you can set this for the occasion, so for a tournament the blind cloud be larger for example). and if you think your hand is good you can raise the bet.
But should the opponent then also be able to raise their bet? And if you don't want it you can fold to give up the bet money instead of potentionally lose more?
For good measure, if the opponent has high "Luck/Sneak" skill, allow him to bluff, or to check his skill versus your skill plus a random number to see if he falls for it if you bluff. Bluffing is a key part of poker. Showing your hand after you bluffed and he folded, causing him to get annoyed and make more mistakes, is another part. Poker is a lot more than just comparing hands! (I've never played it but I sometimes watch it on TV, and a good bluff is always fun to watch!)
 
I do like the idea of betting on your hand. I does make me wonder, should we change poker so that it just has a default blind bet (and you can set this for the occasion, so for a tournament the blind cloud be larger for example). and if you think your hand is good you can raise the bet.
But should the opponent then also be able to raise their bet? And if you don't want it you can fold to give up the bet money instead of potentionally lose more?

For good measure, if the opponent has high "Luck/Sneak" skill, allow him to bluff, or to check his skill versus your skill plus a random number to see if he falls for it if you bluff. Bluffing is a key part of poker. Showing your hand after you bluffed and he folded, causing him to get annoyed and make more mistakes, is another part. Poker is a lot more than just comparing hands! (I've never played it but I sometimes watch it on TV, and a good bluff is always fun to watch!)

I have given some thought to both the aspects of folding when raised and bluffing and once I have the tournament aspect working might return to add some elements of these. We already have a minimum bet of 100 and once you can bet later depending on your hand for poker it makes no sense to put in more blind (unless you are in a highstakes game with a higher ante so have to).

Before the opportunity to raise ideally you would see how many cards your opponent has chosen to draw (as theoretically he knows how many you took, so the AI can look at the odds) this gives some indication of the possible strength you face (but of course there is always the change all 5 but draw a 5 card combination to walk into). The first step would be if the AI gets a chance to fold or indeed raise, which it doesn't at the moment). Bluffing the AI or the AI bluffing you is harder and you don't have any of the other "tells" involved in real head to head poker to help so really just a random chance element. Before adding any of that we still don't have a foolproof "value" of hand (I was miffed when I got 1,2,3,4,5 as a starting hand to be told it was ranked as ace high and not a straight!) - after a hand like that!

But it is only a small representation of gaming within another game after all not a poker (or blackjack) simulator. Still anyone who wants to add more depth in the meantime is welcome to give it a go.
 
@pedrwyth I took a look at your file and indeed I think it could be done a bit better so did that myself now. Here is again a WIP version of my gambling file. I've now added the following things again:

- During blackjack there is now a draw option. The oponent will accept the draw from a 17 or higher (so if you for example have 12 and pass the turn and they also have 12 they will still draw a card but if you both have 18 or so they wont).
- There is now a visual cue for when the card deck is shuffled again (see if you can spot it)
- In poker after you both changed your hand the gambler will ask you if you want to raise, the amount of raises you can do will depend on your location (for now in taverns you can only raise it once while in the casino you can do it twice). I've added two lines in the habitue_dialog.h for this so included that here too.
- If you get a 21 during blackjack the game is instantly over and you just win
- The scoring bugs in blackjack are now fixed (hopefully) (I've played about 100 hands I think and haven't seen any wrong ones win)

Also a lot more code cleanup. While adding debug messages everytime I come acros code I dont know what it does I try to figure it out and if needed I change it.

For now I left the poker not shuffling in it because I still thinks it adds a layer of extra play which you will only detect if you are doing it more.

Let me know if this is what you where looking for :) . The removal of sounds I haven't included yet. I think we should do this by a variable or something so you can set it based on quests or locations.
Also I noticed you have a different background in your file. Is that the background used for your tournament or just a replacement?

BTW I must admit that I've tried a few poker games and I think having this extra step of having the option to raise makes it more interesting. I do wonder if we should also add a fold option, but it would give the same result as just continuing now. So if we want to have a fold option the opponent should also be able to raise. So I think this way there is a nice balance. you have some information about the opponent based on what they discarded but even while I've written the AI now I was surprised by the result sometimes.

EDIT:

Found 2 more small bugs:
- straight starting with an ace (a,2,3,4,5) wasn't recognised
- you weren't able to pass the turn properly if you wanted in poker or if you had a good hand

Update the file included in this post
 

Attachments

  • Habitue_dialog.h
    5.6 KB · Views: 121
  • gamble.c
    98.9 KB · Views: 131
Last edited:
@pedrwyth Here is again a WIP version of my gambling file.

Ok thanks I will of course look at it again with interest.

In poker after you both changed your hand the gambler will ask you if you want to raise, the amount of raises you can do will depend on your location (for now in taverns you can only raise it once while in the casino you can do it twice). I've added two lines in the habitue_dialog.h for this so included that here too.

The removal of sounds I haven't included yet. I think we should do this by a variable or something so you can set it based on quests or locations.

Habitue_dialogue.h is where I have already extra dialogue related to getting an invite to the tournament (within a girl won in a card game ), I added a comment at the bottom to warn future modders of its unusual use in gamble.c which seems to mean you have to change the file length declared in there if you add extra dialogue lines (even if they don't relate to gambling). Not a problem to merge them later. I also have some extra interface_string for changed dialogues (well in game text) and yes my removal of the sounds, swearing, and the like was and when reintroduced will be of course conditional on context (I didn't think that even needed saying). The aim is to add to, not change, the original (unless it was broken/lacking). Mine was quest based (in case the location sees other uses in future) for example
Code:
if (!checkAttribute(playerChar,"quest.poker.started"))PlaySound("gamble_shout_win");

Also I noticed you have a different background in your file. Is that the background used for your tournament or just a replacement?
Just a WIP place holder.

I think this way there is a nice balance. you have some information about the opponent based on what they discarded but even while I've written the AI now I was surprised by the result sometimes.
That's the nice thing about the game, you may know the odds against something but it doesn't mean it can't happen. That, apart from decisions like whether to risk trying to fill a straight or flush or keep a low pair and hope for a match, is about all there is to the in-game game as it stands, so it was good to see the dealer's draw right at the end and see if you were winning until that last draw - so I'll see how it feels now you have that taking place earlier (to give that extra info about how many cards they draw). Should be OK though still just bet some more and see the winner.


For now I left the poker not shuffling in it because I still thinks it adds a layer of extra play which you will only detect if you are doing it more.

However I know I can't agree to not shuffle before each poker hand, a depleted pack may make an interesting card counting challenge but whatever it is, it is not poker as I know it. It may replace the missing human element with something else but it throws all the odds . So I guess that's heading for a toggle in internal settings (with my vote being for shuffle as the default).

I'll spend some time looking (and playing) at/with the rest (of the poker element) and see where we are and get back to you.
 
Habitue_dialogue.h is where I have already extra dialogue related to getting an invite to the tournament (within a girl won in a card game ), I added a comment at the bottom to warn future modders of its unusual use in gamble.c which seems to mean you have to change the file length declared in there if you add extra dialogue lines (even if they don't relate to gambling). Not a problem to merge them later. I also have some extra interface_string for changed dialogues (well in game text)
Yeah the use of the dialogfile is a bit weird, and still produces an error also. I'm still looking into that because I haven't found which system actually loads in the dialog file.

However I know I can't agree to not shuffle before each poker hand, a depleted pack may make an interesting card counting challenge but whatever it is, it is not poker as I know it. It may replace the missing human element with something else but it throws all the odds . So I guess that's heading for a toggle in internal settings (with my vote being for shuffle as the default).

I haven't decided on this yet. I just forgot to change it (back) in my version :p . I can see that shuffling would be good to have the same odds every game. On the other hands having the option for some card counting is interesting too. So I'm also still in doubt here. For blackjack I'm sure it should not shuffle unless the deck is depleted.
 
Yeah the use of the dialogfile is a bit weird, and still produces an error also. I'm still looking into that because I haven't found which system actually loads in the dialog file.
The problem is that "debug.c" is loaded for every dialog. I've seen that cause an error as well - it certainly causes an error every time you gamble, and causes the same error at other times, though I haven't found a similarly reliable cause.

"debug.c" just allows you to see the character's skills. Since you can do that anyway by pressing the "O" key while facing him, there is no need for "debug.c" at all. So the simplest way to eliminate the error once and for all is to remove all references to "debug.c", starting with this line in function "DialogMain" in "PROGRAM\dialog.c":
Code:
Character.Dialog.Filename.Debug = "Debug.c";

I haven't decided on this yet. I just forgot to change it (back) in my version :p . I can see that shuffling would be good to have the same odds every game. On the other hands having the option for some card counting is interesting too. So I'm also still in doubt here. For blackjack I'm sure it should not shuffle unless the deck is depleted.
For vingt-un, I agree, do not shuffle until the deck is depleted, as card-counting is a valid strategy. For poker, I agree with @pedrwyth, shuffle the deck every time.
 
For vingt-un, I agree, do not shuffle until the deck is depleted, as card-counting is a valid strategy. For poker, I agree with @pedrwyth, shuffle the deck every time.

Ok I will change that. I also had a little look at how the name of the game was used exactly and I think I should be able to alter the code a little bit to make it easier to change the name of the game without it altering the logic. So will try to implement that also.
Then after we've made a choice on what we are going to do with renaming blackjack it should be easy to implement. At that point if you wanted you could even link it to the period/nation or anything like that :p .
 
For blackjack I'm sure it should not shuffle unless the deck is depleted.

For vingt-un, I agree, do not shuffle until the deck is depleted, as card-counting is a valid strategy. For poker, I agree with @pedrwyth, shuffle the deck every time.

I agree with non-shuffle in the other game, that's why they use up to six packs in casinos (and have the shoe to hold them) but to make it hard for card counters to gain too much certainty shuffle once down to about 75 cards. so 75/6*52 is about 1/4 left ie our 1 pack equivalent is somewhere around 13 cards left. I'm never going to play that game to that level of intensity so am not too fussed anyway.

I've looked at the file and how it performs (in tests so far) and I am pretty impressed. Up to now the only (other) thing I don't like is the limited single raise, But seeing how you programmed that (MaxRaises) it is brilliantly easy to change, to say 3 levels (which I did). That would mean from 100,200,500,1000 or from 200,500,1000,2000 in both cases limited to 10 times the original buy in. I can see that as a good in-house tavern rule. Without the ability to bet strongly on a good hand you are just pushing 100/200 stakes around the table, a good way to pass time and study hands but not to actually win (and clean out your opponent). Of course I could just change that for our tournament because otherwise it IS a boring slog.

In the casino I would think it is the change to the bet levels that is the difference rather than the number of times you can press a bet button (but no harm in having more level increases there in addition).

Of course to be effective your gambleperk also needs to up that limit to the maximum possible steps anywhere and perhaps a bit of extra dialogue in the tavern about setting aside usual house limits to add some gloss to the perk.

When your opponent can't meet the raise it doesn't action which is fine (that's where an all-in call could come into play) and I guess it is at that point that some AI of not wanting to meet the raise (ie fold) could be inserted before accepting any raise in the future
 
Last edited:
Ok I will change that. I also had a little look at how the name of the game was used exactly and I think I should be able to alter the code a little bit to make it easier to change the name of the game without it altering the logic. So will try to implement that also.
Please don't. I'm already having trouble understanding all the new changes. When I don't understand code, I get suspicious. When I get suspicious, I'm liable to leave it out of the next update. However, to be fair, I'll test the version from post #94 when I get time and check that vingt-un/blackjack, at least, still works properly. (I'd already made a very minor fix which made the game stop at once if either the player or the opponent were dealt a natural 21, and tested it - it worked fine. The only problem I could see is that the opponent wins ties, whereas ties ought to result in no money changing hands.)

The game names don't need to change by period or nation. "Blackjack" is wrong for all periods and nations, "Vingt-un" is correct for all periods and nations, "Twenty-One" is somewhere in between. Poker didn't exist at any time in the game but is interesting and is also a key part of the forthcoming gambler quest, so again, it does not need to change name by period or nation. And dice is just dice, regardless of period or nation.
 
Back
Top