Follow and Cover

Hambil

Emperor
Joined
Oct 16, 2006
Messages
1,100
Set a combat unit to automatically follow the nearest non-combat unit, and provide cover for it when it stops. Handy for helping protect workers from barbarians.

It doesn't use scouts, only non-scouting combat units. To stop the automated action just move the combat unit manually, or perform some other action on it.

Due to game mechanics (pathing issues) your civilians will always have some vulnerability to capture while moving. But the two units will move together on the same turn if possible, so the civilian is always covered if there are no pathing issues.

Make sure you finish any current games before updating from an older version of Follow and Cover, or your saved games may not load.

This mod changes UnitPanel.lua and will conflict with any mods that change that file.

Beta release.
 

Attachments

  • followandcover.jpg
    followandcover.jpg
    29 KB · Views: 169
  • 8930_2013-04-13_00001.jpg
    8930_2013-04-13_00001.jpg
    343.5 KB · Views: 448
  • Follow and Cover (v 4).civ5mod
    13.3 KB · Views: 182
Okay, now I've decided to go ahead with the UI part myself. I actually built a simple unit, and that worked, but... it's just not what I want. I want the ability to be available for all existing combat units like in days of old. So, I am now learning how to add buttons and listen for button clicks and fire custom events weeeeee!

I know, I'm like a dog with a bone, and probably just talking to myself here. But, I'm having fun so I'm kind of okay with that :p
 
Okay, now I've decided to go ahead with the UI part myself. I actually built a simple unit, and that worked, but... it's just not what I want. I want the ability to be available for all existing combat units like in days of old. So, I am now learning how to add buttons and listen for button clicks and fire custom events weeeeee!

I know, I'm like a dog with a bone, and probably just talking to myself here. But, I'm having fun so I'm kind of okay with that :p

If you're trying to do that directly in UnitPanel.lua/xml you're playing with fire IMHO as just about every button in there is added as a consequence of a unit being able to handle a command, perform an action, or build something so the entire display is highly dynamic. Also, there are are two versions of the xml, it being one of the few UI contexts that have a _small variant.
 
Okay I think this works well enough for an alpha. But, I'd like (gentle request, I know everyone is busy) some other eyes on it before I upload it to thousands of Steam users. I figure I'll add more configurability in version 2.

In play testing so far I've run into only a few small issues, but obviously more play testing is needed. This can be moved to the Mod forum if you'd like since it's going to be an active mod soon, or is now.
 
There is a flaw, but I think I can live with it. The flaw is as follows:
1. DoTurn is called.
2. Escorting unit see it's sitting on a civilian and fortifies.
3. DoTurn ends and the automated worker moves.
4. Next turn the escorting unit moves to cover again, but the civilian has been left exposed for a turn.

I don't think I can work around it, it's just hard coded game machanics. But, the workers still get a lot more cover than without the mod (or without manually covering them). So I still think it's worthwhile. Especially the cover they get while building improvements.
 
Which is a variation of what I was trying to get at in post #7 here - http://forums.civfanatics.com/showthread.php?t=493078 ;)

Yes, expect since civilian units (to my knowledge) can't get terrain movement bonuses (without another mod interferring) then the combat unit should always have enough moves to catch up and cover. But there is certainly a window for capture in there. :( Mostly I added the 'always move to cover' flag so that things around a city with multiple workers and escorters, work smoother. With always move to cover set off, they don't swaps workers around. In fact, now that I know I can't work around the queue order issue, I think I'll remove the flag and just have them always stick to their civilian.
 
My worker if off to the gold fields. Unfortunately it's going to take their Spearmen guards 9 turns and a battle to get there!



By which time they'll be working the iron to the west of the horses
 
Won't automation on both be broken when they approach the barbarian camp? I don't mind if the mod doesn't account for everything as long as it returns manual control when things like this happen. Honestly, it's not even my bug. If Faraxis is pathing that way, with a visible barbarian camp in the path, they are seriously messing up pathing. I guess they don't really have a 'give up' option though. The silly worker will try anyway.
 
Won't automation on both be broken when they approach the barbarian camp? I don't mind if the mod doesn't account for everything as long as it returns manual control when things like this happen. Honestly, it's not even my bug. If Faraxis is pathing that way, with a visible barbarian camp in the path, they are seriously messing up pathing. I guess they don't really have a 'give up' option though. The silly worker will try anyway.

The worker routes correctly through the city, but the escort can't (due to the catapult) so takes the next shortest route available (around the mountains), because the camp is not within illuminated territory, it may or may not still be there (Schrodinger's Barbarians???), so the path finder makes no account for it until the Spearmen get it within sight. Whether it's there or not, the spearmen are not escorting the worker.

Don't think it's a lost cause, just think there are a number of common use-cases that haven't been allowed for.
 
Ah, I see, the unit in the city blocks the path of the escort but not the civilian. Interesting. And tricky. I'll have to think about this one.

Edit: As I think it over I want to say the behavor above 'works as expected'. Meaning, the escort will end up under manual control by the barbarian camp. It's going to be complex and inperfect (hence why I say I hate pathing code - for example, embark changes the above issue) but as long as when we fail we do so 'gracefully' and the player is returned control, it's probably okay? I can even send a 'Worker unprotected!' notification, complete with map centering.
 
Top Bottom