trader5050 Posted October 16, 2021 Report Share Posted October 16, 2021 Hello, I'm trying to expand upon the Miami Mod patrol capability by having units self-direct to incidents. The problem is that I can't seem to identify anything/anyone. I'm trying: GameObjectList list = Game::GetGameObjects(); for(int i=0; i<list.GetNumObjects(); i++) { GameObject obj = list.GetObject(i); /* cars */ if (obj.GetType()==TYPE_VEHICLE) { } /* people */ if (obj.GetType()==TYPE_PERSON) { /* injured? */ Person prsn(&obj); if (prsn.IsInjured() || prsn.IsComatose()) { Mission::PlayHint("Found an injured person!"); somethingToDo=true; } } /* start chase */ if (somethingToDo) { Mission::PlayHint("Found a rescue activity!"); sendRescue(v,obj); break; } } I was also checking for gangsters, etc., but nothing ever triggers. Any help is appreciated! Quote Link to comment Share on other sites More sharing options...
itchboy Posted October 16, 2021 Report Share Posted October 16, 2021 1 hour ago, trader5050 said: You need to have that piece of code repeat every second or so in order for the game to actually detect things that AI can auto-dispatch to. With that in mind, the script must also be smart enough to know that the function for dispatching only needs to execute once and never again, and the vehicle itself can be interrupted by user input. I don't recommend using the full GetGameObjects list as it lags the game out when run at a constant pace. Other issues you may come across is effectively parking the unit once on scene, and considerations like "what if the gate at the station is closed" or "what if this vehicle AI pathfinding gets stuck" Quote Link to comment Share on other sites More sharing options...
trader5050 Posted October 16, 2021 Author Report Share Posted October 16, 2021 Is there anything I can force to run every second? Only thing I can think of atm is force deploying an invisible object that runs in a loop with a 1 second sleep. Quote Link to comment Share on other sites More sharing options...
itchboy Posted October 17, 2021 Report Share Posted October 17, 2021 4 hours ago, trader5050 said: Is there anything I can force to run every second? Only thing I can think of atm is force deploying an invisible object that runs in a loop with a 1 second sleep. This is it actually, the only way to do anything on a repeat basis. Repeat/recursion scripts are known to lag the game badly as explained. Be sure to tread carefully from this point forward. 1 Quote Link to comment Share on other sites More sharing options...