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
Feat: enable sending guest to specific ride #21897
base: develop
Are you sure you want to change the base?
Conversation
src/openrct2/entity/Guest.cpp
Outdated
return; | ||
if (x == LOCATION_NULL) | ||
return; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function does not seem to check if the guest is actually in the park.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line was copypasted from Guest::PickRideToGoOn(), which was what I based all this code on. I'm not sure what it does but left it since it didn't obviously hurt anything.
the guest is checked to be in the park in the PeepState check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally looking forward to the changes, just have a little feedback as I was looking through the PR.
I've gone ahead per @Basssiiie's suggestion and moved all the code out of Guest and into ScGuest. Couple questions-
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one! 😀
Regarding the formatting, it should be possible to run clang-format from cmdline, though I've never done it before. |
From the base directory of OpenRCT2 - you should be able to run sh scripts/check-code-formatting Presuming you have bash installed... |
Tested it and found no issues. LGTM! 😄 Click here for the plugin I used for testing.registerPlugin({
name: "Test guest ride head to",
version: "1",
authors: ['Basssiiie'],
targetApiVersion: 82,
type: "local",
licence: "MIT",
main()
{
ui.registerMenuItem("Test guest ride head to", function()
{
ui.activateTool({
id: "test-guest-ride-head-to",
cursor: "cross_hair",
onDown: function(args)
{
var id = args.entityId;
if (id == undefined) return;
var guest = map.getEntity(id);
if (guest.type !== "guest") return;
var rides = map.rides.slice().sort(function(l,r){return l.name.localeCompare(r.name)});
var window = ui.openWindow({
classification: "test-guest-ride-head-to",
title: "Guest ride head to",
width: 210,
height: 100,
onUpdate: function()
{
var label = window.findWidget("guest-ride");
var rideId = guest.rideHeadedTo;
var ride = rides.filter(function(r){return r.id == rideId})[0];
if (ride)
{
label.text = "Ride head to: " + ride.name + " (" + guest.rideHeadedTo + ")";
}
else
{
label.text = "Ride head to: null";
}
},
widgets: [
{
type: "label",
x: 5,
y: 20,
width: 200,
height: 15,
text: "Name: " + guest.name
},
{
name: "guest-ride",
type: "label",
x: 5,
y: 40,
width: 200,
height: 15,
},
{
type: "dropdown",
x: 5,
y: 60,
width: 200,
height: 15,
items: rides.map(function(r){return r.name}),
onChange: function(index)
{
guest.rideHeadedTo = rides[index].id;
}
},
{
type: "button",
text: "Reset ride headed to",
x: 5,
y: 80,
width: 200,
height: 15,
onClick: function()
{
guest.rideHeadedTo = null;
}
},
]
})
}
})
})
}
}); |
I believe code formatting is failing just because of |
This PR adds a new feature (I'd say a cheat), the ability to specifically send guests to a given ride, regardless of whether they'd naturally choose it or not.
Calling the
Guest::SendToRide
method will override their current state if they're walking, sitting, watching a ride, or using the bin. It'll also override their behavior if they were trying to leave the park, and will send them to the ride instead.This is exposed to the plugin api through the direct guest property method
sendToRide(rideId)
, or via thecheatset
game action. For player visibility, also addsrideHeadedTo
as a getter prop on Guest.This is my first c++ submission, and I'd appreciate a thorough review in case I've done anything non-optimally.
Future improvement would include stealing guests out of other queue lines, but I ran into issues when the original ride would try and process guests who are no longer in the queue and the game would crash. I wasn't able to solve this in a satisfying way that would scale as a user tries looping through all the guests in a park.
TODO: I know the plugin api version will need a bump after this, but unsure when that happens in the PR process.