reduce HP method in Unit class?

Everything about mods can be found here.

Moderator: Morax

reduce HP method in Unit class?

Postby Lionhardt » 24 Jul 2015, 01:31

I had a look at the script that is used in Cluster Freak. Apparently the unit class has a method Destroy(). Call looks like this
Code: Select all
unit:Destroy()
. Is there also a method to deal x amount of damage to a unit? x being ether a percentage or a absolute hp value. I guess there is not... but would be great. Because I'd like to modify that script for my own purposes.
Help me make better maps for all of us, visit my Mapping Thread.

Maps needing gameplay feedback:
Spoiler: show
[list updated last: 31.1.2018]

(maps available in the vault)

- Hexagonian Drylands
- Fervent Soil and Torrid Suns

YouTube Channel
User avatar
Lionhardt
Contributor
 
Posts: 1070
Joined: 29 Jan 2013, 23:44
Has liked: 188 times
Been liked: 144 times
FAF User Name: Lionhardt

Re: reduce HP method in Unit class?

Postby Turkey » 24 Jul 2015, 03:37

Code: Select all
unit:SetHealth(instigator, health)

Instigator is a reference to the entity that is making the health modification, can be the unit itself. Health is the value to set the health to.
A unit halving its own health then might be

Code: Select all
local fraction = 0.5
unit:SetHealth(unit, unit:GetHealth() * fraction)

This is a good reference: http://supcom.wikia.com/wiki/LUADOC_1.5.3599
Turkey
Crusader
 
Posts: 26
Joined: 08 Feb 2015, 01:01
Has liked: 2 times
Been liked: 2 times
FAF User Name: Turkey

Re: reduce HP method in Unit class?

Postby Lionhardt » 24 Jul 2015, 08:12

Thanks a lot.
Help me make better maps for all of us, visit my Mapping Thread.

Maps needing gameplay feedback:
Spoiler: show
[list updated last: 31.1.2018]

(maps available in the vault)

- Hexagonian Drylands
- Fervent Soil and Torrid Suns

YouTube Channel
User avatar
Lionhardt
Contributor
 
Posts: 1070
Joined: 29 Jan 2013, 23:44
Has liked: 188 times
Been liked: 144 times
FAF User Name: Lionhardt


Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest