peewee_RotA wrote: ↑Fri Mar 08, 2024 5:16 pm
The root cause of my problem is that Item #1 makes a calculation based on damage done and Item #2 modifies the damage.
No matter what I do, Item #1's ModifyDamage happens before Item #2's Modify damage. So the changes from the item don't take effect until too late.
I'm not sure if I completely understand your problem, but am I correct in assuming that both Item #1 and Item #2 belong to the same owner?
If they do, then the order of
ModifyDamage calls depends on the order the items are situated in the owner's inventory.
So, if you want to ensure that a certain item's
ModifyDamage is
always called first, your item needs a way to maintain its position in the beginning of the inventory chain. Which can be accomplished with the following code:
Code: Select all
class AlwaysFirstItem : Inventory
{
override void Tick()
{
if (Owner != null && Owner.Inv != self)
{
for (let ii = Owner.Inv; ii != null; ii = ii.Inv)
{
if (ii.Inv == self)
{
ii.Inv = Inv;
Inv = Owner.Inv;
Owner.Inv = self;
break;
}
}
}
Super.Tick();
}
}
Note that, for obvious reasons, this would only work if you have only one such item class. If you need to apply effects from multiple items in a consistent order, it might perhaps be feasible to have a "master" item that serves as the entry point e.g. via
ModifyDamage, which runs custom code that uses
FindInventory and queries the items it finds in the exact order that's necessary to produce the desired result.