aliens

Author Topic: [DONE][Suggestion] spawnItemChance split between ranged and melee  (Read 627 times)

Offline Darox

  • Squaddie
  • *
  • Posts: 8
    • View Profile
I wanted to create a combat knife that a soldier could use to melee or throw at enemies, with the ability to recover it from enemies after throwing. Giving it 1 ammo and using spawnItem to create a copy of the item on impact worked exactly as I wanted, right up until I tested the melee attack and realized that every melee hit also spawned a new knife. This behavior would also stop someone from adding any kind of 'gun bash' melee attack to a flare launcher or similar.

My suggestion is a meleeSpawnItemChance which defaults to -1 aka "use spawnItemChance value" but if set to 0-100 overwrites spawnItemChance when using melee attacks.

Code: [Select]
  - type: STR_COMBAT_KNIFE
[...]
    spawnItem: STR_COMBAT_KNIFE
    spawnItemChance: 100
    meleeSpawnItemChance: 0
[...]

Online Yankes

  • Commander
  • Global Moderator
  • Commander
  • *****
  • Posts: 3475
  • Posts: 421
    • View Profile
Re: [Suggestion] spawnItemChance split between ranged and melee
« Reply #1 on: March 14, 2025, 10:59:34 am »
Doable

Online Yankes

  • Commander
  • Global Moderator
  • Commander
  • *****
  • Posts: 3475
  • Posts: 421
    • View Profile
Re: [Suggestion] spawnItemChance split between ranged and melee
« Reply #2 on: March 22, 2025, 05:00:38 pm »
Done in OXCE 8.1.4
https://github.com/MeridianOXC/OpenXcom/commit/449c0a89f2429539edd4876a302a8a5579eb8a1e

Code: [Select]
items:
  - type: STR_PISTOL
    confAimed:
      ammoSpawnItemChanceOverride: 0
    confSnap:
      ammoSpawnItemChanceOverride: 100
  - update: STR_PISTOL_CLIP
    spawnItem: STR_ELECTRO_FLARE
Each action type have its own override (melee too), it work with spawn units, items and zombifcation.
« Last Edit: March 22, 2025, 05:19:19 pm by Yankes »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9511
    • View Profile
Re: [DONE][Suggestion] spawnItemChance split between ranged and melee
« Reply #3 on: March 23, 2025, 11:13:35 am »
All 3 attribute names:

Code: [Select]
items:
  - type: STR_PISTOL
    confAimed:
      ammoZombieUnitChanceOverride: 10
      ammoSpawnUnitChanceOverride: 20
      ammoSpawnItemChanceOverride: 30

Offline Darox

  • Squaddie
  • *
  • Posts: 8
    • View Profile
Re: [DONE][Suggestion] spawnItemChance split between ranged and melee
« Reply #4 on: March 23, 2025, 11:16:31 am »
Excellent, thanks a lot.