Feature: Bounties added to Buildings/Units at 10% of value + 1.25 for each lvl
This commit is contained in:
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.RA
|
||||
[Sync]
|
||||
int Experience = 0;
|
||||
[Sync]
|
||||
int Level = 0;
|
||||
public int Level { get; private set; }
|
||||
|
||||
public void GiveOneLevel()
|
||||
{
|
||||
|
||||
59
OpenRA.Mods.RA/GivesBounty.cs
Normal file
59
OpenRA.Mods.RA/GivesBounty.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
#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.Mods.RA.Effects;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class GivesBountyInfo : TraitInfo<GivesBounty>
|
||||
{
|
||||
public readonly int Percentage = 10;
|
||||
public readonly int LevelMod = 125;
|
||||
}
|
||||
|
||||
class GivesBounty : INotifyDamage
|
||||
{
|
||||
|
||||
int GetMultiplier(Actor self)
|
||||
{
|
||||
// returns 100's as 1, so as to keep accuracy for longer.
|
||||
var info = self.Info.Traits.Get<GivesBountyInfo>();
|
||||
var gainsExp = self.TraitOrDefault<GainsExperience>();
|
||||
if (gainsExp == null)
|
||||
return 100;
|
||||
|
||||
var slevel = self.Trait<GainsExperience>().Level;
|
||||
return (slevel > 0) ? slevel * info.LevelMod : 100;
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageState == DamageState.Dead)
|
||||
{
|
||||
var info = self.Info.Traits.Get<GivesBountyInfo>();
|
||||
// Prevent TK from giving Bounty
|
||||
if (e.Attacker == null || e.Attacker.Destroyed || e.Attacker.Owner.Stances[self.Owner] == Stance.Ally)
|
||||
return;
|
||||
|
||||
var valued = self.Info.Traits.GetOrDefault<ValuedInfo>();
|
||||
var cost = valued != null ? valued.Cost : 0;
|
||||
// 2 hundreds because of GetMultiplier and info.Percentage.
|
||||
var bounty = (int)(cost * GetMultiplier(self) * info.Percentage / 10000);
|
||||
|
||||
e.Attacker.World.AddFrameEndTask(w => w.Add(new CashTick(bounty, 20, 1, self.CenterLocation, e.Attacker.Owner.ColorRamp.GetColor(0))));
|
||||
|
||||
e.Attacker.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(bounty);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
@@ -66,6 +66,7 @@
|
||||
<Compile Include="Air\EjectOnDeath.cs" />
|
||||
<Compile Include="Buildings\Sellable.cs" />
|
||||
<Compile Include="Effects\CashTick.cs" />
|
||||
<Compile Include="GivesBounty.cs" />
|
||||
<Compile Include="Lint\LintBuildablePrerequisites.cs" />
|
||||
<Compile Include="ProductionBar.cs" />
|
||||
<Compile Include="Render\RenderEditorOnly.cs" />
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
Notification: unitlst1.aud
|
||||
ProximityCaptor:
|
||||
Types:Vehicle
|
||||
GivesBounty:
|
||||
|
||||
^Tank:
|
||||
AppearsOnRadar:
|
||||
@@ -57,6 +58,7 @@
|
||||
Notification: unitlst1.aud
|
||||
ProximityCaptor:
|
||||
Types:Tank
|
||||
GivesBounty:
|
||||
|
||||
^Infantry:
|
||||
AppearsOnRadar:
|
||||
@@ -93,6 +95,7 @@
|
||||
Notification: unitlst1.aud
|
||||
ProximityCaptor:
|
||||
Types:Infantry
|
||||
GivesBounty:
|
||||
|
||||
^Ship:
|
||||
AppearsOnRadar:
|
||||
@@ -115,6 +118,7 @@
|
||||
Notification: navylst1.aud
|
||||
ProximityCaptor:
|
||||
Types:Ship
|
||||
GivesBounty:
|
||||
|
||||
^Plane:
|
||||
AppearsOnRadar:
|
||||
@@ -139,6 +143,7 @@
|
||||
EjectOnDeath:
|
||||
PilotActor: E1
|
||||
SuccessRate: 50
|
||||
GivesBounty:
|
||||
|
||||
^Building:
|
||||
AppearsOnRadar:
|
||||
@@ -168,6 +173,7 @@
|
||||
Types:Building
|
||||
Sellable:
|
||||
AcceptsSupplies:
|
||||
GivesBounty:
|
||||
|
||||
^Wall:
|
||||
AppearsOnRadar:
|
||||
|
||||
Reference in New Issue
Block a user