Move unused functions to another folder

This commit is contained in:
AirwavesMan
2020-06-10 17:03:31 +02:00
parent 11f10829cb
commit ac79d91ca0
37 changed files with 185 additions and 250 deletions

View File

@@ -0,0 +1,26 @@
Folder for old scripts that are no longer used by epoch. All scripts can still be used without moving it to the missionfile.
//fn_collisions = compile preprocessFileLineNumbers "\z\addons\dayz_code\old\fn_collisions.sqf";
//zombie_generateSwarm = compile preprocessFileLineNumbers "\z\addons\dayz_code\old\swarm_generate.sqf";
//player_zombieSwarmAttack = compile preprocessFileLineNumbers "\z\addons\dayz_code\old\player_zombieSwarmAttack.sqf";
//player_fixHatchet = compile preprocessFileLineNumbers "\z\addons\dayz_code\old\player_fixTools.sqf";
//player_makeFire = compile preprocessFileLineNumbers "\z\addons\dayz_code\old\player_makefire.sqf";
//player_buildVanilla = compile preprocessFileLineNumbers "\z\addons\dayz_code\old\player_buildVanilla.sqf";
//player_buildPlaceables = compile preprocessFileLineNumbers "\z\addons\dayz_code\old\player_buildPlaceables.sqf";
//fn_buildCamera = compile preprocessFileLineNumbers "\z\addons\dayz_code\old\fn_buildCamera.sqf";
//object_build = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\object_build.sqf";
//object_upgradeFireplace = compile preprocessFileLineNumbers "\z\addons\dayz_code\old\object_upgradeFireplace.sqf";
//player_takearrow = compile preprocessFileLineNumbers "\z\addons\dayz_code\old\player_takeArrow.sqf";
//fn_updateCraftUI = compile preprocessFileLineNumbers "\z\addons\dayz_code\old\fn_updateCraftUI.sqf";
//player_craftItemVanilla = compile preprocessFileLineNumbers "\z\addons\dayz_code\old\player_craftItemVanilla.sqf";
//player_craftItemGUI = compile preprocessFileLineNumbers "\z\addons\dayz_code\old\player_craftItemGUI.sqf";
//player_checkRecipe = compile preprocessFileLineNumbers "\z\addons\dayz_code\old\player_checkRecipe.sqf";
//pvs_processSetAccessCode = compile preprocessFile "\z\addons\dayz_code\old\processSetAccessCode.sqf";
//pvs_processAccessCode = compile preprocessFile "\z\addons\dayz_code\old\processAccessCode.sqf";
//player_taskHint = compile preprocessFileLineNumbers "\z\addons\dayz_code\old\player_taskHint.sqf";
//object_cargoCheck = compile preprocessFileLineNumbers "\z\addons\dayz_code\old\object_cargoCheck.sqf";
//player_weaponCheck = compile preprocessFileLineNumbers "\z\addons\dayz_code\old\player_weaponCheck.sqf";
//curTimeStr = compile preprocessFileLineNumbers "\z\addons\dayz_code\old\fn_curTimeStr.sqf";
//fn_niceSpot = compile preprocessFileLineNumbers "\z\addons\dayz_code\old\fn_niceSpot.sqf";
//call compile preprocessFileLineNumbers "\z\addons\dayz_code\old\achievements_init.sqf";
//fnc_Obj_FenceHandleDam = compile preprocessFileLineNumbers "\z\addons\dayz_code\old\fence_handleDam.sqf";

View File

@@ -0,0 +1,64 @@
achievementClientMsg = {
private ["_achievement","_player","_AchievementText","_text","_display","_achievementID","_serverEvent"];
/* Only call this from the server
achievementClientPV = [_achievementID];
owner publicVariableClient "achievementClientPV";
*/
_achievement = (_this select 0) select 0; // what should they get
_player = (_this select 0) select 1; // who to send the message to
_AchievementText = switch (_achievement) do
{
case 0: {"Time Waster"}; // play for over 1 hour straight
case 1: {"High Flyer"}; // 500+ AGL
case 2: {"Grave Robber"}; // Stand near a "mass_grave"
case 3: {"Shopaholic"}; // Visit 5 supermarkets
case 4: {"Top Shopper"}; // Visit 10 supermarkets
case 5: {"Sick Puppy"}; // Visit 4 hospitals
case 6: {"White Collar Worker"}; // Visit 3 offices
case 7: {"Fire Warden"}; // Visit 4 firestations
case 8: {"Slice Of Fried Gold"}; // Visit 8 pubs
case 9: {"Plane Spotter"}; // Visit all 3 ATCs
case 10: {"Trinkets of Deceit"}; // Visit 3 churches
case 11: {"Litter Bug"}; // drop 5 tinned/canned items
case 12: {"Cannibal"}; // eat a piece of raw meat
case 13: {"Hunter Gatherer"}; // gut an animal
case 14: {"Firestarter"}; // light a fire
case 15: {"Steady Aim"}; // make a kill from over 200m
case 16: {"Marksman"}; // make a kill from over 500m
case 17: {"Sniper"}; // make a kill from over 1000m
case 18: {"Bunny Basher"}; // kill a rabbit from over 200m
case 19: {"Clean Bill of Health"}; // cure an infection (ABs)
case 20: {"Medic of the apocalypse"}; // give 4 blood bags
};
_display = false;
_serverEvent = _achievement in [15,16,17];
if (_serverEvent) then {
if ((_achievement == 15) && (!achievement_SteadyAim)) then {
achievement_SteadyAim = true;
_display = true;
};
if ((_achievement == 16) && (!achievement_Marksman)) then {
_display = true;
achievement_Marksman = true;
};
if ((_achievement == 17) && (!achievement_Sniper)) then {
_display = true;
achievement_Sniper = true;
};
}
else
{
_display = true;
};
if (_display) then {
_text = format["<t size='0.5' color='#ffffff'>Achievement<br/><t size='1.0' color='#F56936'>%1</t>",_AchievementText];
null = [_text,0,1,5,2] spawn bis_fnc_dynamictext;
// would like to use localize so text can be tweaked using stringtable.xml
};
};

View File

@@ -0,0 +1 @@
// moved to dayz_code/system/scheduler/sched_achievement.sqf

View File

@@ -0,0 +1,21 @@
achievementServer = {
private ["_playerOwnerID","_player","_achievementID","_achievements"];
_achievementID = (_this select 0) select 0;
_player = (_this select 0) select 1;
_playerOwnerID = owner _player;
diag_log (text format ["Achievement: %1 was awarded to %2", _achievementID, _player]);
_achievements = _player getVariable "Achievements";
_achievements set [_achievementID,1];
_player setVariable ["Achievements",_achievements];
// now send the OSD message to the client that called this
achievementClientPV = [_achievementID];
_playerOwnerID publicVariableClient "achievementClientPV";
};

View File

@@ -0,0 +1,21 @@
// Server only
if (isDedicated) then {
achievementNewDB = true; // true = object_data table (1.8.x), false = instance_deployable table (1.7.x)
call compile preprocessFileLineNumbers "\z\addons\dayz_code\old\achievements\achievementsServer.sqf";
"achievement" addPublicVariableEventHandler {[_this select 1] call achievementServer};
};
// Client only
if (!isDedicated) then {
call compile preprocessFileLineNumbers "\z\addons\dayz_code\old\achievements\achievements.sqf";
// Allow server events to trigger the OSD
"achievementClientPV" addPublicVariableEventHandler {[_this select 1] call achievementClientMsg};
// Start the mustyMonitor
[] execVM "\z\addons\dayz_code\old\achievements\achievementsMonitor.sqf";
};

View File

@@ -0,0 +1,105 @@
/***********************************************************
ASSIGN DAMAGE TO A Object.
Called by "HandleDamage" vehicle Event Handler
- Function fnc_Obj_FenceHandleDam
Wooden Defaults - [Object,[High Explosive(1),Medium Explosive(0.5),Melee damage(0.00001 + random(0.05))]] call fnc_Obj_FenceHandleDam;
Metal Defaults - [Object,[High Explosive(0.5),Medium Explosive(0.25),Melee damage(0.00001 + random(0.005))]] call fnc_Obj_FenceHandleDam;
- return : 0 no damage
--Note, Melee damage runs this script 12 times per hit.
************************************************************/
/*
private["_obj","_total","_damage"];
//Object the EH is assigned too
_obj = ((_this select 0) select 0);
//array holding dam sent to the eventhandler
//_damageArray _this select 1;
if !(((_this select 0) select 4) in ["PipeBomb","explosive_bolt","Hatchet_Swing_Ammo","Crowbar_Swing_Ammo","Machete_Swing_Ammo"]) exitwith { false };
_damage = switch (1==1) do {
case (((_this select 0) select 4) in ["PipeBomb"]): { (((_this select 0) select 1) select 0) }; //0.5 High explosive
case (((_this select 0) select 4) in ["explosive_bolt"]): { (((_this select 0) select 1) select 1) }; //0.25 Medium explosive, maybe grenades and other such items.
case (((_this select 0) select 4) in ["Hatchet_Swing_Ammo","Crowbar_Swing_Ammo","Machete_Swing_Ammo"]): { ((_this select 0) select 2) }; //0.00001 Melee damage,
//default { 0 };
};
//Server running or client
if (isServer) then {
if !(_obj in needUpdate_FenceObjects) then {
needUpdate_FenceObjects set [count needUpdate_FenceObjects, _obj];
};
//TotalDamage Set by the server
_obj setDamage (damage _obj) + _damage;
//diag_log format["Server Reporting - %1",needUpdate_FenceObjects];
} else {
//If its a client send to server for saving and damage setting.
PVDZ_fence_Update = [_obj,(damage _obj) + _damage];
publicVariableServer "PVDZ_fence_Update";
//diag_log ("Client Reporting");
};
//} else {
// //We really coulde just send to server and have the server setDamage
// //send to server then back to owning client/server
// PVDZ_send = [_obj,"objWallDamage",_this];
// publicVariableServer "PVDZ_send";
//};
diag_log format["Object: %1, Damage:%2(%4), Projectile:%3",typeof ((_this select 0) select 0),((damage _obj) + _damage),((_this select 0) select 4),(damage _obj)];
*/
private["_obj","_damage"];
//[_this,[0.5,0.25,0.00001]]
if !(((_this select 0) select 4) in ["PipeBomb","explosive_bolt","Hatchet_Swing_Ammo","Crowbar_Swing_Ammo","Machete_Swing_Ammo"]) exitwith { false };
_obj = ((_this select 0) select 0);
//_selectionName = ((_this select 0) select 1);
//_damage = ((_this select 0) select 2);
//_source = ((_this select 0) select 3);
//_projectile = ((_this select 0) select 4);
//_damageArray = (_this select 1);
_damage = switch (1==1) do {
case (((_this select 0) select 4) in ["PipeBomb"]): { ((_this select 1) select 0) }; //0.5 High explosive
case (((_this select 0) select 4) in ["explosive_bolt"]): { ((_this select 1) select 1) }; //0.25 Medium explosive, maybe grenades and other such items.
case (((_this select 0) select 4) in ["Hatchet_Swing_Ammo","Crowbar_Swing_Ammo","Machete_Swing_Ammo"]): { ((_this select 1) select 2) }; //0.00001 Melee damage,
//default { 0 };
};
//Just incase damage from melee is 0 (higher tier fences have no melee damage) we return false
//if (_damage == 0) then { _damage = false; };
//Server running or client
if (_damage > 0) then {
if (isServer) then {
[_obj,(damage _obj) + _damage,"SERVER",dayz_serverKey] call server_addtoFenceUpdateArray;
//diag_log format["Server Reporting - %1",needUpdate_FenceObjects];
} else {
//If its a client send to server for saving and damage setting.
PVDZ_fence_Update = [_obj,(damage _obj) + _damage,dayz_playerUID,dayz_authKey];
publicVariableServer "PVDZ_fence_Update";
//diag_log ("Client Reporting");
};
};
diag_log format["Object: %1, Damage:%4 + %5(%2), Projectile:%3",(typeof _obj),((damage _obj) + _damage),((_this select 0) select 4),(damage _obj),_damage];
// all "HandleDamage event" functions should return the effective damage that the engine will record for that part
//(damage _obj) + _damage
false

View File

@@ -0,0 +1,30 @@
if (0 != count Dayz_constructionContext) then {
if (dayz_soundMuted) then {call player_toggleSoundMute;}; // disable before fadeSound
if (!(Dayz_constructionContext select 3)) then {
_ghost = Dayz_constructionContext select 0;
if (abs(([_ghost, player] call BIS_fnc_distance2D) - (1 + (sizeOf (typeOf _ghost)) * 0.5)) < 1) then {
showCinemaBorder false;
Dayz_BuildCamera = "camera" camCreate (player modeltoWorld [0,0,2]);
0.2 fadeSound 0.1;
Dayz_BuildCamera cameraeffect ["External", "TOP"];
Dayz_BuildCamera camcommit 0;
Dayz_BuildCamera camsettarget _ghost;
Dayz_BuildCamera camsetFov 0.1;
Dayz_BuildCamera camsetrelpos [-1,0,60];
Dayz_BuildCamera camcommit 0;
Dayz_constructionContext set [3, true];
localize "str_buildCameraOn" call dayz_rollingMessages;
};
}
else {
Dayz_BuildCamera cameraeffect ["terminate", "TOP"];
0.2 fadeSound 1;
player switchCamera (Dayz_constructionContext select 2);
camdestroy Dayz_BuildCamera;
Dayz_constructionContext set [3, false];
localize "str_buildCameraOff" call dayz_rollingMessages;
};
_handled = true; // used by keyboard.sqf
};

View File

@@ -0,0 +1,108 @@
#include "\z\addons\dayz_code\util\Vector.hpp"
_project =
{
private ["_verts","_axis","_min","_max"];
local _verts = +(_this select 0);
local _axis = _this select 1;
{ _verts set [_foreachIndex, Vector_DotProduct_Fast(_axis, _x)] } foreach _verts;
local _min = _verts select 0;
local _max = _min;
{
if (_x < _min) then
{ _min = _x };
if (_x > _max) then
{ _max = _x };
}
foreach _verts;
[_min, _max]
};
_notOverlap =
{
#define AMIN (_this select 0 select 0)
#define AMAX (_this select 0 select 1)
#define BMIN (_this select 1 select 0)
#define BMAX (_this select 1 select 1)
AMAX < BMIN || AMIN > BMAX
};
_boundingBoxVertices =
{
private ["_min","_max","_verts","_v"];
local _min = _this select 0;
local _max = _this select 1;
local _verts = [_min, _max];
_verts resize 8;
local _v = +_min;
_v set [0, _max select 0];
_verts set [2, +_v];
_v set [1, _max select 1];
_verts set [3, +_v];
_v = +_min;
_v set [1, _max select 1];
_verts set [4, +_v];
_v set [2, _max select 2];
_verts set [5, +_v];
_v = +_min;
_v set [0, _max select 0];
_verts set [6, +_v];
_v set [2, _max select 2];
_verts set [7, _v];
_verts
};
_modelToWorld =
{
private ["_object","_verts"];
local _object = _this select 0;
local _verts = _this select 1;
{ _verts set [_foreachIndex, _object modelToWorld _x] } foreach _verts;
_verts
};
_getAxes =
{
private ["_dir","_up","_side"];
local _dir = vectorDir _this;
local _up = vectorUp _this;
local _side = Vector_Rotate3D_Fast(_dir, _up, 90);
[_dir, _side, _up]
};
_collision =
{
private ["_abb","_bbb","_averts","_bverts","_axes","_result"];
local _abb = boundingBox (_this select 0);
local _bbb = boundingBox (_this select 1);
local _averts = [_this select 0, _abb call _boundingBoxVertices] call _modelToWorld;
local _bverts = [_this select 1, _bbb call _boundingBoxVertices] call _modelToWorld;
local _axes = (_this select 0 call _getAxes) + (_this select 1 call _getAxes);
local _result = true;
{
if ([[_averts, _x] call _project, [_bverts, _x] call _project] call _notOverlap) exitWith
{ _result = false };
}
foreach _axes;
_result
};
_this call _collision;

View File

@@ -0,0 +1,14 @@
private["_hrStr","_minStr","_strTime"];
_curDate = date;
_hr = _curDate select 3;
_min = _curDate select 4;
_hrStr = "";
_minStr = "";
if (_hr < 10) then {_hrStr = format["0%1",_hr]} else {_hrStr = format["%1",_hr]};
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

View File

@@ -0,0 +1,214 @@
/*
Created exclusively for ArmA2:OA - DayZMod.
Please request permission to use/alter/distribute from project leader (R4Z0R49) AND the author (facoptere@gmail.com)
*/
// Check/find a spot before pitching "Land_Fire_DZ", "TentStorage", "Wire_cat1", "Sandbag1_DZ" or "Hedgehog_DZ"
// _this 0: object class
// _this 1: object (player) or array (ATL format)
// _this 2: optional, empty array that will be filled by computed boolean: _testonLadder, _testSea, _testPond, _testBuilding, _testSlope, _testDistance
// return a worldspace consisting of array [ direction, ATL position ] or empty array if no position is found
// if 2nd argument is a player, the position returned is just in front of the player, direction is so that the object is "looking to" the player
private ["_booleans","_class","_isPlayer","_size","_testPond","_testBuilding","_testonLadder","_testSlope","_testSea","_testDistance","_noCollision","_dir","_obj","_objectsPond","_ok","_maxdistance","_x","_new","_pos"];
_class = _this select 0;
_pos = _this select 1;
_realSize = {
[[0,0], (boundingBox _this) select 1] call BIS_fnc_distance2D
};
// check that tent position is outside the pool footprint.
// we can't check altitude since pool has no height
_checkPerimeter = {
private ["_inside","_relPos","_point","_boundingBox","_min","_max","_myX","_myY","_building"];
_building = _this select 0;
_point = _this select 1;
_inside = false;
_relPos = _building worldToModel _point;
_boundingBox = boundingBox _building;
//diag_log format ["%1 %2", _relPos, _boundingBox];
_min = _boundingBox select 0;
_max = _boundingBox select 1;
_myX = _relPos select 0;
_myY = _relPos select 1;
if ((_myX > (_min select 0)) and {(_myX < (_max select 0))}) then {
if ((_myY > (_min select 1)) and {(_myY < (_max select 1))}) then {
_inside = true;
};
};
_inside
};
// check if _pos a player object or some ATL coordinates array
_isPlayer = (typeName _pos != "ARRAY");
_testBuilding = true;
_testDistance = _isPlayer;
_maxdistance = 5;
_testonLadder = _isPlayer;
_testPond = false;
_testSea = false;
_testSlope = false;
_noCollision = false;
switch _class do {
case "TentStorage" : { // tent pitching must follow all restrictions
_testPond = true;
_testSea = true;
};
case "DomeTentStorage" : { // tent pitching must follow all restrictions
_testPond = true;
_testSea = true;
};
case "StashSmall" : {
_testPond = true;
_testSea = true;
};
case "StashMedium" : {
_testPond = true;
_testSea = true;
};
case "Land_Fire_DZ" : { // no fire in the water :)
_testPond = true;
_testSea = true;
};
case "CamoNet_DZ" : { // no fire in the water :)
_testPond = true;
_testSea = true;
_testSlope = false;
_noCollision = false;
_testBuilding = false;
};
case "Wire_cat1" : {};
case "Sandbag1_DZ" : {};
case "Hedgehog_DZ" : {};
default { // = vehicles (used for hive maintenance on startup)
_testBuilding = false;
_testSlope = false;
_noCollision = false;
};
};
//diag_log(format["niceSpot: will test: pond:%1 building:%2 slope:%3 sea:%4 distance:%5 collide:%6", _testPond, _testBuilding, _testSlope, _testSea, _testDistance, _noCollision]);
_dir = if (_isPlayer) then {getDir(_pos)} else {0};
_obj = _class createVehicleLocal (getMarkerpos "respawn_west");
uiSleep 0.01;
_size = _obj call _realSize;
if (_isPlayer) then { _size = _size + (_pos call _realSize); };
// compute initial position. If _pos is the player, then the object will be in front of him/her
_new = nil;
_new = if (_isPlayer) then { _pos modeltoworld [0,_size/2,0] } else { _pos };
_new set [2, 0];
// place a temporary object (not colliding or can colliding)
if (_noCollision) then {
deleteVehicle _obj;
uiSleep 0.01;
_obj = _class createVehicleLocal _new;
// get non colliding position
_new = getPosATL _obj;
// get relative angle of object position according to player PoV
if (_isPlayer) then {
_x = _pos worldToModel _new;
_dir = _dir + (if ((_x select 1)==0) then { 0 } else { (_x select 0) atan2 (_x select 1) });
};
} else {
_obj setDir _dir;
_obj setPosATL(_new);
};
if (_testBuilding) then { // let's proceed to the "something or its operator in a building" test
_testBuilding = (([_obj, true] call fnc_isInsideBuilding) // obj in/close to a building (enterable or not)
// or _pos is a player who is in a *enterable* building
OR {(_isPLayer AND {([_pos, false] call fnc_isInsideBuilding)})});
};
deleteVehicle _obj;
uiSleep 0.01;
if (_testPond) then { // let's proceed to the "object in the pond" test (not dirty)
_testPond = false;
_objectsPond = nearestObjects [_new, [], 100];
{
if (((typeOf(_x) == "") // unnamed class?
AND {((((_x worldToModel _new) select 2) < 0)) // below water level?
AND {([_x, _new] call _checkPerimeter)}}) // inside pond square footprint?
AND {(["pond", str(_x), false] call fnc_inString)} // and is actually a pond?
) exitWith {
_testPond = true;
};
} forEach _objectsPond;
};
if (_testSlope) then { // "flat spot" test
_testSlope = false;
_x = _new isflatempty [
0, // don't check collisions
0, // don't look around
(0.1*_size), // slope gradient
_size, // object size
1, // do not check in the sea
false, // don't check far from shore
if (_isPlayer) then {_pos} else {objNull} // not used -- seems buggy.
];
if (count _x < 2) then { // safepos found (gradient ok AND not in sea water)
_testSlope = true;
};
};
if (_testSea) then { // "not in the sea, not on the beach" test
_testSea = false;
_x = _new isflatempty [
0, // don't check collisions
0, // don't look around
999, // do not check slope gradient
_size, // object size
0, // check not in the sea
false, // don't check far from shore
if (_isPlayer) then {_pos} else {objNull} // not used -- seems buggy.
];
if (count _x < 2) then { // safepos found (gradient ok AND not in sea water)
_testSea = true;
}
else {
_x set [2,0];
_x = ATLtoASL _x;
if (_x select 2 < 3) then { // in the wave foam
_testSea = true;
};
};
};
if (_testDistance) then { // check effective distance from the player
_testDistance = ((_pos distance _new) > _maxdistance);
};
if (_testonLadder) then { // forbid item install process if player is on a ladder (or in a vehicle)
_testonLadder = (
((getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState _pos) >> "onLadder")) == 1)
OR {((isPlayer _pos) AND {((vehicle _pos) != _pos)})}
);
};
//diag_log(format["niceSpot: result pond:%1 building:%2 slope:%3 sea:%4 distance:%5 collide:%6", _testPond, _testBuilding, _testSlope, _testSea, _testDistance, _noCollision]);
_ok = !_testPond AND !_testBuilding AND !_testSlope AND !_testSea AND !_testDistance AND !_testonLadder;
if (count _this > 2) then {
_booleans = _this select 2;
_booleans set [0, _testonLadder];
_booleans set [1, _testSea];
_booleans set [2, _testPond];
_booleans set [3, _testBuilding];
_booleans set [4, _testSlope];
_booleans set [5, _testDistance];
//diag_log(format["niceSpot: booleans: %1", _booleans]);
};
if (_ok) then { [round(_dir), _new] } else { [] }

View File

@@ -0,0 +1,359 @@
/*%FSM<COMPILE "C:\Program Files (x86)\Bohemia Interactive\Tools\FSM Editor Personal Edition\scriptedFSM.cfg, DayZ Zombie Combat Agent">*/
/*%FSM<HEAD>*/
/*
item0[] = {"init",0,250,-150.000000,-250.000000,-50.000000,-200.000000,0.000000,"init"};
item1[] = {"End",1,250,175.000000,-250.000000,275.000000,-200.000000,0.000000,"End"};
item2[] = {"Attack",4,218,-150.000000,425.000000,-50.000000,475.000000,0.000000,"Attack"};
item3[] = {"Not_Alive",4,218,50.000000,300.000000,150.000000,350.000000,5.000000,"Not" \n "Alive"};
item4[] = {"Nobody_Near",4,218,50.000000,350.000000,150.000000,400.000000,4.000000,"Nobody" \n "Near"};
item5[] = {"",7,210,-29.000042,321.000000,-20.999958,329.000000,0.000000,""};
item6[] = {"",7,210,-29.000042,370.999939,-20.999958,379.000061,0.000000,""};
item7[] = {"true",8,218,-150.000000,-175.000000,-50.000000,-125.000000,0.000000,"true"};
item8[] = {"Begin",2,250,-150.000000,-100.000000,-50.000000,-50.000000,0.000000,"Begin"};
item9[] = {"Has_Target",4,218,-150.000000,125.000000,-50.000000,175.000000,1.000000,"Has" \n "Target"};
item10[] = {"Chase",2,250,-150.000000,300.000000,-50.000000,350.000000,0.000000,"Chase"};
item11[] = {"",7,210,221.000000,371.000000,229.000000,379.000000,0.000000,""};
item12[] = {"moveToCompleted",4,218,-25.000000,200.000000,75.000000,250.000000,0.000000,"moveToCompleted"};
item13[] = {"",7,210,221.000000,233.500000,229.000000,241.500000,0.000000,""};
item14[] = {"",7,210,221.000000,321.000000,229.000000,329.000000,0.000000,""};
item15[] = {"is_Dedicated",4,218,50.000000,-250.000000,150.000000,-200.000000,5.000000,"is" \n "Dedicated"};
item16[] = {"Cleanup_",2,250,175.000000,150.000000,275.000000,200.000000,0.000000,"Cleanup?"};
item17[] = {"nobody_around",4,218,175.000000,-75.000000,275.000000,-25.000000,0.000000,"nobody" \n "around"};
item18[] = {"someone_here",4,218,300.000000,150.000000,400.000000,200.000000,0.000000,"someone" \n "here"};
item19[] = {"wait",2,250,300.000000,75.000000,400.000000,125.000000,0.000000,"wait"};
item20[] = {"time_up",4,218,300.000000,-75.000000,400.000000,-25.000000,0.000000,"time" \n "up"};
item21[] = {"",7,210,346.000000,8.500000,354.000000,16.500000,0.000000,""};
item22[] = {"",7,210,221.000000,8.500000,229.000000,16.500000,0.000000,""};
item23[] = {"Time_Check",4,218,425.000000,75.000000,525.000000,125.000000,0.000000,"Time" \n "Check"};
item24[] = {"",7,210,346.000000,-166.500000,354.000000,-158.500000,0.000000,""};
item25[] = {"",7,210,221.000000,-166.500000,229.000000,-158.500000,0.000000,""};
item26[] = {"deleted",4,218,425.000000,-75.000000,525.000000,-25.000000,0.000000,"deleted"};
item27[] = {"",7,210,471.000000,-166.500000,479.000000,-158.500000,0.000000,""};
item28[] = {"",7,210,471.000000,8.500000,479.000000,16.500000,0.000000,""};
item29[] = {"Time_Check",4,4314,-275.000000,300.000000,-175.000000,350.000000,0.000000,"Time Check"};
item30[] = {"____FAKE____",9,1200,0.000000,0.000000,0.000000,0.000000,0.000000,"____FAKE____"};
link0[] = {0,7};
link1[] = {0,15};
link2[] = {2,10};
link3[] = {3,14};
link4[] = {4,11};
link5[] = {5,3};
link6[] = {5,6};
link7[] = {6,4};
link8[] = {7,8};
link9[] = {8,9};
link10[] = {9,10};
link11[] = {10,2};
link12[] = {10,5};
link13[] = {10,29};
link14[] = {11,14};
link15[] = {13,16};
link16[] = {14,13};
link17[] = {15,1};
link18[] = {16,18};
link19[] = {16,22};
link20[] = {17,25};
link21[] = {18,19};
link22[] = {19,21};
link23[] = {19,23};
link24[] = {20,24};
link25[] = {21,20};
link26[] = {21,22};
link27[] = {21,28};
link28[] = {22,17};
link29[] = {23,19};
link30[] = {24,25};
link31[] = {25,1};
link32[] = {26,27};
link33[] = {27,24};
link34[] = {28,26};
link35[] = {29,10};
link36[] = {12,30};
link37[] = {30,12};
globals[] = {25.000000,1,0,0,0,640,480,1,163,6316128,1,-438.144928,688.129517,520.129150,-284.928619,838,1030,1};
window[] = {2,-1,-1,-1,-1,910,130,1338,130,3,856};
*//*%FSM</HEAD>*/
class FSM
{
fsmName = "DayZ Zombie Combat Agent";
class States
{
/*%FSM<STATE "init">*/
class init
{
name = "init";
init = /*%FSM<STATEINIT""">*/"_position = _this select 0;" \n
"_agent = _this select 1;" \n
"_target = _this select 2;" \n
"" \n
"" \n
"diag_log (""Agent Initialized: "" + str(_this));"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "is_Dedicated">*/
class is_Dedicated
{
priority = 5.000000;
to="End";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"isDedicated"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "true">*/
class true
{
priority = 0.000000;
to="Begin";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"(!isNil 'dayz_clientPreload' && {dayz_clientPreload}) && !(isNull _agent)"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "End">*/
class End
{
name = "End";
init = /*%FSM<STATEINIT""">*/"if (!isDedicated) then {" \n
" if (!isNull _agent) then {" \n
" deleteVehicle _agent;" \n
" };" \n
"} else {" \n
" [_agent] call zombie_findOwner;" \n
"};"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "Begin">*/
class Begin
{
name = "Begin";
init = /*%FSM<STATEINIT""">*/"_array = [];" \n
"" \n
"_bodyStay = 60;" \n
"" \n
"_timeN = time;" \n
"//hint ""run local zombie"";" \n
"_isSomeone = true;" \n
"" \n
"_targetPos = [];" \n
"_countr = 0;" \n
"" \n
"//Spawn roaming script (individual to unit)" \n
"_entityTime = time;" \n
""/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "Has_Target">*/
class Has_Target
{
priority = 1.000000;
to="Chase";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"!(isNull _target)"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/"_countr = 0;" \n
"_losCheck = 0;" \n
"_cantSee = false;" \n
"_agent forceSpeed 6;" \n
"_targetPos = getPosATL _target;"/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "Chase">*/
class Chase
{
name = "Chase";
init = /*%FSM<STATEINIT""">*/"_timeN = diag_tickTime;" \n
"_timeP = diag_tickTime;" \n
"" \n
"_isAlive = alive _agent;" \n
"_targetPos = getPosATL _target;" \n
"_agent moveTo _targetPos;" \n
"" \n
"_list = (getposATL _agent) nearEntities [[""CAManBase"",""AllVehicles""],dayz_canDelete];" \n
"_isSomeone = ({isPlayer _x} count _list) > 0;" \n
"" \n
"if (_agent distance _target > 10) then {" \n
" _agent setUnitPos ""middle"";" \n
"};" \n
"" \n
" "/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "Not_Alive">*/
class Not_Alive
{
priority = 5.000000;
to="Cleanup_";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"!_isAlive"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/"diag_log (""Not Alive"");" \n
"dayz_swarmSpawnZombies = dayz_swarmSpawnZombies - 1;"/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "Nobody_Near">*/
class Nobody_Near
{
priority = 4.000000;
to="Cleanup_";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"!_isSomeone"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/"dayz_swarmSpawnZombies = dayz_swarmSpawnZombies - 1;"/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "Time_Check">*/
class Time_Check
{
priority = 0.000000;
to="Chase";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"(diag_tickTime - _timeP) > 3"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "Attack">*/
class Attack
{
priority = 0.000000;
to="Chase";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"_agent distance _target < 3 AND (diag_tickTime - _timeN) > 1"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/"_vehicle = (vehicle player);" \n
"_hpList = _vehicle call vehicle_getHitpoints;" \n
"_hp = _hpList call BIS_fnc_selectRandom;" \n
"_wound = getText(configFile >> ""cfgVehicles"" >> (typeOf _vehicle) >> ""HitPoints"" >> _hp >> ""name"");" \n
"" \n
"[_agent, _wound] spawn player_zombieSwarmAttack;"/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "Cleanup_">*/
class Cleanup_
{
name = "Cleanup_";
init = /*%FSM<STATEINIT""">*/"_waitStart = time;" \n
"" \n
"_list = (getposATL _agent) nearEntities [[""CAManBase"",""AllVehicles""],dayz_canDelete];" \n
"_isSomeone = ({isPlayer _x} count _list) > 0;"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "nobody_around">*/
class nobody_around
{
priority = 0.000000;
to="End";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"!_isSomeone"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/"dayz_spawnZombies = dayz_spawnZombies - 1;"/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "someone_here">*/
class someone_here
{
priority = 0.000000;
to="wait";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"_isSomeone"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "wait">*/
class wait
{
name = "wait";
init = /*%FSM<STATEINIT""">*/"_list = (getposATL _agent) nearEntities [[""CAManBase"",""AllVehicles""],dayz_canDelete];" \n
"_isSomeone = ({isPlayer _x} count _list) > 0;" \n
"" \n
"_timeN = time;"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "time_up">*/
class time_up
{
priority = 0.000000;
to="End";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"(time - _waitStart) > 300"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "nobody_around">*/
class nobody_around
{
priority = 0.000000;
to="End";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"!_isSomeone"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/"dayz_spawnZombies = dayz_spawnZombies - 1;"/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "deleted">*/
class deleted
{
priority = 0.000000;
to="End";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"isNull _agent;"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "Time_Check">*/
class Time_Check
{
priority = 0.000000;
to="wait";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"(time - _timeN) > 30"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "____FAKE____">*/
class ____FAKE____
{
name = "____FAKE____";
init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "moveToCompleted">*/
class moveToCompleted
{
priority = 0.000000;
to="____FAKE____";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"moveToCompleted _agent;"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
};
initState="init";
finalStates[] =
{
"End"
};
};
/*%FSM</COMPILE>*/

View File

@@ -0,0 +1,367 @@
/*
Created by ziellos2k exclusively for DayZMod.
Please request permission to use/alter from ziellos2k.
Edited by Alby with permission from ziellos2k.
*/
disableSerialization;
_getItemName = {
private ["_return","_classname"];
_classname = _this select 0;
_return = _classname;
if (isClass (configFile >> "CfgWeapons" >> _classname)) then {
if (isText (configFile >> "CfgWeapons" >> _classname >> "displayName")) then {
_return = getText (configFile >> "CfgWeapons" >> _classname >> "displayName");
};
};
if (isClass (configFile >> "CfgMagazines" >> _classname)) then {
if (isText (configFile >> "CfgMagazines" >> _classname >> "displayName")) then {
_return = getText (configFile >> "CfgMagazines" >> _classname >> "displayName");
};
};
_return;
};
_getItemPicture = {
private ["_return","_classname"];
_classname = _this select 0;
_return = _classname;
if (isClass (configFile >> "CfgWeapons" >> _classname)) then {
_return = getText (configFile >> "CfgWeapons" >> _classname >> "picture");
};
if (isClass (configFile >> "CfgMagazines" >> _classname)) then {
_return = getText (configFile >> "CfgMagazines" >> _classname >> "picture");
};
_return;
};
_inArray = {
private ["_return","_array","_search"];
_array = _this select 0;
_search = _this select 1;
_return = -1;
for "_i" from 0 to (count _array) - 1 do {
if ((_array select _i) select 0 == _search) then {
_return = _i;
};
};
_return;
};
_getGear = {
private ["_return","_index"];
_return = [];
_weapons = [];
_magazines = [];
_nearByPile = nearestObjects [getPosATL player, ["SmallCraftTable_dz"], 3];
if (count _nearByPile > 0) then {
_weaps = getWeaponCargo (_nearByPile select 0);
_mags = getMagazineCargo (_nearByPile select 0);
//diag_log format ["%1, %2", _weaps, _mags];
//Add weapons
_objWpnTypes = _weaps select 0;
_objWpnQty = _weaps select 1;
for "_i" from 0 to (count _objWpnTypes - 1) do {
_obj = _objWpnTypes select _i;
_index = [_return, _obj] call _inArray;
if (_index != -1) then {
_return set [_index, [_obj, ((_return select _index) select 1) + (_objWpnQty select _i), 0]];
} else {
_return set [count _return, [_obj, _objWpnQty select _i, 0]];
};
};
//Add Magazines
_objMagTypes = _mags select 0;
_objMagQty = _mags select 1;
for "_i" from 0 to (count _objMagTypes - 1) do {
_obj = _objMagTypes select _i;
_index = [_return, _obj] call _inArray;
if (_index != -1) then {
_return set [_index, [_obj, ((_return select _index) select 1) + (_objMagQty select _i), 0]];
} else {
_return set [count _return, [_obj, _objMagQty select _i, 0]];
};
};
} else {
_weapons = weapons player;
_magazines = magazines player;
{
_return set [count _return, [_x, 1, 0]];
} forEach (_weapons);
{
if !(_x in MeleeMagazines) then {
_index = [_return, _x] call _inArray;
if (_index != -1) then {
_return set [_index, [_x, ((_return select _index) select 1) + 1, 0]];
} else {
_return set [count _return, [_x, 1, 0]];
};
};
} forEach (_magazines);
};
_return;
};
_init = {
_itemArray = [] call _getGear;
uiNamespace setVariable ["DAYZ_CraftingDialog_Items", _itemArray];
};
_cleanup = {
if (dialog) then { closeDialog 0 };
uiNamespace setVariable ["DAYZ_CraftingDialog", nil];
uiNamespace setVariable ["DAYZ_CraftingDialog_Items", nil];
};
_addItem = {
private ["_selected","_classname","_index","_item","_classname","_gearcount","_tablecount"];
_selected = lbCurSel _list;
_classname = _list lnbData [_selected, 2];
_index = [_itemArray, _classname] call _inArray;
_item = _itemArray select _index;
_classname = _item select 0;
_gearcount = _item select 1;
_tablecount = _item select 2;
if (_gearcount > 0) then {
_gearcount = _gearcount - 1;
_tablecount = _tablecount + 1;
};
_itemArray set [_index, [_classname, _gearcount, _tablecount]];
};
_removeItem = {
private ["_selected","_classname","_index","_item","_classname","_gearcount","_tablecount"];
_selected = lbCurSel _list;
_classname = _list lnbData [_selected, 2];
_index = [_itemArray, _classname] call _inArray;
_item = _itemArray select _index;
_classname = _item select 0;
_gearcount = _item select 1;
_tablecount = _item select 2;
if (_tablecount > 0) then {
_gearcount = _gearcount + 1;
_tablecount = _tablecount - 1;
};
_itemArray set [_index, [_classname, _gearcount, _tablecount]];
};
_update = {
private ["_control","_pictureIndex","_item","_classname","_gearcount","_tablecount","_itemName","_itemPicture","_index"];
lbClear _list;
// clear crafting table boxes
for "_i" from 0 to 50 do {
_control = _display displayCtrl (200 + _i);
_control ctrlSetText "";
};
_pictureIndex = 1;
for "_i" from 0 to (count _itemArray) - 1 do {
_item = _itemArray select _i;
_classname = _item select 0;
_gearcount = _item select 1;
_tablecount = _item select 2;
_itemName = [_classname] call _getItemName;
_itemPicture = [_classname] call _getItemPicture;
_index = _list lnbAddRow [str _gearcount, "", _itemName, str _tablecount];
_list lnbSetData [[_index, 2], _classname];
_list lnbSetPicture [[_index, 1], _itemPicture];
for "_j" from 0 to _tablecount - 1 do {
_control = _display displayCtrl (200 + _pictureIndex);
_control ctrlSetText _itemPicture;
_pictureIndex = _pictureIndex + 1;
};
};
};
_craftItem = {
private ["_classList","_countList","_item","_classname","_tablecount","_arrayToSend"];
_classList = [];
_countList = [];
for "_i" from 0 to (count _itemArray) - 1 do {
_item = _itemArray select _i;
_classname = _item select 0;
_tablecount = _item select 2;
if (_tablecount > 0) then {
_classList set [count _classList, _classname];
_countList set [count _countList, _tablecount];
};
};
if (count _classList > 0) then {
_arrayToSend = [_classList,_countList];
[_arrayToSend] call player_checkRecipe;
};
};
_construction = {
private ["_classList","_countList","_item","_classname","_tablecount","_arrayToSend"];
_classList = [];
_countList = [];
for "_i" from 0 to (count _itemArray) - 1 do {
_item = _itemArray select _i;
_classname = _item select 0;
_tablecount = _item select 2;
if (_tablecount > 0) then {
_classList set [count _classList, _classname];
_countList set [count _countList, _tablecount];
};
};
if (count _classList > 0) then {
_arrayToSend = [_classList,_countList];
[_arrayToSend] call player_checkConstructionRecipe;
};
};
_getRecipes = {
private["_config","_control","_controlPos","_msg","_lines"];
_config = configFile >> "CfgCrafting";
_control = _display displayCtrl 430;
_controlPos = ctrlPosition _control;
_msg = "";
_lines = 0;
for "_i" from 0 to ((count _config) - 1) do {
_entry = _config select _i;
_input = getArray (_entry >> "input");
_itemMsg = "";
if (count _input > 0) then {
_isRecipe = true;
{
_item = _x select 0;
_amount = _x select 2;
if (typeName _item == "ARRAY") then {
_amount = _item select 2;
_item = _item select 0;
};
_itemMsg = _itemMsg + format ["%1 %2<br />", _amount, [_item] call _getItemName];
_lines = _lines + 1;
} forEach _input;
_msg = _msg + format ["<t size='1.25'>%1</t><br />%2<br />", getText (_entry >> "displayName"), _itemMsg];
_lines = _lines + 2.25;
};
};
_control ctrlSetPosition [_controlPos select 0, _controlPos select 1, _controlPos select 2, 0.03921 * _lines]; // text size * numoflines
_control ctrlSetStructuredText parseText _msg;
_control ctrlCommit 0;
};
_getconstructionRecipes = {
private["_config","_control","_controlPos","_msg","_lines"];
_config = configFile >> "CfgConstruction";
_control = _display displayCtrl 430;
_controlPos = ctrlPosition _control;
_msg = "";
_lines = 0;
for "_i" from 0 to ((count _config) - 1) do {
_entry = _config select _i;
_input = getArray (_entry >> "input");
_itemMsg = "";
if (count _input > 0) then {
_isRecipe = true;
{
_item = _x select 0;
_amount = _x select 2;
if (typeName _item == "ARRAY") then {
_amount = _item select 2;
_item = _item select 0;
};
_itemMsg = _itemMsg + format ["%1 %2<br />", _amount, [_item] call _getItemName];
_lines = _lines + 1;
} forEach _input;
_msg = _msg + format ["<t size='1.25'>%1</t><br />%2<br />", getText (_entry >> "displayName"), _itemMsg];
_lines = _lines + 2.25;
};
};
_control ctrlSetPosition [_controlPos select 0, _controlPos select 1, _controlPos select 2, 0.03921 * _lines]; // text size * numoflines
_control ctrlSetStructuredText parseText _msg;
_control ctrlCommit 0;
};
_display = uiNamespace getVariable ["DAYZ_CraftingDialog", nil];
_itemArray = uiNamespace getVariable ["DAYZ_CraftingDialog_Items", []];
_list = _display displayCtrl 432;
_event = _this select 0;
switch (_event) do {
case "initcrafting": {
[] call _init;
[] call _update;
[] call _getRecipes;
};
case "initconstruction": {
[] call _init;
[] call _update;
[] call _getconstructionRecipes;
};
case "add": {
[] call _addItem;
[] call _update;
};
case "remove": {
[] call _removeItem;
[] call _update;
};
case "craft": {
[] call _craftItem;
};
case "close": {
[] call _cleanup;
};
case "construction": {
[] call _construction;
};
};

View File

@@ -0,0 +1,108 @@
private ["_status","_array","_object","_items","_classname","_text","_build","_inside","_location","_nearObjects","_dis","_sfx","_variables","_ghost","_keepOnSlope","_direction","_passcode"];
_array = _this select 3;
_ghost = _array select 0;
_object = nil;
_items = _array select 1;
_classname = _array select 2;
_text = _array select 3;
_build = _array select 4;
_dis = _array select 5;
_sfx = _array select 6;
_uid = getPlayerUID player;
_keepOnSlope = 0 == (getNumber (configFile >> "CfgVehicles" >> _classname >> "canbevertical"));
//_damageArray = (getArray (configFile >> "CfgVehicles" >> _classname >> "damageValues"));
Dayz_constructionContext set [ 4, false ]; // Stop the construction mode, cf. player_build.sqf
//if (count Dayz_constructionContext < 5) then { Dayz_constructionContext set [ 5, false ]; // };
if (_build) then {
_location = getPosATL _ghost;
_direction = getDir _ghost;
_object = createVehicle [_classname, getMarkerpos "respawn_west", [], 0, "NONE"];
_object setDir _direction;
diag_log (Dayz_constructionContext);
if ((Dayz_constructionContext select 5) or (_keepOnSlope)) then {
_object setVectorUp surfaceNormal _location;
_location set [2,0];
} else {
_object setVectorUp [0,0,1];
if (_location select 2 == 0) then { _location set [2, -0.01]; };
};
deleteVehicle _ghost;
[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
[player,_dis,true,(getPosATL player)] call player_alertZombies;
["Working",0,[20,40,15,0]] call dayz_NutritionSystem; // Added Nutrition-Factor for work
player playActionNow "Medic";
//wait animation end
waitUntil {getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "disableWeapons") == 1};
waitUntil {getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "disableWeapons") == 0};
_object setPosATL _location;
player reveal _object;
_variables = [];
if (_object iskindof "DZ_buildables") then {
_passcode = [floor(random 10),floor(random 10),floor(random 10),floor(random 10)];
_object setVariable ["ownerArray",[getPlayerUID player],true];
_object setVariable ["dayz_padlockCombination",_passcode,true];
_variables set [ count _variables, ["ownerArray", [getPlayerUID player]]];
_variables set [ count _variables, ["padlockCombination", _passcode]];
//_object removeAllEventHandlers "HandleDamage";
//_object addeventhandler ["HandleDamage",{ [_this,_damageArray] call fnc_Obj_FenceHandleDam; } ];
};
_object setVariable ["characterID",dayz_characterID, true];
if (_object isKindOf "TrapItems") then {
if (getNumber (configFile >> "CfgVehicles" >> typeOf _object >> "initState") > 0) then {
_object setVariable ["armed", true, true];
} else {
_object setVariable ["armed", false, true];
};
_variables set [ count _variables, ["armed", _object getVariable "armed"]];
};
/* //set fuel, Later use Generator
if (typeOf _object == "Generator_DZ") then {
diag_log format["Object: %1, Fuel: %2",_object,fuel _object];
if (local _object) then {
_object setFuel 0;
} else {
PVDZ_send = [_object,"SetFuel",[_object,0]];
publicVariableServer "PVDZ_send";
};
};
*/
_object setVariable ["characterID",dayz_characterID,true];
PVDZ_obj_Publish = [dayz_characterID,_object,[round _direction,_location],_variables,player,dayz_authKey];
publicVariableServer "PVDZ_obj_Publish";
diag_log [diag_ticktime, __FILE__, "New Networked object, request to save to hive. PVDZ_obj_Publish:", PVDZ_obj_Publish];
format[localize "str_build_01",_text] call dayz_rollingMessages;
} else {
if ((!isNil "_ghost") and {(!isNull _ghost)}) then { deleteVehicle _ghost; };
{
if (isClass (configFile >> "CfgMagazines" >> _x)) then {
player addMagazine _x;
};
} foreach _items;
format[localize "str_build_failed_02",_text] call dayz_rollingMessages;
};

View File

@@ -0,0 +1,58 @@
//_newObjects = [_previous,weapons player] call player_weaponCheck;
private["_change","_currentTypes","_currentQty","_previousTypes","_previousQty","_serial"];
_currentObjects = _this select 0;
_checkObjects = _this select 1;
_change = false;
if (count _currentObjects > 1) then {
_currentTypes = _currentObjects select 0;
_currentQty = _currentObjects select 1;
} else {
_currentTypes = [];
_currentQty = [];
};
if (count _checkObjects > 1) then {
_previousTypes = _checkObjects select 0;
_previousQty = _checkObjects select 1;
} else {
_previousTypes = [];
_previousQty = [];
};
//Check if some of old loadout not there
//Review current loadout
_serial = 0;
{
_itemVal = _x;
_itemQty = _currentQty select _serial;
_oldSerial = _previousTypes find _itemVal;
_oldQty = 0;
if (_oldSerial >= 0) then {
_oldQty = _previousQty select _oldSerial;
};
if (_itemQty != _oldQty) then {_change = true};
_serial = _serial + 1;
} forEach _currentTypes;
//Review old loadout
_serial = 0;
{
_itemVal = _x;
_itemQty = _previousQty select _serial;
_oldSerial = _currentTypes find _itemVal;
_oldQty = 0;
if (_oldSerial >= 0) then {
_oldQty = _currentQty select _oldSerial;
};
if (_itemQty != _oldQty) then {_change = true};
_serial = _serial + 1;
} forEach _previousTypes;
_change;

View File

@@ -0,0 +1,164 @@
/*
This script is not part of dayz permission must be given to use. r4z0r49@gmail.com or skype me R4Z0R49.
Simple class system to use this script.
class Upgrade {
requiredTools[] = {"ItemToolbox"};
requiredParts[] = {"equip_crate","PartWoodPile"};
create = "TentStorage1";
};
*/
private ["_objclass","_cursorTarget","_item","_classname","_requiredTools","_requiredParts","_upgrade","_upgradeConfig",
"_upgradeDisplayname","_onLadder","_isWater","_upgradeParts","_startUpgrade","_missingPartsConfig","_textMissingParts","_dis",
"_sfx","_ownerID","_objectID","_objectUID","_dir","_weapons","_magazines","_backpacks",
"_object","_itemName","_vector","_finished"];
_cursorTarget = _this select 0;
if ((isNil "_cursorTarget") or {(isNull _cursorTarget)}) then {
_cursorTarget = nearestObjects [ player modelToWorld [0,1.5,0] , ["Land_Fire_DZ"], 1.5];
_cursorTarget = if (count _cursorTarget == 0) then { objNull } else { _cursorTarget select 0 };
};
if (isNull _cursorTarget) exitWith {};
if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;};
dayz_actionInProgress = true;
_item = typeof _cursorTarget;
//remove action menu
player removeAction s_player_upgradestorage;
s_player_upgradestorage = -1;
//Not needed
//_itemName = getText (configFile >> "CfgVehicles" >> _item >> "displayName");
////diag_log (str(_itemName));
//Get tools needed
_classname = configFile >> "CfgVehicles" >> _item;
_requiredTools = getArray (_classname >> "Upgrade" >> "requiredTools");
//diag_log (str(_requiredTools));
//get parts needed
_requiredParts = getArray (_classname >> "Upgrade" >> "requiredParts");
//diag_log (str(_requiredParts));
//get item to create
_upgrade = getText (_classname >> "Upgrade" >> "create");
//diag_log (str(_upgrade));
//Display name of upgrade part
_upgradeConfig = configFile >> "CfgVehicles" >> _upgrade;
//diag_log (str(_upgradeConfig));
_upgradeDisplayname = getText (_upgradeConfig >> "displayName");
//diag_log (str(_upgradeDisplayname));
//Normal blocked stuff
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
_isWater = (surfaceIsWater (getPosATL player)) or dayz_isSwimming;
_upgradeParts = [];
_startUpgrade = true;
if(_isWater or _onLadder) exitWith { localize "str_CannotUpgrade" call dayz_rollingMessages; dayz_actionInProgress = false; };
// lets check player has requiredTools for upgrade
{
if (!(_x IN items player)) exitWith {
_missingPartsConfig = configFile >> "CfgVehicles" >> _x;
_textMissingParts = getText (_missingPartsConfig >> "displayName");
//systemChat format["Missing %1 to upgrade storage.", _textMissingParts];
format [localize "str_missing_to_do_this", _textMissingParts] call dayz_rollingMessages;
_startUpgrade = false;
};
} count _requiredTools;
// lets check player has requiredParts for upgrade
{
if (!(_x IN magazines player)) exitWith {
_missingPartsConfig = configFile >> "CfgMagazines" >> _x;
_textMissingParts = getText (_missingPartsConfig >> "displayName");
//systemChat format["Missing %1 to upgrade storage.", _textMissingParts];
format [localize "str_missing_to_do_this", _textMissingParts] call dayz_rollingMessages;
_startUpgrade = false;
};
if (_x IN magazines player) then {
_upgradeParts set [count _upgradeParts, _x];
};
} count _requiredParts;
//Does object have a upgrade option.
if ((_startUpgrade) AND (isClass(_upgradeConfig))) then {
_dis = 20;
_sfx = "tentpack";
[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
[player,_dis,true,(getPosATL player)] call player_alertZombies;
_finished = ["Medic",1] call fn_loopAction;
//Double check player did not drop required parts
if (!_finished or (isNull _cursorTarget) or ({!(_x in magazines player)} count _upgradeParts > 0)) exitWith {};
// Added Nutrition-Factor for work
["Working",0,[100,15,5,0]] call dayz_NutritionSystem;
//get ownerID from old tent.
_ownerID = _cursorTarget getVariable ["characterID","0"];
_objectID = _cursorTarget getVariable ["ObjectID","0"];
_objectUID = _cursorTarget getVariable ["ObjectUID","0"];
//Get location and direction of old item
_dir = round getDir _cursorTarget;
_vector = [vectorDir _cursorTarget,vectorUp _cursorTarget];
//reset orientation before measuring position, otherwise the new object will be placed incorrectly. -foxy
_cursorTarget setDir 0;
_pos = getPosATL _cursorTarget;
if (abs(((_vector select 1) select 2) - 1) > 0.001) then { _pos set [2,0]; };
//get contents
_magazines = getMagazineCargo _cursorTarget;
deleteVehicle _cursorTarget;
// remove parts from players inventory before creation of new tent.
{
player removeMagazine _x;
_upgradeParts = _upgradeParts - [_x];
} count _upgradeParts;
//create new tent
_object = createVehicle [_upgrade, getMarkerpos "respawn_west", [], 0, "CAN_COLLIDE"];
//reseting orientation to make sure the object goes where it's supposed to -foxy
_object setDir 0;
_object setPosATL _pos;
_object setVectorDirAndUp _vector;
//set ownerID from old tent.
_object setVariable ["characterID",_ownerID];
//Make sure player knows about the new object
player reveal _object;
[[],_magazines,[],_object] call fn_addCargo;
//Light fire
[_object,true] call dayz_inflame;
_object spawn player_fireMonitor;
PVDZ_obj_Publish = [dayz_characterID,_object,[_dir,_pos],[[[],[]],_magazines,[[],[]]],player,dayz_authKey];
publicVariableServer "PVDZ_obj_Publish";
diag_log [diag_ticktime, __FILE__, "New Networked object, request to save to hive. PVDZ_obj_Publish:", PVDZ_obj_Publish];
localize "str_upgradeDone" call dayz_rollingMessages;
/*
} else {
localize "str_upgradeNoOption" call dayz_rollingMessages;
*/
};
dayz_actionInProgress = false;

View File

@@ -0,0 +1,288 @@
private ["_classType","_item","_action","_missingTools","_missingItem","_emergingLevel","_isClass","_classname","_requiredTools",
"_requiredParts","_ghost","_text","_onLadder","_isWater","_object","_actionBuildHidden","_getBeams",
"_o","_offset","_rot","_r","_p","_bn","_bb","_h","_bx","_by","_minElevation","_maxElevation",
"_check","_min","_max","_objColliding","_a","_beams","_best","_b","_d","_checkNotBuried","_elevation","_position","_delta","_overElevation",
"_maxplanting","_safeDistance","_dir","_angleRef","_tmp","_actionCancel","_sfx","_actionBuild","_keepOnSlope","_msg",
"_ok","_missing","_upgradeParts","_posReference"];
if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;};
dayz_actionInProgress = true;
call gear_ui_init;
closeDialog 1;
_item = _this select 0;
_action = _this select 1;
_classType = "ItemActions";
if (count _this > 2) then {
_classType = _this select 2;
};
_emergingLevel = 1.1;
_isClass = switch (1==1) do {
case (isClass (configFile >> "CfgMagazines" >> _item)): {"CfgMagazines"};
case (isClass (configFile >> "CfgWeapons" >> _item)): {"CfgWeapons"};
};
//need to swap all build systems to this "ItemActions"
_classname = getText (configFile >> _isClass >> _item >> _classType >> _action >> "create");
_requiredTools = getArray (configFile >> _isClass >> _item >> _classType >> _action >> "require");
_requiredParts = getArray (configFile >> _isClass >> _item >> _classType >> _action >> "consume");
_ghost = getText (configFile >> _isClass >> _item >> _classType >> _action >> "ghost");
if (_ghost == "") then { _ghost = _classname; };
_text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
_keepOnSlope = 0 == (getNumber (configFile >> "CfgVehicles" >> _classname >> "canbevertical"));
_onLadder = {getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder") == 1};
_isWater = {(surfaceIsWater (getPosATL _object)) or dayz_isSwimming};
if (0 != count Dayz_constructionContext) exitWith {
dayz_actionInProgress = false;
localize "str_already_building" call dayz_rollingMessages;
};
_posReference = [player] call FNC_GetPos;
_canBuild = [_posReference, _item, false] call DZE_BuildChecks;
if !(_canBuild select 0) exitWith {dayz_actionInProgress = false;};
// lets check player has requiredTools for upgrade
_ok = true;
_missing = "";
{
if (!(_x IN items player)) exitWith {
//systemchat("Missing tools for upgrade." +str());
_missing = getText (configFile >> "CfgWeapons" >> _x >> "displayName");
_ok = false;
};
} count _requiredTools;
if (!_ok) exitWith {
dayz_actionInProgress = false;
//cutText [format [localize "str_player_31_missingtools",_text,_missing] , "PLAIN DOWN"];
_msg = format [localize "str_player_31_missingtools",_text,_missing];
_msg call dayz_rollingMessages;
};
// lets check player has requiredParts for upgrade
_ok = true;
_upgradeParts = [];
{
if (!(_x IN magazines player)) exitWith {
_missing = getText (configFile >> "CfgMagazines" >> _x >> "displayName");
_ok = false;
};
if (_x IN magazines player) then {
_upgradeParts set [count _upgradeParts, _x];
player removeMagazine _x;
};
} count _requiredParts;
if (!_ok) exitWith {
{ player addMagazine _x; } foreach _upgradeParts;
dayz_actionInProgress = false;
// cutText [format [localize "str_player_31", _missing, localize "str_player_31_build"] , "PLAIN DOWN"];
_msg = format [localize "str_player_31", _missing, localize "str_player_31_build"];
_msg call dayz_rollingMessages;
};
_msg = localize "str_player_build_rotate";
_msg call dayz_rollingMessages;
//Get fence beams based on model
_getBeams = {
private [ "_p", "_r", "_bn", "_bb", "_bx", "_by" ];
_o = _this select 0;
_offset = _this select 1;
_rot = _this select 2;
_r = [];
for "_bn" from 1 to 4 do {
_p = _o selectionPosition Format [ "beam%1", _bn ];
if (_p distance [0,0,0] == 0) exitWith {
if (_bn == 1) then { // no memory points defined
_bb = boundingBox _o;
_h = _offset + ((_o worldToModel (getPosATL _o)) select 2);
_p = [ (_bb select 0) select 0, 0, _h ];
_r set [ 0, _o modelToWorld _p];
_p = [ (_bb select 1) select 0, 0, _h ];
_r set [ 1, _o modelToWorld _p];
};
};
if (_rot != 0) then {
_bx = _p select 0;
_by = _p select 1;
_p set [0, (_bx * cos _rot) - (_by * sin _rot)];
_p set [1, (_bx * sin _rot) + (_by * cos _rot)];
};
_p set [2, (_p select 2) + _offset];
_r set [ count _r, _o modelToWorld _p];
};
_r
};
_minElevation = {
private "_r";
_r = 400;
{ _r = _r min (_x select 2); } count _this;
_r
};
_maxElevation = {
private "_r";
_r = -400;
{ _r = _r max (_x select 2); } count _this;
_r
};
_checkNotBuried = {
// lift up the object so that any beams are buried, but also don't lift further the planting level (straight placement only)
_elevation = _position select 2;
_delta = 0;
_overElevation = 0;
_beams = [_object, 0,0] call _getBeams;
if (_elevation < 0) then { _delta = -_elevation; }
else {
_overElevation = _beams call _minElevation;
if (_overElevation>0.05) then { // bury the object so that posATL is still positif and all beams are above the ground
_delta = - (_overElevation min _elevation);
};
if (_overElevation < -0.05) then { // lift up the object because a beam is burried
_delta = - _overElevation + 0.10;
};
};
_position set [ 2, _elevation + _delta ];
_maxplanting = _beams call _maxElevation;
// _maxplanting is the height of the emerging foundations, must not be so high because we don't want some "floating" foundations
};
_object = _ghost createVehicleLocal getMarkerpos "respawn_west";
_safeDistance = 0.5 + (sizeOf _ghost) * 0.5; // beware of hedgehogs
_dir = getDir player;
_object setDir _dir;
// ghost, angle, previous camera, build view on/off, continue on/off, slope on/off
Dayz_constructionContext = [_object, round (_dir/5)*5, cameraView, false, true, _keepOnSlope];
_posReference = getPosATL player;
_objColliding = objNull;
_best = [50,[0,0,0],[0,0,0]];
_maxplanting = 10;
_position = getPosATL _object;
_actionBuildHidden = true;
_actionCancel = player addAction [localize "str_player_build_cancel", "\z\addons\dayz_code\actions\object_build.sqf", [_object, _requiredParts, _classname, _text, false, 0, "none"], 1, true, true, "", "0 != count Dayz_constructionContext"];
while {Dayz_constructionContext select 4} do {
//Reset colliding Status
_objColliding = objNull;
// force the angle so that the ghost is showing always the same side
_angleRef=Dayz_constructionContext select 1;
_dir = _angleRef - (getDir player);
if (_dir > 180) then {_dir = _dir - 360};
if (_dir < -180) then {_dir = _dir + 360};
if (_dir < -75) then {
_angleRef = ceil(((getDir player) - 75)/5)*5;
Dayz_constructionContext set [ 1, _angleRef];
};
if (_dir > 75) then {
_angleRef = floor(((getDir player) + 75)/5)*5;
Dayz_constructionContext set [ 1, _angleRef];
};
// move object according to player position
if ((abs(([_object, player] call BIS_fnc_distance2D) - _safeDistance) > (if (_best select 0 < 0.50) then {0.50} else {0.05})) or (abs([player, _object] call BIS_fnc_relativeDirTo) > (if (_best select 0 < 0.50) then {5} else {1})) or (r_interrupt)) then {
r_interrupt = false;
_object setDir _angleRef;
_tmp = player modelToWorld [0, _safeDistance,0];
if ((Dayz_constructionContext select 5) or (_keepOnSlope)) then {
_tmp set [2, 0];
_object setVectorUp surfaceNormal _tmp;
} else {
_tmp set [2, _position select 2];
_object setVectorUp [0,0,1];
};
_position = +(_tmp);
_object setPosATL _position;
};
if (_best select 0 < 0.50) then {
_position = [
(_position select 0) + ((_best select 2) select 0) - ((_best select 1) select 0),
(_position select 1) + ((_best select 2) select 1) - ((_best select 1) select 1),
_position select 2
];
_object setPosATL _position;
};
if (Dayz_constructionContext select 5 or _keepOnSlope) then {
_maxplanting = 0;
_position set [2, 0];
} else {
// adjust the elevation of the object according to slope and beams to keep them visible (straight placement only)
call _checkNotBuried;
};
_object setPosATL _position;
if ((((vehicle player) != player or _posReference distance player > 20 or 0 != player getVariable["startcombattimer",0]) or {(!alive player)}) or {((call _onLadder) or {(call _isWater)})}) exitWith {
[[],[],[],[_object, _requiredParts , _classname, _text, false, 0, "none"]] call object_build;
};
//Quick Fix stop Tents/sandbags/tanktraps/wire being placed near an fence you dont own.
{
//Is Placeable closer then 5 to the fence.
if (_x distance _object < 5) exitWith {
//if player does not own fence set to block placeable.
if(_x getVariable ["ownerArray", [""]] select 0 != getPlayerUID player) then {
_objColliding = _x;
};
};
} foreach (nearestObjects [_object, ["DZ_buildables"], 6]);
if ((isNull _objColliding) and (_maxplanting <= _emergingLevel)) then {
if (_actionBuildHidden) then {
//Remove actions
_actionBuildHidden = false;
player removeAction _actionCancel;
_sfx = if (_object isKindOf "Land_A_tent") then {"tentunpack"} else {"repair"};
// placement is fine, enable "Build" in the menu
_actionBuild = player addAction [localize "str_player_build_complete", "\z\addons\dayz_code\old\object_build.sqf", [_object, _requiredParts , _classname, _text, true, 20, _sfx], 1, true, true, "", "0 != count Dayz_constructionContext"];
_actionCancel = player addAction [localize "str_player_build_cancel", "\z\addons\dayz_code\old\object_build.sqf", [_object, _requiredParts , _classname, _text, false, 0, "none"], 1, true, true, "", "0 != count Dayz_constructionContext"];
};
} else {
if (!_actionBuildHidden) then {
_actionBuildHidden = true;
player removeAction _actionBuild;
};
};
uiSleep 0.03;
};
if (!_actionBuildHidden) then { // player can't build until all is fine
_actionBuildHidden = true;
player removeAction _actionBuild;
};
player removeAction _actionCancel;
if (Dayz_constructionContext select 3) then {
// "build" camera was on, switch it off
call fn_buildCamera;
};
Dayz_constructionContext = [];
dayz_actionInProgress = false;
//systemChat "Dayz_constructionContext reset";

View File

@@ -0,0 +1,386 @@
// (c) facoptere@gmail.com, licensed to DayZMod for the community
private ["_classType","_item","_action","_missingTools","_missingItem","_emergingLevel","_isClass","_classname","_requiredTools",
"_requiredParts","_ghost","_placement","_text","_onLadder","_isWater","_object","_string","_actionBuildHidden","_getBeams",
"_o","_offset","_rot","_r","_p","_bn","_bb","_h","_bx","_by","_minElevation","_maxElevation","_insideCheck","_building",
"_unit","_bbb","_ubb","_check","_min","_max","_myX","_myY","_checkBuildingCollision","_objColliding","_inside","_checkOnRoad",
"_roadCollide","_checkBeam2Magnet","_a","_beams","_best","_b","_d","_checkNotBuried","_elevation","_position","_delta","_overElevation",
"_maxplanting","_safeDistance","_dir","_angleRef","_tmp","_actionCancel","_sfx","_actionBuild","_byPassChecks","_keepOnSlope","_msg",
"_isCollisionBypass","_ok","_missing","_upgradeParts","_ownerID","_posReference"];
/*
Needs a full rewrite to keep up with the demand of everything we plan to add.
*/
if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;};
dayz_actionInProgress = true;
call gear_ui_init;
closeDialog 1;
_item = _this select 0;
_action = _this select 1;
_classType = "ItemActions";
//diag_log (_item);
if (count _this > 2) then {
_classType = _this select 2;
};
_emergingLevel = 1.1;
_isClass = switch (1==1) do {
case (isClass (configFile >> "CfgMagazines" >> _item)): {"CfgMagazines"};
case (isClass (configFile >> "CfgWeapons" >> _item)): {"CfgWeapons"};
};
//need to swap all build systems to this "ItemActions"
_classname = getText (configFile >> _isClass >> _item >> _classType >> _action >> "create");
_requiredTools = getArray (configFile >> _isClass >> _item >> _classType >> _action >> "require");
_requiredParts = getArray (configFile >> _isClass >> _item >> _classType >> _action >> "consume");
_ghost = getText (configFile >> _isClass >> _item >> _classType >> _action >> "ghost");
if (_ghost == "") then { _ghost = _classname; };
_text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
_keepOnSlope = 0 == (getNumber (configFile >> "CfgVehicles" >> _classname >> "canbevertical"));
_onLadder = {getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder") == 1};
_isWater = {(surfaceIsWater (getPosATL _object)) or dayz_isSwimming};
if (0 != count Dayz_constructionContext) exitWith {
dayz_actionInProgress = false;
localize "str_already_building" call dayz_rollingMessages;
};
// item is missin - this really is pointless but it aint broke so dont fix it
if (isClass (configFile >> _isClass >> _item)) then {
if ((!(_item IN magazines player))) exitWith {
_string = switch true do {
case (_item isKindOf "Land_A_tent"): {"str_player_31_pitch"};
default {"str_player_31_build"};
};
//cutText [format [localize "str_player_31",_text,(localize _string)] , "PLAIN DOWN"];
_msg = format [localize "str_player_31",_text,(localize _string)];
_msg call dayz_rollingMessages;
//diag_log(format["player_build: item:%1 require:%2 Player items:%3 magazines:%4", _item, _requiredTools, (items player), (magazines player)]);
};
};
_posReference = [player] call FNC_GetPos;
_canBuild = [_posReference, _item, false] call DZE_BuildChecks;
if !(_canBuild select 0) exitWith {dayz_actionInProgress = false;};
// lets check player has requiredTools for upgrade
_ok = true;
_missing = "";
{
if (!(_x IN items player)) exitWith {
//systemchat("Missing tools for upgrade." +str());
_missing = getText (configFile >> "CfgWeapons" >> _x >> "displayName");
_ok = false;
};
} count _requiredTools;
if (!_ok) exitWith {
dayz_actionInProgress = false;
//cutText [format [localize "str_player_31_missingtools",_text,_missing] , "PLAIN DOWN"];
_msg = format [localize "str_player_31_missingtools",_text,_missing];
_msg call dayz_rollingMessages;
};
// lets check player has requiredParts for upgrade
_ok = true;
_upgradeParts = [];
{
if (!(_x IN magazines player)) exitWith {
_missing = getText (configFile >> "CfgMagazines" >> _x >> "displayName");
_ok = false;
};
if (_x IN magazines player) then {
_upgradeParts set [count _upgradeParts, _x];
player removeMagazine _x;
};
} count _requiredParts;
if (!_ok) exitWith {
{ player addMagazine _x; } foreach _upgradeParts;
dayz_actionInProgress = false;
// cutText [format [localize "str_player_31", _missing, localize "str_player_31_build"] , "PLAIN DOWN"];
_msg = format [localize "str_player_31", _missing, localize "str_player_31_build"];
_msg call dayz_rollingMessages;
};
_msg = localize "str_player_build_rotate";
_msg call dayz_rollingMessages;
//Get fence beams based on model
_getBeams = {
private [ "_p", "_r", "_bn", "_bb", "_bx", "_by" ];
_o = _this select 0;
_offset = _this select 1;
_rot = _this select 2;
_r = [];
for "_bn" from 1 to 4 do {
_p = _o selectionPosition Format [ "beam%1", _bn ];
if (_p distance [0,0,0] == 0) exitWith {
if (_bn == 1) then { // no memory points defined
_bb = boundingBox _o;
_h = _offset + ((_o worldToModel (getPosATL _o)) select 2);
_p = [ (_bb select 0) select 0, 0, _h ];
_r set [ 0, _o modelToWorld _p];
_p = [ (_bb select 1) select 0, 0, _h ];
_r set [ 1, _o modelToWorld _p];
};
};
if (_rot != 0) then {
_bx = _p select 0;
_by = _p select 1;
_p set [0, (_bx * cos _rot) - (_by * sin _rot)];
_p set [1, (_bx * sin _rot) + (_by * cos _rot)];
};
_p set [2, (_p select 2) + _offset];
_r set [ count _r, _o modelToWorld _p];
};
_r
};
_minElevation = {
private "_r";
_r = 400;
{ _r = _r min (_x select 2); } count _this;
_r
};
_maxElevation = {
private "_r";
_r = -400;
{ _r = _r max (_x select 2); } count _this;
_r
};
#define COLLIDABLE_OBJECT_MIN_SIZE 8
//check if building being placed and objects around placement is free to be built on.
//Fence owners must build all the foundations by one player anyone can still upgrade (pending lock build level)
_checkBuildingCollision =
{
scopeName "root";
_objColliding = objNull;
local _count = getNumber (configFile >> "CfgVehicles" >> _ghost >> "buildCollisionPoints");
if (_count == 0) exitWith {};
local _wall = _object isKindOf "DZ_buildables";
//Make sure no one can build within 6 meters of someone elses walls. Also block placement from anyone from the model origin.
if (_wall && {
local _result = false;
{
if (_x != _object && { _x distance _object < 1.5 || { _x getVariable ["ownerArray", [""]] select 0 != getPlayerUID player } } ) exitWith
{ _objColliding = _x; _result = true; };
} foreach (nearestObjects [_object, ["DZ_buildables"], 6]);
_result
}) exitWith {};
//Load object collision points
local _points = [];
_points resize _count;
for "_i" from 0 to _count - 1 do
{ _points set [_i, ATLtoASL (_object modelToWorld (_object selectionPosition format ["buildCollision%1", _i]))]; };
//Trace paths
{
local _p2 = _x select 0; //[0,1,3,2,0,3]
for "_i" from 1 to count _x - 1 do
{
local _p1 = _p2;
_p2 = _x select _i;
{
if (!_wall || { !(_x isKindOf "DZ_buildables" && { _x getVariable ["ownerArray", [""]] select 0 == getPlayerUID player }) }) then
{
local _type = typeof _x;
if (_type != "" && { sizeof _type >= COLLIDABLE_OBJECT_MIN_SIZE }) then
{
_objColliding = _x;
breakTo "root";
};
};
} foreach lineIntersectsWith [_points select _p1, _points select _p2, _object, player];
};
} foreach getArray (configFile >> "CfgVehicles" >> _ghost >> "buildCollisionPaths");
};
//Is placement on a road?
_checkOnRoad = {
_roadCollide = false;
{
_x set [2,0];
if (isOnRoad _x) exitWith { _roadCollide = true; };
} forEach ([_object, 0,0] call _getBeams);
_roadCollide
};
//Make the object attach to beams if it can
_checkBeam2Magnet = {
_a = [];
{
if ((!isNull _x) and (_x != _object)) then { _a = _a + ([_x, 0,0] call _getBeams); };
} forEach (nearestObjects [getPosATL _object, ["DZ_buildables"], 15]);
_beams = [_object, 0,0] call _getBeams;
_best = [50,[0,0,0],[0,0,0]];
{
_b = _x;
{
_d = [_x, _b] call BIS_fnc_distance2D;
if (_d < _best select 0) then {
_best = [_d,_b,_x];
};
} forEach _a;
} count _beams;
// _best contains the best beam to dock to. [ distance, coor of beam found around, coor of beam of ghost object ]
};
_checkNotBuried = {
// lift up the object so that any beams are buried, but also don't lift further the planting level (straight placement only)
_elevation = _position select 2;
_delta = 0;
_overElevation = 0;
_beams = [_object, 0,0] call _getBeams;
if (_elevation < 0) then { _delta = -_elevation; }
else {
_overElevation = _beams call _minElevation;
if (_overElevation>0.05) then { // bury the object so that posATL is still positif and all beams are above the ground
_delta = - (_overElevation min _elevation);
};
if (_overElevation < -0.05) then { // lift up the object because a beam is burried
_delta = - _overElevation + 0.10;
};
};
_position set [ 2, _elevation + _delta ];
_maxplanting = _beams call _maxElevation;
// _maxplanting is the height of the emerging foundations, must not be so high because we don't want some "floating" foundations
};
_object = _ghost createVehicleLocal getMarkerpos "respawn_west";
_safeDistance = 0.5 + (sizeOf _ghost) * 0.5; // beware of hedgehogs
_dir = getDir player;
_object setDir _dir;
Dayz_constructionContext = [_object, round (_dir/5)*5, cameraView, false, true, _keepOnSlope];
// ghost, angle, previous camera, build view on/off, continue on/off, slope on/off
_posReference = getPosATL player;
_objColliding = objNull;
_best = [50,[0,0,0],[0,0,0]];
_maxplanting = 10;
_position = getPosATL _object;
_actionBuildHidden = true;
_actionCancel = player addAction [localize "str_player_build_cancel", "\z\addons\dayz_code\actions\object_build.sqf", [_object, _requiredParts, _classname, _text, false, 0, "none"], 1, true, true, "", "0 != count Dayz_constructionContext"];
while {Dayz_constructionContext select 4} do {
// force the angle so that the ghost is showing always the same side
_angleRef=Dayz_constructionContext select 1;
_dir = _angleRef - (getDir player);
if (_dir > 180) then {_dir = _dir - 360};
if (_dir < -180) then {_dir = _dir + 360};
if (_dir < -75) then {
_angleRef = ceil(((getDir player) - 75)/5)*5;
Dayz_constructionContext set [ 1, _angleRef];
};
if (_dir > 75) then {
_angleRef = floor(((getDir player) + 75)/5)*5;
Dayz_constructionContext set [ 1, _angleRef];
};
// move object according to player position
if ((abs(([_object, player] call BIS_fnc_distance2D) - _safeDistance) > (if (_best select 0 < 0.50) then {0.50} else {0.05}))
or (abs([player, _object] call BIS_fnc_relativeDirTo) > (if (_best select 0 < 0.50) then {5} else {1})) or (r_interrupt)) then {
r_interrupt = false;
_object setDir _angleRef;
_tmp = player modelToWorld [0, _safeDistance,0];
if ((Dayz_constructionContext select 5) or (_keepOnSlope)) then {
_tmp set [2, 0];
_object setVectorUp surfaceNormal _tmp;
}
else {
_tmp set [2, _position select 2];
_object setVectorUp [0,0,1];
};
_position = +(_tmp);
_object setPosATL _position;
};
//Need to add config based bypass checks array.
call _checkBuildingCollision;
// try to dock a beam from current ghost to another beams nearby
call _checkBeam2Magnet;
if (_best select 0 < 0.50) then {
_position = [
(_position select 0) + ((_best select 2) select 0) - ((_best select 1) select 0),
(_position select 1) + ((_best select 2) select 1) - ((_best select 1) select 1),
_position select 2
];
_object setPosATL _position;
};
if (Dayz_constructionContext select 5 or _keepOnSlope) then {
_maxplanting = 0;
_position set [2, 0];
} else {
// adjust the elevation of the object according to slope and beams to keep them visible (straight placement only)
call _checkNotBuried;
};
_object setPosATL _position;
if ((((vehicle player) != player or _posReference distance player > 20 or 0 != player getVariable["startcombattimer",0]) or {(!alive player)}) or {((call _onLadder) or {(call _isWater)})}) exitWith {
[[],[],[],[_object, _requiredParts , _classname, _text, false, 0, "none"]] call object_build;
};
if (isNull _objColliding and _maxplanting <= _emergingLevel and !(call _checkOnRoad)) then {
// placement is fine, enable "Build" in the menu
if (_actionBuildHidden) then {
_actionBuildHidden = false;
player removeAction _actionCancel;
_sfx = if (_object isKindOf "Land_A_tent") then {"tentunpack"} else {"repair"};
_actionBuild = player addAction [localize "str_player_build_complete", "\z\addons\dayz_code\old\object_build.sqf", [_object, _requiredParts , _classname, _text, true, 20, _sfx], 1, true, true, "", "0 != count Dayz_constructionContext"];
_actionCancel = player addAction [localize "str_player_build_cancel", "\z\addons\dayz_code\old\object_build.sqf", [_object, _requiredParts , _classname, _text, false, 0, "none"], 1, true, true, "", "0 != count Dayz_constructionContext"];
};
} else {
if (!_actionBuildHidden) then {
_actionBuildHidden = true;
player removeAction _actionBuild;
};
};
uiSleep 0.03;
};
if (!_actionBuildHidden) then { // player can't build until all is fine
_actionBuildHidden = true;
player removeAction _actionBuild;
};
player removeAction _actionCancel;
if (Dayz_constructionContext select 3) then { // "build" camera was on, switch it off
call fn_buildCamera;
};
Dayz_constructionContext = [];
dayz_actionInProgress = false;
//systemChat "Dayz_constructionContext reset";

View File

@@ -0,0 +1,71 @@
/*
Created by Alby exclusively for DayZMod.
Please request permission to use/alter from Alby.
*/
private ["_items","_counts","_config","_isRecipe","_item","_index","_amount","_count","_entry","_input","_array","_overwrite","_i","_inputIndex","_inputItems"];
disableSerialization;
_array = _this select 0;
_items = _array select 0;
_counts = _array select 1;
_overwrite = [];
_config = configFile >> "CfgCrafting";
//diag_log (str(_this));
//diag_log format["Items: %1 Counts: %2 Config: %3", _items, _counts, _config];
for "_i" from 0 to ((count _config) - 1) do {
_entry = _config select _i;
_input = getArray (_entry >> "input");
//diag_log format["Recipe: %1 Input: %2", _entry, _input];
if (count _input > 0) then {
_isRecipe = true;
_inputIndex = 0;
{
//Check to see if _x is array of arrays
_inputItems = _x;
if (typeName (_x select 0) != "ARRAY") then {
_inputItems = [_x];
};
//Handles OR type of input
{
_item = _x select 0;
_index = _items find _item;
//diag_log format["Item: %1 Index: %2", _item, _index];
if (_index > -1) then {
_amount = _x select 2;
_count = _counts select _index;
//diag_log format["Amount: %1 Count: %2", _amount, _count];
if (_count >= _amount) then {
if (count _inputItems > 1) then {
_overwrite set [count _overwrite,[_inputIndex, [_item, _x select 1, _amount]]];
};
_isRecipe = true;
} else {
_isRecipe = false;
};
} else {
_isRecipe = false;
};
if (_isRecipe) exitWith {};
}forEach _inputItems;
if (!_isRecipe) exitWith {};
_inputIndex = _inputIndex + 1;
}forEach _input;
if (_isRecipe) exitWith {
//diag_log format["Items: %1 Recipe: %2", _this, _entry];
[_entry, _overwrite] call player_craftItemGUI;
};
};
};
//diag_log format["Exited with Items: %1", _array];

View File

@@ -0,0 +1,193 @@
/*
Created by r4z0r49 exclusively for DayZMod.
craft from rightclick options.
text = "Wooden Plank";
script = "spawn player_craftItem;";
requiretools[] = {"ItemHatchet"};
output[] = {{"ItemPlank","CfgMagazines",2}};
input[] = {{"ItemLog","CfgMagazines",1}};
failChance = 1;
*/
//diag_log("crafting system");
private ["_config","_input","_output","_required","_failChance","_hasInput","_availabeSpace","_classname","_isClass","_onLadder","_hasTools","_avail","_selection","_item","_amount","_itemName","_freeSlots","_slotType","_i","_j","_dis","_sfx","_finished"];
if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;};
dayz_actionInProgress = true;
//diag_log(str(isnil "r_player_crafting"));
//Process has started
if( (animationState player) IN [ "ainvpknlmstpslaywrfldnon_medic" ]) exitwith {dayz_actionInProgress = false;};
//Config class of right click item
_classname = _this;
//diag_log (str(_classname));
//Check what class the item is.
_isClass = switch (1==1) do {
case (isClass (configFile >> "CfgMagazines" >> _classname)): {"CfgMagazines"};
case (isClass (configFile >> "CfgWeapons" >> _classname)): {"CfgWeapons"};
};
_config = (configFile >> _isClass >> _classname >> "ItemActions" >> "Crafting");
//Check for normal blocked systems
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
if(!r_drag_sqf and !r_player_unconscious and !_onLadder) then {
_input = getArray (_config >> "input");
//diag_log (str(_input));
_output = getArray (_config >> "output");
//diag_log (str(_output));
_required = getArray (_config >> "requiretools");
//diag_log (str(_required));
_failChance = getNumber (_config >> "failChance");
//diag_log (str(_failChance));
// lets check player has requiredTools for upgrade
_hasTools = true;
{
if (_x == "ItemHatchet") then {
if (!("MeleeHatchet" in weapons player)) then {
if (!(DayZ_onBack == "MeleeHatchet")) then {
if (!(_x IN items player)) then {
systemChat format[localize "str_missing_to_do_this", _x];
_hasTools = false;
};
};
};
};
} count _required;
if (!_hasTools) exitwith {};
_hasInput = true;
{
private ["_avail"];
_selection = _x select 1;
_item = _x select 0;
_amount = _x select 2;
switch (_selection) do {
case "CfgWeapons":
{
_avail = {_x == _item} count weapons player;
};
case "CfgMagazines":
{
_avail = {_x == _item} count magazines player;
};
};
if (_avail < _amount) exitWith {
_hasInput = false;
_itemName = getText(configFile >> _selection >> _item >> "displayName");
format[localize "str_crafting_missing",(_amount - _avail),_itemName] call dayz_rollingMessages;
};
} forEach (_input);
if (_hasInput) then {
//Remove melee magazines (BIS_fnc_invAdd and BIS_fnc_invSlotsEmpty fix)
false call dz_fn_meleeMagazines;
_freeSlots = [player] call BIS_fnc_invSlotsEmpty;
{
_item = _x select 0;
_amount = _x select 2;
_slotType = [_item] call BIS_fnc_invSlotType;
for "_i" from 1 to _amount do {
for "_j" from 1 to (count _slotType) do {
if ((_slotType select _j) > 0) then {
_freeSlots set[_j, ((_freeSlots select _j) + (_slotType select _j))];
};
};
};
} forEach _input;
_availabeSpace = true;
{
_item = _x select 0;
_amount = _x select 2;
_slotType = [_item] call BIS_fnc_invSlotType;
for "_i" from 1 to _amount do {
for "_j" from 1 to (count _slotType) do {
if ((_slotType select _j) > 0) then {
_freeSlots set[_j, ((_freeSlots select _j) - (_slotType select _j))];
if (_freeSlots select _j < 0) exitWith {
_availabeSpace = false;
localize "str_crafting_space" call dayz_rollingMessages;
};
};
};
};
} forEach _output;
//uiSleep 1;
true call dz_fn_meleeMagazines;
if (_availabeSpace) then {
//player playActionNow "PutDown";
call gear_ui_init;
closeDialog 1;
_dis=20;
_sfx = if (_classname == "equip_rope") then {"bandage"} else {"chopwood"};
[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
[player,_dis,true,(getPosATL player)] call player_alertZombies;
_finished = ["Medic",1] call fn_loopAction;
if (!_finished) exitWith {};
{
_item = _x select 0;
_amount = _x select 2;
for "_i" from 1 to _amount do {
_selection = _x select 1;
switch (_selection) do {
case "CfgWeapons":
{
player removeWeapon _item;
};
case "CfgMagazines":
{
player removeMagazine _item;
};
};
//uiSleep 0.1;
};
} forEach _input;
{
_item = _x select 0;
_selection = _x select 1;
_amount = _x select 2;
_itemName = getText(configFile >> _selection >> _item >> "displayName");
for "_i" from 1 to _amount do {
if (random 1 > _failChance) then {
switch (_selection) do {
case "CfgWeapons":
{
player addWeapon _item;
};
case "CfgMagazines":
{
player addMagazine _item;
};
case "CfgVehicles":
{
player addBackpack _item;
};
};
format[localize "str_crafting_success",_itemName] call dayz_rollingMessages;
//uiSleep 2;
} else {
format[localize "str_crafting_failed",_itemName] call dayz_rollingMessages;
//uiSleep 2;
};
};
} forEach _output;
};
};
};
dayz_actionInProgress = false;

View File

@@ -0,0 +1,167 @@
/*
Created by Alby exclusively for DayZMod.
Please request permission to use/alter from Alby.
*/
private ["_config","_input","_output","_required","_failChance","_hasInput","_availabeSpace","_overwrite","_nearByPile","_index","_entry","_nearByTable","_weaps","_mags","_objMagTypes","_objMagQty","_i","_obj","_return","_inArray","_avail","_selection","_item","_amount","_itemName","_freeSlots","_slotType","_j"];
disableSerialization;
["close"] call fn_updateCraftUI;
_config = _this select 0;
_overwrite = _this select 1;
_input = getArray (_config >> "input");
_output = getArray (_config >> "output");
_required = getArray (_config >> "required");
_failChance = getNumber (_config >> "failChance");
_nearByPile = nearestObjects [getPosATL player, ["SmallCraftTable_dz"], 3];
//diag_log (str(_this));
if (count _overwrite > 0) then {
{
_index = _x select 0;
_entry = _x select 1;
_input set [_index, _entry];
}forEach _overwrite;
};
if (count _nearByPile > 0) then {
//done from craftingtable (ground)
//diag_log ("Table");
_nearByTable = nearestObjects [getPosATL player, ["SmallCraftTable_dz"], 3];
if (count _nearByTable > 0) then {
_weaps = getWeaponCargo (_nearByTable select 0);
_mags = getMagazineCargo (_nearByTable select 0);
//Add Magazines
_objMagTypes = _mags select 0;
_objMagQty = _mags select 1;
//diag_log format["%1, %2",_objMagTypes,_objMagQty];
for "_i" from 0 to (count _objMagTypes - 1) do {
_obj = _objMagTypes select _i;
_index = [_return, _obj] call _inArray;
//diag_log format["MagName: %1, %2",_obj,_index];
};
_hasInput = true;
};
} else {
//done from player inventory
_hasInput = true;
{
private ["_avail"];
_selection = _x select 1;
_item = _x select 0;
_amount = _x select 2;
switch (_selection) do {
case "CfgWeapons":
{
_avail = {_x == _item} count weapons player;
};
case "CfgMagazines":
{
_avail = {_x == _item} count magazines player;
};
};
if (_avail < _amount) exitWith {
_hasInput = false;
_itemName = getText(configFile >> _selection >> _item >> "displayName");
format[localize "str_crafting_missing",(_amount - _avail),_itemName] call dayz_rollingMessages;
};
} forEach (_input + _required);
if (_hasInput) then {
//Remove melee magazines (BIS_fnc_invAdd and BIS_fnc_invSlotsEmpty fix)
false call dz_fn_meleeMagazines;
_freeSlots = [player] call BIS_fnc_invSlotsEmpty;
{
_item = _x select 0;
_amount = _x select 2;
_slotType = [_item] call BIS_fnc_invSlotType;
for "_i" from 1 to _amount do {
for "_j" from 1 to (count _slotType) do {
if ((_slotType select _j) > 0) then {
_freeSlots set[_j, ((_freeSlots select _j) + (_slotType select _j))];
};
};
};
} forEach _input;
_availabeSpace = true;
{
_item = _x select 0;
_amount = _x select 2;
_slotType = [_item] call BIS_fnc_invSlotType;
for "_i" from 1 to _amount do {
for "_j" from 1 to (count _slotType) do {
if ((_slotType select _j) > 0) then {
_freeSlots set[_j, ((_freeSlots select _j) - (_slotType select _j))];
if (_freeSlots select _j < 0) exitWith {
_availabeSpace = false;
localize "str_crafting_space" call dayz_rollingMessages;
};
};
};
};
} forEach _output;
true call dz_fn_meleeMagazines;
//uiSleep 1;
if (_availabeSpace) then {
player playActionNow "PutDown";
{
_item = _x select 0;
_amount = _x select 2;
for "_i" from 1 to _amount do {
_selection = _x select 1;
switch (_selection) do {
case "CfgWeapons":
{
player removeWeapon _item;
};
case "CfgMagazines":
{
player removeMagazine _item;
};
};
//uiSleep 0.1;
};
} forEach _input;
{
_item = _x select 0;
_selection = _x select 1;
_amount = _x select 2;
_itemName = getText(configFile >> _selection >> _item >> "displayName");
for "_i" from 1 to _amount do {
if (random 1 > _failChance) then {
switch (_selection) do {
case "CfgWeapons":
{
player addWeapon _item;
};
case "CfgMagazines":
{
player addMagazine _item;
};
case "CfgVehicles":
{
player addBackpack _item;
};
};
format[localize "str_crafting_success",_itemName] call dayz_rollingMessages;
//uiSleep 2;
} else {
format[localize "str_crafting_failed",_itemName] call dayz_rollingMessages;
//uiSleep 2;
};
};
} forEach _output;
};
};
};

View File

@@ -0,0 +1,47 @@
//fixHatchet old file
private ["_tool","_tape","_fixedItem","_config","_dName","_handle","_finished"];
_tool = _this;
_config = configFile >> "CfgWeapons" >> _tool;
_fixedItem = getText(_config >> "fixedTool");
_dName = getText(configFile >> "CfgWeapons" >> _fixedItem >> "displayName");
//Used for Grip
_tape = "equip_duct_tape";
//Handle
_handle = "equip_lever";
if (dayz_actionInProgress) exitWith { localize "str_player_actionslimit" call dayz_rollingMessages; };
dayz_actionInProgress = true;
call gear_ui_init;
closeDialog 0;
// Check if the player has the tape
if ((_tape in magazines player) && (_handle in magazines player) && (_tool in items player)) then {
[player,"bandage",0,false] call dayz_zombieSpeak;
_finished = ["Medic",1] call fn_loopAction;
if (!_finished) exitWith {};
// Check again to make sure player didn't drop item
if ((_tape in magazines player) && (_handle in magazines player) && (_tool in items player)) then {
player removeWeapon _tool;
player removeMagazine _tape;
player removeMagazine _handle;
player addWeapon _fixedItem;
format[localize "str_fixToolSuccess", _dName] call dayz_rollingMessages;
};
} else { //If the player doesn't have the mats.
if (!(_tape in magazines player)) then {
if (!(_handle in magazines player)) then {
localize "str_fixToolFail" call dayz_rollingMessages;
} else {
localize "str_fixtoolMissingTape" call dayz_rollingMessages;
};
} else {
localize "str_fixtoolMissingHandle" call dayz_rollingMessages;
};
};
dayz_actionInProgress = false;

View File

@@ -0,0 +1,97 @@
private ["_item","_config","_exit","_text","_booleans","_worldspace","_dir","_location","_fire","_tool","_itemPile","_posASL","_testSea","_finished"];
_tool = _this;
call gear_ui_init;
closeDialog 0;
if (dayz_actionInProgress) exitWith { localize "str_player_actionslimit" call dayz_rollingMessages; };
dayz_actionInProgress = true;
_item = "ItemLog";
_itemPile = "PartWoodPile";
_config = configFile >> "CfgMagazines" >> _item;
_text = getText (_config >> "displayName");
_exit = false;
if (_tool == "PartWoodPile") then {
_exit = true;
{if (_x in DayZ_Ignitors) exitWith {_exit = false};} forEach (items player);
};
if (_exit) exitWith {
localize "str_fireplace_noMatches" call dayz_rollingMessages;
dayz_actionInProgress = false;
};
// item is missing or tools are missing
if (!(_item in magazines player) && !(_itemPile in magazines player)) exitWith {
localize "str_player_22" call dayz_rollingMessages;
dayz_actionInProgress = false;
};
_booleans = []; //testonLadder, testSea, testPond, testBuilding, testSlope, testDistance
_worldspace = ["Land_Fire_DZ", player, _booleans] call fn_niceSpot;
// player on ladder or in a vehicle
if (_booleans select 0) exitWith {
localize "str_player_21" call dayz_rollingMessages;
dayz_actionInProgress = false;
};
_testSea = true;
_posASL = getPosASL player;
if ((_booleans select 1) && _posASL select 2 > 2) then {
//Allow building on raised platform 2m+ ASL (like docks)
_testSea = false;
_worldspace = [0,_posASL];
};
// object would be in the water (pool or sea)
if ((_booleans select 1 && _testSea) OR (_booleans select 2)) exitWith {
localize "str_player_26" call dayz_rollingMessages;
dayz_actionInProgress = false;
};
if ((count _worldspace) == 2) then {
[player,20,true,(getPosATL player)] call player_alertZombies;
_finished = ["Medic",1] call fn_loopAction;
if (!_finished or (!(_item in magazines player) && !(_itemPile in magazines player))) exitWith {};
if (_item in magazines player) then {
player removeMagazine _item;
} else {
player removeMagazine _itemPile;
};
_dir = _worldspace select 0;
_location = _worldspace select 1;
// fireplace location may not be in front of player (but in 99% time it should)
player setDir _dir;
player setPosATL (getPosATL player);
// Added Nutrition-Factor for work
["Working",0,[20,40,15,0]] call dayz_NutritionSystem;
_fire = createVehicle ["Land_Fire_DZ", [0,0,0], [], 0, "CAN_COLLIDE"];
_fire setDir _dir;
if (_testSea) then {
_fire setPos _location; // follow terrain slope
} else {
_fire setPosASL _location;
};
player reveal _fire;
[_fire,true] call dayz_inflame;
_fire spawn player_fireMonitor;
/*if (dayz_playerAchievements select 14 < 1) then {
// Firestarter
dayz_playerAchievements set [14,1];
achievement = [14, player, dayz_characterID];
publicVariableServer "achievement";
};*/
localize "str_fireplace_01" call dayz_rollingMessages;
} else {
localize "str_fireplace_02" call dayz_rollingMessages;
};
dayz_actionInProgress = false;

View File

@@ -0,0 +1,33 @@
private ["_qty_quivers","_control","_qty_quiverarrows","_empty","_emptymagslotcount"];
disableSerialization;
call gear_ui_init;
_qty_quivers = {_x == "12Rnd_Quiver_Wood"} count magazines player;
_control = uiNamespace getVariable 'uiControl';
_qty_quiverarrows = gearSlotAmmoCount _control;
//Remove melee magazines (BIS_fnc_invAdd fix) (add new melee ammo to array if needed)
{player removeMagazines _x} forEach ["Hatchet_Swing","Crowbar_Swing","Machete_Swing","Fishing_Swing"];
_empty = [player] call BIS_fnc_invSlotsEmpty;
_emptymagslotcount = _empty select 4; //empty magazines slots
if (_qty_quivers > 1) exitWith { localize "str_quiver_reachlimit" call dayz_rollingMessages;};
if (_qty_quiverarrows == 2) then { //remove 12Rnd_Quiver_Wood - add 2 arrows
if (_emptymagslotcount > 0) then {
player removeMagazine "12Rnd_Quiver_Wood";
player addMagazine "1Rnd_Arrow_Wood";
player addMagazine "1Rnd_Arrow_Wood";
} else {
localize "str_player_24" call dayz_rollingMessages; //Error
};
} else {
if (_emptymagslotcount > 0) then {
player removeMagazine "12Rnd_Quiver_Wood";
player addMagazine "1Rnd_Arrow_Wood";
player addMagazine ["12Rnd_Quiver_Wood",_qty_quiverarrows-1];
} else {
localize "str_player_24" call dayz_rollingMessages; //Error
};
};

View File

@@ -0,0 +1,42 @@
#define WHITE [1,1,1,1]
#define GREY [0.75,0.75,0.75,1]
#define GREEN [0.6,0.8,0.4,1]
#define RED [1,0.1,0,1]
private["_task", "_taskDescription", "_taskStatus", "_taskParams"];
_task = _this select 0;
_taskDescription = (taskDescription _task) select 1;
_taskStatus = toUpper(taskState _task);
_taskParams = switch (_taskStatus) do
{
case "CREATED":
{
[format["NEW TASK ASSIGNED: \n%1", _taskDescription], WHITE, "taskNew"]
};
case "ASSIGNED":
{
[format["ASSIGNED TASK: \n%1", _taskDescription], WHITE, "taskCurrent"]
};
case "SUCCEEDED":
{
[format["TASK ACCOMPLISHED: \n%1", _taskDescription], GREEN, "taskDone"]
};
case "FAILED":
{
[format["TASK FAILED: \n%1", _taskDescription], RED, "taskFAILED"]
};
case "CANCELED":
{
[format["TASK CANCELED: \n%1", _taskDescription], GREY, "taskDone"]
};
};
taskHint _taskParams;

View File

@@ -0,0 +1,36 @@
private ["_newObjects","_change"];
//_newObjects = [_previous,weapons player] call player_weaponCheck;
_currentObjects = _this select 0;
_checkObjects = _this select 1;
_change = false;
//Check if some of old loadout not there
_newObjects = [];
{
if (!(_x in _newObjects)) then {
_type = _x;
_qtyNow = {_x == _type} count _checkObjects;
_qtyBefore = {_x == _type} count _currentObjects;
if (_qtyNow != _qtyBefore) then {
_change = true;
};
_newObjects set [count _newObjects,_type];
};
} forEach _currentObjects;
//Compare current loadout with old loadout
_newObjects = [];
{
if (!(_x in _newObjects)) then {
_type = _x;
_qtyNow = {_x == _type} count _checkObjects;
_qtyBefore = {_x == _type} count _currentObjects;
if (_qtyNow != _qtyBefore) then {
_change = true;
};
_newObjects set [count _newObjects,_type];
};
} forEach _checkObjects;
_change

View File

@@ -0,0 +1,66 @@
private["_unit","_targets","_move","_damage","_wound","_sound","_local","_dir","_hpList","_hp","_strH","_dam","_total","_result","_vehicle","_tPos","_zPos","_cantSee","_inAngle"];
_unit = _this select 0;
_wound = _this select 1;
_vehicle = (vehicle player);
//_targets = _unit getVariable ["targets",[]];
//if (!(_vehicle in _targets)) exitWith {};
//Do the attack
_move = "ZombieStandingAttack1";
_rnd = 0;
_rnd = round(random 9) + 1;
_move = "ZombieStandingAttack" + str(_rnd);
_dir = [_unit,player] call BIS_Fnc_dirTo;
_unit setDir _dir;
[objNull, _unit, rPlayMove, _move] call RE;
//Wait
uiSleep 0.3;
if (_vehicle != player) then {
_hpList = _vehicle call vehicle_getHitpoints;
_hp = _hpList call BIS_fnc_selectRandom;
_wound = getText(configFile >> "cfgVehicles" >> (typeOf _vehicle) >> "HitPoints" >> _hp >> "name");
_damage = random 0.03;
_chance = round(random 12);
if ((_chance % 4) == 0) then {
_openVehicles = ["ATV_Base_EP1", "Motorcycle", "Bicycle"];
{
if (_vehicle isKindOf _x) exitWith {
player action ["eject", _vehicle];
};
} forEach _openVehicles;
};
[_unit,"hit",0,false] call dayz_zombieSpeak;
if (_wound IN [ "glass1", "glass2", "glass3", "glass4", "glass5", "glass6" ]) then {
_dam = _vehicle getHit _wound;
// we limit how _dam could be damaged by Z. Above 0.8, the vehicle could explode, which is ridiculous.
_damage = (if (_dam < 0.8 OR {(!(_wound IN dayZ_explosiveParts))}) then {0.1} else {0.01});
// Add damage to vehicle. the "sethit" command will be done by the gameengine for which vehicle is local
//diag_log(format["%1: Part ""%2"" damaged from vehicle, damage:+%3", __FILE__, _wound, _damage]);
_total = [_vehicle, _wound, _damage, _unit, "zombie", true] call fnc_veh_handleDam;
};
} else {
if ((_unit distance player) <= 3) then {
_tPos = (getPosASL _vehicle);
_zPos = (getPosASL _unit);
_inAngle = [_zPos,(getdir _unit),50,_tPos] call fnc_inAngleSector;
if (_inAngle) then {
_cantSee = [_unit,_vehicle] call dayz_losCheck;
if (!_cantSee) then {
_damage = 0.1 + random (1.2);
//diag_log ("START DAM: Player Hit on " + _wound + " for " + str(_damage));
[player, _wound, _damage, _unit,"zombie"] call fnc_usec_damageHandler;
[_unit,"hit",0,false] call dayz_zombieSpeak;
};
};
};
};

View File

@@ -0,0 +1,22 @@
private ["_unitSending","_object","_object","_code"];
_unitSending = _this select 0;
_object = _this select 1;
_code = _this select 2;
//diag_log format["%1, %2-%3",_unitSending,_object,_code];
_ownerID = owner _unitSending;
if (_unitSending distance _object < 5) then {
_currentCode = _object getVariable ["dayz_padlockCombination",[]];
_result = [_currentCode,_code] call BIS_fnc_areEqual;
PVCDZ_Client_processCode = [_object,_result,_code];
_ownerID publicVariableClient "PVCDZ_Client_processCode";
diag_log format["INFO: %1, %5 is trying to guess with %3 for %2 at time %4",(name _unitSending),(typeof _object),_code,time,(getPlayerUID _unitSending)];
} else {
diag_log format["WARNING: %1, %5 is asking for code for %2 but is a range of %3 at time %4",(name _unitSending),(typeof _object),(_unit distance _object),time,(getPlayerUID _unitSending)];
};

View File

@@ -0,0 +1,29 @@
private ["_unitSending","_object","_object","_code"];
_unitSending = _this select 0;
_object = _this select 1;
_code = _this select 2;
//diag_log format["%1, %2-%3",_unitSending,_object,_code];
_ownerID = owner _unitSending;
_ownerArray = _object getVariable ["ownerArray",["0"]];
if ((_ownerArray select 0) == (getPlayerUID _unitSending)) then {
if (_unitSending distance _object < 5) then {
_object setVariable ["dayz_padlockCombination",_code,false];
PVCDZ_Client_processAccessCode = [_code];
_ownerID publicVariableClient "PVCDZ_Client_processAccessCode";
[_object,"accessCode",_code] call server_updateObject;
_object setVariable ["dayz_padlockHistory", [], true];
_object setVariable ["dayz_padlockLockStatus", true,true];
diag_log format["INFO: %1, %5 has changed the access code for %2 with %3 at time %4",(name _unitSending),(typeof _object),_code,time,(getPlayerUID _unitSending)];
} else {
diag_log format["WARNING: %1, %5 is asking to change access code of %2 from a distance of %3 at time %4",(name _unitSending),(typeof _object),(_unit distance _object),time,(getPlayerUID _unitSending)];
};
} else {
diag_log format["WARNING: %1, %2 is trying to set a code for a gate he does not own.",(name _unitSending),(getPlayerUID _unitSending)];
};

View File

@@ -0,0 +1,126 @@
#include "scheduler.hpp"
sched_achievement_init = {
private ["_timewasterCounter","_buildingList","_buildingCounter"];
//following achievements are monitored in this task
achievement_LitterCount = 0;
achievement_Gut = false;
// following achievements are monitored and saved elsewhere
achievement_Raw = false;
achievement_Fire = false;
achievement_SteadyAim = false;
achievement_Marksman = false;
achievement_Sniper = false;
// variables for the monitoring
_timewasterCounter = diag_ticktime;
_buildingList = [];
_buildingCounter = [0,0,0,0,0,0,0,0,0];
[_timewasterCounter, _buildingList, _buildingCounter]
};
sched_achievement = {
HIDE_FSM_VARS
private ["_timewasterCounter","_buildingList","_buildingCounter","_buildingAchivement","_buildingType","_buildingLimit","_building","_matchType","_count", "_o"];
_timewasterCounter = _this select 0;
_buildingList = _this select 1;
_buildingCounter = _this select 2;
_buildingAchivement = [
[""], // Achievement #2
["Land_A_GeneralStore_01a","Land_A_GeneralStore_01"], // Achievement #3 (5 stores)
["Land_A_GeneralStore_01a","Land_A_GeneralStore_01"], // Achievement #4 (10 stores)
["Land_A_Hospital"], // Achievement #5
["Land_A_Office01"], // Achievement #6
["Land_a_stationhouse"], // Achievement #7
["Land_A_Pub_01"], // Achievement #8
["Land_Mil_ControlTower"], // Achievement #9
["Land_Church_03"] // Achievement #10
];
_buildingLimit = [ 1, 5, 10, 4, 3, 4, 8, 3, 3 ];
// 0 = Time Waster - have been playing for over _timeWasterValue second in a single session
if (dayz_playerAchievements select 0 < 1) then {
if (diag_ticktime - _timewasterCounter >= 3600) then {
_timewasterCounter = -1; // stop checking
dayz_playerAchievements set [0,1];
achievement = [0, player, dayz_characterID];
publicVariableServer "achievement";
};
};
// 1 = High Flyer - find yourself over 500m ATL
if (dayz_playerAchievements select 1 < 1) then {
if (visiblePosition player select 2 > 500) then {
dayz_playerAchievements set [1,1];
achievement = [1, player, dayz_characterID];
publicVariableServer "achievement";
};
};
// 2 = near mass grave
if (dayz_playerAchievements select 2 < 1) then {
_o = (visiblePositionASL player) nearestObject "Mass_grave";
if ((!isNull _o) and {(_o distance player < 3)}) then {
dayz_playerAchievements set [2,1];
achievement = [2, player, dayz_characterID];
publicVariableServer "achievement";
};
};
// 3-10 = Building checker - counts the number of unique buildings (of a certain type) you visit
_building = nearestBuilding visiblePositionASL player; // gives nearest enterable building within 50 meters
if(!isNull _building) then {
if (!(_building in _buildingList)) then {
_buildingType = typeOf _building;
if ((player distance _building < 0.5 * sizeof _buildingType) and {([player,_building] call fnc_isInsideBuilding)}) then {
_matchType = false;
{
if (_buildingType in _x) then {
_matchType = true;
_count = _buildingCounter select _forEachIndex;
_count = _count +1;
_buildingCounter set [_forEachIndex, _count ];
if ((_count >= _buildingLimit select _forEachIndex) and (dayz_playerAchievements select (_forEachIndex + 3) < 1)) then {
dayz_playerAchievements set [ _forEachIndex + 3, 1];
achievement = [_forEachIndex + 3, player, dayz_characterID];
publicVariableServer "achievement";
};
};
} forEach _buildingAchivement;
if (_matchType) then {
_buildingList set [ count _buildingList, _building ];
};
};
};
};
// 11 = LitterCount
if (dayz_playerAchievements select 11 < 1) then {
if (achievement_LitterCount == 5) then {
achievement_LitterCount = -1; //???
dayz_playerAchievements set [11,1];
achievement = [11, player, dayz_characterID];
publicVariableServer "achievement";
};
};
// 12 = ??????
// 13 = Gutting
if (dayz_playerAchievements select 13 < 1) then {
if (achievement_Gut) then {
dayz_playerAchievements set [13,1];
achievement = [13, player, dayz_characterID];
publicVariableServer "achievement";
};
};
[_timewasterCounter, _buildingList, _buildingCounter]
};

View File

@@ -0,0 +1,18 @@
#include "scheduler.hpp"
sched_humanityChange = {
HIDE_FSM_VARS
_startcombattimer = player getVariable["startcombattimer", 0];
//If player is not in combat and humanity differs from the last time it ran run humanityCheck(skin change check)
if (_startcombattimer == 0) then {
_playerHumanity = player getVariable ["humanity",0];
if ((_playerHumanity != playerHumanityCHK) and (vehicle player == player)) then {
[_playerHumanity] call player_humanityCheck;
playerHumanityCHK = _playerHumanity;
};
};
objNull
};

View File

@@ -0,0 +1,43 @@
private["_position","_doLoiter","_unitTypes","_isNoone","_loot","_array","_agent","_type","_radius","_method","_nearByPlayer","_attempt","_myDest","_newDest","_lootType"];
_player = _this select 0;
_amount = _this select 1;
_counter = 0;
_agent = objNull;
if ([_player] call DZE_SafeZonePosCheck) exitWith {};
while {_counter < _amount} do {
//Create the Group and populate it
_type = "swarm_newBase"; //"_unitTypes call BIS_fnc_selectRandom;
//_type = "Pastor";
_position = [position _player,50,100,0] call fn_selectRandomLocation;
_agent = createAgent [_type, _position, [], 0, "NONE"];
_agent setVariable["agentObjectSwarm",_agent,true];
_agent setUnitPos "Middle";
dayz_swarmSpawnZombies = dayz_swarmSpawnZombies + 1;
dayz_spawnZombies = dayz_spawnZombies + 1;
if (isNull _agent) exitWith {
dayz_spawnZombies = dayz_spawnZombies - 1;
dayz_swarmSpawnZombies = dayz_swarmSpawnZombies - 1;
};
_isAlive = alive _agent;
//counter
_counter = _counter + 1;
//debug
//diag_log (format["Agent: %1, Type: %2,To spawn: %3/%4",_agent,_type,_amount,_counter]);
//Move
//[_agent, _position] call zombie_loiter;
//Start behavior
_id = [_position,_agent,player] execFSM "\z\AddOns\dayz_code\old\fn_swarmagent.fsm";
};

View File

@@ -0,0 +1,572 @@
/*%FSM<COMPILE "C:\Program Files (x86)\Bohemia Interactive\Tools\FSM Editor Personal Edition\scriptedFSM.cfg, DayZ Zombie Wild Agent">*/
/*%FSM<HEAD>*/
/*
item0[] = {"init",0,250,-325.000000,-275.000000,-225.000000,-225.000000,0.000000,"init"};
item1[] = {"End",1,250,175.000000,-275.000000,275.000000,-225.000000,0.000000,"End"};
item2[] = {"Not_Alive",4,218,50.000000,300.000000,150.000000,350.000000,5.000000,"Not" \n "Alive"};
item3[] = {"loiter",4,218,-325.000000,0.000000,-225.000000,50.000000,0.000000,"loiter"};
item4[] = {"Loiter",2,4346,-325.000000,125.000000,-225.000000,175.000000,0.000000,"Loiter"};
item5[] = {"",7,210,-29.000042,321.000000,-20.999960,329.000000,0.000000,""};
item6[] = {"true",8,218,-325.000000,-175.000000,-225.000000,-125.000000,0.000000,"true"};
item7[] = {"Begin",2,250,-325.000000,-100.000000,-225.000000,-50.000000,0.000000,"Begin"};
item8[] = {"Has_Target",4,218,-150.000000,225.000000,-50.000000,275.000000,1.000000,"Has" \n "Target"};
item9[] = {"Chase",2,250,-150.000000,300.000000,-50.000000,350.000000,0.000000,"Chase"};
item10[] = {"",7,210,-29.000006,146.000000,-20.999996,154.000000,0.000000,""};
item11[] = {"",7,210,-29.000006,196.000000,-20.999996,204.000000,0.000000,""};
item12[] = {"",7,210,-104.000000,196.000000,-95.999992,204.000000,0.000000,""};
item13[] = {"Time_Check",4,218,-250.000000,50.000000,-150.000000,100.000000,0.000000,"Time" \n "Check"};
item14[] = {"Time_Check",4,218,-275.000000,300.000000,-175.000000,350.000000,0.000000,"Time" \n "Check"};
item15[] = {"No_Target",4,218,-275.000000,375.000000,-175.000000,425.000000,3.000000,"No" \n "Target"};
item16[] = {"",7,210,-479.000000,396.000000,-471.000000,404.000000,0.000000,""};
item17[] = {"",7,210,-479.000000,146.000000,-471.000000,154.000000,0.000000,""};
item18[] = {"",7,210,221.000000,321.000000,229.000000,329.000000,0.000000,""};
item19[] = {"Cleanup_",2,250,175.000000,200.000000,275.000000,250.000000,0.000000,"Cleanup?"};
item20[] = {"",7,210,-104.000023,396.000000,-95.999992,404.000000,0.000000,""};
item21[] = {"cant_see",4,218,-275.000000,450.000000,-175.000000,500.000000,2.000000,"cant" \n "see"};
item22[] = {"Finish_Move",2,250,-275.000000,525.000000,-175.000000,575.000000,0.000000,"Finish" \n "Move"};
item23[] = {"finished",4,218,-400.000000,525.000000,-300.000000,575.000000,1.000000,"finished"};
item24[] = {"",7,210,-479.000000,546.000000,-471.000000,554.000000,0.000000,""};
item25[] = {"time_up",4,218,175.000000,-25.000000,275.000000,25.000000,0.000000,"time" \n "up"};
item26[] = {"",7,210,271.000000,96.000000,279.000000,104.000008,0.000000,""};
item27[] = {"",7,210,221.000000,96.000008,229.000000,103.999977,0.000000,""};
item28[] = {"",7,210,271.000000,-79.000000,279.000000,-71.000000,0.000000,""};
item29[] = {"",7,210,221.000000,-79.000000,229.000000,-71.000000,0.000000,""};
item30[] = {"too_long",4,218,-400.000000,600.000000,-300.000000,650.000000,0.000000,"too long"};
item31[] = {"",7,210,-229.000000,621.000000,-221.000000,629.000000,0.000000,""};
item32[] = {"",7,210,-479.000000,621.000000,-471.000000,629.000000,0.000000,""};
item33[] = {"Reset_Targeting",2,250,-525.000000,325.000000,-425.000000,375.000000,0.000000,"Reset" \n "Targeting"};
item34[] = {"true",8,218,-525.000000,200.000000,-425.000000,250.000000,0.000000,"true"};
item35[] = {"deleted",4,218,225.000000,0.000000,325.000000,50.000000,0.000000,"deleted"};
item36[] = {"",7,210,-104.000000,471.000000,-95.999992,479.000000,0.000000,""};
item37[] = {"moveToCompleted",4,218,-400.000000,50.000000,-300.000000,100.000000,1.000000,"moveToCompleted "};
item38[] = {"Failed_to_move",4,218,-550.000000,-75.000000,-450.000000,-25.000000,2.000000,"Failed to move"};
item39[] = {"Second_Hand",4,218,-200.000000,-275.000000,-100.000000,-225.000000,0.000000,"Second Hand"};
item40[] = {"End_1",1,250,-75.000000,-275.000000,25.000000,-225.000000,0.000000,"End"};
item41[] = {"",7,210,-4.000000,-79.000000,4.000000,-71.000000,0.000000,""};
item42[] = {"",7,210,-4.000000,146.000000,4.000000,154.000000,0.000000,""};
item43[] = {"isLocal",4,218,25.000000,125.000000,125.000000,175.000000,5.000000,"isLocal"};
item44[] = {"",7,210,71.000000,-254.000000,79.000000,-246.000000,0.000000,""};
item45[] = {"____FAKE____",9,1800,0.000000,0.000000,0.000000,0.000000,0.000000,"____FAKE____"};
link0[] = {0,6};
link1[] = {0,39};
link2[] = {2,18};
link3[] = {3,4};
link4[] = {4,10};
link5[] = {4,13};
link6[] = {4,37};
link7[] = {5,2};
link8[] = {6,7};
link9[] = {7,3};
link10[] = {7,41};
link11[] = {8,9};
link12[] = {9,5};
link13[] = {9,14};
link14[] = {9,20};
link15[] = {10,11};
link16[] = {10,42};
link17[] = {11,5};
link18[] = {11,12};
link19[] = {12,8};
link20[] = {13,4};
link21[] = {14,9};
link22[] = {15,16};
link23[] = {16,33};
link24[] = {17,4};
link25[] = {18,19};
link26[] = {19,27};
link27[] = {20,15};
link28[] = {20,36};
link29[] = {21,22};
link30[] = {22,23};
link31[] = {22,31};
link32[] = {23,24};
link33[] = {24,16};
link34[] = {25,29};
link35[] = {26,35};
link36[] = {27,25};
link37[] = {27,26};
link38[] = {28,29};
link39[] = {29,1};
link40[] = {30,32};
link41[] = {31,30};
link42[] = {32,24};
link43[] = {33,34};
link44[] = {34,17};
link45[] = {35,28};
link46[] = {36,21};
link47[] = {37,4};
link48[] = {39,40};
link49[] = {41,42};
link50[] = {42,43};
link51[] = {43,44};
link52[] = {44,40};
link53[] = {38,45};
link54[] = {45,38};
globals[] = {25.000000,1,0,0,0,640,480,1,128,6316128,1,-571.718994,323.614502,673.426392,-311.286346,581,1030,1};
window[] = {2,-1,-1,-1,-1,831,52,1260,52,3,599};
*//*%FSM</HEAD>*/
class FSM
{
fsmName = "DayZ Zombie Wild Agent";
class States
{
/*%FSM<STATE "init">*/
class init
{
name = "init";
init = /*%FSM<STATEINIT""">*/"_agent = _this select 0;" \n
"_position = _agent modelToWorld [0,0,0];" \n
"" \n
"_secondHand = false;" \n
"" \n
"" \n
"if (count _this > 1) then {" \n
" //_secondHand = true;" \n
" diag_log (""Second Hand Zombie Initialized: "" + str(_this));" \n
"};" \n
"" \n
"" \n
"diag_log (""Agent Initialized: "" + str(_this));"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "Second_Hand">*/
class Second_Hand
{
priority = 0.000000;
to="End_1";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"count _this > 1"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/"diag_log (""Second Hand"");"/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "true">*/
class true
{
priority = 0.000000;
to="Begin";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"!(isNull _agent)"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "End">*/
class End
{
name = "End";
init = /*%FSM<STATEINIT""">*/"if (!isNull _agent) then {" \n
" deleteVehicle _agent;" \n
"};"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "Loiter">*/
class Loiter
{
name = "Loiter";
init = /*%FSM<STATEINIT""">*/"_isAlive = alive _agent;" \n
"_isLocal = local _agent;" \n
"" \n
"_target = _agent call compile preprocessFileLineNumbers ""\z\addons\dayz_code\compile\zombie_findTargetAgent.sqf"";" \n
"" \n
"_agent moveTo _pos;" \n
"_agent forceSpeed 2;" \n
"" \n
"//if (_runonce) then {" \n
"// _agent moveTo _pos;" \n
"// _runonce = false;" \n
"//};" \n
"" \n
"_timeN = diag_tickTime;" \n
"" \n
"diag_log format [""Agent: %1, Distance: %2, Location: %3"",_agent,(_agent distance _pos),_pos];" \n
"" \n
"if (!_isLocal) then {" \n
"diag_log (""State ID: 6"");" \n
"diag_log (str(_pos));" \n
"diag_log (str(_this));" \n
"diag_log (str(_agent));" \n
"};"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "Not_Alive">*/
class Not_Alive
{
priority = 5.000000;
to="Cleanup_";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"!_isAlive"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "isLocal">*/
class isLocal
{
priority = 5.000000;
to="End_1";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"!_isLocal"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "Has_Target">*/
class Has_Target
{
priority = 1.000000;
to="Chase";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"!(isNull _target)"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/"//Leader cries out" \n
"" \n
"if (!_hasMoved) then {" \n
" _agent setVariable[""doLoiter"",true,true];" \n
"};" \n
"_countr = 0;" \n
"_losCheck = 0;" \n
"_advLosCheck = 0;" \n
"_cantSee = false;"/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "moveToCompleted">*/
class moveToCompleted
{
priority = 1.000000;
to="Loiter";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"moveToCompleted _agent"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/"//_pos = [_position,20,100,1,0,10,0] call BIS_fnc_findSafePos;" \n
"_pos = [_position,20,100,1] call fn_selectRandomLocation;" \n
"" \n
"" \n
"if (!_isLocal) then {" \n
"diag_log (""State ID: 49"");" \n
"};"/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "Time_Check">*/
class Time_Check
{
priority = 0.000000;
to="Loiter";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"(diag_tickTime - _timeN) > 30"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/"_pos = [_position,20,100,1] call fn_selectRandomLocation;"/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "Begin">*/
class Begin
{
name = "Begin";
init = /*%FSM<STATEINIT""">*/"//_doLoiter = _agent getVariable[""doLoiter"",true];" \n
"" \n
"_array = [];" \n
"" \n
"_isLocal = local _agent;" \n
"" \n
"_runonce = true;" \n
"" \n
"_bodyStay = 60;" \n
"" \n
"_hasMoved = true;" \n
"" \n
"_agent disableAI ""FSM"";" \n
"_newDest = getPosATL _agent;" \n
"_timeN = time;" \n
"_target = objNull;" \n
"_targetPos = [];" \n
"_countr = 0;" \n
"" \n
"//Spawn roaming script (individual to unit)" \n
"_entityTime = diag_tickTime;" \n
"_timeR = diag_tickTime;" \n
"" \n
"" \n
"diag_log (""State ID: 10"");" \n
""/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "isLocal">*/
class isLocal
{
priority = 5.000000;
to="End_1";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"!_isLocal"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "loiter">*/
class loiter
{
priority = 0.000000;
to="Loiter";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"_hasMoved"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/"//_pos = [_position,20,100,1,0,10,0] call BIS_fnc_findSafePos;" \n
"_pos = [_position,20,100,1] call fn_selectRandomLocation;" \n
""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "Chase">*/
class Chase
{
name = "Chase";
init = /*%FSM<STATEINIT""">*/"_timeN = diag_tickTime;" \n
"" \n
"if (speed _agent < 0.1) then {_countr = _countr + 1} else {_countr = 0};" \n
"_target = _agent call zombie_findTargetAgent;" \n
"_isAlive = alive _agent;" \n
"_targetPos = getPosATL _target;" \n
"" \n
"//Move to target" \n
"if (_agent distance _target > 2.2) then {" \n
" _agent moveTo _targetPos;" \n
" _agent forceSpeed 6;" \n
"};" \n
"" \n
"//Check if LOS" \n
"if (_losCheck == 5) then {" \n
" _losCheck = 0;" \n
" _cantSee = [_agent,_target] call dayz_losCheck;" \n
"};" \n
"" \n
"if (_cantSee) then {" \n
" _advLosCheck = _advLosCheck +1;" \n
"};" \n
""/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "Not_Alive">*/
class Not_Alive
{
priority = 5.000000;
to="Cleanup_";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"!_isAlive"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "No_Target">*/
class No_Target
{
priority = 3.000000;
to="Reset_Targeting";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"(isNull _target)"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "cant_see">*/
class cant_see
{
priority = 2.000000;
to="Finish_Move";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"_advLosCheck > 5"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "Time_Check">*/
class Time_Check
{
priority = 0.000000;
to="Chase";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"(diag_tickTime - _timeN) > 1"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/"// reset stance to favorite one" \n
"if (_agent distance _target > 5) then {" \n
" _agent setUnitPos (_agent getVariable [""stance"", ""UP""]);" \n
"};" \n
"" \n
"//LOS Tick" \n
"_losCheck = _losCheck + 1;" \n
"" \n
"if (_agent distance _target <= 2.2) then {" \n
" _dir = [_agent,_target] call BIS_Fnc_dirTo;" \n
" _agent setDir _dir;" \n
"" \n
"// _agentPos = getPosATL _agent;" \n
"// _agent moveTo _agentPos;" \n
" _agent forceSpeed 0;" \n
"" \n
" if (speed _agent == 0) then {" \n
" _losCheck = _losCheck + 1;" \n
" };" \n
"};" \n
"" \n
"if (_agent distance _target > 2.2 AND _agent distance _target < 5) then {" \n
" //Stand up" \n
" _agent setUnitPos ""UP"";" \n
"};"/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "Cleanup_">*/
class Cleanup_
{
name = "Cleanup_";
init = /*%FSM<STATEINIT""">*/"_waitStart = diag_tickTime;"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "deleted">*/
class deleted
{
priority = 0.000000;
to="End";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"isNull _agent;"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "time_up">*/
class time_up
{
priority = 0.000000;
to="End";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"(diag_tickTime - _waitStart) > 300"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "Finish_Move">*/
class Finish_Move
{
name = "Finish_Move";
init = /*%FSM<STATEINIT""">*/"_timeN = diag_tickTime;" \n
""/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "finished">*/
class finished
{
priority = 1.000000;
to="Reset_Targeting";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"_agent distance _targetPos < 3"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "too_long">*/
class too_long
{
priority = 0.000000;
to="Reset_Targeting";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"(diag_tickTime - _timeN) > 10"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "Reset_Targeting">*/
class Reset_Targeting
{
name = "Reset_Targeting";
init = /*%FSM<STATEINIT""">*/"// reset stance to favorite one" \n
"_agent setUnitPos (_agent getVariable [""stance"", ""UP""]);" \n
"" \n
"if (!isNull _target) then {" \n
" _targetPos = getPosATL _target;" \n
" _agent setVariable [""myDest"",_targetPos];" \n
" _agent moveTo _targetPos;" \n
"};" \n
"" \n
"//Local" \n
"_agent setVariable [""localtargets"",[],false];" \n
"" \n
"//Remote" \n
"_remotetargets = [];" \n
"_remotetargets = _agent getVariable [""remotetargets"",[]];" \n
"" \n
"//Clear remote on reset" \n
"if (count _remotetargets > 0) then" \n
"{" \n
" _agent setVariable [""remotetargets"",[],true];" \n
"};" \n
"" \n
"//Clear Target" \n
"_target = objNull;"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "true">*/
class true
{
priority = 0.000000;
to="Loiter";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "End_1">*/
class End_1
{
name = "End_1";
init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/"diag_log (""End State"");"/*%FSM</STATEPRECONDITION""">*/;
class Links
{
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "____FAKE____">*/
class ____FAKE____
{
name = "____FAKE____";
init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "Failed_to_move">*/
class Failed_to_move
{
priority = 2.000000;
to="____FAKE____";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"moveToFailed _agent"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/"//_pos = [_position,20,100,1,0,10,0] call BIS_fnc_findSafePos;" \n
"" \n
"if (!_isLocal) then {" \n
"diag_log (""State ID: 50"");" \n
"};"/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
};
initState="init";
finalStates[] =
{
"End",
"End_1"
};
};
/*%FSM</COMPILE>*/