Boids: natural flight movement and behavior

Post your example zscripts/ACS scripts/etc here.
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
User avatar
Enjay
 
 
Posts: 26430
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Boids: natural flight movement and behavior

Post 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.
User avatar
4page
Posts: 117
Joined: Tue Aug 06, 2019 5:08 pm
Location: American Pacific Northwest

Re: Boids: natural flight movement and behavior

Post 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.
User avatar
4page
Posts: 117
Joined: Tue Aug 06, 2019 5:08 pm
Location: American Pacific Northwest

Re: Boids: natural flight movement and behavior

Post 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.
User avatar
eharper256
Posts: 870
Joined: Sun Feb 25, 2018 2:30 am
Location: UK

Re: Boids: natural flight movement and behavior

Post 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.
User avatar
Enjay
 
 
Posts: 26430
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Boids: natural flight movement and behavior

Post 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.
You do not have the required permissions to view the files attached to this post.
User avatar
00face
Posts: 46
Joined: Mon Nov 20, 2017 8:24 pm

Re: Boids: natural flight movement and behavior

Post 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.
User avatar
4page
Posts: 117
Joined: Tue Aug 06, 2019 5:08 pm
Location: American Pacific Northwest

Re: Boids: natural flight movement and behavior

Post 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.
User avatar
00face
Posts: 46
Joined: Mon Nov 20, 2017 8:24 pm

Re: Boids: natural flight movement and behavior

Post 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.
User avatar
Xim
Posts: 2057
Joined: Fri Feb 20, 2009 2:46 pm
Location: Somewhere with trees

Re: Boids: natural flight movement and behavior

Post 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.
User avatar
4page
Posts: 117
Joined: Tue Aug 06, 2019 5:08 pm
Location: American Pacific Northwest

Re: Boids: natural flight movement and behavior

Post 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:
User avatar
4page
Posts: 117
Joined: Tue Aug 06, 2019 5:08 pm
Location: American Pacific Northwest

Re: Boids: natural flight movement and behavior

Post by 4page »

Finally been getting around to making some improvements to the Boid library. Update improves performance quite a bit on maps with many thinkers, and just slightly otherwise. I changed the names of the actors and such to remove the "HXA" prefix, so if you're already using the older version and are going to update, make sure you change the names of things to reflect the new naming scheme. I wasn't able to improve performance as much as I would like, but hopefully I'll be able to figure out a good way to do that soon.

Return to “Script Library”