Update 508More work on aggressive behavior.
Because of their ranged attack this creature has one part of its aggressive behavior that is different from all the other rain world creatures - they don't want to get
to their victim, they want to get to a position from where they have a clear shot at their victim. It might not sound like a big difference - if you get to your victim you'll also have a clear shot, after all. But there are several situations where these priorities inform very different behavior.
Imagine the garbage valley of yesterday's gif, for example. A vulture is in the middle of the valley, slowly moving upwards with a scavenger in its jaws - the rest of the pack spread out on the slopes around it. If they were to path TO the vulture, they'd all gravitate to the closest spot they can get to - ie the bottom of the valley. That's how it was set up yesterday, and of course it looked stupid. The sensible course of action is climbing up the sides of the valley until you are in a position to start hurling stuff at the vulture.
Another example - a creature has climbed to the top of a pole. You're standing below another pole to the side of it. If you path to the creature, you'll run on the floor to the other pole, then climb up it and end up colliding with the other creature which might be cool if you're a lizard that wants to attack with your teeth. A scavenger however should climb up the
other pole and throw a spear at the target.
This is the system I worked with today. As with almost all of my "where in the room to go" systems I base it around a function that can rate an arbitrary tile on a scale for how "fit" that tile is. Once I have that, I can fall back on different ways of picking a random tile in the room (sometimes just a pure random pick) and ask a simple question, "is this tile more fit than the one that is my current destination?". If so, I switch - and the next frame the current destination will be that new, slightly fitter tile, giving a slightly higher bar for the future random picks to get over.
One reason why this is cool, is that you can mix methods of finding test tiles. If they are all compared by the same metric, the comparing will always be valid even if they were found by different means. In this scavenger spear throw behavior for example, I mix a purely random tile selection with a horizontal ray trace from the target's position that stops when reaching a scavenger accessible tile. That latter method is most often returning the better tiles (it makes sense that you want to be on the same height as the target, but on the next platform off) but because purely random tiles are also occasionally thrown in the mix you might get a surprising decision now and then, and stalemates when the conventional method of finding destinations isn't working for one reason or another can be broken.
Another way I have of making the behaviors mix up a little bit, seem more organic and get stuck less is to simply save the previous destinations in a list and give tiles close to those a lower rating. That means that the creature can go back to the same spot if the incentive is very strong, but it has a little bit of a bias to try different stuff.
And then of course I have a conservative bias on all of these, so that the destination I have currently decided on is a bit more attractive than whatever I'm comparing to. This is to avoid flicker - it's almost always better to stick to a plan for a little bit than to change your mind every frame and end up vibrating on the spot.
Giving the attack behavior a bit of a social component was not much trouble - I employed a similar technique as with the yellow lizards.
![](/Rain-World-Devlog/Images/Archived Images/5Blg6.gif)
By rating destinations closer to the pack members' destinations lower, I can naturally have them spread out a bit. In order to avoid flicker ("oh, you want to go here, then I'll go over here", "oh, you changed your mind, then let me also change my mind" ... etc) they mostly take the destinations of individuals that are more dominant than themselves into account - meaning that the team leader will go in for the kill pretty much as if alone with the target, and the others will play more supportive roles spreading out and covering the flanks.
You might be able to see this ranked hunting behavior in the gif, where the individual I suspect to be the group leader (brown, pink eyes, slightly beefier build. I base this assumption on cosmetic treats that should correlate with dominance, but can't know for sure.) is the one that takes the obvious route, and that dark grey orange-eyed individual switches to another route when it understands that it's competing with the leader. Two other more submissive individuals guard a corner of the map and take a more obscure flank respectively. This might very well be me projecting though, no way to know for sure as didn't write their dominance values in the debugging info when recording, sorry! People's tendency to project order onto utter nonsense is the life blood of this project though
![Grin](/Rain-World-Devlog/Images/Smileys/grin.gif)
Apart from all this aggressive behavior stuff, I have started working on making their behavior dynamic. They are able to change their behavior towards other creatures depending on context - for example a vulture or a lizard with its jaws occupied by another poor creature is considered less dangerous as it can't bite, and one that is carrying a pack member might actually turn into a target for aggression rather than a threat to flee from depending on the individual's aggression, bravery or sympathy stats. The logic there being that if you are extraordinarily un-aggressive you won't use violence, if you're cowardly you won't take the risk of a rescue mission, and if you're terribly unsympathetic you just won't care about your friend being hauled off.
I'm very much aware that these individual personality traits probably never will become evident to the player, but it only takes me a few seconds to add a personality check for triggering some behaviors, and it's cool to know that it's in there!
Puh, long update! See you guys tomorrow!