From 03c80fb9c634b8def72c450e6974359740e0a136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Husti=C4=87?= Date: Tue, 16 Jun 2015 22:49:41 +0100 Subject: [PATCH 1/2] Added tesla boost capabilities. Shock troopers and tesla tanks standing near a tesla coil will charge it up, enhancing its range, modifying the zap animation and allowing it to work even when player's power is down. The sound for charger weapons edited from https://www.freesound.org/people/JoelAudio/sounds/136542/ --- .../Traits/Power/RequiresPower.cs | 11 ++-- mods/ra/bits/litningupg.shp | Bin 0 -> 504 bytes mods/ra/bits/teslacharge.aud | Bin 0 -> 5054 bytes mods/ra/rules/infantry.yaml | 11 ++++ mods/ra/rules/structures.yaml | 14 ++++++ mods/ra/rules/vehicles.yaml | 11 ++++ mods/ra/sequences/misc.yaml | 7 +++ mods/ra/weapons/other.yaml | 47 ++++++++++++++++++ 8 files changed, 96 insertions(+), 5 deletions(-) create mode 100644 mods/ra/bits/litningupg.shp create mode 100644 mods/ra/bits/teslacharge.aud diff --git a/OpenRA.Mods.Common/Traits/Power/RequiresPower.cs b/OpenRA.Mods.Common/Traits/Power/RequiresPower.cs index 335da3efb7..d3ea5c4da9 100644 --- a/OpenRA.Mods.Common/Traits/Power/RequiresPower.cs +++ b/OpenRA.Mods.Common/Traits/Power/RequiresPower.cs @@ -13,23 +13,24 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Needs power to operate.")] - class RequiresPowerInfo : ITraitInfo + class RequiresPowerInfo : UpgradableTraitInfo, ITraitInfo { - public object Create(ActorInitializer init) { return new RequiresPower(init.Self); } + public override object Create(ActorInitializer init) { return new RequiresPower(init.Self, this); } } - class RequiresPower : IDisable, INotifyOwnerChanged + class RequiresPower : UpgradableTrait, IDisable, INotifyOwnerChanged { PowerManager playerPower; - public RequiresPower(Actor self) + public RequiresPower(Actor self, RequiresPowerInfo info) + : base(info) { playerPower = self.Owner.PlayerActor.Trait(); } public bool Disabled { - get { return playerPower.PowerProvided < playerPower.PowerDrained; } + get { return playerPower.PowerProvided < playerPower.PowerDrained && !IsTraitDisabled; } } public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) diff --git a/mods/ra/bits/litningupg.shp b/mods/ra/bits/litningupg.shp new file mode 100644 index 0000000000000000000000000000000000000000..c57e2cc7cf9be42242dea4c072e6debf7c305d7f GIT binary patch literal 504 zcmYLFJ1;~*6#gazjm*TGO6idZjaniRH2#6VprIMabJ1Mu*G1_?4Chqzyf;d3uZOBf!WTnPVRweF2J3^?@EVXAJdxC+O(IB zVKrJKVva9idXqg^s>GNX0q$zo9wy@MFAib7e)HrX(9EO-O z5V6ExAp)c)B(N%Ew;76|Fl!dQ0nB)1LT#|P1>?$`8lIyU_^aR`$5{TJM;_L>C#1Ki z8D%LQQJapL-20fS-@xbpb}OgwZ6b1$#?nI(lcSNW`7UV^1kdnO;Ue+Pu}gPQ%OfqJ t_5|N2l%v-kRe!|W1^j;SEH*#<2-RZH6UTTx1ea0Q(xP#IbVd1a>JQgA#kv3h literal 0 HcmV?d00001 diff --git a/mods/ra/bits/teslacharge.aud b/mods/ra/bits/teslacharge.aud new file mode 100644 index 0000000000000000000000000000000000000000..f46ad675b154560870f26d86109404e027ea24c8 GIT binary patch literal 5054 zcmXw-TX5UfoyGxBwgHl|0LpDZkdi>k=@1|(Q*w8P7s-~rFQR0(b~>}8i_=Zo7uim> zNwW{SI1>P*ZGe<)fTS#dl4F9TBvMYdyvPnIXJM1#5dbco1OVul00h9l{Z9b+zrXxttSwEeqW{}#xHnrg zoDp&XEp$>~VId|Ao8V_0VPx{r@$ej|eFmLh-sfbf4D%J#iLb{vCo-}QZNsib>$l^| zyadQ@rb`skk-jaI&ULSGsQm>8lWlzQyv!s)UnxCiUIm$qCDidd9*B(U6+L z1kVwLnJ&FG5hJieDpk#YsNas!usjl9<#1qTp_fvYD0q1vx_^lp2&a;yE*ErbwW4vs z-?u!+ol%mUS6T8ScrG=zyx?*owY5m6{1ur$64OV;b4n^*2} z^XRHkT@X2!xkr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sPzW76QLV z#DCb|5XrP}4vKPZK8Jsss=CzvCb^(Vo-jTqDH+n6Z*ynE;*xd0WjV&U9Rq(zMvbR$ zN>OkAV_uo3yTfYH&pLQm^+JWFMB&%v4O~wU}MCHp2yS$FD?H z;DlG1i@#aVDjMdzY5kIDv-1^$5m8_E)F^9}X#Z;~5rS{a2lse! z0I|3a9-fTkG0-8Wm3OjG(g`zaN*Dv;*2#3{qs74To8AVtV(~7Y&UCI8FC<`i)$O_g zm8@cEMCQpS{eql^Aw3X(BaY*bJ9NaHHt_A?o0z95aVZ`QA1fIq>SpUo$u}D$(AH3- zI&K7YMXtxR*4n`FfQU=K059$N+kd3yIa_lwDUB`G5p-1wW-nwQh87BGA~itXus9@f z$>vaP1CyHX8x`-IK;^CLKfYSvYUy=Wk8XmfJ~;Dkyk`SLA`0hdpN&>*5|!3>T<@)6 z*pc-{Byg4MeF7P~WOg??XwRfTJ2{c|vdcgC+GQ-w@tz_$;SSX?EsV7JZb__b%Y&|~ zb(1k%2J$3q-|f}`TL3efb;ToC(_O!uRL?5z4Q{~9#;5pqCQ?Q)1KG_ZC27iMU)}Ck z)PUBF-Sc$>3bDQ#a{U|*EpfhNCa~M>n+-@Frzjf2%^YJ#Td?`8^>+`7Ez>f&Z~L hgvmgBiVeM0Pu}@)bCTM%)uICxx_#vo%P Date: Fri, 9 Oct 2015 20:56:59 +0200 Subject: [PATCH 2/2] Enabled multiple timed upgrades from single source. This makes the UpgradeManager support requests to grant a timed upgrade multiple times from a single source. GrantUpgradeWarhead modified to take advantage of this. --- .../Traits/Upgrades/UpgradeManager.cs | 22 +++++++++---------- .../Warheads/GrantUpgradeWarhead.cs | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Upgrades/UpgradeManager.cs b/OpenRA.Mods.Common/Traits/Upgrades/UpgradeManager.cs index 81a7765d1e..7a440bce0a 100644 --- a/OpenRA.Mods.Common/Traits/Upgrades/UpgradeManager.cs +++ b/OpenRA.Mods.Common/Traits/Upgrades/UpgradeManager.cs @@ -85,13 +85,13 @@ namespace OpenRA.Mods.Common.Traits }); } - /// Upgrade level increments are limited to one per source, i.e., if a single source - /// attempts granting multiple upgrades, they will not accumulate. They will replace each other - /// instead, leaving only the last granted upgrade active. An upgrade from each new distinct - /// source will increment the upgrade's level until AcceptsUpgrade starts returning false. Then, - /// when no new levels are accepted, the upgrade source with the shortest remaining upgrade - /// duration will be replaced by the new source. - public void GrantTimedUpgrade(Actor self, string upgrade, int duration, object source = null) + /// Upgrade level increments are limited to dupesAllowed per source, i.e., if a single + /// source attempts granting more upgrades than dupesAllowed, they will not accumulate. They will + /// replace each other instead, leaving only the most recently granted upgrade active. Each new + /// upgrade granting request will increment the upgrade's level until AcceptsUpgrade starts + /// returning false. Then, when no new levels are accepted, the upgrade source with the shortest + /// remaining upgrade duration will be replaced by the new source. + public void GrantTimedUpgrade(Actor self, string upgrade, int duration, object source = null, int dupesAllowed = 1) { var timed = timedUpgrades.FirstOrDefault(u => u.Upgrade == upgrade); if (timed == null) @@ -102,17 +102,17 @@ namespace OpenRA.Mods.Common.Traits return; } - var src = timed.Sources.FirstOrDefault(s => s.Source == source); - if (src == null) + var srcs = timed.Sources.Where(s => s.Source == source); + if (srcs.Count() < dupesAllowed) { timed.Sources.Add(new TimedUpgrade.UpgradeSource(duration, source)); if (AcceptsUpgrade(self, upgrade)) GrantUpgrade(self, upgrade, timed); else - timed.Sources.Remove(timed.Sources.OrderByDescending(s => s.Remaining).Last()); + timed.Sources.Remove(timed.Sources.MinBy(s => s.Remaining)); } else - src.Remaining = duration; + srcs.MinBy(s => s.Remaining).Remaining = duration; timed.Remaining = Math.Max(duration, timed.Remaining); } diff --git a/OpenRA.Mods.Common/Warheads/GrantUpgradeWarhead.cs b/OpenRA.Mods.Common/Warheads/GrantUpgradeWarhead.cs index 4ea45972e7..f45e1b4ea1 100644 --- a/OpenRA.Mods.Common/Warheads/GrantUpgradeWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/GrantUpgradeWarhead.cs @@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Warheads if (Duration > 0) { if (um.AcknowledgesUpgrade(a, u)) - um.GrantTimedUpgrade(a, u, Duration, firedBy); + um.GrantTimedUpgrade(a, u, Duration, firedBy, Upgrades.Count(upg => upg == u)); } else {