Skip to content

Commit

Permalink
1.1 update
Browse files Browse the repository at this point in the history
  • Loading branch information
XeoNovaDan committed Apr 19, 2020
1 parent 1779e17 commit 3afb708
Show file tree
Hide file tree
Showing 36 changed files with 280 additions and 318 deletions.
Binary file added 1.1/Assemblies/ProperShotguns.dll
Binary file not shown.
19 changes: 17 additions & 2 deletions About/About.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<ModMetaData>
<name>[XND] Proper Shotguns</name>
<description>Pump shotguns and chain shotguns will fire actual buckshots rather than single slug-like shots.</description>
<author>XeoNovaDan</author>
<url>https://ludeon.com/forums/index.php?topic=29503.0</url>
<packageId>XeoNovaDan.ProperShotguns</packageId>
<url>https://steamcommunity.com/sharedfiles/filedetails/?id=1438488634</url>
<supportedVersions>
<li>1.0</li>
<li>1.1</li>
</supportedVersions>
<description>Pump shotguns and chain shotguns will fire actual buckshots rather than single slug-like shots.</description>
<modDependencies>
<li>
<packageId>brrainz.harmony</packageId>
<displayName>Harmony</displayName>
<downloadUrl>https://github.com/pardeike/HarmonyRimWorld/releases/latest</downloadUrl>
<steamWorkshopUrl>https://steamcommunity.com/workshop/filedetails/?id=2009463077</steamWorkshopUrl>
</li>
</modDependencies>
<loadAfter>
<li>Ludeon.RimWorld</li>
<li>Ludeon.RimWorld.Royalty</li>
<li>brrainz.harmony</li>
</loadAfter>
</ModMetaData>
6 changes: 0 additions & 6 deletions About/Manifest.xml

This file was deleted.

File renamed without changes.
13 changes: 11 additions & 2 deletions Languages/English/Keyed/ModSettings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<LanguageData>

<ProperShotgunsSettingsCategory>Proper Shotguns</ProperShotgunsSettingsCategory>
<DamageRoundingMode>Damage Rounding Mode</DamageRoundingMode>
<ProperShotguns.SettingsCategory>Proper Shotguns</ProperShotguns.SettingsCategory>

<ProperShotguns.ShotgunDamageRounding>Shotgun pellet damage rounding</ProperShotguns.ShotgunDamageRounding>
<ProperShotguns.ShotgunDamageRounding_Random>Random</ProperShotguns.ShotgunDamageRounding_Random>
<ProperShotguns.ShotgunDamageRounding_Random_Desc>Pellet damage will randomly be rounded up or down depending on decimal value - 3.7 has a 70% chance of being rounded up to 4, and a 30% chance of being rounded down to 3.</ProperShotguns.ShotgunDamageRounding_Random_Desc>
<ProperShotguns.ShotgunDamageRounding_Standard>Standard</ProperShotguns.ShotgunDamageRounding_Standard>
<ProperShotguns.ShotgunDamageRounding_Standard_Desc>Pellet damage will follow standard rounding rules - down if decimal value is less than 0.5, otherwise up.</ProperShotguns.ShotgunDamageRounding_Standard_Desc>
<ProperShotguns.ShotgunDamageRounding_Floor>Down</ProperShotguns.ShotgunDamageRounding_Floor>
<ProperShotguns.ShotgunDamageRounding_Floor_Desc>Pellet damage will always be rounded down.</ProperShotguns.ShotgunDamageRounding_Floor_Desc>
<ProperShotguns.ShotgunDamageRounding_Ceil>Up</ProperShotguns.ShotgunDamageRounding_Ceil>
<ProperShotguns.ShotgunDamageRounding_Ceil_Desc>Pellet damage will always be rounded up.</ProperShotguns.ShotgunDamageRounding_Ceil_Desc>

</LanguageData>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions Patches/VanillaExpanded/Factions/Settlers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<Patch>

<Operation Class="PatchOperationFindMod">
<mods>
<li>Vanilla Factions Expanded - Settlers</li>
</mods>
<match Class="PatchOperationSequence">
<success>Always</success>
<operations>

<!-- general verb patching -->
<li Class="PatchOperationReplace">
<xpath>/Defs/ThingDef[defName="VFES_Gun_DoubleBarreledShotgun"]/verbs/li/verbClass</xpath>
<value>
<verbClass>ProperShotguns.Verb_ShootShotgun</verbClass>
</value>
</li>

</operations>
</match>
</Operation>

</Patch>
53 changes: 53 additions & 0 deletions Patches/VanillaExpanded/Weapons/Lasers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8" ?>
<Patch>

<Operation Class="PatchOperationFindMod">
<mods>
<li>Vanilla Weapons Expanded - Laser</li>
</mods>
<match Class="PatchOperationSequence">
<success>Always</success>
<operations>

<!-- general verb patching -->
<li Class="PatchOperationReplace">
<xpath>/Defs/ThingDef[defName="VWEL_Gun_LaserShotgun" or defName="VWEL_Gun_SalvagedLaserShotgun"]/verbs/li/verbClass</xpath>
<value>
<verbClass>ProperShotguns.Verb_ShootShotgun</verbClass>
</value>
</li>
<li Class="PatchOperationRemove">
<xpath>/Defs/ThingDef[defName="VWEL_Gun_LaserShotgun" or defName="VWEL_Gun_SalvagedLaserShotgun"]/verbs/li/burstShotCount</xpath>
</li>

<!-- projectile patching -->
<li Class="PatchOperationAddModExtension">
<xpath>/Defs/ThingDef[defName="VWEL_Bullet_LaserShotgun" or defName="VWEL_Bullet_SalvagedLaserShotgun"]</xpath>
<value>
<li Class="ProperShotguns.ShotgunExtension">
<pelletCount>4</pelletCount>
</li>
</value>
</li>

<!-- ===== Laser Shotgun ===== -->
<li Class="PatchOperationReplace">
<xpath>/Defs/ThingDef[defName="VWEL_Bullet_LaserShotgun"]/projectile/damageAmountBase</xpath>
<value>
<damageAmountBase>28</damageAmountBase>
</value>
</li>

<!-- ===== Salvaged Laser Shotgun ===== -->
<li Class="PatchOperationReplace">
<xpath>/Defs/ThingDef[defName="VWEL_Bullet_SalvagedLaserShotgun"]/projectile/damageAmountBase</xpath>
<value>
<damageAmountBase>16</damageAmountBase>
</value>
</li>

</operations>
</match>
</Operation>

</Patch>
File renamed without changes.
File renamed without changes.
Binary file modified Source/.vs/ProperShotguns/v16/.suo
Binary file not shown.
Binary file modified Source/.vs/ProperShotguns/v16/Server/sqlite3/storage.ide
Binary file not shown.
27 changes: 27 additions & 0 deletions Source/ProperShotguns/Enums/ShotgunDamageRoundMode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using RimWorld;
using Verse;
using HarmonyLib;
using UnityEngine;

namespace ProperShotguns
{

public enum ShotgunDamageRoundMode
{

Random,
Standard,
Floor,
Ceil

}

}
9 changes: 5 additions & 4 deletions Source/ProperShotguns/HarmonyPatches/HarmonyPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
using System.Runtime.CompilerServices;
using RimWorld;
using Verse;
using Harmony;
using HarmonyLib;
using UnityEngine;

namespace ProperShotguns
{

[StaticConstructorOnStartup]
internal static class HarmonyPatches
public static class HarmonyPatches
{

static HarmonyPatches()
{
var h = HarmonyInstance.Create("XeoNovaDan.ProperShotguns");
h.PatchAll();
ProperShotguns.harmonyInstance.PatchAll();
}

}

}
6 changes: 3 additions & 3 deletions Source/ProperShotguns/HarmonyPatches/Patch_Pawn_MindState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
using RimWorld;
using Verse;
using Verse.AI;
using Harmony;
using HarmonyLib;
using UnityEngine;

namespace ProperShotguns
{

static class Patch_Pawn_MindState
public static class Patch_Pawn_MindState
{

[HarmonyPatch(typeof(Pawn_MindState), "CanStartFleeingBecauseOfPawnAction")]
static class CanStartFleeingBecauseOfPawnAction
public static class CanStartFleeingBecauseOfPawnAction
{

public static void Postfix(Pawn p, ref bool __result)
Expand Down
36 changes: 26 additions & 10 deletions Source/ProperShotguns/HarmonyPatches/Patch_Projectile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using RimWorld;
using Verse;
using Verse.AI;
using Harmony;
using HarmonyLib;
using UnityEngine;

namespace ProperShotguns
Expand All @@ -19,27 +19,43 @@ static class Patch_Projectile
{

[HarmonyPatch(typeof(Projectile), nameof(Projectile.DamageAmount), MethodType.Getter)]
static class get_DamageAmount
public static class get_DamageAmount
{

public static void Postfix(Projectile __instance, ThingDef ___equipmentDef, ref int __result)
public static void Postfix(Projectile __instance, ref int __result)
{
var verbCache = __instance.TryGetComp<CompProjectileVerbCache>();
if (verbCache != null && verbCache.cachedVerbClass is Type t && t.IsAssignableFrom(typeof(Verb_ShootShotgun)))
{
var shotgunExtension = __instance.def.GetModExtension<ShotgunExtension>() ?? ShotgunExtension.defaultValues;
var shotgunExtension = ShotgunExtension.Get(__instance.def);
float adjustedDamage = (float)__result / shotgunExtension.pelletCount;
if (ProperShotgunsSettings.damageRoundMode == ProperShotgunsSettings.StandardDamageRoundModeString)
__result = Mathf.RoundToInt(adjustedDamage);
else
__result = GenMath.RoundRandom(adjustedDamage);

// Determine pellet damage
switch(ProperShotgunsSettings.damageRoundMode)
{
case ShotgunDamageRoundMode.Standard:
__result = Mathf.RoundToInt(adjustedDamage);
break;
case ShotgunDamageRoundMode.Random:
__result = GenMath.RoundRandom(adjustedDamage);
break;
case ShotgunDamageRoundMode.Ceil:
__result = Mathf.CeilToInt(adjustedDamage);
break;
case ShotgunDamageRoundMode.Floor:
__result = Mathf.FloorToInt(adjustedDamage);
break;
default:
throw new NotImplementedException();
}
}
}

}

[HarmonyPatch(typeof(Projectile), nameof(Projectile.Launch), new Type[] { typeof(Thing), typeof(Vector3), typeof(LocalTargetInfo), typeof(LocalTargetInfo), typeof(ProjectileHitFlags), typeof(Thing), typeof(ThingDef) })]
static class Launch
[HarmonyPatch(typeof(Projectile), nameof(Projectile.Launch),
new Type[] { typeof(Thing), typeof(Vector3), typeof(LocalTargetInfo), typeof(LocalTargetInfo), typeof(ProjectileHitFlags), typeof(Thing), typeof(ThingDef) })]
public static class Launch
{

public static void Postfix(Projectile __instance, Thing launcher)
Expand Down
Loading

0 comments on commit 3afb708

Please sign in to comment.