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

WIP Improvements to Smuggling.

Might I sugest you make this easier by just having the check in CheckCoastGuard:
Code:
if(PChar.location == PChar.quest.contraband.CurrentPlace)
    {
        float chance_get_caught = GetEventData();
        if(Rand((100*SMUGGLING_TIME_CHANCE_MULT))<=chance_get_caught)
        {
            if(DEBUG_SMUGGLING>1) TraceAndLog("SMUGGLING Coastguard found you!");
            Lai_QuestDelay("Rand_ContrabandInterruption",1.0);
            StopCoastGuardCheck();
        }
        if(DEBUG_SMUGGLING>1) TraceAndLog("SMUGGLING caught chance is "+chance_get_caught+" in "+(100*SMUGGLING_TIME_CHANCE_MULT));
        if(DEBUG_SMUGGLING>1) TraceAndLog("SMUGGLING Evaded the Coastguard (for now)");
    }
    if(dialogRun || dialogSelf){
        SetEventHandler("PauseCoastGuardCheck","PauseCoastGuardCheck",1);
        PostEvent("PauseCoastGuardCheck",5000,"f",chance_get_caught);   
    }
    else PostEvent("CheckCoastGuard",5000,"f",chance_get_caught);
and change it into this:
Code:
if(PChar.location == PChar.quest.contraband.CurrentPlace && (!dialogRun || !dialogSelf))
    {
        float chance_get_caught = GetEventData();
        if(Rand((100*SMUGGLING_TIME_CHANCE_MULT))<=chance_get_caught)
        {
            if(DEBUG_SMUGGLING>1) TraceAndLog("SMUGGLING Coastguard found you!");
            Lai_QuestDelay("Rand_ContrabandInterruption",1.0);
            StopCoastGuardCheck();
        }
        if(DEBUG_SMUGGLING>1) TraceAndLog("SMUGGLING caught chance is "+chance_get_caught+" in "+(100*SMUGGLING_TIME_CHANCE_MULT));
        if(DEBUG_SMUGGLING>1) TraceAndLog("SMUGGLING Evaded the Coastguard (for now)");
    }
    PostEvent("CheckCoastGuard",5000,"f",chance_get_caught);

yeah I tried keeping it in the function but I couldnt make it work :p what it does now works, but apart from the &&|| thing it looks like a solid plan, so definitly feel free to optimize it!


The random number generator from POTC isn't that good with numbers under 10. The distribution isn't really random. I'd sugest multiplying your numbers a bit so instead of doing a D3 you do a D30, your changes will stay the same but the random number generator of potc will work better with numbers of 10 and higher.
alright, gonna see what I can do :) :type1
would something like this work?
Code:
// DeathDaisy: 3d6 persuasion system based on leadership and luck so far
    int PersuadeInt;
    int ThreeDice;
    int pLeadership = CalcCharacterSkill(PChar,SKILL_LEADERSHIP);
    int pLuck = CalcCharacterSkill(PChar,SKILL_SNEAK);
    int PersuasionChance = 3+(rand(pLuck*10)/10)+pLeadership-(getSmugglingState(smugisland)-1);
    if(CheckCharacterPerk(PChar,"Trustworthy")) PersuasionChance = PersuasionChance+1;
    if(CheckCharacterPerk(PChar,"IronWill")) PersuasionChance = PersuasionChance+1;
    PersuasionChance = iClamp(4,16,PersuasionChance);
Code:
// DeathDaisy: Roll 3 six-sided dice to determine success for a nice bell curve
            ThreeDice = round(((rand(50)+10)+(rand(50)+10)+(rand(50)+10))/10);

It's a good start for these perks, do check if you also assigned them for the right officerroles so officers can also have them ;).
But personally I prefer to have perks not serve a single purpose but have them expand more. But we can maybe find some more place where there is a attempt of persuation in sidequests etc, and add a check for this here :), I'll leave that up to you. One thing which comes mind is the haggling for the officer price. You can sometimes talk this down. Maybe this perk could help you here. Also Persuading a captain to give up instead of fight migth be a good place to add these perks.
Personally I would only add 1 perk but that's up to you :), altough I do think having 10% more leadership can cost you more than just 1 perk point ;).
youre very right, the stats and costs are pretty much just placeholders, they dont actually do anything other than exist rn :p was planning on locking the second one for later levels and increasing the costs somewhat. and deffo gotta go through and add more uses for them in dialogs all around before they make sense :type1 I'll make a thread for help with what they should do and balancing if/when theyre a bit better implemented
 
I didn't think of the smuggling issues. This idea goes against long established game play.

You know the random goods floating in the sea? Usually that is contraband. So when you go to port it gets confiscated and you get fined. You might as well delete all that stuff floating in the sea because it will be just left there.

Sometimes a store will have something for a very good price and I will buy it, just because, then sail around with it until it fetches a good price. This could cause me to dock at ports where it is contraband on the way to the store with the good price. So the cargo is taken and I am fined heavily.

What happens when I go bankrupt and can not pay the fine? Will the thugs take my ship too?

Oh, who gets the trustworthy perk? I'm at level 64 or so and do not have it.
 
I didn't think of the smuggling issues. This idea goes against long established game play.

You know the random goods floating in the sea? Usually that is contraband. So when you go to port it gets confiscated and you get fined. You might as well delete all that stuff floating in the sea because it will be just left there.

Sometimes a store will have something for a very good price and I will buy it, just because, then sail around with it until it fetches a good price. This could cause me to dock at ports where it is contraband on the way to the store with the good price. So the cargo is taken and I am fined heavily.

What happens when I go bankrupt and can not pay the fine? Will the thugs take my ship too?

Oh, who gets the trustworthy perk? I'm at level 64 or so and do not have it.
I think those are all very fair points :yes those mechanics can maybe be fun if you plan on going all-out smuggler on a character or just like getting kicked in the teeth by games(I know I have those days, my modded skyrim was torture), but otherwise its a recipe for disaster what with all the random goods you pick up here and there and most dont keep track of whats contraband in the ports they dock at. if @Levis wanna work on it anyway tho as I still think it could be kinda cool, since buildsettings are fairly easy to add and there are like 1000 already, could there be like a "super advanced smuggling" option to activate there when youre planning to play a smuggler char etc?

another thing I remembered; I have no idea if the smuggling things I added for sweden/america works so might be worth taking a look at.
 
yeah I tried keeping it in the function but I couldnt make it work :p what it does now works, but apart from the &&|| thing it looks like a solid plan, so definitly feel free to optimize it!
At the moment it wont work. If I save my game right after the dialog is done (before the 5 second check to reenable it is done) and then load the game the check won't continue.
The smuggler check it self (from what I remember) has a build in function to store it being running while saving so it will resume after loading a game. So you want to keep all your logic in this function so it will always run.
 
I didn't think of the smuggling issues. This idea goes against long established game play.

You know the random goods floating in the sea? Usually that is contraband. So when you go to port it gets confiscated and you get fined. You might as well delete all that stuff floating in the sea because it will be just left there.

Sometimes a store will have something for a very good price and I will buy it, just because, then sail around with it until it fetches a good price. This could cause me to dock at ports where it is contraband on the way to the store with the good price. So the cargo is taken and I am fined heavily.

What happens when I go bankrupt and can not pay the fine? Will the thugs take my ship too?

Oh, who gets the trustworthy perk? I'm at level 64 or so and do not have it.
Like I said already I will think about it a bit more and see if I can revise the idea. For now there is still enough other stuff to do like interface enhancements to give you more information about the smuggling.
 
At the moment it wont work. If I save my game right after the dialog is done (before the 5 second check to reenable it is done) and then load the game the check won't continue.
The smuggler check it self (from what I remember) has a build in function to store it being running while saving so it will resume after loading a game. So you want to keep all your logic in this function so it will always run.
hadnt considered for a second what would happen with saves! Ill change it to your thing :onya
 
I changed it to this
Code:
void CheckCoastGuard()
{
    ref PChar = GetMainCharacter();
    float chance_get_caught = GetEventData();
    if(PChar.location == PChar.quest.contraband.CurrentPlace && !dialogRun && !dialogSelf)
    {
        if(Rand((100*SMUGGLING_TIME_CHANCE_MULT))<=chance_get_caught)
        {
            if(DEBUG_SMUGGLING>1) TraceAndLog("SMUGGLING Coastguard found you!");
            Lai_QuestDelay("Rand_ContrabandInterruption",1.0);
            StopCoastGuardCheck();
        }
        if(DEBUG_SMUGGLING>1) TraceAndLog("SMUGGLING caught chance is "+chance_get_caught+" in "+(100*SMUGGLING_TIME_CHANCE_MULT));
        if(DEBUG_SMUGGLING>1) TraceAndLog("SMUGGLING Evaded the Coastguard (for now)");
    }
    else{
        if(DEBUG_SMUGGLING>1) TraceAndLog("SMUGGLING caught chance paused");
    }
    PostEvent("CheckCoastGuard",5000,"f",chance_get_caught);
}
I moved the chance_get_caught float outside the if statement, otherwise it forgot the caught chance when it was paused and returned crazy numbers. it shouldnt give any reprecussions, rite?

also attaching the guard dialog with the new dice generator with larger rands :) it seems to work well! and gives nicer random numbers when running a series through the console, so good call xD
 

Attachments

  • smuggling.c
    74.3 KB · Views: 115
  • random_guards_group_dialog.c
    18.6 KB · Views: 113
Just a reminder: '-price' doesn't work, it has to be '-1.0 * price', so I have to fix this every time I WinMerge one of your "random_guards_group_dialog.c" variants with the one I'm trying to build up. ;)

You don't have to stick with 6-sided dice. If you want a larger random number, many RPG's use 20-sided dice. Or percentage dice. (Ever seen a 100-sided die? Good luck rolling it, or rather, good luck getting it to stop, let alone figure out which side is on top. xD More usually, percentages are rolled with a pair of 10-sided dice, one for 10's and one for units.)
 
Just a reminder: '-price' doesn't work, it has to be '-1.0 * price', so I have to fix this every time I WinMerge one of your "random_guards_group_dialog.c" variants with the one I'm trying to build up. ;)

You don't have to stick with 6-sided dice. If you want a larger random number, many RPG's use 20-sided dice. Or percentage dice. (Ever seen a 100-sided die? Good luck rolling it, or rather, good luck getting it to stop, let alone figure out which side is on top. xD More usually, percentages are rolled with a pair of 10-sided dice, one for 10's and one for units.)
oh right! I havent changed the one in wongame since I wasnt sure if you should lose money when betting and was gonna check it out, but then I forgot because Im a ditz :ko I think its simply a mistake and should be commented out tbh, but Im not 100%. feels weird that you should lose money even tho you gamble instead of bribe..

Im a huge roleplaying dork xD have played both d20 and d100 systems (100-sided die are pretty much just balls :rofl). what I really like about the 3 6-sided ones is that the odds as you get better are in a bellcurve as opposed to linear as with DnDs d20 and percentage dice like WH Fantasy and CoC. so each stat and bonus you add to your target number makes a much larger difference than in a linear progression. with a 20-sided dice you have a 5% chance to roll any number. with 3d6 you have a 9.3% chance to roll under 6, a 50% chance to roll under 10 and a 90.7% chance to roll under 14 frex. Im not gonna claim its necessarily better :p but I really like the feeling of growth non-linear odds give
 
The point is, D6 is apparently too small for PoTC's random number system to work properly. Personally, I'm not so sure of that, and other parts of the game probably won't work if it's true, starting with the 'rand(4)' which determines which of your random dialogs will be used. Have you noticed any bias towards any particular persuasion line?

If 6-sided dice can't be used, use 20-sided dice instead. You don't have to duplicate a paper RPG system. If you want three dice and you don't trust the system to roll a D6 properly, you can use 3D20 instead. Or 3D16. Or whatever number you like. (By the way, there really is such a thing as a D16. I've got one.)

All you need to turn the existing code into 3D50 is to change 'rand(50)+10' into 'rand(50)+1'. (And then probably add a +27 modifier because '(rand(50) + 10) + (rand(50) + 10) + (rand(50) + 10)' is really 'rand(50) + rand(50) + rand(50) + 30', so you need the +27 to bring the result back into range.)
 
Solved - Random or Quasi Random Numbers?

Here is an old thread about the RNG. It's not that big of a problem but from what I remember doing that research having an rng for only 3 numbers could skew sometimes. Having a higher number to roll from looks to be more random, or even better using the frand.
 
The point is, D6 is apparently too small for PoTC's random number system to work properly. Personally, I'm not so sure of that, and other parts of the game probably won't work if it's true, starting with the 'rand(4)' which determines which of your random dialogs will be used. Have you noticed any bias towards any particular persuasion line?

If 6-sided dice can't be used, use 20-sided dice instead. You don't have to duplicate a paper RPG system. If you want three dice and you don't trust the system to roll a D6 properly, you can use 3D20 instead. Or 3D16. Or whatever number you like. (By the way, there really is such a thing as a D16. I've got one.)

All you need to turn the existing code into 3D50 is to change 'rand(50)+10' into 'rand(50)+1'. (And then probably add a +27 modifier because '(rand(50) + 10) + (rand(50) + 10) + (rand(50) + 10)' is really 'rand(50) + rand(50) + rand(50) + 30', so you need the +27 to bring the result back into range.)
hard to say with the lines, I havnt been paying attention but its not something Ive reacted at. Im gonna keep it in mind tho

about the dice tho, its not as much about copying gurps as its that I just find 3d6 easier than 3d50 to wrap my head around when coming up with and balancing modifiers and such, it works well with the 1-10 scale of skills and perks already in the game I think. adding a +/-1 is as easy as it gets :shrug there is a randnorm() function for random bellcurves to check out if the rand(50)+10)/10 isnt good, but I dont think I understand it well enough to ever have any hope of balancing it :ko (googled for the 16 sided dice, they look unusual and weird xD what systems are they used for? damage in DnD?)

Solved - Random or Quasi Random Numbers?

Here is an old thread about the RNG. It's not that big of a problem but from what I remember doing that research having an rng for only 3 numbers could skew sometimes. Having a higher number to roll from looks to be more random, or even better using the frand.
would the frand work better for 1-6, or is it the same problem with small numbers?

the gambling system should probably be looked at too, I think it also uses rand(5)+1 or even rand(6)
 
don't worry that much about the RNG, it's not that much of a problem if its not easy for you to change ;).
 
@DeathDaisy: there's a slight problem with 'random_guards_group_dialog.c':
Code:
RUNTIME ERROR - file: dialogs\random_guards_group_dialog.c; line: 23
missed attribute: contraband
Line 23 is this:
Code:
ref smugisland = GetIslandByIndex(sti(Pchar.quest.Contraband.islandindex));
The error happened when I was playing a character who had never smuggled. When I went into a tavern, a random soldier talked to me, and that was the result. If you haven't done any smuggling, "Pchar.quest.Contraband" doesn't exist, so that line fails. It doesn't crash the game or block the guard's dialog, but it would be nice if talking to the guard didn't spawn an error.
 

Attachments

  • error.log
    524 bytes · Views: 114
@DeathDaisy: there's a slight problem with 'random_guards_group_dialog.c':
Code:
RUNTIME ERROR - file: dialogs\random_guards_group_dialog.c; line: 23
missed attribute: contraband
Line 23 is this:
Code:
ref smugisland = GetIslandByIndex(sti(Pchar.quest.Contraband.islandindex));
The error happened when I was playing a character who had never smuggled. When I went into a tavern, a random soldier talked to me, and that was the result. If you haven't done any smuggling, "Pchar.quest.Contraband" doesn't exist, so that line fails. It doesn't crash the game or block the guard's dialog, but it would be nice if talking to the guard didn't spawn an error.
right you are!

I put all the smuggling stuff I added in the beginning into an if I stole from sumwhere else that seems to check if the quest exists
Code:
if(CheckAttribute(Pchar, "quest.Contraband.Active") && Pchar.quest.Contraband.Active == true)
    {
        ref smugisland = GetIslandByIndex(sti(Pchar.quest.Contraband.islandindex));
        
        string PatrolState = "";
        // DeathDaisy: 3d6 persuasion system based on leadership and luck so far
        int PersuadeInt;
        int ThreeDice;
        int pLeadership = CalcCharacterSkill(PChar,SKILL_LEADERSHIP);
        int pLuck = CalcCharacterSkill(PChar,SKILL_SNEAK);
        int PersuasionChance = 3+round(rand(pLuck*10)/10)+pLeadership-(getSmugglingState(smugisland)-1);
        if(CheckCharacterPerk(PChar,"Trustworthy")) PersuasionChance = PersuasionChance+1;
        if(CheckCharacterPerk(PChar,"IronWill")) PersuasionChance = PersuasionChance+1;
        //if(CheckCharacterPerk(PChar,"Charisma")) PersuasionChance = PersuasionChance+2;
        //if(CheckCharacterPerk(PChar,"WitCharm")) PersuasionChance = PersuasionChance+3;
        //if(sti(Pchar.model.nation) == sti(NPChar.nation) && PChar.model.playertype == PLAYER_TYPE_MARINE) PersuasionChance = PersuasionChance+3;
        PersuasionChance = iClamp(4,16,PersuasionChance);
        //trace(PersuasionChance);
    }
I dont get the errors when not having the quest anymore but the quest dialog still works when it should afaict:onya
 

Attachments

  • random_guards_group_dialog.c
    18.8 KB · Views: 98
there is a randnorm() function for random bellcurves to check out if the rand(50)+10)/10 isnt good, but I dont think I understand it well enough to ever have any hope of balancing it

If you tell me exactly what results you want, I can tell you either how to use RandNorm() or what dice to roll.

RandNorm is fairly simple. You specify a mean and a standard deviation. The mean is the number around which you wish the random number to vary, and the standard deviation is the expected amount. The version used in PotC will produce numbers as far off as 4 standard deviations from the mean. Basically, 66% of the results will be within one standard deviation of the mean, 95% will be within two standard deviations, and 99% will be within three. The remaining 1% will be up to about four.

So, RandNorm(100, 10) should produce 2/3 of it's results between 90 to 110, 95% will be 80 to 120, 99% will be 70 to 130, with limits of about 60 to 140. While there are ways to get the curve to be flatter or sharper, or to cluster more to one side or the other, I've totally forgotten what they are in the last 8 years and the last time I tried to figure it out again I failed. If there are any mathematicians in the house, I'd be much obliged.

Rolling a large quantity of dice will produce something approaching the bell curve, and it's closer as more dice are rolled. But if you want a bell curve, RandNorm will do it in far fewer calculations.

Hook
 
If you tell me exactly what results you want, I can tell you either how to use RandNorm() or what dice to roll.

RandNorm is fairly simple. You specify a mean and a standard deviation. The mean is the number around which you wish the random number to vary, and the standard deviation is the expected amount. The version used in PotC will produce numbers as far off as 4 standard deviations from the mean. Basically, 66% of the results will be within one standard deviation of the mean, 95% will be within two standard deviations, and 99% will be within three. The remaining 1% will be up to about four.

So, RandNorm(100, 10) should produce 2/3 of it's results between 90 to 110, 95% will be 80 to 120, 99% will be 70 to 130, with limits of about 60 to 140. While there are ways to get the curve to be flatter or sharper, or to cluster more to one side or the other, I've totally forgotten what they are in the last 8 years and the last time I tried to figure it out again I failed. If there are any mathematicians in the house, I'd be much obliged.

Rolling a large quantity of dice will produce something approaching the bell curve, and it's closer as more dice are rolled. But if you want a bell curve, RandNorm will do it in far fewer calculations.

Hook
since Ive done lots of dice rolling and very little other math the last decade, I used three six-sided dice equivalents (ie (rand(5)+1)+(rand(5)+1)+(rand(5)+1)) to get a number between 3 and 18 to get a bellcurve with 10 in the middle. since the rng can be funky with small numbers I turned it into round((rand(50)+10)+(rand(50)+10)+(rand(50)+10)/10). it does seem to work alright and keeps it at a level I can understand, but its maybe not very pretty :p its probably accurate enough for what it does, the persuasion system is no big deal tbh, but if I can do similar numbers better with randnorm() I wont mind using that instead. and I often find myself wanting non-linear calcs so learning how to use it would be ideal overall xD would randnorm(10,2) give something similar? would it have the same problem with small numbers as the normal rand system?
 
btw something which came to mind.
If the officer returns from scouting, does this officer also receive experience for this scouting? If not than I think this should be added, could be another reason why you send the officer for scouting ;).
 
Back
Top