Jump to content
Sign in to follow this  
Flat!!!

Bomb activated by speed

Recommended Posts

Download my carbomb script:

Car Bomb Script

It has many modes and is not only speed activated...

For example once engine is on it will blow after X seconds...

----------------------------------------------------------------

------------------------Original post----------------------------

----------------------------------------------------------------

I would like to know how I can make something activate when reached certain speed or goes under a certain speed. For example a car goes over 50km/h and then car setdamge 1 gets activated.

Share this post


Link to post
Share on other sites

example:

if ((speed _myVehicle > 120) or (speed _myVehicle < 50)) then {insert your action here};

Share this post


Link to post
Share on other sites

Go to the OFPEC Editors Depot Scripts section  here and look for Car Bomb - Speed Activated. Make sure you update the type of explosive to the ArmA name.

Share this post


Link to post
Share on other sites

I announce my Car bomb script in 1.0 state. That means that you can download it from smile_o.gifArmaholic

Please comment smile_o.gif And give me ideas icon_rolleyes.gif If you have problems with the script or would like to see a improvement in something, please feel free to ask

Share this post


Link to post
Share on other sites

Any ideas? Modes... General info, How it preforms?

Please give me some feed back so I can improve the script and my skills...

Share this post


Link to post
Share on other sites

I've had a quick look at the sqs file without testing it in game. Please note, I'm no script guru either smile_o.gif

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unitdir = getdir _object - 0

Why subtract 0?

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#start

? (_mode==0):goto "cantstop"

? (_mode==1):goto "upperlimit"

? (_mode==2):goto "cantstopupperlimit"

? (_mode==3):goto "engineon"

? (_mode==4):goto "engineon2a"

If you only have 5 cases, the last line does not need the if condition. It wastes cpu power performing the check.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#cantstop

if (speed _object >_speed) then {goto "cantstop2"}

? (!alive _object) : goto "Destroy"

goto "cantstop"

I would add some sleep to time these loops, checking the speed values as quickly as possible can reduce game performance with no real reason.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">goto

Every goto wastes cpu power searching through the entire script from the beginning for the desired label. Try to use while, for etc. They can be easier to read too since the flow of the script isn't jumping up and down the page. It may be better to use a different script for each bomb simulation mode rather than one script with 5 modes.

As someone who has only started using scripts in the last year, my general advice is to try and create as efficient scripts as possible. One inefficient script doesn't matter much, but ten running at once can ruin your FPS. Otherwise, nice work! Blowing up cars is somehow very satisfying smile_o.gif

Share this post


Link to post
Share on other sites

Thx for the reply smile_o.gif

So I actually have no idea why I used -0 ... pretty dumb of me...

Modes... It might be a bit annoying to keep track of 5 diffrent scripts altho I will try to use less goto's in the next version...

Again Thx for telling me about those things as I really am kinda new to scripts... ~4-6days smile_o.gif

Everybody is free to tip me on how to improve... smile_o.gif

Share this post


Link to post
Share on other sites

How about using @ instead of loops? Would it be better?

Share this post


Link to post
Share on other sites

Unfortunately not. Waituntil/@ check conditions very quickly, possibly every frame. It would be slightly better than the loop with goto tags, since it doesn't need to find the label.

Use a while () do {}

Share this post


Link to post
Share on other sites

New version on the way.... Fixes a explosion bug where there never is a explosion only the vehicle brakes to 1 damage.

I used @ for this version I will use @ instead of the goto's as I don't know how to use whole yet... Altho maybe in 1.2 I will implement them. Also there are no goto's except the mode choice... (removed the last check) and in mode 4 where I think it is necessary.

I will post the link here and in my sig when it is up...

BTW thx for the tips Fasad. Perhaps you can help me understand "while" command?

Share this post


Link to post
Share on other sites

I now release version1.1 which fixes:

-Explosion in mode 0

-Explosion in mode 1

-Explosion in mode 2

-Optimized performance

Link: Car Bomb Script

Please post in this topic if you have any ideas or comments.

Hope you like it smile_o.gif

Share this post


Link to post
Share on other sites

I would really appreciate comments and ideas so I could improve the script. smile_o.gif

Share this post


Link to post
Share on other sites

Tell me what you think when you have tested it smile_o.gif

Share this post


Link to post
Share on other sites

Fasad I seriously can not understand in what way I should use the while command.

Quote[/b] ]

Use a while () do {}

Please give me an Example.

I am still only in scripting for 1 week which I mostly have had other things to do... So I would really appreciate some tips:)

And Can anybody give me Ideas on improvement... that has tested it in game? Thanx in advance icon_rolleyes.gif

Share this post


Link to post
Share on other sites

sad_o.gif

Sorry for the mistake, correct format should be :

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">while {} do {}

When in doubt, check the wiki.

I took one part of your script (sqs) and replaced

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">@(speed _object >_speed) or (!alive _object)

with (sqf)

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">while {(speed _object < _speed) or (!alive _object)} do {sleep (0.9 + random 0.2)};

Honestly, it is probably complete overkill for this script, since I had to add 100 stationary cars running this script to see any difference in framerate (1 fps) between the @ and the while/do. There may be other factors such as exec vs execVM too. The idea is to reduce the number of checks the game does every frame, especially with things that are do not need to be exact. The random number de-synchronizes the checks for multiple cars. Ah well, hopefully it might help you in the future some day.

Share this post


Link to post
Share on other sites

New version smile_o.gif v1.2

Carbomb script

It adds 3 new modes.

1 is that when you enter the vehicle it will blow after X seconds.

Another is similar to the previous only if you get out it wont blow.

There is also one that can be used for suicide bombing. If an object gets X meters from another object... KABOOOM smile_o.gif

Please post any issues. I would rally appreciate comments and ideas

Share this post


Link to post
Share on other sites

Hi, great script smile_o.gif I've been having some fun with the Bo_GBU12_LGB bomb biggrin_o.gif

Was wondering if you could give me some help.

I want to make it so the car which has the explosive can travel to a target and explode when it gets within around 5 metres. How do I do this? And the car has to travel quite a distance so if it's possible, I don't want any speed activation.

Thanks

Share this post


Link to post
Share on other sites

Hi, the script does not only make an explosion when speed activated. The topic name is inappropriate but it can not be changed. Anyway you have to download my script (v1.2) and then type the the following into the init line of the vehicle some thing like:

[bMP, 30, 5, "Sh_120_SABOT", carone] exec "carbombv1.2.sqs"

In the example the vehicle called BMP will blow up with a M1A1 main gun explosion once it is 30 meters away from carone.

For all the modes read the readme.txt file included in the DL

In your case:

[name of car, 5, 5, explosive, destination] exec "carbombv1.2.sqs"

Share this post


Link to post
Share on other sites

Hey thanks for this master piece. Now i can make some terrorist maps.

I have a map called: roadblock duty.

and now using your script.

But when the car with the bomb come closer to my target unit the car explodes. but all the surrounding units dont take damage. How can i fix this?

Share this post


Link to post
Share on other sites

Sorry i got it.

Its a bug in the game.

The car explode on the bridge.

My units were on the normal ground

Share this post


Link to post
Share on other sites

Roger. Keep reporting anything you find smile_o.gif I really need someone to report bugs ideas and improvments smile_o.gif

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×