aliens

Author Topic: Reaction fire and shooting modes  (Read 4092 times)

Offline yrizoud

  • Commander
  • *****
  • Posts: 1014
    • View Profile
Reaction fire and shooting modes
« on: December 11, 2013, 03:28:10 am »
According to Ufopaedia, in vanilla UFO Reaction fire (for the player side) only takes Snap shots. I think OpenXCom also picks auto fire, but I'm not sure.
I tested a custom weapon that only provides "aimed shot", and indeed, reaction fire doesn't happen at all. As a result,  I'd have two pieces of advice for weapon modders out there :

1) If you make a weapon with only one shooting mode (and not auto), make it a "snap" mode or it will not work for reaction fire.

2) If you make a sniper weapon, don't balance the snap shot for "reflex shooting when you bump on a sectoid". If you do, your camping snipers who catch sight of an alien at extreme range will empty their clip and miss, instead of shooting the single bullet that you'd expect - and hit.

Offline Arpia

  • Colonel
  • ****
  • Posts: 116
    • View Profile
Re: Reaction fire and shooting modes
« Reply #1 on: December 11, 2013, 07:03:47 am »
did you test an auto-only weapon as well?

Offline yrizoud

  • Commander
  • *****
  • Posts: 1014
    • View Profile
Re: Reaction fire and shooting modes
« Reply #2 on: December 11, 2013, 11:59:09 am »
I just checked in the source code directly, it's in TileEngine.cpp :
TileEngine::checkReactionFire() calls TileEngine::tryReactionSnap() :
   https:// reaction fire is ALWAYS snap shot.
   action.type = BA_SNAPSHOT;
   https:// unless we're a melee unit.
   if (action.weapon->getRules()->getBattleType() == BT_MELEE)
   {
      action.type = BA_HIT;
   }


edit: also calls TileEngine::canMakeSnap() to eliminate units whose weapon has "0" TU for snap shot:
      https:// has a gun capable of snap shot with ammo
      (weapon->getRules()->getBattleType() != BT_MELEE &&
      weapon->getRules()->getTUSnap() && https:// <--- implicit : different from zero
      weapon->getAmmoItem() &&
      unit->getTimeUnits() > unit->getActionTUs(BA_SNAPSHOT, weapon))))


« Last Edit: December 11, 2013, 12:08:46 pm by yrizoud »

Offline atlimit8

  • Squaddie
  • *
  • Posts: 9
    • View Profile
reaction fire priority in ruleset
« Reply #3 on: December 23, 2013, 10:16:45 am »
Perhaps you would like something like this:


Code: [Select]
  - type: STR_SNIPER_RIFLE
    size: ?
    costBuy: ?
    costSell:
    weight: ?
    bigSprite: ?
    floorSprite: ?
    handSprite: ?
    bulletSprite: ?
    fireSound: 4
    compatibleAmmo:
      - STR_SNIPER_RIFLE_CLIP
    accuracyAuto: ?
    accuracySnap:
    accuracyAimed: ?
    tuAuto: ?
    tuSnap: ?
    tuAimed: ?
    battleType: 1
    twoHanded: true
    invWidth: 1
    invHeight: 3
    reactionFiring: [STR_AIMED_SHOT, STR_AUTO_SHOT, STR_SNAP_SHOT]

where
Code: [Select]
reactionFiring: [STR_AIMED_SHOT, STR_AUTO_SHOT, STR_SNAP_SHOT] is used to order the reaction fire options.

The code should check each action in order seeing if there are enough TUs and ammo, then check actions short on ammo but not TUs in the same order.
This would cause the effective order to be aimed, snap, then auto if auto is short on ammo, which makes auto less likely to hit.

This could also be hard-coded, but would have to be replaced if custom actions for individual items can be added in the future.
For example:
   A future machine gun mod may have snap, aimed, semi-auto, and full-auto actions.
 
Code: [Select]
reactionFiring: [STR_FULL_AUTO_SHOT, STR_SEMI_AUTO_SHOT, STR_AIMED_SHOT, STR_SNAP_SHOT]