Merge pull request #570 from duncanspumpkin/peep_update

Peep update
This commit is contained in:
Ted John 2014-11-18 13:26:53 +00:00
commit af1cd86a35
8 changed files with 570 additions and 140 deletions

View File

@ -274,7 +274,7 @@ int viewport_interaction_get_item_right(int x, int y, viewport_interaction_info
return info->type;
case VIEWPORT_INTERACTION_ITEM_FOOTPATH_ITEM:
sceneryEntry = g_pathBitSceneryEntries[mapElement->properties.scenery.age & 0x0F];
sceneryEntry = RCT2_ADDRESS(0x9ADA50, rct_scenery_entry*)[mapElement->properties.path.additions & 0x0F];
RCT2_GLOBAL(RCT2_ADDRESS_MAP_TOOLTIP_ARGS + 0, uint16) = 1164;
if (mapElement->flags & 0x20) {
RCT2_GLOBAL(RCT2_ADDRESS_MAP_TOOLTIP_ARGS + 2, uint16) = 3124;

View File

@ -30,6 +30,7 @@
#include "../scenario.h"
#include "../sprites.h"
#include "../world/sprite.h"
#include "../world/scenery.h"
#include "peep.h"
#include "staff.h"
@ -107,28 +108,87 @@ void peep_update_all()
}
}
/* rct2: 0x6939EB */
int sub_6939EB(sint16* x, sint16* y, rct_peep* peep){
RCT2_GLOBAL(0xF1AEF0, uint8) = peep->var_70;
if (peep->var_71 == 0xFE){
peep->var_71 = 0xFF;
/* some sort of check to see if peep is connected to the ground?? */
int sub_68F3AE(rct_peep* peep){
peep->var_C4++;
if ((peep->var_C4 & 0xF) != (peep->sprite_index & 0xF))return 1;
uint16 ebx = (peep->next_x | (peep->next_y << 8)) >> 5;
rct_map_element* map_element = TILE_MAP_ELEMENT_POINTER(ebx);
uint8 map_type = MAP_ELEMENT_TYPE_PATH;
if ((peep->next_z >> 8) & ((1 << 4) | (1 << 3))){
map_type = MAP_ELEMENT_TYPE_SURFACE;
}
*x = peep->x - peep->var_32;
*y = peep->y - peep->var_34;
int ebx = *x;
int edx = *y;
if (ebx < 0) ebx = -ebx;
if (edx < 0) edx = -edx;
int z = peep->next_z & 0xFF;
int ebp = ebx + edx;
if (peep->var_71 >= 0xFE){
if (ebp <= peep->var_36){
for (;; map_element++){
if ((map_element->type & MAP_ELEMENT_TYPE_MASK) == map_type){
if (z == map_element->base_height)return 1;
}
if (map_element->flags & MAP_ELEMENT_FLAG_LAST_TILE)break;
}
peep_decrement_num_riders(peep);
peep->state = PEEP_STATE_FALLING;
peep_window_state_update(peep);
return 0;
}
void sub_693B58(rct_peep* peep){
int ebx;
if (peep->action >= 0xFE){
ebx = RCT2_ADDRESS(0x981D8C, uint8)[peep->var_6D];
}
else{
ebx = RCT2_ADDRESS(0x981D8F, uint8)[peep->action];
}
if (ebx == peep->var_6E)return;
invalidate_sprite((rct_sprite*)peep);
peep->var_6E = ebx;
uint8* edx = RCT2_ADDRESS(0x98270C, uint8*)[peep->sprite_type * 2];
peep->var_14 = edx[ebx * 4];
peep->var_09 = edx[ebx * 4 + 1];
peep->var_15 = edx[ebx * 4 + 2];
// This is pointless as nothing will have changed.
invalidate_sprite((rct_sprite*)peep);
}
static void peep_state_reset(rct_peep* peep){
peep_decrement_num_riders(peep);
peep->state = PEEP_STATE_1;
peep_window_state_update(peep);
RCT2_CALLPROC_X(0x00693BE5, 0, 0, 0, 0, (int)peep, 0, 0);
}
/* rct2: 0x6939EB
* Possibly peep update action frame.
* Also used to move peeps to the correct position to
* start an action. Returns 0 if the correct destination
* has not yet been reached.
*/
int sub_6939EB(sint16* x, sint16* y, rct_peep* peep){
RCT2_GLOBAL(0xF1AEF0, uint8) = peep->var_70;
if (peep->action == 0xFE){
peep->action = 0xFF;
}
*x = peep->x - peep->destination_x;
*y = peep->y - peep->destination_y;
int x_delta = abs(*x);
int y_delta = abs(*y);
if (peep->action >= 0xFE){
if (x_delta + y_delta <= peep->destination_tolerence){
return 0;
}
int direction = 0;
if (ebx < edx){
if (x_delta < y_delta){
direction = 8;
if (*y >= 0){
direction = 24;
@ -143,7 +203,7 @@ int sub_6939EB(sint16* x, sint16* y, rct_peep* peep){
peep->sprite_direction = direction;
*x = peep->x + RCT2_ADDRESS(0x981D7C, uint16)[direction / 4];
*y = peep->y + RCT2_ADDRESS(0x981D7E, uint16)[direction / 4];
ebx = peep->var_E0 + 1;
int ebx = peep->var_E0 + 1;
uint32* edi = RCT2_ADDRESS(0x982708, uint32*)[peep->sprite_type * 2];
uint8* _edi = (uint8*)(edi[peep->var_6E * 2 + 1]);
if (ebx >= *_edi){
@ -156,26 +216,30 @@ int sub_6939EB(sint16* x, sint16* y, rct_peep* peep){
int* edi = RCT2_ADDRESS(0x982708, uint32*)[peep->sprite_type * 2];
uint8* _edi = (uint8*)(edi[peep->var_6E * 2 + 1]);
peep->var_72++;
ebx = _edi[peep->var_72 + 1];
peep->action_frame++;
int ebx = _edi[peep->action_frame + 1];
// If last frame of action
if (ebx == 0xFF){
peep->var_70 = 0;
peep->var_71 = 0xFF;
RCT2_CALLPROC_X(0x693B58, 0, 0, 0, 0, (int)peep, 0, 0);
peep->action = 0xFF;
sub_693B58(peep);
invalidate_sprite((rct_sprite*)peep);
*x = peep->x;
*y = peep->y;
return 1;
}
peep->var_70 = ebx;
if (peep->var_71 != PEEP_ACTION_THROW_UP || peep->var_72 != 15){
// If not throwing up and not at the frame where sick appears.
if (peep->action != PEEP_ACTION_THROW_UP || peep->action_frame != 15){
invalidate_sprite((rct_sprite*)peep);
*x = peep->x;
*y = peep->y;
return 1;
}
// We are throwing up
peep->hunger /= 2;
peep->nausea_growth_rate /= 2;
@ -186,9 +250,10 @@ int sub_6939EB(sint16* x, sint16* y, rct_peep* peep){
peep->var_45 |= (1 << 2);
// Create sick at location
RCT2_CALLPROC_X(0x67375D, peep->x, peep->sprite_direction, peep->y, peep->z, 0, 0, peep->sprite_index & 1);
int sound_id = scenario_rand() & 3 + 24;
int sound_id = (scenario_rand() & 3) + 24;
sound_play_panned(sound_id, 0x8001, peep->x, peep->y, peep->z);
@ -264,12 +329,12 @@ void peep_remove(rct_peep* peep){
* Falling and its subset drowning
*/
void peep_update_falling(rct_peep* peep){
if (peep->var_71 == PEEP_ACTION_DROWNING){
if (peep->action == PEEP_ACTION_DROWNING){
// Check to see if we are ready to drown.
sint16 x, y;
sub_6939EB(&x, &y, peep);
//RCT2_CALLPROC_X(0x6939EB, 0, 0, 0, 0, (int)peep, 0, 0);
if (peep->var_71 == PEEP_ACTION_DROWNING) return;
if (peep->action == PEEP_ACTION_DROWNING) return;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x80000)){
RCT2_GLOBAL(0x13CE952, uint16) = peep->name_string_idx;
RCT2_GLOBAL(0x13CE954, uint32) = peep->id;
@ -325,11 +390,11 @@ void peep_update_falling(rct_peep* peep){
peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_DROWNING, -1);
peep->var_71 = PEEP_ACTION_DROWNING;
peep->var_72 = 0;
peep->action = PEEP_ACTION_DROWNING;
peep->action_frame = 0;
peep->var_70 = 0;
RCT2_CALLPROC_X(0x693B58, 0, 0, 0, 0, (int)peep, 0, 0);
sub_693B58(peep);
invalidate_sprite((rct_sprite*)peep);
peep_window_state_update(peep);
return;
@ -388,12 +453,11 @@ void peep_try_get_up_from_sitting(rct_peep* peep){
peep->state = PEEP_STATE_WALKING;
peep_window_state_update(peep);
int x = (peep->x & 0xFFE0) + 16;
int y = (peep->y & 0xFFE0) + 16;
peep->var_32 = x;
peep->var_34 = y;
peep->var_36 = 5;
RCT2_CALLPROC_X(0x693B58, 0, 0, 0, 0, (int)peep, 0, 0);
// Set destination to the center of the tile.
peep->destination_x = (peep->x & 0xFFE0) + 16;
peep->destination_y = (peep->y & 0xFFE0) + 16;
peep->destination_tolerence = 5;
sub_693B58(peep);
}
/**
@ -401,7 +465,7 @@ void peep_try_get_up_from_sitting(rct_peep* peep){
*/
void peep_update_sitting(rct_peep* peep){
if (peep->var_2C == 0){
if (RCT2_CALLPROC_X(0x68F3AE, 0, 0, 0, 0, (int)peep, 0, 0) & 0x4000)return;
if (!sub_68F3AE(peep))return;
//691541
RCT2_CALLPROC_X(0x693C9E, 0, 0, 0, 0, (int)peep, 0, 0);
@ -417,7 +481,7 @@ void peep_update_sitting(rct_peep* peep){
peep->sprite_direction = ((peep->var_37 + 2) & 3) * 8;
invalidate_sprite((rct_sprite*)peep);
peep->var_71 = 254;
peep->action = 254;
peep->var_6F = 7;
RCT2_CALLPROC_X(0x693BAB, 0, 0, 0, 0, (int)peep, 0, 0);
@ -427,13 +491,13 @@ void peep_update_sitting(rct_peep* peep){
peep->time_to_sitdown = (129 - peep->energy) * 16 + 50;
}
else if (peep->var_2C == 1){
if (peep->var_71 < 0xFE){
if (peep->action < 0xFE){
sint16 x, y;
sub_6939EB(&x, &y, peep);
//RCT2_CALLPROC_X(0x6939EB, 0, 0, 0, 0, (int)peep, 0, 0);
if (peep->var_71 != 0xFF) return;
if (peep->action != 0xFF) return;
peep->var_71 = 0xFE;
peep->action = 0xFE;
peep_try_get_up_from_sitting(peep);
return;
}
@ -443,12 +507,11 @@ void peep_update_sitting(rct_peep* peep){
peep->state = PEEP_STATE_WALKING;
peep_window_state_update(peep);
int x = (peep->x & 0xFFE0) + 16;
int y = (peep->y & 0xFFE0) + 16;
peep->var_32 = x;
peep->var_34 = y;
peep->var_36 = 5;
RCT2_CALLPROC_X(0x693B58, 0, 0, 0, 0, (int)peep, 0, 0);
// Set destination to the center of the tile
peep->destination_x = (peep->x & 0xFFE0) + 16;
peep->destination_y = (peep->y & 0xFFE0) + 16;
peep->destination_tolerence = 5;
sub_693B58(peep);
return;
}
@ -462,10 +525,10 @@ void peep_update_sitting(rct_peep* peep){
peep_try_get_up_from_sitting(peep);
return;
}
peep->var_71 = PEEP_ACTION_SITTING_EAT_FOOD;
peep->var_72 = 0;
peep->action = PEEP_ACTION_SITTING_EAT_FOOD;
peep->action_frame = 0;
peep->var_70 = 0;
RCT2_CALLPROC_X(0x693B58, 0, 0, 0, 0, (int)peep, 0, 0);
sub_693B58(peep);
invalidate_sprite((rct_sprite*)peep);
return;
}
@ -480,28 +543,34 @@ void peep_update_sitting(rct_peep* peep){
return;
}
peep->var_71 = PEEP_ACTION_SITTING_LOOK_AROUND_LEFT;
peep->action = PEEP_ACTION_SITTING_LOOK_AROUND_LEFT;
if (rand & 0x80000000){
peep->var_71 = PEEP_ACTION_SITTING_LOOK_AROUND_RIGHT;
peep->action = PEEP_ACTION_SITTING_LOOK_AROUND_RIGHT;
}
if (rand & 0x40000000){
peep->var_71 = PEEP_ACTION_SITTING_CHECK_WATCH;
peep->action = PEEP_ACTION_SITTING_CHECK_WATCH;
}
peep->var_72 = 0;
peep->action_frame = 0;
peep->var_70 = 0;
RCT2_CALLPROC_X(0x693B58, 0, 0, 0, 0, (int)peep, 0, 0);
sub_693B58(peep);
invalidate_sprite((rct_sprite*)peep);
return;
}
}
/* rct2: 0x691A30
* Also used by entering_ride and queueing_front */
static void peep_update_leaving_ride(rct_peep* peep){
RCT2_CALLPROC_X(RCT2_ADDRESS(0x9820DC, int)[peep->var_2C], 0, 0, 0, 0, (int)peep, 0, 0);
}
/**
* rct2: 0x69185D
*/
void peep_update_queuing(rct_peep* peep){
if (RCT2_CALLPROC_X(0x68F3AE, 0, 0, 0, 0, (int)peep, 0, 0) & 0x4000){
RCT2_CALLPROC_X(0x691A23, 0, 0, 0, 0, (int)peep, 0, 0);
static void peep_update_queuing(rct_peep* peep){
if (!sub_68F3AE(peep)){
RCT2_CALLPROC_X(0x6966A9, 0, 0, 0, 0, (int)peep, 0, 0);
return;
}
rct_ride* ride = GET_RIDE(peep->current_ride);
@ -516,7 +585,7 @@ void peep_update_queuing(rct_peep* peep){
if (peep->var_2C != 0xA){
if (peep->var_74 == 0xFFFF){
//Happens every time peep goes onto ride.
peep->var_36 = 0;
peep->destination_tolerence = 0;
peep_decrement_num_riders(peep);
peep->state = PEEP_STATE_QUEUING_FRONT;
peep_window_state_update(peep);
@ -533,14 +602,14 @@ void peep_update_queuing(rct_peep* peep){
}
RCT2_CALLPROC_X(0x693C9E, 0, 0, 0, 0, (int)peep, 0, 0);
if (peep->var_71 < 0xFE)return;
if (peep->action < 0xFE)return;
if (peep->sprite_type == 0){
if (peep->var_7A >= 2000 && (0xFFFF & scenario_rand()) <= 119){
// Look at watch
peep->var_71 = PEEP_ACTION_CHECK_WATCH;
peep->var_72 = 0;
peep->action = PEEP_ACTION_CHECK_WATCH;
peep->action_frame = 0;
peep->var_70 = 0;
RCT2_CALLPROC_X(0x693B58, 0, 0, 0, 0, (int)peep, 0, 0);
sub_693B58(peep);
invalidate_sprite((rct_sprite*)peep);
}
if (peep->var_7A >= 3500 && (0xFFFF & scenario_rand()) <= 93)
@ -550,7 +619,7 @@ void peep_update_queuing(rct_peep* peep){
}
}
else{
if (!(peep->var_7A & 0x3F) && peep->var_71 == 0xFE && peep->var_6F == 2){
if (!(peep->var_7A & 0x3F) && peep->action == 0xFE && peep->var_6F == 2){
switch (peep->sprite_type){
case 0xF:
case 0x10:
@ -575,10 +644,10 @@ void peep_update_queuing(rct_peep* peep){
case 0x2E:
case 0x2F:
// Look at watch
peep->var_71 = PEEP_ACTION_CHECK_WATCH;
peep->var_72 = 0;
peep->action = PEEP_ACTION_CHECK_WATCH;
peep->action_frame = 0;
peep->var_70 = 0;
RCT2_CALLPROC_X(0x693B58, 0, 0, 0, 0, (int)peep, 0, 0);
sub_693B58(peep);
invalidate_sprite((rct_sprite*)peep);
break;
}
@ -597,6 +666,227 @@ void peep_update_queuing(rct_peep* peep){
}
}
/* rct2: 0x006BF567 */
static void peep_update_mowing(rct_peep* peep){
peep->var_E2 = 0;
if (!sub_68F3AE(peep))return;
invalidate_sprite((rct_sprite*)peep);
while (1){
sint16 x = 0, y = 0;
if (sub_6939EB(&x, &y, peep)){
int eax = x, ebx, ecx = y, z, ebp, edi;
RCT2_CALLFUNC_X(0x662783, &eax, &ebx, &ecx, &z, (int*)&peep, &edi, &ebp);
x = eax;
y = ecx;
sprite_move(x, y, z, (rct_sprite*)peep);
invalidate_sprite((rct_sprite*)peep);
return;
}
peep->var_37++;
if (peep->var_37 == 1){
RCT2_CALLPROC_X(0x00693BE5, 2, 0, 0, 0, (int)peep, 0, 0);
}
if (RCT2_ADDRESS(0x9929C8, uint16)[peep->var_37 * 2] == 0xFFFF){
peep_state_reset(peep);
return;
}
peep->destination_x = RCT2_ADDRESS(0x9929C8, uint16)[peep->var_37 * 2] + peep->next_x;
peep->destination_y = RCT2_ADDRESS(0x9929CA, uint16)[peep->var_37 * 2] + peep->next_y;
if (peep->var_37 != 7)continue;
rct_map_element* map_element = TILE_MAP_ELEMENT_POINTER((peep->next_x | (peep->next_y << 8)) >> 5);
for (; ((map_element->type & MAP_ELEMENT_TYPE_MASK) != MAP_ELEMENT_TYPE_SURFACE); map_element++);
if ((map_element->properties.surface.terrain & MAP_ELEMENT_SURFACE_TERRAIN_MASK) == (TERRAIN_GRASS << 5)){
map_element->properties.surface.grass_length = 0;
gfx_invalidate_scrollingtext(peep->next_x, peep->next_y, map_element->base_height * 8, map_element->base_height * 8 + 16);
}
peep->staff_lawns_mown++;
peep->var_45 |= (1 << 5);
}
}
/* rct2: 0x006BF7E6 */
static void peep_update_watering(rct_peep* peep){
peep->var_E2 = 0;
if (peep->var_2C == 0){
if (!sub_68F3AE(peep))return;
RCT2_CALLPROC_X(0x693C9E, 0, 0, 0, 0, (int)peep, 0, 0);
if (!(RCT2_GLOBAL(0xF1EE18, uint16) & 1))return;
peep->sprite_direction = (peep->var_37 & 3) << 3;
peep->action = PEEP_ACTION_STAFF_WATERING;
peep->action_frame = 0;
peep->var_70 = 0;
sub_693B58(peep);
invalidate_sprite((rct_sprite*)peep);
peep->var_2C = 1;
}
else if (peep->var_2C == 1){
if (peep->action != PEEP_ACTION_NONE_2){
sint16 x, y;
sub_6939EB(&x, &y, peep);
return;
}
int x = peep->next_x + RCT2_ADDRESS(0x993CCC, sint16)[peep->var_37 * 2];
int y = peep->next_y + RCT2_ADDRESS(0x993CCE, sint16)[peep->var_37 * 2];
rct_map_element* map_element = TILE_MAP_ELEMENT_POINTER((x | (y << 8)) >> 5);
for (;; map_element++){
if ((map_element->type & MAP_ELEMENT_TYPE_MASK) == MAP_ELEMENT_TYPE_SCENERY){
if (abs((peep->next_z & 0xFF) - map_element->base_height) <= 4){
rct_scenery_entry* scenery_entry = g_smallSceneryEntries[map_element->properties.scenery.type];
if (scenery_entry->small_scenery.flags& SMALL_SCENERY_FLAG6){
map_element->properties.scenery.age = 0;
gfx_invalidate_scrollingtext(x, y, map_element->base_height * 8, map_element->clearance_height * 8);
peep->staff_gardens_watered++;
peep->var_45 |= (1 << 4);
}
}
}
if (map_element->flags&MAP_ELEMENT_FLAG_LAST_TILE){
peep_state_reset(peep);
return;
}
}
}
}
/* rct2: 0x006BF6C9 */
static void peep_update_emptying_bin(rct_peep* peep){
peep->var_E2 = 0;
if (peep->var_2C == 0){
if (!sub_68F3AE(peep))return;
RCT2_CALLPROC_X(0x693C9E, 0, 0, 0, 0, (int)peep, 0, 0);
if (!(RCT2_GLOBAL(0xF1EE18, uint16) & 1))return;
peep->sprite_direction = (peep->var_37 & 3) << 3;
peep->action = PEEP_ACTION_STAFF_EMPTY_BIN;
peep->action_frame = 0;
peep->var_70 = 0;
sub_693B58(peep);
invalidate_sprite((rct_sprite*)peep);
peep->var_2C = 1;
}
else if (peep->var_2C == 1){
if (peep->action == PEEP_ACTION_NONE_2){
peep_state_reset(peep);
return;
}
sint16 x = 0, y = 0;
sub_6939EB(&x, &y, peep);
if (peep->action_frame != 11)return;
rct_map_element* map_element = TILE_MAP_ELEMENT_POINTER((peep->next_x | (peep->next_y << 8)) >> 5);
for (;; map_element++){
if ((map_element->type & MAP_ELEMENT_TYPE_MASK) == MAP_ELEMENT_TYPE_PATH){
if ((peep->next_z & 0xFF) == map_element->base_height)break;
}
if (map_element->flags&MAP_ELEMENT_FLAG_LAST_TILE){
peep_state_reset(peep);
return;
}
}
if ((map_element->properties.path.additions & 0xF) == 0){
peep_state_reset(peep);
return;
}
rct_scenery_entry* scenery_entry = g_pathBitSceneryEntries[(map_element->properties.path.additions & 0xF) - 1];
if (!(scenery_entry->small_scenery.flags & SMALL_SCENERY_FLAG1)
|| map_element->flags&(1 << 5)
|| map_element->properties.path.additions & (1 << 7)){
peep_state_reset(peep);
return;
}
map_element->properties.path.addition_status = ((3 << peep->var_37) << peep->var_37);
gfx_invalidate_scrollingtext(peep->next_x, peep->next_y, map_element->base_height * 8, map_element->clearance_height * 8);
peep->staff_bins_emptied++;
peep->var_45 |= (1 << 4);
}
}
/* rct2: 0x6BF641 */
static void peep_update_sweeping(rct_peep* peep){
peep->var_E2 = 0;
if (!sub_68F3AE(peep))return;
invalidate_sprite((rct_sprite*)peep);
if (peep->action == PEEP_ACTION_STAFF_SWEEP && peep->action_frame == 8){
//Remove sick at this location
RCT2_CALLPROC_X(0x6738E1, peep->x, 0, peep->y, peep->z, 0, 0, 0);
peep->staff_litter_swept++;
peep->var_45 |= (1 << 4);
}
sint16 x = 0, y = 0;
if (sub_6939EB(&x, &y, peep)){
int eax = x, ebx, ecx = y, z, ebp, edi;
RCT2_CALLFUNC_X(0x694921, &eax, &ebx, &ecx, &z, (int*)&peep, &edi, &ebp);
x = eax;
y = ecx;
sprite_move(x, y, z, (rct_sprite*)peep);
invalidate_sprite((rct_sprite*)peep);
return;
}
peep->var_37++;
if (peep->var_37 != 2){
peep->action = PEEP_ACTION_STAFF_SWEEP;
peep->action_frame = 0;
peep->var_70 = 0;
sub_693B58(peep);
invalidate_sprite((rct_sprite*)peep);
return;
}
peep_state_reset(peep);
}
/* rct2: 0x6902A2 */
static void peep_update_1(rct_peep* peep){
if (!sub_68F3AE(peep))return;
peep_decrement_num_riders(peep);
if (peep->type == PEEP_TYPE_GUEST){
peep->state = PEEP_STATE_WALKING;
}
else{
peep->state = PEEP_STATE_PATROLLING;
}
peep_window_state_update(peep);
peep->destination_x = peep->x;
peep->destination_y = peep->y;
peep->destination_tolerence = 10;
peep->var_76 = 0;
peep->var_78 = peep->sprite_direction >> 3;
}
/**
* rct2: 0x690009
*/
@ -608,6 +898,120 @@ static void peep_update_picked(rct_peep* peep){
}
}
/* rct2: 0x6914CD */
static void peep_update_leaving_park(rct_peep* peep){
if (peep->var_37 != 0){
RCT2_CALLPROC_X(0x693C9E, 0, 0, 0, 0, (int)peep, 0, 0);
if (!(RCT2_GLOBAL(0xF1EE18, uint16) & 2))return;
RCT2_CALLPROC_X(0x69A535, 0, 0, 0, 0, (int)peep, 0, 0);
return;
}
sint16 x = 0, y = 0;
if (sub_6939EB(&x, &y, peep)){
invalidate_sprite((rct_sprite*)peep);
sprite_move(x, y, peep->z, (rct_sprite*)peep);
invalidate_sprite((rct_sprite*)peep);
return;
}
peep->var_2A = 1;
peep->destination_tolerence = 5;
RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16)--;
RCT2_GLOBAL(0x9A9804, uint16) |= (1 << 0);
peep->var_37 = 1;
window_invalidate_by_class(WC_GUEST_LIST);
RCT2_CALLPROC_X(0x693C9E, 0, 0, 0, 0, (int)peep, 0, 0);
if (!(RCT2_GLOBAL(0xF1EE18, uint16) & 2))return;
RCT2_CALLPROC_X(0x69A535, 0, 0, 0, 0, (int)peep, 0, 0);
}
/* rct2: 0x6916D6 */
static void peep_update_watching(rct_peep* peep){
if (peep->var_2C == 0){
if (!sub_68F3AE(peep))return;
RCT2_CALLPROC_X(0x693C9E, 0, 0, 0, 0, (int)peep, 0, 0);
if (!(RCT2_GLOBAL(0xF1EE18, uint16) & 1))return;
peep->destination_x = peep->x;
peep->destination_y = peep->y;
peep->sprite_direction = (peep->var_37 & 3) * 8;
invalidate_sprite((rct_sprite*)peep);
peep->action = 0xFE;
peep->var_6F = 2;
RCT2_CALLPROC_X(0x693BAB, 0, 0, 0, 0, (int)peep, 0, 0);
peep->var_2C++;
peep->time_to_stand = clamp(0, ((129 - peep->energy) * 16 + 50) / 2, 255);
RCT2_CALLPROC_X(0x0069B8CC, 0, 0, 0, 0, (int)peep, 0, 0);
}
else if (peep->var_2C == 1){
if (peep->action < 0xFE){
//6917F6
sint16 x = 0, y = 0;
sub_6939EB(&x, &y, peep);
if (peep->action != 0xFF)return;
peep->action = 0xFE;
}
else{
if (peep_has_food(peep)){
if ((scenario_rand() & 0xFFFF) <= 1310){
peep->action = PEEP_ACTION_CHECK_WATCH;
peep->action_frame = 0;
peep->var_70 = 0;
sub_693B58(peep);
invalidate_sprite((rct_sprite*)peep);
return;
}
}
if ((scenario_rand() & 0xFFFF) <= 655){
peep->action = PEEP_ACTION_TAKE_PHOTO;
peep->action_frame = 0;
peep->var_70 = 0;
sub_693B58(peep);
invalidate_sprite((rct_sprite*)peep);
return;
}
if ((peep->standing_flags & 1)){
if ((scenario_rand() & 0xFFFF) <= 655){
peep->action = PEEP_ACTION_WAVE;
peep->action_frame = 0;
peep->var_70 = 0;
sub_693B58(peep);
invalidate_sprite((rct_sprite*)peep);
return;
}
}
}
peep->standing_flags ^= (1 << 7);
if (!(peep->standing_flags & (1 << 7)))return;
peep->time_to_stand--;
if (peep->time_to_stand != 0)return;
peep_decrement_num_riders(peep);
peep->state = PEEP_STATE_WALKING;
peep_window_state_update(peep);
RCT2_CALLPROC_X(0x0069B8CC, 0, 0, 0, 0, (int)peep, 0, 0);
// Send peep to the center of current tile.
peep->destination_x = (peep->x & 0xFFE0) + 16;
peep->destination_y = (peep->y & 0xFFE0) + 16;
peep->destination_tolerence = 5;
sub_693B58(peep);
}
}
/**
* rct2: 0x691451
*/
@ -639,6 +1043,55 @@ static void peep_update_entering_park(rct_peep* peep){
window_invalidate_by_class(WC_GUEST_LIST);
}
/* From peep_update */
static void peep_update_thoughts(rct_peep* peep){
// Thoughts must always have a gap of at least
// 220 ticks in age between them. In order to
// allow this when a thought is new it enters
// a holding zone. Before it becomes fresh.
int add_fresh = 1;
int fresh_thought = -1;
for (int i = 0; i < PEEP_MAX_THOUGHTS; i++) {
if (peep->thoughts[i].type == PEEP_THOUGHT_TYPE_NONE)
break;
if (peep->thoughts[i].var_2 == 1) {
add_fresh = 0;
// If thought is fresh we wait 220 ticks
// before allowing a new thought to become fresh.
if (++peep->thoughts[i].var_3 >= 220) {
peep->thoughts[i].var_3 = 0;
// Thought is no longer fresh
peep->thoughts[i].var_2++;
add_fresh = 1;
}
}
else if (peep->thoughts[i].var_2 > 1) {
if (++peep->thoughts[i].var_3 == 0) {
// When thought is older than ~6900 ticks remove it
if (++peep->thoughts[i].var_2 >= 28) {
peep->var_45 |= 1;
// Clear top thought, push others up
memmove(&peep->thoughts[i], &peep->thoughts[i + 1], sizeof(rct_peep_thought)*(PEEP_MAX_THOUGHTS - i - 1));
peep->thoughts[PEEP_MAX_THOUGHTS - 1].type = PEEP_THOUGHT_TYPE_NONE;
}
}
}
else {
fresh_thought = i;
}
}
// If there are no fresh thoughts
// a previously new thought can become
// fresh.
if (add_fresh && fresh_thought != -1) {
peep->thoughts[fresh_thought].var_2 = 1;
peep->var_45 |= 1;
}
}
/**
*
* rct2: 0x0068FC1E
@ -647,47 +1100,13 @@ static void peep_update(rct_peep *peep)
{
//RCT2_CALLPROC_X(0x0068FC1E, 0, 0, 0, 0, (int)peep, 0, 0); return;
//return;
int i, j;
if (peep->type == PEEP_TYPE_GUEST) {
if (peep->var_AD != 255)
if (++peep->var_AE < 720)
peep->var_AD = 255;
// Update thoughts
i = 0;
int ebp = 0;
int edi = -1;
for (i = 0; i < PEEP_MAX_THOUGHTS; i++) {
if (peep->thoughts[i].type == PEEP_THOUGHT_TYPE_NONE)
break;
if (peep->thoughts[i].var_2 == 1) {
ebp++;
if (++peep->thoughts[i].var_3 >= 220) {
peep->thoughts[i].var_3 = 0;
peep->thoughts[i].var_2++;
ebp--;
}
} else if (peep->thoughts[i].var_2 > 1) {
if (++peep->thoughts[i].var_3 > 255) {
if (++peep->thoughts[i].var_3 >= 28) {
peep->var_45 |= 1;
// Clear top thought, push others up
for (j = i; j < PEEP_MAX_THOUGHTS - 1; j++)
peep->thoughts[j].type = peep->thoughts[j + 1].type;
peep->thoughts[PEEP_MAX_THOUGHTS - 1].type = PEEP_THOUGHT_TYPE_NONE;
}
}
} else {
edi = i;
}
}
if (ebp == 0 && edi != -1) {
peep->thoughts[edi].var_2 = 1;
peep->var_45 |= 1;
}
peep_update_thoughts(peep);
}
// Walking speed logic
@ -696,7 +1115,7 @@ static void peep_update(rct_peep *peep)
stepsToTake = 95;
if ((peep->flags & PEEP_FLAGS_SLOW_WALK) && peep->state != PEEP_STATE_QUEUING)
stepsToTake /= 2;
if (peep->var_71 == 255 && (RCT2_GLOBAL((int)peep + 0x29, uint8) & 4)) {
if (peep->action == 255 && ((peep->next_z >> 8) & 4)) {
stepsToTake /= 2;
if (peep->state == PEEP_STATE_QUEUING)
stepsToTake += stepsToTake / 2;
@ -716,16 +1135,16 @@ static void peep_update(rct_peep *peep)
peep_update_falling(peep);
break;
case PEEP_STATE_1:
RCT2_CALLPROC_X(0x006902A2, 0, 0, 0, 0, (int)peep, 0, 0);
peep_update_1(peep);
break;
case PEEP_STATE_QUEUING_FRONT:
RCT2_CALLPROC_X(0x00691A24, 0, 0, 0, 0, (int)peep, 0, 0);
peep_update_leaving_ride(peep);
break;
case PEEP_STATE_ON_RIDE:
// No action
break;
case PEEP_STATE_LEAVING_RIDE:
RCT2_CALLPROC_X(0x00691A30, 0, 0, 0, 0, (int)peep, 0, 0);
peep_update_leaving_ride(peep);
break;
case PEEP_STATE_WALKING:
RCT2_CALLPROC_X(0x0069030A, 0, 0, 0, 0, (int)peep, 0, 0);
@ -734,7 +1153,8 @@ static void peep_update(rct_peep *peep)
peep_update_queuing(peep);
break;
case PEEP_STATE_ENTERING_RIDE:
RCT2_CALLPROC_X(0x00691A24, 0, 0, 0, 0, (int)peep, 0, 0);
// Calls the same function as leaving ride
peep_update_leaving_ride(peep);
break;
case PEEP_STATE_SITTING:
peep_update_sitting(peep);
@ -746,17 +1166,16 @@ static void peep_update(rct_peep *peep)
RCT2_CALLPROC_X(0x006BF1FD, 0, 0, 0, 0, (int)peep, 0, 0);
break;
case PEEP_STATE_MOWING:
RCT2_CALLPROC_X(0x006BF567, 0, 0, 0, 0, (int)peep, 0, 0);
peep_update_mowing(peep);
break;
case PEEP_STATE_SWEEPING:
RCT2_CALLPROC_X(0x006BF641, 0, 0, 0, 0, (int)peep, 0, 0);
peep_update_sweeping(peep);
break;
case PEEP_STATE_ENTERING_PARK:
peep_update_entering_park(peep);
//RCT2_CALLPROC_X(0x00691451, 0, 0, 0, 0, (int)peep, 0, 0);
break;
case PEEP_STATE_LEAVING_PARK:
RCT2_CALLPROC_X(0x006914CD, 0, 0, 0, 0, (int)peep, 0, 0);
peep_update_leaving_park(peep);
break;
case PEEP_STATE_ANSWERING:
RCT2_CALLPROC_X(0x006C0CB8, 0, 0, 0, 0, (int)peep, 0, 0);
@ -768,16 +1187,16 @@ static void peep_update(rct_peep *peep)
RCT2_CALLPROC_X(0x006912A3, 0, 0, 0, 0, (int)peep, 0, 0);
break;
case PEEP_STATE_WATCHING:
RCT2_CALLPROC_X(0x006916D6, 0, 0, 0, 0, (int)peep, 0, 0);
peep_update_watching(peep);
break;
case PEEP_STATE_EMPTYING_BIN:
RCT2_CALLPROC_X(0x006BF6C9, 0, 0, 0, 0, (int)peep, 0, 0);
peep_update_emptying_bin(peep);
break;
case PEEP_STATE_20:
RCT2_CALLPROC_X(0x00691089, 0, 0, 0, 0, (int)peep, 0, 0);
break;
case PEEP_STATE_WATERING:
RCT2_CALLPROC_X(0x006BF7E6, 0, 0, 0, 0, (int)peep, 0, 0);
peep_update_watering(peep);
break;
case PEEP_STATE_HEADING_TO_INSPECTION:
RCT2_CALLPROC_X(0x006C16D7, 0, 0, 0, 0, (int)peep, 0, 0);
@ -1045,11 +1464,11 @@ void peep_applause()
}
// Clap
if ((peep->state == PEEP_STATE_WALKING || peep->state == PEEP_STATE_QUEUING) && peep->var_71 >= 254) {
peep->var_71 = PEEP_ACTION_CLAP;
peep->var_72 = 0;
if ((peep->state == PEEP_STATE_WALKING || peep->state == PEEP_STATE_QUEUING) && peep->action >= 254) {
peep->action = PEEP_ACTION_CLAP;
peep->action_frame = 0;
peep->var_70 = 0;
RCT2_CALLPROC_X(0x00693B58, 0, 0, 0, 0, (int)peep, 0, 0);
sub_693B58(peep);
invalidate_sprite((rct_sprite*)peep);
}
}
@ -1084,7 +1503,7 @@ void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argum
switch (peep->state){
case PEEP_STATE_FALLING:
*argument_1 = peep->var_71 == PEEP_ACTION_DROWNING ? STR_DROWNING : STR_WALKING;
*argument_1 = peep->action == PEEP_ACTION_DROWNING ? STR_DROWNING : STR_WALKING;
*argument_2 = 0;
break;
case PEEP_STATE_1:
@ -1427,13 +1846,13 @@ int peep_has_food(rct_peep* peep){
* esi: peep
*/
void peep_insert_new_thought(rct_peep *peep, uint8 thought_type, uint8 thought_arguments){
int var_71 = RCT2_ADDRESS(0x981DB0, uint16)[thought_type];
int action = RCT2_ADDRESS(0x981DB0, uint16)[thought_type];
if (var_71 != 0xFF && peep->var_71 >= 254){
peep->var_71 = var_71;
peep->var_72 = 0;
if (action != 0xFF && peep->action >= 254){
peep->action = action;
peep->action_frame = 0;
peep->var_70 = 0;
RCT2_CALLPROC_X(0x693B58, 0, 0, 0, 0, (int)peep, 0, 0);
sub_693B58(peep);
invalidate_sprite((rct_sprite*)peep);
}

View File

@ -227,8 +227,14 @@ enum PEEP_ACTION_EVENTS {
PEEP_ACTION_STAFF_FIX = 15,
PEEP_ACTION_STAFF_FIX_2 = 16,
PEEP_ACTION_STAFF_FIX_GROUND = 17,
PEEP_ACTION_STAFF_WATERING = 19,
PEEP_ACTION_WAVE = 22,
PEEP_ACTION_STAFF_EMPTY_BIN = 23,
PEEP_ACTION_TAKE_PHOTO = 25,
PEEP_ACTION_CLAP = 26,
PEEP_ACTION_NONE_1 = 254,
PEEP_ACTION_NONE_2 = 255
};
enum PEEP_FLAGS {
@ -351,7 +357,7 @@ typedef struct {
uint16 name_string_idx; // 0x22
uint16 next_x; // 0x24
uint16 next_y; // 0x26
uint16 next_z; // 0x28
uint16 next_z; // 0x28 possibly split into two uint8s
uint8 var_2A;
uint8 state; // 0x2B
uint8 var_2C;
@ -363,9 +369,9 @@ typedef struct {
};
uint8 tshirt_colour; // 0x30
uint8 trousers_colour; // 0x31
uint16 var_32;
uint16 var_34;
uint8 var_36;
uint16 destination_x; // 0x32 Location that the peep is trying to get to
uint16 destination_y; // 0x34
uint8 destination_tolerence; // 0x36 How close to destination before next action/state 0 = exact
uint8 var_37;
uint8 energy; // 0x38
uint8 energy_growth_rate; // 0x39
@ -396,13 +402,17 @@ typedef struct {
uint8 current_seat; // 0x6C
};
uint16 time_to_sitdown; //0x6B
struct{
uint8 time_to_stand; //0x6B
uint8 standing_flags; //0x6C
};
};
uint8 var_6D; // 0x6D
uint8 var_6E; // 0x6E
uint8 var_6F;
uint8 var_70;
uint8 var_71;
uint8 var_72;
uint8 action; // 0x71
uint8 action_frame; // 0x72
uint8 var_73;
uint16 var_74;
uint8 var_76;
@ -549,5 +559,6 @@ void peep_decrement_num_riders(rct_peep* peep);
void peep_insert_new_thought(rct_peep *peep, uint8 thought_type, uint8 thought_arguments);
void peep_set_map_tooltip(rct_peep *peep);
void sub_693B58(rct_peep* peep);
#endif

View File

@ -142,7 +142,7 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx,
}
newPeep->var_45 = 0;
newPeep->var_71 = 0xFF;
newPeep->action = 0xFF;
newPeep->var_6D = 0;
newPeep->var_70 = 0;
newPeep->var_E0 = 0;

View File

@ -1140,7 +1140,7 @@ static void ride_spiral_slide_update(rct_ride *ride)
ride->var_15D--;
peep = &(g_sprite_list[ride->maze_tiles].peep);
peep->var_32++;
peep->destination_x++;
}
// Invalidate something related to station start

View File

@ -1229,7 +1229,7 @@ void window_guest_overview_tool_down(){
peep_decrement_num_riders(peep);
peep->state = 0;
peep_window_state_update(peep);
peep->var_71 = 0xFF;
peep->action = 0xFF;
peep->var_6D = 0;
peep->var_70 = 0;
peep->var_6E = 0xFF;
@ -1238,7 +1238,7 @@ void window_guest_overview_tool_down(){
peep->happiness_growth_rate -= 10;
if (peep->happiness_growth_rate < 0)peep->happiness_growth_rate = 0;
RCT2_CALLPROC_X(0x00693B58, 0, 0, 0, 0, (int)peep, 0, 0);
sub_693B58(peep);
tool_cancel();
RCT2_GLOBAL(0x9DE550, sint32) = -1;
}
@ -1262,7 +1262,7 @@ void window_guest_overview_tool_abort(){
peep_decrement_num_riders(peep);
peep->state = 0;
peep_window_state_update(peep);
peep->var_71 = 0xFF;
peep->action = 0xFF;
peep->var_6D = 0;
peep->var_70 = 0;
peep->var_6E = 0;

View File

@ -1154,7 +1154,7 @@ void window_staff_overview_tool_down(){
peep_decrement_num_riders(peep);
peep->state = PEEP_STATE_FALLING;
peep_window_state_update(peep);
peep->var_71 = 0xFF;
peep->action = 0xFF;
peep->var_6D = 0;
peep->var_70 = 0;
peep->var_6E = 0;
@ -1192,7 +1192,7 @@ void window_staff_overview_tool_abort(){
peep_decrement_num_riders(peep);
peep->state = PEEP_STATE_FALLING;
peep_window_state_update(peep);
peep->var_71 = 0xFF;
peep->action = 0xFF;
peep->var_6D = 0;
peep->var_70 = 0;
peep->var_6E = 0;

View File

@ -477,10 +477,10 @@ static rct_peep *park_generate_new_guest()
peep->sprite_direction = spawn.direction << 3;
// Get the centre point of the tile the peep is on
peep->var_32 = (peep->x & 0xFFE0) + 16;
peep->var_34 = (peep->y & 0xFFE0) + 16;
peep->destination_x = (peep->x & 0xFFE0) + 16;
peep->destination_y = (peep->y & 0xFFE0) + 16;
peep->var_36 = 5;
peep->destination_tolerence = 5;
peep->var_76 = 0;
peep->var_78 = spawn.direction;
peep->var_37 = 0;