Since lobstermen can melee attack without a weapon and psionic aliens can still spam you when unarmed, I decided it was time for the player to get some special weapons! The new code I'm documenting here allows the player to access an armor's specialWeapon, a unit’s meleeWeapon, or a unit’s psiWeapon.
Note: This requires an OXCE+ version published on or after 8 May 2018, otherwise the mods won't do anything.
There are two ways of accomplishing this with the following ruleset parameters:
- specialIconSprite: -1 # defines an image from SPICONS.DAT for an item to use instead of the 'psi’ button that appears when using a MC’d psionic alien, default -1 means no icon
- specialUseEmptyHand: false # true here allows this item to be accessed by clicking on a unit's empty hand when used as a special weapon, default is false
If an item is defined as an armor's specialWeapon, a unit's meleeWeapon or psiWeapon, and has either a special icon sprite or can be used in an empty hand, then you'll be able to use it! There's the further limitation that the item’s battleType must be a firearm, melee weapon, medi-kit, motion scanner, psi-amp, or mind probe; no grenades, no flares, no ammo, and no corpses are allowed to be used as a special weapon. If the item has a special icon, then it'll appear where the 'psi' button usually does, and can be accessed by clicking on that icon or pressing a hotkey for it, default 'Y'. If the weapon can be used from an empty hand, just click/press the hotkey for that hand slot when nothing's there. Both types support middle-clicking to bring up the ufopaedia article for the item if it's been researched, and the empty hand further supports pressing CTRL+M to bring up the preview for melee attack power. If for some reason you have multiple items that are competing for one of these two access methods, the one displayed will be the first available from this list, in order: melee, psi-amps, firearms, medi-kits, motion scanners, and finally mind probes.
As for item behavior, using either of the buttons will bring up an action menu just the same as any other weapon, though firing animations won't use the item’s handSprite. The AI already knows how to use melee weapons and psi attacks like this; the code adds use of projectile weapons, but only if the AI unit has no other weapon. Player units can react with projectile special weapons but only if they have no other weapon in their hands.
If all of that was confusing, here are two example use cases that will hopefully make it clearer. The first is simply giving X-Com agents the ability to punch with empty hands:
items:
# this item is what is used for the attack
- type: STR_UNARMED_MELEE
specialUseEmptyHand: true
# the rest of the item definition procedes as usual, see the attached mod for more
# now, add the attack to X-Com armors
armors:
- type: STR_NONE_UC
specialWeapon: STR_UNARMED_MELEE
# the mod attached below does this for personal and power armor too
With this mod, all you have to do is click a soldier's empty hand and start punching away!
The second example puts a built-in gauntlet with a laser equivalent to the laser pistol on the power suit and flying suit:
items:
- type: STR_UNARMED_POWER
specialIconSprite: 3
specialUseEmptyHand: true
# the rest of the item definition is found in the mod attached below
armors:
- type: STR_POWER_SUIT_UC
specialWeapon: STR_UNARMED_POWER
- type: STR_FLYING_SUIT_UC
specialWeapon: STR_UNARMED_POWER
extraSprites: # get a new image for the icon
- type: SPICONS.DAT
width: 32
height: 24
files:
2: Resources/spicon_brawl.png # 0 is used for the launch blaster bomb button, 1 for alien psi
files:
3: Resources/spicon_laserpistol.png
Both examples are contained in the mod attached below.