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

Linking cargo type to encounter type

but as a start, does that look like it'll work and give a roughly balanced distribution?
I think that cuts out lower value goods for the more protected encounters as for example merchant 2 with the bottom 5 definitely gone plus a random extra squeeze.
I think you also need to add a squeeze on the more valuable goods so for the unescorted merchant add 6 to iStart inside case 0 so no gold,silver,coffee,cinnamon,mahogany or ebony, then say add 1 for light escort inside case 1 - so no gold etc however the balance works out - or maybe a random element to the squeeze on the high value goods too.
 
I think that cuts out lower value goods for the more protected encounters as for example merchant 2 with the bottom 5 definitely gone plus a random extra squeeze.
I think you also need to add a squeeze on the more valuable goods so for the unescorted merchant add 6 to iStart inside case 0 so no gold,silver,coffee,cinnamon,mahogany or ebony, then say add 1 for light escort inside case 1 - so no gold etc however the balance works out - or maybe a random element to the squeeze on the high value goods too.
yeah my biggest problem with this versus an array is that I'm not very good at maths. I'm a non-linear kinda gal, but I have a much harder time coming up with ways to non-linearly affect the odds :p with arrays it's just "case Merchant1: if(rand(10) <= 1) GetFantasticLoot; break;"

the unescorted merchants are already practically clamped since 8 - iShipClass is realistically never going above 5 since MaxMerchantClass or whatever its called is set to 3 as standard, so iBootyQuality will never go above 27 which means they will never have anything better than oil, which I almost think is maybe too harsh. I'd like it to be possible but increasingly unlikely to get better goods. I'm just too dumb to understand all the cool math functions in utils.c to make it happen :8q I'd love to learn tho, if anyone has any ideas
 
I definitely appreciate you working on this, @DeathDaisy!
But I have to admit, I am severely short on time so I can't really look into it properly to think of any ideas... :oops:
 
the unescorted merchants are already practically clamped since 8 - iShipClass is realistically never going above 5 since MaxMerchantClass or whatever its called is set to 3 as standard, so iBootyQuality will never go above 27 which means they will never have anything better than oil, which I almost think is maybe too harsh.

Hmm I should have looked how you were using iBootyQuality :confused:which did indeed restrict what an unescorted trader could have. However there is a loop randGoods within which you place goods of iBootyQuality type which will see the same good everytime round it I think.

So I suggest something like
Code:
int iStart = GOOD_PLANKS + 1;// TIH we start after repair goods now for random cargo
    int iBootyQuality = 0;
     int iBooty;
    switch(iGetEncType){
        case 0: // Merchant 0: single merchant
            iBootyQuality = GOODS_QUANTITY ; //include down to the least valuable
        iStart += 6;// omit the 6 most valuable
        break;
        case 1: // Merchant 1: merchants with a light escort
            iBootyQuality = GOODS_QUANTITY - rand((8 - iShipClass) + 1); // remove a random amount of the least valuable
        iStart += 2;// omit gold and silver
        break;
        case 2: // Merchant 2: a single merchant with heavy escort
            iBootyQuality = GOODS_QUANTITY - 5 - rand((8 - iShipClass) + (iGetNumWarShips*2));// remove at least 5 of the less valuable and a further random amount
        break;
        case 3: // Patrol: a small patrol
            iBootyQuality = GOODS_QUANTITY - rand(5);
        break;
        case 4:
       
    }
 
   // iBootyQuality = iClamp(iStart,GOODS_QUANTITY,iBootyQuality);

    // TIH --> we generate random different types now, instead of always 7 different types
    int randGoods = 1 + rand(6);
    for (int r=0;r<randGoods;r++)
    {  
    iBooty = iStart + rand(iBootyQuality - iStart - 1)// PW not sure about the -1 I think this excludes the lowest value cargo
    iBooty = iClamp(iStart,GOODS_QUANTITY,iBooty);
    Fantom_SetCharacterGoods(rFantom, iBooty, makeint(iMultiply * rand(iRandMultiply * 3)) );
       
        //Fantom_SetCharacterGoods(rFantom, iBootyQuality, makeint(iMultiply * rand(iRandMultiply * 3)) );
        //Fantom_SetCharacterGoods(rFantom, iStart + rand(GOODS_QUANTITY - iStart - 1), makeint(iMultiply * rand(iRandMultiply * 3)) );
    }
but there is also this code lower down the function that would need similar treatment
Code:
if(rFantom.FantomType == "trade")
    {
        int fillCargo = iStart + rand(GOODS_QUANTITY - iStart - 1);// random pick a good to be maxed
        int fillQuantity = GetCargoGoods(rFantom,fillCargo) + GetCharacterFreeSpace(rFantom,fillCargo);// fill up the hold
        Fantom_SetCharacterGoods(rFantom, fillCargo, fillQuantity);
    }
- since iBooty would be set the last time through the loop can just put that in place of the random choice and fill any space with the last good chosen. EDIT Actually could just use fillCargo as the variable throughout and save on an integer (iBooty) .:)
 
Hmm I should have looked how you were using iBootyQuality :confused:which did indeed restrict what an unescorted trader could have. However there is a loop randGoods within which you place goods of iBootyQuality type which will see the same good everytime round it I think.

So I suggest something like
Code:
int iStart = GOOD_PLANKS + 1;// TIH we start after repair goods now for random cargo
    int iBootyQuality = 0;
     int iBooty;
    switch(iGetEncType){
        case 0: // Merchant 0: single merchant
            iBootyQuality = GOODS_QUANTITY ; //include down to the least valuable
        iStart += 6;// omit the 6 most valuable
        break;
        case 1: // Merchant 1: merchants with a light escort
            iBootyQuality = GOODS_QUANTITY - rand((8 - iShipClass) + 1); // remove a random amount of the least valuable
        iStart += 2;// omit gold and silver
        break;
        case 2: // Merchant 2: a single merchant with heavy escort
            iBootyQuality = GOODS_QUANTITY - 5 - rand((8 - iShipClass) + (iGetNumWarShips*2));// remove at least 5 of the less valuable and a further random amount
        break;
        case 3: // Patrol: a small patrol
            iBootyQuality = GOODS_QUANTITY - rand(5);
        break;
        case 4:
     
    }
 
   // iBootyQuality = iClamp(iStart,GOODS_QUANTITY,iBootyQuality);

    // TIH --> we generate random different types now, instead of always 7 different types
    int randGoods = 1 + rand(6);
    for (int r=0;r<randGoods;r++)
    {
    iBooty = iStart + rand(iBootyQuality - iStart - 1)// PW not sure about the -1 I think this excludes the lowest value cargo
    iBooty = iClamp(iStart,GOODS_QUANTITY,iBooty);
    Fantom_SetCharacterGoods(rFantom, iBooty, makeint(iMultiply * rand(iRandMultiply * 3)) );
     
        //Fantom_SetCharacterGoods(rFantom, iBootyQuality, makeint(iMultiply * rand(iRandMultiply * 3)) );
        //Fantom_SetCharacterGoods(rFantom, iStart + rand(GOODS_QUANTITY - iStart - 1), makeint(iMultiply * rand(iRandMultiply * 3)) );
    }
but there is also this code lower down the function that would need similar treatment
Code:
if(rFantom.FantomType == "trade")
    {
        int fillCargo = iStart + rand(GOODS_QUANTITY - iStart - 1);// random pick a good to be maxed
        int fillQuantity = GetCargoGoods(rFantom,fillCargo) + GetCharacterFreeSpace(rFantom,fillCargo);// fill up the hold
        Fantom_SetCharacterGoods(rFantom, fillCargo, fillQuantity);
    }
- since iBooty would be set the last time through the loop can just put that in place of the random choice and fill any space with the last good chosen.

yeah I had discovered the same thing with iBootyQuality generating the same goods, so I have since moved the whole thing to inside the for(int r=0;r<randGoods;r++). but this caused the problem that I cant use it in the fillCargo part since its all inside another function, and its probably unnecessarily messy to put the whole switch there as well, so probably your version will work better. what do you think?

Code:
int iStart = GOOD_PLANKS + 1;// TIH we start after repair goods now for random cargo
    int iBootyQuality;


    // TIH --> we generate random different types now, instead of always 7 different types
    int randGoods = 1 + rand(6);
    for (int r=0;r<randGoods;r++)
    {
        // DeathDaisy: Loot based on encounter type, fleet size, maybe other things
        switch(iGetEncType){
            case 0: // Merchant 0: single merchant
                iBootyQuality = GOODS_QUANTITY - rand(8 - iShipClass);
            break;
            case 1: // Merchant 1: merchants with a light escort
                iBootyQuality = GOODS_QUANTITY - rand((8 - iShipClass) + 2);
            break;
            case 2: // Merchant 2: a single merchant with heavy escort
                iBootyQuality = GOODS_QUANTITY - 5 - rand((8 - iShipClass) + (iGetNumWarShips*2));
            break;
            case 3: // Patrol: a small patrol
            break;
            case 4: // Fleet: warships
            break;
            case 5: // Corsar: -->PIRATE ONLY<--, warships
            break;
            case 6: // Pirate: -->PIRATE ONLY<--, small craft
            break;
            case 7: // Punitive Squadron: a rag-tag bunch
            break;
            case 8: // L - Merchant 0: Shallow Waters Merchant Fleet, a group of merchants
                iBootyQuality = GOODS_QUANTITY - rand((8 - iShipClass) + (roundup(iGetNumMerchantShips/2)));
            break;
            case 9: // L - Merchant 1: Coastal Waters Merchant Fleet, an escorted group of merchants
                iBootyQuality = GOODS_QUANTITY - round(GOODS_QUANTITY/4) - rand((8 - iShipClass) + iGetNumMerchantShips + iGetNumWarShips);
            break;
            case 10: // L - Merchant 2: -->SPAIN ONLY<--, Trans-Atlantic Treasure Fleet, a convoy
                iBootyQuality = GOODS_QUANTITY - round(GOODS_QUANTITY/3) - rand((8 - iShipClass) + iGetNumMerchantShips + (iGetNumWarShips*2));
                iBootyQuality = iClamp(iStart,roundup(GOODS_QUANTITY/2),iBootyQuality);
            break;
            case 11: // L - Patrol: Regional Patrol, a large patrol
            break;
            case 12: // L - Fleet: Regional Patrol, a small fleet
            break;
            case 13: // L - Corsar: ARMADA, a battle fleet
            break;
            case 14: // L - Pirate, -->PIRATE ONLY<--, a rag-tag bunch
            break;
            case 15: // L - Punitive Squadron, a scratch patrol
            break;
        }
        iBootyQuality = iClamp(iStart,GOODS_QUANTITY,iBootyQuality);
       
        Fantom_SetCharacterGoods(rFantom, iBootyQuality, makeint(iMultiply * rand(iRandMultiply * 3)) );makeint(iMultiply * rand(iRandMultiply * 3)) );
    }

    // TIH --> better method, prevents overloaded ships due to innept mathmatics Sep3'06
    if(rFantom.FantomType == "trade")
    {
        int fillCargo = iBootyQuality;// random pick a good to be maxed | DeathDaisy: THIS WONT WORK you dummy, but would rather not put the whole switch here again
        int fillQuantity = GetCargoGoods(rFantom,fillCargo) + GetCharacterFreeSpace(rFantom,fillCargo);// fill up the hold
        Fantom_SetCharacterGoods(rFantom, fillCargo, fillQuantity);
    }

EDIT Actually could just use fillCargo as the variable throughout and save on an integer (iBooty) .:)
this is elegant, I like it.
 
yeah I had discovered the same thing with iBootyQuality generating the same goods, so I have since moved the whole thing to inside the for(int r=0;r<randGoods;r++). but this caused the problem that I cant use it in the fillCargo part since its all inside another function, and its probably unnecessarily messy to put the whole switch there as well, so probably your version will work better. what do you think?
[

I was just reading the code and thinking aloud - It's your thing so whatever you like that works :popcorn:the main crux was getting the info about the encounter to feed into your switches
 
I was just reading the code and thinking aloud - It's your thing so whatever you like that works :popcorn:the main crux was getting the info about the encounter to feed into your switches

I went with your idea anyway because it was much tidier, and ultimately easier to work with xD
Code:
int iBootyQuality = 0;
    int iBooty;
   
    switch(iGetEncType){
            case 0: // Merchant 0: single merchant
                iBootyQuality = GOODS_QUANTITY; //include down to the least valuable
                iStart += 6;// omit the 6 most valuable
            break;
            case 1: // Merchant 1: merchants with a light escort
                iBootyQuality = GOODS_QUANTITY - rand((8 - iShipClass) + 1); // remove a random amount of the least valuable
                iStart += 2;// omit gold and silver
            break;
            case 2: // Merchant 2: a single merchant with heavy escort
                 iBootyQuality = GOODS_QUANTITY - 5 - rand((8 - iShipClass) + (iGetNumWarShips*2));// remove at least 5 of the less valuable and a further random amount
            break;
            case 3: // Patrol: a small patrol
            break;
            case 4: // Fleet: warships
            break;
            case 5: // Corsar: -->PIRATE ONLY<--, warships
            break;
            case 6: // Pirate: -->PIRATE ONLY<--, small craft
            break;
            case 7: // Punitive Squadron: a rag-tag bunch
            break;
            case 8: // L - Merchant 0: Shallow Waters Merchant Fleet, a group of merchants
                iBootyQuality = GOODS_QUANTITY - rand((8 - iShipClass) + (roundup(iGetNumMerchantShips/2))); // cut out shipclass
                iStart += 4; // omit 4 most valuble
            break;
            case 9: // L - Merchant 1: Coastal Waters Merchant Fleet, an escorted group of merchants
                iBootyQuality = GOODS_QUANTITY - round(GOODS_QUANTITY/4) - rand((8 - iShipClass) + iGetNumMerchantShips + iGetNumWarShips); // omit the bottom quarter of cheap goods and another couple depending on chance and how large the fleet
                iStart += 2; // omit gold, enough protection for maybe silver? omitted too for now. treasure fleets are supposed to be the big haul after all
            break;
            case 10: // L - Merchant 2: -->SPAIN ONLY<--, Trans-Atlantic Treasure Fleet, a convoy
                iBootyQuality = GOODS_QUANTITY - round(GOODS_QUANTITY/3) - rand((8 - iShipClass) + iGetNumMerchantShips + (iGetNumWarShips*2)); // cut out bottom 3rd cheap goods, another few based on chance, number of merchant ships and TWICE the number of war ships. might be too good even. jackpot!
                //iBootyQuality = iClamp(iStart,roundup(GOODS_QUANTITY/2),iBootyQuality);
            break;
            case 11: // L - Patrol: Regional Patrol, a large patrol
            break;
            case 12: // L - Fleet: Regional Patrol, a small fleet
            break;
            case 13: // L - Corsar: ARMADA, a battle fleet
            break;
            case 14: // L - Pirate, -->PIRATE ONLY<--, a rag-tag bunch
            break;
            case 15: // L - Punitive Squadron, a scratch patrol
            break;
        }
        //iBootyQuality = iClamp(iStart,GOODS_QUANTITY,iBootyQuality);


    // TIH --> we generate random different types now, instead of always 7 different types
    int randGoods = 1 + rand(6);
    for (int r=0;r<randGoods;r++)
    {
       
        iBooty = iStart + rand(iBootyQuality - iStart - 1) // PW not sure about the -1 I think this excludes the lowest value cargo
        iBooty = iClamp(iStart,GOODS_QUANTITY,iBooty);
       
        Fantom_SetCharacterGoods(rFantom, iBooty, makeint(iMultiply * rand(iRandMultiply * 3)) );
    }
    // TIH <--

    // TIH --> better method, prevents overloaded ships due to innept mathmatics Sep3'06
    if(rFantom.FantomType == "trade")
    {
        iBooty = iStart + rand(iBootyQuality - iStart - 1) // PW not sure about the -1 I think this excludes the lowest value cargo
        iBooty = iClamp(iStart,GOODS_QUANTITY,iBooty)
        int fillQuantity = GetCargoGoods(rFantom,iBooty) + GetCharacterFreeSpace(rFantom,iBooty);// fill up the hold
        Fantom_SetCharacterGoods(rFantom, iBooty, fillQuantity);
    }

this should work I think, but I havent had much chance to test it.

also still don't quite know what to do with the warships. it seems theyre given a bit of goods, and if I read the code right, with what I've done above they'll always end up with gold :p not the best. but I don't know if I should give them no stuff, less valuable stuff or just the same stuff but less of it(which is how it was before).
 
I figure warships only need supplies.
Maybe extra cannonballs, powder and rations or so.
 
Pirate ships, on the other hand, could be carrying random loot.

For that matter, warships could very well be carrying gold. The Girona certainly carried plenty of treasure. Beyond that, although naval captains weren't supposed to indulge in private trade, some of them did anyway.
 
I figure warships only need supplies.
Maybe extra cannonballs, powder and rations or so.
Pirate ships, on the other hand, could be carrying random loot.

For that matter, warships could very well be carrying gold. The Girona certainly carried plenty of treasure. Beyond that, although naval captains weren't supposed to indulge in private trade, some of them did anyway.
hm, maybe warships could by default not carry any nonessential goods, but have a small chance of carrying something of arbitrary value, so it could be anything from bricks to gold?

pirates should definitely carry random stuff! xD just havent figured out quite what and how much yet :p
 
Pirate ships, on the other hand, could be carrying random loot.

For that matter, warships could very well be carrying gold. The Girona certainly carried plenty of treasure. Beyond that, although naval captains weren't supposed to indulge in private trade, some of them did anyway.
Smaller, faster warships were commonly used for transporting military payrolls. Troop ships were also used for this purpose. Other entities, such as the EITC and VOC, used refitted fast merchantmen with extra armament for moving wealth around. Spain had fast galleons, war galleons, and those floating fortresses known as Manila galleons for the same purpose.

Any of these would make for good hunting. :ship
 
Code:
    int iStart = GOOD_PLANKS + 1;// TIH we start after repair goods now for random cargo
    int iBootyQuality = 0;
    int iBooty;
   
    switch(iGetEncType){
            case 0: // Merchant 0: single merchant
                iBootyQuality = GOODS_QUANTITY; //include down to the least valuable
                iStart += 6;// omit the 6 most valuable
            break;
            case 1: // Merchant 1: merchants with a light escort
                iBootyQuality = GOODS_QUANTITY - rand((iShipClass) + 1); // remove a random amount of the least valuable
                iStart += 2;// omit gold and silver
            break;
            case 2: // Merchant 2: a single merchant with heavy escort
                 iBootyQuality = GOODS_QUANTITY - 5 - rand((iShipClass) + (iGetNumWarShips*2));// remove at least 5 of the less valuable and a further random amount
            break;
            case 3: // Patrol: a small patrol
                iBootyQuality = GOODS_QUANTITY;
                iStart += 10; // omit the 10 most valuable! it's a lonely, small warship after all
            break;
            case 4: // Fleet: warships
                iBootyQuality = GOODS_QUANTITY; // could carry anything!
            break;
            case 5: // Corsar: -->PIRATE ONLY<--, warships
                iBootyQuality = GOODS_QUANTITY - iShipClass; // ditto! but remove the least expensive goods to reward the player for taking on warships
            break;
            case 6: // Pirate: -->PIRATE ONLY<--, small craft
                iBootyQuality = GOODS_QUANTITY; // ditto!!!
                iStart += 2; // maybe shouldn't carry gold and silver
            break;
            case 7: // Punitive Squadron: a rag-tag bunch
                iBootyQuality = GOODS_QUANTITY - rand(iShipClass); // governor comendeered all ships, they might have been carrying anything too
            break;
            case 8: // L - Merchant 0: Shallow Waters Merchant Fleet, a group of merchants
                iBootyQuality = GOODS_QUANTITY - rand(iShipClass) + (roundup(iGetNumMerchantShips/2))); // cut out shipclass
                iStart += 4; // omit 4 most valuble
            break;
            case 9: // L - Merchant 1: Coastal Waters Merchant Fleet, an escorted group of merchants
                iBootyQuality = GOODS_QUANTITY - round(GOODS_QUANTITY/4) - rand(iShipClass + iGetNumMerchantShips + iGetNumWarShips); // omit the bottom quarter of cheap goods and another couple depending on chance and how large the fleet
                iStart += 2; // omit gold, enough protection for maybe silver? omitted too for now. treasure fleets are supposed to be the big haul after all
            break;
            case 10: // L - Merchant 2: -->SPAIN ONLY<--, Trans-Atlantic Treasure Fleet, a convoy
                iBootyQuality = GOODS_QUANTITY - round(GOODS_QUANTITY/3) - rand(iShipClass + iGetNumMerchantShips + (iGetNumWarShips*2)); // cut out bottom 3rd cheap goods, another few based on chance, number of merchant ships and TWICE the number of war ships. might be too good even. jackpot!
            break;
            case 11: // L - Patrol: Regional Patrol, a large patrol
                iBootyQuality = GOODS_QUANTITY;
                iStart += 6; // Regional patrols are probably not doing any heavy duty trading on the side?
            break;
            case 12: // L - Fleet: Regional Patrol, a small fleet
                iBootyQuality = GOODS_QUANTITY;
                iStart += 2; // Regional fleets might?
            break;
            case 13: // L - Corsar: ARMADA, a battle fleet
                iBootyQuality = GOODS_QUANTITY - rand(iShipClass*2); // potentially very high value loot. should get rewarded for taking on a battle fleet?
            break;
            case 14: // L - Pirate, -->PIRATE ONLY<--, a rag-tag bunch
                iBootyQuality = GOODS_QUANTITY - rand(iShipClass); // can carry anything
            break;
            case 15: // L - Punitive Squadron, a scratch patrol
                iBootyQuality = GOODS_QUANTITY; // any and all ships the governor could muster. random loot!
                if(rand(100) < 20) iStart += 2; // could sometimes in a blue moon carry noble metals!
            break;
        }


    // TIH --> we generate random different types now, instead of always 7 different types
    if(rFantom.FantomType == "trade" || rFantom.FantomType == "pirate" || rFantom.FantomType == "war" && rand(100) < 15){ // DeathDaisy: an if argument to have a separate chance for warships to carry extra cargo?
        int randGoods = 1 + rand(6);
        for (int r=0;r<randGoods;r++)
        {
            iBooty = iStart + rand(iBootyQuality - iStart); // PW not sure about the -1 I think this excludes the lowest value cargo | DeathDaisy: agree about the -1, removed it for now, but it might return!
            iBooty = iClamp(iStart,GOODS_QUANTITY,iBooty);
           
            Fantom_SetCharacterGoods(rFantom, iBooty, makeint(iMultiply * rand(iRandMultiply * 3)) );
        }
        // TIH <--
    }

    // TIH --> better method, prevents overloaded ships due to innept mathmatics Sep3'06
    if(rFantom.FantomType == "trade")
    {
        iBooty = iStart + rand(iBootyQuality - iStart); // random pick a good to be maxed
        iBooty = iClamp(iStart,GOODS_QUANTITY,iBooty);
        int fillQuantity = GetCargoGoods(rFantom,iBooty) + GetCharacterFreeSpace(rFantom,iBooty);// fill up the hold
        Fantom_SetCharacterGoods(rFantom, iBooty, fillQuantity);
    }
the big changes:
-added iBootyQuality calcs for all cases, dont know if they are completely/remotely balanced?
-added if(rFantom.FantomType == "trade" || rFantom.FantomType == "pirate" || rFantom.FantomType == "war" && rand(100) < 15) to give warships a 15%ish chance of generating cargo. too little? does mixing || and && that way work for what Im trying to do?
-discovered iShipClass already had the 8 - shipclass to make higher classes return higher numbers, so that's fixed
 
-added if(rFantom.FantomType == "trade" || rFantom.FantomType == "pirate" || rFantom.FantomType == "war" && rand(100) < 15) to give warships a 15%ish chance of generating cargo. too little? does mixing || and && that way work for what Im trying to do?

I don't think the PotC code handles that correctly.
You may want to use a temporary Boolean instead, just to be safe.



You could try

Code:
// TIH --> we generate random different types now, instead of always 7 different types
       int randGoods = 1 + rand(6);
        if (rFantom.FantomType == "war" && rand(100) > 15) randGoods = 0;
    for (int r=0;r<randGoods;r++)
        {
            iBooty = iStart + rand(iBootyQuality - iStart); // PW not sure about the -1 I think this excludes the lowest value cargo | DeathDaisy: agree about the -1, removed it for now, but it might return!
            iBooty = iClamp(iStart,GOODS_QUANTITY,iBooty);
      
            Fantom_SetCharacterGoods(rFantom, iBooty, makeint(iMultiply * rand(iRandMultiply * 3)) );
        }
        // TIH <--
    }
Which I think should skip the setting loop for "war" around 85% of the time -but I don't know for sure how a non execution of a loop even once would react.
Incidentally I think this line needs changing to greater than?
Code:
 if(rand(100) < 20) iStart += 2; // could sometimes in a blue moon carry noble metals!
 
Last edited:
I don't think the PotC code handles that correctly.
You may want to use a temporary Boolean instead, just to be safe.
You could try

Code:
// TIH --> we generate random different types now, instead of always 7 different types
       int randGoods = 1 + rand(6);
        if (rFantom.FantomType == "war" && rand(100) > 15) randGoods = 0;
    for (int r=0;r<randGoods;r++)
        {
            iBooty = iStart + rand(iBootyQuality - iStart); // PW not sure about the -1 I think this excludes the lowest value cargo | DeathDaisy: agree about the -1, removed it for now, but it might return!
            iBooty = iClamp(iStart,GOODS_QUANTITY,iBooty);
     
            Fantom_SetCharacterGoods(rFantom, iBooty, makeint(iMultiply * rand(iRandMultiply * 3)) );
        }
        // TIH <--
    }
Which I think should skip the setting loop for "war" around 85% of the time -but I don't know for sure how a non execution of a loop even once would react.
sounds very nice :onya gonna try it out! if it works I think I'm more or less done unless I have forgotten something, then it just needs balancing xD

Incidentally I think this line needs changing to greater than?
Code:
 if(rand(100) < 20) iStart += 2; // could sometimes in a blue moon carry noble metals!
yes indeed :eek:
 
I realised me testing it for function and balance alone maybe isnt the most efficient way :p I think this is the only file Ive touched, so sharing what I got so far! xD it's from SEA_AI

EDIT: actually I ofc rearranged the goods in STORE\goods.h too, so attaching that as well
 

Attachments

  • AIFantom.c
    34.3 KB · Views: 213
  • goods.h
    2.2 KB · Views: 228
Last edited:
I realised me testing it for function and balance alone maybe isnt the most efficient way :p I think this is the only file Ive touched, so sharing what I got so far! xD it's from SEA_AI

EDIT: actually I ofc rearranged the goods in STORE\goods.h too, so attaching that as well
I merged your changes into my game setup to help with testing. Time to for a little cruise, says I. :sail
 
hm, getting loads of errors, mostly about array size.. I dont know where it would output a number that isnt within 33. I didnt sink any ships so I couldnt tell if they got cargo anyway, but my guess is that iBooty outputs a weird number. it shouldnt, because it's an int, but stranger things has happened :shrug for example this excerpt from error.log
Code:
RUNTIME ERROR - file: sea_ai\AIFantom.c; line: 641
Unknown data type
thats this line:
Code:
        int fillQuantity = GetCargoGoods(rFantom,iBooty) + GetCharacterFreeSpace(rFantom,iBooty);// fill up the hold
iBooty not putting out a proper number is my best guess, unless this error existed before me messing with it :eek: why it would do that is a mystery to me
 

Attachments

  • error.log
    4.9 KB · Views: 212
  • compile.log
    21.8 KB · Views: 184
Back
Top