Energy consuming Weapons

Place to get help with not working mods / modding interface.
wlfbck
Inserter
Inserter
Posts: 47
Joined: Wed Nov 30, 2016 7:04 pm
Contact:

Energy consuming Weapons

Post 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 :)
321freddy
Fast Inserter
Fast Inserter
Posts: 125
Joined: Fri Sep 23, 2016 10:16 pm
Contact:

Re: Energy consuming Weapons

Post 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.
wlfbck
Inserter
Inserter
Posts: 47
Joined: Wed Nov 30, 2016 7:04 pm
Contact:

Re: Energy consuming Weapons

Post 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.
wlfbck
Inserter
Inserter
Posts: 47
Joined: Wed Nov 30, 2016 7:04 pm
Contact:

Re: Energy consuming Weapons

Post 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 :)
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Energy consuming Weapons

Post 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.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
321freddy
Fast Inserter
Fast Inserter
Posts: 125
Joined: Fri Sep 23, 2016 10:16 pm
Contact:

Re: Energy consuming Weapons

Post 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.
wlfbck
Inserter
Inserter
Posts: 47
Joined: Wed Nov 30, 2016 7:04 pm
Contact:

Re: Energy consuming Weapons

Post 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.
ShinyAfro
Inserter
Inserter
Posts: 27
Joined: Mon Jan 04, 2016 1:27 pm
Contact:

Re: Energy consuming Weapons

Post 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.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Energy consuming Weapons

Post 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.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
wlfbck
Inserter
Inserter
Posts: 47
Joined: Wed Nov 30, 2016 7:04 pm
Contact:

Re: Energy consuming Weapons

Post 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 :)
Post Reply

Return to “Modding help”