• Civilization 7 has been announced. For more info please check the forum here .

Era of Miracles fantasy mod - developer diary

I like this from a flavor and an AI perspective. From a flavor perspective, I always thought it reasonable that your archers have a sword and are smart enough to use it when needed. From an AI perspective, toughening up ranged units (in melee, even if that means lowering ranged strength) should help the AI a lot given its problem protecting ranged units (Spatz may be able to confirm this prediction).
 
From a flavor perspective, I always thought it reasonable that your archers have a sword and are smart enough to use it when needed.

Actually, that's not very historically accurate. Just because the archers might carry a sword (and often, many didn't) doesn't mean they could function as a cohesive fighting force that way. The Roman Legions and greek phalanges were about a steady advance by infantry with shields along the entire front, and spears or short stabbing swords used in the gaps between the shields. If a non-infantry unit was attacked, it wouldn't matter what sort of swords they carried, they'd be dead meat if they didn't run away. In an infantry-on-infantry battle, the losing side's soldiers would similarly run away, by dropping their heavy shields (to allow them to run faster than the other side's soldiers could advance), hence the phrase "with your shield or on it". While the fleeing unit would obviously not be capable of more combat for a little while, it wouldn't get wiped out. Well-trained infantry wouldn't break formation to chase down fleeing soldiers; that's what the cavalry were for.
And it's not just about shields, since this sort of behavior extended into later eras, where the "tercio" type infantry formations of the 1600s would have muskets and pikemen as effectively part of a single unit; you couldn't attack the ranged units without first going through the pikes... until the infantry broke and ran, at which point cavalry could cut them down.
Granted, in many early armies the "archers" were just comprised of whichever infantry and/or cavalry weren't on the front line at that particular moment, in which case they'd be fully trained and equipped for melee fights, but that was pretty much over by the longbow era.

So, the best way to reflect this in Civ5 would be to have "light" units, like archers, or fast units like cavalry being able to withdraw and take less damage when attacked by slower melee forces. Unfortunately, Civ5 just doesn't really have a functional "withdraw" mechanic to reflect this sort of thing, although a few mods have tried to add one in.

From an AI perspective, toughening up ranged units (in melee, even if that means lowering ranged strength) should help the AI a lot given its problem protecting ranged units (Spatz may be able to confirm this prediction).

In general yes, it helps the AI since the existing AI isn't very good at rock-paper-scissors sorts of strategies. A human knows to concentrate on fielding a certain type of unit and to have his top combat priority be to take out whatever counter-unit the other side uses; in later eras you might have 20 Bombers and know to take out the AAA/SAMs first, allowing your air units to pound the enemy's tanks down to nothing before you send your own in. The AI will instead consistently have a handful of each unit type and so not do as well with this sort of strategy, as there'd be no single subgroup that could be eliminated to give that sort of advantage. By making archers a little less vulnerable, you make it harder for the human to selectively destroy an AI player's support units and easily roll over the rest.

The catch is that decreasing archers' ranged ability hurts the AI in other ways. For instance, consider defense; an AI that parks an archer inside a city won't care if you beef up its melee combat rating, it just needs that extra bombardment power. Obviously, the human won't be on defense nearly as often as a typical AI, except on the highest difficulties, so this obviously skews things. You can compensate for this, somewhat, by adding something like the Home Field Advantage promotion in my own mod (all units get +10% when fighting in friendly territory, doubled when ATTACKING within friendly territory) to make those sorts of defensive units still as strong as before without giving a similar boost to the attackers' open-field ranged units.

Also, consider promotions; archers can't take Drill or Shock, and so will never have the kind of melee strength necessary to really resist attack, especially when facing an infantry unit that's gained a couple promotions. One of the things that I'm doing in my own mod is removing the Accuracy and Barrage promotion lines altogether, with the ranged combat bonus against Open terrain being rolled into the existing line of Open melee promotions, and a similar merging for the Rough promotion lines. This'll help archers quite a bit, as archers specializing in rough-terrain fights would now gain a defensive benefit from their promotions as well. (It also fixes the crossbow -> rifleman upgrade problem.) But even without that, there are ways to boost ranged units' defensive strengths without changing all of the individual units' stats.

Bottom line, it's not an easy change to make, because it'd affect so many other things. I had few problems with this sort of thing in my future, mod, but by that point in the tech tree you're no longer worried about many of the above issues. (When units in cities add very little to its strength, and air/orbital units make withdrawing from combat useless, there's less need for these sorts of things.)
 
I like this from a flavor and an AI perspective. From a flavor perspective, I always thought it reasonable that your archers have a sword and are smart enough to use it when needed. From an AI perspective, toughening up ranged units (in melee, even if that means lowering ranged strength) should help the AI a lot given its problem protecting ranged units (Spatz may be able to confirm this prediction).

Giving ranged units a melee attack and increasing their combat rating are two different things, which have different impact on the AI :) But it's possible that some units in this mod will have both melee and ranged attack.

Spatzimaus said:
Unfortunately, Civ5 just doesn't really have a functional "withdraw" mechanic to reflect this sort of thing, although a few mods have tried to add one in.

What about the withdraw mechanic used by Incan Slingers?

Also, consider promotions; archers can't take Drill or Shock, and so will never have the kind of melee strength necessary to really resist attack, especially when facing an infantry unit that's gained a couple promotions. One of the things that I'm doing in my own mod is removing the Accuracy and Barrage promotion lines altogether, with the ranged combat bonus against Open terrain being rolled into the existing line of Open melee promotions, and a similar merging for the Rough promotion lines. This'll help archers quite a bit, as archers specializing in rough-terrain fights would now gain a defensive benefit from their promotions as well. (It also fixes the crossbow -> rifleman upgrade problem.) But even without that, there are ways to boost ranged units' defensive strengths without changing all of the individual units' stats.

I'm going to totally rebuild the promotion system, I don't like the current one based on open/rough terrain promotions. Instead there will be Attack and Defense promotions, Charge that increases attack strength in open terrain (available to Mounted units), promotions that increase combat strength and movement on specific terrain/feature types, and so on (maybe even generic "Combat" promotions like in Civ4, but I'm not sure if it's a good idea).

2011-11-04: Problems with processes

The tech tree is still incomplete, but I wanted to do something else for a change. So I added the Caravans process, which will be usable only by the Azracs (the technology that allows it will be blocked for other civs), and will give some gold and a bit of science. But when I tried to use it in the game, it didn't work! I investigated this problem and found out that the 2 processes (Wealth and Research) are fixed in the interface files, and I need to edit these files to allow more processes. I think it's a bad design decision in a moddable game like Civ5. Fortunately the solution is already found here. Btw I don't think it's a good idea to add a food process available to everyone, but I'm thinking about a "Breeding" process available to one of the unrevealed civs that adds some food and some science.

Also I'd like to add a Culture process, but it doesn't seem to be possible...
 
What about the withdraw mechanic used by Incan Slingers?

Well, for one thing, I don't buy DLC so I've never used them. But even without that, there just aren't many places where it's tunable. What you'd really want here is a more complex system, like "Archers can withdraw from infantry but not from cavalry", which is something the existing stubs don't really help with. Or better yet, some percentages that vary with a lot of other factors; even if the slingers already have a withdraw ability, you don't have much control over the exact chances.

It's sort of like nuke interception. In previous civ games, nukes had a flat chance of being knocked down by players that had SDI. So when I was adding my own nuke interception logic to Civ5, I started with that. But since I was forced to build the system myself, it allowed me to add some variation into the system, where the chance of being intercepted would also depend on how many civs you were at war with, how advanced the nuke was, and there'd be maximum and minimum chances depending on the type of nuke used.
So if we were to write our own "withdraw" logic then it could be tunable like that, but using what's been provided in XML, we're very limited.

I'm going to totally rebuild the promotion system, I don't like the current one based on open/rough terrain promotions. Instead there will be Attack and Defense promotions, Charge that increases attack strength in open terrain (available to Mounted units), promotions that increase combat strength and movement on specific terrain/feature types, and so on

There aren't any XML functions for having promotions depend on a terrain type. (Features, yes, terrain no.) You're pretty much limited to Domain, Features, Open/Rough, and specific unit types.

Beyond that, the danger of the way you've described this is exactly what I said in the previous post about the attack-vs-defense thing. Why would any archer ever want to take a defensive promotion, given how rarely they'll take damage? If you make it possible for archers to take +defense promotions, then the AI WILL take them, and end up with weaker units as a result. But if you don't make it possible, then you're back where you started, with the archers being dead meat when attacked.

This is why I'm sticking with the Open/Rough split. By taking a promotion in the "Open" or "Rough" lines, the archer will still get a useful offensive boost, AND the defensive boost that he otherwise wouldn't even consider adding. Now, one possibility I thought of was to invert it; that is, the vs-Open ranged attack bonus would pair with the Rough melee/defense bonus and vice versa. (Given how much people prefer to park their units in rough terrain, this'd balance the two lines out.) But that's probably just a little too complex to handle.

(maybe even generic "Combat" promotions like in Civ4, but I'm not sure if it's a good idea).

It probably isn't. Again, AI issues; generic promotions are weaker than specific ones for a player who knows what he's picking, but they're stronger than average for an AI who picks randomly. A human will take whatever attack promotion gives a bigger boost than this generic one, and come out ahead.

Also I'd like to add a Culture process, but it doesn't seem to be possible...

It's not possible in XML, but is possible through Lua. Fairly easy to do, actually; it's one of the things on my list of stuff to work on for my Empire mod. Create a new Process with the appropriate flavor (in this case, Culture), have it do nothing in XML, and add an end-of-turn Lua event that adds the appropriate amount of Culture to each city that ended the turn with that process. The only real problem would be that it wouldn't be immediately reflected in the CityView and TopPanel UI elements, but if you're already changing those for other reasons (like I am) then that's easy enough to fix.

You can use that sort of logic to add a whole series of other Processes. Imagine a "Training" process that adds +1XP to all units you own, a "Diplomacy" process that adds a small amount of Influence to all city-states each turn, a "Defense" process that gives the city a temporary defensive bonus until your next turn, a "Greatness" process that increases the city's Great Person Point generation for that turn, or a "Popularity" process that adds extra Golden Age progress. Throw in things like a more straightforward Food-generating one, and you could have a wide variety of processes to choose from. Again, all possible through Lua. Pretty much anything is possible this way; you could make a process that makes workers near that city work faster, or that makes Great Improvements (Academies, etc.) produce more yields, or whatever else you can come up with if you really wanted to, although of course the AI wouldn't handle those quite as well.
 
Well, for one thing, I don't buy DLC so I've never used them. But even without that, there just aren't many places where it's tunable. What you'd really want here is a more complex system, like "Archers can withdraw from infantry but not from cavalry", which is something the existing stubs don't really help with. Or better yet, some percentages that vary with a lot of other factors; even if the slingers already have a withdraw ability, you don't have much control over the exact chances.

I don't buy DLC either, but there is a tag for this in Promotions, so I think I can use it :) And I don't need more complexity here, a simple withdraw chance is enough for me.

There aren't any XML functions for having promotions depend on a terrain type. (Features, yes, terrain no.) You're pretty much limited to Domain, Features, Open/Rough, and specific unit types.

Hmm, so what about this table definition in CIV5UnitPromotions.xml? I hope it works, if not for selectable promotions, I'll need this for the racial abilities...

Spoiler :
Code:
	<Table name="UnitPromotions_Terrains">
		<Column name="PromotionType" type="text" reference="UnitPromotions(Type)"/>
		<Column name="TerrainType" type="text" reference="Terrains(Type)"/>
		<Column name="Attack" type="integer" default="0"/>
		<Column name="Defense" type="integer" default="0"/>
		<Column name="DoubleMove" type="boolean" default="false"/>
		<Column name="Impassable" type="boolean" default="false"/>
		<Column name="PassableTech" type="text" reference="Technologies(Type)"/>
		<Column name="PediaType" type="text"/>
	</Table>

Beyond that, the danger of the way you've described this is exactly what I said in the previous post about the attack-vs-defense thing. Why would any archer ever want to take a defensive promotion, given how rarely they'll take damage? If you make it possible for archers to take +defense promotions, then the AI WILL take them, and end up with weaker units as a result. But if you don't make it possible, then you're back where you started, with the archers being dead meat when attacked.

Good question, I'll have to think about it. Maybe the defensive bonus for ranged units should be much bigger, and only one level, while the ranged attack promotions would have multiple levels and a smaller bonus per level...

About the processes: I'm not skilled in LUA enough to create these, but if you do it in your mod, I can copy some code from it (if you allow me, of course).
 
About the processes: I'm not skilled in LUA enough to create these, but if you do it in your mod, I can copy some code from it (if you allow me, of course).

Unfortunately it's not in any of the versions of my mods that you can get to at the moment. I've got test versions on my home machine that include some of these bits, but unfortunately, that computer is currently nonfunctional due to a hardware failure. (ETA: a week or two. I'm posting this from my work computer.) Even after I get the machine up and running, these likely won't be in the versions I publish until I've had some time to evaluate their balance.

It's not a complicated thing to add for yourself, but there are several major UI elements you'd want to change to fully implement it (although if your mod's already changing a lot of things, then you'd be changing TopPanel and CityView anyway) and there are some major balance issues, especially involving the AI.

For instance, if you wanted an +XP process, then the question would arise of area; should it give XP to all units in your empire, or just the ones near this city? And if it's near this city, or if there's a cap of any kind, then the AI won't handle it well as it wouldn't know when is a good time to use that process. So that means empire-wide, probably uncapped XP gains, and there are obviously some major balance issues there. (Not the least of which is, how would this vary with the production of that city?)
Likewise, a process that increases the generation of Great Person points only makes sense if the city's generating an appreciable number of Great Person points. In a city that's unlikely to ever spawn a great person and generates few GPPs of its own, it'd be a waste to take this action. So you either have to design it in such a way that it's never a waste (like a global effect) or add better AI control.
This is also the main drawback to the most commonly suggested Processes, a +Culture one and a +Food one. Gold and Research (the two existing processes) are purely global yields, with no real dependence on which city generated the yields, and so are fairly easy for the AI to do well with. But the border-growth aspects of Culture or the city growth of Food are a lot harder to balance correctly, because the AI will be just as likely to use these processes when it doesn't need the excess. (Or in the case of Food, when growth would actually be a bad thing.) In the case of Culture it's not so bad, as the global effects (more policies) are generally more significant than the local ones and the only cities that'll use a process will be fully developed ones that don't need border growth anyway. But this is a major drawback if you want to add many of the more exotic Processes I listed earlier.

There's also a SLIGHT problem of timing: processes need to be evaluated at the end of a player's turn, but the only end-of-turn event we have is the Serial event triggering at the end of the active player's turn. (Whereas, we have a start-of-turn GameEvent that applies only to each player in turn, which is much better for most Lua functions you want to add.) This means some awkwardness when an AI uses the process, as it won't have an effect until your own turn ends. Also, it'd screw up badly on hotseat games, not that I care too much about those.
 
No need to hurry, I don't want it now, my mod still needs a lot of work before it's released. And I just wanted the Culture process, I'll think about the other ones you mentioned whether it's a good idea to add them or not.

2011-11-05: Unusual unit movement types

A question for the experienced modders here (especially Spatz): would it be possible to create units with the following movement allowances, and how?

1. A unit that can move on all terrain, including mountains, coast and ocean (like a flying ship)
2. A unit that can move on land (but not on mountains), lakes and coast (Lizardmen)
3. A unit that can move on land (but not on mountains) and on lakes (fresh water based units of the Vodniks)
4. A unit that can move on land and mountains, but not on lakes (some Dwarven units and other units after taking the Mountaineering promotion; they should be also able to move on impassable features)
5. A unit that can move on land and the Ice feature (Frostlings)
 
A question for the experienced modders here (especially Spatz): would it be possible to create units with the following movement allowances, and how?

The short answer for most of these is "No."
The long answer is "Noooooooooooooo."

Okay, fine, I'll be more specific. The only controls we have over movement are very limited; the <CanMoveImpassable> promotion flag, for instance, simply tells the game that every terrain treated as Impassable is now possible to access, except that Ocean is handled separately thanks to the embarkation logic. Unfortunately, there's no easy way to override individual terrain types' accessibility to individual units, it's a pretty all-or-nothing thing. There are a half-dozen flags in the UnitPromotions file related to this sort of thing, some of which are nonfunctional, so you can try them out to see what each does.
But I don't remember any that'd let you move across one impassable terrain type but not others; Lakes and Mountains are both Land hexes with the Impassable flag, even though Lakes are a Terrain type and Mountains are a Plot type. (Yes, Lakes are a land type, not a sea type. Go figure.) Ice or Natural Wonders are a bit different, as you CAN make Features impassable to units without a given promotion (see the Forest limitation for early wheeled units), but giving that limitation to every unit except those few you want to use on Ice is not really a good solution.

While coastal and ocean waters ARE flagged as Impassable to land units, there are other factors involved. If a unit has the hovering promotion (like the helicopter) then it can move over shallow water but can't move into deep water. But if it has any of the three embarkation promotions (which everyone does once you research Optics) then it'll embark as soon as you move it into the shallow water, which means you either need to remove the embarkation (which screws up your ability to cross oceans) or give up on the shallow water part.

If you have total control over the map scripts, you can avoid this by removing deep water entirely, to where all water is shallow, and remove all embarkation, which'd allow hovering units to cross oceans. Of course, without deep water there's nothing stopping continents from contacting each other at the start of the game, so this'd only work for mods that completely overhaul the tech tree and are willing to accept that sort of change.
You can also override the UnitSetXY GameEvent to trigger an embarkation change (although you can't PREVENT one, which makes it easy to get stuck in an infinite loop), but that unfortunately doesn't work well in this case for various technical reasons. (Trust me, I spent a couple weeks trying to get this to override the embarkation correctly. It didn't go well.)

-------------

Now, failing that sort of massive overhaul, you CAN make a unit that can move on all terrain, including mountains, lakes, coast, and oceans, though. The trick there is to make it a SEA unit with the CanMoveImpassable flag, which allows it to move through oceans as if it were a naval unit, but can also move across land (since those are its "Impassable" types, there's no land-based counterpart to Embarkation, and apparently it has no problem with the Plot type transition in that direction). Yes, it works, and it only requires the Sea Domain, and does NOT require the Naval combat class, so your unit can still be of type "Armor" or "Mounted" or whatever and gain the usual promotions for that class. In my Alpha Centauri mod, I use this mechanism for the Vertol, Former, Nessus Worm, and Gravship, so I've had plenty of time to test it. No Lua mechanism is required, although I have one to make sure these units don't get assigned any embarkation promotions just to be sure.

This does have some issues:
> As sea units, these units can only be built in coastal cities. (This is the big one, especially if you want the unit to upgrade to something without this ability.)
> As sea units, they can stack directly with land-based combat units, without violating 1UPT, but cannot stack with other sea units of any kind. (This one has some major conceptual benefits; if your hovering unit is really powerful, it can be used to screen a more vulnerable unit.)
> They don't gain the benefits of land-only XP buildings (if any), but do benefit from sea-only XP buildings. (In my mod, the Barracks only adds 5 XP to sea and air units, and the Military Academy doesn't boost XP, but Harbors and Seaports each add +10XP to naval units. So it matters there.)
> They can be torpedoed by submarines. Conversely, if any land-based ranged units have that same "attack only in domain" limit for any reason (none in vanilla have it), then they CANNOT hit these units.
> They don't get the free promotions from the Great Lighthouse or those Commerce policies that boost naval units, and will be treated like their land-bound counterparts in this area, but they also don't gain any domain-specific boosts affecting land units.
> When an air or naval unit has taken the anti-Sea promotions, it hurts your unit more, while the corresponding anti-Land promotion doesn't affect them; this is generally a plus, but it's something to watch for.
> While they can fight naval units, which tend to have low combat ratings compared to land-bound counterparts, they're not actually Naval units and so don't trigger the "Naval Penalty" negative promotion bombers get. (You can change Naval Penalty to explicitly get a penalty against these units, if you really want to, but you might not WANT that sort of thing.)
> The unit's z-value for its graphics will change a bit as the unit comes out of the water (hovering a little higher over land hexes than sea ones), but that's not a bad thing in most cases. This really only matters if you're not adding a custom 3D model.

There are a few other quirks, but those are the big ones. And yes, the AI seems to use these units pretty well, although it won't send them out into deep water very often as those hexes aren't really defensible, so it won't think it's a good idea to stray too far from land unless it sees something out in the water worth attacking. One of the ways I've tweaked that is to give Atolls a defense bonus, which encourages the AI to move between those, which tends to help the number of these units that get moved offshore.
 
A question for the experienced modders here (especially Spatz): would it be possible to create units with the following movement allowances, and how?
The short answer for most of these is "No."
The long answer is "Noooooooooooooo."
:lol: That's a very comprehensive long answer. I've been thinking of making a mod that will essentially be set in a William Gibsonesque version of cyberspace, where terrain/feature types represent types of computer systems and countermeasures that you need to gradually unlock access to through techs/promotions. I'm guessing the best way to plan for this might be to use a higher base movement for most units such as 2, give terrain types a higher movement cost that can be affected by promotions, and using Features for some temporarily impassable terrains?

Off topic, I was thinking that for this mod you might be able to take advantage of the Social Policy system to represent some of the more powerful magic. E.g. policy trees could represent schools or "colors" of magic, with policies inside them being powerful enchantments or rituals that have world-level effects; allowing AI to use and benefit from them without needing extensive mod capabilities in the SDK.
 
2011-11-06

About the movement: I'll make some experiments and see what happens, but generally I'm afraid what you said is true :( So we need DLL access to make it possible...

While coastal and ocean waters ARE flagged as Impassable to land units, there are other factors involved. If a unit has the hovering promotion (like the helicopter) then it can move over shallow water but can't move into deep water. But if it has any of the three embarkation promotions (which everyone does once you research Optics) then it'll embark as soon as you move it into the shallow water, which means you either need to remove the embarkation (which screws up your ability to cross oceans) or give up on the shallow water part.

What if embarkation is not applicable to a given unit combat type? (I mean, when it's not in Promotion_UnitCombats)? I suppose this will make the "hovering" unit able to cross Coast and all impassable land terrain, but not Oceans?

About the units that can cross all terrain: Making them sea units is good for me, as they are meant to be flying ships. But the fact that they are buildable only in coastal cities isn't good, have you tried to set the MinAreaSize to 0 or -1?

One of the ways I've tweaked that is to give Atolls a defense bonus, which encourages the AI to move between those, which tends to help the number of these units that get moved offshore.

I remember I set some defensive bonuses for Coast terrain and Atoll feature, but it didn't work. Did you managed to get it working or it only affect the behavior of the AI without providing a true defensive bonus?

orlanth said:
Off topic, I was thinking that for this mod you might be able to take advantage of the Social Policy system to represent some of the more powerful magic. E.g. policy trees could represent schools or "colors" of magic, with policies inside them being powerful enchantments or rituals that have world-level effects; allowing AI to use and benefit from them without needing extensive mod capabilities in the SDK.

This was discussed here before, some of the policies will represent magical effects indeed. I'll post more detailed info about policies later.
 
Spoiler :


If you make a unit with a high bombardment and a low melee attack, then the AI handles it just fine, regardless of whether it has that melee attack or not
There is no point in making a unit with a high ranged attack and low melee strength that can melee attack; the number of times were you would want to use the melee attack is vanishingly small (capturing a city, or wanting to kill a unit and move 1 tile at the same time).

Capturing workers/settlers and capturing cities, and in my experience the AI's capable of doing those just fine.
Note that you (and the AI) can use a ranged unit to capture a civilian unit by moving onto it in vanilla. It does not require that you enable the unit to be able to initiate a melee attack on combat units.

If you make a unit with a low bombardment and a high Combat rating, then it's a bit tougher, since the AI will still generally prefer to use the ranged attacks, but even there it's not too bad in my experience
The AI only ever uses the ranged attack, right? So I think that is too bad.
By definition; there is only a point in having such a unit (from the human perspective) if sometimes it is more advantageous to use the melee attack than it is to use the ranged attack. But the AI will only use the ranged attack. So by definition you are creating a unit that the AI can't handle.

The UI limitation requiring manual attacks hurts the PLAYER, not the AI.
Uh, yes. And the player is the one we're targeting with a mod, so the extra MM hassle is annoying.
There are multiple downsides; the human player faces the UI issue, the AI faces the fact that it doesn't understand the mechanic.

The other problem is: melee defense and melee attack are the same thing. So if you make a unit that is worth using melee attack, you're also making a unit that is good at defending against melee.

You've got it backwards. The 125 is the DEFENDER's bonus, so raising it to 150, for instance, would make ranged units even LESS vulnerable to bombardment, not more.
I don't have it backwards; why are you assuming that changing the parameter would necessarily mean raising it? The original question made it sound like the goal was to make the ranged units use their melee strength for defense against ranged attacks in exactly the same way that melee units use their strength against ranged attacks. I don't think that is a good idea.

Make a crossbow-equivalent unit with Combat 10, Ranged Combat 10 (instead of 6/12), and what do you have? A unit whose attack is a little weaker but who is much harder to kill
I have no problem with this kind of thing, but I don't see a reason to add a melee attack ability too.
Also, my understanding is that "RANGE_ATTACK_RANGED_DEFENDER_MOD" is a global parameter that affects all units, not a local one for particular units? [If I'm wrong here, ignore this.] So if you start messing around with the parameter to accomodate a 10/10 unit, you mess it up for any other units that aren't designed around it.

Basically I think that most ranged units should use the good ranged attack/vulnerable in melee design. It works well (units have the advantage of being able to attack without taking damage, but are vulnerable and need to be protected) and the AI can manage it reasonably well.

* * *
Actually, that's not very historically accurate. Just because the archers might carry a sword (and often, many didn't) doesn't mean they could function as a cohesive fighting force that way.
Agreed. Most dedicated ranged units would be very weak in melee. They were usualyl lightly armed and armored, and didn't have the training or discipline for melee fighting.

So, the best way to reflect this in Civ5 would be to have "light" units, like archers, or fast units like cavalry being able to withdraw and take less damage when attacked by slower melee forces.
The Inca slinger withdraw mechanic doesn't work very well.
IMO the way to model this is either with a move after attack mechanic, or to go the VEM route for "vanguard" units and have a unit line that is purely defensive; no ranged attack, but a defensive bonus.
But I still think that the powerful ranged attackers shouldn't be able to withdraw at all; they should have to be protected from melee troops.

From an AI perspective, toughening up ranged units (in melee, even if that means lowering ranged strength) should help the AI a lot given its problem protecting ranged units (Spatz may be able to confirm this prediction).
I'm fine with changing ratios to make ranged units slightly more hardy, and I agree this helps the AI, because the AI doesn't protect them as well as a human. VEM does this with archers and siege units. But there is a difference between raising strength slightly to make it harder to 1-shot a unit, and raising strength to the point where the unit can actually perform well in melee combat.
If you do the latter, you risk a design where ranged units are all you build. Ranged attack is very very powerful in the Civ5 combat engine, because it doesn't take any damage in return. So it is very important that ranged units have a weakness.

For instance, consider defense; an AI that parks an archer inside a city won't care if you beef up its melee combat rating, it just needs that extra bombardment power
My understanding was that the combat boost to the city from garrisoning a unit did depend on its melee strength? But I agree it doesn't make much difference in this case, but that is ok. A ranged unit in a city will still be useful.

(It also fixes the crossbow -> rifleman upgrade problem.)
First, I think this is less likely to be a problem in a fantasy mod. But if it does show up, I'd recommend using the VEM solution, which writes code that automatically changes ranged promotions into melee promotions when upgraded.

instead there will be Attack and Defense promotions
I'd be very careful about this. The human is vastly better at using specializations than the AI player is. I worry that this kind of design can make certain promotions into no-brainers for the human; ranged units will always take attack promotions, spearmen will always take defense promotions, move-after-attack units will always take attack promotions, etc.

A question for the experienced modders here (especially Spatz): would it be possible to create units with the following movement allowances, and how?
I'm not technically experienced at all, but for some of these, could you fudge the issue by giving the units the same graphic when embarked, letting them defend when embarked, giving them no amphibious attack penalty, and somehow let them move after embarking?
Is there a Denmark mechanic that might be relevant here too (I don't have that DLC)?

 
What if embarkation is not applicable to a given unit combat type? (I mean, when it's not in Promotion_UnitCombats)? I suppose this will make the "hovering" unit able to cross Coast and all impassable land terrain, but not Oceans?

Correct, that's the same behavior you'd get if, after the unit is created, you were to strip the embarkation promotions. (Those promotions aren't continually assigned, it's only done when the unit is created. So removing them once with a SerialEventUnitCreated trigger is enough.) It's only really a conflict with embarkation, so if you have some other way of moving the unit across oceans (transport ships, airlift mechanics, etc.) then it's not so bad, but in the absence of those, you end up with the behavior you described. Now, I'm sure you could come up with some explanation for why flying unit X can't leave the continent it was created on, but this sort of behavior really hurts the AI. He might make this unit on some tiny island out in the ocean, and it'd be stuck there.

At one point I tried to handle this through a Lua override on the movement, and there were ways it could have worked, but the basic problem is that the AI would never be able to handle it. For instance, let's say you added a bit of lua code so that a hovering unit would auto-embark when it tried to move into deep water, and vice versa. It'd work, but the AI would never trigger it, because he wouldn't TRY to move into that impassable ocean hex since he'd already know that you couldn't get to the other side that way.
A similar problem applies to airlifting; if it's something that requires a conscious action on the player's part, then it's no good because the AI won't understand that moving from point A to point B would be faster if you went through city C. In my mod, the way I got around that was to create an "airlift" promotion, and automatically give it to any unit that started its turn in the city containing a certain building (and remove it from any unit that started its turn anywhere else). The Airlift promotion was just a straightforward 10-hex Paradrop promotion, which the AI already can use fairly well, and since the AI prefers to place units in cities anyway, it'll benefit from this fairly often, and would take it into account when assigning movement orders for the turn. You could tie the Airlift promotion to the movement event itself, to where a unit moving into a city gets the promotion on the spot, but once the AI picks a movement order it won't usually deviate even if the circumstances change (like if an enemy unit that it hadn't spotted is near the movement path). So a start-of-turn event just seemed more balanced, besides requiring less overhead.

About the units that can cross all terrain: Making them sea units is good for me, as they are meant to be flying ships. But the fact that they are buildable only in coastal cities isn't good, have you tried to set the MinAreaSize to 0 or -1?

No, haven't played with that particular value; feel free to experiment. But it looked to me like the sea behavior is just hardcoded in the engine; there's a lot of that going on. For instance, Work Boats (or any other water-based workers you add) will automatically hook up Fish, Pearls, and Whales just fine, but will NOT hook up water-based Oil, or any other resources you add to the water, regardless of whether they're luxury, strategic, or bonus resources. You can hook those up yourself, but the AI (both city-states and major empires) just won't connect its own Oil correctly.
Given that, I just wouldn't be surprised to see the coastal city limitations being inherently tied to the Sea domain deep within the game engine, regardless of what else you set.

I remember I set some defensive bonuses for Coast terrain and Atoll feature, but it didn't work. Did you manage to get it working or it only affect the behavior of the AI without providing a true defensive bonus?

As far as I could tell it was providing an actual defensive bonus, but admittedly I didn't look too closely. Besides, even if it doesn't work, there are ways around that.

You see, in my mods I have "carrier" bonuses. Not aircraft carrier, more like a disease carrier. There's a "Base" policy given to every player at the start of the game, and the math for gaining new policies is tweaked to account for that extra policy while still giving a very similar progression to vanilla (base value 10, multiplier 4, exponent 2.21 I think, instead of the default 25/5/2.0). Similarly, there's a "Home Field Advantage" policy given to every unit of every class whenever it's created, that provides a small bonus when fighting in friendly territory. (Technically, it's given by the Palace to any unit of yours that ever enters your territory, so you can avoid getting it with your starting Warrior, units gifted by a CS, or units the Germans and Ottomans seize from barbarians, but since the promotion won't DO anything until the unit is in friendly space anyway, that's no big deal.) There are a couple things like that, to where every player and every unit has at least one entity that I can assign balancing effects to.

So if the base defense boost to Atolls doesn't work, then I can simply add it as a Feature combat bonus to the HFA promotion instead (through the same table used for the Mohawk promotion), which every unit will get anyway, and for obvious reasons only naval units will benefit from that particular bonus. Actually, I might do that anyway, since you can't give things like attack bonuses/penalties to Features, and I might do something similar with forests and jungles to keep them from being quite so awesome for early warfare.
 
2011-11-07

About the movement: At least it's good that I can create units that can move on mountains by using CanMoveImpassable (they will get embarked when entering a lake, won't they?), and the flying ships, even if they can be built only in coastal cities (a possible workaround is to create a unit that can be built anywhere and upgraded to the flying ship).

Ahriman said:
The other problem is: melee defense and melee attack are the same thing. So if you make a unit that is worth using melee attack, you're also making a unit that is good at defending against melee.

This can be changed by promotions that give bonuses or penalties to attack or defense.

Ahriman said:
The Inca slinger withdraw mechanic doesn't work very well.

Can you elaborate? I don't have the DLC and I haven't tested such units, so I'd like to know what's wrong with that mechanic.

But I still think that the powerful ranged attackers shouldn't be able to withdraw at all; they should have to be protected from melee troops.

I agree, I'm going to use the withdraw mechanic for "skirmishers" (like the Slinger), and perhaps for cavalry and other fast units. I'm not going to use it for units like Archers and Crossbowmen.

I'm fine with changing ratios to make ranged units slightly more hardy, and I agree this helps the AI, because the AI doesn't protect them as well as a human. VEM does this with archers and siege units. But there is a difference between raising strength slightly to make it harder to 1-shot a unit, and raising strength to the point where the unit can actually perform well in melee combat.
If you do the latter, you risk a design where ranged units are all you build. Ranged attack is very very powerful in the Civ5 combat engine, because it doesn't take any damage in return. So it is very important that ranged units have a weakness.

I agree, and I think I'll reduce the ranged attack strengths compared to melee units strengths in this mod, melee units should be able to deal much more damage than ranged units of the same period. But the melee strength of ranged units (without melee attack) can be quite high (like 2/3 to 3/4 of the strength of melee units of the same era) to help the AI. With the 125% modifier, this will make them defend against ranged units almost as good as melee units.

First, I think this is less likely to be a problem in a fantasy mod. But if it does show up, I'd recommend using the VEM solution, which writes code that automatically changes ranged promotions into melee promotions when upgraded.

I'm not going to make any ranged units upgradable to melee units or vice versa.

I'd be very careful about this. The human is vastly better at using specializations than the AI player is. I worry that this kind of design can make certain promotions into no-brainers for the human; ranged units will always take attack promotions, spearmen will always take defense promotions, move-after-attack units will always take attack promotions, etc.

I suppose the AI is bad at picking promotions in the current system as well, so it's not a big problem, it's just one of the things that the AI is bad at, regardless of the type of promotions available (unless there are ONLY generic promotions like Civ4's Combat, but this would make this aspect of the game totally uninteresting). Of course I'll need to think about avoiding no-brainers when working on the promotion system. Also, to help the AI the bonuses from promotions shouldn't be too big, I think one of the things that make the AI in FFH weak are the big promotion bonuses.

I'm not technically experienced at all, but for some of these, could you fudge the issue by giving the units the same graphic when embarked, letting them defend when embarked, giving them no amphibious attack penalty, and somehow let them move after embarking?
Is there a Denmark mechanic that might be relevant here too (I don't have that DLC)?

That's an interesting idea. I don't know how to change the embarked graphics, but giving defensive embarkation (and movement after embarkation or disembarkation if possible; I don't remember if it's doable with individual units or only a civ-wide trait effect) to units like the Lizardmen is a good idea (and of course I'll make them amphibious as well).

Spatz said:
Now, I'm sure you could come up with some explanation for why flying unit X can't leave the continent it was created on, but this sort of behavior really hurts the AI. He might make this unit on some tiny island out in the ocean, and it'd be stuck there.

You're right, I'm not going to create such units.

the AI (both city-states and major empires) just won't connect its own Oil correctly.

That's bad, I'm going to keep Oil in the game, usable by some civs. I hope it will get fixed in a patch.
 
This can be changed by promotions that give bonuses or penalties to attack or defense.
True, but that can start getting messy if you have to add a whole bunch of promotions to a unit just as its base abilities.
Also, there is the fact that using promotions to give modifiers is not the same as changing underlying strength; yes, strength 4 and strength 5 with -20% are the same, but once you start adding other modifiers, strength 4 with -20% and strength 5 with -40% are not the same.

Can you elaborate? I don't have the DLC and I haven't tested such units, so I'd like to know what's wrong with that mechanic.
From memory; the mechanic works as follows. A unit has withdraw promotion, or not. If it has the promotion, when attacked, the unit has a chance of instantly retreating (without taking or dealing any damage) into one of the three hexes that are behind the unit, opposite the hex that the attacker is coming from. This chance is 20% per tile that has open terrain and is unoccupied, and then minus some percent for each movement point the attacker has beyond 2 (ie: mounted units are harder to retreat from).
The attacker moves into the vacated space, and it counts as the attackers attack for that turn (ie turn over unless they have blitz or move after attack).

I don't like the mechanic because:
a) It means that the unit either fights combat as normal, or withdraws completely without any combat. Too all-or-nothing.
b) The unit withdraws even if you actually wanted it to defend (you can't easily override).
c) The terrain requirements and requirements to keep spaces open are very annoying to keep track of and severely limit the use of the mechanic past the early game (later in the game, you have more units)
d) The AI doesn't understand the mechanic (it doesn't know how to keep terrain clear)
e) The trigger chance isn't high enough to be reliable; it is almost never worth keeping your unit forward while risking a 40-80% chance of losing your ranged unit. So you end up still wanting to use your slingers in basically the same way that you use archers; by keeping them out of harm's way.
[The only nice thing about slingers really comes from the double-moves-in-hills, because it means they can skirmish in hill terrain by starting adjacent to an enemy infantry, moving back a tile, shooting, and the enemy can't catch up with them.]

I think I'll reduce the ranged attack strengths compared to melee units strengths in this mod, melee units should be able to deal much more damage than ranged units of the same period. But the melee strength of ranged units (without melee attack) can be quite high (like 2/3 to 3/4 of the strength of melee units of the same era) to help the AI. With the 125% modifier, this will make them defend against ranged units almost as good as melee units.
That seems reasonable.
 
That's bad, I'm going to keep Oil in the game, usable by some civs. I hope it will get fixed in a patch.

Well, it's been broken for several months now, so who knows. The thing about Oil is, 2/3rds of it will be on land and so won't suffer from this issue, because the game figures out how much water-based Oil to add by taking the total number of oil units on land, dividing by 2, and then figuring out how many water-based deposits that'd correspond to. It's just that last one-third that isn't working, so it won't REALLY screw up the balance of the game too badly.

I noticed this in my own mod because one of my strategics, Dilithium, is purely a water-based strategic. Another, Omnicytes, are half land and half water, so it was affected as well. It became VERY obvious that the AI wasn't connecting any Dilithium, so I added a Lua hack to where if a workboat moved over a revealed Oil, Dilithium, or Omnicytes, and the owner had the correct tech, then it'd manually kill the workboat and create the improvement. It's helped, but it's still not doing it well because the AI won't generally send a workboat more than 1 hex from its city unless it knows there's something to use it on.
Point being, whatever's going on inside the engine to cause this issue MUST involve some sort of explicit behavior override, because my new resources weren't being connected regardless of what I classified them as. If the game knew how to connect a generic Bonus resource or a generic Luxury resource, then it would have worked when I tried using those categories. Since it didn't, then the engine must be looking explicitly for "Fish", "Whales", and "Pearls". And that means that even if the devs fix the Oil issue, it won't help with any other custom water resources.
Also, I've confirmed that it's not just a question of whether the WorkBoat knows to move to the resource hex; even if it's already there, it still won't create the Improvement. So it's a multi-level failure in that particular AI.

It's funny, because land-based workers have no problem with new resources' improvements. It's ONLY the sea resources that fail. (And yes, I tried giving the Work Boat the land-based worker AI. No luck.)
 
2011-11-08

About the withdraw mechanic: What you described is good enough for me, as I wrote earlier I don't need anything more complicated. When used with units like Slingers and Horsemen, it should work fine, as these units are typically not used for defense. Also I don't mean it to be used deliberately, it's just a last chance to survive in emergency situations.

About the Oil problem: I think the best possible solution is to give the AI an Offshore Platform for free (perhaps with a probability to avoid getting them immediately) when they have a water-based Oil in their territory, and have technology to build the improvement (the same with other water-based resources added to the mod).
 
About the Oil problem: I think the best possible solution is to give the AI an Offshore Platform for free (perhaps with a probability to avoid getting them immediately) when they have a water-based Oil in their territory, and have technology to build the improvement (the same with other water-based resources added to the mod).

That's actually much harder than it sounds, because there's no easy way to only loop over only the resource hexes within your territory. You'd have to loop over the entire map, check for the resource in every tile, check ownership of each tile, check the techs of that owner, and so on, and that's pretty severe, memorywise, unless you're somehow able to integrate it into some other function that's already doing that sort of map scan. (And that all-map scan is the single most memory-intensive thing you can do in this game, adding a noticeable delay between each turn if you do it on larger maps, so NOTHING should be doing that except during some sort of gated event.) To save time you COULD loop over your own cities, then loop over the hexes within 5 spaces of each, but you'd have a huge amount of overlap so it wouldn't save a whole lot of time in the end.

And yes, I've thought of doing exactly that in spite of that timing limitation, because in theory you'd only need to check it when a player gains a specific tech. But what happens when another player pillages the tile? (Remember, pillaged water improvements are destroyed entirely, there's no "damaged" state like the land-based ones have.) So now we're back to an every-turn thing, to see if it needs to be replaced. And if you just replace it on the spot, now you've created an infinite loop where a ship pillages a platform every turn, only to have it respawn; so, you'd need some sort of timer or randomization to prevent it from immediately rebuilding, which takes us right back to the huge overhead.
So now, the only way to keep it from being unbearably time-consuming would be to make offshore platforms (or any other improvements for new water resources) invulnerable to pillaging, which makes no sense at all, besides just defeating the whole purpose of having those resources be water-based in the first place (a reason to maintain a navy in eras where air power dominates).

------------------

Trust me, I spent WAY too much time trying out alternate mechanisms for this issue. The simplest and most effective solution, and the one I'll be using, would be this: whenever a Work Boat is created in the Industrial or later (which means a simple SerialEventUnitCreated check, instead of a map check), check to see if there's an unimproved incidence of these resources within a 5-hex radius (which removes the need for an all-map scan). If so, don't even bother moving the unit, just kill it on the spot and place the improvement in the correct place.
You see, the AI IS currently recognizing that it has an unimproved water resource near the city, and will produce the Work Boat it needs; it just won't move the boat to the resource. Since by the time you hit Refrigeration all work boats can move 5+ hexes, it's not really unbalanced, although you CAN get strange behaviors (like a workboat building an improvement on a hex where a ship is parked).
The problem is, I can STILL find problems with this. You might be using a workboat from city A to improve a resource near city B, because B is one hex back from the shore and so can't build its own. Granted, the AI sucked at doing that before, so there's no real loss if I just ignore this sort of special case.

I was planning on putting this change into the next version of my own mod, but as my machine's still dead, there's no ETA on that. But I hope I've got my point across, that fixing this issue just sucks in general.
 
About the withdraw mechanic: What you described is good enough for me, as I wrote earlier I don't need anything more complicated. When used with units like Slingers and Horsemen, it should work fine, as these units are typically not used for defense. Also I don't mean it to be used deliberately, it's just a last chance to survive in emergency situations.
But it isn't a last chance to survive, like Civ4 withdraw (or the mods that created a similar defensive withdraw) which left the unit with a single hitpoint, it is a chance to be *completely unscathed*. You don't even get damaged.
Horsemen already have an ability to get out of the way, it is their high movement points. They are already very powerful, they don't need an extra get-out-of-jail-free card too.
[And horsemen can definitely be used as a defensive screen, if you give them a withdraw chance then they risk becoming better defenders than actual defense units.]

I think slingers would be more interesting to have move-after-attack (but low strength and 2 moevs) rather than withdraw.
 
2011-11-09

Spatz said:
And that all-map scan is the single most memory-intensive thing you can do in this game, adding a noticeable delay between each turn if you do it on larger maps, so NOTHING should be doing that except during some sort of gated event.

This is something I don't understand. Why a simple scan of, say, about 10000 hexes (Huge map) takes so much time and memory for contemporary computers that can execute billions of operations per second and have gigabytes of memory? There must be some highly suboptimal algorithms involved. I know LUA is an interpreted language, but still it shouldn't take as much time...

About pillaging the water-based improvements: you're right, I haven't thought of it. Your solution seems reasonable, although not perfect as you pointed out yourself. Maybe it should check for "idle" workboats - those that aren't going anywhere... But still there can be problems, like an improvement appearing where the way to the resource is blocked by enemy ships.

@Ahriman: Why are you so negative about adding the retreat promotion to some units? I think it's a nice little feature to have in my mod. By "last chance to survive" I meant that the units having it will be generally weak on defense, so any enemy attack can be fatal to them, and a retreat chance can save them in this case. Horseman is a strong unit in the normal game, but in this mod it doesn't have to, perhaps I'll give such units a defense penalty, like the one Lancers have. (Heavy cavalry units, like the Knights, won't have the defense penalty, but they won't have a retreat chance either.) Also, the retreat chance is a numerical value, so I can make it smaller than the Incan Slinger has.

Ahriman said:
I think slingers would be more interesting to have move-after-attack (but low strength and 2 moevs) rather than withdraw.

Why not both?
 
This is something I don't understand. Why a simple scan of, say, about 10000 hexes (Huge map) takes so much time and memory for contemporary computers that can execute billions of operations per second and have gigabytes of memory? There must be some highly suboptimal algorithms involved.

The thing is, you're not just looping over all of the hexes. For each hex, you're loading a data structure containing all of the information about that hex. The problem is that we're using a gigantic, non-indexed database that pretty much REQUIRES being loaded in its entirety. Now, you could get around that by scanning the map once at the start of the game, saving the important bits to a local array (or the ModData structures), and scanning that instead for certain things. It's still very inefficient, and it wouldn't work well for "temporary" stuff like improvements, but for things like knowing which hexes contain water-based Oil, it wouldn't be too bad since there'd only be a few.
 
Top Bottom