Author Topic: [DONE][Suggestion] Battery-powered weapons  (Read 813 times)

Offline Meridian

  • Global Moderator
  • Commander
  • ***
  • Posts: 6959
  • OXCE developer
    • View Profile
    • My Wiki
[DONE][Suggestion] Battery-powered weapons
« 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.

Added.

Example:

Code: [Select]
items:
  - type: STR_LASGUN
    compatibleAmmo: [STR_LASGUN_CLIP]
    confAimed:
      spendPerShot: 4        # 4x battery consumption for 2x power
      name: STR_BIG_BOOM
    confSnap:
      name: STR_SMALL_BOOM
    tags:
      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.
Example:

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

  scripts:
    hitUnit:
      - 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;
            end;
          end;
          return power part side;


Full sample mod is attached.
« Last Edit: January 23, 2021, 03:30:05 pm by Meridian »

Offline Meridian

  • Global Moderator
  • Commander
  • ***
  • Posts: 6959
  • OXCE developer
    • View Profile
    • My Wiki

Offline gaffer

  • Captain
  • ***
  • Posts: 59
    • View Profile
Re: [DONE][Suggestion] Battery-powered weapons
« Reply #2 on: January 25, 2021, 01:17:18 am »
Keeping an eye on this.

Thanks Meridian.