OpenXcom Forum

Modding => OpenXcom Extended => Topic started by: Meridian on January 23, 2021, 03:26:41 pm

Title: [DONE][Suggestion] Battery-powered weapons
Post by: Meridian on January 23, 2021, 03:26:41 pm
Hey Yankee!

I told you something about weapons using different amount of ammo per shot years ago. You said it would be simple but then stopped because it will be hard to change it without something about default game.

So let me repeat what i want to have. Mostly for energy weapons which uses battery like magazines, a weapons should able to use different amount of ammo per shot. So for example you got a heavy laser and it has a low power shot and high power shot.. so high power shot would consumes "3" ammo rather then one. It makes this kind of weapons very special.



Code: [Select]
  - type: STR_LASGUN
    compatibleAmmo: [STR_LASGUN_CLIP]
      spendPerShot: 4        # 4x battery consumption for 2x power
      name: STR_BIG_BOOM
      name: STR_SMALL_BOOM
      BPL_AIMED_2X_POWER: 1  # custom script

I've been thinking about a similar option for the lasguns in the 40k mod - all of them should, for the most part, use the same power cell, but one of the more rare variants should use more energy charges per shot and do more damage.

One possible way of doing this would be to use a "onFiring" script that Yankes has been experimenting on. The weapon doesn't actually fire the ammo, but the loaded ammo is checked on firing with this script and consumed to give the shot more power. That way either certain shot types or different weapons could consume the energy cell faster or slower depending on how the script is written.

"onFiring" script is not easy, and not very well definable either.
I've added bullet consumption via ruleset; tested only on player-controlled units so far.

Help testing on AI would be appreciated.

The second part can be solved via standard "hitUnit" script.

Code: [Select]
# Battery Powered Lasgun script by Meridian
      BPL_AIMED_2X_POWER: int

      - offset: 0.1
        code: |
          var int temp;
          if eq battle_action battle_action_aimshoot;
            weapon_item.getTag temp Tag.BPL_AIMED_2X_POWER;
            if neq temp 0;
              # debug_log "hitUnit: yo, double up!";
              mul power 2;
          return power part side;

Full sample mod is attached.
Title: Re: [DONE][Suggestion] Battery-powered weapons
Post by: Meridian on January 23, 2021, 03:30:58 pm
OXCE test build:
Title: Re: [DONE][Suggestion] Battery-powered weapons
Post by: gaffer on January 25, 2021, 01:17:18 am
Keeping an eye on this.

Thanks Meridian.