Commit 1ef1adcf authored by Razer's avatar Razer
Browse files

Added better AI DB handling + object material store + no more texture saving to DB if default

parent 7113abcc
......@@ -103,15 +103,17 @@ while{_doswitchloop} do {
};
};
if (DB_DEBUG) then {
diag_log "===========================APMSDB START OF REQUEST==================================";
diag_log format ["<ApmsDB>: DEBUG: CALLED FROM: %1",_fnc_scriptNameParent];
diag_log format ["<ApmsDB>: DEBUG: REQUEST TYPE: %1",_originalrequest select 0];
diag_log format ["<ApmsDB>: DEBUG: ORIGINAL REQUEST: %1 ",_originalrequest];
diag_log format ["<ApmsDB>: DEBUG: RESPONSE: %1 ",_response];
diag_log format ["<ApmsDB>: DEBUG: RETURN DATA: %1 ",_return];
diag_log "============================APMSDB END OF REQUEST===================================";
};
#ifdef DB_DEBUG
if (DB_DEBUG) then {
diag_log "===========================APMSDB START OF REQUEST==================================";
diag_log format ["<ApmsDB>: DEBUG: CALLED FROM: %1",_fnc_scriptNameParent];
diag_log format ["<ApmsDB>: DEBUG: REQUEST TYPE: %1",_originalrequest select 0];
diag_log format ["<ApmsDB>: DEBUG: ORIGINAL REQUEST: %1 ",_originalrequest];
diag_log format ["<ApmsDB>: DEBUG: RESPONSE: %1 ",_response];
diag_log format ["<ApmsDB>: DEBUG: RETURN DATA: %1 ",_return];
diag_log "============================APMSDB END OF REQUEST===================================";
};
#endif
if(isNil "_return") exitWith {
diag_log ("<ApmsDB>: ERROR: DB RESPONSE > NIL RETURN");
......
......@@ -120,21 +120,40 @@ private _magazinesturret = [];
};
};
//--- Animations
//--- Animations TODO CHECK IF NOT AT THE DEFAULT VALUE
private _animStates = [];
if (_objectType == 4) then {
_animStates = animationState _object; // Use string
} else {
private _animList = parseSimpleArray (toLower str(getArray(configfile >> "CfgVehicles" >> (typeOf _object) >> "animationList")));
("true" configClasses (configfile >> "CfgVehicles" >> (typeof _object) >> "AnimationSources") apply {configName _x}) apply {
private _phase = if!((toLower _x) in _animList) then {_object animationSourcePhase _x} else {_object animationPhase _x};
_animStates pushBack [_x,_phase];
private _animName = _x;
if ((_hitpoints findIf {(toLower(_x select 0)) == _animName}) == -1) then { // Don't add if already defined in hitpoints
private _phase = if!((toLower _animName) in _animList) then {_object animationSourcePhase _animName} else {_object animationPhase _animName};
_animStates pushBack [_animName,_phase];
};
};
};
//--- Get Cargo items / unit loadout
private _items = [_object] call BASE_fnc_getAllCargo;
//--- Textures / Materials
private _textures = [[],[]]; // [[textures],[materials]]
(getObjectTextures _object) apply {
private _cfgTemp = (configfile >> "CfgVehicles" >> typeOf _object);
if !("true" configClasses (_cfgTemp >> "TextureSources") isEqualTo []) then { // "textureList"
if (count(getArray(_cfgTemp >> "hiddenSelectionsTextures")) == 1 && {((getArray(_cfgTemp >> "hiddenSelectionsTextures")) select 0 != _x)}) then {
(_textures#0) pushBack _x;
};
};
};
(getObjectMaterials _object) apply {
if (_x != "") then {
(_textures#1) pushBack _x;
};
};
//--- Attached/Object parent (remove position stuff)
if (_objectType != 4 && {!(isNull (attachedTo _object)) && {alive (attachedTo _object)}}) exitWith { // If parent is dead continue normally (as its now detached by eventhandler)
[
......@@ -142,7 +161,7 @@ if (_objectType != 4 && {!(isNull (attachedTo _object)) && {alive (attachedTo _o
PROTOCOL_DBCALL_ARGUMENT_CLASSNAME,typeOf _object,
PROTOCOL_DBCALL_ARGUMENT_PRIORITY,_priority,
PROTOCOL_DBCALL_ARGUMENT_OBJECTTYPE,_objectType,
PROTOCOL_DBCALL_ARGUMENT_ACCESSCODE, _object getVariable ["APMS_unlockCode",[]],
PROTOCOL_DBCALL_ARGUMENT_ACCESSCODE,_object getVariable ["APMS_unlockCode",[]],
PROTOCOL_DBCALL_ARGUMENT_LOCKED,locked _object,
PROTOCOL_DBCALL_ARGUMENT_PLAYER_UUID,_object getVariable ["oOWNER",""],
PROTOCOL_DBCALL_ARGUMENT_HITPOINTS,_hitpoints,
......@@ -151,10 +170,10 @@ if (_objectType != 4 && {!(isNull (attachedTo _object)) && {alive (attachedTo _o
PROTOCOL_DBCALL_ARGUMENT_FUELCARGO,getFuelCargo _object,
PROTOCOL_DBCALL_ARGUMENT_REPAIRCARGO,getRepairCargo _object,
PROTOCOL_DBCALL_ARGUMENT_ITEMS,_items,
PROTOCOL_DBCALL_ARGUMENT_MAGAZINESTURRET, _magazinesturret,
PROTOCOL_DBCALL_ARGUMENT_VARIABLES, _variables,
PROTOCOL_DBCALL_ARGUMENT_ANIMATIONSTATE, _animStates,
PROTOCOL_DBCALL_ARGUMENT_TEXTURES,getObjectTextures _object,
PROTOCOL_DBCALL_ARGUMENT_MAGAZINESTURRET,_magazinesturret,
PROTOCOL_DBCALL_ARGUMENT_VARIABLES,_variables,
PROTOCOL_DBCALL_ARGUMENT_ANIMATIONSTATE,_animStates,
PROTOCOL_DBCALL_ARGUMENT_TEXTURES,_textures,
PROTOCOL_DBCALL_ARGUMENT_RESERVEDONE, [],
PROTOCOL_DBCALL_ARGUMENT_RESERVEDTWO, []
];
......@@ -188,19 +207,21 @@ if(_objectType == 4) then {
_object setVariable ["_svar_apmsunit_settings",_aiSettings];
//--- AI Side/Group setings
// Check for override / old data already set
private _grpInfo = _object getVariable "_svar_apmsunit_grpinfo";
if (isNil "_grpInfo") then {
// Get group name from group variable if exists
_grpName = (group _object) in DB_var_aiGroupList;
if!(isNil "_grpName") exitWith {
_variables pushBack ["_svar_apmsunit_grpname",_grpName];
_object setVariable ["_svar_apmsunit_grpname",_grpName];
private _grpNameIndex = DB_var_aiGroupList findIf {(_x select 0) isEqualTo (group _object)};
if(_grpNameIndex != -1) exitWith {
private _grpData = (DB_var_aiGroupList select _grpNameIndex) select 1;
_variables pushBack ["_SVAR_apmsUnit_grpInfo",_grpData];
_object setVariable ["_SVAR_apmsUnit_grpInfo",_grpData];
};
// Get group name
_leader = leader _object;
_grpName = _leader getVariable "oUUID";
private _leader = leader _object;
private _grpName = _leader getVariable "oUUID";
if(isNil "_grpName") then {
// If leader is not in DB select first unit from group
_leader = (units (group _object)) select {_x getVariable ["oUUID",""] != ""};
......@@ -210,7 +231,7 @@ if(_objectType == 4) then {
};
_grpName = "group_" + _grpName;
(group _object) setVariable ["apms_grpname_temp",_grpName]; // Set group variable for future
DB_var_aiGroupList pushBack [(group _object),_grpName]; // [group 1:1,"group_xxxxxxxx(oUID)"]
_variables pushBack ["_SVAR_apmsUnit_grpInfo",[_grpName,str(side _object)]];
_object setVariable ["_SVAR_apmsUnit_grpInfo",[_grpName,str(side _object)]];
......@@ -281,9 +302,9 @@ private _positionadvanced = (_object getVariable ["APMS_positionAdvanced",
PROTOCOL_DBCALL_ARGUMENT_MAGAZINESTURRET,_magazinesturret,
PROTOCOL_DBCALL_ARGUMENT_VARIABLES,_variables,
PROTOCOL_DBCALL_ARGUMENT_ANIMATIONSTATE,_animStates,
PROTOCOL_DBCALL_ARGUMENT_TEXTURES,getObjectTextures _object,
PROTOCOL_DBCALL_ARGUMENT_TEXTURES,_textures,
PROTOCOL_DBCALL_ARGUMENT_DIRECTION,getDir _object,
PROTOCOL_DBCALL_ARGUMENT_POSITIONTYPE, _positionType,
PROTOCOL_DBCALL_ARGUMENT_POSITIONTYPE,_positionType,
PROTOCOL_DBCALL_ARGUMENT_POSITIONX,_position select 0,
PROTOCOL_DBCALL_ARGUMENT_POSITIONY,_position select 1,
PROTOCOL_DBCALL_ARGUMENT_POSITIONZ,_position select 2,
......
......@@ -130,9 +130,22 @@ if(_positiontype == 1) then {
//--- Textures
// WARNING: Only works for SimpleObjects created using a classname!
{
_object setObjectTextureGlobal [_forEachIndex,_x];
} forEach _textures;
// TODO REMOVE FOR 0.4.5 (new format: [[textures],[materials]])
if(count _textures > 1 && {(_textures select 0) isEqualType []}) then {
// Add textues
{
_object setObjectTextureGlobal [_forEachIndex,_x];
} forEach (_textures select 0);
// Add materials
{
_object setObjectMaterialGlobal [_forEachIndex,_x];
} forEach (_textures select 1);
} else {
// OLD FORMAT [textures]
{
_object setObjectTextureGlobal [_forEachIndex,_x];
} forEach _textures;
};
//--- For buildings and vehicles use same script setting commands
......
......@@ -16,6 +16,7 @@ DB_var_worldVariables = [];
DB_var_clanList = [];
DB_var_Objects = [];
DB_var_ObjectUUIDS = [];
DB_var_aiGroupList = [];
DB_var_restoreObjectInProgress = true;
DB_var_savingObjects = true;
DB_var_runObjectMon = true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment