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

How to hook static fields #43

Open
2079541547 opened this issue Jun 22, 2024 · 3 comments
Open

How to hook static fields #43

2079541547 opened this issue Jun 22, 2024 · 3 comments

Comments

@2079541547
Copy link

I want to do what the hook static field should do. The following is using Tool dump

Screenshot_20240622_103704
Screenshot_20240622_103645

@Lsc0x80
Copy link

Lsc0x80 commented Jun 29, 2024

//...
auto ItemID_Sets_c = BNM::Class("Terraria.ID", "ItemID").GetInnerClass("Sets");
BNM::Field<BNM::Mono::Array<bool>> Deprecated = ItemID_Sets_c.GetField("Deprecated");
for (const bool& a : Deprecated.Get()->ToVector())
{
    // Code that writes values to file
}
// this line sets 13th element to true
Deprecated.Get()[12] = true;

//...

@2079541547
Copy link
Author

Thank you, good comrade

@2079541547
Copy link
Author

I want to create a new field inside itemid and hook the switch branch of SetDefaults5 in item, I want to be able to call this.DefaultToAccessory(30, 42);
What can I do with code like this?
image
image

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

No branches or pull requests

2 participants