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

Conversation

mtusnio
Copy link

@mtusnio mtusnio commented May 13, 2017

Links to #288

I don't have a dedicated server yet to test it on properly, but I'm looking mainly for review comments (although if someone can test it I won't say no to that!). As you can see in the code the idea is that the reputation malus can be applied in two ways: either by damaging a building or destroying. Technically destroying a building outright is better for your reputation then damaging and destroying, but in a way it makes sense - people don't really like you breaking their houses and then finishing them up later. ;)

The filter is applied on a prefix basis, so the first entry that matches the prefix will be the multiplier we take. I've set up basic multipliers to weed out: small buildings that shouldn't be that big of an issue, larger buildings that get a 1.5-2.0 multiplier. Chapels (churches are invincible apparently?) that go from 2.5 and 3.0, and then industrial/transport/communication buildings which give a massive penalty. After all no-one likes their factories getting ripped to shreds. Please check if you're fine with the numbers!

I looked through the code provided by @Breech99 but I don't think that's needed at the moment, as in we are only interested in knowing whether there's some building somewhere that transitions from one phase to another, the netids might come in useful though in the future to store the states of buildings between saves.

Final test :

  • local
  • server

@Vdauphin Vdauphin self-requested a review May 13, 2017 17:31
@Vdauphin Vdauphin added this to the 1.17 milestone May 13, 2017
@Vdauphin Vdauphin removed their request for review May 13, 2017 17:33
Copy link
Owner

@Vdauphin Vdauphin left a comment

Choose a reason for hiding this comment

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

Hello, thank you this look very good ! Can you use the master_daily branch (#288 (comment))? See you soon :)

@mtusnio
Copy link
Author

mtusnio commented May 13, 2017

Crap, sure, will do. I forgot about that comment, and I was so happy I picked the right branch this time. :D

@mtusnio mtusnio changed the base branch from master_stable to master_daily May 13, 2017 17:40
Vdauphin
Vdauphin previously approved these changes May 13, 2017
Copy link
Owner

@Vdauphin Vdauphin left a comment

Choose a reason for hiding this comment

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

btc_buildings_multipliers is really interesting. I know church can't be destroy sadly :/ Did you think about the https://community.bistudio.com/wiki/boundingBoxReal or https://community.bistudio.com/wiki/boundingBox for building witch are not inside the array ?

@@ -24,6 +24,23 @@ call btc_fnc_db_autosave;

addMissionEventHandler ["HandleDisconnect",btc_fnc_eh_handledisconnect];

addMissionEventHandler ["BuildingChanged",{
Copy link
Owner

Choose a reason for hiding this comment

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

Copy link
Author

@mtusnio mtusnio May 13, 2017

Choose a reason for hiding this comment

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

Sure, I also realised that the files use tabs rather than spaces by default, I'll convert these.

@mtusnio
Copy link
Author

mtusnio commented May 13, 2017

You mean to use the bounding box to determine roughly its size? Not sure if that'd be a good idea, some buildings are quite large (like the sheds with metal roofs), but it doesn't make much sense for the reputation hit to be as high as the big houses. There's something else I just spotted though - https://community.bistudio.com/wiki/Arma_3_CfgVehicles_EMPTY - there's a bit called "Category" which groups them by type, so you could technically apply a category filter first. The only question is how to access the category, I guess it's through some Cfg file magic.

@Vdauphin
Copy link
Owner

You mean to use the bounding box to determine roughly its size?
yes !

Not sure if that'd be a good idea, some buildings are quite large (like the sheds with metal roofs), but it doesn't make much sense for the reputation hit to be as high as the big houses.

ok perfect :)

There's something else I just spotted though - https://community.bistudio.com/wiki/Arma_3_CfgVehicles_EMPTY - there's a bit called "Category" which groups them by type, so you could technically apply a category filted first.

if the btc_buildings_multipliers is enough to find building this is ok. I worried if the player destroy walls. Does the reputation is decreased ? Is it not too much?

@mtusnio
Copy link
Author

mtusnio commented May 13, 2017

You mean by toppling the walls over? I checked with lamp posts, but that didn't have any impact since the model doesn't change at all. Are there any walls in Arma that don't fall down but change their model when destroyed?

@Vdauphin
Copy link
Owner

You mean by toppling the walls over?

yes!

I checked with lamp posts, but that didn't have any impact since the model doesn't change at all.

perfect

Are there any walls in Arma that don't fall down but change their model when destroyed?

I don't think so, you write then.

@mtusnio mtusnio force-pushed the Add_Building_Reputation branch 2 times, most recently from 865062b to f4fa8cb Compare May 13, 2017 18:18
@mtusnio
Copy link
Author

mtusnio commented May 13, 2017

A quick question, since I just realised, there's also a mission_tanoa.sqm, I'm wondering if then it'd make sense to have a switch/case with different buildings depending on the (official) terrain?

Current list only tackles Altis.

@Vdauphin
Copy link
Owner

I don't think. The btc_buildings_multipliers should cover all terrains or if not possible at least vanilla terrains.

@mtusnio
Copy link
Author

mtusnio commented May 13, 2017

I'll fix it up properly, for performance reasons it might make sense to just do a switch/case depending on map type, especially since in the future it'd be easy to just accommodate any changes by adding a new world map.

@Breech99
Copy link

Breech99 commented May 13, 2017

I've got a dedicated box I'll run it on to test with 5-7 of my peeps. It's an Intel I7 6700k at 4.8ghz. I'll check logs and see if anything pops up unexpectedly. I'm working on some suicide car bomb theory test scripts.
Awesome work mtusino! I don't see any other missions doing half of the features H&M is scripting. So challenging and fun.

I've added that one guy's Oil Derick and added to LandMarine locations so side missions can spawn near it. Can hardly wait to add the ford class carrier way way off the shores of the islands for a hearts and minds test. Feel free to try out this crazy version I did for Tanoa on the main airport as a base of operations. https://github.com/Breech99/HeartsAndMinds/tree/Hearts-and-MindsMain_Blufor_Base

@Vdauphin
Copy link
Owner

Vdauphin commented May 13, 2017

I don't know if I am wrong but the btc_buildings_multipliers is specific so it will not work for
all map, if I am correct (Tested on Tanoa, small house are not catch
because there are named like Land_House_Small_ blabla (may be it is intended))

If we take a look of your array, I can see common name like Small Big
Chapel House. It should be interesting to make the filter less
specific but independ from the map which is a very important point for
H&M.

An array like that : btc_buildings_multipliers = [ ["Small", 0.5], ["Big", 2], [ "House", 1.0 ], ["Shop", 1.5], ["Chapel", 2.5], ["Factory", 2], ["Airport", 10], ["Hangar", 1.5] ]; (just a short exemple)

And a filtering like that:

{
	if (( (toUpper _classname) find toUpper(_x select 0))> -1) then {
		_malus = _malus * (_x select 1);
	};
} forEach btc_buildings_multipliers;

So if the building destroyed with keyword : Big and House the malus will be : _malus * 2 * 4

Do you think this approch could be better ?

@mtusnio
Copy link
Author

mtusnio commented May 14, 2017

Yeah, that was my initial issue with "How should it preferably work on Tanoa & other maps". I'll go through the list of structures in other maps such as Cherno etc. to see if they follow the same model, but could do something like this. In worse case scenario this could be expanded to give multiple categories under one multiplier to look for edge cases like different naming and such. On custom maps then, in worse case scenario it will just apply a static -5/-10 (or whatever it's set to).

No a funny note, out of curiosity I did a quick google for Cherno but found references to the DayZ version of Cherno. Their house names? All in Czech :D

@Vdauphin
Copy link
Owner

All in Czech :D

X)

@mtusnio
Copy link
Author

mtusnio commented May 15, 2017

Pushed a change. The array is not split into two, one to allow explicit overwriting for specific buildings, the other just stacks modifiers based on the names. I had a look at Cherno/Takistan classnames as well to add some categories, but Cherno is a mix of Czech and English names. However, it seems the most important ones are in plain English. I couldn't find the hotel classname though, so that's a bit of an issue.

Oh, also, I squashed your commit into the main one since it was a fix for the changes I did in PR.

@mtusnio mtusnio force-pushed the Add_Building_Reputation branch 3 times, most recently from 158f47c to 77336f1 Compare May 15, 2017 15:20
@Vdauphin
Copy link
Owner

For me this is perfect.

A little question, why do you use call BIS_fnc_inString and not toupper and find command?

@mtusnio
Copy link
Author

mtusnio commented May 15, 2017

I haven't tested this myself, but based on this example it seems that the find function just finds a specific object you're looking for, it doesn't check the insides of arrays within an array. You could technically do a loop and then run a find on the string itself, but Bis_fnc_inString does the same thing pretty much. I preferred inString for readability, but then it's SQF so it's unreadable by definition. ;)

Funnily enough Bis_fnc_inString is newer than find, at first I thought maybe find is supposed to replace it but doesn't look like it.

@Vdauphin
Copy link
Owner

Vdauphin commented May 15, 2017

hint str ("japa is the man!" find "the man!"); //8 (since ["Arma 3","Arma3",127,126674,"Development"])

is same as:

["the man!","japa is the man!"] call BIS_fnc_inString

find is faster because is a command, not a function.

@mtusnio
Copy link
Author

mtusnio commented May 15, 2017

I was expecting Bis_fnc_inString would be optimised (or at worst use find) for string searching, but I just checked and yeah, find is a good deal faster. Updated the handler to use find instead.

@@ -0,0 +1,24 @@
params ["_from", "_to", "_isRuin"];
private _classname = typeOf _from;
Copy link
Owner

Choose a reason for hiding this comment

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

should be private _classname = toUpper typeOf _from;

private _skipCategories = false;

{
if ((toUpper _classname) find (toUpper (_x select 0)) != -1) exitWith {
Copy link
Owner

Choose a reason for hiding this comment

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

toUpper _classname --> _classname


if (!_skipCategories) then {
{
if ((toUpper _classname) find (toUpper (_x select 0)) != -1) then {
Copy link
Owner

Choose a reason for hiding this comment

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

toUpper _classname --> _classname

@mtusnio
Copy link
Author

mtusnio commented May 16, 2017

Done, I've also thrown in some more classnames to cover more buildings on Cherno.


// 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!

@Vdauphin
Copy link
Owner

Vdauphin commented May 19, 2017

Hello, When you kill a civilan you just have a malus of 10. I am not sure but I think the malus boost increase a lot the global malus. May be the initial malus should be decreased by a half.
Damge =2.5
Dedtroy =5

What do you think ?

One last thing thé documentation should be update to advise palyer of this. Thank you for the good job

@Breech99
Copy link

Oh, so the boost increase increases civilian killed punish more than -10? I'll have to check. I do think I like what the current settings are at now.

btc_rep_malus_civ_hd = - 10;
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

how much more do they increase with the boost?

@Vdauphin
Copy link
Owner

so the boost increase increases civilian killed punish more than -10?

No sorry. I mean in comparison civil malus is only -10. You lost a lot more reputation when you destroy a building than killing a civilian. But if from your point of view is okay leave it like that.

For documentation add here: https://github.com/Vdauphin/HeartsAndMinds/blob/master_daily/%3DBTC%3Dco%4030_Hearts_and_Minds.Altis/core/doc.sqf#L118

Something like that:
damaging or destroying building ....

@Breech99
Copy link

Breech99 commented May 21, 2017

Fantastic.. Yeah, let the player be aware in documentation "You will have to do your best to minimize collateral damage from damaging or destroying buildings." "There will be times where you cannot avoid but try and keep damage to a minimum." -either one of those comments along those lines.

@mtusnio
Copy link
Author

mtusnio commented May 21, 2017

I don't have access to my PC at the moment, but yeah, I'm happy with whatever numbers you prefer. :) I'll change it and update the docs once I'm back

@Vdauphin
Copy link
Owner

I am doing Final test on your PR before merging and..
hum ... wait ... something is missing ... you do a well calculation ... but you forget to apply it x) :p

Add a line like this should help ;)
_malus call btc_fnc_rep_change;

Byebye!

@Vdauphin Vdauphin merged commit 87b1f8c into Vdauphin:master_daily May 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants