Set explosion chance of barrels

11 replies [Last post]
Hoot
User offline. Last seen 4 years 45 weeks ago. Offline
Joined: 2013-12-14
Posts: 51

Barrels are quite hard to get exploded. Even a direct hit with a grenade launcher or an airstrike does not cause them to explode.

It would be great to make the explosion chance customizable ... so a barrel explodes if receiving a certain amount of hits, or even a receiving a gunshot.

Edit OT ohboy, captchas even here ...

Wuzzy
Wuzzy's picture
User offline. Last seen 25 weeks 2 days ago. Offline
Joined: 2012-06-20
Posts: 1304

Technically, it’s not an explosion chance which makes the barrels explode but their health going to 0. They have health similar to hedgehogs but you can’t see it directly. You can tell from the smoke how many health is left. The more smoke, the less health.
From what I can tell from the source code, barrels start with 60 health and I think their health increases when they become frozen.

(Edit: But don’t take my word for it, I am not a Hedgewars developer!)

But I understand your point. Configuring the barrel’s starting health would indeed be a nice thing to have.

Hi, I am a Hedgewars developer. Smile

nemo
nemo's picture
User offline. Last seen 19 weeks 4 days ago. Offline
Joined: 2009-01-28
Posts: 1861

Wuzzy allegedly wrote:

Technically, it’s not an explosion chance which makes the barrels explode but their health going to 0. They have health similar to hedgehogs but you can’t see it directly. You can tell from the smoke how many health is left. The more smoke, the less health.
From what I can tell from the source code, barrels start with 60 health and I think their health increases when they become frozen.

(Edit: But don’t take my word for it, I am not a Hedgewars developer!)

But I understand your point. Configuring the barrel’s starting health would indeed be a nice thing to have.

You're right about the starting health. Freezing a barrel adds an extra 60hp.
Fire is an excellent way to blow up barrels BTW.
Molotov cocktails really do a number on them.

And, yeah, health was deliberately picked so that a direct hit w/ shotgun would not blow them up on starting turn. Thus 60.
Fall damage has been tweaked so you can still bat them and usually get a satisfying explosion.
Firepunch should work too, on a flat surface or to a lower height, although I'd have to recheck it. Might require a slightly lower height.

You can also hammer them down off a girder onto the hogs below, or use a 'nade for it.

A bit of fall damage will put a 'naded barrel which will have like 15hp (or 10hp if you're good at placing), over the edge.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

Hoot
User offline. Last seen 4 years 45 weeks ago. Offline
Joined: 2013-12-14
Posts: 51

Ah, good to know, thanks! I was just a bit confused that a direct hit with mortar or airstrike didn't seem to do much to a barrel.

As wuzzy stated, a feature to set the starting health to a custom value would be great (or even adjusting sensibility to different types of hits like bullets and grenades etc, like it seems to be with fall damange if I understand that correctly), for then could one create some "barrel mayhem" styles which would require players to be REALLY careful ...

So if that is not a big coding issue, it would be very welcome indeed.

BTW OT (don't know where to drop the bucket of flowers): a big, BIG thanks for the Multiplayer implementation. Seldom had a game where multplayer over the internet had been so easy and smooth to set up. Really great job!

nemo
nemo's picture
User offline. Last seen 19 weeks 4 days ago. Offline
Joined: 2009-01-28
Posts: 1861

Well... You could just set 200% damage in the scheme and give hogs 200HP to compensate...
As a bonus hogs will get kicked twice as far for extra mayhem.

It seems a rather minor thing to add an option for.
You could make a custom lua if you wanna try it out tho. Is basically a one-liner.
I'll put it on DLC for you if you like.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

Hoot
User offline. Last seen 4 years 45 weeks ago. Offline
Joined: 2013-12-14
Posts: 51

That'd be great.
It should also be possible to just modify the value of the barrel "health" in the correct file, right? In which (lua?) file is that information stored? It seems I missed the localization instructions of the files, and can't find a matching one in the application package.

nemo
nemo's picture
User offline. Last seen 19 weeks 4 days ago. Offline
Joined: 2009-01-28
Posts: 1861

Barrel health (as well as the health of basically anything) is hardcoded at creation. Is just that lua can manipulate that after creation.
So...
function onGearAdd(gear)
SetHealth(gear,5)
end

in a lua script would set the barrels to 5hp.
They'll smoke like mad ofc.

Lua scripts sometimes take some random scheme variable and use it as a config param. So, for example:

SetHealth(gear,WaterRise)
Would set the health to the water rise during sudden death.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

Vatten
Vatten's picture
User offline. Last seen 1 year 30 weeks ago. Offline
Joined: 2009-09-02
Posts: 48

nemo allegedly wrote:

function onGearAdd(gear)
SetHealth(gear,5)
end

should be:

function onGearAdd(gear)
if(GetGearType(gear)==gtExplosives)
then
SetHealth(gear,5)
end
end

--If you want to set the barrels to 5 health.

Vattenania, my beloved motherland, my beloved homeland! You are always with me in my thoughts and in my heart!

nemo
nemo's picture
User offline. Last seen 19 weeks 4 days ago. Offline
Joined: 2009-01-28
Posts: 1861

My apologies. Vatten is right. Otherwise every single thing (hogs being the biggest problem) would get 5hp.
I blame lack of sleep Wink Smiley

Vatten allegedly wrote:

nemo allegedly wrote:

function onGearAdd(gear)
SetHealth(gear,5)
end

should be:

function onGearAdd(gear)
if(GetGearType(gear)==gtExplosives)
then
SetHealth(gear,5)
end
end

--If you want to set the barrels to 5 health.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

Hoot
User offline. Last seen 4 years 45 weeks ago. Offline
Joined: 2013-12-14
Posts: 51

EDIT Oh sorry, your last comments have not been displayed, therefore I had posted this here; kind of bad cacheing on my side it seems. Thanks for the support! /EDIT

---

So, for example:
In resources/data/scripts add barrel.lua with content:

--
function onGearAdd(gear)
if GetGearType(gear) == gtExplosives then
SetHealth(gear,21)
end
--

Hmmmm ...

nemo
nemo's picture
User offline. Last seen 19 weeks 4 days ago. Offline
Joined: 2009-01-28
Posts: 1861

My Documents/Hedgewars/Data/Scripts/Multiplayer (assuming you are under Windows - ~/.hedgewars/Data/Scripts/Multiplayer for Linux)
or package in a .hwp and put in Data

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

Wuzzy
Wuzzy's picture
User offline. Last seen 25 weeks 2 days ago. Offline
Joined: 2012-06-20
Posts: 1304

nemo allegedly wrote:
You could make a custom lua if you wanna try it out tho.

True, but there’s a downside for using Lua. You can only use one script at a time. You can’t just combine two or more scripts.
Also, you would have to edit the Lua script for each time you want to change the barrel health.
An option in the game schemes would be, on the other hand, much more flexible and easier to use.

Hi, I am a Hedgewars developer. Smile

User login

Copyright © 2004-2024 Hedgewars Project. All rights reserved. [ contact ]