-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Level progression fixes and formatting
`vehiclemanager` addition fixes the vehicle events by capping to 4, required `elementareatrigger` fixes area event triggers by capping to 4 players required.
- Loading branch information
Showing
4 changed files
with
55 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-- Levels that trigger events that depend on all players inside become a problem with >4 players | ||
-- This caps the `total_players` variable to 4. The vehicle events are triggered by a listener | ||
-- fired by `VehicleManager:on_player_entered_vehicle(vehicle_unit, player)` | ||
-- Only change to this function is the 2nd line added to do the cap. | ||
function VehicleManager:all_players_in_vehicles() | ||
local total_players = managers.network:session():amount_of_alive_players() | ||
total_players = total_players > 4 and 4 or total_players | ||
|
||
local players_in_vehicles = 0 | ||
for _, vehicle in pairs(self._vehicles) do | ||
players_in_vehicles = players_in_vehicles + vehicle:vehicle_driving():num_players_inside() | ||
end | ||
|
||
return total_players == players_in_vehicles | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-- Store original functions from the ones we modify | ||
local orig_ElementAreaTrigger = { | ||
project_amount_all = ElementAreaTrigger.project_amount_all | ||
} | ||
|
||
|
||
-- Capping the value to 4 for `criminals`/`local_criminals` instigators to avoid | ||
-- some event comparisons that fail above expected max value of 4. | ||
-- Start of Framing Frame Day 2 where everyone needs to be in the train is said to be affected | ||
function ElementAreaTrigger:project_amount_all() | ||
local i = orig_ElementAreaTrigger.project_amount_all(self) | ||
|
||
-- Ensure i is no higher than 4 for these instigators (May also want to include `ai_teammates`?) | ||
-- This value for these instigators includes both Peers and AI criminals | ||
if self._values.instigator == "criminals" or self._values.instigator == "local_criminals" then | ||
i = i > 4 and 4 or i | ||
end | ||
|
||
return i | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters