Author Topic: [DONE][Suggestion] Hit side on weapon  (Read 2545 times)

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11454
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
[DONE][Suggestion] Hit side on weapon
« on: July 30, 2022, 01:17:19 pm »
When defining a environmental hazard in environmentalConditions, you can specify which side the effect hits (the "side" parameter). I would like to request a similar property directly on a weapon.

(It can probably be scripted, but there's like 10 people on Earth who can write scripts and they rarely overlap with modders.)
« Last Edit: August 11, 2022, 08:58:19 pm by Meridian »

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: [Suggestion] Hit side on weapon
« Reply #1 on: July 30, 2022, 05:21:33 pm »
Code: [Select]
items:
  - type: STR_ITEM_HITS_SPECIFIC_SIDE
    scripts:
      hitUnit:
        # set part BODYPART_TORSO; # optional but you may want to set what part it hits too, HEAD, TORSO, LEFTARM, RIGHTARM, LEFTLEG, RIGHTLEG
        set side SIDE_UNDER; # can be FRONT, LEFT, RIGHT, BACK, UNDER
        return power part side;

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8616
    • View Profile
Re: [Suggestion] Hit side on weapon
« Reply #2 on: July 30, 2022, 05:35:34 pm »
Thanks oharty.

To answer also the original request: it is very hard for us to add new non-script features to places where script support was already added. This has many different reasons; I will spare you the gruesome details. The bottomline is: in these cases, both Yankes and I (and others) will gladly help with writing a script; or even extend the scripting engine if a script cannot be written. Both of these options are much easier for us than trying to add a non-script feature and make it backwards-compatible with all the possible scripts that anyone may have written in the meantime.

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11454
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: [Suggestion] Hit side on weapon
« Reply #3 on: July 31, 2022, 01:17:07 pm »
Code: [Select]
items:
  - type: STR_ITEM_HITS_SPECIFIC_SIDE
    scripts:
      hitUnit:
        # set part BODYPART_TORSO; # optional but you may want to set what part it hits too, HEAD, TORSO, LEFTARM, RIGHTARM, LEFTLEG, RIGHTLEG
        set side SIDE_UNDER; # can be FRONT, LEFT, RIGHT, BACK, UNDER
        return power part side;

Thanks, much appreciated. I'll experiment.

I don't get this, though: other scripts I am using under hitUnit have their offset and start with something like "code: |". This one doesn't?

To answer also the original request: it is very hard for us to add new non-script features to places where script support was already added. This has many different reasons; I will spare you the gruesome details. The bottomline is: in these cases, both Yankes and I (and others) will gladly help with writing a script; or even extend the scripting engine if a script cannot be written. Both of these options are much easier for us than trying to add a non-script feature and make it backwards-compatible with all the possible scripts that anyone may have written in the meantime.

I totally understand, and wouldn't push anyway. I hope to not bother you with questions much. ;)
« Last Edit: July 31, 2022, 01:19:49 pm by Solarius Scorch »

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: [Suggestion] Hit side on weapon
« Reply #4 on: July 31, 2022, 09:10:00 pm »
I don't get this, though: other scripts I am using under hitUnit have their offset and start with something like "code: |". This one doesn't?

I attached this to the specific item definition ("items:") instead of making it a global script ("extended: scripts:") accessed by putting a tag on the item.

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11454
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: [Suggestion] Hit side on weapon
« Reply #5 on: August 02, 2022, 02:55:48 pm »
I attached this to the specific item definition ("items:") instead of making it a global script ("extended: scripts:") accessed by putting a tag on the item.

Thanks, a lot! Unfortunately I'm doing something wrong. I have no idea how to check which armour value was actually used, except checking which side is damaged on the unit stat screen. And going by that, the damage is being done not to the intended bottom armour, but by normal rules.

The idea is to give rats a special ability to always attack under armour (since their attack is pretty weak, and I want to give them some edge; bottom armour is usually the thinnest).

Here's the entire weapon entry:
Code: [Select]
  - type: STR_SHADOWBAT_WEAPON
    categories: [STR_BUILT_INS]
    weight: 0
    bigSprite: 595
    floorSprite: 31
    handSprite: 104
    meleeSound: 48
    meleeHitSound: 108
    clipSize: -1
    power: 15
    strengthApplied: false
    damageType: 7
    damageAlter:
      ArmorEffectiveness: 0.5
      ToTile: 0.33
    accuracyMelee: 120
    tuMelee: 20
    battleType: 3
    fixedWeapon: true
    invWidth: 2
    invHeight: 2
    recover: false
    flatRate: true
    scripts:
      hitUnit:
        set part BODYPART_HEAD;
        set side SIDE_UNDER;
        return power part side;

Help pls :)

Offline Yankes

  • Commander
  • *****
  • Posts: 3207
    • View Profile
Re: [Suggestion] Hit side on weapon
« Reply #6 on: August 02, 2022, 04:02:12 pm »
Ok, problem is that `hitUnit` is hook from unit perceptive not weapon.
This mean you need add global armor script and use tags in items.

I think I will simply fix it by adding new hook that is linked to weapon not armor,
as this use case repeat multiple times where you want specific behavior per weapon.

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11454
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: [Suggestion] Hit side on weapon
« Reply #7 on: August 02, 2022, 04:26:25 pm »
Many thanks, Yankes. Please keep us posted!

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: [Suggestion] Hit side on weapon
« Reply #8 on: August 02, 2022, 06:00:16 pm »
If you're going to have multiple weapons with this feature, I may have some time to write a global version.

Offline Yankes

  • Commander
  • *****
  • Posts: 3207
    • View Profile
Re: [Suggestion] Hit side on weapon
« Reply #9 on: August 03, 2022, 09:23:15 pm »
New hooks: `hitUnitAmmo` and `damageUnitAmmo`
Work exactly same as old ones but are defined on ammo (or weapon if it do not use ammo).

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11454
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: [Suggestion] Hit side on weapon
« Reply #10 on: August 04, 2022, 05:43:13 pm »
New hooks: `hitUnitAmmo` and `damageUnitAmmo`
Work exactly same as old ones but are defined on ammo (or weapon if it do not use ammo).

Cool, cool.

Will this work on melee weapons?

Offline Yankes

  • Commander
  • *****
  • Posts: 3207
    • View Profile
Re: [Suggestion] Hit side on weapon
« Reply #11 on: August 04, 2022, 06:21:15 pm »
Yes, as I said if weapon do not use ammo then weapon itself is checked for this hook.
Rule of thumb is "item that defined damage type that is used to damage unit".

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11454
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: [Suggestion] Hit side on weapon
« Reply #12 on: August 07, 2022, 12:47:01 pm »
Implemented the script, it works just fine.

Which means it's not only correct, but even suitable for morons. :P