Author Topic: Possible to code a weapon hurting own player unit?  (Read 2627 times)

wcho035

  • Guest
Possible to code a weapon hurting own player unit?
« on: September 28, 2019, 06:53:22 am »
Hi, I have experimented with the leeroyjenkin feature.  It need a melee weapon, however can there be a melee weapon to hurt a unit own health to turn it into a real suicide unit? The Cybermite from the xcomfiles does not have that capability.

Offline Nord

  • Commander
  • *****
  • Posts: 1637
  • The Gate is open.
    • View Profile
Re: Possible to code a weapon hurting own player unit?
« Reply #1 on: September 28, 2019, 09:12:38 am »
Try this
   
Code: [Select]
costMelee:
     health: 100

wcho035

  • Guest
Re: Possible to code a weapon hurting own player unit?
« Reply #2 on: September 28, 2019, 09:31:20 am »
Thanks nord, I give it ago

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: Possible to code a weapon hurting own player unit?
« Reply #3 on: September 28, 2019, 03:24:35 pm »
No, there isn't a way to directly have a unit kill itself when attacking in melee range. The health cost for attacks will just prevent attacking if HP is lower than cost. Scripts to hurt attacker when hitting just sets the attacker's HP to 1 at minimum. Finally, the AI doesn't like to attack if they are inside the radius of their own AoE weapon.

Closest you could probably do is have negative HP recovery on the unit's armor and a script that counteracts the HP loss until the unit hits in melee. Once they hit, set HP and TUs to 1 and set a tag on the unit to let the health degen kill it beginning of the next turn.

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11456
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Possible to code a weapon hurting own player unit?
« Reply #4 on: September 28, 2019, 05:23:14 pm »
Perhaps it's time to request suicide bombing as a full-fledged feature. It's a common thing in games, it makes sense, and it keeps being brought up by various people...

wcho035

  • Guest
Re: Possible to code a weapon hurting own player unit?
« Reply #5 on: September 28, 2019, 05:42:10 pm »
Oh thank you all for the kind contribution. I have not yet tested the code Nord had suggested cause I am at work. However, like mr ohartenstein23 had written, it’s not possible. I am sadden for not able to create a true suicide unit cause my head huggers are unstoppable. Should have been like the face huggers in aliens, 1 hugger for 1 soldier.

Solarius, thanks for the suggestion of  this need to be a requested feature. However, I have requested enough as it is.  With the random number generation for clone soldier’s stats still pending.. I will leave it to some else to do it.

Thank you all for the advice.

Offline SuperCaffeineDude

  • Colonel
  • ****
  • Posts: 107
    • View Profile
    • supercaffeinedude
Re: Possible to code a weapon hurting own player unit?
« Reply #6 on: September 29, 2019, 04:42:50 pm »
Perhaps it's time to request suicide bombing as a full-fledged feature. It's a common thing in games, it makes sense, and it keeps being brought up by various people...

I hadn't tried it yet, but it was something I had in mind to simulate a few transformations, like an egg/host shooting a blank that "kills" the egg/host and converts said unit to a hatchling, and a parasite burrowing into a target or latching on (half-life style) by killing the parasite and converting the target (zombie style). And aside from that, obviously, it'd be good to make suicide bombers (bloated-zombies, terrorists, etc.).

(Side-question: Can we change the type of explosion a unit like the cyberdisc creates? Like maybe a flamethrower armor explodes with fire, or an underwater monster sprays "bloody-viscera" smoke.)

wcho035

  • Guest
Re: Possible to code a weapon hurting own player unit?
« Reply #7 on: September 29, 2019, 05:07:22 pm »
Thanks nord, I give it ago

Hi Nord, after some consideration, I will test this advice of yours, but at a cost of 300 health.. let see how this go..

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: Possible to code a weapon hurting own player unit?
« Reply #8 on: October 08, 2019, 02:09:22 pm »
Finally, the AI doesn't like to attack if they are inside the radius of their own AoE weapon.
Vexing, that was going to be the implementation for suicide units I was setting up.

It is good to know though and explains some of the enemy behaviour I've been observing.

wcho035

  • Guest
Re: Possible to code a weapon hurting own player unit?
« Reply #9 on: October 08, 2019, 02:11:27 pm »
It doesn't work. It was a good try though.