Creatures & Encounters!


I had map and dungeon movement complete! But moving around with no encounters is pretty boring, so I wanted to move on to encounters. In my previous text adventures, the fighting was all one on one, but I wanted to change that with this game. I wanted the creatures to travel in packs, and for the player to be able to encounter different creatures at the same time! I also wanted the encounters to be more realistic, using sleep cycles and the current game world time, habitats that correspond to the tiles of the game map, grouping, for how many may appear in one encounter and rarity for how rare it is to encounter.

The first thing I needed for encounters was creatures. I used ChatGPT to help me come up with the creatures I wanted as well as their stats and other attributes. First, I asked it to list me 30 creatures from medieval European folklore, which produced the following list:

  1. Dragons
  2. Unicorns
  3. Griffins
  4. Giants
  5. Mermaids
  6. Goblins
  7. Gnomes
  8. Faeries
  9. Elves
  10. Dwarves
  11. Banshees
  12. Witches
  13. Wizards
  14. Warlocks
  15. Trolls
  16. Ogres
  17. Pixies
  18. Sprites
  19. Selkies
  20. Satyrs
  21. Centaurs
  22. Minotaurs
  23. Manticores
  24. Harpies
  25. Chimeras
  26. Cockatrices
  27. Wyverns
  28. Kelpies
  29. Naiads
  30. Dryads

Which I then refined into this list:

1. human
2. fairies
3. elf
4. merfolk
5. satyr
6. kobold
7. goblin
8. hobgoblin
9. ogre
10. troll
11. giant
12. boar
13. wolf
14. bear
15. harpy
16. griffin
17. unicorn
18. wyvern
19. manticore
20. dragon

Next, I asked it to come up with the habitats of the creatures, using these terrain tiles: plains, water, mountains, swamp, forest. Originally, I had it generate different percentages they would be in each terrain, but I later scrapped that in favor of a list of terrains they can be found on. These are the sleep cycles it came up with:

  • DIURNAL: active during the day, sleeping at night
  • NOCTURNAL: active at night, sleeping during the day
  • CREPUSCULAR: active during twilight (dawn and dusk)
  • MATUTINAL: active in the morning, sleeping in the afternoon and at night
  • VESPERTINE: active in the evening, sleeping in the morning and afternoon
  • CATHEMERAL: sporadically active throughout a 24-hour period, with no set pattern

I decided not to use CATHEMERAL, because I can just add multiple sleep cycles.

I got it to come up with some social group sizes for each creature. Rarity, alignment spectrum, diet, lifespan, and stat ranges. I went through a lot of iterations with ChatGPT and ended up adjusting all these myself, but ChatGPT gave a good starting point.

After I had all this defined in code, it was time to create random encounters! I made a RandomEncounter method that takes in all this data and checks it against every creature type. If there is a match, then it rolls for a the grouping and creates that many random creatures of that species. Once this happens, the search continues, and if there is another match, the results get added to the list as before. This way, you can encounter multiple creature types at once. I want the alignment to play a role here; I might add good creatures and bad creatures to fight amongst each other in an encounter.

I had ChatGPT help write a RandomEncounter method that takes in all this data and checks it against every creature type. I did end up rewriting most of it though. 

public static List<Character> RandomEncounter()

{

    List<Character> encounter = new List<Character>();

    foreach (KeyValuePair<string, Species> kvp in Program.allSpecies)

    {

        Species species = kvp.Value;

        // Check if the species is found in the current tile type

        if (species.habitat.Contains(Program.world.map.map[Program.world.player.ScaledPosition.X, Program.world.player.ScaledPosition.Y]))

        {

            if (Species.GetActiveSleepCycles(Program.world.GetDateTime()).Contains(species.sleepCycle))

            {

                // Generate a random number to compare against the species rarity

                int rarityRoll = Program.world.random.Next(1, 100);

                if (rarityRoll <= species.rarity)

                {

                    int numberOfCreatures = Program.world.random.Next(species.grouping.Item1, species.grouping.Item2);

                    // Add the encounter to the list of encounters

                    for (int i = 0; i < numberOfCreatures; i++)

                    {

                        encounter.Add(new Character(species, i));

                    }

                }

            }

        }

    }

    return encounter;

}

If there is a match then it rolls for a the grouping and creates that many random creatures of that species, once this happens the search continues and if there is another match the results get added to the list as before and goes to check for every creature type. This way you can encounter multiple creature types at once. I want the alignment to play a role here, I might add good creatures and bad creatures to fight amongst each other in an encounter, but that won't be until later in the project. I hope you enjoyed this look into my game's development.

Leave a comment

Log in with itch.io to leave a comment.