diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 65323bb07d..081a482e81 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -1,4 +1,4 @@ - + Debug @@ -326,6 +326,7 @@ + diff --git a/OpenRA.Mods.RA/Render/RenderInfantry.cs b/OpenRA.Mods.RA/Render/RenderInfantry.cs index 4ca3ce6015..abbd0628ca 100644 --- a/OpenRA.Mods.RA/Render/RenderInfantry.cs +++ b/OpenRA.Mods.RA/Render/RenderInfantry.cs @@ -23,6 +23,7 @@ namespace OpenRA.Mods.RA.Render public class RenderInfantry : RenderSimple, INotifyAttack, INotifyDamage, INotifyIdle { + public bool Panicked = false; public enum AnimationState { Idle, @@ -53,7 +54,7 @@ namespace OpenRA.Mods.RA.Render public override void Tick(Actor self) { base.Tick(self); - + // If path is blocked, we can have !isMoving and !idle // Need to handle this case specially if (!mobile.IsMoving && State == AnimationState.Moving) @@ -64,7 +65,7 @@ namespace OpenRA.Mods.RA.Render else if (State != AnimationState.Moving && mobile.IsMoving) { State = AnimationState.Moving; - anim.PlayRepeating("run"); + anim.PlayRepeating(Panicked ? "panic-run" : "run"); } } diff --git a/OpenRA.Mods.RA/ScaredyCat.cs b/OpenRA.Mods.RA/ScaredyCat.cs new file mode 100644 index 0000000000..21f49477a9 --- /dev/null +++ b/OpenRA.Mods.RA/ScaredyCat.cs @@ -0,0 +1,51 @@ +#region Copyright & License Information +/* + * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using OpenRA.Traits; +using OpenRA.Traits.Activities; +using System.Drawing; +using OpenRA.Mods.RA.Move; +using OpenRA.Mods.RA.Render; + +namespace OpenRA.Mods.RA +{ + class ScaredyCatInfo : ITraitInfo + { + public readonly int MoveRadius = 2; + + public object Create(ActorInitializer init) { return new ScaredyCat(init.self, this); } + } + + class ScaredyCat : INotifyIdle, INotifyDamage + { + readonly ScaredyCatInfo Info; + bool Panicked = false; + public ScaredyCat(Actor self, ScaredyCatInfo info) + { + Info = info; + } + + public void TickIdle(Actor self) + { + if (!Panicked) + return; + var target = Util.SubPxVector[self.World.SharedRandom.Next(255)]* Info.MoveRadius / 1024 + self.Location; + self.Trait().ResolveOrder(self, new Order("Move", self, false) { TargetLocation = target }); + } + + public void Damaged(Actor self, AttackInfo e) + { + if (Panicked) + return; + Panicked = true; + self.Trait().Panicked = true; + } + } +} diff --git a/mods/cnc/rules/civilian.yaml b/mods/cnc/rules/civilian.yaml index 74e521784d..09d093352f 100644 --- a/mods/cnc/rules/civilian.yaml +++ b/mods/cnc/rules/civilian.yaml @@ -209,14 +209,12 @@ C1: Inherits: ^CivInfantry Selectable: Voice: CivilianMaleVoice - Bounds: 12,17,0,-9 - C2: Inherits: ^CivInfantry Selectable: Voice: CivilianFemaleVoice - Bounds: 12,17,0,-9 + C3: Inherits: ^CivInfantry @@ -224,8 +222,7 @@ C4: Inherits: ^CivInfantry Selectable: Voice: CivilianFemaleVoice - Bounds: 12,17,0,-9 - + C5: Inherits: ^CivInfantry @@ -233,8 +230,7 @@ C6: Inherits: ^CivInfantry Selectable: Voice: CivilianFemaleVoice - Bounds: 12,17,0,-9 - + C7: Inherits: ^CivInfantry @@ -242,8 +238,7 @@ C8: Inherits: ^CivInfantry Selectable: Voice: CivilianFemaleVoice - Bounds: 12,17,0,-9 - + C9: Inherits: ^CivInfantry @@ -251,5 +246,4 @@ C10: Inherits: ^CivInfantry Selectable: Voice: CivilianFemaleVoice - Bounds: 12,17,0,-9 \ No newline at end of file diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 9dc53c7fa6..2fca8a4c5d 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -131,6 +131,7 @@ ^CivInfantry: Inherits: ^Infantry -Buildable: + -AutoTarget: AppearsOnRadar: Selectable: Voice: CivilianMaleVoice @@ -142,16 +143,17 @@ Mobile: Speed: 4 Health: - HP: 20 + HP: 25 RevealsShroud: Range: 2 AttackFrontal: PrimaryWeapon: Pistol -# ActorLostNotification: -# Notification: civdead1.aud -# NotifyAll: true + ActorLostNotification: + Notification: civdead1.aud + NotifyAll: true ProximityCaptor: Types:CivilianInfantry + ScaredyCat: ^Plane: AppearsOnRadar: diff --git a/mods/cnc/sequences/infantry.yaml b/mods/cnc/sequences/infantry.yaml index 5f7f0afa19..5b560330f2 100644 --- a/mods/cnc/sequences/infantry.yaml +++ b/mods/cnc/sequences/infantry.yaml @@ -565,7 +565,7 @@ c1: Start: 8 Length: 6 Facings: 8 - panic: + panic-run: Start: 8 Length: 6 Facings: 8 @@ -614,7 +614,7 @@ c2: Start: 8 Length: 6 Facings: 8 - panic: + panic-run: Start: 8 Length: 6 Facings: 8 @@ -664,7 +664,7 @@ c3: Start: 8 Length: 6 Facings: 8 - panic: + panic-run: Start: 8 Length: 6 Facings: 8 @@ -714,7 +714,7 @@ c4: Start: 8 Length: 6 Facings: 8 - panic: + panic-run: Start: 8 Length: 6 Facings: 8 @@ -764,7 +764,7 @@ c5: Start: 8 Length: 6 Facings: 8 - panic: + panic-run: Start: 8 Length: 6 Facings: 8 @@ -814,7 +814,7 @@ c6: Start: 8 Length: 6 Facings: 8 - panic: + panic-run: Start: 8 Length: 6 Facings: 8 @@ -864,7 +864,7 @@ c7: Start: 8 Length: 6 Facings: 8 - panic: + panic-run: Start: 8 Length: 6 Facings: 8 @@ -914,7 +914,7 @@ c8: Start: 8 Length: 6 Facings: 8 - panic: + panic-run: Start: 8 Length: 6 Facings: 8 @@ -964,7 +964,7 @@ c9: Start: 8 Length: 6 Facings: 8 - panic: + panic-run: Start: 8 Length: 6 Facings: 8 @@ -1014,7 +1014,7 @@ c10: Start: 8 Length: 6 Facings: 8 - panic: + panic-run: Start: 8 Length: 6 Facings: 8