modding questions

ReligionIsDumb

Chieftain
Joined
Dec 22, 2010
Messages
13
I apologize if this is post has already been addressed elsewhere. I poked around and didn't find my answer. The Modder's guide shows well how to put new game elements in, but I don't want new game elements. I want to fundamentally change the way the game works.

IMO, one of the most broken things (and the primary reason I went back to civ4) about civ5 is how combat works. Some examples of things I might want to change in trying to fix the system would be as follows:

1. Creating a unit "guard" action that allows it to get one attack against the first enemy unit to enter its weapon's range. This interrupts the opponents turn to resolve the attack. This way, horse archers can not attack archers without ever getting fired at themselves

2. Changing how much units heal every turn. Making promotions NOT heal a unit.

3. Making it so that ranged units fight back against other ranged units (if they are within range) like melee units do.

or

4. Making it so melee units DONT fight back against other melee units when it is not their turn

5. Introducing battle fatigue for units that which reduces combat effectiveness as it gets lower but comes back more quickly than unit casualties.

6. Allow the merging of units that are less than full strength or splitting of units.

7. Allow units to be commisioned and immediately appear on the battlefield with a very low strength which gradually increases over time.

8. Allow the upkeep cost of units to vary from unit to unit and use resources other than money

There are a number of other things I am thinking about, and these are all ideas that I would have to tinker with to see how they work, but this is probably sufficient to get the idea of what I want to do.

My question is: are these things moddable at all? While changing the surface stuff like unit stats and leader traits is reasonably straightforward, changing the above things fundamentally changes the way the game works, and I am not sure it can be done without editing the source code.

On the economic side, there are a number of things to change also that may or may not even be doable.

1. Is it possible to make luxury resources have diminishing returns on multiple resources rather than no return?

2. Is it possible to make happiness city-specific rather than empire-wide...or perhaps have a combination

3. Is it possible to make strategic resources provide a per-turn quantity of the resource?

4. Is it possible to make strategic resources salvageable from defeated military units?

I think I get how to do the basic stuff from the modding guide, but these kinds of things require something more than just changing game assets in an xml file. They require actual coding.

thanks in advance
 
1/lua
2/xml
3/lua
4/dll
5/lua
6/lua
7/lua
8/lua

I've not messed with the economic side, so I can't say for the rest.

those are not simple change, and you'll have to ask yourself how it will affect the AI (and for "teaching" the AI you will most surely need the dll)

basically, for what you want to do the modding guide won't help you more than getting started here, you'll have to look at the available lua code and events from the vanilla files and mod.
 
2. Changing how much units heal every turn. Making promotions NOT heal a unit.

The base heal rates are in GlobalDefines.xml, also promotions can change them.

Promotions don't heal units in Civ5, except the "instant heal" one, which can be removed from the game.
 
1/lua
2/xml
3/lua
4/dll
5/lua
6/lua
7/lua
8/lua

I'd put 1, 3, 5, 6, and 8 as "DLL" as well. Not that you CAN'T do them in Lua, but the AI would have no idea how to use these mechanisms. So if you make it so that two units can merge into a single, more powerful unit, you can easily make it so that a player would do this, but the AI wouldn't be able to use it except if he ended up with two appropriate units in adjacent hexes by sheer coincidence, because he has no behavior that would enable this system. If you make ranged units fight back, then the AI will still go into combats believing that his ranged units won't take damage, and end up having his ranged units die far more often. This is a VERY abuseable advantage for the human player.
Besides, there's ALREADY a significant rule there. When a ranged unit attacks another ranged unit, the defender gets a significant strength boost (25 or 50 percent) to represent "return fire". So while they're not wounding the attacker, they ARE taking less damage than a comparable melee unit would.

Simply put, Lua ADDS, and almost never SUBTRACTS capability. It's enabling, not prohibitive. It's easy to use Lua to add the ability to do something new or add an effect after the fact, but very, very hard to use Lua to stop someone from doing something in the first place. The AI will continue to do things in its normal manner, and not base its behavior on your alterations, which can be an extremely crippling problem if you're not careful.

Also, on #2:
2. Changing how much units heal every turn. Making promotions NOT heal a unit.

Promotions DON'T heal a unit. This isn't Civ4, where you get half your health back every time you take any promotion; the only promotion that heals units is the one-time Quick Heal promotion, and that's easy to disable. It's strange that you'd put this one on there, since you explicitly said that you'd gone back to Civ4 because you were unhappy with how Civ5 does things, but you're asking for something that Civ5 already does and Civ4 didn't.
 
I'd put 1, 3, 5, 6, and 8 as "DLL" as well. Not that you CAN'T do them in Lua, but the AI would have no idea how to use these mechanisms. So if you make it so that two units can merge into a single, more powerful unit, you can easily make it so that a player would do this, but the AI wouldn't be able to use it except if he ended up with two appropriate units in adjacent hexes by sheer coincidence, because he has no behavior that would enable this system. If you make ranged units fight back, then the AI will still go into combats believing that his ranged units won't take damage, and end up having his ranged units die far more often. This is a VERY abuseable advantage for the human player.
You're right and that's was the point of my quick note about AI, but as usual your answer is more detailed :D

About the ranged unit fighting back, it definitely help the AI for naval combat in my ww2 mod, as else the AI ships are just sitting ducks. I'm not sure of the result for land combat.

Besides, there's ALREADY a significant rule there. When a ranged unit attacks another ranged unit, the defender gets a significant strength boost (25 or 50 percent) to represent "return fire". So while they're not wounding the attacker, they ARE taking less damage than a comparable melee unit would.
I've never noticed that, is it on the combat panel, or documented somewhere else ?
 
Also, on #2:


Promotions DON'T heal a unit. This isn't Civ4, where you get half your health back every time you take any promotion; the only promotion that heals units is the one-time Quick Heal promotion, and that's easy to disable. It's strange that you'd put this one on there, since you explicitly said that you'd gone back to Civ4 because you were unhappy with how Civ5 does things, but you're asking for something that Civ5 already does and Civ4 didn't.

I probably just mis-remembered this, but I also haven't played civ5 in about a year, so this might have changed in a patch. I played it when it was first released and was so disgusted I gave it back to the friend who let me borrow it and never touched it again. Upon reflection, I decided that the basic core of the game could be good if properly modded.

I didn't like the heal thing in civ4 either, but it wasn't as much of a problem since battles were usually over in 1 turn anyway and the uber-healing wasn't as much of a balance issue.
 
I've never noticed that, is it on the combat panel, or documented somewhere else ?

It's in GlobalDefines, I think. Something like "RANGED_COUNTERATTACK_MOD"; I'm at work and so can't check the files myself. Once I saw that in the files I did a couple test cases to see if it worked, and it appeared to; for the same Combat value, a ranged unit would take less damage from bombardment than a melee one. But remember, a ranged unit defends with its Combat rating, not its much larger Ranged Combat rating, so adding 25 or 50% to that is STILL going to leave you at a fairly low value relative to melee units in the same era.

You're right and that's was the point of my quick note about AI, but as usual your answer is more detailed

I know you understand that, it's just a standard disclaimer by this point. ANY Lua change will suffer from this issue, so unless Lua code is specifically designed to reinforce the behaviors that the AI already has, it's going to cause problems. In my own mods I tried to do this carefully, with all Lua-based logics either being hands-off bonuses of some kind, random triggers, or things that encouraged the player to play more like the AI does.

Too many new folks have these grand ideas of how they want things to change, especially in terms of new actions, and nearly every time the answer is "while you CAN do that, it won't work because the AI won't understand it." So I try to spell that out as often as I can; in many cases it's possible to find mechanisms that DO work with the AI, and accomplish nearly the same result.

ReligionIsDumb said:
I probably just mis-remembered this, but I also haven't played civ5 in about a year, so this might have changed in a patch.

It hasn't changed. Promotions in Civ5 have NEVER healed units like the Civ4 ones did. There's only one promotion that directly heals units, and that's the one-shot Insta-Heal option; if you dislike that one it's easy enough to disable, but the promotion healing effect you complained about is in Civ4, and NOT in Civ5. It was one of the most abuseable parts of Civ4, really, since the AI would never save up promotions just to use the self-heal at the right times.
 
Not that you CAN'T do them in Lua, but the AI would have no idea how to use these mechanisms.

This point is basically true, so I don't mean to contradict it. However, some thoughts to add to this:
  1. The AI doesn't really understand the current tactical system either.
  2. Make alterations with full awareness of how the AI actually does behave. Not only can you add things without hurting the AI, in many cases you can help the AI. Two examples:
    • Archer-type units that are competent melee fighters, boosted in combat but gimped a little in ranged combat. (Maybe they pick up a sword at close range?) It seems like a reasonable prediction that the AI will do better with this since it is so fond of putting its ranged units out in the action (and it fits the flavor and needs of my mod).
    • Great generals (called great warriors in my mod) that attach to a combat unit (which I always think of as an army or fleet anyway). Solves the stupid wandering general AI problem. Also means I don't have to drive them around everywhere. So two annoying birds killed with one stone.
  3. You can in many cases program AI behavior in Lua to exploit new mechanisms added in Lua. For example, attachment of great generals (above) is a Lua function. In addition to adding the function, I add logic in Lua to tell the AI when to do this (the dll has no say whatsoever). I can now add more Lua actions for this unit (like "break line", "capture siege engine", and so forth) that are 100% Lua. (Of course, programming AI logic is non-trivial, but there is no reason why it will be easier in dll/C++ than in Lua)
Simply put, Lua ADDS, and almost never SUBTRACTS capability. It's enabling, not prohibitive. It's easy to use Lua to add the ability to do something new or add an effect after the fact, but very, very hard to use Lua to stop someone from doing something in the first place. The AI will continue to do things in its normal manner, and not base its behavior on your alterations, which can be an extremely crippling problem if you're not careful.

Yes but...
You can drive research by blocking other techs (same for policies)
You can stop units from doing something, for example a great general from building a fort, by simply removing that action from the builds.xml. You can then add back the action as a purely Lua controlled function (which you do have complete control of).
 
The AI doesn't really understand the current tactical system either.

You can expand this point further. The AI doesn't really "understand" ANYTHING. It has a small pool of pre-programmed behaviors, combined with a weighted randomization system (where the weighting is handled through the Flavor system). The AI doesn't PLAN, the AI doesn't really ADAPT, and the AI doesn't ever UNDERSTAND.

This is why you can't alter many things. The AI simply isn't very flexible; it has only a very limited ability to react to circumstances, and these behaviors are not persistent, meaning they only depend on the circumstances of the moment. So if your change requires an addition to or alteration of the AI's normal behavior patterns, it'll break. Now, there are plenty of changes that can be made that don't require significant alterations to the AI's playstyles, and you're free to do these. But if your modifications require any real amount of planning (like having a chain of four buildings lead to a super-powerful building) then the AI will be hopelessly outclassed by human players.

Not only can you add things without hurting the AI, in many cases you can help the AI.

Correct. The prime example of this were the ICS nerfs back at the start of the year. Once upon a time, players could have a huge advantage over AIs by using a very artificial playstyle. The balance changes that eventually stopped the ICS strategy did so by forcing the player to play with strategies similar to what the AI already used.
Likewise, the AI's military strategy is heavily skewed towards garrisons; the AI will always leave a fraction of its army spread throughout the empire instead of throwing absolutely everything at the front lines, because this allows it to adapt to changing circumstances far better, but it's a significant advantage to the human player. But if you boost the danger of random barbarians, to where the player has to do the same sort of thing to keep his outlying cities from being overrun, or you add policies that give happiness and/or culture to garrisoned cities, then it helps the AI indirectly by rewarding AI-like behaviors.

(Of course, programming AI logic is non-trivial, but there is no reason why it will be easier in dll/C++ than in Lua)

Actually, there IS a major reason why it'll be easier in C++, and that's that we can insert the execution commands BEFORE the event happens. With Lua, we can only adjust most things after the fact. Also, with Lua we're limited to a very small pool of triggering events, whereas the C++ code will give us the ability to add new ones at the necessary points.

You can stop units from doing something, for example a great general from building a fort, by simply removing that action from the builds.xml.

This only works for a very limited number of things, specifically those actions that are explicitly added through XML tables (and that's only the Build actions, really) or that can be disabled through the GameEvents interfaces. Most things can't be disabled this way. And if you can't disable them, then your idea doesn't work.

I'll give you a very, very simple example: I want to make a unit that can't die. No matter how lopsided the combat gets, I want this unit to always have 1 HP. Unfortunately, you can't do that in Lua. Once the combat starts, the unit WILL take X damage, and if X is 10 or more, the unit dies, period.

Or imagine a terraforming unit, that in addition to some unusual build actions, continually adds a small amount of food, production, and gold to whatever tile it's sitting on at the moment. A human would know what to do with this, but an AI wouldn't, and no amount of Lua coding can change its behavior to what would be needed. You could try manually overriding actions to keep these units sitting on certain hexes, but the AI would keep trying to move it wherever its normal behaviors dictate, and you could never program in enough intelligence in your override to make optimal use of this sort of ability.

Or you want to change the game so that extra copies of a Luxury add 1 Happiness to your empire. You can do this easily enough through Lua, but the AI will still trade away his excess for the exact same amount of gold as before. With the DLL we'd be able to change that, but the current Lua/XML setups can't do what's necessary.
 
Back
Top Bottom