Skip to content
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

Merged
merged 5 commits into from
Nov 14, 2017
Merged

Reforge hooks updates #257

merged 5 commits into from
Nov 14, 2017

Conversation

Jofairden
Copy link
Member

@Jofairden Jofairden commented Oct 19, 2017

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 to reforgePrice. The passed reforgePrice is item.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.

/// </summary>
public virtual void PreReforge(Item item)
Copy link
Collaborator

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.

Copy link
Member Author

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))
Copy link
Member Author

@Jofairden Jofairden Oct 20, 2017

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.

@Jofairden Jofairden merged commit 3b42c9f into master Nov 14, 2017
@Jofairden
Copy link
Member Author

Jofairden commented Nov 14, 2017

Should be fine, player.CanBuyItem is dirty. I blame vanilla
Any changes necessary can be easily made anyway

@Jofairden Jofairden deleted the Reforging branch November 14, 2017 18:23
@Jofairden Jofairden mentioned this pull request Nov 14, 2017
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants