OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Gooner861 on 11 Jun 2004, 21:39:26
-
If u had a mission where u had to be carfeul that u did not shoot barrels placed around cos they were explosive or had chemicals in them etc, is there a way to make it explode if a stray bullet hits it?
-
Read the eventhandler tute by unknown-guy-that-armsty-doesn't-remember. Should get you watch you need. Ooooo! That with a nice wiz-wiz-bullet script could make a nasty habit for the AI. :D
:beat: *Gets Shot* :beat:
-
Complicated stuff. I'll have to read the tute by IGOR DRUKOV about 20 times to understand it. Thanks. I'll eventually understand it, i think.
-
I don't think an addeventhandler "hit" work on objects like a barrel, only humans and sometimes vehicles
use
?getdammage barrel > 0.1 : ....BOOOM!!
-
I have used this on many maps:
in the initialization block of the barrel put
[this]exec "barrboom.sqs"
then
;;barrboom.sqs
?!(local Server): Goto "end"
_barr=_this select 0
_shell = "heat125"
_barr setdammage .7
#start
?(getdammage _barr)<.75:goto "start"
_shell = "heat125" camcreate (getpos _barr)
#end
Exit
you can obviously tinker with the setdammage and getdammage to make the barrels more or less volitile, and the _shell type to make them more or less explosive
-
Hello all!
Grendel made just such a script that launches the barrels into the air after exploding and will even catch nearby troops on fire! Enjoy! ;D
Wadmann
-
Thanks for the help people.
Zombie i tried ur script but it didnt work ???.
Wadmann cud u explain those scripts please cos im abit unsure as how to activate them, wot names to give etc.
Thanks.
-
hey!!!
Gooner m8, maddmatt has created an exploding barrel script and it is pretty damn good... I'll post it 2moz after i ask his permission or ill get him 2 do it... ;D
sim
-
EH Hit works on everything I belive. Once did a bomb and when you shot it (EH Hit), it would've exploded.
:beat: *Gets Shot* :beat:
-
I'm not wadmann, but here's how the script works:
create a few barrels on the map you want to explode once they take damage. Give them all a name (barrel1, barrel2, barrel3, barrel4)
now add (or create) the init.sqs in your mission folder:
barrellist=[barrel1, barrel2, barrel3, barrel4]
{_x addeventhandler [{hit},{_this exec {explode.sqs}}]} forEach barrellist
You see, just add all the barrels you want to script to run on in the barrellist.
now you only have to make sure the explode and burn scripts are in your mission folder too.
(little add, comment this line in explode.sqs:
;player sidechat format["%1",_dammage]
to get rid of the player side chat .
gl with this nice script!
-
Ok so ive dun as it says but each time a preview an error comes up saying there is an invalid number in this :
{_x addeventhandler [{hit},{_this exec {explode.sqs}}]} forEach barrellist
-
Try this:
{_x addeventhandler ["hit",{_this exec "explode.sqs"}]} forEach barrellist
Planck
-
Nah its still comes up with an error message.
By the way im using the mission.sqm that comes with the scripts. In it there is a trigger with this in the On activation field:
if ({man} counttype [_x] == 1) then {[_x] exec {burn.sqs}}"" forEach thislist
Dunno if that will help at all.
-
I think this is gonna help you ;)
{_x addeventhandler [{hit},{(_this select 0) exec {explode.sqs}}]} forEach barrellist
-
Hello Gooner861!
As this is not my script, I can't add much to the discussion other than add/ask this:
{_x addeventhandler [{hit},{_this exec {explode.sqs}}]} forEach barrellistThis is the line from my working demo mission with no errors so it should work for everyone else.
Did the demo work for you and did you then merge the demo into you own mission in order to get this error?
Did you add an array for "barrellist" in the init and also name the barrels correctly?
What version of OFP are you running? I received no errors with 1.96.
Oh yeah, where was the !#! looking error marker in the line of code? That usually will dial me into just the part that is wrong.
Ok so ive dun as it says but each time a preview an error comes up saying there is an invalid number in this :
{_x addeventhandler [{hit},{_this exec {explode.sqs}}]} forEach barrellist
As most of the commands in this line of code do not return a number as a value, I can only guess that it has to do with the forEach command and therefore the "Barrellist" but guess is the operative phrase here. Maybe Grendel will stop by and clear this up for everyone! ;)
Wadmann
-
I don't get it that what I posted doesn't work for you. I just cut and pasted out of my post and it works, anyway, attached is an example mission that may help you. Much less complex than eventhandlers
-
I'll tell you wot i did Wadmann.
Got all the files and put it into a mission folder. Previewed the game and the error came up. I named the barrels:
b, b_1, b_2, b_3 and b_4. Still nothing happened. My version of OFP is 1.75 i think, mayb that cud b it but i doubt it.
@ Zombie, i as well just copied and pasted ur script straight in2 a mission folder, i'll try again and get back to you.
Thanks :)
-
Oh no no no, soz bout that Zombie it was my stupid fault, it works now, its great just wot i wanted. ;D
Im still interested though in the other exploding and burning barrel script.
-
lol, np m8, glad I could help. BTW, if you put the barrells close enough, when 1 goes, they will chain reaction and the whole ammo dump will go up, cool effect but quite cpu intensive
-
I'm not that good and I may be missing something but what's wrong with just creating a Barrel object and putting the following in its Init field -
@!(alive this); "heat125" camcreate (getpos this)
You then copy the object using CTRL-C and paste it all over your map using CTRL-V. Bingo, lots of barrels that expolde once they are destroyed. If the barrels take too much damage then you could simply have them start the game with very very low Health.
I hope that this works.
Roni
-
haven't tried your solution, the syntax looks ok tho. The thing is I try to stay away from using @. It loops very fast and can cause lag. I like ?!(alive.... in a script, it doesn't lag so much. Also I am not certain if commands like that will work in the init field. I know it works in triggers and scripts tho.
-
Yes, @ commands will lag - I probably should have asked how many barrels you were planning on having ! :beat:
You can actually run any command from in the Init field - one of my favourite tricks when checking out a new island is to place myself in a single OH-58 starting in the air with setViewDistance 3000 in the Init field. This really opens up the map and allows a lot more to be seen from the air.
If you don't want to use @ try -
#loop; ? !(alive) this : "heat125" camcreate (getpos this); ~1; goto "loop"
in the Init field. It does look messy but it should work.
Cheers
Roni
-
hey!!!
Gooner m8, maddmatt has created an exploding barrel script and it is pretty d**n good... I'll post it 2moz after i ask his permission or ill get him 2 do it... ;D
sim
My script is very easy to use, all it requires is a simple init-field command in each barrel and it will work fine. The barrel will also burn for between 1 and 2 minutes.
I've attached the script here, instructions on how to use it are provided within the script.