OpenXcom Forum

Modding => OpenXcom Extended => OXCE Support => Topic started by: The Martian on September 08, 2019, 11:29:03 pm

Title: [Answered] (OXCE) Can I replace the melee attack with a ranged attack?
Post by: The Martian on September 08, 2019, 11:29:03 pm
I'm attempting to replace the weapon melee attack with a grenade launcher as shown in the "UFOpaedia Ruleset Reference Nightly (https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)#Compatible_ammo_and_Action_Mapping)" example.

The command to fire the Grenade appears at the top of the weapon action list in place of the melee attack as expected.

The weapon loads normal rifle clips and it will also load 1 grenade round in the inventory screen, however on the battlescape the icon for the rifle displays that it has 15 bullets and 0 grenades loaded.

Additionally when I attempt to fire it the message "There is no one there!" is displayed and the weapon does not fire.

Is there an additional step to override the melee slot?

Here is the code I'm using for the rifle:
Code: [Select]
  - type: STR_RIFLE_GRENADE_LAUNCHER
    size: 0.2
    costSell: 2250
    weight: 8
    bigSprite: 1
    floorSprite: 1
    handSprite: 0
    bulletSprite: 2
    fireSound: 76
#    compatibleAmmo:
#      - STR_RIFLE_CLIP
#      - STR_RIFLE_AA_CLIP
    ammo:
      0:
        compatibleAmmo: [ STR_RIFLE_CLIP, STR_RIFLE_AA_CLIP ]
        tuLoad: 5
        tuUnload: 2
      1:
        compatibleAmmo: [ STR_RIFLE_CLIP, STR_RIFLE_AA_CLIP ]
        tuLoad: 5
        tuUnload: 2
      2:
        compatibleAmmo: [ STR_RIFLE_CLIP, STR_RIFLE_AA_CLIP ]
        tuLoad: 5
        tuUnload: 2
      3:
        compatibleAmmo: [ STR_LAUNCHER_FRAG, STR_LAUNCHER_INC, STR_LAUNCHER_SMOKE, STR_LAUNCHER_ELERIUM ]
        tuLoad: 5
        tuUnload: 2
    accuracyAuto: 35
    accuracySnap: 60
    accuracyAimed: 110
    tuAuto: 35
    tuSnap: 25
    tuAimed: 70
    battleType: 1
    twoHanded: true
    invWidth: 1
    invHeight: 3
    attraction: 8
    tuMelee: 45
    accuracyMelee: 50
    listOrder: 2100
    confMelee:
      shots: 1
      name: STR_GRENADE_LAUNCHER_SHOT
      ammoSlot: 1
      arcing: true

Also on the inventory screen it does not display any indication that the weapon is loaded with a secondary ammo type. Only the normal rifle clip is displayed as loaded when I mouse over the rifle.
Title: Re: (OXCE) Using "Compatible ammo and Action Mapping" to replace the melee attack?
Post by: Meridian on September 08, 2019, 11:45:21 pm
"ammoSlot: 3" instead of "ammoSlot: 1" ?
Title: Re: (OXCE) Using "Compatible ammo and Action Mapping" to replace the melee attack?
Post by: The Martian on September 09, 2019, 12:01:11 am
I've changed confMelee: to ammoSlot: 3 however I'm still getting the "There is no one there!" message instead of the grenade firing.

On the plus side the secondary ammo counter is now displaying a 1 for the loaded grenade on the battlescape by the weapon icon.

Code: [Select]
  - type: STR_RIFLE_GRENADE_LAUNCHER
    size: 0.2
    costSell: 2250
    weight: 8
    bigSprite: 1
    floorSprite: 1
    handSprite: 0
    bulletSprite: 2
    fireSound: 76
#    compatibleAmmo:
#      - STR_RIFLE_CLIP
#      - STR_RIFLE_AA_CLIP
    ammo:
      0:
        compatibleAmmo: [ STR_RIFLE_CLIP, STR_RIFLE_AA_CLIP ]
        tuLoad: 5
        tuUnload: 2
      1:
        compatibleAmmo: [ STR_RIFLE_CLIP, STR_RIFLE_AA_CLIP ]
        tuLoad: 5
        tuUnload: 2
      2:
        compatibleAmmo: [ STR_RIFLE_CLIP, STR_RIFLE_AA_CLIP ]
        tuLoad: 5
        tuUnload: 2
      3:
        compatibleAmmo: [ STR_LAUNCHER_FRAG, STR_LAUNCHER_INC, STR_LAUNCHER_SMOKE, STR_LAUNCHER_ELERIUM ]
        tuLoad: 5
        tuUnload: 2
    accuracyAuto: 35
    accuracySnap: 60
    accuracyAimed: 110
    tuAuto: 35
    tuSnap: 25
    tuAimed: 70
    battleType: 1
    twoHanded: true
    invWidth: 1
    invHeight: 3
    attraction: 8
    tuMelee: 45
    accuracyMelee: 50
    listOrder: 2100
    confMelee:
      shots: 1
      name: STR_GRENADE_LAUNCHER_SHOT
      ammoSlot: 3
      arcing: true
Title: Re: (OXCE) Using "Compatible ammo and Action Mapping" to replace the melee attack?
Post by: The Martian on September 09, 2019, 12:42:13 am
It appears if I get the X-Com unit point blank with the enemy it can perform a melee attack using the "Launch Grenade" action... and this action consumes the grenade ammo, but still acts as a normal melee attack instead of an explosive.

So the melee action slot does seem to be assigned to the correct ammo now, it just isn't acting as a projectile.

Edit:
Aside from changing confMelee:'s ammoSlot: 1 to ammoSlot: 3 is there something else I can reconfigure?

I tried defining confAuto:, confSnap: & confAimed: just in case all four confAction: variables needed to be setup but the problem did not resolve.
Title: Re: (OXCE) Using "Compatible ammo and Action Mapping" to replace the melee attack?
Post by: Yankes on September 09, 2019, 01:12:31 am
right now each action is hardcore to its normal behavior, range is range and melee is melee, changing this will need lot of work because game depend on this atack types to change logic everywhere to match correct behavior
Title: Re: (OXCE) Using "Compatible ammo and Action Mapping" to replace the melee attack?
Post by: The Martian on September 09, 2019, 01:31:08 am
right now each action is hardcore to its normal behavior, range is range and melee is melee . . .

If that is the case please be aware that the tutorial found in the UFOpaedia (https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)#Compatible_ammo_and_Action_Mapping) is in error about being able to re-assign the melee action to a projectile.

Quote from: UFOpaedia
In OXCE, you can load multiple different types of ammo into one gun at the same time. This allows you to create, for example, a rifle with a built-in grenade launcher. There are up to 4 ammo slots, and they correspond to Aimed/Snap/Auto/Melee action... so you need to "sacrifice" one of the shot types to have a different ammo slot. Going back to the rifle with a grenade launcher example, you could have the rifle with Aimed/Snap/Auto and sacrifice the Melee action for implementing let's say a snap shot for the grenade launcher.
Code: [Select]
Example:

 - type: STR_WEAPON_WITH_4_AMMO_SLOTS
   ammo:
     0:
       compatibleAmmo: [ STR_AMMO_1, STR_AMMO_2 ]
       tuLoad: 5
       tuUnload: 2
     1:
       compatibleAmmo: [ STR_AMMO_3 ]
       tuLoad: 10
       tuUnload: 4
     2:
       compatibleAmmo: [ STR_AMMO_1, STR_AMMO_4 ]
       tuLoad: 10
       tuUnload: 4
     3:
       compatibleAmmo: [ STR_GRENADE ]
       tuLoad: 20
       tuUnload: 8

A mapping between actions and ammo slots (see above).

Example:
Code: [Select]
- type: STR_RIFLE_WITH_A_GRENADE_LAUNCHER
   confAimed:
     shots: 1
     name: STR_AIMED_SHOT
     ammoSlot: 0
     arcing: false
   confSnap:
     shots: 2
     name: STR_DOUBLE_SNAP_SHOT
     ammoSlot: 0
     arcing: false
   confAuto:
     shots: 10
     name: STR_CRAZY_AUTO_SHOT
     ammoSlot: 0
     arcing: false
   confMelee:
     shots: 1
     name: STR_LAUNCH_GRENADE
     ammoSlot: 3
     arcing: true






Title: Re: (OXCE) Using "Compatible ammo and Action Mapping" to replace the melee attack?
Post by: efrenespartano on September 09, 2019, 02:19:34 am
I had this exact issue with a M16/M03 rifle with GL, so I just change it to Aimed shot.

But... How about adding the Melee attack some range? Is it possible to have a ranged melee attack?

Enviado desde mi LG-M400 mediante Tapatalk

Title: Re: (OXCE) Using "Compatible ammo and Action Mapping" to replace the melee attack?
Post by: Meridian on September 09, 2019, 10:07:03 am
If that is the case please be aware that the tutorial found in the UFOpaedia (https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)#Compatible_ammo_and_Action_Mapping) is in error about being able to re-assign the melee action to a projectile.

Description updated.
Title: Re: (OXCE) Using "Compatible ammo and Action Mapping" to replace the melee attack?
Post by: wcho035 on September 09, 2019, 01:20:41 pm
Will this multiple ammo setup work on HWP?
Title: Re: (OXCE) Using "Compatible ammo and Action Mapping" to replace the melee attack?
Post by: Meridian on September 09, 2019, 02:54:58 pm
Will this multiple ammo setup work on HWP?

Don't know.
Most likely not.
Title: Re: (OXCE) Using "Compatible ammo and Action Mapping" to replace the melee attack?
Post by: Yankes on September 09, 2019, 08:42:16 pm
If that is the case please be aware that the tutorial found in the UFOpaedia (https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)#Compatible_ammo_and_Action_Mapping) is in error about being able to re-assign the melee action to a projectile.
I probably mess up my future plans with current implementation. I will fix description today.
Title: Re: (OXCE) Using "Compatible ammo and Action Mapping" to replace the melee attack?
Post by: wcho035 on September 10, 2019, 02:58:35 pm
Hi, I am experimenting with this like the others. So I have one of my weapon coding here. It is not working as plan, perhaps someone can correct me?

 - type: STR_FLINTLOCK
    size: 0.1
    costBuy: 200
    costSell: 150
    weight: 5
    bigSprite: 817
    floorSprite: 678
    handSprite: 995
    bulletSprite: 1
    fireSound: 4
#    compatibleAmmo:
#      - STR_SINGLESHOTCART
#    accuracySnap: 50
#    accuracyAimed: 70
#    tuSnap: 35
#    tuAimed: 45
    battleType: 1
    invWidth: 1
    invHeight: 2
    maxRange: 12
    ammo:
      0:
        compatibleAmmo: [ STR_SINGLESHOTCART ]
        tuLoad: 5
        tuUnload: 2
      1:
        compatibleAmmo: [ STR_GRENADE ]
        tuLoad: 10
        tuUnload: 4
    confAimed:
      shots: 1
      name: STR_AIMED_SHOT
      ammoSlot: 0
      arcing: false
      accuracyAimed: 70
      tuAimed: 45
    confAimed:
      shots: 1
      name: STR_GRENADE_SHOT
      ammoSlot: 1
      arcing: true
      accuracyAimed: 70
      tuAimed: 45
Title: Re: (OXCE) Using "Compatible ammo and Action Mapping" to replace the melee attack?
Post by: Meridian on September 10, 2019, 03:18:15 pm
Can't have confAimed twice.

Use ruleset validator for basic syntax validation.
Title: Re: (OXCE) Using "Compatible ammo and Action Mapping" to replace the melee attack?
Post by: wcho035 on September 10, 2019, 03:26:37 pm
  - type: STR_FLINTLOCK
    size: 0.1
    costBuy: 200
    costSell: 150
    weight: 5
    bigSprite: 817
    floorSprite: 678
    handSprite: 995
    bulletSprite: 1
    fireSound: 4
#    compatibleAmmo:
#      - STR_SINGLESHOTCART
    accuracySnap: 50
    accuracyAimed: 70
    tuSnap: 35
    tuAimed: 45
    battleType: 1
    invWidth: 1
    invHeight: 2
    maxRange: 12
    ammo:
      0:
        compatibleAmmo: [ STR_SINGLESHOTCART ]
        tuLoad: 5
        tuUnload: 2
      1:
        compatibleAmmo: [ STR_GRENADE ]
        tuLoad: 10
        tuUnload: 4
    confAimed:
      shots: 1
      name: STR_GRENADE_SHOT
      ammoSlot: 1
      arcing: true   

I have updated the code, but no grenade ammo showing.
Title: Re: (OXCE) Using "Compatible ammo and Action Mapping" to replace the melee attack?
Post by: wcho035 on September 10, 2019, 03:32:00 pm
I got it, you can't use normal grenade as an ammo. Has to be an assigned ammo type. Damned. I was hoping to put less ammo type in my game.
Title: Re: (OXCE) Using "Compatible ammo and Action Mapping" to replace the melee attack?
Post by: wcho035 on September 10, 2019, 03:37:50 pm
This code doesn't work properly on tanks. Only the first weapon is loaded, the second is not.
Title: Re: (OXCE) Using Compatible ammo and Action Mapping to replace the melee attack?
Post by: The Martian on September 10, 2019, 10:52:20 pm
Thank you for updating the UFOpaedia Ruleset Reference (https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)). ^_^
I had this exact issue with a M16/M03 rifle with GL, so I just change it to Aimed shot.
I followed your advice and assigned "Aimed Shot" to launch the grenade and renamed "Snap Shot" to "Aimed Shot".

The reason for renaming the "Snap Shot" is that even though it is now has the appearance of "Aimed Shot" it will still trigger reaction fire.

These confAction: commands are pretty fun to mess about with so far.
Title: Re: (OXCE) Using "Compatible ammo and Action Mapping" to replace the melee attack?
Post by: Nord on September 11, 2019, 12:50:02 pm
Also multi-ammunitions does'nt shows in ufopedia.