1. Dismiss Notice
  2. GOG.com logo

    Thanks to YOUR votes, GOG.com now sells:
    - Sea Dogs - Sea Dogs: Caribbean Tales
    - Sea Dogs: City of Abandoned Ships

    Vote now to add Pirates of the Caribbean to the list!

    Dismiss Notice
  3. Under the Crossbones Podcast

    A Pirate Podcast with Interviews
    Music, Comedy and all things Pirate!

    - Episode Guide - About - Subscribe -
    - Twitter - Facebook - iTunes - Android -
    - Youtube - Fill the Coffers -

    Dismiss Notice
  4. New Horizons logo

    Quick links for PotC: New Horizons
    - Download latest version
    - Wiki - FAQ - Report bugs here
    - ModDB profile

  5. GOF logo

    Quick links for AoP2: Gentlemen of Fortune 2
    - Downloads and info
    - Historical Immersion Supermod
    - ModDB Profile

Dismiss Notice
New to the forum?
Please take a moment to read our Welcome Message and Forum Rules.

Linking cargo type to encounter type

Discussion in 'Build Beta and Brainstorming' started by Grey Roger, Oct 10, 2017.

  1. Pieter Boelen

    Pieter Boelen (Not So) Old Seadog Staff Member Administrator Storm Modder Hearts of Oak Donator

    Joined:
    Nov 11, 2004
    Messages:
    66,581
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
    Use Trace to see what output it generates?
     
  2. DeathDaisy

    DeathDaisy Freebooter Storm Modder

    Joined:
    Aug 18, 2017
    Messages:
    267
    Gender:
    Female
    Ah right, ofc. Gonna do that when I get home tonite!
     
    Pieter Boelen likes this.
  3. DeathDaisy

    DeathDaisy Freebooter Storm Modder

    Joined:
    Aug 18, 2017
    Messages:
    267
    Gender:
    Female
    I added the trace but I no longer get the errors and the readings look fine, so no idea what happened. good news I spose!
     
    Pieter Boelen likes this.
  4. DeathDaisy

    DeathDaisy Freebooter Storm Modder

    Joined:
    Aug 18, 2017
    Messages:
    267
    Gender:
    Female
    :eek: hit a rather serious snag : the iGetEncounterType that saves the encounter type from the spawning in Fantom_GenerateEncounter seems to work well when running into encounters in the wild, but when generating ships outside harbors and around islands it always returns 0 as far as I can tell; Ive seen warships trace 0 as encounter type, which should be impossible because enc type 0 is traders only. SetCoastTraffic in sea.c (see dot see :cheeky) seems to be the one that puts them there. so got to add a check for if the SetGoods thing is ran from somewhere else that does not give an enc num I can save. it does send with it a character ref and the trader/war/pirate type, so its still possible to do some checks for booty that makes sense, but think its gonna be harder to do specifics :type1 @Mad Jack Wolfe, if you do any pirating you might wanna hold off any serious pillaging around the coast :p sail-ho and map encounters should be fine tho! xD

    also had a discouraging encounter; I was playing a smuggler and sailing around in a small lugger. I got caught in a violent storm outside Hispaniola that almost ruined me, but it finally calmed down. that's when I saw a hostile spanish treasure galleon also caught in the storm, that had lost two masts and overall fared much worse than me. she surrendered as soon as I approached. I boarded her and killed the captain, but after all that the cargo hold was empty. I think I was fooled by the name honestly, and that it was generated as a coastguard ie war encounter and didnt imply infinite riches ;)
    therefore it was probably because of
    Code:
    if (rFantom.FantomType == "war" && rand(100) > 15) randGoods = 0;
    I'm considering adding GetCharacterShipType(rFantom) != "trade" to the if too; that way ships that are classed as both war and trade should still carry a bit of cargo even in a war encounter, but pure warships will mostly carry nothing. or make it so that the treasure galleon is exempt to avoid similar disappointments because of childish expectations :p or just leave it as is, not rewarding naivety? :shrug

    gonna try and have a closer look at it later today when I find the time. any thoughts are still appreciated tho! xD
     
  5. Pieter Boelen

    Pieter Boelen (Not So) Old Seadog Staff Member Administrator Storm Modder Hearts of Oak Donator

    Joined:
    Nov 11, 2004
    Messages:
    66,581
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
    Indeed only world map/DirectSail encounters are created through those encounter types.
    So quest ships and coast raiders are not covered.

    Looking at a ship's flag tells you whether it is a navy or merchant one, if that is of any help.
     
  6. DeathDaisy

    DeathDaisy Freebooter Storm Modder

    Joined:
    Aug 18, 2017
    Messages:
    267
    Gender:
    Female
    my plan is to set iGetEncType to -1 by default instead of undefined which I guess is 0, so if the switch case is -1 a different generic chance calc runs. something like this:
    Code:
    case -1: // Fantom_GenerateEncounter not run, do something else
                iBootyQuality = GOODS_QUANTITY - rand(iShipClass);
            break;
    rn only ship class is considered. are there other things that should be accounted for?

    it is! xD I didnt think of that!
     
    Last edited: Nov 12, 2017
  7. Pieter Boelen

    Pieter Boelen (Not So) Old Seadog Staff Member Administrator Storm Modder Hearts of Oak Donator

    Joined:
    Nov 11, 2004
    Messages:
    66,581
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
    Maybe whether it is a war/merchant/versatile ship? And perhaps Pirates should be an exception of some kind.
     
  8. DeathDaisy

    DeathDaisy Freebooter Storm Modder

    Joined:
    Aug 18, 2017
    Messages:
    267
    Gender:
    Female
    while traders and pirates already get a larger amount of the cargo they get, I think it aint unreasonable traders get more expensive loot too :ninja
    Code:
    case "-1": // Fantom_GenerateEncounter not run, do something else
                iBootyQuality = GOODS_QUANTITY - rand(iShipClass);
                if(rand(100) > 60 && rFantom.FantomType != "pirate"){ // for fun! better cargo potential for trader vessels
                    if(GetCharacterShipType(rFantom) == "trade" && GetCharacterShipType(rFantom) != "war") iBootyQuality -= rand(round(randnorm(iShipClass*2,iShipClass)));
                    if(GetCharacterShipType(rFantom) == "trade" && GetCharacterShipType(rFantom) == "war") iBootyQuality -= rand(round(randnorm(iShipClass,iShipclass/2)));
                }
                if(iShipClass > 5){ iStart += 6;} // lesser vessels don't carry the most valuble cargo
                else{
                    if(rand(100) > 20) iStart += 2; // higher end ships could sometimes in a blue moon carry noble metals!
                }
            break;
    the odds are a bit chaotic and arbitrary, but if I dun it right it gives pure traders a chance for fairly much better cargo, versatile ships get a chance for slightly better cargo, pirates and warship get the whole spectrum. ships lower than class 5 dont get the real treasures, better ships get a chance for gold and silver 20% of the time, they are the dream to aim for after all :sail direct sail and map encounters are probably still the juiciest catches, but coast ships should still be valid targets :dance

    it doesnt seem to break straight away at least, so attaching the new version, lots of new traces included for testing! :pirate41:
     

    Attached Files:

    Pieter Boelen and pedrwyth like this.
  9. pedrwyth

    pedrwyth Privateer Storm Modder

    Joined:
    Jan 8, 2015
    Messages:
    645
    Gender:
    Male
    Great stuff @DeathDaisy , it seems to work as intended. :cheersMy first comment on balancing is I've hardly seen a "war" vessel getting cargo so I think the 80% exception too strong in the long term - indeed for balancing it might be worth commenting out completely whilst we see what goods a warship gets - then cutting down the odds of that later.:flower

    I did lead me to wonder about boosting chest contents for warships rather than cargo but that would be a whole extra ball game - perhaps interesting none the less?
     
    Last edited: Nov 13, 2017
    DeathDaisy likes this.
  10. Grey Roger

    Grey Roger Sea Dog Staff Member Storm Modder

    Joined:
    Feb 12, 2007
    Messages:
    6,389
    The original problem was to arrange that unescorted merchants have less valuable cargo, while single merchant with heavy escort should have more valuable cargo - does this deal with that?

    Warships were never an issue, so the small amount of random cargo they get doesn't need to be changed.

    Chest contents on warships probably don't need changing. Warships start with higher morale, so you're more likely to have to fight your way through several decks, looting lots of weapons as you go. On the other hand, if you grapeshot the ship into submission, chest contents still won't matter because you won't see them. ;)
     
  11. Pieter Boelen

    Pieter Boelen (Not So) Old Seadog Staff Member Administrator Storm Modder Hearts of Oak Donator

    Joined:
    Nov 11, 2004
    Messages:
    66,581
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
    It should do. :yes
     
  12. DeathDaisy

    DeathDaisy Freebooter Storm Modder

    Joined:
    Aug 18, 2017
    Messages:
    267
    Gender:
    Female
    it does! xD should be well worth targetting more dangerous marks now!:pirate41:


    Thanks! xD

    about the warships, maybe it is as @Grey Roger said, its fixing something that isnt broken. we'll comment it out for now. I still like the idea tho, it might be worth revisiting at sum point, specially together with the on-deck chests! its probably a whole different beast, but none the less it would be a cool thing to make up for the meagre cargo of warships. a chest full of crew salaries on a navy ship makes sense and is a treasure indeed:treasure:

    I encountered the index error again yesterday. cant get to the logs right now, but I think it was when ecnountring an enc type 0 on the map. gotta take a closer look at that math and see how iBooty would end up as larger than 33. my spontaneous guess without looking at the code is that the -1 we removed in the rand(iBootyQuality - iStart) thing somehow causes iBooty to end up as 34 sometimes? gonna try it when I get the chance.
     
  13. DeathDaisy

    DeathDaisy Freebooter Storm Modder

    Joined:
    Aug 18, 2017
    Messages:
    267
    Gender:
    Female
    readded the -1 and encountered an enc type 0 and did not get array size errors, gonna assume that solved it! attaching what is hopefully a functioning AIFantom.c xD
     

    Attached Files:

    Pieter Boelen likes this.
  14. pedrwyth

    pedrwyth Privateer Storm Modder

    Joined:
    Jan 8, 2015
    Messages:
    645
    Gender:
    Male
    Yes it's that array size - there are 33 goods but in an array 0-32 so using the 33 causes the array to go out of range when picking a good if the full number 33 is left by the random variable - hence the -1. Sorry I didn't check through the logic when I queried why one was being taken from the 33
     
  15. DeathDaisy

    DeathDaisy Freebooter Storm Modder

    Joined:
    Aug 18, 2017
    Messages:
    267
    Gender:
    Female
    no need to be sorry, I could have checked too and not just blindly remove it, so it was a team effort! :p now it seems to work like a charm, so thanks for all the input :cheers
     

Share This Page