OpenXcom Forum
Modding => Work In Progress => Topic started by: yrizoud 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.
-
did you test an auto-only weapon as well?
-
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))))
-
Perhaps you would like something like this:
- 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 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.
reactionFiring: [STR_FULL_AUTO_SHOT, STR_SEMI_AUTO_SHOT, STR_AIMED_SHOT, STR_SNAP_SHOT]