Author Topic: [Solved] Spawning a unit with builtInWeaponSets: that has a grenade?  (Read 2120 times)

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
(Goal)
When a unit dies via damage caused by either enviroEffects: or negative health regen on its armor that unit will not trigger the specab: 1 effect on death and explode.

If I understand correctly this occurs because the unit is not dying during a turn but instead between turns.

This got me thinking that maybe a makeshift solution could be created using a pre-primed grenade.

Fortunately Greenscarf has posted a script that does just that: (Thank you for sharing your script Greenscarf!)
[Documentation][y-script] OXCE Script examples.

(Problem)
I've run into a snag, for some reason I cannot spawn a unit with a grenade using the units: builtInWeaponSets: list.

Code: [Select]
    builtInWeaponSets:
      - - STR_MAGNA_BLAST_GRENADE


If someone could take a quick look at my code in the mod attached to this post and see if they can spot the problem I would appreciate it. (TestMod.zip)

The small example mod is composed of:
- Greenscarf's scripts that auto-prime the grenade.
- A test unit that will die via decaying health on its armor.
- A test weapon to spawn the enemy unit quickly where it can easily be observed.

« Last Edit: February 12, 2023, 03:04:49 pm by Meridian »

Offline Buscher

  • Colonel
  • ****
  • Posts: 168
    • View Profile
Re: Spawning a unit with builtInWeaponSets: that has a grenade?
« Reply #1 on: September 12, 2021, 02:29:47 pm »
You need to set allowInv: true in your test armor.

For next time it would be helpful if you provided an alienRace list
Spoiler:
alienRaces:
  - id: STR_AQUATOID_TEST
    members:
      - STR_AQUATOID_COMMANDER
      - STR_AQUATOID_NAVIGATOR
      - STR_AQUATOID_MEDIC
      - STR_AQUATOID_TECHNICIAN
      - STR_AQUATOID_SQUAD_LEADER
      - TEST_UNIT_UNIT
      - STR_CALCINITE_TERRORIST
      - STR_CALCINITE_TERRORIST
  - id: STR_AQUATOID_TEST_UNDERWATER
    members:
      - STR_AQUATOID_COMMANDER
      - STR_AQUATOID_NAVIGATOR
      - STR_AQUATOID_MEDIC
      - STR_AQUATOID_TECHNICIAN
      - STR_AQUATOID_SQUAD_LEADER
      - TEST_UNIT_UNIT
      - STR_HALLUCINOID_TERRORIST
      - STR_HALLUCINOID_TERRORIST

Also if you are interested you can take a look at the Penetante in ROSIGMA. They got explosive collars which they can activate at their own volition
Items
Script
Armor
Unit

No idea if this kind of linking works with Discord but in theory you can watch a video here

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: Spawning a unit with builtInWeaponSets: that has a grenade?
« Reply #2 on: September 19, 2021, 03:58:26 pm »
(Please excuse my late reply)

You need to set allowInv: true in your test armor.

Thank you that fixed it!


Also if you are interested you can take a look at the Penetante in ROSIGMA. They got explosive collars which they can activate at their own volition
Items
Script
Armor
Unit

I've been playing around with your script for triggering grenades via a melee strike.

It's a lot of fun thank you for sharing it.


For next time it would be helpful if you provided an alienRace list
Spoiler:
alienRaces:
  - id: STR_AQUATOID_TEST
    members:
      - STR_AQUATOID_COMMANDER
      - STR_AQUATOID_NAVIGATOR
      - STR_AQUATOID_MEDIC
      - STR_AQUATOID_TECHNICIAN
      - STR_AQUATOID_SQUAD_LEADER
      - TEST_UNIT_UNIT
      - STR_CALCINITE_TERRORIST
      - STR_CALCINITE_TERRORIST
  - id: STR_AQUATOID_TEST_UNDERWATER
    members:
      - STR_AQUATOID_COMMANDER
      - STR_AQUATOID_NAVIGATOR
      - STR_AQUATOID_MEDIC
      - STR_AQUATOID_TECHNICIAN
      - STR_AQUATOID_SQUAD_LEADER
      - TEST_UNIT_UNIT
      - STR_HALLUCINOID_TERRORIST
      - STR_HALLUCINOID_TERRORIST

Sorry about that.

I'm just starting to try out working with alienDeployments: and hadn't read the Ruleset Reference (Nightly) as far as alienRaces: hence the item to spawn the unit for testing instead of a proper deployment.


No idea if this kind of linking works with Discord but in theory you can watch a video here

The linking seems to have worked fine and the video was helpful.

Spoiler:
Code: [Select]
Items:

  - type: STR_EXPLOSIVE_COLLAR_DUMMY
    specialUseEmptyHand: true
    fixedWeapon: true
    recover: false
    meleeSound: 2140
    meleeHitSound: { mod: 40k, index: 0 }
    power: 200 # for the AI to pick this
    meleeAnimation: { mod: 40k, index: 0 }
    damageType: 7
    accuracyMelee: 200
    tuMelee: 1
    clipSize: -1
    battleType: 3
    meleeMultiplier:
      melee: 0.0
      flatHundred: 1.0
    flatRate: true
    tags:
      ITEM_IS_FOR_BOMBER: 1

  - type: STR_EXPLOSIVE_COLLAR_CHAOS #frag                #4006
    bulletSprite: {mod: 40k, index: 22}
    fireSound: {mod: 40k, index: 491}
    bigSprite: {mod: 40k, index: 19}
    floorSprite: {mod: 40k, index: 19}
    handSprite: {mod: 40k, index: 336}
    power: 100
    blastRadius: 5
    damageType: 3
    battleType: 4 # grenade
    recover: false
    tuPrime: 999
    fixedWeapon: true
    isExplodingInHands: true
    hiddenOnMinimap: true
    defaultInventorySlot: STR_BELT
    tags:
      ITEM_IS_BOMB: 1
Code: [Select]
extended:
  tags:
    RuleItem:
      ITEM_IS_FOR_BOMBER: int
      ITEM_IS_BOMB: int

  scripts:
    hitUnit:
      - offset: 43
        code: |
          var ptr RuleItem ruleItem;
          var int temp;
          var ptre BattleItem someItem;
          var int numInventoryItems;

          damaging_item.getRuleItem ruleItem;
          ruleItem.getTag temp Tag.ITEM_IS_FOR_BOMBER;

          if eq temp 1;
            attacker.getInventoryItem.size numInventoryItems;
            # debug_log "numInventoryItems" numInventoryItems;
            loop var i numInventoryItems;
              attacker.getInventoryItem someItem i;
              someItem.getTag temp Tag.ITEM_IS_BOMB;
              # attacker.setTag Tag.UNIT_TURNED_TRAITOR 1; # doesn't recolor fast enough
              if eq temp 1;
                attacker.setTimeUnits 0;
                someItem.setFuseTimer 0;
                someItem.setFuseEnabled 1;
                return 0 part side;
              end;
            end;
          end;

          return power part side;
Code: [Select]
  - type: STR_CHAOS_PENETANTE_ARMOR
    visibilityAtDay: 30
    visibilityAtDark: 20
    spriteSheet: CHAOS_PENETANTE.PCK
    spriteInv: CHAOS_PENETANTE_0M0
    corpseBattle:
      - STR_CHAOS_PENETANTE_CORPSE
    frontArmor: 20 #armor stuffed to survive to reach the enemy for detonation
    sideArmor: 10
    rearArmor: 0
    underArmor: 10
    drawingRoutine: 0
    damageModifier: #Penetante
      - 1.0 #none
      - 1.1 #AP
      - 1.1 #FLAMES
      - 1.1 #HE
      - 1.1 #LASCANON
      - 1.1 #PLASMA
      - 1.0 #STUN
      - 1.2 #MELEE
      - 1.2 #ACID
      - 0.0 #SMOKE
      - 1.0 #IMPACT
      - 1.1 #MELTA
    loftempsSet: [ 3 ]
    specialWeapon: STR_EXPLOSIVE_COLLAR_DUMMY
Code: [Select]
    armor: STR_CHAOS_PENETANTE_ARMOR
    standHeight: 20
    kneelHeight: 14
    moraleLossWhenKilled: 10
    aggression: 6
    value: 1
    specab: 1 #explodes on death
    energyRecovery: 40
    moveSound: -1
    deathSound: [41, 42, 43]
    livingWeapon: true
    builtInWeaponSets:
      - - STR_KNIF
        - STR_GRENADE
        - STR_EXPLOSIVE_COLLAR_CHAOS
      - - STR_STUB_GUN_CHAOS
        - STR_STUB_GUN_AMMO
        - STR_GRENADE
        - STR_EXPLOSIVE_COLLAR_CHAOS
      - - STR_STUB_GUN_CHAOS
        - STR_STUB_GUN_AMMO
        - STR_GRENADE
        - STR_EXPLOSIVE_COLLAR_CHAOS