Home   Help Search Login Register  

Author Topic: Satchel Charges To Take Down Buildings On Nogova  (Read 2213 times)

0 Members and 1 Guest are viewing this topic.

Offline GoldGazelle

  • Members
  • *
  • Knowledge can be taught. Wisdom can not.
Satchel Charges To Take Down Buildings On Nogova
« on: 28 May 2010, 22:21:25 »
Hi there everyone,

The Objective:
 - To destroy any building or radio tower with one or more satchel charges on the island of Nogova

The Problem:
 - Damn Those Buildings Are Strong! Before making my mission I tested out using a Black Ops Day unit (equipped with three satchel charges) to plant A satchel charge in a one story building hoping it would level it. Not even a dent. All three satchel charges? Nope. I used an Abrams, about ten rounds of sabot got the job done. I don't think a unit can carry that many satchel charges.

A Shitty Solution:
 - I tried making a script that when the player has less than three satchels (ie. he just planted one) he would immediately set the timer on it and after a 31 second delay in the script (one second after the charge blows, it looked the best)
Code: [Select]
object "building ID Number" setdammage 1.0 would be executed and the building would bite the dust. It worked, but there is way too many problems with the script I wrote.

 - The player could touch off the charges before the delay runs out and the charges would blow but the building wouldn't collapse until 31 seconds are up.
 - The player might not realize he just automatically set the timer after placing the first charge and blow himself up if he sticks around to long.
 - If you place more than one charge, the timer will only be set on one so only one will blow up
 - (I'm sure the list goes on)

A Good Solution:
 - As soon as the player touches off one, two or three charges (depending on how many you place at ONE building) setdammage for that building is executed and every thing looks good and you don't have to place, run and wait or some specific sequence in order to level a building. How do I do this?

"Whew"

Here is the shitty script I wrote:

Code: [Select]
#LOOP


_bombs =  ("_x == {pipebomb}" count magazines soldier)

?_bombs < 3 : _setTimer =  player action ["SETTIMER"]
?_bombs < 3: goto "EXIT"

Goto "LOOP"

#EXIT

~31

object 85759 setdammage 1.0

exit

Thank you for your time and patience,

GoldGazelle

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Re: Satchel Charges To Take Down Buildings On Nogova
« Reply #1 on: 29 May 2010, 00:26:37 »
Hi there GoldGazelle. Try this:

(1) add a "fired" eventhandler to the player using the addEventHandler command. Use it to execute a script that will check the ammo type of the fired weapon to see if it is a "pipeBomb." (The ammo type will be returned as _this select 4, see the tutorial for more info). This is more efficient than checking to see if the player has less than exactly three magazines. :P If the ammo fired turns out to be a pipebomb, then:

(2) Use the nearestObject command on the player to return the nearest pipeBomb, which will be the one he just set.

Code: [Select]
_bombset = nearestObject [getpos player, "pipeBomb"]

It's a very fun command, isn't it? ;) Now, use isNull to check for when that pipeBomb has ceased to exist, because it exploded:

Code: [Select]
@(isNull _bombset)

Now setDammage the buildings. :cool2:
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)

Offline dr. seltsam

  • Members
  • *
Re: Satchel Charges To Take Down Buildings On Nogova
« Reply #2 on: 29 May 2010, 11:22:49 »
What about ...
giving that building some pre-damage in the Init.sqs ?

object xxxxx setDamage 0.95

:whistle:

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Re: Satchel Charges To Take Down Buildings On Nogova
« Reply #3 on: 29 May 2010, 14:23:36 »
Hahaha, dr. seltsam is right. :-[

But I think tracking the satchel charge is funner. ;)
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)

Offline GoldGazelle

  • Members
  • *
  • Knowledge can be taught. Wisdom can not.
Re: Satchel Charges To Take Down Buildings On Nogova
« Reply #4 on: 29 May 2010, 23:25:30 »
Thanks guys,

It took me a little while to write a script for RKurtzDmitriyev's solution. (I've added the test mission to this post, with necessary script). Although, my script has one problem that I know of; If I place a charge within the trigger (holding the
Code: [Select]
Soldier AddEventHandler ["fired",{_this exec "onfiring.sqs"}] script) that is around my target building, thus activating the script, then "Say" accidentally place another charge and go to deactivate it, the building will collapse (because the charge closest to the player, which is now the second charge, is no more which triggers the setdammage script).

Could I stick a Distance script in there so that the charge has to be close enough to the building and any charges farther away wouldn't activate the script? (this won't really solve the problem)
Or
Could I stick something in my script telling it that after one charge is placed other charges won't activate it but touchingoff #1, #2 and #3 charge would still activate it because I'm touchingoff the first charge?
Or even better
Is there a way to make the script NOT activate by the Deactivation of a charge?

Yes dr. seltsam you are very right. I wish I had thought of that in the begging, but now I have a splinter in my brain and I have to get it out (if ya know what I mean).

Thanks guys for your help, keep up the good work.

GoldGazelle

Test Mission Below (no mods or addons needed)


« Last Edit: 29 May 2010, 23:28:22 by GoldGazelle »

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Re: Satchel Charges To Take Down Buildings On Nogova
« Reply #5 on: 30 May 2010, 01:52:12 »
Quote
now I have a splinter in my brain and I have to get it out (if ya know what I mean).

Mine too. Fortunately I came up with a solution. Check demo mission. The script I used is commented.  Watch the right-hand skyscraper get obliterated by one satchel charge. :P

Notice that I can simply attach the eventhandler using the player's initialization field, rather than using a trigger. Notice also that, in answer to your question...

Quote
Could I stick a Distance script in there so that the charge has to be close enough to the building and any charges farther away wouldn't activate the script? (this won't really solve the problem)

Once you've "captured" the satchel charge using nearestObject, you can use the distance command on it like any other object. This is included in the script.
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)

Offline GoldGazelle

  • Members
  • *
  • Knowledge can be taught. Wisdom can not.
Re: Satchel Charges To Take Down Buildings On Nogova
« Reply #6 on: 30 May 2010, 04:44:19 »
It's...It's so beautiful.

Awesome work  :good: man. It works great. I did add a 0.75 second delay before the building gets damaged, it just makes it look a little bit better. The destroyed building looks like something out of a Dr. Seuss book, hehe. I never knew you could climb up the elevator shaft of those buildings.

This might be stretching it a bit too far, but would it be possible to create a script that can level the nearest building (not one specific building) to a placed charge? I'll see if I can't figure out something. You give it a try too, eh.

Your help has been greatly appreciated,

GoldGazelle   

Offline Lone~Wolf

  • Mission Tools & Mods
  • Members
  • *
  • Vladimir Dmitri Mikhail Andreevich Stamenov
Re: Satchel Charges To Take Down Buildings On Nogova
« Reply #7 on: 30 May 2010, 17:17:50 »
Aha, before this Topic gets forgotten I might want to contribute something for your plan.

My excellent friend and fellow OFP enthusiast Grizzly-1 made a lovely script a few weeks ago that made for very realistic addon-free building razing.

I think it's addon free, perhaps it needs ED_102. Anyway, I need to dig it up and I'll post it here shortly.

Hope it helps,
        Lone~Wolf (Courtesy Grizzly-1)  :D
Snarling creature, lurking in the background, still writing in .sqs

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Re: Satchel Charges To Take Down Buildings On Nogova
« Reply #8 on: 31 May 2010, 01:59:55 »
I'm glad you liked the demo mission. :)

Quote
This might be stretching it a bit too far, but would it be possible to create a script that can level the nearest building (not one specific building) to a placed charge? I'll see if I can't figure out something. You give it a try too, eh.

Tsk tsk, this could be difficult....

I'm thinking about it. The easiest way I can think of is to use a function such as objsoftypeinrange.sqf by Raptorsaurus, which will return an array of objects of a certain general type in a certain range. Then, take those members of the array which are close to a satchel charge, and have them setDammage'd using a similar script to the one in the demo mission.

Yet another way would be to attach a "hit" eventhandler to every single building on the island. It still would be some very tedious work, but I can think of a way to do this without having to hunt down every building visually. Have this "hit" eventhandler check if a nearby satchel (found using similar scripting as above) blew up very close to when it was hit. Then setDammage the object.

Unfortunately there isn't a convenient command which will return every single map object in a certain radius...would be so much easier. Might check around the function library to see if someone's made one though.
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)