Home   Help Search Login Register  

Author Topic: A script for barrels to explode  (Read 1671 times)

0 Members and 1 Guest are viewing this topic.

Offline Captain Crunch

  • Members
  • *
A script for barrels to explode
« on: 03 Apr 2007, 14:34:35 »

Hi, in OFP, to sparkle up some missions, I used to have this script that made barrels explode if they were hit too many times. I try to use it in ArmA but it doesn't work. I know that CamCreate was replaced by CreateVehicle but there must be something else  I do wrong. Please help.

This is what the script looks like:

Code: [Select]
;In Init field type : [] Exec "Script.sqs"

_Barrel = _This Select 0

#Loop
? (GetDammage _Barrel > 0.05) : GoTo "Kaboom"
~1
GoTo "Loop"

#Kaboom
Bang = "HandGrenade" CreateVehicle GetPos _Barrel
~6
Bang = "SmokeShell" CreateVehicle GetPos _Barrel

Exit

Thanx in advance.
« Last Edit: 03 Apr 2007, 18:24:39 by bedges »
Back to the forest!

Offline Cheetah

  • Former Staff
  • ****
Re: A script for barrels to explode
« Reply #1 on: 03 Apr 2007, 14:44:45 »
Please use the code and /code tags to make the code easier to read.

Will test this script, no errors displayed by the engine in the top left corner?

EDIT: after a few shots on the barrel it catches fire. The script seems to do nothing, except for producing white smoke?
EDIT1: the smoke shell does indeed get created, I don't think that the class name for the hand grenade it correct.
EDIT2: haven't found the correct classname for a handgrenade, but I think that it's the problem as using a Sh_122_HE shell (artillery round) instead almost killed me.

Can't find classname to let the code work, maybe someone else knows the howto..
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Captain Crunch

  • Members
  • *
Re: A script for barrels to explode
« Reply #2 on: 03 Apr 2007, 15:25:26 »
Thank You for the swift reply Cheetah.

That is weird. I tried with the Sh_122_HE instead and it still doesn't work. And if I get it right, the script seems to work with You since, I quote:
Quote
The script seems to do nothing, except for producing white smoke?

The script doesn't work at all for me. I get no explosions, no white smoke, nothing. The way I do it is I type in every Init field of the barrels I put in the mission:
Code: [Select]
[] Exec "Barrels.sqs"
Anyone knows why I get no results. It used to work great in OFP.
Back to the forest!

Offline Cheetah

  • Former Staff
  • ****
Re: A script for barrels to explode
« Reply #3 on: 03 Apr 2007, 15:39:05 »
I put this activation code in the init of the barrel: [this] exec "script.sqs";

Attached is the working mission.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: A script for barrels to explode
« Reply #4 on: 03 Apr 2007, 20:23:11 »
Classnames for the grenades are : "HandGrenade" and "HandGrenadeTimed".

However you need to use the ammo classname instead of the magazine classname.

"GrenadeHand"
"GrenadeHandTimed"


Planck
I know a little about a lot, and a lot about a little.

Offline Captain Crunch

  • Members
  • *
Re: A script for barrels to explode
« Reply #5 on: 03 Apr 2007, 20:53:36 »
Thank You guys. This works great.
Back to the forest!

Offline F2kSel

  • Members
  • *
Re: A script for barrels to explode
« Reply #6 on: 04 Apr 2007, 01:53:32 »
I do something similar.


Code: [Select]
;  Use this to call the script directly
; [unit,delay,ammo] exec "DamSmoke.sqs"   ie. in a trigger
;unit = oil drum
;delay= time before explosion
; ammo= the type of explosive

; Or Place this in the init line of and object or unit
; I find Oil drums work best.
; this addEventHandler ["hit",{[_this select 0,4,"G_30mm_HE"] exec "DamSmoke.sqs"}]


_veh=_THIS SELECT 0
_delay=_this select 1
_charge =_this select 2
_veh removeAllEventHandlers "hit"
_veh setdamage 1


; rnd=delay before exploding
_rnd= random _delay
~_rnd

; crate the bang
BOMB1 = _charge createVehicle getpos _veh


; I had some slight lag  with the object moving before exploding
~0.2

; some items just wont move or need more inertia
_veh setvelocity[-4+(random 8),-4+(random 8),random 16]

exit

I like to use the velocity command to make the object a little lighter it helps them get off the ground.
It's looks good if you group a few together and place them on the side of a hill.

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: A script for barrels to explode
« Reply #7 on: 04 Apr 2007, 02:30:25 »
I have a script similar to this.

I think I found a bug with large explosives that have been made using createvehicle.

I got about 5 people on a dedicated server and ran a script to spawn an lgb at each of their feet. Everyone, including the dedicated server crashed to desktop.

Hopefully you won't have this problem with the grenade.