Skip to content

Commit

Permalink
Update to v1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuradha (Anu) Dissanayake authored and Anuradha (Anu) Dissanayake committed Oct 30, 2022
1 parent 91af150 commit 2abc010
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 39 deletions.
Binary file not shown.
1 change: 1 addition & 0 deletions mod-structure/About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<li>1.1</li>
<li>1.2</li>
<li>1.3</li>
<li>1.4</li>
</supportedVersions>

<modDependencies>
Expand Down
14 changes: 7 additions & 7 deletions mod-structure/Defs/UpdateFeatureDefs/UpdateFeatureDefs.xml
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<HugsLib.UpdateFeatureDef Abstract="true" Name="UpdateFeatureBase">
<HugsLib.UpdateFeatureDef Abstract="true" Name="AFFUpdates">
<modNameReadable>Avoid Friendly Fire</modNameReadable>
<modIdentifier>AvoidFriendlyFire</modIdentifier>
<linkUrl>https://ludeon.com/forums/index.php?topic=35571.0</linkUrl>
</HugsLib.UpdateFeatureDef>

<HugsLib.UpdateFeatureDef ParentName="UpdateFeatureBase">
<HugsLib.UpdateFeatureDef ParentName="AFFUpdates">
<defName>AvoidFriendlyFire_0_17_6</defName>
<assemblyVersion>0.17.6</assemblyVersion>
<content>Mod now supports weapons with forced miss radius, such as miniguns</content>
</HugsLib.UpdateFeatureDef>

<HugsLib.UpdateFeatureDef ParentName="UpdateFeatureBase">
<HugsLib.UpdateFeatureDef ParentName="AFFUpdates">
<defName>AvoidFriendlyFire_0_18_2</defName>
<assemblyVersion>0.18.2</assemblyVersion>
<content>Shooters will no longer worry about pawns wearing a shield belt with at least 10% power standing in the line of fire. You can now attack with shielded infantry while ranged troops continue to fire over them from behind. If the shield drops below 10% power while the pawn is still subject to friendly fire, then the shooters will stop. They will resume shooting after the shield gets above 10%. This behaviour can be disabled from the mod options if needed.</content>
</HugsLib.UpdateFeatureDef>

<HugsLib.UpdateFeatureDef ParentName="UpdateFeatureBase">
<HugsLib.UpdateFeatureDef ParentName="AFFUpdates">
<defName>AvoidFriendlyFire_0_18_5</defName>
<assemblyVersion>0.18.5</assemblyVersion>
<content>Added a setting in Mod Options to always enable 'Avoid FF' status on a pawn when it's undrafted. If you tend to disable the 'Avoid FF' setting on pawns during combat, using this option will ensure it is always turned back on again before the next combat. This new option is off by default.</content>
</HugsLib.UpdateFeatureDef>

<HugsLib.UpdateFeatureDef ParentName="UpdateFeatureBase">
<HugsLib.UpdateFeatureDef ParentName="AFFUpdates">
<defName>AvoidFriendlyFire_0_18_7</defName>
<assemblyVersion>0.18.7</assemblyVersion>
<content>Pet protection can now be turned off in Mod Options if desired. This can be useful when using tamed boomrats as weapons, or with certain mods.</content>
</HugsLib.UpdateFeatureDef>

<HugsLib.UpdateFeatureDef ParentName="UpdateFeatureBase">
<HugsLib.UpdateFeatureDef ParentName="AFFUpdates">
<defName>AvoidFriendlyFire_1_0_3</defName>
<assemblyVersion>1.0.3</assemblyVersion>
<content>In Rimworld 1.x, low skill shooters have a larger miss radius than higher skilled ones. This mod now accounts for that. This can be turned off in mod settings to revert to the fixed "one-tile miss radius" assumption, but that may result in friendly fire hits.</content>
</HugsLib.UpdateFeatureDef>

<HugsLib.UpdateFeatureDef ParentName="UpdateFeatureBase">
<HugsLib.UpdateFeatureDef ParentName="AFFUpdates">
<defName>AvoidFriendlyFire_1_0_4</defName>
<assemblyVersion>1.0.4</assemblyVersion>
<content>Shooters who are being blocked by friendlies (but would otherwise have a target) will now have their name on the map and in the Colonist Bar be written in cyan. Likewise, the first friendly blocking any shooter will show up in green.</content>
Expand Down
9 changes: 3 additions & 6 deletions src/AvoidFriendlyFire/AvoidFriendlyFire.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=2.1.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lib.Harmony.2.1.1\lib\net472\0Harmony.dll</HintPath>
<Reference Include="0Harmony, Version=2.2.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lib.Harmony.2.2.2\lib\net472\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp, Version=0.19.6814.14609, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\ThirdParty\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="HugsLib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\UnlimitedHugs.Rimworld.HugsLib.9.0.0\lib\net472\HugsLib.dll</HintPath>
<HintPath>..\packages\UnlimitedHugs.Rimworld.HugsLib.10.0.1\lib\net472\HugsLib.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -89,9 +89,6 @@
<Reference Include="UnityEngine.DSPGraphModule">
<HintPath>..\..\ThirdParty\UnityEngine.DSPGraphModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.FileSystemHttpModule">
<HintPath>..\..\ThirdParty\UnityEngine.FileSystemHttpModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.GameCenterModule">
<HintPath>..\..\ThirdParty\UnityEngine.GameCenterModule.dll</HintPath>
</Reference>
Expand Down
6 changes: 3 additions & 3 deletions src/AvoidFriendlyFire/FireManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ private bool IsPawnWearingUsefulShield(Pawn pawn)

foreach (Apparel apparel in pawn.apparel.WornApparel)
{
var shield = apparel as ShieldBelt;
if (shield == null)
if (apparel.def != ThingDefOf.Apparel_ShieldBelt)
continue;

var shield = apparel.AllComps.FirstOrDefault(c => c is CompShield) as CompShield;
if (shield.ShieldState != ShieldState.Active)
return false;

var energyMax = shield.GetStatValue(StatDefOf.EnergyShieldEnergyMax);
var energyMax = shield.parent.GetStatValue(StatDefOf.EnergyShieldEnergyMax);
return shield.Energy / energyMax > 0.1f;
}

Expand Down
22 changes: 3 additions & 19 deletions src/AvoidFriendlyFire/FireProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,16 @@ public float GetAimOnTargetChance()
factorFromWeather = CasterMap.weatherManager.CurWeatherAccuracyMultiplier;
}

ThingDef coveringGas = null;
var factorFromCoveringGas = 1f;
foreach (var point in GenSight.PointsOnLineOfSight(Origin, Target))
{
if (!point.CanBeSeenOver(CasterMap))
break;

Thing gas = point.GetGas(CasterMap);
if (IsThisGasMorePenalisingThan(gas, coveringGas))
{
coveringGas = gas.def;
}
if (point.AnyGas(CasterMap, GasType.BlindSmoke))
factorFromCoveringGas = 1f - GasUtility.BlindingGasAccuracyPenalty;
}

var factorFromCoveringGas = 1f - (coveringGas?.gas.accuracyPenalty ?? 0f);

var result = factorFromShooterAndDist * factorFromEquipment * factorFromWeather *
factorFromCoveringGas;
if (result < 0.0201f)
Expand All @@ -111,17 +106,6 @@ public float GetAimOnTargetChance()
return result;
}

private static bool IsThisGasMorePenalisingThan(Thing gas, ThingDef otherGas)
{
if (gas == null)
return false;

if (otherGas == null)
return true;

return otherGas.gas.accuracyPenalty < gas.def.gas.accuracyPenalty;
}

private bool HasClearShotFrom(IntVec3 tryFromOrigin)
{
var lineStarted = false;
Expand Down
5 changes: 3 additions & 2 deletions src/AvoidFriendlyFire/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.11.0")]
[assembly: AssemblyFileVersion("1.3.11.0")]
[assembly: AssemblyVersion("1.4.12.0")]
[assembly: AssemblyFileVersion("1.4.12.0")]




4 changes: 2 additions & 2 deletions src/AvoidFriendlyFire/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Lib.Harmony" version="2.1.1" targetFramework="net472" />
<package id="UnlimitedHugs.Rimworld.HugsLib" version="9.0.0" targetFramework="net472" />
<package id="Lib.Harmony" version="2.2.2" targetFramework="net472" />
<package id="UnlimitedHugs.Rimworld.HugsLib" version="10.0.1" targetFramework="net472" />
</packages>

0 comments on commit 2abc010

Please sign in to comment.