Skip to content

Commit

Permalink
Added the fire module #137
Browse files Browse the repository at this point in the history
  • Loading branch information
CreepPork committed Nov 18, 2017
1 parent 9a392e8 commit c1efb6d
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class CfgFunctions
class IED_DamageHandler;
class setSRFrequencies;
class setLRFrequencies;
class effectFire;
};
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
Author: Borivoj Hlava, CreepPork_LV
Description:
Creates a fire effect.
Parameters:
_this select: 0 - NUMBER - Value of the Color Red
_this select: 1 - NUMBER - Value of the Color Green
_this select: 2 - NUMBER - Value of the Color Blue
_this select: 3 - NUMBER - Timeout
_this select: 4 - NUMBER - Damage
_this select: 5 - NUMBER - Effect Size
_this select: 6 - NUMBER - Particle Density
_this select: 7 - NUMBER - Particle Life Time
_this select: 8 - NUMBER - Particle Size
_this select: 9 - NUMBER - Particle Speed
_this select: 10 - NUMBER - Particle Orientation
_this select: 11 - OBJECT - Effect Emitter
_this select: 12 - OBJECT - (Dummy) Logic
_this select: 13 - OBJECT - Unit who placed down the Fire Effect module
Returns:
Nothing
*/

params
[
"_colorRed",
"_colorGreen",
"_colorBlue",
"_timeout",
"_damage",
"_effectSize",
"_particleDensity",
"_particleLifeTime",
"_particleSize",
"_particleSpeed",
"_orientation",
"_emitter",
"_logic",
"_curator"
];

hint "Something's happening!";
systemChat str (getPos _logic);
systemChat str (_logic);
diag_log (format ["Logic Pos: %1 - Logic ref: %2 - Emittor: %3", getPos _logic, _logic, _emitter]);

private _pos = getPos _logic;

//--- particle effect creation
_emitter setParticleParams [["\A3\data_f\ParticleEffects\Universal\Universal",16,10,32],"","billboard",1,_particleLifeTime,[0,0,0],[0,0,0.4*_particleSpeed],0,0.0565,0.05,0.03,[0.9*_particleSize,0],
[[1*_colorRed,1*_colorGreen,1*_colorBlue,-0],[1*_colorRed,1*_colorGreen,1*_colorBlue,-1],[1*_colorRed,1*_colorGreen,1*_colorBlue,-1],[1*_colorRed,1*_colorGreen,1*_colorBlue,-1],[1*_colorRed,1*_colorGreen,1*_colorBlue,-1],[1*_colorRed,1*_colorGreen,1*_colorBlue,0]],
[1], 0.01, 0.02, "", "", "",_orientation,false,-1,[[3,3,3,0]]];
_emitter setParticleRandom [_particleLifeTime/4, [0.15*_effectSize,0.15*_effectSize,0], [0.2,0.2,0], 0.4, 0, [0,0,0,0], 0, 0, 0.2];
if (_damage > 0) then {_emitter setParticleFire [0.6*_damage, 0.25*_damage, 0.1];};
_emitter setDropInterval (1/_particleDensity);

//--- light
private _lightSize = (_particleSize + _effectSize)/2;

private _light = createVehicle ["#lightpoint", (getPos _emitter), [], 0, "NONE"];
_light setPos [_pos select 0,_pos select 1,(_pos select 2) + 0.5];
_light setLightBrightness 1.0;
_light setLightColor [1,0.65,0.4];
_light setLightAmbient [0.15,0.05,0];
_light setLightIntensity (50 + 400*_lightSize);
_light setLightAttenuation [0,0,0,1];
_light setLightDayLight false;
_light attachTo [_logic];

_logic setVariable ["effectLight",[_light],true];

//--- timeout
if (_timeout != 0) then {
[_logic,_timeout, _curator] spawn {
scriptName "fn_moduleEffectsFire_timeoutLoop";
params ["_logic", "_timeout", "_curator"];

sleep _timeout;
deleteVehicle ((_logic getVariable "effectEmitter") select 0);
deleteVehicle ((_logic getVariable "effectLight") select 0);
if (player == _curator) then {deleteVehicle (_logic getVariable ["Achilles_var_createDummyLogic_module", objNull])};
};
}
else
{
[_logic, ((_logic getVariable "effectEmitter") select 0), ((_logic getVariable "effectLight") select 0)] spawn
{
scriptName "fn_moduleEffectsFire_awaitDeletionLoop";
params ["_logic", "_emitter", "_light"];

// Wait until the logic is deleted and clean up the effects
waitUntil {isNull _logic};
deleteVehicle _emitter;
deleteVehicle _light;
};
};
4 changes: 4 additions & 0 deletions @AresModAchillesExpansion/addons/language_f/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,10 @@
<Russian>Композиции объектов</Russian>
<German>Erweiterte Kompositionen</German>
</Key>
<Key ID="STR_EFFECTS_CUSTOM_FIRE">
<Original>Custom Fire</Original>
<English>Custom Fire</English>
</Key>
<Key ID="STR_SPAWN_EFFECT">
<Original>Spawn Effect</Original>
<English>Spawn Effect</English>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ class Achilles_Effects_Function_Base
class modulePersistentSmokePillar {};
class lightSourceAttributes {};
class spawnSmoke {};
class moduleEffectsFire {};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
File: fn_moduleEffectsFire.sqf
Author: Borivoj Hlava, modified by CreepPork_LV
Description:
Module function. Creates fire on position of module.
Parameter(s):
_this select 0 (Object) - Module logic.
Returned value:
None.
*/

params ["_logic"];

// Create our dialog to show all the data
private _dialogResult = [
localize "STR_EFFECTS_CUSTOM_FIRE",
[
[localize "STR_A3_CfgVehicles_ModuleEffectsFire_F_Arguments_ColorRed_0", "", "0.5"],
[localize "STR_A3_CfgVehicles_ModuleEffectsFire_F_Arguments_ColorGreen_0", "", "0.5"],
[localize "STR_A3_CfgVehicles_ModuleEffectsFire_F_Arguments_ColorBlue_0", "", "0.5"],
[localize "STR_A3_CfgVehicles_ModuleEffectsFire_F_Arguments_Timeout_0", "", "0"],
[localize "STR_A3_CfgVehicles_ModuleEffectsFire_F_Arguments_FireDamage_0", "", "1"],
[localize "STR_A3_CfgVehicles_ModuleEffectsFire_F_Arguments_EffectSize_0", "", "1"],
[localize "STR_A3_CfgVehicles_ModuleEffectsFire_F_Arguments_ParticleDensity_0", "", "25"],
[localize "STR_A3_CfgVehicles_ModuleEffectsFire_F_Arguments_ParticleLifeTime_0", "", "0.6"],
[localize "STR_A3_CfgVehicles_ModuleEffectsFire_F_Arguments_ParticleSize_0", "", "1"],
[localize "STR_A3_CfgVehicles_ModuleEffectsFire_F_Arguments_ParticleSpeed_0", "", "1"],
[localize "STR_A3_CfgVehicles_ModuleEffectsFire_F_Arguments_ParticleOrientation_0", "", "0"]
]
] call Ares_fnc_ShowChooseDialog;

// If user pressed cancel
if (_dialogResult isEqualTo []) exitWith {deleteVehicle _logic};

// Send the function to everyone
if (isNil "Achilles_var_moduleEffectFireInit") then
{
Achilles_var_moduleEffectFireInit = true;
publicVariable "Achilles_fnc_effectFire";
};

// Create dummy logic because some users may not have Achilles.
private _dummyLogic = _logic call Achilles_fnc_createDummyLogic;

private _source = "#particlesource" createVehicle (getPos _logic);
_dummyLogic setVariable ["effectEmitter",[_source],true];

private _emitter = (_dummyLogic getVariable "effectEmitter") select 0;
_emitter setPos (getPos _logic);

// Get the data
_dialogResult params
[
"_colorRed",
"_colorGreen",
"_colorBlue",
"_timeout",
"_damage",
"_effectSize",
"_particleDensity",
"_particleLifeTime",
"_particleSize",
"_particleSpeed",
"_orientation"
];

// Convert the strings to numbers
_colorRed = parseNumber _colorRed;
_colorGreen = parseNumber _colorGreen;
_colorBlue = parseNumber _colorBlue;
_timeout = parseNumber _timeout;
_damage = parseNumber _damage;
_effectSize = parseNumber _effectSize;
_particleDensity = parseNumber _particleDensity;
_particleLifeTime = parseNumber _particleLifeTime;
_particleSize = parseNumber _particleSize;
_particleSpeed = parseNumber _particleSpeed;
_orientation = parseNumber _orientation;

if (_colorRed > 1) then {_colorRed = 1};
if (_colorRed < 0) then {_colorRed = 0};
if (_colorGreen > 1) then {_colorGreen = 1};
if (_colorGreen < 0) then {_colorGreen = 0};
if (_colorBlue > 1) then {_colorBlue = 1};
if (_colorBlue < 0) then {_colorBlue = 0};

// Attach the emitter so it moves when the curator's module is adjusted.
_emitter attachTo [_dummyLogic];

// Run the code for everyone on the server
[_colorRed, _colorGreen, _colorBlue, _timeout, _damage, _effectSize, _particleDensity, _particleLifeTime, _particleSize, _particleSpeed, _orientation, _emitter, _dummyLogic, player] remoteExecCall ["Achilles_fnc_effectFire", 0, _dummyLogic]
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
#include "\achilles\modules_f_ares\module_header.hpp"

#define EFFECT_MODULES ["ModuleFlare_F","ModuleSmoke_F","ModuleIRGrenade_F","ModuleChemlight_F","ModuleLightSource_F","ModulePersistentSmokePillar_F","ModuleTracers_F"]
#define EFFECT_MODULES ["ModuleFlare_F","ModuleSmoke_F","ModuleIRGrenade_F","ModuleChemlight_F","ModuleLightSource_F","ModulePersistentSmokePillar_F", "ModuleTracers_F"]
#define NO_CHOICE_MODULES ["ModuleIRGrenade_F","ModuleTracers_F"]

private _spawnPos = position _logic;

private _category_names = EFFECT_MODULES apply {getText (configfile >> "CfgVehicles" >> _x >> "displayName")};
_category_names pushBack (localize "STR_EFFECTS_CUSTOM_FIRE");

_dialogResult =
[
localize "STR_SPAWN_EFFECT",
[
[localize "STR_CATEGORY", _category_names],
[localize "STR_TYPE", ["..."]]
[localize "STR_TYPE", [""]]
],
"Achilles_fnc_RscDisplayAtttributes_SpawnEffect"
] call Ares_fnc_ShowChooseDialog;

if (count _dialogResult == 0) exitWith {};

// If the module picked is the Custom Fire module
if ((_dialogResult select 0) == 7) exitWith {[_logic] call Achilles_fnc_moduleEffectsFire; _deleteModuleOnExit = false};

_module_category = EFFECT_MODULES select (_dialogResult select 0);
private _module_category = EFFECT_MODULES select (_dialogResult select 0);

_module_type = if (_module_category in NO_CHOICE_MODULES) then
private _module_type = if (_module_category in NO_CHOICE_MODULES) then
{
_module_category;
} else
Expand All @@ -31,8 +34,8 @@ _module_type = if (_module_category in NO_CHOICE_MODULES) then
_modules select (_dialogResult select 1);
};

_group = group _logic;
_effect_logic = _group createUnit [_module_type, _spawnPos, [], 0, "NONE"];
private _group = group _logic;
private _effect_logic = _group createUnit [_module_type, _spawnPos, [], 0, "NONE"];
_effect_logic setPos _spawnPos;
[[_effect_logic]] call Ares_fnc_AddUnitsToCurator;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define EFFECT_MODULES ["ModuleFlare_F","ModuleSmoke_F","ModuleIRGrenade_F","ModuleChemlight_F","ModuleLightSource_F","ModulePersistentSmokePillar_F","ModuleTracers_F"]
#define NO_CHOICE_MODULES ["ModuleIRGrenade_F","ModuleTracers_F"]
#define EFFECT_MODULES ["ModuleFlare_F","ModuleSmoke_F","ModuleIRGrenade_F","ModuleChemlight_F","ModuleLightSource_F","ModulePersistentSmokePillar_F","ModuleTracers_F", "CustomFire"]
#define NO_CHOICE_MODULES ["ModuleIRGrenade_F","ModuleTracers_F", "CustomFire"]

#define IDC_CTRL_CATEGORY 20000
#define IDD_DYNAMIC_GUI 133798
Expand Down

0 comments on commit c1efb6d

Please sign in to comment.