Increase range of all weapons?

Started by Shurp, May 17, 2018, 06:49:38 PM

Previous topic - Next topic

Shurp

I'm looking for the best way to increase the range of every projectile weapon in the game to 60 to end the annoyance of scythers parking *just* outside of the range of your weapons.  Right now the only ways I know to do it are either to copy the whole weapon file (Weapons_Guns.xml) and edit every range or create a monster patch file that updates verbs/li/range for each weapon.

Is there some way I can edit BaseHumanMakeableGun, stick a range modification in there, and have it inherited by every weapon?  I've already done a similar mod to ApparelBase/statBases/SellPriceFactor but that attribute already existed in ApparelBase.
If you give an annoying colonist a parka before banishing him to the ice sheet you'll only get a -3 penalty instead of -5.

And don't forget that the pirates chasing a refugee are often better recruits than the refugee is.

Canute

If you got a editor with macro function just search for range, move 2 cells right mark the number and replace it with 60, then repeat the macro.

But beside that, i wouldn't use range 60, Rimworld can't draw the circle with 60, i think 55 is max. so i would use range 50.


Shurp

Sure, I can do a search operation on "<range>" and type over each and every entry, but then I have to copy the whole Weapons_Guns.xml into my mod directory.  I was hoping for an easier / more aesthetic fix.
If you give an annoying colonist a parka before banishing him to the ice sheet you'll only get a -3 penalty instead of -5.

And don't forget that the pirates chasing a refugee are often better recruits than the refugee is.

PatrykSzczescie

Use the advantage which scythers don't use - cover. Sniper rifles have a longer range, but if you have no shooters - sucks2bu. Another alternative is EMP shells and grenades.

jamaicancastle

You can write an xpath that says "all nodes that have a parent of X", though you'd have to have several for all the possibilities: BaseGun, BaseMakeableGun, BaseHumanGun, etc. and it might or might not work with other mods.

There are a couple of ways to solve this in C# as well. For instance, you could write a method that will find every gun in the def database and overwrite its range, all in one go.

Shurp

#5
Quote from: jamaicancastle on May 18, 2018, 03:37:59 PM
You can write an xpath that says "all nodes that have a parent of X"

Thanks jamaicancastle, this sounds like exactly what I'm looking for.  But what would the actual syntax of this be like?

For my clothing patch, I have:

<xpath>/Defs/ThingDef[@Name = "ApparelBase"]/statBases/SellPriceFactor</xpath>

Which allows me to change all clothing to a sellpricefactor of 1.0 (I hate the clothing sale penalty)

Would something like this:

<xpath>/Defs/ThingDef[@Name = "BaseHumanMakeableGun"]/verbs/li/range</xpath>

be effective?

I guess I could just try it and see what happens :)  But I thought maybe someone would actually know and correct my mistakes before I blunder into them.
If you give an annoying colonist a parka before banishing him to the ice sheet you'll only get a -3 penalty instead of -5.

And don't forget that the pirates chasing a refugee are often better recruits than the refugee is.

jamaicancastle

I don't think you can patch that in the parent, since it will just be overwritten by individual defs. However, you can target the ParentName attribute the same way you do the Name attribute, so your xpath will look something like this:

<xpath>/Defs/ThingDef[@ParentName = "BaseHumanMakeableGun"]/verbs/li/range</xpath>

That will target all defs that inherit directly from BaseHumanMakeableGun. Like I said before you'll want to look through the core guns and see what parents they use so that you catch them all. (Or maybe exclude some, like grenades.) This will only match the direct parent, it won't travel further down the inheritance chain.

Shurp

Hey hey!  That worked!  Thank you!

I should quit while I'm ahead... but I have to ask... *how* did it work?  These "Name" and "ParentName" and "@" thingies, what are they all about?  (I hope I'm not wading in way over my head here)
If you give an annoying colonist a parka before banishing him to the ice sheet you'll only get a -3 penalty instead of -5.

And don't forget that the pirates chasing a refugee are often better recruits than the refugee is.

Shurp

Urk... and I have one more question.  Why does a pump shotgun have an accuracy of 64 at long range that it's not supposed to be able to reach?  Doesn't the medium range accuracy of 77 take care of hitting targets to range 16?
If you give an annoying colonist a parka before banishing him to the ice sheet you'll only get a -3 penalty instead of -5.

And don't forget that the pirates chasing a refugee are often better recruits than the refugee is.

jamaicancastle

Name and ParentName are XML attributes. Xpath refers to them using the @ condition. All the xpath does, basically, is provide a set of conditions for the patcher; the xpath you used basically breaks down to "is this node a range, that's inside an li, inside a verbs, inside a ThingDef with a ParentName attribute of 'BaseHumanMakeableGun'?" For every node that matches that exact set of characteristics, it performs the operation (probably a Replace in this case).

The key parts are a) if multiple nodes match all the conditions, the patch will happen to all of them and b) pretty much anything that would distinguish one XML node from another can be used as part of the condition.

As for the pump shotgun having a long-range accuracy - completeness, I assume. This way if the range ever changes to be above 16, it will work the way you'd expect instead of doing something odd.

Shurp

Except it is odd for a shotgun to be able to hit anything accurately at long range :)  Anyway, I manually edited it down to something sensible (25%) so I'm happy now.

And thank you for the explanation, that makes sense!  And thanks for all the help!  I look forward to raiders with pistols trying (and mostly failing) to plink my colonists to death at long range with pistols and SMGs... which I think is how real raiders would behave, rather than charging to their death across an open field to get close enough for a good shot.
If you give an annoying colonist a parka before banishing him to the ice sheet you'll only get a -3 penalty instead of -5.

And don't forget that the pirates chasing a refugee are often better recruits than the refugee is.