mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Automatic staff placement
This will automatically place hired staff near a random guest (with fallbacks if no guests are in the park). The setting can be toggled in the options or by holding SHIFT when hiring.
This commit is contained in:
@@ -3676,3 +3676,4 @@ STR_5339 :Base height
|
||||
STR_5340 :Clearance height
|
||||
STR_5341 :Flags
|
||||
STR_5342 :Choose a map tile
|
||||
STR_5343 :Automatically place staff
|
||||
|
||||
@@ -175,6 +175,7 @@ config_property_definition _generalDefinitions[] = {
|
||||
{ offsetof(general_configuration, test_unfinished_tracks), "test_unfinished_tracks", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL },
|
||||
{ offsetof(general_configuration, no_test_crashes), "no_test_crashes", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL },
|
||||
{ offsetof(general_configuration, date_format), "date_format", CONFIG_VALUE_TYPE_UINT8, DATE_FORMAT_DMY, _dateFormatEnum },
|
||||
{ offsetof(general_configuration, auto_staff_placement), "auto_staff", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL },
|
||||
};
|
||||
|
||||
config_property_definition _interfaceDefinitions[] = {
|
||||
|
||||
@@ -132,6 +132,7 @@ typedef struct {
|
||||
uint8 test_unfinished_tracks;
|
||||
uint8 no_test_crashes;
|
||||
uint8 date_format;
|
||||
uint8 auto_staff_placement;
|
||||
} general_configuration;
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include "../addresses.h"
|
||||
#include "../config.h"
|
||||
#include "../game.h"
|
||||
#include "../scenario.h"
|
||||
#include "../interface/viewport.h"
|
||||
#include "../localisation/string_ids.h"
|
||||
#include "../management/finance.h"
|
||||
@@ -107,20 +109,8 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx,
|
||||
move_sprite_to_list((rct_sprite *)newPeep, SPRITE_LINKEDLIST_OFFSET_PEEP);
|
||||
|
||||
newPeep->sprite_identifier = 1;
|
||||
newPeep->sprite_height_negative = 0x0F;
|
||||
newPeep->sprite_height_positive = 5;
|
||||
newPeep->sprite_width = 8;
|
||||
newPeep->sprite_direction = 0;
|
||||
|
||||
sprite_move(_ax, *ecx, _dx, (rct_sprite*)newPeep);
|
||||
|
||||
newPeep->state = PEEP_STATE_PICKED;
|
||||
if (newPeep->x != -32768) {
|
||||
newPeep->state = 0;
|
||||
}
|
||||
|
||||
newPeep->var_45 = 0;
|
||||
newPeep->action = 0xFF;
|
||||
newPeep->action = PEEP_ACTION_NONE_2;
|
||||
newPeep->var_6D = 0;
|
||||
newPeep->action_sprite_image_offset = 0;
|
||||
newPeep->no_action_frame_no = 0;
|
||||
@@ -142,8 +132,6 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx,
|
||||
newPeep->var_C6 = 3;
|
||||
}
|
||||
|
||||
newPeep->staff_type = 0xFF;
|
||||
|
||||
uint16 idSearchSpriteIndex;
|
||||
rct_peep* idSearchPeep;
|
||||
|
||||
@@ -180,8 +168,80 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx,
|
||||
newPeep->sprite_height_negative = *((uint8*)(_edx + 1));
|
||||
newPeep->sprite_height_positive = *((uint8*)(_edx + 2));
|
||||
|
||||
sprite_move( newPeep->x, newPeep->y, newPeep->z, (rct_sprite*)newPeep);
|
||||
if ((gConfigGeneral.auto_staff_placement != 0) != ((SDL_GetModState() & KMOD_SHIFT) != 0)) {
|
||||
newPeep->state = PEEP_STATE_FALLING;
|
||||
|
||||
sint16 x, y, z;
|
||||
uint32 count = 0;
|
||||
uint16 sprite_index;
|
||||
rct_peep *guest;
|
||||
|
||||
FOR_ALL_GUESTS(sprite_index, guest)
|
||||
if (guest->state == PEEP_STATE_WALKING) ++count;
|
||||
|
||||
if (count == 0) {
|
||||
count = 0;
|
||||
uint8 i;
|
||||
for (i = 0; i < 4; ++i) {
|
||||
if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] != SPRITE_LOCATION_NULL) ++count;
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
uint32 max = ((uint32)0xFFFFFFFF) - (((uint32)0xFFFFFFFF) % count) - 1;
|
||||
if (max + count == 0) max = ((uint32)0xFFFFFFFF);
|
||||
uint32 rand;
|
||||
do {
|
||||
rand = scenario_rand();
|
||||
} while (rand > max);
|
||||
rand %= count;
|
||||
|
||||
for (i = 0; i < 4; ++i) {
|
||||
if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] != SPRITE_LOCATION_NULL) {
|
||||
if (rand == 0) break;
|
||||
--rand;
|
||||
}
|
||||
}
|
||||
|
||||
uint8 dir = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_DIRECTION, uint8)[i];
|
||||
x = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[i];
|
||||
y = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, sint16)[i];
|
||||
z = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Z, sint16)[i];
|
||||
x += 16 + ((dir & 1) == 0 ? ((dir & 2) ? 32 : -32) : 0);
|
||||
y += 16 + ((dir & 1) == 1 ? ((dir & 2) ? -32 : 32) : 0);
|
||||
} else {
|
||||
newPeep->state = PEEP_STATE_PICKED;
|
||||
x = newPeep->x;
|
||||
y = newPeep->y;
|
||||
z = newPeep->z;
|
||||
}
|
||||
} else {
|
||||
uint32 max = ((uint32)0xFFFFFFFF) - (((uint32)0xFFFFFFFF) % count) - 1;
|
||||
if (max + count == 0) max = ((uint32)0xFFFFFFFF);
|
||||
uint32 rand;
|
||||
do {
|
||||
rand = scenario_rand();
|
||||
} while (rand > max);
|
||||
rand %= count;
|
||||
|
||||
FOR_ALL_GUESTS(sprite_index, guest)
|
||||
if (guest->state == PEEP_STATE_WALKING) {
|
||||
if (rand == 0) break;
|
||||
--rand;
|
||||
}
|
||||
|
||||
x = guest->x;
|
||||
y = guest->y;
|
||||
z = guest->z;
|
||||
}
|
||||
|
||||
sprite_move(x, y, z + 16, (rct_sprite*)newPeep);
|
||||
invalidate_sprite((rct_sprite*)newPeep);
|
||||
} else {
|
||||
newPeep->state = PEEP_STATE_PICKED;
|
||||
|
||||
sprite_move(newPeep->x, newPeep->y, newPeep->z, (rct_sprite*)newPeep);
|
||||
invalidate_sprite((rct_sprite*)newPeep);
|
||||
}
|
||||
|
||||
newPeep->time_in_park = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16);
|
||||
newPeep->var_CC = 0xFFFFFFFF;
|
||||
|
||||
@@ -120,6 +120,7 @@ enum WINDOW_OPTIONS_WIDGET_IDX {
|
||||
WIDX_AUTOSAVE_DROPDOWN,
|
||||
WIDX_ALLOW_SUBTYPE_SWITCHING,
|
||||
WIDX_TEST_UNFINISHED_TRACKS,
|
||||
WIDX_AUTO_STAFF_PLACEMENT,
|
||||
WIDX_DEBUGGING_TOOLS,
|
||||
|
||||
// Twitch
|
||||
@@ -211,7 +212,8 @@ static rct_widget window_options_misc_widgets[] = {
|
||||
{ WWT_DROPDOWN_BUTTON, 1, 288, 298, 84, 93, 876, STR_NONE },
|
||||
{ WWT_CHECKBOX, 2, 10, 299, 99, 110, 5122, STR_NONE }, // allow subtype
|
||||
{ WWT_CHECKBOX, 2, 10, 299, 114, 125, 5155, 5156 }, // test unfinished tracks
|
||||
{ WWT_CHECKBOX, 2, 10, 299, 129, 140, 5150, STR_NONE }, // enabled debugging tools
|
||||
{ WWT_CHECKBOX, 2, 10, 299, 129, 140, 5343, STR_NONE }, // auto staff placement
|
||||
{ WWT_CHECKBOX, 2, 10, 299, 144, 155, 5150, STR_NONE }, // enabled debugging tools
|
||||
{ WIDGETS_END },
|
||||
};
|
||||
|
||||
@@ -355,6 +357,7 @@ static uint32 window_options_page_enabled_widgets[] = {
|
||||
(1 << WIDX_AUTOSAVE_DROPDOWN) |
|
||||
(1 << WIDX_ALLOW_SUBTYPE_SWITCHING) |
|
||||
(1 << WIDX_TEST_UNFINISHED_TRACKS) |
|
||||
(1 << WIDX_AUTO_STAFF_PLACEMENT) |
|
||||
(1 << WIDX_DEBUGGING_TOOLS),
|
||||
|
||||
MAIN_OPTIONS_ENABLED_WIDGETS |
|
||||
@@ -532,6 +535,11 @@ static void window_options_mouseup()
|
||||
config_save_default();
|
||||
window_invalidate(w);
|
||||
break;
|
||||
case WIDX_AUTO_STAFF_PLACEMENT:
|
||||
gConfigGeneral.auto_staff_placement ^= 1;
|
||||
config_save_default();
|
||||
window_invalidate(w);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1098,16 +1106,18 @@ static void window_options_invalidate()
|
||||
widget_set_checkbox_value(w, WIDX_ALLOW_SUBTYPE_SWITCHING, gConfigInterface.allow_subtype_switching);
|
||||
widget_set_checkbox_value(w, WIDX_REAL_NAME_CHECKBOX, RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_SHOW_REAL_GUEST_NAMES);
|
||||
widget_set_checkbox_value(w, WIDX_SAVE_PLUGIN_DATA_CHECKBOX, gConfigGeneral.save_plugin_data);
|
||||
widget_set_checkbox_value(w, WIDX_DEBUGGING_TOOLS, gConfigGeneral.debugging_tools);
|
||||
widget_set_checkbox_value(w, WIDX_TEST_UNFINISHED_TRACKS, gConfigGeneral.test_unfinished_tracks);
|
||||
widget_set_checkbox_value(w, WIDX_AUTO_STAFF_PLACEMENT, gConfigGeneral.auto_staff_placement);
|
||||
widget_set_checkbox_value(w, WIDX_DEBUGGING_TOOLS, gConfigGeneral.debugging_tools);
|
||||
|
||||
window_options_misc_widgets[WIDX_REAL_NAME_CHECKBOX].type = WWT_CHECKBOX;
|
||||
window_options_misc_widgets[WIDX_SAVE_PLUGIN_DATA_CHECKBOX].type = WWT_CHECKBOX;
|
||||
window_options_misc_widgets[WIDX_AUTOSAVE].type = WWT_DROPDOWN;
|
||||
window_options_misc_widgets[WIDX_AUTOSAVE_DROPDOWN].type = WWT_DROPDOWN_BUTTON;
|
||||
window_options_misc_widgets[WIDX_ALLOW_SUBTYPE_SWITCHING].type = WWT_CHECKBOX;
|
||||
window_options_misc_widgets[WIDX_DEBUGGING_TOOLS].type = WWT_CHECKBOX;
|
||||
window_options_misc_widgets[WIDX_TEST_UNFINISHED_TRACKS].type = WWT_CHECKBOX;
|
||||
window_options_misc_widgets[WIDX_AUTO_STAFF_PLACEMENT].type = WWT_CHECKBOX;
|
||||
window_options_misc_widgets[WIDX_DEBUGGING_TOOLS].type = WWT_CHECKBOX;
|
||||
break;
|
||||
|
||||
case WINDOW_OPTIONS_PAGE_TWITCH:
|
||||
|
||||
Reference in New Issue
Block a user