Author Topic: [Solved] Number of shots per attack action  (Read 4261 times)

Offline Searmay

  • Sergeant
  • **
  • Posts: 35
    • View Profile
[Solved] Number of shots per attack action
« on: December 21, 2017, 05:42:24 pm »
TFTD style UFOpaedia articles (type_id 14) do not correctly report the number of auto shots made. UFO articles (type_id 4) do, so I presume it wasn't updated when this was made configurable.

The offending code is src/Ufopaedia/ArticleStateTFTDItem.cpp line 78, which should be:
Code: [Select]
tr("STR_SHOT_TYPE_AUTO").arg(item->getConfigAuto()->shots).c_str(),

And while we're there, the UFO version changed the code for snap and aimed shots too, so lines 93 and 108 should change similarly:
Code: [Select]
tr("STR_SHOT_TYPE_SNAP").arg(item->getConfigSnap()->shots).c_str(),
Code: [Select]
tr("STR_SHOT_TYPE_AIMED").arg(item->getConfigAimed()->shots).c_str(),

Related to this: the number of snap and aimed shots aren't actually configurable, though they almost are. It looks like it doesn't bother to read aimedshots and snapShots, but it would use them if it could. Can be fixed in src/Mod/RueItem.cpp by adding around the similar code for autoShots on line 588:
Code: [Select]
_confAimed.shots = node["aimedShots"].as<int>(_confAimed.shots);
_confSnap.shots = node["snapShots"].as<int>(_confSnap.shots);

Apologies if this isn't sufficiently clear, I'm not really used to bug reporting.
« Last Edit: February 11, 2023, 04:29:24 pm by Meridian »

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3349
    • View Profile
Re: Ufopaedia bug and feature request with fix
« Reply #1 on: December 21, 2017, 06:13:23 pm »

Offline Searmay

  • Sergeant
  • **
  • Posts: 35
    • View Profile
Re: Ufopaedia bug and feature request with fix
« Reply #2 on: December 21, 2017, 06:30:03 pm »
It doesn't actually work without the extra lines indicated though. I don't pretend to understand the code, but I've recompiled it and I get multiple snap shots with that line, but not without it.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3349
    • View Profile
Re: Ufopaedia bug and feature request with fix
« Reply #3 on: December 21, 2017, 07:02:51 pm »
For what ruleset? What you add to `load` function is not correct place to do this. Do you see that line I reference is outside `load` and in `loadConfAction`?
I have one line that look like lines you added:
https://github.com/Yankes/OpenXcom/blob/master/src/Mod/RuleItem.cpp#L579
but reason that is exists is completely different, not to load number of shoot but for backward compatibility.

correct way to load this is in this line:
https://github.com/Yankes/OpenXcom/blob/master/src/Mod/RuleItem.cpp#L501
that call this line:
https://github.com/Yankes/OpenXcom/blob/master/src/Mod/RuleItem.cpp#L227

For ufopeadia change,  indeed, TFTD article do not show number of hits. Meridian could use you change.

Offline Searmay

  • Sergeant
  • **
  • Posts: 35
    • View Profile
Re: Ufopaedia bug and feature request with fix
« Reply #4 on: December 21, 2017, 07:33:21 pm »
I tested it with a simple mod and got nothing.
Code: [Select]
items:
  - type: STR_RIFLE
    snapShots: 2
When I load up a test battle with a rifle and fire a snap shot with just that mod enabled, I get one shot.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3349
    • View Profile
Re: Ufopaedia bug and feature request with fix
« Reply #5 on: December 22, 2017, 01:09:47 am »
I tested it with a simple mod and got nothing.
Code: [Select]
items:
  - type: STR_RIFLE
    snapShots: 2
When I load up a test battle with a rifle and fire a snap shot with just that mod enabled, I get one shot.
yup, because this ruleset is incorrect. This is way work for you and not work in OXCE. Correct is:
Code: [Select]
items:
  - type: STR_RIFLE
    confSnap:
      shots: 4
    confAuto:
      shots: 8
You can see this examples https://openxcom.org/forum/index.php?action=dlattach;topic=2915.0;attach=35504

Offline Searmay

  • Sergeant
  • **
  • Posts: 35
    • View Profile
Re: Ufopaedia bug and feature request with fix
« Reply #6 on: December 22, 2017, 08:20:04 pm »
Oh I see, thanks. Does that format let you define everything about the shot (tu, accuracy, etc) to keep it all together?

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3349
    • View Profile
Re: Ufopaedia bug and feature request with fix
« Reply #7 on: December 23, 2017, 01:01:00 am »
Yes, in future I plan add more properties to configure and with that I will need change only one line not 4 or more to add something to all attack types.