Home   Help Search Login Register  

Author Topic: JBOY_barrel_boom: Exploding barrels (ACCEPTED)  (Read 2875 times)

0 Members and 1 Guest are viewing this topic.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
JBOY_barrel_boom: Exploding barrels (ACCEPTED)
« on: 12 Dec 2008, 07:14:32 »
Here's a fun script I've been selfishly sitting on to include in my mission sequel to Last Tango In Bagango.  Since that is going way too slow, it's time I released this simple script.

This script causes a barrel to explode and launch after the barrel has been killed.  Time between burning and exploding varies, which makes it more fun IMO (like a HL2 barrel).  There is a small chance of a barrel having a second explosion also.

Try the attached sample mission.

From the comments in the script:

Code: [Select]
; ****************************************************************
; JBOY_barrel_boom.sqs by johnnyboy
;
; This script will cause barrels to burn a few seconds, then explode.
;
; To use, put the following code in the barrel's init field:
;
;  this addeventhandler ["killed",{ _this exec "JBOY_barrel_boom.sqs";}]
; ****************************************************************

Modified script uploaded 12/13/2008 per spoonman's suggestions for mid-air explosions.

OFPEC Download
« Last Edit: 06 Feb 2009, 18:10:21 by hoz »
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: JBOY_barrel_boom: Exploding barrels
« Reply #1 on: 12 Dec 2008, 08:18:07 »
Well, that was a nice bit of fun! Always nice, too, when someone digs in the scripting closet to find a solution to a problem that someone else is having.

Explosives don't magically explode in mid-air, since they require something to collide with to detonate them. You might try creating a "weaponholder" (large invisible object, but solid enough to detonate explosive rounds) temporarily at the same position as the ammo you create. Also remember that when you use createVehicle, the engine always places the object in a non-colliding position as near to the requested position as possible. If you want to force a collision, then setPos the object into the required position immediately after creating it (setPos ignores geometry - it is absolute).

Seems that this would work fine in MP, so no worries there (strictly you don't even need the "?(!isServer): exit;" clause, since KILLED handlers for inanimate objects will only ever be run on the server. However, it is worth leaving it in as it makes it clear to the reader that it is a server-side script).

To run the script, you can just use (without altering the script):
Code: (barrel init line) [Select]
this addeventhandler ["killed",{ _this exec "JBOY_barrel_boom.sqs";}]
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline schuler

  • Contributing Member
  • **
Re: JBOY_barrel_boom: Exploding barrels
« Reply #2 on: 12 Dec 2008, 12:56:41 »
well its nice to know some thinks never change. this guy just plain likes to blow things up!
I think I will though this in First Response as a hidden ied type of deal. I might as well i got the backpack bomb going off too!
  Hey a good word for the long trails of smoke is flagellum 
nice work JBOY!!!!!!

And a quote I got a kick out of by spooner ~ Explore the vast undersea kingdom at last...and blow it up!
Fire, Fire, schuler
Semper Fi

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: JBOY_barrel_boom: Exploding barrels
« Reply #3 on: 12 Dec 2008, 17:22:45 »
A similar script was my only OFPEC approved script resource for OFP, but was lost in the Great Flood.  The OFP barrels were more fun, because they were light and responded to physics better, so when one exploded near by, the physics engines launched the nearby ones, which would then explode somewhere else.  I miss those bouncing barrels!

Spooner:  Thanks for the MP feedback, and the simplified init line.  I was worried that my use of Random would cause the barrels to launch in different directions on different clients.  But if Killed event is server side, then I guess its not a problem...

Regarding mid-air collisions, mando helped me out before on similar problem, and suggested a computer object for collision.  It worked, but sometimes you could see it for a split second.  Invisible weapon holder sounds like a better solution.  At that time, I also found that you want to setpos shell to modelToWorld [0,0,0] of collision object instead of pos of collision object, because some percentage of time setpos would put shell immediately beneath collision object, and fall to ground.

When I get some time, I'll work on the mid-air explosions--they make the effect more fun.

Schuler:  "Flagellum"...lol...that's my word for the day!  Yes, its true, I do like blowing stuff up...  I look forward to seeing this in action in First Response!

El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...