Jump to content
Sign in to follow this  
TAW_T-Bone

destroy obj special

Recommended Posts

Hi,

i want to know if it possible to set a object like radar that it needs 5 satchels charges to destroy it. Or that it can only be destroy by a maverick from an apache.

I was thinking of making a trigger with in the condition something like this == "HandGrenades_West"; and on act: radar SetDamage 1;

But this isn't working i hope you get the idea.

Share this post


Link to post
Share on other sites

I tested it but couldn't get it to work.

_this = radar addEventHandler ["HandleDamage",radar,"",3, player,"15Rnd_9x19_M9"];

I place this in a Anti-air radar in the initialization box. the radar in named "radar".

To test it i wanted it to take it down with one shot with my M9 so the 15Rnd_9x19_M9 is the class name of the magazine. can you direct me a bit here?

Share this post


Link to post
Share on other sites

I did a quick test this morning using the example from the biki...

this addeventhandler ["HandleDamage",{hintSilent format ["T=%1 : %2", time, _this];_this select 2;} ];

You'd of course remove the hint part, but that'll give you the ammo type used against it as _this select 2, then just compare that against Maverick's round type. Didn't get to test against satchel, which I think might be a problem since it might be explosive?

Basically you'll intercept all damage to the radar till one matches your requirements and let that through.

Share this post


Link to post
Share on other sites

this addEventHandler ["handleDamage","hint str(_this)"]

If you use a satchel charge PipeBomb will be returned, however how you tell if five are used is another matter.

I didn't know that using this makes the tower invincible to damage as well, until you destroy it with setdamage .

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Well, it doesn't stop damage on it's own, but you should be able to intercept the damage with it I believe. The main problem in my test earlier was I kept shooting a Anti-Air Radar with an NLAW. First two hits reported the M_NLAW_AT or whatever the ammo was, but the third one reported nothing and the radar was destroyed...

As for the 5 thing, just keep track of how many times it was hit I guess? :)

Share this post


Link to post
Share on other sites

But if you placed 5 charges and all go off at once it only counts one.

I'm still struggling on how you would compare the info, how to extract the ammo to to useful data.

Remembering a thread from a while back asking how to make a camo net invincible I tried using the handledamage handler and it does indeed make it invincible.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Use a nearObjects scan to test when 5 are placed nearby, set a variable saying it's good to do, then wait for the pimebomb to hit?

Or just not use that kind of limitation in a mission. heh I wonder, could you up the HP of an item so that needed 5? Dunno.

Share this post


Link to post
Share on other sites

It doesn't seem to work for pipebombs, cars, tanks no problem.

count (nearestObjects [player, ["PipeBomb"], 20]) == 1

no effect, change to "car" and as long as one is present it works.

Share this post


Link to post
Share on other sites
I did a quick test this morning using the example from the biki...

this addeventhandler ["HandleDamage",{hintSilent format ["T=%1 : %2", time, _this];_this select 2;} ];

You'd of course remove the hint part, but that'll give you the ammo type used against it as _this select 2, then just compare that against Maverick's round type. Didn't get to test against satchel, which I think might be a problem since it might be explosive?

Basically you'll intercept all damage to the radar till one matches your requirements and let that through.

Sorry Kylania can you explain what all parameters mean?

cause i can't figure it out - i am probably thinking i an other direction then the script is.

Share this post


Link to post
Share on other sites

Yeah i saw that but what does it mean. Like the "T=%1 : %2" for in-stand where and how should i put in the maverick. and does 1 mean dead or destroy?

Do you know how to use it?

Share this post


Link to post
Share on other sites

The %1 and %2 are part of the format command. They are replaced by the first and second things after the double quotes, like this:

_girl = "Tammy";
_dog = "Rufus";
hint format["My girlfriend [color="Blue"]%1[/color] loves my dog, '[color="DarkOrange"]%2[/color]'", [color="Blue"]_girl[/color], [color="DarkOrange"]_dog[/color]];

Would print out a hint saying:

My girlfriend Tammy loves my dog, 'Rufus'

Share this post


Link to post
Share on other sites

This topic is very useful. Thanks for TAW for posting, the idea will be useful. Gna tag it for email noticification.

@kylania u been teaching me tonight. Didn't think format could be so simple. Thanks for that :D

Share this post


Link to post
Share on other sites

I think this is how you filter the command to only allow certain types of ammo to damage an object

Radar addEventHandler ["HandleDamage",{(_this select 4) == "PipeBomb"}];

Now only a satchel charge will take it down, still only one is needed though.

Share this post


Link to post
Share on other sites

If u could somehow find a way to let's say when you use 1 satchel it takes away a 1/5th of the radar's total health...

To simplify maybe attempt to script it so that if a satchel blows up take off 0.2 damage from it's health.

If health == 1 and if one satchel blows up then 1 - 0.2 = 0.8... and so on. I'm trying to find the logic lol, bit tired atm.

Edit---------

Would using this work?

SQF
switch (VARIABLE) do {
case VALUE_1: {COMMAND_1};
case VALUE_2: {COMMAND_2};
default {DEFAULT_COMMAND};
};

When u put a trigger that counts how many satchels are in it. Count it into a variable...

Then use the switch...

_radar = this getPos(getnearestobject "Id");
_satchel = 0;
switch (_satchel) do {
case 1: {_radar setDammage ((getDammage _radar)-0.2)};
case 2: {_radar setDammage ((getDammage _radar)-0.4)};
default {DEFAULT_COMMAND};
};

this isn't exactly accurate at all, I'm just trying to us my logic without being in front of the screen. I bet I got all the code wrong If someone can build on this code it could work?

Edited by WoodyUK

Share this post


Link to post
Share on other sites

The problem is how can you tell if all 5 have been detonated together, I also still haven't found a way of detecting a placed pipebomb.

I think the trick is to use the handledamage to check for damage at several different points on the radar and then if they have suffered sufficient damage to all the parts have it destroyed.

One way could be to place a few invisible objects some distance away and at all three corners of the tower and when they suffer enough damage blow the tower.

Share this post


Link to post
Share on other sites

Would this work...

player addEventHandler ["Fired",{if ((_this select 1) == "Pipebomb") then {[] _satchel = _satchel + 1; }}]

Assuming that eventHandler only executes when the player places a satchel on the ground...

And then trying to figure a way to check if the player has "touched off" the satchels...

Share this post


Link to post
Share on other sites

How about detecting pipebombs placed near the object then delete and replace them with pipebomb placeholders. When 5 have been placed add an action to the tower to "set charges", then 30 seconds or however long later, blow it all up via script?

Share this post


Link to post
Share on other sites

i was just thinking along the lines of that Kylania... fake 5 satchel explosions... TAW this approach may work..

if you could name each individual pipebomb placeholder as suggested by kylania... you can apply a satchel explosion to each of the placeholders... using createUnit i think it is. Then _radar setDammage 1 would destroy it.

Share this post


Link to post
Share on other sites

Here's a really rough demo mission for this. (Needs BAF to look pretty, BAF is pretty, why don't you have it yet? :))

Place your Tower where you want it with this as it's init: (or run it from the init.sqf or something)

nul = [this, "pipebomb", 5] execVM "tower.sqf";

Then here's the code for it: (adapted from a script by Rocket)

_tower = _this select 0;
_type = _this select 1;
_count = _this select 2;

_placed = 0;

_tpos = getPos _tower;
_radius = 20;

while {alive _tower} do {
_bombarray = _tpos nearObjects [_type, _radius];
_qty = count _bombarray;
{_ppos = getPos _x; deleteVehicle _x; "timeBomb" createVehicle _ppos; _placed = _placed + 1;} forEach _bombarray;
hintSilent format["%1 bombs replaced", _placed]; // debug
_bombarray = [];

if (_placed >= _count) then {
	hint "That's enough bombs!  Timer set!";
	sleep 10;
	hint "20 seconds till charges go off!";
	sleep 10;
	hint "10 seconds...";
	sleep 5;
	hint "5 seconds...";
	sleep 5;
	"Bo_GBU12_LGB" createVehicle getPos _tower;
};
sleep 2;
};

A few problems I can think of are 1) you can deactivate a timebomb and it would still count as placed 2) not really MP friendly probably? 3) no guaranteed cleanup of the timebombs. But it works. :)

Share this post


Link to post
Share on other sites

Trying to spawn a tower with the event handler to only be blown up with a satchel charge. Would this be correct?

tower = createVehicle ["Land_radar_EP1", [(getMarkerPos "towermarker") select 0,(getMarkerPos "towermarker") select 1,0], [], 3, "GROUND"];
[tower] Radar addEventHandler ["HandleDamage",{(_this select 4) == "PipeBomb"}];

Share this post


Link to post
Share on other sites

Got it working like this instead:

tower = createVehicle ["Land_radar_EP1", [(getMarkerPos "towermarker") select 0,(getMarkerPos "towermarker") select 1,0], [], 3, "GROUND"];
tower addEventHandler ["HandleDamage",{(_this select 4) == "PipeBomb"}];

Share this post


Link to post
Share on other sites

Could you use allow damage false, then capture FiredNear and then when enough have been fired off set the damage to 1?

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  

×