There is a doCombat function in CvGameUtils.py. What I want to understand is when this function is actually triggered. Is it when a specified unit enters a plot (ie the pDestPlot)?
OK no takers. Here is my delema: I am using the OnUnitMove function in the CvEventManager.py file to detect when a unit moves onto a specified plot. The problem is the function tests every unit from opponent players. As the game goes on the function takes longer and longer, as more units are created. By the time you get to the modern era, the time it takes to process this function is way too long.
What I want to do is reverse the check. Instead of checking every unit, I'd rather test the plot and trigger an event if unit from an opponent moves into the plot. In this way the function wouldn't run, until the event takes place. Is there a way I can do this in Python and or XML?
With no other options, I stripped down the function to bare bones code (just 2 lines) and moved out all of those prechecks, which made a huge difference in performance. If the one line check is true, then it runs the 2nd line, which is the execution code, now moved into a separate function. The result: Turns are much faster even on a huge map and I can finish a game out now.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.