Merge pull request #10097 from ZehMatt/duck-managment

Duck improvements and fixes
This commit is contained in:
Duncan authored and GitHub committed 2019-10-20 07:35:07 +01:00
commit 86474df361
10 files changed
+67 -22

No files matched your search

+2
View File
@@ -3778,6 +3778,8 @@ STR_6327 :Transparent background for giant screenshots
STR_6328 :{SMALLFONT}{BLACK}With this option enabled, giant screenshots will have a transparent background instead of the default black colour.
STR_6329 :{STRING}{STRINGID}
STR_6330 :Downloading [{STRING}] from {STRING} ({COMMA16} / {COMMA16})
STR_6331 :Create Ducks
STR_6332 :Remove Ducks
#############
# Scenarios #
+12
View File
@@ -126,7 +126,9 @@ enum WINDOW_CHEATS_WIDGET_IDX
WIDX_GENERAL_GROUP = WIDX_TAB_CONTENT,
WIDX_OPEN_CLOSE_PARK,
WIDX_CREATE_DUCKS,
WIDX_PARK_PARAMETERS,
WIDX_REMOVE_DUCKS,
WIDX_OWN_ALL_LAND,
WIDX_FORCE_PARK_RATING,
WIDX_PARK_RATING_SPINNER,
@@ -269,7 +271,9 @@ static rct_widget window_cheats_misc_widgets[] =
MAIN_CHEATS_WIDGETS,
{ WWT_GROUPBOX, 1, XPL(0) - GROUP_SPACE, WPL(1) + GROUP_SPACE, YPL(0), HPL(7.25), STR_CHEAT_GENERAL_GROUP, STR_NONE }, // General group
{ WWT_BUTTON, 1, XPL(0), WPL(0), YPL(1), HPL(1), STR_CHEAT_OPEN_PARK, STR_CHEAT_OPEN_PARK_TIP }, // open / close park
{ WWT_BUTTON, 1, XPL(0), WPL(0), YPL(2), HPL(2), STR_CREATE_DUCKS, STR_CREATE_DUCKS }, // Create ducks
{ WWT_BUTTON, 1, XPL(1), WPL(1), YPL(1), HPL(1), STR_CHEAT_PARK_PARAMETERS, STR_CHEAT_PARK_PARAMETERS_TIP }, // Park parameters
{ WWT_BUTTON, 1, XPL(1), WPL(1), YPL(2), HPL(2), STR_REMOVE_DUCKS, STR_REMOVE_DUCKS }, // Remove ducks
{ WWT_BUTTON, 1, XPL(0), WPL(0), YPL(3), HPL(3), STR_CHEAT_OWN_ALL_LAND, STR_CHEAT_OWN_ALL_LAND_TIP }, // Own all land
{ WWT_CHECKBOX, 1, XPL(0), WPL(0), YPL(5), HPL(5), STR_FORCE_PARK_RATING, STR_NONE }, // Force park rating
SPINNER_WIDGETS (1, XPL(1), WPL(1) - 10, YPL(5) + 2, HPL(5) - 3, STR_NONE, STR_NONE), // park rating (3 widgets)
@@ -535,6 +539,8 @@ static uint64_t window_cheats_page_enabled_widgets[] = {
MAIN_CHEAT_ENABLED_WIDGETS |
(1ULL << WIDX_FREEZE_WEATHER) |
(1ULL << WIDX_OPEN_CLOSE_PARK) |
(1ULL << WIDX_CREATE_DUCKS) |
(1ULL << WIDX_REMOVE_DUCKS) |
(1ULL << WIDX_WEATHER) |
(1ULL << WIDX_WEATHER_DROPDOWN_BUTTON) |
(1ULL << WIDX_CLEAR_GRASS) |
@@ -925,6 +931,12 @@ static void window_cheats_misc_mouseup(rct_window* w, rct_widgetindex widgetInde
case WIDX_OPEN_CLOSE_PARK:
CheatsSet(CheatType::OpenClosePark);
break;
case WIDX_CREATE_DUCKS:
CheatsSet(CheatType::CreateDucks, CHEATS_DUCK_INCREMENT);
break;
case WIDX_REMOVE_DUCKS:
CheatsSet(CheatType::RemoveDucks);
break;
case WIDX_CLEAR_GRASS:
CheatsSet(CheatType::SetGrassLength, GRASS_LENGTH_CLEAR_0);
break;
+3
View File
@@ -83,6 +83,8 @@ enum class CheatType : int32_t
DisableRideValueAging,
IgnoreResearchStatus,
EnableAllDrawableTrackPieces,
CreateDucks,
RemoveDucks,
Count,
};
@@ -108,6 +110,7 @@ enum
#define CHEATS_GIVE_GUESTS_MONEY MONEY(1000, 00)
#define CHEATS_TRAM_INCREMENT 250
#define CHEATS_DUCK_INCREMENT 20
#define CHEATS_STAFF_FAST_SPEED 0xFF
#define CHEATS_STAFF_NORMAL_SPEED 0x60
#define CHEATS_STAFF_FREEZE_SPEED 0
+21
View File
@@ -230,6 +230,12 @@ public:
case CheatType::EnableAllDrawableTrackPieces:
gCheatsEnableAllDrawableTrackPieces = _param1 != 0;
break;
case CheatType::CreateDucks:
CreateDucks(_param1);
break;
case CheatType::RemoveDucks:
duck_remove_all();
break;
default:
{
log_error("Unabled cheat: %d", _cheatType.id);
@@ -343,6 +349,8 @@ private:
return { { 0, 5 }, { 0, 0 } };
case CheatType::SetForcedParkRating:
return { { 0, 999 }, { 0, 0 } };
case CheatType::CreateDucks:
return { { 0, 100 }, { 0, 0 } };
default:
return { { 0, 0 }, { 0, 0 } };
}
@@ -772,4 +780,17 @@ private:
auto parkSetParameter = ParkSetParameterAction(isOpen ? ParkParameter::Open : ParkParameter::Close);
GameActions::ExecuteNested(&parkSetParameter);
}
void CreateDucks(int count) const
{
for (int i = 0; i < count; i++)
{
// 100 attempts at finding some water to create a few ducks at
for (int32_t attempts = 0; attempts < 100; attempts++)
{
if (scenario_create_ducks())
break;
}
}
}
};
+3
View File
@@ -3968,6 +3968,9 @@ enum
STR_STRING_STRINGID = 6329,
STR_DOWNLOADING_OBJECTS_FROM = 6330,
STR_CREATE_DUCKS = 6331,
STR_REMOVE_DUCKS = 6332,
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
STR_COUNT = 32768
};
+1 -1
View File
@@ -34,7 +34,7 @@
// This string specifies which version of network stream current build uses.
// It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version.
#define NETWORK_STREAM_VERSION "20"
#define NETWORK_STREAM_VERSION "21"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
static Peep* _pickup_peep = nullptr;
+1 -1
View File
@@ -184,7 +184,7 @@ void misc_paint(paint_session* session, const rct_sprite* misc, int32_t imageDir
}
case SPRITE_MISC_DUCK:
if (dpi->zoom_level == 0)
if (dpi->zoom_level <= 1)
{
const rct_duck* duck = &misc->duck;
uint32_t imageId = duck_get_frame_image(&misc->duck, imageDirection);
+19 -18
View File
@@ -82,7 +82,6 @@ money32 gScenarioCompanyValueRecord;
char gScenarioFileName[MAX_PATH];
static int32_t scenario_create_ducks();
static void scenario_objective_check();
using namespace OpenRCT2;
@@ -420,24 +419,25 @@ void scenario_update()
*
* rct2: 0x006744A9
*/
static int32_t scenario_create_ducks()
bool scenario_create_ducks()
{
// Check NxN area around centre tile defined by SquareSize
constexpr int32_t SquareSize = 7;
constexpr int32_t SquareCentre = SquareSize / 2;
constexpr int32_t SquareRadiusSize = SquareCentre * 32;
CoordsXY centrePos;
centrePos.x = 64 + (scenario_rand_max(MAXIMUM_MAP_SIZE_PRACTICAL) * 32);
centrePos.y = 64 + (scenario_rand_max(MAXIMUM_MAP_SIZE_PRACTICAL) * 32);
centrePos.x = SquareRadiusSize + (scenario_rand_max(MAXIMUM_MAP_SIZE_TECHNICAL - SquareCentre) * 32);
centrePos.y = SquareRadiusSize + (scenario_rand_max(MAXIMUM_MAP_SIZE_TECHNICAL - SquareCentre) * 32);
Guard::Assert(map_is_location_valid(centrePos));
if (!map_is_location_in_park(centrePos))
return 0;
return false;
int32_t centreWaterZ = (tile_element_water_height(centrePos));
if (centreWaterZ == 0)
return 0;
// Check NxN area around centre tile defined by SquareSize
constexpr int32_t SquareSize = 7;
constexpr int32_t SquareCentre = SquareSize / 2;
return false;
CoordsXY innerPos{ centrePos.x - (32 * SquareCentre), centrePos.y - (32 * SquareCentre) };
int32_t waterTiles = 0;
@@ -463,25 +463,26 @@ static int32_t scenario_create_ducks()
// Must be at least 25 water tiles of the same height in 7x7 area
if (waterTiles < 25)
return 0;
return false;
// Set x, y to the centre of the tile
centrePos.x += 16;
centrePos.y += 16;
int32_t duckCount = (scenario_rand() & 3) + 2;
for (int32_t i = 0; i < duckCount; i++)
uint32_t duckCount = (scenario_rand() % 4) + 2;
for (uint32_t i = 0; i < duckCount; i++)
{
int32_t r = scenario_rand();
innerPos.x = (r >> 16) & 0x7F;
innerPos.y = (r & 0xFFFF) & 0x7F;
uint32_t r = scenario_rand();
innerPos.x = (r >> 16) % SquareRadiusSize;
innerPos.y = (r & 0xFFFF) % SquareRadiusSize;
CoordsXY targetPos{ centrePos.x + innerPos.x - SquareRadiusSize, centrePos.y + innerPos.y - SquareRadiusSize };
CoordsXY targetPos{ centrePos.x + innerPos.x - 64, centrePos.y + innerPos.y - 64 };
Guard::Assert(map_is_location_valid(targetPos));
create_duck(targetPos);
}
return 1;
return true;
}
const random_engine_t::state_type& scenario_rand_state()
+1
View File
@@ -395,6 +395,7 @@ extern char gScenarioFileName[260];
void load_from_sc6(const char* path);
void scenario_begin();
void scenario_update();
bool scenario_create_ducks();
const random_engine_t::state_type& scenario_rand_state();
void scenario_rand_seed(random_engine_t::result_type s0, random_engine_t::result_type s1);
+4 -2
View File
@@ -91,11 +91,12 @@ rct_duck* rct_sprite::AsDuck()
void rct_duck::Invalidate()
{
invalidate_sprite_0((rct_sprite*)this);
invalidate_sprite_1((rct_sprite*)this);
}
void rct_duck::Remove()
{
Invalidate();
sprite_remove((rct_sprite*)this);
}
@@ -123,7 +124,7 @@ void rct_duck::UpdateFlyToWater()
int32_t manhattanDistanceN = abs(target_x - newX) + abs(target_y - newY);
auto surfaceElement = map_get_surface_element_at({ target_x, target_y });
int32_t waterHeight = surfaceElement->GetWaterHeight();
int32_t waterHeight = surfaceElement != nullptr ? surfaceElement->GetWaterHeight() : 0;
if (waterHeight == 0)
{
state = DUCK_STATE::FLY_AWAY;
@@ -383,6 +384,7 @@ void duck_remove_all()
nextSpriteIndex = sprite->next;
if (sprite->type == SPRITE_MISC_DUCK)
{
invalidate_sprite_1((rct_sprite*)sprite);
sprite_remove((rct_sprite*)sprite);
}
}