Openrct2: Ducks are not spawning!

Created on 11 Jan 2019  ·  24Comments  ·  Source: OpenRCT2/OpenRCT2

OS: Windows 10
Version: 0.2.1
Commit/Build: 746feaa


Ducks no longer seem to spawn!

Steps to reproduce:

  1. Create large body of water (code says you need at least 25 tiles of water at same height in a 7x7 area)
  2. Wait forever
  3. No ducks seem to spawn
bug

Most helpful comment

Heavens, no! We must fix this immediately!

All 24 comments

Heavens, no! We must fix this immediately!

There are flying ducks but no swimming ducks
image

That's interesting, because I thought they always have a water body as target.. Could it be that the coordinates are somehow wrong?

The month must be <= APRIL, checked that? I've checked in _Crazy Castle_ on devel and the ducks spawn fine.

https://github.com/OpenRCT2/OpenRCT2/blob/92412d4bab085fe5adbdac80f67af4a50d2fab98/src/openrct2/scenario/Scenario.cpp#L332-L341

Yes I know that, I only check in March and April

But april < april does not hold.

But april < april does not hold.

april <= april does, fortunately. ;)

I see the earlier comment got amended to fix that. Indeed, the code linked has LE, rather than LT, but I overlooked that.

@deurklink But you haven't seen any ducks?

If you're building from source you could set a breakpoint at openrct2/scenario/Scenario.cpp:425 to see what happens when the game tries to create the ducks.

I know, and I already played a bit with that to see what would happen, but not enough to draw any conclusions from it yet

Well, I wonder, does it ever come to line 465? Then it should draw ducks.
If it doesn't, but it comes to line 461, no (found) water is big enough.
,, ,, line 443, no (found) water height is zero.
,, ,, line 438, no (found) water is in the park.

Of course, it might be less simplistic than that but that should at least point out where the logical flaw is.

Another important factor is that the tiles are randomly selected if you don't have a lot of water then its less likely they will spawn.

One map I tested on was Leafy Lake.. That one should have enough water, right?

You still have to consider when I'm talking random tile it literally picks a random value for x and y within the range of the entire map not just within your park and that only happens once per game week, so yes and no?

@ZehMatt, well, the current implementation spends a maximum of hundred tries to find a single suitable tile for spawning, so in practice, this should often be successful in a water-rich map.

@deurklink To be certain, you are looking for them on the closest zoomlevel, right? What's on line 9 of your object/rct2/water/rct2.wtrcyan.json in the data directory?

"allowDucks": true,

OK, i checked some more scenarios now.

Ivory towers: Spawns ducks
White Water Park: Spawns ducks
Leafy Lake: No ducks
Mega Park: No ducks
Forest frontiers had no ducks when i filled the entire map with water. When i used the own all land cheat however, ducks started to spawn in areas of land that were outside the normally owned land.
I think the function just generates very specific coordinates.. Gonna take a look at the coordinates it generates to try duck spawning.

Interesting investigation @deurklink, could it be a not-so-sane random
number generator for the scenario ?

On Sun, Jan 20, 2019, 09:23 deurklink <[email protected] wrote:

OK, i checked some more scenarios now.

Ivory towers: Spawns ducks
White Water Park: Spawns ducks
Leafy Lake: No ducks
Mega Park: No ducks
Forest frontiers had no ducks when i filled the entire map with water.
When i used the own all land cheat however, ducks started to spawn in areas
of land that were outside the normally owned land.
I think the function just generates very specific coordinates.. Gonna take
a look at the coordinates it generates to try duck spawning.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/OpenRCT2/OpenRCT2/issues/8584#issuecomment-455846693,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AApOaB6aV3c5svFj_phyRO8SWa6Rl05Lks5vFCd5gaJpZM4Z77J9
.

OK I think i found an issue.. The tile coordinates it generates are all between 64 and 255-64. To illustrate what that means in Forest Frontiers, the icy area is where the game will never check for water to create ducks at..
image

Also note that the land has to be owned by the player for a tile to be considered.

And here's Leafy Lake..
image
I think we've found the root of the ducks issue 😁

OK I replaced the original code for coordinate generation:

    x = (scenario_rand() & 0xFF) * 32;
    y = (scenario_rand() & 0xFF) * 32;

    //original code:
    //x = ((r >> 16) & 0xFFFF) & 0x7F;
    //y = (r & 0xFFFF) & 0x7F;
    //x = (x + 64) * 32;
    //y = (y + 64) * 32;

And look at that! A leafy lake full of ducks!
image

This is great. Seems like a sign issue to me.

Maybe comment on the magic
On Sun, Jan 20, 2019, 10:10 deurklink <[email protected] wrote:

OK I replaced the original code for coordinate generation:

r = scenario_rand();
x = (scenario_rand() & 0xFF) * 32;
y = (scenario_rand() & 0xFF) * 32;

//original code:
//x = ((r >> 16) & 0xFFFF) & 0x7F;
//y = (r & 0xFFFF) & 0x7F;
//x = (x + 64) * 32;
//y = (y + 64) * 32;

And look at that! A leafy lake full of ducks!
[image: image]
https://user-images.githubusercontent.com/6469413/51437218-89dd4880-1c9b-11e9-880f-53be2742e740.png


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/OpenRCT2/OpenRCT2/issues/8584#issuecomment-455849451,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AApOaEVOycJAkpyID23KL1WwDnTQLPDBks5vFDKFgaJpZM4Z77J9
.

Actually, it seems to be intended (hence the x+64 part). I just checked in vanilla rct2 and it looks like an original bug (or intended behaviour). In Crazy Castle, for example, the ducks only stick to a small corner of the map.

Nice job there @deurklink

Reopening since the fix has been reverted (it caused crashes).

Was this page helpful?
0 / 5 - 0 ratings