Skip to content

Commit

Permalink
Clarify AttackPanicChance and add PanicChance.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mailaender authored and abcdefg30 committed Apr 24, 2020
1 parent 250f5be commit a4b427b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Makes the unit automatically run around when taking damage.")]
class ScaredyCatInfo : ITraitInfo, Requires<MobileInfo>
{
[Desc("Chance (out of 100) the unit has to enter panic mode when attacked.")]
public readonly int PanicChance = 100;

[Desc("How long (in ticks) the actor should panic for.")]
public readonly int PanicLength = 25 * 10;

[Desc("Panic movement speed as a percentage of the normal speed.")]
public readonly int PanicSpeedModifier = 200;

[Desc("Chance (out of 100) the unit has to enter panic mode when attacked.")]
[Desc("Chance (out of 100) the unit has to enter panic mode when attacking.")]
public readonly int AttackPanicChance = 20;

[SequenceReference(null, true)]
Expand Down Expand Up @@ -81,7 +84,7 @@ void INotifyIdle.TickIdle(Actor self)

void INotifyDamage.Damaged(Actor self, AttackInfo e)
{
if (e.Damage.Value > 0)
if (e.Damage.Value > 0 && self.World.SharedRandom.Next(100) < info.PanicChance)
Panic();
}

Expand Down

0 comments on commit a4b427b

Please sign in to comment.