[1.1] SimpleSidearms (1.4.0)

Started by PeteTimesSix, May 16, 2017, 04:21:35 PM

Previous topic - Next topic

SpaceDorf

Quote from: Oblitus on August 20, 2017, 09:47:44 AM

- Use mod to make your animals actually haul
- Unforbid it
- Your pawn will pick it up from safe warehouse instead of walking into zombie horde

- I have heard somebody made something like that ..
- Animals were busy rescuing pawns
- Animals got blocked from hauling because asshat pawn reserved the weapon for pickup ..
Maxim 1   : Pillage, then burn
Maxim 37 : There is no overkill. There is only open fire and reload.
Rule 34 of Rimworld :There is a mod for that.
Avatar Made by Chickenplucker

DukeAl

#136
Hi,
I get an error in the debug log when using your mod. I have uploaded the output_log.txt here: https://gist.github.com/4defbd44a3af9276382747b69f86aa67
I'm using your latest version (1.2.1) together with CE (0.17.1.4c) and a bunch of other mods.
And of course thank you for this great mod :)

PeteTimesSix

#137
Quote from: BeoTea on August 17, 2017, 08:53:47 PM
Thanks, now I've gotta find a reason why SS wont work for me. When I turn it on, the debug menu pops up and there's lots of red. Time to learn what red means.
It means you're getting exceptions and should press that little copy button in the corner and let me see it, ideally along with a modlist and a savegame  :D
Quote from: DukeAl on August 20, 2017, 03:33:36 PM
Hi,
I get an error in the debug log when using your mod. I have uploaded the output_log.txt here: https://gist.github.com/4defbd44a3af9276382747b69f86aa67
I'm using your latest version (1.2.1) together with CE (0.17.1.4c) and a bunch of other mods.
And of course thank you for this great mod :)
See, this guy gets it. Fix'd.

Quote from: [email protected] on August 19, 2017, 11:56:09 PM
Don't use this mod with zombieland. My pawns keep going back to collect their weapons = dead pawn. :(
Unfortunately given how the AI works I can only make recovering sidearms more or less important than ALL the work assignments (including bed rest).
Unless invisible work tabs are a thing, which they may very well be. I'll check at some point (but not soon; I've got other things to attend to, not the mention I really should get around to being a Responsible Adult soon).
Mods: SimpleSidearms | QOLTweaksPack
Check them out, feedback and suggestions are welcome.

sirgzu

Hi great mod! Just wondering, could it work for tools?

There are a bunch of mods that add tools (i.e melee weapons) that increase certain task efficiency. Would be great if the pawns were smart enough to switch to the right tool when carrying out a specific task.

Currently I have to leave them with the tool selected and manually change when I draft them but this is dangerous since pawns set to autocombat threats will rush to fight with their underpowered tools instead of automatically switching to ranged (dunno if they'd switch to stronger melee if available).

Alternatively giving the option to autoswitch from melee to ranged when not drafter would alleviate this, albeit reducing pawns to using a single tool instead of carrying a choice of different tools.

SpaceDorf

Quote from: sirgzu on August 21, 2017, 07:59:11 AM

Alternatively giving the option to autoswitch from melee to ranged when not drafter would alleviate this, albeit reducing pawns to using a single tool instead of carrying a choice of different tools.

The Mod has a Hugslib Menu, you can set a autoswitch option for ranged weapons.
Works fine for my pawns.
Maxim 1   : Pillage, then burn
Maxim 37 : There is no overkill. There is only open fire and reload.
Rule 34 of Rimworld :There is a mod for that.
Avatar Made by Chickenplucker

sirgzu

Quote from: SpaceDorf on August 21, 2017, 08:47:21 AM
Quote from: sirgzu on August 21, 2017, 07:59:11 AM

Alternatively giving the option to autoswitch from melee to ranged when not drafter would alleviate this, albeit reducing pawns to using a single tool instead of carrying a choice of different tools.

The Mod has a Hugslib Menu, you can set a autoswitch option for ranged weapons.
Works fine for my pawns.
I might have gotten that wrong but for me they switch *between* ranged weapons.
if they have a melee weapon as main, they will attack with that and won't switch to ranged.
Could be a bug idk.. I definitely had a look in the options. I'll check again tonight.

The13thRonin

Anyone know if this works with Skyangels Hardcore Modpack HCSK?

sirgzu

#142
I can confirm there is a bug with the ranged weapon selection logic.

pawns will only switch ranged weapons when they detect a threat in their currently equipped weapon range area instead of considering their side weapons range.
This also explains why when you have a melee weapon equipped you'll never switch to ranged.

Also idk what's the formula for computing weapon preference but I'm not sure it's taking burst shot count into consideration.
I attached two weapons for comparison, with default settings the game favours the mosin-nagant over the ppsh up to 8 tiles close.
according to my calculations, the ppsh is the winner at any range, here it goes:
ppsh: 8(dmg)*10(burst)/(1.9(warmup)+2.2(cooldown))*0.3(accuracy,long) = 5.85(dmg/s) worst case scenario
mosin: 17(dmg)/(1(warmup)+1.7(cooldown))*0.86(accuracy,medium) = 5.41(dmg/s) best case scenario
the pawn should keep using ppsh until max(19)range and switch to mosin beyond that. am I missing something?

[attachment deleted by admin: too old]

PeteTimesSix

#143
Quote from: sirgzu on August 21, 2017, 02:38:13 PM
I can confirm there is a bug with the ranged weapon selection logic.

pawns will only switch ranged weapons when they detect a threat in their currently equipped weapon range area instead of considering their side weapons range.
This also explains why when you have a melee weapon equipped you'll never switch to ranged.

Thats not a bug, its a lack of a feature. At one point I spent like two weeks trying to get it to work - it was just too much of a buggy mess and never worked quite right.

Quote from: sirgzu on August 21, 2017, 02:38:13 PM
Also idk what's the formula for computing weapon preference but I'm not sure it's taking burst shot count into consideration.
I attached two weapons for comparison, with default settings the game favours the mosin-nagant over the ppsh up to 8 tiles close.
according to my calculations, the ppsh is the winner at any range, here it goes:
ppsh: 8(dmg)*10(burst)/(1.9(warmup)+2.2(cooldown))*0.3(accuracy,long) = 5.85(dmg/s) worst case scenario
mosin: 17(dmg)/(1(warmup)+1.7(cooldown))*0.86(accuracy,medium) = 5.41(dmg/s) best case scenario
the pawn should keep using ppsh until max(19)range and switch to mosin beyond that. am I missing something?

One thing to know is the DPS calculation takes into account the current distance to the target. Burst shot should be accounted for (though I might be wrong, its been a while since I wrote that function). Lets see...

VerbProperties atkProps = atkVerb.verbProps;
           
            if (atkProps.range * atkProps.range < range || atkProps.minRange * atkProps.minRange > range)
                return -1;

            float damage = (atkProps.projectileDef == null) ? 0 : atkProps.projectileDef.projectile.damageAmountBase;
            float warmup = atkProps.warmupTime;
            float cooldown = weapon.def.GetStatValueAbstract(StatDefOf.RangedWeapon_Cooldown, null);
            int burstShot = atkProps.burstShotCount;
            int ticksBetweenShots = atkProps.ticksBetweenBurstShots;
            float rawDps = (damage * burstShot) / (((warmup + cooldown)) + warmup * (speedBias - 1f) + (burstShot - 1) * (ticksBetweenShots / 60f));
            float Dps = rawDps * GetHitChanceFactor(atkProps, weapon, range);

            return Dps;

Right. There's the speed bias (to favor faster weapons so you actually get shots off at close range before getting interrupted by melee attacks) and after a point in the warmup is reached the shot wont be interrupted anymore (there's config options for both). The rest of it? I think I nicked it from the vanilla's game DPS stat calculator...
Mods: SimpleSidearms | QOLTweaksPack
Check them out, feedback and suggestions are welcome.

sirgzu

#144
Quote from: PeteTimesSix on August 21, 2017, 06:27:13 PM
Right. There's the speed bias (to favor faster weapons so you actually get shots off at close range before getting interrupted by melee attacks) and after a point in the warmup is reached the shot wont be interrupted anymore (there's config options for both). The rest of it? I think I nicked it from the vanilla's game DPS stat calculator...
Ok it makes sense I guess. It is not clear in the options how the speed bias impacts the decision...
A few questions about the formula, I hope you don't mind ;)
- why speedBias - 1f ? Default value is 1.25 which I would interpret as 125% but that's just me...
- why + warmup * (speedBias - 1f) + (burstShot - 1) * (ticksBetweenShots / 60f)) I can't make sense of this at all
The formula to me would look more like:
float rawDps = (damage * burstShot) / (((warmup * (1/speedBias)  + cooldown));

PeteTimesSix

#145
Well, like I said, the formula is based on Rimworld's own DPS formula, which I think is this (its been a while, I didnt remember where it was and I found this by searching the code for " dps", so...)

int num = burstShotsGetter(d);
float num2 = warmupGetter(d) + cooldownGetter(d);
num2 += (float)(num - 1) * ((float)d.Verbs[0].ticksBetweenBurstShots / 60f);
return (float)(damageGetter(d) * num) / num2;

Yeah. Given the helpful variable names (Im sorry decompiler, I know you tried your best), I didn't want to make too many changes to the formula if I could help it, especially while I was writing it (I think I rewrote this function like three times before it started working?). That's why the speed bias is in its own little addition (warmup + 0.25 * warmup comes out at 1.25 warmup just like it should). Everything after the division sign is time between firing cycles (The warmup time, cooldown, bursting time). There's one less burst shot at the end because that part of the formula is counting the time between burst shots (with a five round burst you have four gaps) and the time between shots is divided by sixty because I dont know ask Tynan.

Like I said, it took me a few tries to get this right (and like fifteen minutes to figure out again just now). Its not the most intuitive formula.
Mods: SimpleSidearms | QOLTweaksPack
Check them out, feedback and suggestions are welcome.

sirgzu

Ok I had another look and it makes sense actually... I'll try again with all weights set to 1 and it should favour the ppsh hopefully. There is another aspect you're not taking into account, it is whether the target is rushing to melee or not.

If the target is going to melee, the actual distance until the weapon has warmed up and is ready to fire will be a few tiles shorter, that might be why there seems to be a bias towards the mosin.

DukeAl

Quote from: PeteTimesSix on August 21, 2017, 07:25:04 AM
Quote from: DukeAl on August 20, 2017, 03:33:36 PM
Hi,
I get an error in the debug log when using your mod. I have uploaded the output_log.txt here: https://gist.github.com/4defbd44a3af9276382747b69f86aa67
I'm using your latest version (1.2.1) together with CE (0.17.1.4c) and a bunch of other mods.
And of course thank you for this great mod :)
See, this guy gets it. Fix'd.
Thank you for the quick fix

sirgzu

I keep getting problems with pawns not switching weapons when they should. I checked the options are checked correctly. This could be due to some mod conflict... If you have any idea what other mod could clash with this one that would help me investigate. I'm not using CE at the moment.

Luckspeare

Reporting a bug that seems like it's related to your mod.  Accidentally loaded some stone chunks onto a caravan pack animal, and when I try to unload it from him, it fails and produces this error just once.  Afterward, attempting again doesn't produce the error/log entry again, but it just silently fails.

Exception filling tab RimWorld.ITab_Pawn_Gear: System.NullReferenceException: Object reference not set to an instance of an object
at SimpleSidearms.intercepts.ITab_Pawn_Gear_InterfaceDrop_Prefix.InterfaceDrop (RimWorld.ITab_Pawn_Gear,Verse.Thing) <0x00041>
at (wrapper dynamic-method) RimWorld.ITab_Pawn_Gear.InterfaceDrop_Patch3 (object,Verse.Thing) <0x00037>
at (wrapper dynamic-method) RimWorld.ITab_Pawn_Gear.DrawThingRow_Patch1 (object,single&,single,Verse.Thing,bool) <0x0037a>
at RimWorld.ITab_Pawn_Gear.FillTab () <0x00ace>
at Verse.InspectTabBase/<DoTabGUI>c__AnonStorey450.<>m__65A () <0x000e3>

Verse.Log:Error(String)
Verse.Log:ErrorOnce(String, Int32)
Verse.<DoTabGUI>c__AnonStorey450:<>m__65A()
Verse.ImmediateWindow:DoWindowContents(Rect)
Verse.<WindowOnGUI>c__AnonStorey2C5:<>m__1B1(Int32)
UnityEngine.GUI:CallWindowDelegate(WindowFunction, Int32, GUISkin, Int32, Single, Single, GUIStyle)