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

Refactor turrets (part 2) #17160

Merged
merged 12 commits into from
Jun 15, 2016
Merged

Refactor turrets (part 2) #17160

merged 12 commits into from
Jun 15, 2016

Conversation

mugling
Copy link
Contributor

@mugling mugling commented Jun 12, 2016

Waiting for #16959 and will then be rebased

  • Greatly simplifies turret code and migrate everything to turret.cpp.
  • Provides vehicle::turrets() accessor
  • Partial fix for Turret refactor and blazemod #17089 (destroyed turrets don't fire)

Implementation:

  • vehicle::turret_query can be used to check a turret status
  • Turrets automatically reload via turret_reload before firing

Still WIP but everything else will build upon 79753b6 without further rebase so comments requested

@mugling mugling force-pushed the tur7 branch 2 times, most recently from f9ba08e to 79753b6 Compare June 13, 2016 11:00
@mugling mugling changed the title Refactor turrets (part 2) [WIP] Refactor turrets (part 2) [WIP] [CR] Jun 13, 2016
@mugling
Copy link
Contributor Author

mugling commented Jun 13, 2016

When setting targets the UI now shows which turrets are in range and will be affected

{
item &gun = pt.base;
if( !gun.is_gun() || gun.ammo_type() == "NULL" ||
gun.ammo_current() == "null" || gun.ammo_remaining() == 0 ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not necessary here, just noting:

ammo_type() == "NULL" and ammo_current() == "null" are repeated a lot in the code and are rather ugly.

It would be much better if they looked like ammo_type().is_null() and ammo_current().is_null().

The fact that they use different capitalization adds to the confusion and has resulted in at least one bug, as far as I recall.

@Coolthulhu
Copy link
Contributor

Possible sources of bugs:
This new turret code assumes turrets are guns that can be loaded, but there are turrets that should not be fired by hand. At some time in history, this was solved by giving those turrets 0 ammo capacity. I think blazemod still has some turrets with 0 ammo capacity.

There needs to be an option to designate a gun as mounted-only.

Also other bugs that should be fixed here, or at least kept in mind when designing: #17071, #17022, #12801

@mugling mugling changed the title Refactor turrets (part 2) [WIP] [CR] Refactor turrets (part 2) Jun 14, 2016
@mugling
Copy link
Contributor Author

mugling commented Jun 14, 2016

As of 948a262 turrets start with automatic targeting disabled. Combined with the fix for destroyed turrets still being usable this stops wreckage spamming debug messages about sufficient ammo.

This is a fairly hefty refactor which sets the stage for part 3 which will tackle a lot of the deficiencies in the interface for targeting individual turrets.

No further changes to this PR anticipated excluding review/fixes.

@Vollinger
Copy link
Contributor

few blazemod issues
not possible to switch firing mode on MANUAL turrets by standing on it and pressing the toggle attack mode key
selecting aim turrets manually option in the vehicle controls menu opens up targeting screen but doesn't fire any turrets
mounted mk 19 grenade launchers are permanently out of ammo

@mugling
Copy link
Contributor Author

mugling commented Jun 15, 2016

not possible to switch firing mode on MANUAL turrets by standing on it and pressing the toggle attack mode key

Not a regression from this specific PR. Firing modes are part 3

selecting aim turrets manually option in the vehicle controls menu opens up targeting screen but doesn't fire any turrets

Was always the case with that prompt

mounted mk 19 grenade launchers are permanently out of ammo

Can you be more specific and is this a regression from this specific PR?

@Coolthulhu Coolthulhu self-assigned this Jun 15, 2016
@Coolthulhu
Copy link
Contributor

Flamethrower can't use napalm ammo, only gasoline.

break;

case turret_status::no_power:
add_msg( m_bad, string_format( _( "The %s is not powered" ), pt.name().c_str() ).c_str() );
Copy link
Contributor

Choose a reason for hiding this comment

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

Period at the end of the sentence - here and above.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, why the weird formatting? Why string_format inside add_msg which already does formatting?

@Coolthulhu
Copy link
Contributor

Turrets now fire at extreme ranges where they can't hit anything.

@Coolthulhu
Copy link
Contributor

turret.cpp needs to be added to .cbp project.

@mugling
Copy link
Contributor Author

mugling commented Jun 15, 2016

Turrets now fire at extreme ranges where they can't hit anything.

Three options:

  1. Hard limit (12 tiles)
  2. JSON limit (no guarantee of better balance)
  3. Calculated based upon to-hit % (separate PR).

Propose option 1 as temporary fix (defacto how it was before) and then 3

@mugling
Copy link
Contributor Author

mugling commented Jun 15, 2016

Flamethrower can't use napalm ammo, only gasoline.

Not sure why though. No obvious problems in vehicle::turret_reload

@Coolthulhu
Copy link
Contributor

  1. JSON limit (no guarantee of better balance)

I'd go with this one, it worked well before.

  1. Calculated based upon to-hit % (separate PR).

Balancing wouldn't be trivial (AoE ammo, burst fire), but later on it could use something like NPC range estimation.

@mugling
Copy link
Contributor Author

mugling commented Jun 15, 2016

I've gone with a hard-limit for now as every turret used 12 anyway.

@Coolthulhu
Copy link
Contributor

Coolthulhu commented Jun 15, 2016

More info about ammo types:
Removing the tank with the "preferred" ammo type allows using the other kind. For water cannon, dirty water is preferred. For flamethrower, it's gasoline.

EDIT: Found it - quantity of ammo isn't checked until it is set, after which the function returns.

@mugling
Copy link
Contributor Author

mugling commented Jun 15, 2016

Removing the tank with the "preferred" ammo type allows using the other kind. For water cannon, dirty water is preferred

Makes sense, need some system of specifying ammo preference

@Coolthulhu
Copy link
Contributor

Ammo preference should wait for another PR, for now just fixes should be enough.

@mugling
Copy link
Contributor Author

mugling commented Jun 15, 2016

@Coolthulhu see f644083

@Coolthulhu
Copy link
Contributor

Empty is a bit too lenient. Consider FIRE_100 weapons, like flamethrowers.

@mugling
Copy link
Contributor Author

mugling commented Jun 15, 2016

Empty is a bit too lenient. Consider FIRE_100 weapons, like flamethrowers.

True, see better fix in 83380a6

@Coolthulhu
Copy link
Contributor

Napalm tank is spelled "naplm"

@Coolthulhu Coolthulhu merged commit 9107bc7 into CleverRaven:master Jun 15, 2016
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.

3 participants