We-the-People-civ4col-mod / Mod

This is the repository where the mod resides.
91 stars 37 forks source link

NMS. when meeting with an enemy, automated ships continue to move if they were not attacked #519

Open MrZorG33 opened 2 years ago

MrZorG33 commented 2 years ago

maybe to make the same check for them as for the scouts? for obvious reasons, unfortunately, I cannot provide screenshots.

but I don’t know if the automatic ships should stop if they encounter ground enemies.

raystuttgart commented 2 years ago

Ok I am confused now ... (Your description does not really explain it to me.)

What do you actually want?

  1. Should it stop, after it spotted an Enemy Unit? (End turn) --> Possible (Thought it was already the case)
  2. Should it stop, while it spots an Enemy Unit during a single move? --> Not possible (Would kill performance)
  3. Should it continue moving automatically after the Enemy is gone? --> Not possible (Command data already lost)
MrZorG33 commented 2 years ago

Should it stop, after it spotted an Enemy Unit? (End turn) --> Possible (Thought it was already the case) it used to be so, but now it is not. you can check it in any of your games.

raystuttgart commented 2 years ago

Ok, I can take care of that.

raystuttgart commented 2 years ago

Please take a look at Trade Route Advisor. There is a command COMMAND_IGNORE_DANGER

Did you set that? Because that triggers your Automated Units to ignore danger.

If you do not set it, they will stop at danger.

Summary: Most likely they just do what you told them in the Trade Route Advisor. (For more information see below)

raystuttgart commented 2 years ago

The Trade Route Screen has this button: (Please check it.)

Civ4ScreenShot0002

If the Units (assigned to Trade Routes) do not stop, then it is because of the Automated Trade System not properly working anymore. (And I do not know enough to repair the automated Trade Route System - I never use it and I thus can not really fix / implement stuff for it.)

Generally if you tell the Units to stop when a danger appears, it should. (At least that is what the code says.) But you could of course also tell a Unit not to stop. (Both settings are possible.)

Please check how you have set up your Trade Routes.

And I am really sorry: But the Automated Trade Route System has been changed so often, I really do not know anymore what works and what does not. (It was originally implemented by Koma13, but many other people later worked on it.)

Summary: Automated Trade Route System bugs is nothing I will touch. (Since I do not understand it, it is to risky that I mess it up even more.)

raystuttgart commented 2 years ago

@MrZorG33 Please check if the setting in Trade Route Screen works. (If not, there is a bug in the Trade Route System.)

MrZorG33 commented 2 years ago

@raystuttgart I did not mean sea trade routes. I spoke about the automatic exploration of the ocean, when I give any ship a task to automatically engage in the exploration of the territory.

MrZorG33 commented 2 years ago

on land yes, automated wagons stop if there is a danger nearby and if "ignore danger" is not enabled. scouts also stop if there is danger in their line of sight, although not always. I noticed that the scout has some kind of promotion for strength, he does not stop when dangers appear (for example, wild animals guarding goodies), but begins to attack them. this is also a question for discussion. for me it would be preferable if the scout stopped anyway and I myself decided what to do next, because sometimes the "goodies guards" need to be bypassed from the other side so as not to attack across the river.

raystuttgart commented 2 years ago

Ok, now that I know that it is about "Automated Scouting of Ships" I understand. But that context was simply missing thus I really could not understand what you wrote about.

There are lots of different types of Automation.

So without getting the information you gave now, it was almost impossible for me to understand what you wanted. :) (Please be more specific next time, otherwise we turn in circles like we did here.)

Summary: Now I know what you want. And yes I can do it.

MrZorG33 commented 2 years ago

I don’t know if this has been fixed, but now I’m faced with the following situation: a unit (native mercenary), automatically moving to a point (to a colony), having detected an enemy (an escaped native slave) did not stop, but continues to move. image

raystuttgart commented 2 years ago

No, this has not been implemented / fixed yet. Otherwise there would have been an update. Too much stuff to do right now and too little time.

MrZorG33 commented 2 years ago

I hope it's appropriate to point it out here. Automated Trade Ships sailing from Europe to the colonies also do not stop when they see an enemy ship in sight. image

these two merchant ships sailed past the enemy schooner, ignoring the danger. I only noticed this because my Frigate "wake up".

MrZorG33 commented 1 year ago

I will update the comment in this issue so that it is not lost. my Corvette explored the area in automatic mode and met Privateer. but he did not stop, but continued to move. image

MrZorG33 commented 1 year ago

@devolution79 , could you take a look at this problem? the statement in the ticket header is valid for the new movement system (NMS). I consider this problem to be one of the key ones. after solving it, you can make NMS as the main one (even if there are some other problems - they are not critical).

devolution79 commented 1 year ago

If an automated unit fails to stop its automation while detecting "danger" then it's likely that there's a missing check or a failure to detect danger at all. This is bit strange since I thought this was a working feature that we've inherited from vanilla ? Perhaps there's been a recent change to the checks regarding hidden nationality ?

devolution79 commented 1 year ago

Was there a change when the buccaneer was added ?

MrZorG33 commented 1 year ago

it makes no difference whether it is a ship with a hidden nationality or not. the ship ignores any enemy unless it attacks it.

devolution79 commented 1 year ago

So the problem applies to all automation types, like explore and sail to Europe ? It is likely that CvUnitAI::AI_breakAutomation() is the culprit. Let's see if AdvCiv is bit more clever here...

devolution79 commented 1 year ago

Ok, I think I see it now. We need to totally rewrite it since it gets everything wrong :rofl:

MrZorG33 commented 1 year ago

yes, any automated movement.

devolution79 commented 1 year ago

I just did some tests to determine if an automated ship will stop its automation if an enemy is detected. Currently we have the following automation types for ships:

  1. Full (automation)
  2. Sail to Europe/Africa(/Port Royal)
  3. Explore
  4. Traderoutes

Result: I can confirm that there is no check for detecting danger for case 2) (i.e. no check for CvUnitAI::AI_breakAutomation) so a ship sailing to Europe will happily attempt to sail past pirates :( This is obviously not intended so I will implement a fix.

For the other cases, the danger check does work so I am not able to reproduce the exploration example you provided. However, from the picture I can see that the Corvette is out of movement points and the pirate is 2 plots away. AI_breakAutomation will not stop the automation in this case. Even though the pirate is within the 2-plot danger range, the check is only applied when the unit still has movement points left. If the corvette had an extra movement point then I'm sure that automation would have stopped since when the corvette would have detected the pirate when it was about to perform its last move and this would have ended the automation.

Regarding the NMS I don't see how it should have any effect with respect to stopping automation.

devolution79 commented 1 year ago

I suppose you could argue that the danger detection range should be farther than 2 plots. Even though the visibility range of ship is usually 2 plots, there could still be friendly units beyond that range that could act as "spotters"

MrZorG33 commented 1 year ago

I will try to provide a save that will show that the security check in points 3 and 4 does not work.

by the way, I don’t understand point 1

MrZorG33 commented 1 year ago

ship of the line sailed from Europe. There was an enemy pirate frigate on his way. the ship of the line did not stop when it noticed the threat. image

load your save, skip all the dialogues and go to the marked location. press Ctrl+A to force all automated units to continue moving. AutoSave_AD-1509-Oaa.zip

MrZorG33 commented 1 year ago

accidentally closed)

MrZorG33 commented 1 year ago

hmm.. when loading he chose a different route, but this does not change the essence) image

devolution79 commented 1 year ago

Which automation type did you use ? Are you using goto city ?

MrZorG33 commented 1 year ago

yes, I sent it from Europe to the city

devolution79 commented 1 year ago

Ok, didn't test goto city

devolution79 commented 1 year ago

OK, I confirm that we likely have several issues here: The goto menu choice ends up calling: gDLL->sendPushMission(info.getData1(), MISSION_MOVE_TO, pCity->getX(), pCity->getY(), 0, false);

There are two problems with this approach: 1) It does not set any of the pf flags to avoid danger so any path is ok, even a dangerous one 2) Since this ends up as a "simple" pushmission there is no automate type set and thus there is no check for breakAutomation

devolution79 commented 1 year ago

I suppose that we could create a new automate type e.g. AUTOMATE_GOTO_CITY

devolution79 commented 1 year ago

Perhaps the real problem is that ships have a high amount of movement points. This means that a ship could encounter an enemy unit in the middle of its 7 moves (say on move 4) but since it has queued a move command for all its moves it does not check for danger until the start of its turn and then the ship may already sailed past an enemy!

MrZorG33 commented 1 year ago

I suppose that we could create a new automate type e.g. AUTOMATE_GOTO_CITY

Will my assumption be correct that ships transporting cargo from one colony to another (in auto mode) will follow the same AUTOMATE_GOTO_CITY rule?

in any case, why on land does a scout in auto mode stop, even if it still has movement points, but ships don’t?

devolution79 commented 1 year ago

I am testing an automatic mission abort feature (human only) that probably works like you want. The downside is that if danger is detected then you cannot just start another automated move so you'll have to take manual action either by destroying the threat or retreating.

devolution79 commented 1 year ago

@MrZorG33

in any case, why on land does a scout in auto mode stop, even if it still has movement points, but ships don’t?

Scouts on land probably push single moves so danger is checked per move point rather than per turn. The goto city feature only checks for danger within 2 plots before starting the mission. So if the ship has 7 moves it could end its turn right next to a pirate since danger is not checked while it is moving. But like I stated above, I've now implemented a check per move

MrZorG33 commented 1 year ago

I am testing an automatic mission abort feature (human only) that probably works like you want. The downside is that if danger is detected then you cannot just start another automated move so you'll have to take manual action either by destroying the threat or retreating.

no, scouts can have 4 movement points. and he, noticing the danger, can stop, even if he has spent only 1 or 2 of them.

devolution79 commented 1 year ago

That's what I meant. The AI logic for automated scouts queue individual moves. So it goes like this check for danger, move, check for danger, move, etc. . The problem with the goto city automation is that it does this: check for danger within visibility range, if no danger then then it queues up all the moves without checking for danger per move

devolution79 commented 1 year ago

@MrZorG33 I really need a tester so I can push the current changes to a branch for you to test ;)

MrZorG33 commented 1 year ago

That's what I meant. The AI logic for automated scouts queue individual moves. So it goes like this check for danger, move, check for danger, move, etc. . The problem with the goto city automation is that it does this: check for danger within visibility range, if no danger then then it queues up all the moves without checking for danger per move

this means we need to make the same logic for ships as for scouts)

@MrZorG33 I really need a tester so I can push the current changes to a branch for you to test ;)

which branch should I download?

devolution79 commented 1 year ago

This is the new behavior. Consider the caravel that is about to sail to Quebec image

After executing the move-to Quebec the caravel now stops here: image

devolution79 commented 1 year ago

Previously it would sail straight to Quebec (which would be ok in this instance since the Caravel has enough moves to reach safety) However, a combat ship would also stop when it detects the pirate and I suppose that is what we want.

MrZorG33 commented 1 year ago

a ship without upgrades has a viewing radius of 1. In this case, it is clear why the caravel stopped next to the pirate frigate. but if the caravel has a promotion that gives it +1 to vision, will it stop next to the pirate frigate or 1 tile before it?

devolution79 commented 1 year ago

Yep, I am using the unit's visibility range so promotions will factor in.

MrZorG33 commented 8 months ago

I remind you that there is such a problem (= авто-фрегат игнорирует капера