-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reforge hooks updates #257
Conversation
/// </summary> | ||
public virtual void PreReforge(Item item) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know of any mods using PreReforge? Making a breaking change like this might be OK if no mods actually ever got around to using it. Otherwise we need a bool NewPreReforge
that by default calls PreReforge, like what we did with when we had to change the Wing hooks. Also mark PreReforge as Obsolete until 0.11.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woops, you're right. I didn't think about that. For sure there are plenty of mods using it because it had to be used to preserve modded data.
Main.mouseReforge = true; | ||
Main.player[Main.myPlayer].mouseInterface = true; | ||
- if (Main.mouseLeftRelease && Main.mouseLeft && Main.player[Main.myPlayer].BuyItem(num62, -1)) | ||
+ if (Main.mouseLeftRelease && Main.mouseLeft && Main.player[Main.myPlayer].BuyItem(num62, -1) && ItemLoader.PreReforge(Main.reforgeItem)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woops. Main.player[Main.myPlayer].BuyItem
will take away gold regardless if the PreReforge hook returns true or not. Not sure if we want it to behave this way.
Should be fine, player.CanBuyItem is dirty. I blame vanilla |
Added a ReforgePrice hook available to adjust the reforge pricing. The
reforgePrice
can be changed to override the price,canApplyDiscount
can be set to false to never apply discount. Returning false will stop the vanilla pricing to take place and the price will be set toreforgePrice
. The passedreforgePrice
isitem.value
(as Terraria uses that as the base price). Returns true by default so vanilla pricing takes place. This hook will be useful to adjust reforge pricing without touching the actual item value.Adjusted the PreReforge hook to return a bool. Returns whether the reforge will take place. If false is returned, the PostReforge hook is never called because the reforge will not happen. Returns true by default.
Changed the reforge code slightly so any modded data on the item being reforged will be preserved. This means modders no longer have to manually preserve their modded data with PreReforge and PostReforge, provided they've setup their Clone override properly.
Personally I'll be using the changes for the Even More Modifiers mod. The reforge price will be adjusted based on the modifier rarity. Possibly, I will let reforging interact with the modifiers.