Put random birds on the roofs of your towns! - Pawkkie/Team-Aquas-Asset-Repo GitHub Wiki

Very specific tutorial incoming: having bird Pokémon that randomly spawn on roofs is a stupidly easy way to add some life to your nice little towns!

Note: This tutorial uses Poryscript. If you don't use Poryscript, you shouldjust paste the code in the Poryscript Playground to convert it back to vanilla scripting!

Solution

In Porymap

Creating the object events

Let's start by opening our map and adding several new object events, each using one of the temp flags FLAG_TEMP_X (of course, make sure they're not using a temp flag that you're already using in your map's scripts), and placing them on roofs. Each object event should look a bit like this:

image

Note: If you're using the Followers feature that should very soon be released in Expansion, OBJ_EVENT_GFX_SPECIES(TAILLOW) will work on its own, no need for you to add new graphics.

Collisions

To have the birds display properly and to avoid them escaping from their roof (we wouldn't want that!), make sure your house's collision looks like this:

image

The 4 tiles correspond to the Z coordinate of the birds. That way, the birds will be free to roam on all the 4 tiles, but will not step on the regular 3 tiles.

Metatile layers

Make sure those 4 roof metatiles look like this in the tileset editor:

image

Since they're drawn on the middle layer and not on the top layer, the birds will not be hidden by the roof tiles!

In your town's scripts file

Now let's add something like this to the mapscripts (or edit the MAP_SCRIPT_ON_LOAD if you already have one):

mapscripts YourMap_MapScripts {
+    MAP_SCRIPT_ON_LOAD {
+        // Set all the flags used by the birds so that they start out all hidden
+        setflag(FLAG_TEMP_1)
+        setflag(FLAG_TEMP_2)
+        setflag(FLAG_TEMP_3)
+        setflag(FLAG_TEMP_4)

+        random(4)
+        switch(var(VAR_RESULT)) {
+            case 0:
+                // This will display only the bird(s) using FLAG_TEMP_1
+                clearflag(FLAG_TEMP_1)
+            case 1:
+                // This will display only the bird(s) using FLAG_TEMP_2
+                clearflag(FLAG_TEMP_2)
+            case 2:
+                clearflag(FLAG_TEMP_4)
+            case 3:
+                // Adding a little variety by having several birds at once in this case
+                clearflag(FLAG_TEMP_1)
+                clearflag(FLAG_TEMP_3)
+        }
}

And that's it!

Birbs

Now that your birds are happily hopping around, you can customize them however you want (replacing them with Zubat at night, adding a shiny bird with a very slim chance of showing, etc). Now go, and spread the bird love in your own hack!