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

Buildings can now (ideally) only last 2 hours max #41

Open
wants to merge 7 commits into
base: development
Choose a base branch
from

Conversation

FightKnight441
Copy link

Buildings can now (ideally) only last 2 hours max. If supplies are still added at the building's max time, it will still consume the supplies., and hint to the player that this is happening.

client/functions/basebuilding/fn_abort_building.sqf Outdated Show resolved Hide resolved
client/functions/basebuilding/fn_place_object.sqf Outdated Show resolved Hide resolved
_supplies = (_maxTimeLimit * _supplyConsumptionRate) - _currentSupplies;

// notify players that time limit has been reached and item was still consumed
["TaskFailed",["",localize "STR_para_build_maxtimereached"]] call para_c_fnc_show_notification;

Choose a reason for hiding this comment

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

This will probably need remoteExec-ing for the specific player, which means we need to pass the player object into the args for this script.

On player-hosted local development this will work because the server IS the player. But probably won't work on dedicated server.

I think. On phone so bit limited in what I can check easily.

Also, there's a notifications config here https://github.com/Bro-Nation/Paradigm/blob/development/client/configs/notifications.hpp

But that's for "client" functions and this is a "server" function.

Hmmm. I Need to think about this/have a look at the rest of the code path. I wonder if we can do the "too long, are your supplies" notification on whatever script calls this on the client?

Because the interaction overlay already shows how much time is left for supplies, so that value is already available to clients.

Copy link
Author

Choose a reason for hiding this comment

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

I was copying how they did notifications for adding a crate.

https://github.com/Bro-Nation/Paradigm/blob/development/client/functions/basebuilding/fn_resupply_building_with_crate.sqf

if !(_nearbySupplies isEqualTo []) then { ["resupplybuilding", [_target, "CRATE"]] call para_c_fnc_call_on_server; } else { ["TaskFailed",["",localize "STR_vn_mf_nosupplydropnearby"]] call para_c_fnc_show_notification; };

Last line, they call a notification in a very similar way so, I think, it ought work, I do see what you mean though.

Copy link

@dijksterhuis dijksterhuis Sep 11, 2024

Choose a reason for hiding this comment

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

This will probably need remoteExec-ing for the specific player, which means we need to pass the player object into the args for this script.

Classic viewing a PR on my phone, I missed the fact _player is already in here as a variable. See REhandler note below for more info. What you'll need for this specific line (111) is

// executes the notification on the client of the specific player who has done the resupply
[["TaskFailed",["",localize "STR_para_build_maxtimereached"]]] remoteExecCall ["para_c_fnc_show_notification", _player];

It probably won't work on player hosted (local development), but it will work on dedicated server. See I need to refactor a thing because I was lazy note below


REhandler

Mostly a note so we're both aware of what's going on. At the top:

//THIS IS A REHANDLER FUNCTION
//It can only be called from rehandler, as it relies on having _player defined.

script --> fn_rehandler.sqf
_player is taken from the para_s_fnc_rehandler function's scope. layman's version -- para_s_fnc_rehandler calls this script and the _player variable still exists so this function can use it, one of those weird sqf things.


I need to refactor a thing because I was lazy

I'll need to add this in paradigm (it should really be here in paradigm/server/remoteExec anyway but I was being lazy :/ ): https://github.com/Bro-Nation/Mike-Force/blob/development/mission/functions/core/helpers/fn_rExecServerToGlobal_playerHost_or_dedicated.sqf

Server to global client remoteExec depending on whether execution is happening on a player hosted server or a dedicated server.

If you change the line to match the above, I'll do a PR after and switch it to that... or .... you can copy the vn_mf_fnc_rExecServerToGlobal_playerHost_or_dedicated function over to paradigm if you want some bonus points for saving me a job?

having both para_s_fnc_rExecServerToGlobal_playerHost_or_dedicated and vn_mf_fnc_rExecServerToGlobal_playerHost_or_dedicated should be fine for the time being (i'll fix the other references to the vn_mf one)

Choose a reason for hiding this comment

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

I was copying how they did notifications for adding a crate.

Last line, they call a notification in a very similar way so, I think, it ought work, I do see what you mean though.

Tally, seems like it's just one of those paradigm things. That's all fine then.

Copy link
Author

Choose a reason for hiding this comment

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

Tally, seems like it's just one of those paradigm things. That's all fine then.

So it does or does not need to change from:

["TaskFailed",["",localize "STR_para_build_maxtimereached"]] call para_c_fnc_show_notification;

to:

[["TaskFailed",["",localize "STR_para_build_maxtimereached"]]] remoteExecCall ["para_c_fnc_show_notification", _player];

??

Choose a reason for hiding this comment

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

sorry, to clarify

Tally, seems like it's just one of those paradigm things. That's all fine then.

this was specifically about localize "STR_para_build_maxtimereached". just saying i didn't realise they used that method. Mike Force has the notification class name for the most part. Example here.

So it does need to change

yep, will need the remoteExec change.

Copy link
Author

Choose a reason for hiding this comment

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

I think I see what you mean, but how does the notification on the resupply_with_crate/sandbag working then?

if !(_nearbySupplies isEqualTo []) then { ["resupplybuilding", [_target, "CRATE"]] call para_c_fnc_call_on_server; } else { ["TaskFailed",["",localize "STR_vn_mf_nosupplydropnearby"]] call para_c_fnc_show_notification; };

@dijksterhuis dijksterhuis changed the title Buildings can now (ideally) only last 2 hours max. If supplies are st… Buildings can now (ideally) only last 2 hours max Sep 11, 2024
@dijksterhuis
Copy link

note to @dijksterhuis --- will need Bro-Nation/Mike-Force#399 for the notification string


// Check if the current lifetime would exceed the time limit
if ( _proposedRemainingTimeSeconds >= _maxTimeLimit) then {
// if the supplies that are being added will exceed 2 hours for the building, trim the supplies so that it only reaches 2 hours max. This will still consume the item!!!

Choose a reason for hiding this comment

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

split comment over two lines please cos it's quite long, we like to try and keep line length below 100 characters for readability and maintenance purposes

Example PR comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants