Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Assemblies/CombatExtended.dll
Binary file not shown.
85 changes: 43 additions & 42 deletions Royalty/Patches/ThingDefs_Buildings/Buildings_Mechanoid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@
<xpath>Defs/ThingDef[defName="Defoliator"]/comps/li[@Class="CompProperties_Explosive"]/wickTicks</xpath>
<value>
<wickTicks>
<min>180</min>
<max>240</max>
</wickTicks>
<min>180</min>
<max>240</max>
</wickTicks>
</value>
</Operation>

<Operation Class="PatchOperationReplace">
<xpath>Defs/ThingDef[defName="UnstablePowerCell"]/comps/li[@Class="CompProperties_Explosive"]/wickTicks</xpath>
<value>
<wickTicks>
<min>180</min>
<max>300</max>
</wickTicks>
<min>180</min>
<max>300</max>
</wickTicks>
</value>
</Operation>

<Operation Class="PatchOperationReplace">
<xpath>Defs/ThingDef[defName="Turret_AutoMortar"]/comps/li[@Class="CompProperties_Explosive"]/wickTicks</xpath>
<value>
<wickTicks>
<min>180</min>
<max>240</max>
</wickTicks>
<min>180</min>
<max>240</max>
</wickTicks>
</value>
</Operation>

Expand Down Expand Up @@ -229,12 +229,12 @@
<Operation Class="PatchOperationAdd">
<xpath>Defs/ThingDef[defName="Turret_AutoMortar"]/comps</xpath>
<value>
<li Class="CombatExtended.CompProperties_Fragments">
<fragments>
<Fragment_Large>5</Fragment_Large>
<Fragment_Small>20</Fragment_Small>
</fragments>
</li>
<li Class="CombatExtended.CompProperties_Fragments">
<fragments>
<Fragment_Large>5</Fragment_Large>
<Fragment_Small>20</Fragment_Small>
</fragments>
</li>
</value>
</Operation>

Expand All @@ -253,15 +253,16 @@
<xpath>Defs/ThingDef[defName = "Artillery_AutoMortar"]</xpath>
<value>
<comps>
<li Class="CombatExtended.CompProperties_Charges">
<chargeSpeeds>
<li>30</li>
<li>50</li>
<li>70</li>
<li>90</li>
</chargeSpeeds>
</li>
</comps>
<li Class="CombatExtended.CompProperties_Charges">
<chargeSpeeds>
<li>30</li>
<li>50</li>
<li>70</li>
<li>90</li>
</chargeSpeeds>
</li>
<li Class="CombatExtended.CompProperties_AmmoUser" />
</comps>
</value>
</Operation>

Expand All @@ -276,26 +277,26 @@
<xpath>Defs/ThingDef[defName = "Artillery_AutoMortar"]/verbs</xpath>
<value>
<verbs>
<li Class="CombatExtended.VerbPropertiesCE">
<verbClass>CombatExtended.Verb_ShootMortarCE</verbClass>
<forceNormalTimeSpeed>false</forceNormalTimeSpeed>
<hasStandardCommand>true</hasStandardCommand>
<defaultProjectile>Bullet_ChargeMortarShell</defaultProjectile>
<warmupTime>11</warmupTime>
<minRange>32</minRange>
<range>700</range>
<burstShotCount>1</burstShotCount>
<soundCast>Mortar_LaunchA</soundCast>
<muzzleFlashScale>16</muzzleFlashScale>
<circularError>3</circularError>
<indirectFirePenalty>0.4</indirectFirePenalty>
<targetParams>
<canTargetLocations>true</canTargetLocations>
</targetParams>
</li>
<li Class="CombatExtended.VerbPropertiesCE">
<verbClass>CombatExtended.Verb_ShootMortarCE</verbClass>
<forceNormalTimeSpeed>false</forceNormalTimeSpeed>
<hasStandardCommand>true</hasStandardCommand>
<defaultProjectile>Bullet_ChargeMortarShell</defaultProjectile>
<warmupTime>11</warmupTime>
<minRange>32</minRange>
<range>700</range>
<burstShotCount>1</burstShotCount>
<soundCast>Mortar_LaunchA</soundCast>
<muzzleFlashScale>16</muzzleFlashScale>
<circularError>3</circularError>
<indirectFirePenalty>0.4</indirectFirePenalty>
<targetParams>
<canTargetLocations>true</canTargetLocations>
</targetParams>
</li>
</verbs>
</value>
</Operation>


</Patch>
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static bool CanReload(Pawn pawn, Thing hopefullyTurret, bool forced = fal
CELogger.Message($"{pawn} could not reload {turret} because turret is manned (or was recently manned) by someone else.");
return false;
}
if (FindBestAmmo(pawn, turret) == null)
if (compAmmo.UseAmmo && FindBestAmmo(pawn, turret) == null)
{
JobFailReason.Is("CE_NoAmmoAvailable".Translate());
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,10 @@ public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
if (!(t is Building_TurretGunCE)) {
return false;
}
var priority = GetThingPriority(pawn, t, forced);
CELogger.Message($"Priority check completed. Got {priority}");

Building_TurretGunCE turret = t as Building_TurretGunCE;
CELogger.Message($"Turret uses ammo? {turret.CompAmmo.UseAmmo}");
if (!turret.CompAmmo.UseAmmo)
return true;

CELogger.Message($"Total magazine size: {turret.CompAmmo.Props.magazineSize}. Needed: {turret.CompAmmo.MissingToFullMagazine}");
CELogger.Message($"Total magazine size: {turret.CompAmmo?.Props.magazineSize.ToString() ?? "null"}. Needed: {turret.CompAmmo?.MissingToFullMagazine.ToString() ?? "null"}");

return JobGiverUtils_Reload.CanReload(pawn, turret, forced);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ private ThingDef GunDef(StatRequest req)
return def;
}

private Thing Gun(StatRequest req)
{
return (req.Thing as Building_TurretGunCE)?.Gun ?? req.Thing;
}

public override bool ShouldShowFor(StatRequest req)
{
return base.ShouldShowFor(req) && (GunDef(req)?.Verbs?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,19 @@ public Thing Gun
{
get
{
if (this.gunInt == null && Map != null)
if (gunInt == null && Map != null)
{
this.gunInt = ThingMaker.MakeThing(this.def.building.turretGunDef, null);
this.compAmmo = gunInt.TryGetComp<CompAmmoUser>();
GetOrCreateGunInt();

InitGun();

// FIXME: Hack to make player-crafted turrets spawn unloaded
if (//Map != null && !Map.IsPlayerHome
//!Faction.IsPlayer
(!Map.IsPlayerHome || Faction != Faction.OfPlayer) && compAmmo != null)
if (!Map.IsPlayerHome || Faction != Faction.OfPlayer)
{
compAmmo.ResetAmmoCount();
compAmmo?.ResetAmmoCount();
}
}
return this.gunInt;
return gunInt;
}
}
public ThingDef Projectile
Expand Down Expand Up @@ -643,6 +640,7 @@ private void InitGun()
CompAmmo.turret = this;
//if (def.building.turretShellDef != null && def.building.turretShellDef is AmmoDef) CompAmmo.selectedAmmo = (AmmoDef)def.building.turretShellDef;
}
gunInt = GetOrCreateGunInt();
List<Verb> allVerbs = this.gunInt.TryGetComp<CompEquippable>().AllVerbs;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you replace this.gunInt with Gun and let the property handle instancing gunInt? That way you won't need GetOrCreateGunInt() anymore, which seems a bit redundant.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that Gun has a bunch of other side effects that I'm not familiar with.

for (int i = 0; i < allVerbs.Count; i++)
{
Expand All @@ -652,6 +650,15 @@ private void InitGun()
}
}

private Thing GetOrCreateGunInt()
{
this.gunInt = this.gunInt ?? ThingMaker.MakeThing(this.def.building.turretGunDef, null);
this.compAmmo = this.compAmmo ?? gunInt.TryGetComp<CompAmmoUser>();

return gunInt;

}

public void TryForceReload()
{
TryOrderReload(true);
Expand Down