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

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

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.
 
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.
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.
 
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
 

Attachments

  • skill_utils.c
    13.6 KB · Views: 128
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....
 
it should just work fine with the code posted above. it would be nice if @Tingyun could test it.
 
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.
 
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.
if you see anything in the error log please post it. but it should just solve the problem with the skill bonusses
 
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.
 
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.
 
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.
 
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.
 
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. ;)
 
I think I have fixed it but have to show up at school so they think I'm working. Soon back.
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.
 
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?
 
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?
 

Attachments

  • skill_utils.c
    13.8 KB · Views: 130
Cursed coins should have a -1 (negative) Luck "bonus" that does stack.
 
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
 
@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?
 
Back
Top