Skip to content

Commit

Permalink
Merge pull request #158 from Sparker95/fix-errors
Browse files Browse the repository at this point in the history
Fix errors
  • Loading branch information
Sparker95 authored Jun 23, 2019
2 parents 349a5d3 + 818e385 commit be2c017
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,11 @@ CLASS("PatrolCmdrAction", "CmdrAction")
SETV(_intel, "waypoints", _routeTargetPositions);
SETV(_intel, "locations", _locations);
SETV(_intel, "side", GETV(_srcGarr, "side"));
SETV(_intel, "dateDeparture", T_GET_AST_VAR("startDateVar")); // Sparker added this, I think it's allright??

// Departure date is 20+ minutes from now but they depart instantly, I don't know why :/
//SETV(_intel, "dateDeparture", T_GET_AST_VAR("startDateVar")); // Sparker added this, I think it's allright??
SETV(_intel, "dateDeparture", DATE_NOW); // Sparker added this, I think it's allright??

CALLM(_intel, "create", []);
};

Expand Down
2 changes: 1 addition & 1 deletion Project_0.Altis/AI/Group/ActionGroupPatrol.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CLASS("ActionGroupPatrol", "ActionGroup")
// Assign patrol waypoints
pr _AI = GETV(_thisObject, "AI");
pr _group = GETV(_AI, "agent");
diag_log format ["[ActionGroupPatrol::activate] Info: Started for AI: _AI"];
OOP_INFO_1("Started for AI: %1", _AI);
pr _gar = CALLM0(_group, "getGarrison");
pr _loc = CALLM0(_gar, "getLocation");

Expand Down
9 changes: 7 additions & 2 deletions Project_0.Altis/GameMode/CivilWar/CivilWarGameMode.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@ CLASS("CivilWarGameMode", "GameModeBase")
}
} ENDMETHOD;

// Overrides GameModeBase, we need to clean up the existing spawns, and that needs to be done locally
/* protected virtual */ METHOD("preInitAll") {
/* protected virtual */ /* METHOD("preInitAll") {
params [P_THISOBJECT];
} ENDMETHOD;
*/

// Overrides GameModeBase, we need to clean up the existing spawn markers, and we delete these markers globally
/* protected virtual */ METHOD("initServerOnly") {
params [P_THISOBJECT];
// Delete all existing spawns
{
Expand Down
2 changes: 1 addition & 1 deletion Project_0.Altis/GameMode/GameModeBase.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ CLASS("GameModeBase", "")
CALLM1(_loc, "setCapacityCiv", _locCapacityCiv);

// Create police stations in cities
if (_locType == LOCATION_TYPE_CITY and _locCapacityCiv >= 23) then {
if (_locType == LOCATION_TYPE_CITY and _locCapacityCiv >= 10) then {
// TODO: Add some visual/designs to this
private _posPolice = +GETV(_loc, "pos");
_posPolice = _posPolice vectorAdd [-200 + random 400, -200 + random 400, 0];
Expand Down
24 changes: 15 additions & 9 deletions Project_0.Altis/Intel/Intel.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ CLASS("IntelLocation", "Intel")
T_SETV("mapMarker", _mrk);

// Set/update marker properties
CALLM0(_thisObject, "setLocationMarkerProperties");
CALLSM1("IntelLocation", "setLocationMarkerProperties", _thisObject);

pr _loc = T_GETV("location");
pr _pos = T_GETV("pos");
Expand All @@ -265,7 +265,7 @@ CLASS("IntelLocation", "Intel")

OOP_INFO_2("Updating %1 from %2", _thisObject, _intelSrc);

CALLM0(_thisObject, "setLocationMarkerProperties");
CALLSM1("IntelLocation", "setLocationMarkerProperties", _intelSrc);

pr _loc = T_GETV("location");
pr _pos = T_GETV("pos");
Expand All @@ -292,13 +292,17 @@ CLASS("IntelLocation", "Intel")
systemChat _string;
} ENDMETHOD;

METHOD("setLocationMarkerProperties") {
params [P_THISOBJECT];
STATIC_METHOD("setLocationMarkerProperties") {
params [P_THISCLASS, P_OOP_OBJECT("_intel")];

pr _mapMarker = T_GETV("mapMarker");
pr _type = T_GETV("type");
pr _pos = T_GETV("pos");
pr _side = T_GETV("side");
diag_log format ["--- setLocationMarkerProperties: %1", _intel];
[_intel] call oop_dumpAllVariables;


pr _mapMarker = GETV(_thisObject, "mapMarker"); // Get map marker from this object, not from source object, because source object doesn't have a marker connected to it
pr _type = GETV(_intel, "type");
pr _pos = GETV(_intel, "pos");
pr _side = GETV(_intel, "side");
pr _mrkType = "unknown";
pr _text = "??";
if (_type != LOCATION_TYPE_UNKNOWN) then {
Expand All @@ -317,7 +321,9 @@ CLASS("IntelLocation", "Intel")
default {[COLOR_UNKNOWN, "ColorCIV"]}; // Purple color
};

pr _radius = T_GETV("accuracyRadius");
diag_log format ["--- Setting color: %1", _color];

pr _radius = GETV(_intel, "accuracyRadius");
if (isNil "_radius") then {_radius = 0; };

CALLM1(_mapMarker, "setPos", _pos);
Expand Down
108 changes: 62 additions & 46 deletions Project_0.Altis/Intel/UnitIntel.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Author: Sparker 18.05.2019

CLASS("UnitIntel", "")

STATIC_VARIABLE("eventHandlerAdded");

/*
Method: (static)initUnit
Call it on server.
Expand Down Expand Up @@ -162,52 +164,64 @@ CLASS("UnitIntel", "")
STATIC_METHOD("initPlayer") {
params [P_THISCLASS];

diag_log "--- initPlayer";

//player removeAllEventHandlers "InventoryOpened";
player addEventHandler ["InventoryOpened",
{
[{!isNull (findDisplay 602)}, {

{ // forEach [619, 633, 638];

(finddisplay 602 displayctrl _x) ctrlAddEventHandler ["LBDblClick", {

params ["_control", "_selectedIndex"];
_data = _control lbData _selectedIndex;
diag_log format ["Dbl click: index: %1, data: %2", _selectedIndex, _data];

// Check if the class name of this item belongs to one of the predefined class names
pr _index = INTEL_INVENTORY_ALL_CLASSES findIf {
(_data find _x) == 0
};

if (_index != -1) then { // If it's the document item, delete it and 'inspect' it
// Call code to inspect the intel item
CALLSM1("UnitIntel", "inspectIntel", _data);

// Delete this document item from inventory
[{ // call CBA_fnc_waitAndExecute
params ["_IDC", "_data"];
//diag_log format ["Inside waitAndExecute: %1", _this];
switch (_IDC) do {
case 619: {diag_log "Backpack"; player removeItemFromBackpack _data;};
case 633: {diag_log "Uniform"; player removeItemFromUniform _data;};
case 638: {diag_log "Vest"; player removeItemFromVest _data;};
};
}, [ctrlIDC _control, _data], 0] call CBA_fnc_waitAndExecute; // Can't remove the item right in this frame because it will crash the game

}; // if (_data == ...)

} ]; // ctrlAddEventHandler

} forEach [619, 633, 638]; // These are IDCs of the uniform, vest and backpack containers

}, []] call CBA_fnc_waitUntilAndExecute;

}]; // Add event handler

// 633 - uniform
// 619 - backpack
// 638 - vest
if (! GET_STATIC_VAR(_thisClass, "eventHandlerAdded") || !isMultiplayer) then { // In singleplayer event handler doesn't get magically on respawn transfered :/

diag_log "--- adding event handler";

player addEventHandler ["InventoryOpened",
{

diag_log "--- Inventory opened event handler!";

[{!isNull (findDisplay 602)}, {

{ // forEach [619, 633, 638];

(finddisplay 602 displayctrl _x) ctrlAddEventHandler ["LBDblClick", {

params ["_control", "_selectedIndex"];
_data = _control lbData _selectedIndex;
diag_log format ["Dbl click: index: %1, data: %2", _selectedIndex, _data];

// Check if the class name of this item belongs to one of the predefined class names
pr _index = INTEL_INVENTORY_ALL_CLASSES findIf {
(_data find _x) == 0
};

if (_index != -1) then { // If it's the document item, delete it and 'inspect' it
// Call code to inspect the intel item
CALLSM1("UnitIntel", "inspectIntel", _data);

// Delete this document item from inventory
[{ // call CBA_fnc_waitAndExecute
params ["_IDC", "_data"];
//diag_log format ["Inside waitAndExecute: %1", _this];
switch (_IDC) do {
case 619: {diag_log "Backpack"; player removeItemFromBackpack _data;};
case 633: {diag_log "Uniform"; player removeItemFromUniform _data;};
case 638: {diag_log "Vest"; player removeItemFromVest _data;};
};
}, [ctrlIDC _control, _data], 0] call CBA_fnc_waitAndExecute; // Can't remove the item right in this frame because it will crash the game

}; // if (_data == ...)

} ]; // ctrlAddEventHandler

} forEach [619, 633, 638]; // These are IDCs of the uniform, vest and backpack containers

}, []] call CBA_fnc_waitUntilAndExecute;

}]; // Add event handler

// 633 - uniform
// 619 - backpack
// 638 - vest

SET_STATIC_VAR("UnitIntel", "eventHandlerAdded", true);
};

} ENDMETHOD;

Expand All @@ -225,4 +239,6 @@ CLASS("UnitIntel", "")
REMOTE_EXEC_CALL_METHOD(_playerCommander, "getIntelFromInventoryItem", [_baseClass ARG _ID ARG clientOwner], 2);
} ENDMETHOD;

ENDCLASS;
ENDCLASS;

SET_STATIC_VAR("UnitIntel", "eventHandlerAdded", false);
5 changes: 5 additions & 0 deletions Project_0.Altis/UI/ClientMapUI/ClientMapUI.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,11 @@ CLASS(CLASS_NAME, "")
case LOCATION_TYPE_CAMP: {"Camp"};
case LOCATION_TYPE_BASE: {"Base"};
case LOCATION_TYPE_UNKNOWN: {"<Unknown>"};
case LOCATION_TYPE_CITY: {"City"};
case LOCATION_TYPE_OBSERVATION_POST: {"Observation post"};
case LOCATION_TYPE_ROADBLOCK: {"Roadblock"};
case LOCATION_TYPE_POLICE_STATION: {"Police Station"};
default {format ["ClientMapUI.sqf line %1", __LINE__]}; // If you see this then you know where to implement this!
};

_timeText = str GETV(_intel, "dateUpdated");
Expand Down
10 changes: 5 additions & 5 deletions Project_0.Altis/onPlayerRespawn.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ saluteKeys = actionKeys "Salute";
};
}];*/

player addEventHandler ["AnimChanged", {
_newUnit addEventHandler ["AnimChanged", {
params ["_unit", "_anim"];

//systemChat format ["AnimChanged to : %1", _anim];
Expand Down Expand Up @@ -105,7 +105,7 @@ player addEventHandler ["AnimChanged", {
*/

// Create a suspiciousness monitor for player
NEW("UndercoverMonitor", [player]);
NEW("UndercoverMonitor", [_newUnit]);

// Create scroll menu to talk to civilians
pr0_fnc_talkCond = { // I know I overwrite it every time but who cares now :/
Expand All @@ -114,7 +114,7 @@ pr0_fnc_talkCond = { // I know I overwrite it every time but who cares now :/
};


player addAction ["Talk to civilian", // title
_newUnit addAction ["Talk to civilian", // title
"cursorObject spawn CivPresence_fnc_talkTo", // Script
0, // Arguments
9000, // Priority
Expand All @@ -128,9 +128,9 @@ player addAction ["Talk to civilian", // title
""]; //memoryPoint

// Init the UnitIntel on player
CALLSM1("UnitIntel", "initPlayer", player);
CALLSM0("UnitIntel", "initPlayer");

// Init the Location Visibility Monitor on player
NEW("LocationVisibilityMonitor", [player]);
NEW("LocationVisibilityMonitor", [_newUnit]);

CALLM(gGameMode, "playerSpawn", _this);

0 comments on commit be2c017

Please sign in to comment.