Welcome to Friday Fun, the blog where I poke my head up from underground, let you all know I’m still alive, and hopefully entertain you with some bits about my project progress and game development experience.
Distinguished Vermin
One thing that I have been fervently trying to do as I rework vermin mechanics is to make sure that each species of vermin must be handled or considered in a slightly different way. In other words, each species of vermin should have distinct gameplay reasons to exist separate from other vermin.
I think I am now well on the way to that. Rats have always been different from mice, because the rats can actually be deadly and so must be treated with much more care than the harmless mice. Now, mosquitoes and roaches both have rules that require orthogonal strategies to deal with them.
Mosquitoes have a day/night cycle. They feed mostly at dusk and dawn, some during the night, and seldom during the day. This is reflected in the capture rates of the new mosquito trap. They will work best if activated for the dusk and dawn hours.
Roaches like to hide, so traps will be more effective if placed near furnishings that make good cover. Each furnishing located within a tight radius of the trap will give a significant bonus to capture rate.
Pickup AND Delivery
Last week I showed off the new trash collection mechanic, and this week I have been working on the converse case – receiving new items. New furnishings and such will be delivered and then can be moved to their desired places.
Finding an open spot in a given two-dimensional area that will hold a particular object is an ability that we as humans take for granted, but for a contemporary computer using contemporary physics libraries, it is actually a pretty hard problem (hard in this case meaning computationally expensive). I actually looked through a modding interface at a game that I thought had solved the problem long ago (Farming Simulator 2013), but found smoke and mirrors instead! It turns out the developers only solved the problem in one dimension (probably by brute force at that point), and then just used multiple one-dimensional lines to create the “spawn area”.
This is a good reminder: If you see a game doing something that seems really complex, there is a decent chance that there is a trick behind the scenes that reduces the complexity.
In the interest of time and sanity, I will abandon my efforts to solve the problem in two dimensions and instead do something similar to Farming Simulator, except I might reduce the problem to zero dimensions and just have multiple co-linear/co-planar spawn points defined simulating a spawn area.
Target Filters
For a lot of the scenarios the last couple of weeks, the Lua scripts involved have needed to work with lists of targets – for example, vermin located within range of a trap, trash bags within the curbside receiving area, potential spawn points for delivered furnishings, furnishings located near a roach trap.
This has led to the refinement of a set of methods for working with these lists of targets. The goal is for these methods to be modular, and do one thing well. Let’s pick apart, for example, the Lua statement that determines what mosquitoes will be attracted to a trap:
It starts with GetTargetsByCategory. Categories in Dehoarder 2 are pretty much tags for objects. So that call will get all targets in the game that contain the category “Mosquito”. Next, the InRange filter is applied. This will reduce the list of targets to just ones that are within 10 meters of targetPosition. Finally, PickRandom (virtually) shuffles the list we have so far like a deck of cards, and then draws a number of items from the shuffled list.
I expect to see this general pattern used a lot – start with an indexed retrieval of objects from a source, and then use filters to winnow down to the objects we are interested in.
Conclusion
That’s a wrap for this week’s Friday Fun. I’m deliberately not making any significant announcements today because they would likely get even more lost than usual among current events. If you want to see me continue the great work I am highlighting here, please wishlist Dehoarder 2 on Steam, and consider supporting me on Patreon; Beta Cat and higher level Patrons will get free access to play the upcoming early alpha versions of the game before most others (only streamers, event judges, and live event attendees get earlier access).