Jump to content
The Dark Mod Forums

Help needed for Flying bats


STRUNK

Recommended Posts

Made a test setup with different hights, and the bats are looking good and making use of the vertical space, but still there is this idle problem.
I'm thinking maybe, if a bat goes into idle, it gets deleted and a new bat spawns at that location .. or the bat just goes invisible until it goes out of idle?
Video:
https://cdn.discordapp.com/attachments/815315205483397142/933467525935673445/2022-01-19_22-03-24.mp4

Edited by STRUNK
Link to comment
Share on other sites

I think you need to add some debug messages to the code to help figure out which state the bats are in when they freeze. Can add this line into each of the states, substituting the dots for the name of the state:

gameLocal.Printf( "currently in state: .... \n" );

Would be a useful clue for figuring out where the code goes wrong.

This debugging works best if you only have 1 bat in your map.

  • Thanks 1
Link to comment
Share on other sites

On 1/19/2022 at 1:34 PM, Dragofer said:

think you need to add some debug messages to the code to help figure out which state the bats are

I really don't know much lol : D
Where does it print to/where can I see the states/tasks? I thought I could see it in the console but nothing happens there ..


Ok I got something printing to the console now. Think somehow my setting in Virtual Studio were wrong.

Edited by STRUNK
Link to comment
Share on other sites

Things are getting better: the bats now only " freeze"  when they hit "me", something you can also see in the latest video, but there they were freezing in other places also.
 

	if (owner->AI_MOVE_DONE) 
	{
		// We've reached the destination, wait a bit
		switchToState(statePreMovingToNextSpot,owner);					//This was: sswitchToState(stateWaiting, owner);
gameLocal.Printf( "currently in state: MovingToNextSpot-REACHED\n" );

This way it affects the rats too but i'll try to figure out how to put it in the script where it only optionally affects animal patrol by a spawnarg. (animal_patrol_wait as a boolian probably, and get rid of your original animal_patrol_wait).

The "states" where the bat is in most of the time is: // grayman #2356 - if you're far from the goal, run. This keeps rats from slow-hopping great distances.
And: // Still moving, maybe turn a bit
(These are part of the AnimalPatrolTask::movingToNextSpot)
I also changed the code for the turning a bit, to have more turning vertically, and that seems to work for more vertical movement of the bat:

			// Still moving, maybe turn a bit
			owner->Event_SaveMove();

			float xDelta = gameLocal.random.RandomFloat()*20 - 10;
			float yDelta = gameLocal.random.RandomFloat()*20 - 10;
			float zDelta = owner->spawnArgs.GetBool("animal_patrol_fly", "0") ? gameLocal.random.RandomFloat() * 40 - 20 : 1; //Was also 20 - 10     														//EDITED
gameLocal.Printf( "currently in state: MovingToNextSpot-still moving, maybe turn\n" );


Conclusion:
Although getting rid of going to stateWaiting seems to be a little improvement, THAT was not the problem of the freezing: The other AI in the map; the rats, and I tested with some other AI, cause the freezing of the bats.
Somehow the bats "freeze"  when they hit an other AI, but not when they hit eachother ..

 

Edited by STRUNK
Link to comment
Share on other sites

32 minutes ago, STRUNK said:

animal_patrol_wait as a boolian probably, and get rid of your original animal_patrol_wait

animal_patrol_wait can already be used like a boolean - if you set it to 0 the bats will never wait, if you set it to 1 the bats will wait 1s which happens to be the default. Imo turning it into a boolean would be a step backwards that deprives mappers of the ability to set different waiting times.

Also, I would change the flow of the code as little as possible. It's likely better to go into the wait state and use a wait time of 0 so that there's no or minimal delay. In TDM code, waiting usually works by checking the clock to see if the current time is now equal to or larger than (start time + wait time), so if wait time is 0 that's immediately satisified.

39 minutes ago, STRUNK said:

The "states" where the bat is in most of the time is:

Did you also see what state the bats are in when they are frozen?

Link to comment
Share on other sites

10 hours ago, Dragofer said:

Did you also see what state the bats are in when they are frozen?

No, for the time the bat is frozen nothing is printed to the console, though it could be I did not have the debug line of code placed for  all different "states".
First I'm gonna look at the spawnargs I put in for trying to make the bats nonsolid/fly through the player. That might have been a bad Idea for they would also fly through other AI, and it didn't work anyway : )

 

Link to comment
Share on other sites

@Dragofer
I found a way to not have these bats "freezing" : setting all acuity spawnargs to 0.
So I guess the freeze is caused by going into some sort of alert state?
It feels to me that, although this can be a solution, there is something else wrong with the bats, for they just shouldn't care about anything. Rats seemingly don't care if they see, hear or touch an other AI ...
 

  • Like 1
Link to comment
Share on other sites

On 1/19/2022 at 6:53 AM, Dragofer said:

so the addition of zDelta isn't having any effect unfortunately.

I think you are right Dragofer.
I'm playing with the the wander_radius and the fly_seek_scale, and it looks to be the fly_seek_scale is the only thing that influences the (chance for?) vertical movement. (Not vertical bobbing but this seek scale was influencing vertical movement in my map/settings, that's why we got different results I guess)

A fly_seek_scale above 1 seems to result in no significant vertical movement at all, under 1 it's occuring more often. The latest video was with a value of 0.1 I think. These bats are really using the vertical space, as they should, but fly long "straight" streches,  bumping their heads against the walls a lot. With a value of 10, they won't go significantly up or down, fly too short streches and look really nervous.
fly_seek_scale 0.5 looks quite good btw, but I'm still wondering what fly_seek_scale actually does?

That said, if your "animal_patrol_wait" could be added to 2.10, animal_patrol bats can be an option for mappers.
Bats don't like small spaces anyway, only to sleep in; these bats don't sleep. (fly_seek_scale works good enough?)
Making the bats not damageable  is a good solution to not deal with ragdolls and such.
Making the bats without senses (all acuity is set at 0 (for bats don't care)), for me, seems a good solution for an AI that is basically meant for decorative purposes, like cricket sounds and flies in toilets.



 

Edited by STRUNK
Link to comment
Share on other sites

3 hours ago, STRUNK said:

but I'm still wondering what fly_seek_scale actually does?

I've glanced in the code earlier today - "seek" seems to have to do with predicting where the AI will be in x seconds based on current position and velocity. I'd assume if you set a high value it'll look far ahead and change course long before it would fly into an obstacle.

3 hours ago, STRUNK said:

That said, if your "animal_patrol_wait" could be added to 2.10, animal_patrol bats can be an option for mappers.
Bats don't like small spaces anyway, only to sleep in; these bats don't sleep. (fly_seek_scale works good enough?)

We're really far advanced in the 2.10 cycle, but something like this seems quite minimally invasive, especially since the code would continue to use old default values unless the AI has that new spawnarg. More complicated stuff like zDelta would be too risky, so would have to use existing methods for vertical movement.

3 hours ago, STRUNK said:

Making the bats not damageable  is a good solution to not deal with ragdolls and such.

A ragdoll is basically a string of collision meshes bound to the joints of an AI. Could try out the AF Editor for giving the bat 3 simple collision meshes around its body + wings.

Link to comment
Share on other sites

On 1/21/2022 at 4:14 PM, Dragofer said:

"seek" seems to have to do with predicting where the AI will be in x seconds based on current position and velocity.

Here a video of fly_seek_scale 1, 4 and 10
1
https://cdn.discordapp.com/attachments/815315205483397142/934550666058285076/2022-01-22_21-39-13.mp4
4
https://cdn.discordapp.com/attachments/815315205483397142/934550792365564004/2022-01-22_21-41-20.mp4
10
https://cdn.discordapp.com/attachments/815315205483397142/934550925014614047/2022-01-22_21-43-17.mp4

 

On 1/21/2022 at 4:14 PM, Dragofer said:

something like this seems quite minimally invasive

I think it will be a welcome addition : )
(Beta) Bats will be released ofc.
 

 

On 1/21/2022 at 4:14 PM, Dragofer said:

A ragdoll is basically a string of collision meshes bound to the joints of an AI.

I tried "burnaway"  "0" and  "burnaway" "1" with no result. I think Bats might just burn away in green flames, but I don't know how to do that yet.

Link to comment
Share on other sites

31 minutes ago, STRUNK said:

I tried "burnaway"  "0" and  "burnaway" "1" with no result. I think Bats might just burn away in green flames, but I don't know how to do that yet.

You can set a "death_script" spawnarg on the bats so a script is called when a bat dies. The cleanest way would be to make a small scriptobjection extension that inherits from the bats' existing scriptobject and only contains a script function that's called by that spawnarg - see Scriptobjects section of the A to Z Scripting guide for how to set that up.

  • Thanks 1
Link to comment
Share on other sites

19 hours ago, STRUNK said:

I think it will be a welcome addition : )
(Beta) Bats will be released ofc.

I've committed the "animal_patrol_wait" spawnarg with rev 9810 - it should be in 2.10b5 onwards.

  • Like 1
Link to comment
Share on other sites

On 1/22/2022 at 1:46 PM, Dragofer said:

You can set a "death_script" spawnarg on the bats so a script is called when a bat dies. The cleanest way would be to make a small scriptobjection extension that inherits from the bats' existing scriptobject and only contains a script function that's called by that spawnarg - see Scriptobjects section of the A to Z Scripting guide for how to set that up.

It has been a long time since I've been scripting anything and I'm doing something wrong I guess .. for my script doesn't work/exist.
I included it in the tdm_custom_scripts.script and so far it goes well: the game starts : )
It's a very little testscript for now only to verify if it works.
 

object ai_bat  : ai_darkmod_base

{
void batDeath();
};

void ai_bat::batDeath()
{
sys.println(" a bat has been killed");
}

I also set up a trigger timer targeting a target callScriptFunction with "call" "batDeath" .. but it prints in the console that batDeath does not exist ..

I looked at requiem's scripts and I cant find anything obviously wrong with my setup ...

 

9 hours ago, Dragofer said:

I've committed the "animal_patrol_wait" spawnarg with rev 9810 - it should be in 2.10b5 onwards.

Great!

Link to comment
Share on other sites

Link to comment
Share on other sites

4 minutes ago, STRUNK said:

I also set up a trigger timer targeting a target callScriptFunction with "call" "batDeath" .. but it prints in the console that batDeath does not exist ..

This wont work because batDeath isnt a global script function, but part of a scriptobject. You can look at the security camera "4-button" prefabs to see how to call object functions on an entity with a callObjectFunction entity.

  • Thanks 1
Link to comment
Share on other sites

9 hours ago, Dragofer said:

it looks like you might not have updated the bat's "scriptobject" spawnarg?

I only added "death_script" "batDeath" but I had to also make the scriptobject "ai_bat" instead of "ai_darkmod_base". 
Finally it all makes sense to me. I really didn't totally understand what you meant by the cleanest way etc : D

Btw. did I ever tell you that I really appreciate your help? You should get a statue for that or something!

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

9 minutes ago, STRUNK said:

Btw. did I ever tell you that I really appreciate your help? You should get a statue for that or something!

Well, TDM is getting a bat and maybe also an ambient AI out of this, so well worth 😛

  • Like 1
Link to comment
Share on other sites

9 hours ago, Dragofer said:

Well, TDM is getting a bat and maybe also an ambient AI out of this, so well worth

I'm thinking to also make a very simple flying AI that is actually only a origin bone, and, if needed a body bone, and if needed some other minimal requirements so mappers can bind things to it, like fireflies ... I saw someone made a bunch of different colored firefly stuff already but I haven't found an AI for it. Is someone working on such a thing already?
 

Link to comment
Share on other sites

1 hour ago, STRUNK said:

I saw someone made a bunch of different colored firefly stuff already but I haven't found an AI for it. Is someone working on such a thing already?

Those are simply animated invisible models with a particle bound to them - no AI involved there. It's quite an efficient way  to make such ambient creatures if they don't need to travel too randomly.  They can also go on quite long paths this way.

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

    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 1 reply
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
×
×
  • Create New...