OpenXcom Forum

Modding => Help => Topic started by: wcho035 on September 28, 2019, 06:53:22 am

Title: Possible to code a weapon hurting own player unit?
Post by: wcho035 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.
Title: Re: Possible to code a weapon hurting own player unit?
Post by: Nord on September 28, 2019, 09:12:38 am
Try this
   
Code: [Select]
costMelee:
     health: 100
Title: Re: Possible to code a weapon hurting own player unit?
Post by: wcho035 on September 28, 2019, 09:31:20 am
Thanks nord, I give it ago
Title: Re: Possible to code a weapon hurting own player unit?
Post by: ohartenstein23 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.
Title: Re: Possible to code a weapon hurting own player unit?
Post by: Solarius Scorch 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...
Title: Re: Possible to code a weapon hurting own player unit?
Post by: wcho035 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.
Title: Re: Possible to code a weapon hurting own player unit?
Post by: SuperCaffeineDude 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.)
Title: Re: Possible to code a weapon hurting own player unit?
Post by: wcho035 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..
Title: Re: Possible to code a weapon hurting own player unit?
Post by: The Martian 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.
Title: Re: Possible to code a weapon hurting own player unit?
Post by: wcho035 on October 08, 2019, 02:11:27 pm
It doesn't work. It was a good try though.