From 77336f197e39909c64b98040940101ea02811374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Tu=C5=9Bnio?= Date: Sat, 13 May 2017 18:01:48 +0100 Subject: [PATCH] ADD: a reputation change whenever a building is destroyed --- .../core/def/mission.sqf | 29 +++++++++++++++++++ .../core/fnc/compile.sqf | 1 + .../core/fnc/eh/buildingchanged.sqf | 24 +++++++++++++++ .../core/init_server.sqf | 2 ++ 4 files changed, 56 insertions(+) create mode 100644 =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/eh/buildingchanged.sqf diff --git a/=BTC=co@30_Hearts_and_Minds.Altis/core/def/mission.sqf b/=BTC=co@30_Hearts_and_Minds.Altis/core/def/mission.sqf index d944af25b..20c0547dd 100644 --- a/=BTC=co@30_Hearts_and_Minds.Altis/core/def/mission.sqf +++ b/=BTC=co@30_Hearts_and_Minds.Altis/core/def/mission.sqf @@ -159,6 +159,33 @@ if (isServer) then { //Vehs btc_vehicles = [btc_veh_1,btc_veh_2,btc_veh_3,btc_veh_4,btc_veh_5,btc_veh_6,btc_veh_7,btc_veh_8,btc_veh_9,btc_veh_10,btc_veh_11,btc_veh_12,btc_veh_13,btc_veh_14,btc_veh_15]; btc_helo = [btc_helo_1]; + + // The two arrays below are prefixes of buildings and their multiplier. + // They will multiply the values of btc_rep_malus_building_destroyed and btc_rep_malus_building_damaged, + // if a building is not present here it will be multiplied by 1.0. + // Use 0.0 to disable reputation hit on a specific's building destruction. + // You can modify this for any other terrain, clearing the table will also make all buildings just have a 1.0 multiplier. + // If there's a hit in btc_buildings_multiplier, btc_buildings_categories_multipliers will NOT be run + btc_buildings_multipliers = [ + // Specific buildings that need to have a custom modifier. + ["Land_BellTower", 0.2 ], ["Land_WIP", 1.5], ["Land_u_Addon_01", 0.2], ["Land_Airport_Tower", 10.0], + ["Land_TentHangar", 7.0], ["Land_i_Shed_Ind", 1.5], ["Land_u_Shed_Ind", 1.5], + ["Land_TTowerBig", 6.0], ["Land_TTowerSmall", 4.5], ["Land_cmp_Tower", 4.0] + ]; + + // The multipliers are applied on top of each other, so "Chapel" and "Small" will both multiply the malus value + btc_buildings_categories_multipliers = [ + ["Shed", 0.75], ["Shop", 1.5], ["Slum", 0.8], ["Small", 0.8], ["Big", 1.5], ["Villa", 2.0], ["Main", 3.0], ["Tower", 2.0], + ["HouseBlock", 2.0], ["School", 3.0], ["Office", 2.0], + ["Chapel", 3.0], ["Minaret", 3.0], ["Mosque", 4.0], ["Church", 4.0], ["Kostel", 4.0], + ["Lighthouse", 4.0], + ["Airport", 4.0], ["Hangar", 1.75], ["ControlTower", 2.25], ["Terminal", 3.0], + ["Hopper", 2.0], ["Tank", 4.0], ["Factory", 2.0], ["Transformer", 1.1], + ["FuelStation", 5.0], + ["Barracks", 1.75], + ["spp", 3.0], ["Powerstation", 3.0], + ["Pump", 2.5] + ]; }; //City @@ -521,6 +548,8 @@ btc_rep_malus_civ_killed = - 10; btc_rep_malus_civ_firenear = - 5; btc_rep_malus_player_respawn = - 10; btc_rep_malus_veh_killed = - 25; +btc_rep_malus_building_damaged = - 5; +btc_rep_malus_building_destroyed = - 10; //Side if (isNil "btc_side_assigned") then {btc_side_assigned = false;}; diff --git a/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/compile.sqf b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/compile.sqf index f3371334a..30a72484e 100644 --- a/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/compile.sqf +++ b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/compile.sqf @@ -64,6 +64,7 @@ if (isServer) then { btc_fnc_eh_veh_respawn = compile preprocessFile "core\fnc\eh\veh_respawn.sqf"; btc_fnc_eh_explosives_defuse = compile preprocessFile "core\fnc\eh\explosives_defuse.sqf"; btc_fnc_eh_handledisconnect = compile preprocessFile "core\fnc\eh\handledisconnect.sqf"; + btc_fnc_eh_buildingchanged = compile preprocessFile "core\fnc\eh\buildingchanged.sqf"; //IED btc_fnc_ied_boom = compile preprocessFile "core\fnc\ied\boom.sqf"; diff --git a/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/eh/buildingchanged.sqf b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/eh/buildingchanged.sqf new file mode 100644 index 000000000..5df65a40e --- /dev/null +++ b/=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/eh/buildingchanged.sqf @@ -0,0 +1,24 @@ +params ["_from", "_to", "_isRuin"]; +private _classname = typeOf _from; +private _malus = [btc_rep_malus_building_damaged, btc_rep_malus_building_destroyed] select _isRuin; +private _skipCategories = false; + +{ + if([_x select 0, _classname] call BIS_fnc_inString) exitWith { + _malus = _malus * (_x select 1); + _skipCategories = true; + }; +} forEach btc_buildings_multipliers; + +if(!_skipCategories) then { + { + if([_x select 0, _classname] call BIS_fnc_inString) then { + _malus = _malus * (_x select 1); + }; + } forEach btc_buildings_categories_multipliers; +}; + +if (btc_debug) then { + systemChat format [ "BuildingChanged: %1 to %2. Malus: %3", + typeOf _from, typeOf _to, _malus ]; +}; diff --git a/=BTC=co@30_Hearts_and_Minds.Altis/core/init_server.sqf b/=BTC=co@30_Hearts_and_Minds.Altis/core/init_server.sqf index a3f3f3cfe..fec752b40 100644 --- a/=BTC=co@30_Hearts_and_Minds.Altis/core/init_server.sqf +++ b/=BTC=co@30_Hearts_and_Minds.Altis/core/init_server.sqf @@ -24,6 +24,8 @@ call btc_fnc_db_autosave; addMissionEventHandler ["HandleDisconnect",btc_fnc_eh_handledisconnect]; +addMissionEventHandler ["BuildingChanged",btc_fnc_eh_buildingchanged]; + ["ace_explosives_defuse", btc_fnc_eh_explosives_defuse] call CBA_fnc_addEventHandler; ["Initialize"] call BIS_fnc_dynamicGroups;