ScaredyCat trait for civilians.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -326,6 +326,7 @@
|
||||
<Compile Include="Widgets\GameInitInfoWidget.cs" />
|
||||
<Compile Include="Widgets\Delegates\GameInitDelegate.cs" />
|
||||
<Compile Include="AttackWander.cs" />
|
||||
<Compile Include="ScaredyCat.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
|
||||
public class RenderInfantry : RenderSimple, INotifyAttack, INotifyDamage, INotifyIdle
|
||||
{
|
||||
public bool Panicked = false;
|
||||
public enum AnimationState
|
||||
{
|
||||
Idle,
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
51
OpenRA.Mods.RA/ScaredyCat.cs
Normal file
51
OpenRA.Mods.RA/ScaredyCat.cs
Normal file
@@ -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<Mobile>().ResolveOrder(self, new Order("Move", self, false) { TargetLocation = target });
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (Panicked)
|
||||
return;
|
||||
Panicked = true;
|
||||
self.Trait<RenderInfantry>().Panicked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,7 +222,6 @@ C4:
|
||||
Inherits: ^CivInfantry
|
||||
Selectable:
|
||||
Voice: CivilianFemaleVoice
|
||||
Bounds: 12,17,0,-9
|
||||
|
||||
C5:
|
||||
Inherits: ^CivInfantry
|
||||
@@ -233,7 +230,6 @@ C6:
|
||||
Inherits: ^CivInfantry
|
||||
Selectable:
|
||||
Voice: CivilianFemaleVoice
|
||||
Bounds: 12,17,0,-9
|
||||
|
||||
C7:
|
||||
Inherits: ^CivInfantry
|
||||
@@ -242,7 +238,6 @@ 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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user