Page 1 of 1

Energy consuming Weapons

Posted: Sun May 07, 2017 5:51 pm
by wlfbck
I was wondering (and actually trying around) if it is possible for weapons to consume energy in any way, preferably instead of using normal ammunition?

Using

Code: Select all

consumption_modifier = 0
with a 1stack ammo is a kinda workaround for the latter part, but adding

Code: Select all

energy_consumption = "1MJ"
to the ammo seems to not do anything. Of course i could check via event (i presume there is one) if the weapon was fired or something similar and substract the energy or something, but probably not cancel the shot. That also seems really... ghetto.

I also had the idea of looking into how the laser turret works. Found that the turret itself has the ammo-category "electric" but the ammunition (which is defined directly there? doesn't work that way for guns) is of category "laser-turret". Strange and unfortunately not helpful.

Appreciating any answers in this regard :)

Re: Energy consuming Weapons

Posted: Sun May 07, 2017 6:10 pm
by 321freddy
Laser and gun turrets actually have different entity types:
  • gun-turret is of type "ammo-turret"
  • laser turret is of type "electric-turret"
So assuming you want to create a new turret which is powered by electricity you set the type to "electric-turret" and then use the energy_consumption inside the projectile definition to adjust it's energy usage. Look at the laser turret definition for an example.

The ammo_category "electric" just tells the game what kind of damage the projectile does, so if your character has an electric damage resistance it will be applied when you get shot by this type of ammo.

Re: Energy consuming Weapons

Posted: Sun May 07, 2017 6:58 pm
by wlfbck
First of all, thanks for the answer!

I realized i probably didn't make it clear, but i want to make a gun, not a turret. I just looked at the laser turret because it's the only weapon in the base game that operates solely on electricity.

The electricity for the gun would come from the power armor.

Re: Energy consuming Weapons

Posted: Mon May 08, 2017 11:26 am
by wlfbck
After looking into it some more, it seems this is just not possible right now. Very sad, but oh well. Hope the devs make that possible at some point :)

Re: Energy consuming Weapons

Posted: Mon May 08, 2017 2:40 pm
by bobingabout
Turrets have 4 entity types (Ammo, Electric, fluid and no input, used by gun turret, laser turret, flame turret and worms respectfully)

Weapons used by the player, or vehicles like car and tank only have one type, Ammo, therefore all consume an item.

Equipment grid weapons also only have one type, Electric, and consume energy from the grid's power supply.


Doing anything different from this doesn't work. however, you can spice things up a bit and make an ammo that shoots combat robots (as long as they don't follow the player, so, distractors work), explosions (like a grenade, or poison capsule) or even biters! (They would be on the team of whoever fired it, so, friendly biters!)

I believe someone, one of the devs, maybe Klonan? made a combat robots mod that includes a gun turret that shoots combat robots. And these robots were actually re-skinned biters with robot weapons.

Re: Energy consuming Weapons

Posted: Mon May 08, 2017 2:57 pm
by 321freddy
I guess you could also use a custom ammo item which you just call "electric charge". Then every few ticks you draw a bit of energy from the players power armor and put a few new "electric charge" items into the ammo slot. You could use the on_player_***_inventory_changed events to prevent the player from moving the "electric charge" ammo out of it's slot. This would definitely be possible, but of course it's just a workaround.

Re: Energy consuming Weapons

Posted: Tue May 09, 2017 12:12 am
by wlfbck
bobingabout wrote:Turrets have 4 entity types (Ammo, Electric, fluid and no input, used by gun turret, laser turret, flame turret and worms respectfully)

Weapons used by the player, or vehicles like car and tank only have one type, Ammo, therefore all consume an item.

Equipment grid weapons also only have one type, Electric, and consume energy from the grid's power supply.


Doing anything different from this doesn't work. however, you can spice things up a bit and make an ammo that shoots combat robots (as long as they don't follow the player, so, distractors work), explosions (like a grenade, or poison capsule) or even biters! (They would be on the team of whoever fired it, so, friendly biters!)

I believe someone, one of the devs, maybe Klonan? made a combat robots mod that includes a gun turret that shoots combat robots. And these robots were actually re-skinned biters with robot weapons.
That sounds pretty funny. What i was/am aiming for is an electrogun in the style of GTA2 (although without the no-damage->5sec->death effect). Actually just now uploaded it.
321freddy wrote:I guess you could also use a custom ammo item which you just call "electric charge". Then every few ticks you draw a bit of energy from the players power armor and put a few new "electric charge" items into the ammo slot. You could use the on_player_***_inventory_changed events to prevent the player from moving the "electric charge" ammo out of it's slot. This would definitely be possible, but of course it's just a workaround.
Interesting idea! Maybe i'll change the implementation to that later on, i made it the traditional way for now.

Re: Energy consuming Weapons

Posted: Tue May 09, 2017 6:36 am
by ShinyAfro
Why not just make as someone said, a battery-type ammo? Perhaps you can script it so when it depletes it spawns a depleted battery cell in your inventory, you would have to "Charge" in an assembler-like machine?

Unless you wanted to have it run from your power armour? Then my guess would be to first have a module to support such a thing, then see if you can run an event every time it fully charges to replace the ammo in the gun with a fresh set of rounds? And call the ammo the "Plug"

The module and ammo would be a cord running from your armour to your gun, plugged in. In theory, anyway.

Re: Energy consuming Weapons

Posted: Tue May 09, 2017 8:13 am
by bobingabout
ShinyAfro wrote:Why not just make as someone said, a battery-type ammo? Perhaps you can script it so when it depletes it spawns a depleted battery cell in your inventory, you would have to "Charge" in an assembler-like machine?
I made a laser weapon that uses laser charges, made from batteries. I'm not sure getting something back works with ammo, it's only just been coded in to work with fuel.

Re: Energy consuming Weapons

Posted: Tue May 09, 2017 10:27 am
by wlfbck
ShinyAfro wrote:Why not just make as someone said, a battery-type ammo? Perhaps you can script it so when it depletes it spawns a depleted battery cell in your inventory, you would have to "Charge" in an assembler-like machine?

Unless you wanted to have it run from your power armour? Then my guess would be to first have a module to support such a thing, then see if you can run an event every time it fully charges to replace the ammo in the gun with a fresh set of rounds? And call the ammo the "Plug"

The module and ammo would be a cord running from your armour to your gun, plugged in. In theory, anyway.
I finished it before i came back to read the thread, unfortunately. The bold part is what i was aiming for originally, which is somewhat possible with 321freddys suggestions. Your last sentence was interestingly enough the first thing that came to my mind too, conceptionally.
bobingabout wrote:
ShinyAfro wrote:Why not just make as someone said, a battery-type ammo? Perhaps you can script it so when it depletes it spawns a depleted battery cell in your inventory, you would have to "Charge" in an assembler-like machine?
I made a laser weapon that uses laser charges, made from batteries. I'm not sure getting something back works with ammo, it's only just been coded in to work with fuel.
Heh, yeah that's basically the ammo model i now used. Good opportunity to thank you for all your great mods btw :)