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.

Fixed Bug with skill boost items that require multiple of the item to work

Discussion in 'Bug Archive' started by Tingyun, Aug 16, 2016.

  1. Pieter Boelen

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

    Joined:
    Nov 11, 2004
    Messages:
    66,623
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
    Why would you compare the "stack" and "num" values to each other?
    "Stack" is only a boolean.

    I still think you need to use stf instead of sti where those attributes are being divided.
     
  2. Levis

    Levis Find(Rum) = false; Staff Member Programmer Creative Support Storm Modder

    Joined:
    Oct 6, 2013
    Messages:
    6,704
    Gender:
    Male
    Occupation:
    ICT
    Location:
    University Twente (Netherlands)
    is it really only boolean?
    then there are some typos indeed. I tought it was meant to be 0 if it doesn't stack and else says how many can stack. so it if says 2 it could go double. but I guess it's a boolean value indeed. we do need to check some items to make sure it works for all ...

    I don't need stf here beause I only want the int value in this case.
     
  3. Levis

    Levis Find(Rum) = false; Staff Member Programmer Creative Support Storm Modder

    Joined:
    Oct 6, 2013
    Messages:
    6,704
    Gender:
    Male
    Occupation:
    ICT
    Location:
    University Twente (Netherlands)
    so that would make it this:
    Code:
    //Levis --> changed to fix the problem with overflowing the stack no applying any bonus
                //Check if the player has enough items
                if(qty >= sti(itm.skill.num))
                {
                    //Check if bonusses stack
                    if(sti(itm.skill.stack) >= 1)
                    {
                        //they stack so we can add the mod
                        mod += sti(itm.skill.(skillName)) * qty/sti(itm.skill.num);
                    }
                    else
                    {
                        //they don't stack so just add the mod once.
                        mod += sti(itm.skill.(skillName));
                    }
                }
                //Levis <--
    
    place in:
    \PROGRAM\characters\skills
     

    Attached Files:

  4. Pieter Boelen

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

    Joined:
    Nov 11, 2004
    Messages:
    66,623
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
    Yep, it should just be booleans. :onya

    Using int for float operations can lead to funny stuff at times.
    I found out about that the hard way when fixing the "fetch quests for 0 gold" bug a while back.
    If it does what you think it does, it is should be fine. But please be very, very careful....
     
  5. Levis

    Levis Find(Rum) = false; Staff Member Programmer Creative Support Storm Modder

    Joined:
    Oct 6, 2013
    Messages:
    6,704
    Gender:
    Male
    Occupation:
    ICT
    Location:
    University Twente (Netherlands)
    it should just work fine with the code posted above. it would be nice if @Tingyun could test it.
     
  6. Tingyun

    Tingyun Corsair Storm Modder

    Joined:
    Aug 8, 2016
    Messages:
    1,445
    Gender:
    Male
    I will be happy to test it tonight and will report back. If there are any particular errors you want me to watch for, besides confirming the skill bonuses works correctly, please let me know.
     
  7. Levis

    Levis Find(Rum) = false; Staff Member Programmer Creative Support Storm Modder

    Joined:
    Oct 6, 2013
    Messages:
    6,704
    Gender:
    Male
    Occupation:
    ICT
    Location:
    University Twente (Netherlands)
    if you see anything in the error log please post it. but it should just solve the problem with the skill bonusses
     
  8. Tingyun

    Tingyun Corsair Storm Modder

    Joined:
    Aug 8, 2016
    Messages:
    1,445
    Gender:
    Male
    Tested, no error log.

    But it makes the bonus stack. In other words, since 3 pyrite gives a +1 to the skill, 6 garnet now gives +2.

    I think that is not intended?

    Also, on immediate loading no skill bonuses are present, I have to switch one of the item around by exchanging it to someone else and back again before the bonus updates. I am sure that is not an issue though, just letting you know.
     
  9. Levis

    Levis Find(Rum) = false; Staff Member Programmer Creative Support Storm Modder

    Joined:
    Oct 6, 2013
    Messages:
    6,704
    Gender:
    Male
    Occupation:
    ICT
    Location:
    University Twente (Netherlands)
    Code:
    n = InitItem(n,"mineral1", "",        7,  1,  0.08,  3,    410, 1,   3, 1, 0,   0,  0,  0,  0, +1,  0,  0,  0,  0,  0,  0,  0,  0,  1);// Pyrite
    
    pyrite should stack according to the inititems. so if what @Pieter Boelen said is true the system now behaves as it should do.
    The case where you first need to rearange the items can be true because the function is only called once a new item is added I think.
     
    Tingyun likes this.
  10. Tingyun

    Tingyun Corsair Storm Modder

    Joined:
    Aug 8, 2016
    Messages:
    1,445
    Gender:
    Male
    Oh, in that case it works fine.

    One concern though, it isn't that hard to accumulate many, many pyrite, garnet, etc. Nearly every native has one of those metals, in addition to their special object (mask, idol, vase, etc). Several hours of the player hunting around at night and it is +4 across multiple skills. So maybe it shouldn't stack past the +1 for balance purposes.
     
  11. Pieter Boelen

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

    Joined:
    Nov 11, 2004
    Messages:
    66,623
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
    Those items probably shouldn't stack at all.
    Just require multiple and that's it?

    What I said is definitely true. ;)

    For performance reasons, skill modifiers are only updated when anything changes.
    If you need to rearrange your items, this failed to happen.
    In that case, I'd like to know how exactly you got the item that didn't trigger the update.
    Possibly there is an "update" missing from certain scenarios.
     
  12. Tingyun

    Tingyun Corsair Storm Modder

    Joined:
    Aug 8, 2016
    Messages:
    1,445
    Gender:
    Male
    Hi Pieter--I just loaded a saved game already having the items in order to test Levis's fix, and then immediately looked at character skills. So it probably is working as intended, and it just had no chance to update since I hadn't done anything.

    As soon as I transfered a pyrite to a companion, it instantly updated and the bonus was present. I just try to report everything, since I don't understand things well enough to be sure something isn't important. Which is why I mentioned the updating thing. ;)
     
  13. Pieter Boelen

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

    Joined:
    Nov 11, 2004
    Messages:
    66,623
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
    Your reports are pretty good! You're welcome to keep it up. :doff
     
    Tingyun likes this.
  14. Jack Rackham

    Jack Rackham HoO Team Member Quest Writer Storm Modder

    Joined:
    Jul 5, 2004
    Messages:
    3,288
    Gender:
    Male
    Occupation:
    math teacher
    Location:
    Sund, Ramsjö, Sweden
    I think I have fixed it but have to show up at school so they think I'm working. Soon back.
     
    Pieter Boelen likes this.
  15. Levis

    Levis Find(Rum) = false; Staff Member Programmer Creative Support Storm Modder

    Joined:
    Oct 6, 2013
    Messages:
    6,704
    Gender:
    Male
    Occupation:
    ICT
    Location:
    University Twente (Netherlands)
    The code I posted above fixes this problem. We just need to take a good look at some of the skill items if we really want them to stack because now that's actually working.
     
  16. Pieter Boelen

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

    Joined:
    Nov 11, 2004
    Messages:
    66,623
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
    I can think of only one item that should stack: The Cursed Coins because they're evil.

    What was the actual reason for this not working in the end?
     
  17. Jack Rackham

    Jack Rackham HoO Team Member Quest Writer Storm Modder

    Joined:
    Jul 5, 2004
    Messages:
    3,288
    Gender:
    Male
    Occupation:
    math teacher
    Location:
    Sund, Ramsjö, Sweden
    I tested the file and they stacked even if I set stack to 0.
    Also counted wrong in my two last test cases

    Here's a file which is Levis' but continued on.
    I have tested it for:

    ..................................numneeded............................stack.........................qty
    an item with....................1...........................................1.............................many numbers
    an item with....................3...........................................1.............................many numbers
    an item with....................1...........................................3.............................many numbers (not in the game now)
    an item with....................2...........................................2.............................many numbers (not in the game now)

    All cases now work.

    cursedcoin doesn't give any bonus. Maybe it's changed?
     

    Attached Files:

  18. Pieter Boelen

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

    Joined:
    Nov 11, 2004
    Messages:
    66,623
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
    Cursed coins should have a -1 (negative) Luck "bonus" that does stack.
     
  19. Levis

    Levis Find(Rum) = false; Staff Member Programmer Creative Support Storm Modder

    Joined:
    Oct 6, 2013
    Messages:
    6,704
    Gender:
    Male
    Occupation:
    ICT
    Location:
    University Twente (Netherlands)
    with my code they shouldn't stack ... It should only give 1 bonus.

    I really don't get what you are doing here
    Code:
    if(qty >= sti(itm.skill.num))
                        {
                    //Check if bonusses stack
                    if(sti(itm.skill.stack) >= 2)        //JRH
                    {
                        if(sti(itm.skill.num) >= 2)
                        {
                            //worst scenario
                            mod += sti(itm.skill.(skillName)) * qty * sti(itm.skill.stack);            //JRH
    
                        }
                        else
                        {
                            //they stack so we can add the mod
                            mod += sti(itm.skill.(skillName)) * qty/sti(itm.skill.num) * sti(itm.skill.stack);    //JRH
                        }
                    }
                    else
                    {
                        //they don't stack so just add the mod once.
                        mod += sti(itm.skill.(skillName));
                    }
                        }
    
    why would you want to multiply the qty with the stack in the first place? and what is this "worse case" scenario :S?
    And @Pieter Boelen said stack was suposted to be a boolean value so why check for larger then 2?
    If stack is 1 or higher it should stack if it is a boolean value.
    If stack is 0 it still goes to the same case as it did before and I don't see any changed you made there so I don't see how this helps :S.

    These are the results I expect to find with my code.

    stack=0 numneed=3 qty=1 bonus=+1 mod=0
    stack=0 numneed=3 qty=3 bonus=+1 mod=1
    stack=0 numneed=3 qty=8 bonus=+1 mod=1
    stack=1 numneed=3 qty=1 bonus=+1 mod=0
    stack=1 numneed=3 qty=3 bonus=+1 mod=1
    stack=1 numneed=3 qty=8 bonus=+1 mod=2
    stack=2 numneed=3 qty=1 bonus=+1 mod=0
    stack=2 numneed=3 qty=3 bonus=+1 mod=1
    stack=2 numneed=3 qty=8 bonus=+1 mod=2
     
  20. Levis

    Levis Find(Rum) = false; Staff Member Programmer Creative Support Storm Modder

    Joined:
    Oct 6, 2013
    Messages:
    6,704
    Gender:
    Male
    Occupation:
    ICT
    Location:
    University Twente (Netherlands)
    @Jack Rackham your code seems to return:

    stack=0 numneed=3 qty=1 bonus=+1 mod=0
    stack=0 numneed=3 qty=3 bonus=+1 mod=1
    stack=0 numneed=3 qty=8 bonus=+1 mod=1
    stack=1 numneed=3 qty=1 bonus=+1 mod=0
    stack=1 numneed=3 qty=3 bonus=+1 mod=1
    stack=1 numneed=3 qty=8 bonus=+1 mod=1
    stack=2 numneed=3 qty=1 bonus=+1 mod=0
    stack=2 numneed=3 qty=3 bonus=+1 mod=6
    stack=2 numneed=3 qty=8 bonus=+1 mod=16

    the last two will be capped to the max which is 4 but it isn't what you want right?
     

Share This Page