Some compiles, start separation of blood system

This commit is contained in:
icomrade
2016-02-27 09:56:53 -05:00
parent 61cbd16de1
commit 18c9e72e15
13 changed files with 684 additions and 2006 deletions

View File

@@ -235,7 +235,7 @@ class CfgSurvival {
class Cow01_EP1: Cow{};
class Goat: Default {
yield = 4;
rawfoodtype = "FoodmuttonRaw";
rawfoodtype = "FoodgoatRaw";
};
class Goat01_EP1: Goat{};
class Goat02_EP1: Goat{};

File diff suppressed because it is too large Load Diff

View File

@@ -18,7 +18,7 @@ CHANGED WEAPON CLASSES
Create switchable blood system with variable.
Convert (if old system) to ItemBloodbag
DZE_UseBloodTypes
bloodBagANEG bloodBagAPOS bloodBagBNEG bloodBagBPOS bloodBagONEG bloodBagOPOS
wholeBloodBagANEG wholeBloodBagAPOS wholeBloodBagBNEG wholeBloodBagBPOS wholeBloodBagONEG wholeBloodBagOPOS
@@ -28,4 +28,7 @@ I.E. ItemCrowbar replaces WeaponHolder_MeleeCrowbar
WeaponHolder_ItemHatchet_DZE
WeaponHolder_MeleeCrowbar
REMOVE TOOL BREAKING, IT'S STUPID
REMOVE TOOL BREAKING, IT'S STUPID
building_spawnLoot_Legacy
building_spawnZombies_Legacy

View File

@@ -1,117 +1,59 @@
/*
Created exclusively for ArmA2:OA - DayZMod
Please request permission to use/alter/distribute from project leader (R4Z0R49)
Modified for DayZ Epoch by [VB]AWOL vbawol@veteranbastards.com.
Spawns loot at the given building.
Single parameter:
object building to spawn loot at
Author:
Foxy
*/
private ["_lootChance"];
_obj = _this;
// lower case to prevent issues with differing case for buildings from map to map.
_type = toLower(typeOf _obj);
#include "\z\addons\dayz_code\util\Vector.hpp"
#include "\z\addons\dayz_code\loot\Loot.hpp"
_config = configFile >> "CfgBuildingLoot" >> _type;
if (DZE_MissionLootTable) then {
_config = missionConfigFile >> "CfgBuildingLoot" >> _type;
};
private
[
"_vectorUp",
"_type",
"_config",
"_lootChance",
"_lootPos",
"_lootGroup",
"_worldPos",
"_existingPile",
"_loot"
];
_vectorUp = vectorUp _this;
if (Vector_Angle(Vector_UP,_vectorUp) > 20) exitWith { 0 };
_type = typeOf _this;
_config = (configFile >> "CfgLoot" >> "Buildings" >> _type);
if (!isClass _config) exitWith {};
_pos = [] + getArray (_config >> "lootPos");
_itemTypes = [] + getArray (_config >> "lootType");
_lootChance = getNumber (_config >> "lootChance");
//_countPositions = count _pos;
_qty = 0; // effective quantity of spawned weaponholder
_lootSpawnBias = 67; //67 between 50 && 100. The lower it is, the lower chance some of the lootpiles will spawn
if (_lootChance <= 0) exitWith {};
// shuffles an array
// parameters: array
// example: _myrandomarray = _myNormalArray call _ShuffleArray;
_ShuffleArray = {
private ["_ar","_rand_array","_rand"];
_ar = _this;
_rand_array = [];
while {count _ar > 0} do {
_rand = (count _ar);
_rand = floor (random _rand);
_rand_array set [count _rand_array, _ar select _rand];
_ar set [_rand, "randarray_del"];
_ar = _ar - ["randarray_del"];
};
_rand_array;
};
_positions = _pos call _ShuffleArray;
// bias for this building. The lower it is, the lower chance some of the lootpiles will spawn
_bias = 50 max _lootSpawnBias;
_bias = 100 min _bias;
_bias = (_bias + random(100 - _bias)) / 100;
//diag_log(format["BIAS:%1 LOOTCHANCE:%2", _bias, _lootChance]);
_lootPos = getArray (_config >> "lootPos");
_lootGroup = Loot_GetGroup(getText(_config >> "lootGroup"));
{
if (count _x == 3) then {
_rnd = (random 1) / _bias;
_iPos = _obj modelToWorld _x;
_nearBy = nearestObjects [_iPos, ["ReammoBox"], 2];
//Get the world position of the spawn position
_worldPos = _this modelToWorld _x;
_worldPos set [2, 0 max (_worldPos select 2)];
//Delete existing lootpiles within 1m of spawn location
{
deleteVehicle _x;
dayz_currentWeaponHolders = dayz_currentWeaponHolders - 1;
}
foreach (_worldPos nearObjects ["ReammoBox", 1]);
if (count _nearBy > 0) then {
_lootChance = _lootChance + 0.05;
};
if (dayz_currentWeaponHolders < dayz_maxMaxWeaponHolders) then {
if (_rnd <= _lootChance) then {
if (count _nearBy == 0) then {
_index = dayz_CBLBase find _type;
_weights = dayz_CBLChances select _index;
_cntWeights = count _weights;
_index = floor(random _cntWeights);
_index = _weights select _index;
_itemType = _itemTypes select _index;
[_itemType select 0, _itemType select 1 , _iPos, 0.0] call spawn_loot;
// diag_log (format["SpawnLoot: Pos: %1, LootType: %2/%3,",_iPos,_itemType select 0,_itemType select 1]);
dayz_currentWeaponHolders = dayz_currentWeaponHolders +1;
//loclout system
_obj setVariable ["looted",diag_tickTime + dayz_tickTimeOffset];
};
};
};
if (_lootChance > random 1 && {dayz_currentWeaponHolders < dayz_maxMaxWeaponHolders}) then
{
Loot_SpawnGroup(_lootGroup, _worldPos);
};
} count _positions;
// small loot
_posSmall = [] + getArray (_config >> "lootPosSmall");
_itemTypesSmall = [] + getArray (_config >> "lootTypeSmall");
_positionsSmall = _posSmall call _ShuffleArray;
{
if (count _x == 3) then {
_rnd = (random 1) / _bias;
_iPos = _obj modelToWorld _x;
_nearBy = nearestObjects [_iPos, ["ReammoBox"], 2];
if (count _nearBy > 0) then {
_lootChance = _lootChance + 0.05;
};
if (dayz_currentWeaponHolders < dayz_maxMaxWeaponHolders) then {
if (_rnd <= _lootChance) then {
if (count _nearBy == 0) then {
_index = dayzE_CBLSBase find _type;
_weights = dayzE_CBLSChances select _index;
_cntWeights = count _weights;
_index = floor(random _cntWeights);
_index = _weights select _index;
//diag_log format["building_spawnLoot.sqf: %1", _itemTypesSmall];
_itemType = _itemTypesSmall select _index;
[_itemType select 0, _itemType select 1, _iPos, 0.0] call spawn_loot_small;
// diag_log (format["SpawnLoot: Pos: %1, LootType: %2/%3,",_iPos,_itemType select 0,_itemType select 1]);
dayz_currentWeaponHolders = dayz_currentWeaponHolders +1;
//loclout system
_obj setVariable ["looted",diag_tickTime + dayz_tickTimeOffset];
};
};
};
};
} count _positionsSmall;
}
foreach _lootPos;

View File

@@ -0,0 +1,117 @@
/*
Created exclusively for ArmA2:OA - DayZMod
Please request permission to use/alter/distribute from project leader (R4Z0R49)
Modified for DayZ Epoch by [VB]AWOL vbawol@veteranbastards.com.
*/
private ["_lootChance"];
_obj = _this;
// lower case to prevent issues with differing case for buildings from map to map.
_type = toLower(typeOf _obj);
_config = configFile >> "CfgBuildingLoot" >> _type;
if (DZE_MissionLootTable) then {
_config = missionConfigFile >> "CfgBuildingLoot" >> _type;
};
_pos = [] + getArray (_config >> "lootPos");
_itemTypes = [] + getArray (_config >> "lootType");
_lootChance = getNumber (_config >> "lootChance");
//_countPositions = count _pos;
_qty = 0; // effective quantity of spawned weaponholder
_lootSpawnBias = 67; //67 between 50 && 100. The lower it is, the lower chance some of the lootpiles will spawn
// shuffles an array
// parameters: array
// example: _myrandomarray = _myNormalArray call _ShuffleArray;
_ShuffleArray = {
private ["_ar","_rand_array","_rand"];
_ar = _this;
_rand_array = [];
while {count _ar > 0} do {
_rand = (count _ar);
_rand = floor (random _rand);
_rand_array set [count _rand_array, _ar select _rand];
_ar set [_rand, "randarray_del"];
_ar = _ar - ["randarray_del"];
};
_rand_array;
};
_positions = _pos call _ShuffleArray;
// bias for this building. The lower it is, the lower chance some of the lootpiles will spawn
_bias = 50 max _lootSpawnBias;
_bias = 100 min _bias;
_bias = (_bias + random(100 - _bias)) / 100;
//diag_log(format["BIAS:%1 LOOTCHANCE:%2", _bias, _lootChance]);
{
if (count _x == 3) then {
_rnd = (random 1) / _bias;
_iPos = _obj modelToWorld _x;
_nearBy = nearestObjects [_iPos, ["ReammoBox"], 2];
if (count _nearBy > 0) then {
_lootChance = _lootChance + 0.05;
};
if (dayz_currentWeaponHolders < dayz_maxMaxWeaponHolders) then {
if (_rnd <= _lootChance) then {
if (count _nearBy == 0) then {
_index = dayz_CBLBase find _type;
_weights = dayz_CBLChances select _index;
_cntWeights = count _weights;
_index = floor(random _cntWeights);
_index = _weights select _index;
_itemType = _itemTypes select _index;
[_itemType select 0, _itemType select 1 , _iPos, 0.0] call spawn_loot;
// diag_log (format["SpawnLoot: Pos: %1, LootType: %2/%3,",_iPos,_itemType select 0,_itemType select 1]);
dayz_currentWeaponHolders = dayz_currentWeaponHolders +1;
//loclout system
_obj setVariable ["looted",diag_tickTime + dayz_tickTimeOffset];
};
};
};
};
} count _positions;
// small loot
_posSmall = [] + getArray (_config >> "lootPosSmall");
_itemTypesSmall = [] + getArray (_config >> "lootTypeSmall");
_positionsSmall = _posSmall call _ShuffleArray;
{
if (count _x == 3) then {
_rnd = (random 1) / _bias;
_iPos = _obj modelToWorld _x;
_nearBy = nearestObjects [_iPos, ["ReammoBox"], 2];
if (count _nearBy > 0) then {
_lootChance = _lootChance + 0.05;
};
if (dayz_currentWeaponHolders < dayz_maxMaxWeaponHolders) then {
if (_rnd <= _lootChance) then {
if (count _nearBy == 0) then {
_index = dayzE_CBLSBase find _type;
_weights = dayzE_CBLSChances select _index;
_cntWeights = count _weights;
_index = floor(random _cntWeights);
_index = _weights select _index;
//diag_log format["building_spawnLoot.sqf: %1", _itemTypesSmall];
_itemType = _itemTypesSmall select _index;
[_itemType select 0, _itemType select 1, _iPos, 0.0] call spawn_loot_small;
// diag_log (format["SpawnLoot: Pos: %1, LootType: %2/%3,",_iPos,_itemType select 0,_itemType select 1]);
dayz_currentWeaponHolders = dayz_currentWeaponHolders +1;
//loclout system
_obj setVariable ["looted",diag_tickTime + dayz_tickTimeOffset];
};
};
};
};
} count _positionsSmall;

View File

@@ -1,62 +1,71 @@
private ["_obj","_type","_config","_canLoot","_unitTypes","_min","_max","_num","_zombieChance","_rnd","_position","_positions","_iPos","_nearBy","_noOneNear"];
//_t1 = diag_tickTime;
if (dayz_maxCurrentZeds > dayz_maxZeds) exitwith {};
if (dayz_CurrentZombies > dayz_maxGlobalZombies) exitwith {};
if (dayz_spawnZombies > dayz_maxLocalZombies) exitwith {};
_obj = _this select 0;
_type = typeOf _obj;
_config = configFile >> "CfgBuildingLoot" >> _type;
if (DZE_MissionLootTable) then {
_config = missionConfigFile >> "CfgBuildingLoot" >> _type;
/*
Created exclusively for ArmA2:OA - DayZMod.
Please request permission to use/alter/distribute from project leader (R4Z0R49)
*/
private ["_wreck","_maxlocalspawned","_maxControlledZombies","_iPos","_nearByZed","_nearByPlayer","_rnd","_positions","_zombieChance","_unitTypes","_min","_max","_num","_clean","_obj","_type","_config","_canLoot","_originalPos","_fastRun","_enabled","_i","_Pos"];
_obj = _this select 0;
_wreck = false;
if (count _this > 1) then {
_wreck = _this select 1;
};
_type = typeOf _obj;
_config = configFile >> "CfgLoot" >> "Buildings" >> _type;
_canLoot = isClass (_config);
_originalPos = getPosATL _obj;
if (_canLoot) then {
//Get zombie class
_zombieChance = getNumber (_config >> "zombieChance");
_rnd = random 1;
_maxlocalspawned = round(dayz_spawnZombies);
//Lets check if we need to divide the amount of zeds
if (r_player_divideinvehicle > 0) then {
_maxlocalspawned = round(dayz_spawnZombies / r_player_divideinvehicle);
};
_maxControlledZombies = round(dayz_maxLocalZombies);
_enabled = false;
if (_canLoot ) then {
//Get zombie class
_unitTypes = getArray (_config >> "zombieClass");
_min = getNumber (_config >> "minRoaming");
_max = getNumber (_config >> "maxRoaming");
//Walking Zombies
_num = (round(random _max)) max _min;
_position = getPosATL _obj;
_noOneNear = (count (_position nearEntities ["CAManBase",30])) == 0;
if (_noOneNear) then {
_positions = getArray (_config >> "lootPosZombie");
if (count _positions > 0) then {
{
if (random 1 < _zombieChance) then {
_iPos = _obj modelToWorld _x;
_nearBy = count (_iPos nearEntities ["zZombie_Base",1]) > 0;
if (!_nearBy) then {
[_iPos,true,_unitTypes] call zombie_generate;
};
};
} count _positions;
} else {
_min = getNumber (_config >> "maxRoaming");
_max = getNumber (_config >> "minRoaming");
_zombieChance = getNumber (_config >> "zombieChance");
for "_i" from 1 to _num do
{
if (random 1 < _zombieChance) then {
[_position,true,_unitTypes] call zombie_generate;
};
};
//Walking Zombies
_num = (round(random _max)) max _min; // + round(_max / 3);
//diag_log ("Class: " + _type + " / Zombies: " + str(_unitTypes) + " / Walking: " + str(_num));
for "_i" from 0 to _num do
{
//_iPos = _obj modelToWorld _originalPos;
if ((_maxlocalspawned < _maxControlledZombies) and (dayz_CurrentNearByZombies < dayz_maxNearByZombies) and (dayz_currentGlobalZombies < dayz_maxGlobalZeds)) then {
[_originalPos,true,_unitTypes,_wreck] call zombie_generate;
};
};
dayz_buildingMonitor set [count dayz_buildingMonitor,_obj];
};
//Add Internal Zombies
if ((random 1) < _zombieChance) then {
_clean = {alive _x} count ((getPosATL _obj) nearEntities ["zZombie_Base",(sizeOf _type)]) == 0;
if (_clean) then {
_positions = getArray (_config >> "zedPos");
//diag_log format["Building: %1 / Positions: %2 / Chance: %3",_type,_positions,_zombieChance];
{
_Pos = [_x select 0, _x select 1, 0];
_rnd = random 1;
if (_rnd < _zombieChance) then {
_iPos = _obj modelToWorld _Pos;
_nearByZed = {alive _x} count (_iPos nearEntities ["zZombie_Base",(((sizeOf _type) * 2) + 10)]) > 0;
_nearByPlayer = ({isPlayer _x} count (_iPos nearEntities ["CAManBase",30])) > 0;
//diag_log ("BUILDING: " + _type + " / " + str(_nearByZed) + " / " + str(_nearByPlayer));
if ((_maxlocalspawned < _maxControlledZombies) and (dayz_CurrentNearByZombies < dayz_maxNearByZombies) and (dayz_currentGlobalZombies < dayz_maxGlobalZeds)) then {
if (!_nearByPlayer and !_nearByZed) then {
[_iPos,false,_unitTypes,false] call zombie_generate;
};
};
};
} forEach _positions;
};
//dayz_buildingMonitor set [count dayz_buildingMonitor,_obj];
};
};
//diag_log ("2 end");

View File

@@ -0,0 +1,62 @@
private ["_obj","_type","_config","_canLoot","_unitTypes","_min","_max","_num","_zombieChance","_rnd","_position","_positions","_iPos","_nearBy","_noOneNear"];
//_t1 = diag_tickTime;
if (dayz_maxCurrentZeds > dayz_maxZeds) exitwith {};
if (dayz_CurrentZombies > dayz_maxGlobalZombies) exitwith {};
if (dayz_spawnZombies > dayz_maxLocalZombies) exitwith {};
_obj = _this select 0;
_type = typeOf _obj;
_config = configFile >> "CfgBuildingLoot" >> _type;
if (DZE_MissionLootTable) then {
_config = missionConfigFile >> "CfgBuildingLoot" >> _type;
};
_canLoot = isClass (_config);
if (_canLoot) then {
//Get zombie class
_zombieChance = getNumber (_config >> "zombieChance");
_rnd = random 1;
//Get zombie class
_unitTypes = getArray (_config >> "zombieClass");
_min = getNumber (_config >> "minRoaming");
_max = getNumber (_config >> "maxRoaming");
//Walking Zombies
_num = (round(random _max)) max _min;
_position = getPosATL _obj;
_noOneNear = (count (_position nearEntities ["CAManBase",30])) == 0;
if (_noOneNear) then {
_positions = getArray (_config >> "lootPosZombie");
if (count _positions > 0) then {
{
if (random 1 < _zombieChance) then {
_iPos = _obj modelToWorld _x;
_nearBy = count (_iPos nearEntities ["zZombie_Base",1]) > 0;
if (!_nearBy) then {
[_iPos,true,_unitTypes] call zombie_generate;
};
};
} count _positions;
} else {
for "_i" from 1 to _num do
{
if (random 1 < _zombieChance) then {
[_position,true,_unitTypes] call zombie_generate;
};
};
};
};
dayz_buildingMonitor set [count dayz_buildingMonitor,_obj];
};

View File

@@ -0,0 +1,61 @@
// (c) facoptere@gmail.com, licensed to DayZMod for the community
"PVCDZ_flies" addPublicVariableEventHandler {
//diag_log format [ "%1 -------------------------------- %2", __FILE__, _this ];
_that = (_this select 1);
_onoff = _that select 0;
_body = _that select 1;
switch _onoff do {
case 0: {
_flies = _body getVariable [ "flies_particle", objNull ];
if (!isNull _flies) then {
deleteVehicle _flies;
_body setVariable [ "flies_particle", nil ];
};
};
default {
if ((isNull (_body getVariable [ "flies_particle", objNull ])) AND {(rain < 0.25)}) then {
_pos = ASLtoATL eyePos _body;
_pos set [2, 0.5 + (_pos select 2)];
_interval = 0.1;
_size = 1.5;
//diag_log format [ "%1 adding flies to %2, at %3", __FILE__, _body, _pos ];
_flies = "#particlesource" createVehicleLocal _pos;
_body setVariable [ "flies_particle", _flies ];
_flies setParticleParams
/*Sprite*/ [["\ca\characters2\OTHER\FLY.p3d", 1, 0, 1, 0], "", // File, Ntieth, Index, Count, Loop(Bool)
/*Type*/ "spaceObject",
/*TimmerPer*/ 1,
/*Lifetime*/ 4,
/*Position*/ [0, 0, 0],
/*MoveVelocity*/ [0, 0, 0.5],
/*Simulation*/ 1, 1.30, 1, 0, //rotationVel, weight, volume, rubbing
/*Scale*/ [0.03, 0.03, 0.03, 0],
/*Color*/ [[1, 1, 1, 1],[1, 1, 1, 1]],
/*AnimSpeed*/ [1.5,0.5],
/*randDirPeriod*/ 0.01,
/*randDirIntesity*/ 0.08,
/*onTimerScript*/ "",
/*DestroyScript*/ "",
/*Follow*/ _body];
// RANDOM / TOLERANCE PARAMS
_flies setParticleRandom
/*LifeTime*/ [2,
/*Position*/ [_size, _size, 0.25],
/*MoveVelocity*/ [0, 0, 0],
/*rotationVel*/ 1,
/*Scale*/ 0.02,
/*Color*/ [0, 0, 0, 0.1],
/*randDirPeriod*/ 0.01,
/*randDirIntesity*/ 0.03,
/*Angle*/ 10];
_flies setDropInterval _interval;
_pos set [2, -0.2 + (_pos select 2)];
};
};
};
};

View File

@@ -0,0 +1,74 @@
/*
Spawns the fire and smoke effect at a crash site.
Based heavily on "\ca\data\particleeffects\scripts\destruction\burn.sqf"
Single parameter:
object crashsite
Author:
Foxy
*/
#define INTENSITY 2
//Local space position of the effects
//Get coordinates from config, if not found use the memory point "smoke"
_position = getArray (configFile >> "CfgVehicles" >> typeOf _this >> "smoke");
if ((count _position) == 0) then { _position = "smoke" };
/**** SMOKE ****/
_color = 0.8 / INTENSITY;
_smoke = "#particlesource" createVehicleLocal getpos _this;
_smoke setDropInterval (0.02 * INTENSITY);
_smoke setParticleParams [
/*Sprite*/ ["\Ca\Data\ParticleEffects\Universal\Universal", 16, 7, 48],
/*????*/ "",
/*Type*/ "Billboard",
/*Frequency*/ 1,
/*Lifetime*/ 3 * INTENSITY,
/*Position*/ _position,
/*MoveVelocity*/ [0, 0, 0.5 * INTENSITY],
/*Simulation*/ 0, 0.05, 0.04, 0.05,
/*Scale*/ [0.5 + 0.5 * INTENSITY, 3 + 3 * INTENSITY],
/*Color*/ [
/**/ [_color, _color, _color, 0.2],
/**/ [_color, _color, _color, 1],
/**/ [_color, _color, _color, 1],
/**/ [0.05 + _color, 0.05 + _color, 0.05 + _color, 0.9],
/**/ [0.1 + _color, 0.1 + _color, 0.1 + _color, 0.6],
/**/ [0.2 + _color, 0.2 + _color, 0.2 + _color, 0.3],
/**/ [1, 1, 1, 0]
/**/ ],
/*Animspeed*/ [0.8, 0.3, 0.25],
/*RandDirPeriod*/ 1,
/*RandDirIntensity*/ 0,
/*OnTimerScript*/ "",
/*DestroyScript*/ "",
/*Follow*/ _this];
_smoke setParticleRandom [
/*LifeTime*/ 0.7 * INTENSITY,
/*Position*/ [1 - INTENSITY / 10, 1 - INTENSITY / 10, 1 - INTENSITY / 10],
/*MoveVelocity*/ [0.2 * INTENSITY, 0.2 * INTENSITY, 0.05 * INTENSITY],
/*RotVelocity*/ 0,
/*Scale*/ 0.3,
/*Color*/ [0.05, 0.05, 0.05, 0],
/*RandDirPeriod*/ 0,
/*RandDirIntensity*/ 0];
/**** LIGHT ****/
_light = "#lightpoint" createVehicleLocal getpos _this;
_light setLightBrightness (INTENSITY / 30);
_light setLightAmbient[0.8, 0.6, 0.2];
_light setLightColor[1, 0.5, 0.4];
if ((typeName _position) == (typeName []))
then { _light lightAttachObject [_this, _position]; }
else { _light lightAttachObject [_this, _this selectionPosition _position]; };

View File

@@ -5,21 +5,22 @@ scriptName "Functions\arrays\fn_selectRandomWeighted.sqf";
Description:
Function to select a random item from an array, taking into account item weights.
The weights should be Numbers between 0 && 1, with a maximum precision of hundreds.
The weights should be Numbers between 0 and 1, with a maximum precision of hundreds.
Parameter(s):
_this select 0: source Array (Array of Any Value)
_this select 1: weights (Array of Number)
Returns:
Any Value selected item
TODO:
[*] Algorithm is inefficient?
*/
private ["_weights","_weighted"];
//_array = _this select 0;
private["_weighted"];
_array = _this select 0;
_weights = _this select 1;
/*
@@ -31,7 +32,7 @@ if ((count _array) > (count _weights)) exitWith {debugLog "Log: [selectRandomWei
//Created weighted array of indices.
_weighted = [];
for "_i" from 0 to ((count _weights) - 1) do
for "_i" from 0 to ((count _weights) - 1) do
{
private ["_weight"];
_weight = _weights select _i;
@@ -39,17 +40,17 @@ for "_i" from 0 to ((count _weights) - 1) do
//Ensure the weight is a Number.
//If it's not, set weight to 0 to exclude it.
if ((typeName _weight) != (typeName 0)) then {diag_log "Log: [selectRandomWeighted] Weights should be Numbers; weight set to 0!"; _weight = 0};
//The weight should be a Number between 0 && 1.
if (_weight < 0) then {diag_log "Log: [selectRandomWeighted] Weights should be more than || equal to 0; weight set to 0!"; _weight = 0};
//if (_weight > 1) then {debugLog "Log: [selectRandomWeighted] Weights should be less than || equal to 1; weight set to 1!"; _weight = 1};
//The weight should be a Number between 0 and 1.
if (_weight < 0) then {diag_log "Log: [selectRandomWeighted] Weights should be more than or equal to 0; weight set to 0!"; _weight = 0};
//if (_weight > 1) then {debugLog "Log: [selectRandomWeighted] Weights should be less than or equal to 1; weight set to 1!"; _weight = 1};
//Normalize the weight for a precision of hundreds.
_weight = round(_weight * 100);
for "_k" from 0 to (_weight - 1) do
for "_k" from 0 to (_weight - 1) do
{
_weighted = _weighted + [_i];
_weighted set [(count _weighted), _i];
};
};
_weighted

View File

@@ -1,4 +1,5 @@
private ["_hrStr","_minStr","_curDate","_hr","_min","_strTime"];
private["_hrStr","_minStr","_strTime"];
_curDate = date;
_hr = _curDate select 3;
_min = _curDate select 4;
@@ -10,4 +11,4 @@ if (_hr == 0) then {_hrStr = "00"};
if (_min < 10) then {_minStr = format["0%1",_min]} else {_minStr = format["%1",_min]};
if (_min == 0) then {_minStr = "00"};
_strTime = format["%1%2 hrs",_hrStr,_minStr];
_strTime;
_strTime

View File

@@ -1,4 +1,6 @@
scriptName "Functions\misc\fn_damageActions.sqf";
#include "\z\addons\dayz_code\util\array.hpp";
/***********************************************************
ADD ACTIONS FOR A CASUALTY
- Function
@@ -68,122 +70,190 @@ if (_inVehicle) then {
} count _weapons;
};
};
//Check if patients
_crew = crew _vehicle;
if (count _crew > 0) then {
_unconscious_crew = [];
{
if (_x getVariable "NORRN_unconscious") then {
_unconscious_crew set [(count _unconscious_crew), _x]
};
} forEach _crew;
_patients = (count _unconscious_crew);
if (_patients > 0) then {
if (!r_action_unload) then {
r_action_unload = true;
_vehType = typeOf _vehicle;
_action = _vehicle addAction [format[localize "str_actions_medical_14",_vehType], "\z\addons\dayz_code\medical\load\unLoad_act.sqf",[player,_vehicle], 0, false, true];
r_player_actions set [count r_player_actions,_action];
};
} else {
if (r_action_unload) then {
call fnc_usec_medic_removeActions;
r_action_unload = false;
};
};
};
} else {
call r_player_removeActions2;
r_player_lastVehicle = objNull;
r_player_lastSeat = [];
};
if (!isNull _menClose && _hasPatient && !r_drag_sqf && !r_action && !_inVehicle && !r_player_unconscious && _isClose) then {
_unit = cursorTarget;
_isDisallowRefuel = typeOf _unit in ["M240Nest_DZ","MMT_Civ","MMT_USMC","Old_bike_TK_CIV_EP1","Old_bike_TK_INS_EP1"];
// player reveal _unit;
_vehClose = (getPosATL player) nearEntities [["Car","Tank","Helicopter","Plane","StaticWeapon","Ship"],5]; //nearestObjects [player, ["Car","Tank","Helicopter","Plane","StaticWeapon","Ship"], 5];
_hasVehicle = ({alive _x} count _vehClose > 0);
_unconscious = _unit getVariable ["NORRN_unconscious", false];
_lowBlood = _unit getVariable ["USEC_lowBlood", false];
_injured = _unit getVariable ["USEC_injured", false];
_inPain = _unit getVariable ["USEC_inPain", false];
_legsBroke = _unit getVariable ["hit_legs", 0] >= 1;
_armsBroke = _unit getVariable ["hit_hands", 0] >= 1;
_charID = _unit getVariable ["CharacterID", 0];
_friendlies = player getVariable ["friendlies", []];
_playerMagazines = magazines player;
_hasBandage = "ItemBandage" in _playerMagazines;
_hasEpi = "ItemEpinephrine" in _playerMagazines;
_hasMorphine = "ItemMorphine" in _playerMagazines;
_hasBlood = "ItemBloodbag" in _playerMagazines;
//_hasToolbox = "ItemToolbox" in items player;
_hasJerry = "ItemJerrycan" in _playerMagazines;
_hasBarrel = "ItemFuelBarrel" in _playerMagazines;
_hasJerryE = "ItemJerrycanEmpty" in _playerMagazines;
_hasBarrelE = "ItemFuelBarrelEmpty" in _playerMagazines;
//_hasEtool = "ItemEtool" in weapons player;
//_hasWire = "ItemWire" in _playerMagazines;
_hasPainkillers = "ItemPainkiller" in _playerMagazines;
if (isPlayer cursorTarget) then {
if (!r_drag_sqf and !r_action and !_inVehicle and !r_player_unconscious and (player distance _menClose < 3)) then {
_unit = cursorTarget;
player reveal _unit;
_isDisallowRefuel = typeOf _unit in ["M240Nest_DZ","MMT_Civ","MMT_USMC","Old_bike_TK_CIV_EP1","Old_bike_TK_INS_EP1"];
_antibiotics =["ItemAntibiotic","ItemAntibiotic1","ItemAntibiotic2","ItemAntibiotic3","ItemAntibiotic4","ItemAntibiotic5","ItemAntibiotic6"];
_bloodBags = ["ItemBloodbag","bloodBagANEG","bloodBagAPOS","bloodBagBNEG","bloodBagBPOS","bloodBagABNEG","bloodBagABPOS","bloodBagONEG","bloodBagOPOS"];
//Allow player to drag
if(_unconscious) then {
r_action = true;
_action1 = _unit addAction [localize "str_actions_medical_01", "\z\addons\dayz_code\medical\drag.sqf",_unit, 0, true, true];
_action2 = _unit addAction [localize "str_actions_medical_02", "\z\addons\dayz_code\medical\pulse.sqf",_unit, 0, true, true];
r_player_actions = r_player_actions + [_action1,_action2];
};
//Load Vehicle
if (_hasVehicle && _unconscious) then {
_x = 0;
r_action = true;
_unit = _unit;
_vehicle = (_vehClose select _x);
while{((!alive _vehicle) && (_x < (count _vehClose)))} do {
_x = _x + 1;
_vehicle = (_vehClose select _x);
};
_vehType = typeOf _vehicle;
_action = _unit addAction [format[localize "str_actions_medical_03",_vehType], "\z\addons\dayz_code\medical\load\load_act.sqf",[player,_vehicle,_unit], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to bandage
if(_injured && _hasBandage) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_04", "\z\addons\dayz_code\medical\bandage.sqf",[_unit], 0, true, true, "", ""];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give Epinephrine
if(_unconscious && _hasEpi) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_05", "\z\addons\dayz_code\medical\epinephrine.sqf",[_unit], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give Morphine
if((_legsBroke || _armsBroke) && _hasMorphine) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_06", "\z\addons\dayz_code\medical\morphine.sqf",[_unit], 0, true, true, "", ""];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give Painkillers
if(_inPain && _hasPainkillers) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_07", "\z\addons\dayz_code\medical\painkiller.sqf",[_unit], 0, true, true, "", ""];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to transfuse blood
if(_lowBlood && _hasBlood) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_08", "\z\addons\dayz_code\medical\transfusion.sqf",[_unit], 0, true, true, "", ""];
r_player_actions set [count r_player_actions,_action];
};
//Repairs
if ((_unit isKindOf "AllVehicles") && !(_unit isKindOf "Man") && !_isDisallowRefuel) then {
_type = TypeOf(_unit);
_typeVeh = getText(configFile >> "cfgVehicles" >> _type >> "displayName");
_vehClose = (getPosATL player) nearEntities [["Car","Tank","Helicopter","Plane","StaticWeapon","Ship"],5]; //nearestObjects [player, ["Car","Tank","Helicopter","Plane","StaticWeapon","Ship"], 5];
_hasVehicle = ({alive _x} count _vehClose > 0);
_unconscious = _unit getVariable ["NORRN_unconscious", false];
_lowBlood = _unit getVariable ["USEC_lowBlood", false];
_injured = _unit getVariable ["USEC_injured", false];
_hasSepsis = _unit getVariable ["USEC_Sepsis", false];
_inPain = _unit getVariable ["USEC_inPain", false];
_legsBroke = _unit getVariable ["hit_legs", 0] >= 1;
_armsBroke = _unit getVariable ["hit_hands", 0] >= 1;
_infected = _unit getVariable ["USEC_infected", false];
_charID = _unit getVariable ["CharacterID", 0];
_friendlies = player getVariable ["friendlies", []];
_playerMagazines = magazines player;
_hasBandage = "ItemBandage" in magazines player;
_hasSepsisBandage = "ItemSepsisBandage" in magazines player;
_hasEpi = "ItemEpinephrine" in magazines player;
_hasMorphine = "ItemMorphine" in magazines player;
_hasSplint = "equip_woodensplint" in magazines player;
_hasPainkillers = "ItemPainkiller" in magazines player;
_hasAntibiotics = Array_Any(magazines player, {_this in _antibiotics});
_hasBloodBag = Array_Any(magazines player, {_this in _bloodBags});
//_hasToolbox = "ItemToolbox" in items player;
_hasJerry = "ItemJerrycan" in _playerMagazines;
_hasBarrel = "ItemFuelBarrel" in _playerMagazines;
_hasJerryE = "ItemJerrycanEmpty" in _playerMagazines;
_hasBarrelE = "ItemFuelBarrelEmpty" in _playerMagazines;
//_hasEtool = "ItemEtool" in weapons player;
//_hasWire = "ItemWire" in _playerMagazines;
_hasPainkillers = "ItemPainkiller" in _playerMagazines;
//CAN WE REFUEL THE OBJECT?
if ((fuel _unit < 1) && (_hasJerry || _hasBarrel)) then {
r_action = true;
_action = _unit addAction [format[localize "str_actions_medical_10",_typeVeh], "\z\addons\dayz_code\actions\refuel.sqf",[], 0, true, true, "", ""];
r_player_actions set [count r_player_actions,_action];
};
//CAN WE siphon fuel from THE OBJECT?
if ((fuel _unit > 0) && (_hasJerryE || _hasBarrelE)) then {
r_action = true;
_action = _unit addAction [format["Siphon fuel from %1",_typeVeh], "\z\addons\dayz_code\actions\siphonFuel.sqf",[], 0, true, true, "", ""];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to drag
if (_hasPatient) then {
if(_unconscious) then {
r_action = true;
_action1 = _unit addAction [localize "STR_UI_GEAR", "\z\addons\dayz_code\actions\openGear.sqf",_unit, 0, true, true];
_action2 = _unit addAction [localize "str_actions_medical_01", "\z\addons\dayz_code\medical\drag.sqf",_unit, 0, true, true];
_action3 = _unit addAction [localize "str_actions_medical_02", "\z\addons\dayz_code\medical\pulse.sqf",_unit, 0, true, true];
} else {
// should only fire if cursor target is man && not vehicle
if ((isPlayer _unit) && !(_charID in _friendlies)) then {
r_action = true;
_action = _unit addAction ["Tag as friendly", "\z\addons\dayz_code\actions\player_tagFriendly.sqf", [], 0, false, true, "", ""];
r_player_actions set [count r_player_actions,_action];
r_player_actions set [count r_player_actions, _action1];
r_player_actions set [count r_player_actions, _action2];
r_player_actions set [count r_player_actions, _action3];
};
//Load Vehicle
if (_hasVehicle and _unconscious) then {
_y = 0;
r_action = true;
_unit = _unit;
_vehicle = (_vehClose select _y);
while{((!alive _vehicle) and (_y < (count _vehClose)))} do {
_y = _y + 1;
_vehicle = (_vehClose select _y);
_vehType = getText (configFile >> "CfgVehicles" >> typeOf _unit >> "displayName");
sleep 0.001;
};
_action = _unit addAction [format[localize "str_actions_medical_03",_vehType], "\z\addons\dayz_code\medical\load\load_act.sqf",[player,_vehicle,_unit], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to bandage
if(_injured && _hasBandage) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_04", "\z\addons\dayz_code\medical\bandage.sqf",[_unit,"ItemBandage"], 0, true, true, "", "'ItemBandage' in magazines player"];
r_player_actions set [count r_player_actions,_action];
};
//Sepsis
if(_hasSepsis and _hasSepsisBandage) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_04", "\z\addons\dayz_code\medical\bandage.sqf",[_unit,"ItemSepsisBandage"], 0, true, true, "", "'ItemBandage' in magazines player"];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give Epinephrine
if(_unconscious && _hasEpi) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_05", "\z\addons\dayz_code\medical\epinephrine.sqf",[_unit], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give Morphine
if((_legsBroke || _armsBroke) && _hasMorphine) then {
r_action = true;
//_action = _unit addAction [localize "str_actions_medical_06", "\z\addons\dayz_code\medical\morphine.sqf",[_unit], 0, true, true, "", ""];
_action = _unit addAction [localize "str_actions_medical_06", "\z\addons\dayz_code\medical\brokeBones.sqf",[_unit,"ItemMorphine"], 0, true, true, "", "'ItemMorphine' in magazines player"];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give equip_woodensplint
if((_legsBroke or _armsBroke) and _hasSplint) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_06_splint", "\z\addons\dayz_code\medical\brokeBones.sqf",[_unit,"equip_woodensplint"], 0, true, true, "", "'equip_woodensplint' in magazines player"];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give Painkillers
if(_inPain && _hasPainkillers) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_07", "\z\addons\dayz_code\medical\painkiller.sqf",[_unit], 0, true, true, "", "'ItemPainkiller' in magazines player"];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to transfuse blood
if(_lowBlood && _hasBlood) then {
if (DZE_UseBloodTypes) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_08", "\z\addons\dayz_code\medical\transfusion.sqf",[_unit], 0, true, true];
r_player_actions set [count r_player_actions,_action];
} else {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_08", "\z\addons\dayz_code\medical\transfusion_NoBloodTypes.sqf",[_unit], 0, true, true, "", ""];
r_player_actions set [count r_player_actions,_action];
};
};
//Allow player to give antibiotics
if (_infected and _hasAntibiotics) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_give_antibiotics", "\z\addons\dayz_code\medical\antibiotics.sqf",[_unit], 0, true, true];
r_player_actions set [count r_player_actions, _action];
};
//Repairs
if ((_unit isKindOf "AllVehicles") && !(_unit isKindOf "Man") && !_isDisallowRefuel) then {
_type = TypeOf(_unit);
_typeVeh = getText(configFile >> "cfgVehicles" >> _type >> "displayName");
//CAN WE REFUEL THE OBJECT?
if ((fuel _unit < 1) && (_hasJerry || _hasBarrel)) then {
r_action = true;
_action = _unit addAction [format[localize "str_actions_medical_10",_typeVeh], "\z\addons\dayz_code\actions\refuel.sqf",[], 0, true, true, "", ""];
r_player_actions set [count r_player_actions,_action];
};
//CAN WE siphon fuel from THE OBJECT?
if ((fuel _unit > 0) && (_hasJerryE || _hasBarrelE)) then {
r_action = true;
_action = _unit addAction [format["Siphon fuel from %1",_typeVeh], "\z\addons\dayz_code\actions\siphonFuel.sqf",[], 0, true, true, "", ""];
r_player_actions set [count r_player_actions,_action];
};
} else {
// should only fire if cursor target is man && not vehicle
if ((isPlayer _unit) && !(_charID in _friendlies)) then {
r_action = true;
_action = _unit addAction ["Tag as friendly", "\z\addons\dayz_code\actions\player_tagFriendly.sqf", [], 0, false, true, "", ""];
r_player_actions set [count r_player_actions,_action];
};
};
if (r_action) then {
r_action_targets set [(count r_action_targets), _unit];
};
if (r_action_unload) then {
r_action_unload = false;
call fnc_usec_medic_removeActions;
};
};
};
if (r_action) then {
r_action_targets = r_action_targets + [_unit];
};
};
@@ -234,6 +304,8 @@ if ((!_isClose || !_hasPatient) && r_action) then {
r_action = false;
};
//Monitor
player setVariable ["damageActions", diag_ticktime, false];
//Pain Effects
//if (r_player_inpain && !r_player_unconscious) then {
// playSound "breath_1";

View File

@@ -0,0 +1,59 @@
private ["_started","_finished","_animState","_isMedic","_num_removed","_unit","_lastused"];
// bleed.sqf
_unit = (_this select 3) select 0;
//_lowBlood = _unit getVariable ["USEC_lowBlood", false];
//_injured = _unit getVariable ["USEC_injured", false];
//_inPain = _unit getVariable ["USEC_inPain", false];
//_lastused = _unit getVariable ["LastTransfusion", time];
// if (_lastused - time < 60) exitwith {cutText [format[(localize "str_actions_medical_18"),_text] , "PLAIN DOWN"]};
call fnc_usec_medic_removeActions;
r_action = false;
// not possible to transfuse while in a vehicle
if (vehicle player != player) exitWith { };
player playActionNow "Medic";
[1,1] call dayz_HungerThirst;
r_interrupt = false;
_animState = animationState player;
r_doLoop = true;
_started = false;
_finished = false;
while {r_doLoop} do {
_animState = animationState player;
_isMedic = ["medic",_animState] call fnc_inString;
if (_isMedic) then {
_started = true;
};
if (_started && !_isMedic) then {
r_doLoop = false;
_finished = true;
};
if (r_interrupt) then {
r_doLoop = false;
};
uiSleep 0.1;
};
r_doLoop = false;
if (_finished) then {
//_unit setVariable["LastTransfusion",time,true]; //reserve for self transfusion
_unit setVariable["USEC_lowBlood",false,true];
_num_removed = ([player,"ItemBloodbag"] call BIS_fnc_invRemove);
if(_num_removed == 1) then {
/* PVS/PVC - Skaronator */
PVDZE_send = [_unit,"Transfuse",[_unit,player]];
publicVariableServer "PVDZE_send";
[player,100] call player_humanityChange;
};
} else {
r_interrupt = false;
player switchMove "";
player playActionNow "stop";
};