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

Allow server operators to exempt some weapons from weapon stay #278

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

GooberRF
Copy link
Contributor

PR adds the $DF Weapon Stay Exemptions dedicated server config option, and resolves #65

This is something that has been asked for a lot by players over the past few years, particularly for the Rail Driver. The ability to treat the Rail Driver as a superweapon like the fusion, which is exempt from weapon stay by default, in theory might actually make the Rail Driver practical in a competitive setting.

I considered implementing this as simply a $DF Rail Driver Is Superweapon toggle, but given how relatively straightforward it was to also support the other weapons, I erred on the side of providing more (completely optional) gameplay customization opportunities to server operators, and expanded the capability to the other weapons.

@is-this-c
Copy link
Contributor

is-this-c commented Oct 3, 2024

Nitpick. But I think exclude or exclusions is better.

Edit: I have looked at the code and all I can say is (beside a C style array I did see) I am not sure whether your code is the right way but I really do not like the way you have done it. Really like to know what rafalh thinsk.

{&WeaponStayExemptionConfig::rail_gun, 0x00872124}};

// declare optional vector for weapon stay exemptions
std::optional<std::vector<uintptr_t>> weapon_stay_exempt_indexes;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the point of making it an optional? Empty vector would have the same effect

@@ -197,12 +243,83 @@ void load_additional_server_config(rf::Parser& parser)
}
}

// memory addresses for weapon stay exemption indexes
constexpr std::pair<bool WeaponStayExemptionConfig::*, uintptr_t> weapon_exemptions[] = {
{&WeaponStayExemptionConfig::rocket_launcher, 0x00872458},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's really no need to have all those offsets hardcoded here. Just let the people configure list of class names, then at load time translate them to indices using weapon_lookup_type

@@ -96,6 +96,52 @@ void load_additional_server_config(rf::Parser& parser)
}
}

if (parser.parse_optional("$DF Weapon Stay Exemptions:")) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick. But I think exclude or exclusions is better.

I don't like "exemptions" too. I think it's not a popular word. Excludes/exclusions sounds more familiar.
Anyway it would make sense to include Fusion Launcher on that list by default and allow changing it to an empty list or whatever the server owner wants. Like if we are making it configurable, there is no reason to have Fusion as a special case.

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.

DF server variable to exclude specific weapons from staying when weapon stay is enabled
3 participants