Author Topic: [Potential Bug?] reactionWeaponAction triggers on moving after shooting  (Read 2272 times)

Offline Buscher

  • Colonel
  • ****
  • Posts: 168
    • View Profile
In the mod I have a gun which simulates a way to call in an airstrike (battleType: 1, arcing, ... essentially a grenade launcher). Enemies shouldn't react on the action_unit.
So I wrote a script that looked exactly like in the first code block here

Spoiler:
Code: [Select]
items:
  - &STR_GUN
    type: STR_PISTOL # test item only # battleType: 1, not arcing

    scripts:
      reactionWeaponAction: |
        debug_log "====================";
        debug_log "reactionWeaponAction";
        debug_log "====================";
        debug_log "action_target" action_target;
        debug_log "action_unit" action_unit;
        debug_log "arc_to_action_unit" arc_to_action_unit;
        debug_log "battle_action" battle_action;
        debug_log "distance" distance;
        debug_log "move" move;
        debug_log "reaction_battle_action" reaction_battle_action;
        debug_log "reaction_chance" reaction_chance;
        debug_log "reaction_unit" reaction_unit;
        debug_log "reaction_weapon" reaction_weapon;
        debug_log "weapon" weapon;



        return 0;


Once the gun is fired, the reactionWeaponAction script continues running for battle_action == 0 (BA_NONE) && move == 0 (walking) || move == 1 (running, didn't test flying) as observed in the openxcom.log. This means that once the gun is fired, you can use up all your TUs for movement and not be fired at. Once you shoot another gun which isn't using this script, things work normal again. See the attachment for a mini mod and savegame to test with.

Knowing that I can solve the problems in the script (see below).
My question is: Is it intended that reactionWeaponAction continues to trigger on movement after the script was called the first time?
Thanks for looking at it.

Spoiler:
Code: [Select]
items:
  - &STR_GUN
    type: STR_PISTOL # test item only

    scripts:
      reactionWeaponAction: |
        # was return 0;


        if neq battle_action BA_NONE; # or compare to specific shooting related battle actions
          return 0;
        end;

        return reaction_chance;



Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9091
    • View Profile
Re: [Potential Bug?] reactionWeaponAction triggers on moving after shooting
« Reply #1 on: February 02, 2023, 03:43:40 pm »
My question is: Is it intended that reactionWeaponAction continues to trigger on movement after the script was called the first time?
Thanks for looking at it.

Don't know.
Need to wait for Yankes for this one.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: [Potential Bug?] reactionWeaponAction triggers on moving after shooting
« Reply #2 on: February 04, 2023, 01:11:21 am »
It look like bug, script on item should only affect when you use item, not when you move with this item, probably move action incorrectly store last used weapon