Jump to content
scottb613

Simple Destruct Script

Recommended Posts

Hi Folks,

 

I'm on a coding spurt - LOL. Doing some simple quality of life scripts. Learning as I go.

 

I made a self-destruct script to destroy any ammo pallets left over after I rearm my units. I learned how to add actions to objects now - new to me - very cool.

 

The script "works" as is.

 

Question: When I [attachTo] - the relative positioning doesn't seem to work. I can never see the charge - no matter the values (assumed buried in object). Shouldn't I be able to move the explosive around on the object (ammo pallet) using the position array?

 

Question: If I use the "scripted charges" this works - however - I originally wanted to place a SOG incendiary grenade on the pallet (better effect) - but that doesn't work using the classname - ideas?

 

//SCOdestruct.sqf
private _target = _this;
private _posit = getpos (_this select 0);
// create and attach charge
private _charge = "DemoCharge_Remote_Ammo_Scripted" createVehicle _posit;
_charge attachTo [_target, [1.0, 1.0, 1,0]];
// now detonate charge
sleep 2;
hint "----RUN---RUN---RUN----";
sleep 3;
hint "---------10";
sleep 1;
hint "--------9";
sleep 1;
hint "-------8";
sleep 1;
hint "------7";
sleep 1;
hint "-----6";
sleep 1;
hint "----5";
sleep 1;
hint "---4";
sleep 1;
hint "--3";
sleep 1;
hint "-2";
sleep 1;
hint "1";
sleep 2;
hint "";
_charge setDamage 1;

Thanks.

 

Regards,
Scott

Share this post


Link to post
Share on other sites
private _target = _this;  // _this is your crate!
private _posit = getpos _this;  // (_this select 0 ??? no-sense)
private _charge1 = "vn_m14_grenade_ammo" createVehicle _posit;
_charge1 attachTo [_target, [1.0, 1.0, 1.0]];   // check your offset. Yours is wrong (4 elements)
sleep 2;
hint "----RUN---RUN---RUN----";
sleep 3;
hint "---------10";
sleep 1;
hint "--------9";
sleep 1;
hint "-------8";
sleep 1;
hint "------7";
sleep 1;
hint "-----6";
sleep 1;
hint "----5";
sleep 1;
hint "---4";
sleep 1;
hint "--3";
sleep 1;
hint "-2";
sleep 1;
hint "1";
sleep 2;
hint "";
_charge2 = "DemoCharge_Remote_Ammo_Scripted" createVehicle _posit;
_charge2 setDamage 1;
deleteVehicle _charge1;
deleteVehicle _target

 

  • Like 4

Share this post


Link to post
Share on other sites
Spoiler

sleep 2;
hint "----RUN---RUN---RUN----";
sleep 3;

for "_countdown" from 10 to 1 step -1 do {
	private _hint = [];
	_hint resize[ _countdown -1, "-" ];
	_hint pushBack str _countdown;
	_hint = _hint joinString "";
	hint _hint;
	sleep 1;
};

sleep 1;
hint "";

Not particularly answering OP's question, just an improvement to the countdown.

Rather than writing each line out, just one loop that can accommodate any length countdown by changing just one number.

 

  • Like 2

Share this post


Link to post
Share on other sites

Hi Folks,

 

Hah - I've gotten a great deal of help lately - thank you. 

🙂

 

I'll work on putting all this great new information to use.

 

Regards,

Scott

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

×