Home   Help Search Login Register  

Author Topic: Unlimited Smoke Grenades and Chem Lights  (Read 4107 times)

0 Members and 1 Guest are viewing this topic.

Offline StressfulGengar

  • Members
  • *
Unlimited Smoke Grenades and Chem Lights
« on: 09 Sep 2014, 17:38:24 »
I am the dedicated mission developer for the clan I am apart of and I have run into a bit of trouble with the latest mission.

A bit of background info is probably needed here. The whole campaign on Altis is to clear the invading CSAT forces off the island mission by mission and it follows a Story line which I have written out with event's, ect. At the point my clan mates are they have gotten in contact with the ADF and are fighting with them to take back the island.

The mission objectives at hand are as follows:
Clear Minefield & IEDs along route
Deliver Supplies to ADF forces via truck (the reason behind clearing IEDs and Minefield) and by Helicopter.

What I need to know is how do I create endless spawning smoke grenades and chem lights so that I can mark the location for the Heli team to put down the supplies as they will be doing this using Slings.

Thanks in advance for the help!!

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Unlimited Smoke Grenades and Chem Lights
« Reply #1 on: 10 Sep 2014, 10:41:10 »
:welcome:
Welcome to OFPEC :)
(or if you're old user with new creds, welcome back :P )

Do you mean endlessly spawning into your inventory or endlessly spawning on the groud once thrown there?
Just checking but I'm suspecting the latter..
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline JohnAJ

  • Members
  • *
Re: Unlimited Smoke Grenades and Chem Lights
« Reply #2 on: 01 Dec 2014, 14:11:26 »
If anybody happens upon this thread when searching Google, I'll be a nice guy and give you my answer, assuming you want every unit to have an unlimited amount of smoke grenades and chemlights. Here's what I'd do:

Code: [Select]
replenish = {
_unit = _this select 0;
_weapon = _this select 3;
_magazine = _this select 5;
if (toString _weapon == "Throw") then {
_chemlight = toArray _magazine;
_chemlight resize 9;
_smoke = toArray _magazine;
_smoke resize 10;
if (toString _chemlight == "Chemlight" or {toString _smoke == "SmokeShell"}) then { _unit addMagazine _magazine; }
};
};
{_x addEventHandler ["Fire", {_this spawn replenish}} forEach allUnits;

Something like that? Should work, haven't tested it though. You should probably privatize the variables too. Also, it might not be a good idea to run this entire thing everytime someone fires. I don't know.

Offline Lone~Wolf

  • Mission Tools & Mods
  • Members
  • *
  • Vladimir Dmitri Mikhail Andreevich Stamenov
Re: Unlimited Smoke Grenades and Chem Lights
« Reply #3 on: 08 Jan 2015, 21:35:52 »
Don't worry, I work a lot with scripts running whenever anyone fires: It's not a problem.

Your code looks fine. The logic is sound, even if the user wishes to tweak it a bit to their own needs.
The method I used to always use in OFP was to check for when a magazine (or in this case a smoke grenade) disappears from the inventory, then give another one. Linking it to the throwing has a lot more finesse though.
Snarling creature, lurking in the background, still writing in .sqs