Page 1 of 1

Invulnerable units

Posted: 06 May 2012, 16:46
by gajop
Is it possible to set a flag for a specific player unit (not UnitDef nor feature), that would mark that unit invulnerable - i.e. completely immune to any kind of damage or negative effect, targeted or otherwise.
Again, much like the 'infinite resource' request, this would allow for unit AI to avoid shooting as such units, and it's much easier to work with other negative effects (such as slow), rather than having to do your own custom checks.
An example of how it would be set is

Code: Select all

Spring.SetUnitInvulnerable(number unitId, boolean invulnerable)
Rationale: It would be useful in custom games - you don't want the player to be able to attack certain structures, or you want to force the player to kill stuff in the right order. It may also be useful in skirmish games if you can imagine creating some sort of missiles/turrets/bombs that can only be hit at certain times, or "event units" such as bombers that you don't want people to be able to shoot down f.e, or just not at all times.

Re: Invulnerable units

Posted: 06 May 2012, 16:50
by FLOZi
Can be done per unitID with UnitPreDamaged callin, you'd have to inform the AI via some other means though.

Re: Invulnerable units

Posted: 06 May 2012, 16:55
by zwzsg
Have UnitPreDamaged() or UnitDamaged() return 0 for the units you want to be invulnerable.

Re: Invulnerable units

Posted: 07 May 2012, 09:04
by Niobium
Relevant:
Spring.SetUnitNeutral(number unitID, boolean neutral) -> nil

Re: Invulnerable units

Posted: 10 May 2012, 21:43
by KDR_11k
Niobium wrote:Relevant:
Spring.SetUnitNeutral(number unitID, boolean neutral) -> nil
That's what Fibre does to prevent the invulnerable units from screwing things up.