Turret using different kinds of ammo?

Started by Syrus, September 05, 2020, 08:21:08 PM

Previous topic - Next topic

Syrus

I was wondering if there is a(n easy) way to make turrets use different kinds of ammo with different kinds of effects without the use of coding, or whether there is a not too complicated way for accomplishing this?

Seeing as defaultProjectile is part of the weapon for turrets, is there a "non-defaultProjectile"?

Then again, I'm not completely averse to coding, it's just that I was wondering if there was a simpler solution or maybe some tipps on how to achieve it.
EDIT: Thinking about this, if it is only possible via code, I'm pretty sure I know how to do switching between different projectiles, but not how to have more than one "fuel" storage for different kinds of ammo. Of course I could just figure out a way to have just one fuel, but that kind of defeats the whole purpose of "different kinds of ammo". Hm...difficult decision.

RawCode

you should write down entire "logic" behind "use different kinds of ammo"

what will happen when turret shoot (and have multiple kinds of ammo loaded)
what will happen when turret need reload (and multiple kinds of ammo available)
how pawns determinate what kind of ammo to haul
what will happen if multiple different types of ammo loaded
how to display multiple different types of ammo

and any other moment related to your question

after that, i hope, you will get obvious answer, no it's not possible to implement something like this without coding.

and with coding it will be somewhat complex, especially if you want your turrets to use "best" type of ammo vs each target, like AP vs heavy armor and HP vs soft.

LWM

I wrote a mod that allows using more than one fuel, but it was designed to use both fuels at the same time.  Still, you could probably (maybe) use it fairly easily to get multiple fuel types that are consumed selectively (may require some finesse).

If you're interested, it's at https://github.com/lilwhitemouse/RimWorld-LWM-Multi-Fuel-Requirement/ - it's licensed under the LGPL; it's that's a problem let me know.

Syrus

My intention was to have a turret which can fire different kinds of projectiles, using shells as "ammo".
As it sounds like this is only doable in code and there isn't another node besides "defaultProjectile".


First part would be to add a button to the UI for that turret.
From another mod I modified I know how to add new elements to the UI, not sure about a button, but I feel like it can't be too difficult.

This button would then allow for toggling between different projectiles / firing modes.
My first thought was that it could just replace the bullet used by the turret, but I would love to try out a shotgun-kind of turret, which would require modifying the burstShotCount (and maybe ticksBetweenBurstShots) of the turret's gun as well. Doubt this is impossible just need to figure out how to replace and modify the parts I want to change.

The big problem is at the same time also just a "nice to have", to be honest.
I would like to have the turret use a different ammo depending on the projectile chosen.
The one currently active would be the one displayed, and colonists would deliver that ammo. Of course it would be even nicer if all used ammos was displayed and pawns delivered all of them. This would probably require a lot of code magic, switching the storages or such...
Considering the problems that arise from it all, I'm second guessing whether this is actually a good idea to try to implement. It would probably be a lot easier to just go with the normal "ammo" as in other turrets and just use something like Uranium or such to "fuel" the gun.

So let's ignore the complicated storage problem.


Why did I write this post at all then?
I was wondering if there was an easy way of doing that because of the "default" part in "defaultProjectile".
Of course I also welcome any advice for making the switchable-projectiles work and what to look out for.
Haven't yet taken a look into how to actually do this, hopefully I'll get around to trying some stuff soon, sounds like a fun idea.


@LWM
You posted while I was typing up the post (yeah, I had something to eat inbetween, took some time :p ), I'll have a look at the code.
Since it's entirely for personal use only, and won't be released to the public, the license shouldn't be a problem?!
Just like to see what I can do, it usually ends up overpowered anyway!

Canute

Give the turret a rearm/refuel button, that turn the existing turret into a new one with the new stats for the new ammo.
Ok that is something you can't do with xml, so you would need to use c# i think.

RawCode

C# is not something evil or over complicated, there are no reasons to avoid it.