Page 3 of 3

Re: Boids: natural flight movement and behavior

Posted: Thu Feb 03, 2022 1:52 pm
by Enjay
4page wrote: HorizonNormalizer ... Try setting that to about 40 and it should work a bit better.

That does get things much closer to the kind of behaviour that I was looking for. Thanks once again.

Re: Boids: natural flight movement and behavior

Posted: Thu Feb 03, 2022 2:17 pm
by 4page
No problem. I tried to make it easy to understand, but I get that there's a lot in there. I'm happy to try to provide solutions and help.

Re: Boids: natural flight movement and behavior

Posted: Fri Feb 04, 2022 9:13 am
by 4page
UPDATED THE LIBRARY:
Function to generate a new FlockID. Pretty much only useful for a spawner so it can spawn boids that will only flock together and with nothing else.
Function to inherit the FlockID of its master pointer. Again only really useful for boids spawned by a spawner.
Fixed the issue with the boids preferring to fly up and down. Turns out in a part that I wrote specifically to try to avoid this behavior I accidentally had a positive instead of a negative. Then I realized I didn't need that section at all so removed it. Now it's much more natural looking and its vertical movement is no more significant than its horizontal movement. However, the HorizonNormalizer field is still necessary if you want it not moving up or down so much.

Re: Boids: natural flight movement and behavior

Posted: Fri Feb 04, 2022 11:33 am
by eharper256
Just tested this; definately an improvement. The birb can now sometimes even manage to get into small tunnels to follow if you give it a bit of time; and the circling master behaviour is much tighter.

Re: Boids: natural flight movement and behavior

Posted: Fri Feb 04, 2022 12:43 pm
by Enjay
Very nice. Definitely more natural looking.

These all probably still require a bit of tweaking to make them a) better and b) more distinct from each other but here are a few bird types that I have been messing with:




Demo file (slightly different to the one in the video) - use the switches in the maps to change the kind of birds that are flying around.
NJ_BirbDemo.pk3


You need to load this on top of 4page's library.
As before, these will probably need a bit of tweaking, and I am sure that I will have made some coding errors/inefficient entries, but all three bird types fly slightly differently and do pretty much what I was hoping they would.

Re: Boids: natural flight movement and behavior

Posted: Wed Feb 16, 2022 4:31 pm
by 00face
Okay, now for a practical request. Can you bind this behavior to the lost souls that come out of the Pain Elemental? As in, swarming in defense, attacking, and frenzy (no Pain Elemental around). Thank you so much for your impressive work so far.

Re: Boids: natural flight movement and behavior

Posted: Thu Feb 17, 2022 6:18 am
by 4page
Theoretically, yeah, you should be able to, but you'd have to rewrite Lost Souls completely, and Pain Elementals partially. It could be quite a bit of work to have it behave correctly, depending on how complex you want the behaviors to interact with each other.

Re: Boids: natural flight movement and behavior

Posted: Fri Feb 25, 2022 4:49 pm
by 00face
Yeah, I know I'm being that guy like "could you just" but I am excited to see this put to use in Doom.

Re: Boids: natural flight movement and behavior

Posted: Thu Apr 07, 2022 12:23 pm
by Xim
Just checked this out today, and it's pretty cool. I too was interested in making a Lost Soul that uses this behavior.

Here's my fairly simple attempt, pretty much just the default lost soul zscript with the boidflight tick added without particles. It seems okay, but maybe could be improved. After all these years I'm still learning.

Code: Select all

Class LostSoulBoid : HXA_Boid
{

   Override Void Tick()
   {
      BoidFlight(MaxVelocity: 30,HorizonNormalizer: 5);
      super.tick();
   }
   
   Default
   {
      Monster
      -NOBLOCKMONST;
      -FRIENDLY;
      +COUNTKILL;
      +MISSILEMORE;
      +NOICEDEATH;
      +ZDOOMTRANS;
      +RETARGETAFTERSLAM;
      Scale 0.75;
      Health 100;
      Radius 16;
      Height 56;
      Mass 50;
      Speed 8;
      Damage 3;
      PainChance 256;   
      AttackSound "skull/melee";
      PainSound "skull/pain";
      DeathSound "skull/death";
      ActiveSound "skull/active";
      RenderStyle "SoulTrans";
      Obituary "$OB_SKULL";
      Tag "$FN_LOST";      
      HXA_Boid.BoidActor "LostSoulBoid";
   }
   
   States
   {
      Spawn:
         SKUL AB 10 BRIGHT A_Look();
         Loop;
      See:
         SKUL AB 6 BRIGHT A_Chase();
         Loop;
      Missile:
         SKUL C 10 BRIGHT A_FaceTarget();
         SKUL D 4 A_SkullAttack();
         SKUL CD 4 BRIGHT;
         Goto See;
      Pain:
         SKUL E 3 BRIGHT;
         SKUL E 3 BRIGHT A_Pain;
         Goto See;         
      Death:
         SKUL F 6 BRIGHT;
         SKUL G 6 BRIGHT A_Scream;
         SKUL H 6 BRIGHT;
         SKUL I 6 BRIGHT A_NoBlocking;
         SKUL J 6;
         SKUL K 6;
         Stop;
   }
}


EDIT: It's seems to be kind of tricky getting a swarm to be hostile to the player. Sometimes they attack you, but a lot of the time they just fly around.

Re: Boids: natural flight movement and behavior

Posted: Fri Apr 08, 2022 11:30 pm
by 4page
You should stop running BoidFlight() when it's attacking. You could try something like:

Code: Select all

Override void Tick()
{
    if(InStateSequence(CurState, FindState("See")))
    {
        BoidFlight(MaxVelocity: 30,HorizonNormalizer: 5);
    }
    super.tick()
}


That might help. But maybe not. I offer no guarantees. :lol: