Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD: a reputation change whenever a building is destroyed #349

Merged
merged 1 commit into from May 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/def/mission.sqf
Expand Up @@ -159,6 +159,35 @@ 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_Mil_ControlTower", 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], ["Slum", 0.8], ["Small", 0.8], ["Big", 1.5], ["Villa", 2.0], ["Main", 3.0], ["Tower", 2.0],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am worry about "Tower" malus. In Side mission destroy tower, you need to destroy tower like this https://github.com/mtusnio/HeartsAndMinds/blob/master_daily/=BTC=co@30_Hearts_and_Minds.Altis/core/def/mission.sqf#L139

Does the malus will be apply on tower spawn by this side?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, probably best to just code out the generic "Tower" class. easy enough to do. I'll do some testing on my dedi server to see how things are going and report back.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a reason why it wouldn't, that's a bit of an issue. I don't like commenting out the class just in case in the future another buildings gets added to the list. I'll have to look into it to see how to properly fix that. The easiest solution would require the side missions to add any spawned building to a list of "enemy" buildings that are ok to blow up. Alternatively I'll see if there's a way to find out if a building is part of the map or custom spawned.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The easiest solution would require the side missions to add any spawned building to a list of "enemy" buildings that are ok to blow up. Alternatively I'll see if there's a way to find out if a building is part of the map or custom spawned.

OR when the mission is a succes (Tower destroyed ) add a bonus over the building malus so : malus - bonus = 0 ;)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a workaround I'd rather avoid, it'll get confusing really quickly. ;)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jackpot! After screwing around to see if I can somehow use object ids to find out whether it's a terrain or mission-created building I found this: getObjectType. Any buildings created with createVehicle return type of 8, while pre-placed ones give 1.

I tested this out with "Land_TTowerBig_1_F" createVehicle (position player), then blew it up. Didn't get any hit.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!

["HouseBlock", 2.0], ["Panelak", 2.0], ["Tenement", 7.0],
["Barn", 1.5], ["School", 3.0], ["Office", 2.0], ["Shop", 1.5], ["Store", 1.5], ["Hospital", 12.0],
["Castle", 2.5], ["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
Expand Down Expand Up @@ -521,6 +550,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 = - 2.5;
btc_rep_malus_building_destroyed = - 5;

//Side
if (isNil "btc_side_assigned") then {btc_side_assigned = false;};
Expand Down
2 changes: 1 addition & 1 deletion =BTC=co@30_Hearts_and_Minds.Altis/core/doc.sqf
Expand Up @@ -114,7 +114,7 @@ When you destroy an hideout or an ammo cache, all the markers related to it will
player createDiaryRecord ["Documentation", ["Reputation", "
<img image='\A3\ui_f\data\igui\cfg\simpleTasks\types\talk_ca.paa' width='20' height='20'/> Reputation can be ask to civilian<br/>
Bad actions cause bad effetcs.<br/>
<img image='\A3\ui_f\data\igui\cfg\simpleTasks\types\meet_ca.paa' width='20' height='20'/> Helping the local population, fighting the Oplitas, disarming IED will rise your reputation; killing civilians, firing near civilians for no reason, losing vehicles, respawns will decrease your repution. At the beginning you have a very low reputation level, so civilians won't help you revealing important information about Oplitas, they will likely lie instead.
<img image='\A3\ui_f\data\igui\cfg\simpleTasks\types\meet_ca.paa' width='20' height='20'/> Helping the local population, fighting the Oplitas, disarming IED will rise your reputation; killing civilians, firing near civilians for no reason, damaging/destroying buildings, losing vehicles, respawns will decrease your repution. At the beginning you have a very low reputation level, so civilians won't help you revealing important information about Oplitas, they will likely lie instead.
"]
];

Expand Down
1 change: 1 addition & 0 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/compile.sqf
Expand Up @@ -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";
Expand Down
29 changes: 29 additions & 0 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/eh/buildingchanged.sqf
@@ -0,0 +1,29 @@
params ["_from", "_to", "_isRuin"];
private _classname = toUpper typeOf _from;
private _malus = [btc_rep_malus_building_damaged, btc_rep_malus_building_destroyed] select _isRuin;
private _skipCategories = false;

// Accept only static, terrain buildings, discard any dynamically created ones
if (getObjectType _from != 1) exitWith { };

{
if (_classname find (toUpper (_x select 0)) != -1) exitWith {
_malus = _malus * (_x select 1);
_skipCategories = true;
};
} forEach btc_buildings_multipliers;

if (!_skipCategories) then {
{
if (_classname find (toUpper (_x select 0)) != -1) 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 ];
};

_malus call btc_fnc_rep_change;
2 changes: 2 additions & 0 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/init_server.sqf
Expand Up @@ -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;
Expand Down