Added misc modules from CSE

This commit is contained in:
Thomas Kooi 2015-01-12 23:30:33 +01:00
parent 7e4d7c1083
commit a4383c70f1
8 changed files with 450 additions and 0 deletions

View File

@ -0,0 +1,9 @@
class CfgFunctions {
class CSE {
class ModulesMisc {
file = "cse\cse_sys_misc\functions";
class handleDamage_DMG { recompile = 1;};
class moduleAmbianceSoundLoop { recompile = 1; };
};
};
};

View File

@ -0,0 +1,151 @@
class CfgVehicles
{
class Logic;
class Module_F: Logic {
class ArgumentsBaseUnits {
};
};
class cse_adjust_stamina: Module_F {
scope = 2;
displayName = "Adjust Stamina [CSE]";
icon = "\cse\cse_main\data\cse_medical_module.paa";
category = "cseMisc";
function = "cse_fnc_initalizeModule_F";
functionPriority = 1;
isGlobal = 1;
isTriggerActivated = 0;
author = "Combat Space Enhancement";
class Arguments {
class adjustment {
displayName = "Adjustment";
description = "How fast should the stamina be adjusted?";
typeName = "NUMBER";
defaultValue = 1;
};
};
class ModuleDescription {
description = "Custom stamina adjustment module";
sync[] = {};
};
};
class cse_damage_ai: Module_F {
scope = 1; // hidden, for backwards compatability
displayName = "Damage Thredshold AI [CSE]";
icon = "\cse\cse_main\data\cse_medical_module.paa";
category = "cse_medical";
function = "cse_fnc_initalizeModule_F";
functionPriority = 1;
isGlobal = 1;
isTriggerActivated = 0;
author = "Combat Space Enhancement";
class Arguments {
class damageThresholdAI {
displayName = "Damage Threshold AI";
description = "How much damage does it take for an AI to be killed?";
typeName = "NUMBER";
defaultValue = 1;
};
class damageThresholdPlayers {
displayName = "Damage Threshold Players";
description = "How much damage does it take for a player to be killed?";
typeName = "NUMBER";
defaultValue = 1;
};
};
class ModuleDescription {
description = "Custom damage threshold module"; // Short description, will be formatted as structured text
sync[] = {};
};
};
class cse_moduleDamageSettings: Module_F {
scope = 2;
displayName = "Damage Settings [CSE]";
icon = "\cse\cse_main\data\cse_medical_module.paa";
category = "cse_medical";
function = "cse_fnc_initalizeModule_F";
functionPriority = 1;
isGlobal = 1;
isTriggerActivated = 0;
author = "Combat Space Enhancement";
class Arguments {
class damageThresholdAI {
displayName = "Damage Threshold AI";
description = "How much damage does it take for an AI to be killed?";
typeName = "NUMBER";
defaultValue = 1;
};
class damageThresholdPlayers {
displayName = "Damage Threshold Players";
description = "How much damage does it take for a player to be killed?";
typeName = "NUMBER";
defaultValue = 1;
};
};
class ModuleDescription {
description = "Custom damage threshold module";
sync[] = {};
};
};
class cse_moduleAmbianceSound: Module_F {
scope = 2;
displayName = "Ambiance Sounds [CSE]";
icon = "\cse\cse_main\data\cse_basic_module.paa";
category = "cseMisc";
function = "cse_fnc_moduleAmbianceSoundLoop";
functionPriority = 1;
isGlobal = 1;
isTriggerActivated = 0;
author = "Combat Space Enhancement";
class Arguments {
class soundFiles {
displayName = "Sounds";
description = "Classnames of the ambiance sounds played. Seperated by ','. ";
typeName = "STRING";
defaultValue = "";
};
class minimalDistance {
displayName = "Minimal Distance";
description = "Minimal Distance";
typeName = "NUMBER";
defaultValue = 400;
};
class maximalDistance {
displayName = "Maximal Distance";
description = "Maximal Distance";
typeName = "NUMBER";
defaultValue = 900;
};
class minimalDelay {
displayName = "Minimal Delay";
description = "Minimal Delay between sounds played";
typeName = "NUMBER";
defaultValue = 10;
};
class maximalDelay {
displayName = "Maximal Delay";
description = "Maximal Delay between sounds played";
typeName = "NUMBER";
defaultValue = 170;
};
class followPlayers {
displayName = "Follow Players";
description = "Follow players. If set to false, loop will play sounds only nearby logic position.";
typeName = "BOOL";
defaultValue = 0;
};
class soundVolume {
displayName = "Volume";
description = "The volume of the sounds played";
typeName = "NUMBER";
defaultValue = 0;
};
};
class ModuleDescription {
description = "Ambiance sounds loop (synced across MP)";
sync[] = {};
};
};
};

View File

@ -0,0 +1,32 @@
class Combat_Space_Enhancement {
class cfgModules {
class cse_adjust_stamina {
init = "call compile preprocessFile 'cse\cse_sys_misc\stamina\init.sqf';";
name = "Stamina adjustment";
};
class cse_damage_ai {
init = "call compile preprocessFile 'cse\cse_sys_misc\damage\init.sqf';";
name = "Damage thresholds for AI";
class EventHandlers {
class CAManBase {
handleDamage = "_this call cse_fnc_handleDamage_DMG;";
};
};
};
class cse_moduleDamageSettings {
init = "call compile preprocessFile 'cse\cse_sys_misc\damage\init.sqf';";
name = "Damage thresholds for AI and players";
class EventHandlers {
class CAManBase {
handleDamage = "_this call cse_fnc_handleDamage_DMG;";
};
};
};
class cse_moduleRemoveBodyOnDisconnect {
init = "call compile preprocessFile 'cse\cse_sys_misc\moduleRemoveBodyOnDisconnect.sqf';";
name = "Remove Player bodies on disconnect";
};
};
};

View File

@ -0,0 +1,22 @@
class CfgPatches {
class cse_sys_misc {
units[] = {""};
weapons[] = {};
requiredVersion = 0.1;
requiredAddons[] = {"cse_gui","cse_main", "cse_f_modules", "cse_f_eh"};
version = "0.10.0_rc";
author[] = {"Combat Space Enhancement"};
authorUrl = "http://csemod.com";
};
};
class CfgAddons {
class PreloadAddons {
class cse_sys_misc {
list[] = {"cse_sys_misc"};
};
};
};
#include "CfgFunctions.h"
#include "CfgVehicles.h"
#include "Combat_Space_Enhancement.h"

View File

@ -0,0 +1,34 @@
/*
init.sqf
Usage:
Author: Glowbal
Arguments:
Returns:
Affects: Local
Executes: call
*/
private ["_args"];
_args = _this;
CSE_DAMAGE_THRESHOLD_AI_DMG = 1;
CSE_DAMAGE_THRESHOLD_PLAYERS_DMG = 1;
{
_value = _x select 1;
if (!isnil "_value") then {
if (_x select 0 == "damageThresholdAI") exitwith {
CSE_DAMAGE_THRESHOLD_AI_DMG = _x select 1;
};
if (_x select 0 == "damageThresholdPlayers") exitwith {
CSE_DAMAGE_THRESHOLD_PLAYERS_DMG = _x select 1;
};
};
}foreach _args;
waituntil {!isnil "cse_main"};
["cse_damageBodypart_DMG", 0, false, "dmg"] call cse_fnc_defineVariable;
["cse_damageBodypartPrevious_DMG", 0, false, "dmg"] call cse_fnc_defineVariable;

View File

@ -0,0 +1,61 @@
/**
* handleDamage_DMG.sqf
* @Descr: N/A
* @Author: Glowbal
*
* @Arguments: []
* @Return:
* @PublicAPI: false
*/
private ["_unit","_selectionName","_amountOfDamage", "_previousDamage", "_totalDamage"];
_unit = _this select 0;
_selectionName = _this select 1;
_amountOfDamage = _this select 2;
if (_amountOfDamage > 0.9 && {alive _unit}) then {
_amountOfDamage = 0.9;
};
if !(["cse_sys_medical"] call cse_fnc_isModuleEnabled_F) then {
if !(isPlayer _unit) then {
if (_amountOfDamage >= CSE_DAMAGE_THRESHOLD_AI_DMG) then {
[_unit] call cse_fnc_setDead;
_amountOfDamage = 1;
};
} else {
if (_amountOfDamage >= CSE_DAMAGE_THRESHOLD_PLAYERS_DMG) then {
[_unit] call cse_fnc_setDead;
_amountOfDamage = 1;
};
};
} else {
// let CMS handle the damage
if (([_unit] call cse_fnc_hasMedicalEnabled_CMS)) exitwith {
};
_previousDamage = [_unit,"cse_damageBodypartPrevious_DMG", 0] call cse_fnc_getVariable;
[_unit,"cse_bodyPartStatusPrevious", _amountOfDamage - _previousDamage] call cse_fnc_setVariable;
_totalDamage = [_unit,"cse_damageBodypart_DMG", 0] call cse_fnc_getVariable;
_totalDamage = _totalDamage + (_amountOfDamage - _previousDamage);
[_unit,"cse_damageBodypart_DMG",_totalDamage] call cse_fnc_setVariable;
// we will handle it here.
if !(isPlayer _unit) then {
if (_totalDamage >= CSE_DAMAGE_THRESHOLD_AI_DMG) then {
[_unit] call cse_fnc_setDead;
_amountOfDamage = 1;
};
} else {
if (_totalDamage >= CSE_DAMAGE_THRESHOLD_PLAYERS_DMG) then {
[_unit] call cse_fnc_setDead;
_amountOfDamage = 1;
};
};
};
_amountOfDamage

View File

@ -0,0 +1,98 @@
/**
* fn_moduleAmbianceSoundLoop.sqf
* @Descr: N/A
* @Author: Glowbal
*
* @Arguments: []
* @Return:
* @PublicAPI: false
*/
private ["_logic", "_units", "_activated","_ambianceSounds", "_soundFiles", "_minimalDistance","_maximalDistance", "_minimalDistance", "_maxDelayBetweenSounds", "_allUnits", "_newPos", "_targetUnit", "_soundToPlay", "_soundPath", "_unparsedSounds", "_list", "_splittedList", "_nilCheckPassedList"];
_logic = [_this,0,objNull,[objNull]] call BIS_fnc_param;
_units = [_this,1,[],[[]]] call BIS_fnc_param;
_activated = [_this,2,true,[true]] call BIS_fnc_param;
if (_activated && isServer) then {
_ambianceSounds = [];
_unparsedSounds = _logic getvariable ["soundFiles", ""];
_minimalDistance = (_logic getvariable ["minimalDistance", 400]) max 1;
_maximalDistance = (_logic getvariable ["maximalDistance", 10]) max _minimalDistance;
_minDelayBetweensounds = (_logic getvariable ["minimalDelay", 10]) max 1;
_maxDelayBetweenSounds = (_logic getvariable ["maximalDelay", 170]) max _minDelayBetweensounds;
_volume = (_logic getvariable ["soundVolume", 30]) max 1;
_followPlayers = _logic getvariable ["followPlayers", false];
_splittedList = [_unparsedSounds, ","] call BIS_fnc_splitString;
_nilCheckPassedList = "";
{
_x = [_x] call cse_fnc_string_removeWhiteSpace;
_splittedList set [_foreachIndex, _x];
}foreach _splittedList;
_soundPath = [(str missionConfigFile), 0, -15] call BIS_fnc_trimString;
{
if (isclass (missionConfigFile >> "CfgSounds" >> _x)) then {
_ambianceSounds pushback (_soundPath + (getArray(missionConfigFile >> "CfgSounds" >> _x >> "sound") select 0));
} else {
if (isclass (configFile >> "CfgSounds" >> _x)) then {
_ambianceSounds pushback ((getArray(configFile >> "CfgSounds" >> _x >> "sound") select 0));
};
};
}foreach _splittedList;
if (count _ambianceSounds == 0) exitwith {
[format["No Ambiance sounds available"]] call cse_fnc_debug;
};
{
if !([".", _x, true] call BIS_fnc_inString) then {
[format["Ambiance soundfile does not contain a file extension %1", _x]] call cse_fnc_debug;
_ambianceSounds set [_foreachIndex, _x + ".wss"];
};
}foreach _ambianceSounds;
[format["Ambiance sounds %1", _ambianceSounds]] call cse_fnc_debug;
while {alive _logic} do {
_allUnits = switch (true) do {
case isMultiplayer: {playableUnits};
case isDedicated: {[_logic]};
default {[player]};
};
if (count _allUnits > 0) then {
_targetUnit = _allUnits select (round(random((count _allUnits)-1)));
_newPos = (getPos _targetUnit);
if (!_followPlayers) then {
_newPos = getPos _logic;
};
if (random(1) >= 0.5) then {
if (random(1) >= 0.5) then {
_newPos set [0, (_newPos select 0) + (_minimalDistance + random(_maximalDistance))];
} else {
_newPos set [0, (_newPos select 0) - (_minimalDistance + random(_maximalDistance))];
};
} else {
if (random(1) >= 0.5) then {
_newPos set [1, (_newPos select 1) + (_minimalDistance + random(_maximalDistance))];
} else {
_newPos set [1, (_newPos select 1) - (_minimalDistance + random(_maximalDistance))];
};
};
if ({(_newPos distance _x < (_minimalDistance / 2))}count _allUnits == 0) then {
_soundToPlay = _ambianceSounds select (round(random((count _ambianceSounds)-1)));
playSound3D [_soundToPlay, _targetUnit, false, _newPos, _volume, 1, 1000];
[format["Played a sound %1", _soundToPlay]] call cse_fnc_debug;
sleep (_minDelayBetweensounds + random(_maxDelayBetweenSounds)) min _maxDelayBetweenSounds;
};
};
};
};
true;

View File

@ -0,0 +1,43 @@
/**
* init.sqf
* @Descr: N/A
* @Author: Glowbal
*
* @Arguments: []
* @Return:
* @PublicAPI: false
*/
private ["_args"];
_args = _this;
CSE_STAMINA_ADJUSTMENT_STM = 1;
{
_value = _x select 1;
if (!isnil "_value") then {
if (_x select 0 == "adjustment") then {
CSE_STAMINA_ADJUSTMENT_STM = _x select 1;
};
};
}foreach _args;
if (!hasInterface) exitwith {};
waituntil{!isnil "cse_gui" && !isnil "cse_main"};
if (CSE_STAMINA_ADJUSTMENT_STM > 0) then {
["cse_adjust_stamina", [], {
_currentStamina = getFatigue player;
_difference = _currentStamina - _previousStamina;
if (_difference > 0) then {
_difference = _difference * CSE_STAMINA_ADJUSTMENT_STM;
player setFatigue (_previousStamina + _difference);
_previousStamina = (_previousStamina + _difference);
} else {
_previousStamina = _currentStamina;
};
}] call cse_fnc_addTaskToPool_f;
} else {
player enableFatigue false;
};