aliens

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

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8974
    • View Profile
[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: 8974
    • View Profile

Offline gaffer

  • Captain
  • ***
  • Posts: 60
    • 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.

Offline zee_ra

  • Colonel
  • ****
  • Posts: 213
    • View Profile
Re: [DONE][Suggestion] Battery-powered weapons
« Reply #3 on: December 04, 2023, 06:33:29 am »
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

"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.

@Meridian,

I would like to inquire, if scripts are fully interpreted?  Is it sufficient to simply insert script text somewhere under a specific YAML node path?

Offline zee_ra

  • Colonel
  • ****
  • Posts: 213
    • View Profile
Re: [DONE][Suggestion] Battery-powered weapons
« Reply #4 on: December 04, 2023, 06:51:20 am »
@Meridian,

Apparently, there's a small omission in documentation.  The spendPerShot property is not documented under the online nightly ruleset reference.

Offline zee_ra

  • Colonel
  • ****
  • Posts: 213
    • View Profile
Re: [DONE][Suggestion] Battery-powered weapons
« Reply #5 on: December 04, 2023, 06:11:58 pm »
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

"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.

Please allow me to consider another question.  What if I need to have a weapon that uses this type of battery munitions, but also confers a power bonus.  At the same time, I would like to have a weapon that also uses the same type of battery munitions, but without power bonus.  A use case may be a sniper rifle and a machine gun.  How could I encode this distinction in the weapon definitions?

Would it work, if I simply encode the powerBonus with a weapon itself, rather than munitions?

Also, is there a way to change completely the definition of a shot?  Could I use the same battery for laser and warp or EMP cannons?  How would it be best to approach this task?  Should I encode the damage types with the weapon itself through damageAlter?  What should I indicate in the battery definition?  Would it work if I set no damageType and power with battery, but would set those with a weapon?