Jump to content
The Dark Mod Forums

Help needed for Flying bats


STRUNK

Recommended Posts

On 1/13/2022 at 4:03 PM, datiswous said:

Did you know there are bats in mission Moving day (which is currently in beta)?

Yes they are the first version and behave very batlike, but are "movers" following/chasing an entity, that is bound to different rotating entities on different axis.
 

 

Link to comment
Share on other sites

Lots of Bats (video):
https://cdn.discordapp.com/attachments/815315205483397142/931919491447816262/2022-01-15_14-58-24.mp4

The Bats do some tricks ans fly around randomly and it's looking good already BUT:
I don't know what I'm doing wrong, but whenever I set use_aas to any aas I get a warning that it cannot use (that) aas ..
And I have a lot of spawnargs that I think are related to flying (behavour) but I really can't figure out what they actually do, so I might have some things set wrong, causing the aas problem.
Also sometimes a Bat just goes up and down and not forward .. and I can't figure out how to keep them going forward all the time.

Maybe some of you can test the bats and look at the .def files so eventually there can be properly working Bats for everyone?

All needed files are included in the attachment. Do not start the game but open the console and enter testmap bat to start the test map.

 

bat.pk4

Edited by STRUNK
  • Like 1
  • Thanks 2
Link to comment
Share on other sites

@STRUNKVery nice work so far! I've looked into the code and saw that this error message about AAS appears when the AI's bounding box is larger than the maximum bounding box size defined in the AAS type. AAS_elemental allows up to 24x24x24, so I changed "size" to "24 24 24" and commented out your "mins" and "maxs" spawnargs (they seem to be redundant, and elementals don't use these) and dmap now works properly, creating an .aas_elemental file.

Some more remarks:

  • the .pk4 has one level of folders too many (the "bat" folder). You should create the zip archive while you're inside the "bat" folder, not by right-clicking it. This way you have the same folder structure as an FM .pk4 and others won't have to unpack it to play the test map.
  • It'd be much cleaner to let your small bat's modelDef and entityDef inherit from the large bat's defs using the "inherit" spawnarg. Then you can delete all properties except the ones that are different for the small bat, and any changes you make to the large bat will automatically be applied to the small bat.
  • Thanks 1
Link to comment
Share on other sites

Another problem is that your af_pose animation is the same as the flying animation, which causes it to continue animating even when the bat has been shot down. It should be a single-frame default pose, like a T-pose for humans.

By the way, this spawn code shows the default values assigned for the various "fly" spawnargs. If you comment out these spawnargs in the entityDef, the code will instead apply these default values:

	spawnArgs.GetInt( "team",			"1",		team );
	spawnArgs.GetInt( "rank",			"0",		rank );
	spawnArgs.GetInt( "fly_offset",			"0",		fly_offset );
	spawnArgs.GetFloat( "fly_speed",		"100",		fly_speed );
	spawnArgs.GetFloat( "fly_bob_strength",		"50",		fly_bob_strength );
	spawnArgs.GetFloat( "fly_bob_vert",		"2",		fly_bob_vert );
	spawnArgs.GetFloat( "fly_bob_horz",		"2.7",		fly_bob_horz );
	spawnArgs.GetFloat( "fly_seek_scale",		"4",		fly_seek_scale );
	spawnArgs.GetFloat( "fly_roll_scale",		"90",		fly_roll_scale );
	spawnArgs.GetFloat( "fly_roll_max",		"60",		fly_roll_max );
	spawnArgs.GetFloat( "fly_pitch_scale",		"45",		fly_pitch_scale );
	spawnArgs.GetFloat( "fly_pitch_max",		"30",		fly_pitch_max );

 

  • Thanks 1
Link to comment
Share on other sites

9 hours ago, Dragofer said:

AAS_elemental allows up to 24x24x24, so I changed "size" to "24 24 24" and commented out your "mins" and "maxs" spawnargs (they seem to be redundant, and elementals don't use these) and dmap now works properly, creating an .aas_elemental file.

I think, when I set the maxs and mins I prevented the bats from going too close to the walls ans having their wings go in them. Also the "stunt" animations require a bigger box. The aas_elemental was the last one I tested but I guess I can change to aas96 and set the size a bit smaller, and get rid of the mins and maxs.

 

 

9 hours ago, Dragofer said:

Another problem is that your af_pose animation is the same as the flying animation, which causes it to continue animating even when the bat has been shot down.

So that should be exported as an md5anim but with only 1 frame?
I think Bats should not be killable by the way : )

Link to comment
Share on other sites

@Dragofer
I don't know what it is with that aas but it seems to work for now. I put the 2 defs in one def file as you said and set aas96 for the bat and it worked. Then I set aas96 for the small bat and I got the warning again. Then I commented out the aas foor the small bat .. so it gets the same as the normal bat, and then I got no warning ... while it uses the aas from the normal bat ... aas96.
Also the mins and max seem to work for keeping the bats going too close to walls, floor and ceiling.

But now, how to keep them flying and not bobbing in one place? When I comment out anim idle I get constant messages in the console that it's missing anim idle ... so that's not an option.

Link to comment
Share on other sites

I found some other spawnargs in the tdm_ai_base.def:

- "idle_animations_interval"    "Defines the interval the idle animations should be played, in seconds. An uncertainty of +/- 20% is automatically applied by the code."
- "idle_animations"     "A set of animation states to be played by the idle AI. See the AI's script object for possible Animation State functions."
But they have no effect on the problem that they don't keep flying forward, like bats do. Bats don't hang araound in one place like rats do ... so I guess I have to change the animal_patrol behavour somehow, but where to find that?

Where can I find scriptobject "ai_darkmod_base" ?
 

Link to comment
Share on other sites

4 hours ago, STRUNK said:

So that should be exported as an md5anim but with only 1 frame?
I think Bats should not be killable by the way : )

Yes, a single-frame animation. And the bats are already quite hard to kill, but I managed to do it after getting in a lucky shot with a fire arrow- despite all the spawnargs you had set. Would just permit it for those players who go through the trouble.

Would upload the .def again for the other problems - or any problem with the bats.

Regarding pauses during animal_patrol, I saw that there are hardcoded pauses between movements - maybe a new spawnarg can be added to make that optional. Will have to look more to see whether something can be done about the vertical flying.

Btw, the hovering in place looks natural to me, just not the vertical flying.

Regarding the scriptobject, it's in tdm_ai_base.script, try unpacking all your .pk4's. But I dont think the scriptobject or idle_animations are going to be of any help here.

Link to comment
Share on other sites

10 hours ago, Dragofer said:

Would just permit it for those players who go through the trouble.

I just set spawnarg "noDamage" "1" on them, but I get your piont.

 

10 hours ago, Dragofer said:

Btw, the hovering in place looks natural to me, just not the vertical flying.

They hover too often, and when they are stationairy on the x an y axis the vertical bobbing gets really unnatural.
I can't find a way to have them fly in 3D without using spawnarg "fly_bob_vert" yet.
 

10 hours ago, Dragofer said:

Regarding the scriptobject, it's in tdm_ai_base.script

Been looking there but cant find the specific scriptobject tdm:ai_base is using (inherit).
I think the function(s) to randomly pause movement must be defined in a script that dictates " animal_patol".

We all know that Rats do have this "pausing" behavour , and therefor the script for "animal_patrol" fits the Rat very well ..
but Rats can't fly! : D

Bats don't pause, so somewhere pieces of the  "animal patrol" script should be eliminated to accopmlice that?

The Bats should be as simple as: "create entity - Bat"  ... and it will fly around within the set boundries, in a Batlike manner" (Plus the (limitid?) ability to use paths).


Update:

bat.pk4

Edited by STRUNK
Link to comment
Share on other sites

1 hour ago, STRUNK said:

I think the function(s) to randomly pause movement must be defined in a script that dictates " animal_patol".

Bats don't pause so somewhere pieces of the  "animal patrol" script should be eliminated to accopmlice that?

"Animal patrol" is 100% implemented in C++ - you can look at it yourself here: AnimalPatrolTask.hAnimalPatrolTask.cpp

The pause duration is set here - would be quite straightforward to replace those hardcoded 1000 milliseconds with a variable derived from a spawnarg so you can disable it completely if you want (would cause zig-zag flying, probably fine for bats):

case stateWaiting:
	if (owner->m_bCanDrown && owner->MouthIsUnderwater()) // grayman #2356 - don't hang around if you're drowning
	{
		_waitEndTime = gameLocal.time;
	}
	else
	{
		_waitEndTime = gameLocal.time + gameLocal.random.RandomInt(1000);
	}
	break;

If they hover too often, it's because their speed is too high in comparison to their allowed move radius. Maybe you'd want to force a certain minimum movement distance, or set a chance for the bat to keep moving without waiting.

This is how the animal patrollers choose a new destination to move to:

case stateMovingToNextSpot:
{
	const idVec3& curPos = owner->GetPhysics()->GetOrigin();
	_moveEndTime = 0;
	for (int i = 0 ; i < 5 ; i++) // grayman #2356 - try a few positions to increase movement in small spaces 
	{
		// Choose a goal position, somewhere near ourselves
		float xDelta = gameLocal.random.RandomFloat()*WANDER_RADIUS - WANDER_RADIUS*0.5f;
		float yDelta = gameLocal.random.RandomFloat()*WANDER_RADIUS - WANDER_RADIUS*0.5f;

		idVec3 newPos = curPos + idVec3(xDelta, yDelta, 1); // grayman #2356 - was '5'; reduced to keep goal positions from becoming too high for rats
		if (owner->MoveToPosition(newPos))
		{
			// Run with a 20% chance
			owner->AI_RUN = (gameLocal.random.RandomFloat() < 0.2f);
			_moveEndTime = gameLocal.time + 10000;	// grayman #2356 - 10s timeout on getting to your next position.
													// This keeps you from getting stuck trying to reach a valid goal
													// that's unreachable. I.e. the goal is on a ledge and the rat
													// trying to reach it falls off the ledge.
			break;
		}
	}
}
		break;

Notice how it only calculates x and y, but sets z to 1. No idea at the moment what even causes bats to fly vertically during animal patrol.

idVec3 newPos = curPos + idVec3(xDelta, yDelta, 1); // grayman #2356 - was '5'; reduced to keep goal positions from becoming too high for rats

 

  • Thanks 1
Link to comment
Share on other sites

1 hour ago, STRUNK said:

Because of the "fly_bob_vert" I put in probably?

Okay, looking at the def it becomes clear:

	"fly_bob_strength"		"500" 	// "How far flying creatures should bob"
	"fly_bob_vert"			"1"	// "Rate at which flying creatures bob up and down."
	"fly_bob_horz"			"0" 	// "Rate at which flying creatures bob left and right"

bob strength 500 means it adds up to 500 to the bat's current vertical velocity ( rotated by the bat's axis ) - so that explains why the bob is far too strong. If I set it to 1 the bats stay completely horizontal.

Link to comment
Share on other sites

On 1/15/2022 at 1:44 PM, Dragofer said:

would be quite straightforward to replace those hardcoded 1000 milliseconds with a variable derived from a spawnarg so you can disable it completely if you want (would cause zig-zag flying, probably fine for bats):

That sounds to me like a very good solution, but I don't know how to do that.

There is no zDelta: That's why the bats had no real vertical movement ( so I used fly_bob_vert to give them some):

		// Choose a goal position, somewhere near ourselves
		float xDelta = gameLocal.random.RandomFloat()*WANDER_RADIUS - WANDER_RADIUS*0.5f;
		float yDelta = gameLocal.random.RandomFloat()*WANDER_RADIUS - WANDER_RADIUS*0.5f;

Instead there is a 1, because the animal patrol is made for small walking animals:

idVec3 newPos = curPos + idVec3(xDelta, yDelta, 1); // grayman #2356 - was '5'; reduced to keep goal positions from becoming too high for rats

So I think, if I could change the waiting time, the wander radius (as in WANDER_RADIUS*x) for fast flying animals, and add a zDelta instead of using 1, or change the 1 to an other number, the bats wouldn't hang around anymore and wouldn't need the vertical bobbing.

The easy way would probably be to somehow set that they are drowning so they wouldn't wait anymore ..
 

 

Edited by STRUNK
Link to comment
Share on other sites

  • STRUNK changed the title to Help needed for Flying bats

I've made a rough experimental build that implements some new spawnargs, shown below with default values (if the entity doesn't have these spawnargs the code will fall back to these default values):

"wander_radius_horizontal"	"240"
"wander_radius_vertical"	"240"
"animal_patrol_fly"		"0"
"animal_patrol_wait"		"1"

Added a zDelta based on wander_radius_vertical but it doesn't seem to have any effect:

wanderRadiusH = owner->spawnArgs.GetFloat("wander_radius_horizontal", "240");
wanderRadiusV = owner->spawnArgs.GetFloat("wander_radius_vertical", "240");
...
// Choose a goal position, somewhere near ourselves
float xDelta = gameLocal.random.RandomFloat()*wanderRadiusH - wanderRadiusH*0.5f;
float yDelta = gameLocal.random.RandomFloat()*wanderRadiusH - wanderRadiusH*0.5f;
float zDelta = owner->spawnArgs.GetBool("animal_patrol_fly", "0") ? gameLocal.random.RandomFloat()*wanderRadiusV - wanderRadiusV * 0.5f : 1;

idVec3 newPos = curPos + idVec3(xDelta, yDelta, zDelta); // grayman #2356 - was '5'; reduced to keep goal positions from becoming too high for rats

The spawnarg for waiting, however, does work as intended.

Anyway, you can use these modified files to make the build for yourself using this compilation guide from the TDM wiki. Compiling a build is very quick (1 button) once you've got it setup.

AnimalPatrolTask.hAnimalPatrolTask.cpp

  • Thanks 1
Link to comment
Share on other sites

On 1/17/2022 at 12:52 PM, Dragofer said:

I've made a rough experimental build that implements some new spawnargs, shown below with default values (if the entity doesn't have these spawnargs the code will fall back to these default values):

Thanks a lot! I'm gonna try if I can compile it and make it work locally, then I can try to tweek it.

Update: I managed to compile with your experimental build and it works. Only thing I got a warning " Cannot detect SVN version " in the console, but I guess it has to do with the latest source I got with the turtoiseSVN (and having the latest available update of 2.10 installed (via the TDM installer) and those are not the same.
Nontheless, the animal_patrol_fly works so things are looking good. Tomorrow morning I'll go do some fiddling around : ) (Yes I have a fresh install for this so I can't f*ck-up my working game).
 

Edited by STRUNK
Link to comment
Share on other sites

On 1/18/2022 at 3:36 PM, STRUNK said:

Thanks a lot! I'm gonna try if I can compile it and make it work locally, then I can try to tweek it.

Update: I managed to compile with your experimental build and it works. Only thing I got a warning " Cannot detect SVN version " in the console, but I guess it has to do with the latest source I got with the turtoiseSVN (and having the latest available update of 2.10 installed (via the TDM installer) and those are not the same.
Nontheless, the animal_patrol_fly works so things are looking good. Tomorrow morning I'll go do some fiddling around : ) (Yes I have a fresh install for this so I can't f*ck-up my working game).
 

Nice - but I assume you still have a high bob_strength? When I set that to 0 or 1 the bats still stay completely horizontal, so the addition of zDelta isn't having any effect unfortunately.

For the SVN version, you need to make sure you've installed TortoiseSVN with one of the options selected as mentioned in the wiki article. But it's stopped working for me - or maybe it just never worked on this particular PC.

Link to comment
Share on other sites

9 hours ago, Dragofer said:

Nice - but I assume you still have a high bob_strength?

No I got rid of the bobbing completely and I still got them schoosing new positions in all axis, so it works it seems.
I changed some things though:
 

// Choose a goal position, somewhere near ourselves
float xDelta = gameLocal.random.RandomFloat()*wanderRadius - wanderRadius*0.5f;
float yDelta = gameLocal.random.RandomFloat()*wanderRadius - wanderRadius*0.5f;
float zDelta = owner->spawnArgs.GetBool("animal_patrol_fly", "0") ? gameLocal.random.RandomFloat()*wanderRadius - wanderRadius*1 : 1;	

Also I found that the wanderRadius was just fine so I got rid of the wanderRadiusH and V and just used the default 240.

The wait does work but doesn't do very much, but it does enough I think. It could be a boolian I think, so normal wait or no wait.

The big thing is that in animal patrol mode they go into idle for like 15 seconds some times, and just stay hovering too long.
I tested that by setting anim idle to the AF pose., and clearly see them going into idle for much too long. Also this idle state stops movement (only plays the anim).

With anim idle ste to the AF pose I see that the wait does work, otherwise they go into idle for a short time.

Latest cpp and map I used: (Didn't change the .def but used the spawnargs in the entity inspector)

AnimalPatrolTask.cpp Bat.map

Edited by STRUNK
Link to comment
Share on other sites

2 hours ago, STRUNK said:

I changed some things though:
 

// Choose a goal position, somewhere near ourselves
float xDelta = gameLocal.random.RandomFloat()*wanderRadius - wanderRadius*0.5f;
float yDelta = gameLocal.random.RandomFloat()*wanderRadius - wanderRadius*0.5f;
float zDelta = owner->spawnArgs.GetBool("animal_patrol_fly", "0") ? gameLocal.random.RandomFloat()*wanderRadius - wanderRadius*1 : 1;	

That's weird, I read your change to zDelta's calculation as resulting in it being anywhere between 0 to -240 in Z from the bat's starting position - whereas previously it was -120 to +120. Definitely good to hear it does work for you, though.

Btw if you change variables that are shared between functions you also have to update the .h file - only attached the .map and .cpp here. Would also make sense to attach your version of the .def file.

2 hours ago, STRUNK said:

I got the newest SVN, but its newer than the latest available update via th installer, but it seems not to matter in this case.

I actually meant the TortoiseSVN client - it has a checkbox during installation to include the revision number.

Link to comment
Share on other sites

9 hours ago, Dragofer said:

That's weird, I read your change to zDelta's calculation as resulting in it being anywhere between 0 to -240 in Z from the bat's starting position - whereas previously it was -120 to +120.

Well maybe it doesn't work better then but could be I saw more significant movement at times with bats going down : )
In that case, the wanderRadiusV and H should be there and V should be twice H ... I guess.

Link to comment
Share on other sites

@Dragofer
I  put your original files back and compiled again and set the wander_radius_vertical to 480 and to me it seems they are using more vertical movement in combination with the animal_patrol_fly then without these changes.

The existing fly_seek_scale spawnarg also seems to have influence. I think set to 1 or 2 has a good result.

So the only significant bad bat behaviour is the long idle they go into sometimes.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 3 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
×
×
  • Create New...