public void Tick(Actor self) { var info = self.Info.Traits.Get<SelfHealingInfo>(); if ((float)self.Health / self.GetMaxHP() >= info.HealIfBelow) return; if (--ticks <= 0) { ticks = info.Ticks; self.InflictDamage(self, -info.Step, null); } }
public IActivity Tick( Actor self ) { if (isCanceled) return NextActivity; self.World.AddFrameEndTask( _ => { var oldHP = self.GetMaxHP(); var newHP = Rules.Info[actor].Traits.Get<OwnedActorInfo>().HP; var newHealth = (transferPercentage) ? (int)((float)self.Health/oldHP*newHP) : Math.Min(self.Health, newHP); self.Health = 0; self.World.Remove( self ); foreach (var s in sounds) Sound.PlayToPlayer(self.Owner, s); var a = self.World.CreateActor( actor, self.Location + offset, self.Owner ); a.Health = newHealth; } ); return this; }
ExtendedDamageState GetExtendedState( Actor self, int damage ) { var effectiveHealth = self.Health + damage; if (effectiveHealth <= 0) return ExtendedDamageState.Dead; if (effectiveHealth < self.GetMaxHP() * self.World.Defaults.ConditionRed) return ExtendedDamageState.Quarter; if (effectiveHealth < self.GetMaxHP() * self.World.Defaults.ConditionYellow) return ExtendedDamageState.Half; if (effectiveHealth < self.GetMaxHP() * 0.75) return ExtendedDamageState.ThreeQuarter; return ExtendedDamageState.Normal; }
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor) { if (mi.Button == MouseButton.Left || underCursor == null || underCursor.Owner == null) return null; if (self == underCursor) return null; var isHeal = self.GetPrimaryWeapon().Warheads.First().Damage < 0; var forceFire = mi.Modifiers.HasModifier(Modifiers.Ctrl); if (isHeal) { if (underCursor.Owner == null) return null; if (self.Owner.Stances[ underCursor.Owner ] != Stance.Ally && !forceFire) return null; if (underCursor.Health >= underCursor.GetMaxHP()) return null; // don't allow healing of fully-healed stuff! } else if ((self.Owner.Stances[ underCursor.Owner ] != Stance.Enemy) && !forceFire) return null; if (!Combat.HasAnyValidWeapons(self, underCursor)) return null; return new Order(isHeal ? "Heal" : "Attack", self, underCursor); }