Add new plugin API properties to entity, ride and park

This commit is contained in:
Basssiiie 2021-08-11 13:54:00 +02:00 committed by GitHub
parent 177f19f64e
commit 23bae61b7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 92 additions and 15 deletions

View File

@ -91,7 +91,7 @@ The following people are not part of the development team, but have been contrib
* Jim Verheijde (Jimver) - Make handymen less likely to get stuck in queue lines, misc. * Jim Verheijde (Jimver) - Make handymen less likely to get stuck in queue lines, misc.
* Helio Batimarqui (batimarqui) - Misc. * Helio Batimarqui (batimarqui) - Misc.
* Keith Stellyes (keithstellyes) - Misc. * Keith Stellyes (keithstellyes) - Misc.
* Bas Cantrijn (Basssiiie) - Misc. * Bas Cantrijn (Basssiiie) - Various plugin additions, misc.
* Adrian Zdanowicz (CookiePLMonster) - Misc. * Adrian Zdanowicz (CookiePLMonster) - Misc.
* Andrew Pratt (andrewpratt64) - Added api hook for vehicle crashes * Andrew Pratt (andrewpratt64) - Added api hook for vehicle crashes

View File

@ -4,6 +4,7 @@
- Feature: [#15143] Added a shortcut key for Giant Screenshot. - Feature: [#15143] Added a shortcut key for Giant Screenshot.
- Feature: [#15164] Highlight elements selected by the Tile Inspector, tracks are currently not supported. - Feature: [#15164] Highlight elements selected by the Tile Inspector, tracks are currently not supported.
- Feature: [#15165] [Plugin] Add the ability to create entities using "map.createEntity". - Feature: [#15165] [Plugin] Add the ability to create entities using "map.createEntity".
- Feature: [#15194] [Plugin] Add guest properties, ride downtime and park casualty penalty.
- Fix: [#13465] Creating a scenario based on a won save game results in a scenario thats instantly won. - Fix: [#13465] Creating a scenario based on a won save game results in a scenario thats instantly won.
- Fix: [#14316] Closing the Track Designs Manager window causes broken state. - Fix: [#14316] Closing the Track Designs Manager window causes broken state.
- Fix: [#14667] “Extreme Hawaiian Island” has unpurchaseable land tiles (original bug). - Fix: [#14667] “Extreme Hawaiian Island” has unpurchaseable land tiles (original bug).

View File

@ -516,9 +516,9 @@ declare global {
readonly isClientOnly: boolean; readonly isClientOnly: boolean;
result: boolean; result: boolean;
} }
type VehicleCrashIntoType = "another_vehicle" | "land" | "water"; type VehicleCrashIntoType = "another_vehicle" | "land" | "water";
interface VehicleCrashArgs { interface VehicleCrashArgs {
readonly id: number; readonly id: number;
readonly crashIntoType: VehicleCrashIntoType; readonly crashIntoType: VehicleCrashIntoType;
@ -577,6 +577,8 @@ declare global {
getAllEntities(type: "peep"): Peep[]; getAllEntities(type: "peep"): Peep[];
getAllEntities(type: "guest"): Guest[]; getAllEntities(type: "guest"): Guest[];
getAllEntities(type: "staff"): Staff[]; getAllEntities(type: "staff"): Staff[];
getAllEntities(type: "car"): Car[];
getAllEntities(type: "litter"): Litter[];
createEntity(type: EntityType, initializer: object): Entity; createEntity(type: EntityType, initializer: object): Entity;
} }
@ -1034,6 +1036,11 @@ declare global {
* The value of the ride. * The value of the ride.
*/ */
value: number; value: number;
/**
* The percentage of downtime for this ride from 0 to 100.
*/
readonly downtime: number;
} }
type RideClassification = "ride" | "stall" | "facility"; type RideClassification = "ride" | "stall" | "facility";
@ -1441,6 +1448,21 @@ declare global {
* Amount of cash in the guest's pocket. * Amount of cash in the guest's pocket.
*/ */
cash: number; cash: number;
/**
* Whether the guest is within the boundaries of the park.
*/
readonly isInPark: boolean;
/**
* Whether the guest is lost or not. The guest is lost when the countdown is below 90.
*/
readonly isLost: boolean;
/**
* Countdown between 0 and 255 that keeps track of how long the guest has been looking for its current destination.
*/
lostCountdown: number;
} }
/** /**
@ -1485,17 +1507,17 @@ declare global {
creationTime: number; creationTime: number;
} }
type LitterType = "vomit" | type LitterType = "vomit" |
"vomit_alt" | "vomit_alt" |
"empty_can" | "empty_can" |
"rubbish" | "rubbish" |
"burger_box" | "burger_box" |
"empty_cup" | "empty_cup" |
"empty_box" | "empty_box" |
"empty_bottle" | "empty_bottle" |
"empty_bowl_red" | "empty_bowl_red" |
"empty_drink_carton" | "empty_drink_carton" |
"empty_juice_cup" | "empty_juice_cup" |
"empty_bowl_blue"; "empty_bowl_blue";
/** /**
@ -1750,6 +1772,12 @@ declare global {
*/ */
constructionRightsPrice: number; constructionRightsPrice: number;
/**
* The amount of penalty points currentlty applied to the park rating for
* drowned guests and crashed coaster cars.
*/
casualtyPenalty: number;
/** /**
* The number of tiles on the map with park ownership or construction rights. * The number of tiles on the map with park ownership or construction rights.
* Updated every 4096 ticks. * Updated every 4096 ticks.

View File

@ -848,6 +848,9 @@ namespace OpenRCT2::Scripting
dukglue_register_property(ctx, &ScGuest::maxIntensity_get, &ScGuest::maxIntensity_set, "maxIntensity"); dukglue_register_property(ctx, &ScGuest::maxIntensity_get, &ScGuest::maxIntensity_set, "maxIntensity");
dukglue_register_property(ctx, &ScGuest::nauseaTolerance_get, &ScGuest::nauseaTolerance_set, "nauseaTolerance"); dukglue_register_property(ctx, &ScGuest::nauseaTolerance_get, &ScGuest::nauseaTolerance_set, "nauseaTolerance");
dukglue_register_property(ctx, &ScGuest::cash_get, &ScGuest::cash_set, "cash"); dukglue_register_property(ctx, &ScGuest::cash_get, &ScGuest::cash_set, "cash");
dukglue_register_property(ctx, &ScGuest::isInPark_get, nullptr, "isInPark");
dukglue_register_property(ctx, &ScGuest::isLost_get, nullptr, "isLost");
dukglue_register_property(ctx, &ScGuest::lostCountdown_get, &ScGuest::lostCountdown_set, "lostCountdown");
} }
private: private:
@ -1115,6 +1118,33 @@ namespace OpenRCT2::Scripting
peep->CashInPocket = std::max(0, value); peep->CashInPocket = std::max(0, value);
} }
} }
bool isInPark_get() const
{
auto peep = GetGuest();
return (peep != nullptr && !peep->OutsideOfPark);
}
bool isLost_get() const
{
auto peep = GetGuest();
return (peep != nullptr && peep->GuestIsLostCountdown < 90);
}
uint8_t lostCountdown_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->GuestIsLostCountdown : 0;
}
void lostCountdown_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->GuestIsLostCountdown = value;
}
}
}; };
class ScStaff : public ScPeep class ScStaff : public ScPeep

View File

@ -449,6 +449,16 @@ namespace OpenRCT2::Scripting
gConstructionRightsPrice = value; gConstructionRightsPrice = value;
} }
int16_t casualtyPenalty_get() const
{
return gParkRatingCasualtyPenalty;
}
void casualtyPenalty_set(int16_t value)
{
ThrowIfGameStateNotMutable();
gParkRatingCasualtyPenalty = value;
}
uint16_t parkSize_get() const uint16_t parkSize_get() const
{ {
return gParkSize; return gParkSize;
@ -600,6 +610,7 @@ namespace OpenRCT2::Scripting
dukglue_register_property(ctx, &ScPark::parkSize_get, nullptr, "parkSize"); dukglue_register_property(ctx, &ScPark::parkSize_get, nullptr, "parkSize");
dukglue_register_property(ctx, &ScPark::name_get, &ScPark::name_set, "name"); dukglue_register_property(ctx, &ScPark::name_get, &ScPark::name_set, "name");
dukglue_register_property(ctx, &ScPark::messages_get, &ScPark::messages_set, "messages"); dukglue_register_property(ctx, &ScPark::messages_get, &ScPark::messages_set, "messages");
dukglue_register_property(ctx, &ScPark::casualtyPenalty_get, &ScPark::casualtyPenalty_set, "casualtyPenalty");
dukglue_register_method(ctx, &ScPark::getFlag, "getFlag"); dukglue_register_method(ctx, &ScPark::getFlag, "getFlag");
dukglue_register_method(ctx, &ScPark::setFlag, "setFlag"); dukglue_register_method(ctx, &ScPark::setFlag, "setFlag");
dukglue_register_method(ctx, &ScPark::postMessage, "postMessage"); dukglue_register_method(ctx, &ScPark::postMessage, "postMessage");

View File

@ -642,6 +642,12 @@ namespace OpenRCT2::Scripting
} }
} }
uint8_t downtime_get() const
{
auto ride = GetRide();
return ride != nullptr ? ride->downtime : 0;
}
Ride* GetRide() const Ride* GetRide() const
{ {
return get_ride(_rideId); return get_ride(_rideId);
@ -681,6 +687,7 @@ namespace OpenRCT2::Scripting
dukglue_register_property( dukglue_register_property(
ctx, &ScRide::inspectionInterval_get, &ScRide::inspectionInterval_set, "inspectionInterval"); ctx, &ScRide::inspectionInterval_get, &ScRide::inspectionInterval_set, "inspectionInterval");
dukglue_register_property(ctx, &ScRide::value_get, &ScRide::value_set, "value"); dukglue_register_property(ctx, &ScRide::value_get, &ScRide::value_set, "value");
dukglue_register_property(ctx, &ScRide::downtime_get, nullptr, "downtime");
} }
}; };
} // namespace OpenRCT2::Scripting } // namespace OpenRCT2::Scripting

View File

@ -46,7 +46,7 @@ namespace OpenRCT2
namespace OpenRCT2::Scripting namespace OpenRCT2::Scripting
{ {
static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 35; static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 36;
// Versions marking breaking changes. // Versions marking breaking changes.
static constexpr int32_t API_VERSION_33_PEEP_DEPRECATION = 33; static constexpr int32_t API_VERSION_33_PEEP_DEPRECATION = 33;