Jump to content
Moon_chilD

Make AI keep disableAI "Path" on Zeus disconnect

Recommended Posts

Hey, 

 

this is my third and hopefully last issue related to Zeus. 

I love using disableAI "Path" or for a matter of fact "forcespeed 0" to keep AI where they are (e.g. in guard towers).
I achieve that by placing a Zeus Module above a unit and apply disableAI "PATH" on them. Works just fine. The issue now is, the second I leave the server (be it a crash or any other reason) the unit starts walking again.

I know why. I know the command is executed locally and need to be executed again if locallity changes. Thatis why I build in a Eventhandler into my code (Here). But it doesn't work. 

Do you guys have an idea how I an get it to work so the AI keeps disableAI "PATH" even if the Zeus disconnects? Maybe there is an Error or oversight in my code. 

 

Your help is much appreciated, thanks a lot in advance! If you have questions just ask.

One more thing, I know my code might be ugly or not the most efficient or even 100% correct. I'm very open to criticism since I'm still in a learning process.

Many Greetings
Moony

Share this post


Link to post
Share on other sites

Why don't you script a  this disableAI "path" directly in the init field of the AI?

As side note: There is no reason an AI shifts from server to client, except if you make it join a player (so no interest for keeping an AI disabled).

 

 

Share this post


Link to post
Share on other sites

In my experience, EnableAI/DisableAI commands are bugged. I'm not sure how this bug triggers, but it causes the feature to never toggle anymore.

I recommend that you always check before enabling/disabling an AI feature, and only change it if it doesn't match your desired state:

if (AI checkAIFeature "Path") then {AI enableAIFeature ["Path", false]};

I haven't noticed the bug after using this method.

 

I'm not sure what was actually wrong with your code, but if you don't manage to find a fix, I suggest you use the "PathCalculated" event handler to disable the AI's path when a new path is generated.

Share this post


Link to post
Share on other sites

@pierremgi I don't put it directly into the units init field because I'm talking about Zeus spawned units. And the issue only appears when the Zeus leaves the Server.

@Leopard20 I will try your two options. 
I don't have a direct check if the AI is disabled or not but I have a variable that is set on the AI accordingly (though checkAIFeature is a bit more elegant)

I'll report back if it works or not!

Share this post


Link to post
Share on other sites

Ah OK, I can see your code now and it seems you are using a mod with custom module. The first hint is that kind of code you should run on local Zeus PC, not everywhere. Furthermore, you make public and remoteExec everywhere some variables. That's weird.

Imho, You should remoteExec, not remoteExecCall such code.

 

Your spawned AIs belongs to Zeus (locality). A simple code from Zeus' PC should work to disable these AIs. If you still notice a change on their behavior while the owner (Zeus) disconnects, so when they are managed by server, you could manage this change for locality in advance. I mean, if you don't care to keep the control of the disabled AI by zeus, what I suggest is to transfer the ownership (setOwner) of these AIs to server prior to disabling them.

Share this post


Link to post
Share on other sites

The remoteExecCall is only to register the Zeus Module through ZEN. Quite frankly I haven't gotten around to figure out how to create my own Zeus modules independently (and especially for those that use a UI) 😁

I think the locality is the huge issue here....for me. I have absolutely no idea when what is local to what.
But this kinda gives me an idea. I think I'm going to try to remoteexec the code (disabelAI) only on the object (so basically where it is local)...at least this is what I get from your answer.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×