OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: mr_book.PXS.Pvt on 30 Aug 2011, 11:24:02

Title: Killing people is easy, but how to kill a weapon? (SOLVED)
Post by: mr_book.PXS.Pvt on 30 Aug 2011, 11:24:02
Hi,
this is the situation: I want to eliminate an AA threat in the form of some soldiers carrying Strelas. These guys don’t necessarily have to be killed, it’s enough if they are stripped off of their weapons and those weapons are destroyed.
And here comes the problem: can a weapon be destroyed? As far as I understand the engine, a “weaponholder” is created for each weapon that is put on the ground. Unfortunately, that weaponholder seems to be indestructible.
Here’s what I tried:
I created a weaponholder: wh=“weaponholder” createvehicle (getpos this); wh addweaponcargo [“strela”, 1].
Then I created a trigger, Radio Alpha, on activation: wh=nearestobject [player, “weaponholder”]; hint format [“%1”, damage wh].
Then I started the preview, manually planted a satchel charge right next to the Strela and blew it off. But, when calling Radio Alpha, the result is: 0. No damage at all! And the Strela can still be picked up, so it really didn’t take any damage.
Now what? Maybe cheating will help? Something like: wh addeventhandler ["firednear", …], so when a satchel goes off near the Strela pile, the whole thing is wh setdamage 1 or deletevehicle wh or whatever. But, honestly, all of that doesn’t sound too good to me.
Any ideas?
Thanks for your time.
mr_book
Title: Re: Killing people is easy, but how to kill a weapon?
Post by: robertoHrvat on 30 Aug 2011, 11:55:28
There is command "RemoveAllWeapons NameOfSoldier" I dont know if works in arma2, if not here must be a somthing like for deleting weapon. So when SC going off soldier die and weapon is crashed (deleted-destroyed).
Title: Re: Killing people is easy, but how to kill a weapon?
Post by: h- on 30 Aug 2011, 12:38:16
@mr_book.PXS.Pvt:
Weapons aren't objects like other objects in the game so you can't really do anything to them.

Weaponholder is basically a invisible ammobox so it might accept eventhandlers, you just have to test the firedNear thing..
Title: Re: Killing people is easy, but how to kill a weapon?
Post by: Wolfrug on 30 Aug 2011, 12:45:32
Hm! Complex.

Can be made easier though. A gamey workaround is to place all of the weapons into an ammo crate, and then blow that one up, since that you can do no problems. I wouldn't recommend going into any firednears or whatever, that might be terribly complex - especially as it's a little uncertain as to how exactly the weaponholders that are created when an AI places a weapon on the ground work (as opposed to the ones you create yourself).

It all depends on the scenario, really. Is the AI carrying the launchers, and you're forcing them to drop them and then destroying them? Or are you sneaking in and destroying them before they're even picked up? The second one is pretty easy: just make sure the launchers are inside an ammo crate instead of laying about, and boom. The first one you could solve for instance by having a super-short blackout, during which the player "disables" all the launchers one way or another (just removemagazine the launcher ammo, for instance) - or heck, even do it as an action attached to each AI that just removes their magazine. If you can do it with dropped weaponholders too, go right ahead.

Since yes, destroying weaponholders doesn't seem to actually work :) Thus -> workaround time!

Depends on the scenario, as mentioned.

Wolfrug out.
Title: Re: Killing people is easy, but how to kill a weapon?
Post by: mr_book.PXS.Pvt on 30 Aug 2011, 15:05:28
Wow,
fast responders all over the place, huh? Well, thank you very much!
Regarding the scenario, it’s supposed to be like, a team of operators goes in, kills the enemy AA soldiers (who carry one Strela each), then takes the Strelas off of the bodies and blows them up right there and then. No carrying ‘em around or bringing ‘em back to base or such.
To avoid unnecessary stupidity, the whole thing should be a no-AI/humans only multiplayer scenario.
Would have been nice had it worked with weaponholders, but when there’s eventhandlers or other overly complex stuff involved, I’d rather put an ammocrate somewhere, so we can cram all Strelas in there and then blow them up. No trickery.
Ok! I’ll try this and then we’ll see.
Again, thank you, and have a nice day.
mr_book

Edit:
Ok, here's what goes and what doesn't:
Eventhandlers don't. Weaponholders don't. Ammocrates do.
It's a pity that the original plan didn't come together and I'm forced to use a crate, but, well, I can live with that.
So, here's the script for the crate ([crate] execvm "crate.sqf"):
Code: [Select]
_box = _this select 0;
_strela = false;

while {damage _box<1} do
{
 _gwc = getweaponcargo _box;
 _weapons = _gwc select 0;
 _amounts = _gwc select 1;
 _a = 0;
 for "_z" from 1 to count _weapons do
 {
  _weapon = tolower (_weapons select _a);
  _amount = _amounts select _a;
  if (not _strela and _weapon=="strela" and _amount==3) exitwith
  {
   leader group player sidechat "Ok! Ready to blow. Clear the area!";
   _strela = true;
  };
  if (_strela and _weapon=="strela" and _amount<3) exitwith
  {
   leader group player sidechat "Hold it! One Strela went missing.";
   _strela = false;
  };
  _a = _a+1;
 };
 sleep 0.1;
};

if (damage _box==1 and _strela) exitwith
{
 task_1 setTaskState "succeeded";
 task_1_s = true;
 publicvariable "task_1_s";
 leader group player sidechat "That's done. Moving to next objective.";
};

if (damage _box==1 and not _strela) exitwith
{
 task_1 setTaskState "failed";
 task_1_f = true;
 publicvariable "task_1_f";
 leader group player sidechat "Whoops! We blew the box up without the Strelas. Fail!";
};
Works nice in the demo mission, and hopefully will in the real mission as well.
Thanks again everybody, and good night.
mr_book