How to move IR grenades to gun store and execute script?

  • Offline night
  • Hardened
  • ****
  • Posts: 100

How to move IR grenades to gun store and execute script?

« posted: Mar 26, 2018, 06:23 PM »
Hey, trying to make it read faction from IR grenade store config. Is there a simple way to put it with other grenades and satchel charges?

And would like to execute the following script that should go into init.sqf:
Code: [Select]
player addEventHandler ["Fired", {private ["_grn"]; _grn = _this; [[_grn, "addons\scripts\ir_to_incendiary.sqf"],"BIS_fnc_execVM",true,true] spawn BIS_fnc_MP;}];
How to convert it from BIS_fnc_MP properly? And what file to paste it into?
Script adds nice visual effects to IR flash.
http://www.armaholic.com/page.php?id=32626
  • Offline AgentRev
  • Developer
  • Veteran
  • ******
  • Posts: 2600

Re: How to move IR grenades to gun store and execute script?

« Reply #1 posted: Apr 04, 2018, 02:30 AM »
I looked at the code from Armaholic, it uses a bunch of commands are that global. Remote executing global commands is essentially like executing the script 50 times in a row (that's bad)

As such, I would highly recommend that you try using it without remote execution first:

Code: [Select]
player addEventHandler ["Fired", compile preprocessFileLineNumbers "addons\scripts\ir_to_incendiary.sqf"];
  • Offline night
  • Hardened
  • ****
  • Posts: 100

Re: How to move IR grenades to gun store and execute script?

« Reply #2 posted: Apr 04, 2018, 11:40 AM »
Added to firstSpawn.sqf under the player addEventHandler ["HandleDamage", unitHandleDamage];
Now i dont see the item being thrown and also no signs of the effects it should make  :'(
  • Offline AgentRev
  • Developer
  • Veteran
  • ******
  • Posts: 2600

Re: How to move IR grenades to gun store and execute script?

« Reply #3 posted: Apr 08, 2018, 11:14 AM »
Here, I fixed the script:

Code: [Select]
/*
IR_TO_INCENDIARY script by SAKY(rkfnql322) fixed by AgentRev
This script is MP Compatible. This script changes useless IR grenades into incendiary grenade.
3 factional IR Strobes and IR Grenade can be used.
Flame can damage most of helicopters. So can be used to destroy severely damaged helicopters without teamkill penalties.
Also, this has a great damage to un guarded infantry so can be used at CQB.
To use the script, just add the line below in the init.sqf. And put this file in the server.(with folder)

player addEventHandler ["Fired", compile preprocessFileLineNumbers "addons\scripts\ir_to_incendiary.sqf"];

Have fun!
*/

if ((_this select 4) in ["F_40mm_Cir","B_IRStrobe","O_IRStrobe","I_IRStrobe"]) then
{
_this spawn
{
_gr = _this select 6;

sleep 2.5;
_SE_ignite = createSoundSource ["SoundFlareLoop_F", _gr, [], 35];
_SE_ignite attachTo [_gr, [0,0,0]];

_PS_spark1 = "#particlesource" createVehicle getPosATL _gr;
_PS_spark1 setParticleClass "FireSparks";
_PS_spark1 setParticleFire [1, 1, 0.5];
_PS_spark1 setDropInterval 0.001;
_PS_spark1 attachTo [_gr, [0,0,0]];

sleep 1;

_SE_burn = createSoundSource ["Sound_Fire", _gr, [], 20];
_SE_burn attachTo [_gr, [0,0,0]];
_PS_spark1 setDropInterval 0.01;

_PS_floorFire = "#particlesource" createVehicle getPosATL _gr;
_PS_floorFire setParticleClass "ExpSparksFire";
_PS_floorFire setParticleFire [0.4, 4, 0.2];
_PS_floorFire setDropInterval 0.001;
_PS_floorFire setParticleRandom [1.2, [0.3, 0.3, 0.1], [3.5, 3.5, 0], 1, 2, [0, 0, 0, 0], 0, 0];
_PS_floorFire attachTo [_gr, [0,0,0]];

_PS_spark0 = "#particlesource" createVehicle getPosATL _gr;
_PS_spark0 setParticleClass "FireSparksSmall";
_PS_spark0 setParticleFire [0.01, 1, 0.5];
_PS_spark0 setDropInterval 0.0005;
_PS_spark0 attachTo [_gr, [0,0,0]];

_PS_smoke = "#particlesource" createVehicle getPosATL _gr;
_PS_smoke setParticleClass "MediumSmoke";
_PS_smoke setParticleFire [0.2, 3, 1];
_PS_smoke setDropInterval 0.05;
_PS_smoke attachTo [_gr, [0,0,0]];

_PS_reflact = "#particlesource" createVehicle getPosATL _gr;
_PS_reflact setParticleClass "ObjectDestructionRefract";
_PS_reflact attachTo [_gr, [0,0,0]];

_al_color_flare = [1, 0.7, 0.7];
_al_flare_light = "#lightpoint" createVehicle getPosATL _gr;
_al_flare_light setLightAmbient _al_color_flare;
_al_flare_light setLightColor _al_color_flare;
_al_flare_light setLightIntensity 100;
_al_flare_light setLightUseFlare true;
_al_flare_light setLightFlareSize 1;
_al_flare_light setLightFlareMaxDistance 2500;
_al_flare_light setLightDayLight true;
_al_flare_light attachTo [_gr, [0,0,0]];

sleep 20;
_PS_reflact setDropInterval 0.5;

deleteVehicle _al_flare_light;
deleteVehicle _PS_floorFire;
deleteVehicle _PS_spark0;
deleteVehicle _PS_spark1;
deleteVehicle _SE_ignite;
deleteVehicle _SE_burn;
deleteVehicle _gr;

deleteVehicle nearestObject [_gr, "nvg_targetC"];
deleteVehicle nearestObject [_gr, "nvg_targetW"];
deleteVehicle nearestObject [_gr, "nvg_targetE"];

sleep 3;
deleteVehicle _PS_reflact;
deleteVehicle _PS_smoke;
};
};
  • Offline night
  • Hardened
  • ****
  • Posts: 100

Re: How to move IR grenades to gun store and execute script?

« Reply #4 posted: Apr 08, 2018, 05:34 PM »
So i added it into firstSpawn.sqf under player addEventHandler ["HandleDamage", unitHandleDamage];
It works for me and damages me, but other players see very tiny fire and it doesn't damage them. Also it doesn't damage server spawned vehicles. Any way to make it global?
Thanks!
  • Offline AgentRev
  • Developer
  • Veteran
  • ******
  • Posts: 2600

Re: How to move IR grenades to gun store and execute script?

« Reply #5 posted: Apr 09, 2018, 05:06 AM »
I rewrote the script:
Code: [Select]
/*
IR_TO_INCENDIARY script by SAKY(rkfnql322) rewritten by AgentRev
This script is MP Compatible. This script changes useless IR grenades into incendiary grenade.
3 factional IR Strobes and IR Grenade can be used.
Flame can damage most of helicopters. So can be used to destroy severely damaged helicopters without teamkill penalties.
Also, this has a great damage to un guarded infantry so can be used at CQB.
To use the script, just add the line below in the init.sqf

execVM "addons\scripts\IR_TO_INCENDIARY.sqf";

and add

class saky_fnc_irToIncendiary { jip = 1; };

in CfgRemoteExec Functions.
Have fun!
*/

#define FIRE_AMMO_TYPES ["F_40mm_Cir","IRStrobeBase"] // case-sensitive

#define SLEEP_REALTIME(SECS) _time = diag_tickTime; waitUntil {diag_tickTime - _time >= SECS}

saky_fnc_irToIncendiary =
{
params [["_grenade",objNull,[objNull]], ["_state",0,[0]]];

if ({_grenade isKindOf _x} count FIRE_AMMO_TYPES == 0) exitWith {};

switch (_state) do
{
case 0:
{
SLEEP_REALTIME(2);
[_grenade, 1] remoteExecCall ["saky_fnc_irToIncendiary", 0];
};
case 1:
{
_PS_spark1 = "#particlesource" createVehicleLocal getPosATL _grenade;
_PS_spark1 setParticleClass "FireSparks";
_PS_spark1 setParticleFire [1, 1, 0.5];
_PS_spark1 setDropInterval 0.001;
_PS_spark1 attachTo [_grenade, [0,0,0]];

_SE_ignite = objNull;
if (isServer) then
{
_SE_ignite = createSoundSource ["SoundFlareLoop_F", _grenade, [], 35];
_SE_ignite attachTo [_grenade, [0,0,0]];
};

[_grenade, _PS_spark1, _SE_ignite] spawn
{
params ["_grenade", "_PS_spark1", "_SE_ignite"];

SLEEP_REALTIME(2);
_PS_spark1 setDropInterval 0.01;

if (isServer) then
{
[_grenade, 2] remoteExecCall ["saky_fnc_irToIncendiary", 0, _grenade];
SLEEP_REALTIME(30);

if (_grenade isKindOf "IRStrobeBase") then { deleteVehicle nearestObject [_grenade, "NVG_TargetBase"] };

_PS_spark1 setDropInterval 999;
//deleteVehicle _PS_spark1;
deleteVehicle _grenade;
deleteVehicle _SE_ignite;
}
else
{
waitUntil {isNull _grenade};
deleteVehicle _PS_spark1;
};
};
};
case 2:
{
_SE_burn = objNull;
if (isServer) then
{
_SE_burn = createSoundSource ["Sound_Fire", _grenade, [], 20];
_SE_burn attachTo [_grenade, [0,0,0]];
};

_PS_smoke = "#particlesource" createVehicleLocal getPosATL _grenade;
_PS_smoke setParticleClass "MediumSmoke";
//_PS_smoke setParticleFire [0.2, 3, 1];
_PS_smoke setDropInterval 0.05;
_PS_smoke attachTo [_grenade, [0,0,0]];

_PS_floorFire = "#particlesource" createVehicleLocal getPosATL _grenade;
_PS_floorFire setParticleClass "ExpSparksFire";
_PS_floorFire setParticleFire [0.4, 4, 0.2];
_PS_floorFire setDropInterval 0.001;
_PS_floorFire setParticleRandom [1, [1, 1, 0.1], [3, 3, 1.5], 0.2, 2.5, [0, 0, 0, 0], 0, 0];
_PS_floorFire attachTo [_grenade, [0,0,0]];

_PS_spark0 = "#particlesource" createVehicleLocal getPosATL _grenade;
_PS_spark0 setParticleClass "FireSparksSmall";
_PS_spark0 setParticleFire [0.01, 1, 0.5];
_PS_spark0 setDropInterval 0.0005;
_PS_spark0 attachTo [_grenade, [0,0,0]];

_PS_reflact = "#particlesource" createVehicleLocal getPosATL _grenade;
_PS_reflact setParticleClass "ObjectDestructionRefract";
_PS_reflact attachTo [_grenade, [0,0,0]];

_al_flare_light = objNull;
if (hasInterface) then
{
_al_color_flare = [1, 0.7, 0.7];
_al_flare_light = "#lightpoint" createVehicleLocal getPosATL _grenade;
_al_flare_light setLightAmbient _al_color_flare;
_al_flare_light setLightColor _al_color_flare;
_al_flare_light setLightIntensity 100;
_al_flare_light setLightUseFlare true;
_al_flare_light setLightFlareSize 1;
_al_flare_light setLightFlareMaxDistance 2500;
_al_flare_light setLightDayLight true;
_al_flare_light attachTo [_grenade, [0,0,0]];
};

[_grenade, _SE_burn, _PS_floorFire, _PS_spark0, _PS_smoke, _PS_reflact, _al_flare_light] spawn
{
params ["_grenade", "_SE_burn", "_PS_floorFire", "_PS_spark0", "_PS_smoke", "_PS_reflact", "_al_flare_light"];
waitUntil {isNull _grenade};

deleteVehicle _PS_floorFire;
deleteVehicle _PS_spark0;
deleteVehicle _al_flare_light;
deleteVehicle _SE_burn;
_PS_reflact setDropInterval 0.5;

SLEEP_REALTIME(10);

deleteVehicle _PS_reflact;
deleteVehicle _PS_smoke;
};
};
};
};

if (hasInterface) then
{
waitUntil {!isNull player};

if (!isNil "saky_irToIncendiary_eventFired") then
{
player removeEventHandler ["Fired", saky_irToIncendiary_eventFired];
};

saky_irToIncendiary_eventFired = player addEventHandler ["Fired",
{
if ({(_this select 4) isKindOf _x} count FIRE_AMMO_TYPES > 0) then
{
[_this select 6] spawn saky_fnc_irToIncendiary;
};
}];
};

add the following at the bottom of \init.sqf
Code: [Select]
[] execVM "addons\scripts\IR_TO_INCENDIARY.sqf";
and this at the bottom of \client\CfgRemoteExec_fnc.hpp
Code: [Select]
class saky_fnc_irToIncendiary { jip = 1; };
The only drawback I found is that it doesn't seem to hurt AI. I think it's because the server does not render particles and therefore does not compute damage from setParticleFire.
  • Offline night
  • Hardened
  • ****
  • Posts: 100

Re: How to move IR grenades to gun store and execute script?

« Reply #6 posted: Apr 09, 2018, 10:33 PM »
Works <3
Ain't damaging as much as i expected, but its fun
  • Offline ShineDwarf
  • First Blood
  • ***
  • Posts: 79
  • Co-Owner, Fractured Gaming

Re: How to move IR grenades to gun store and execute script?

« Reply #7 posted: Apr 11, 2018, 03:37 AM »
Just curious, had you tried toxic grenades?
  • Offline night
  • Hardened
  • ****
  • Posts: 100

Re: How to move IR grenades to gun store and execute script?

« Reply #8 posted: Apr 11, 2018, 03:40 AM »
Not in person, but they are on my servers  ;D