Two mod ideas, how to start ?

intutama

Warlord
Joined
Dec 8, 2012
Messages
117
Hello everyone,
I have two ideas for mods that I'd like:

1. 95% Combat guarantee
This mod would prevent a unit with >95% chance of combat from dying. The unit can still be wounded, but it just can't die. Naturally units with <5% would not be able to win a combat. I finally decided to try to make such a mod after my CR5 elephant lost against a wandering catapult :mad:

2. New unit Pirate Hunter
This is a unit available along galleys, it would be a little bit cheaper and weaker but would have a bonus against barbarian (reach same combat chances as barbarian vs warrior) and cannot hold units.

Do you have tutorials etc. which show how to do this? I suppose for 2. (new unit) it really shouldn't be difficult. For 1. I'm afraid there's some hacking involved, so here maybe you have ideas how to start...

PS: while I have no experience with modding, I do work as SW developer, in case this is relevant.
 
Since you are a software developer, all you need is probably pointers to the right places in the code. So for number 1 I suggest starting with CvUnit::resolveCombat() in the DLL sources. Adding new units can be done in XML, but there is no XML tag for strength against barbarians. You would have to implement that in the DLL yourself.
 
1. 95% Combat guarantee
This mod would prevent a unit with >95% chance of combat from dying.
I think this mod component I wrote a couple of years ago does just that. Or it could at least be a starting point. The combat odds threshold is lower, but configurable. I've abandoned that idea though because (I'll just quote what I wrote in the discussion thread for the mod) "it would be more elegant to limit the number of combat rounds (like in air combat) than to use an arbitrary survival threshold. Either way, a side-effect of this kind of mod is that it gets (even) easier to wage war with very few losses. I think it would have to be coupled with a cost on unit healing, and that's a big task to design and implement." Then again, a 95% threshold probably doesn't affect the game balance that much ...
 
@f1rpo: This looks good! I just want to get rid of the absurd luck due to which you can win/lose an combat you can't lose/win... To be honest I think 80% is too low, as you said you might eventually snowball because you don't lose units and the mop-up crew keeps getting stronger too. I guess any attempt to fix the combat in this game wouldn't really work, as anyway it's built about stack of dooms - you could add zone of controls etc. but then probably the AI would fare even worse in combat (see: Civ V / VI).

Same idea with the pirate hunters, if you are out of luck you can waste many galleys trying to get rid of one stupid pirate... Even with two galleys nothing is guaranteed because pirates can come unscathed from the first fight.
 
The civ4 engine consists of the following:
  1. game exe
  2. dll file (C++)
  3. python files
  4. xml files
  5. graphics and audio files
If a file is present in the mod, it will overwrite the file of the same name in the game, meaning you can overwrite everything with the exception of the game exe file. The DLL file contains most of the game mechanics and it is responsible for most calls to python and all to xml. Even better, C++ is compiled (optimized and much faster) and unlike python, we do have a working debugger for C++. Using a modded DLL file will however make the mod windows only while python/xml only mods will work on all platforms. Python has some exe callbacks, which aren't available in C++, mainly related to graphics. The screen interface with button placements, clicks etc is python code.

That's pretty much the layout of a mod and what modders have to work with. I have written a guide on how to compile and compiler setup here: https://sourceforge.net/p/colonizationmodcollection/wiki/compile/. Sure it's for Medieval Conquest, a colonization mod, but it's still the civ4 engine and guides for BTS is 99% colo compatible and vice versa. The compiler info is 100% the same. Use Makefile 2.5 (my signature) instead of the git repo mentioned in the wiki and you have a decent chance of getting it to work.

I would recommend using an existing mod as a base instead of vanilla. Something like K-mod should contain a lot of useful features without moving the game away from the vanilla gameplay.

None of this applies to your actual question of how to do something specifically to combat. However once you have the compiler going, it shouldn't be too hard for you to figure out where to work on the code in CvUnit.cpp. The code is almost self documented due to useful names of functions and variables.
 
I just want to get rid of the absurd luck due to which you can win/lose an combat you can't lose/win... To be honest I think 80% is too low, as you said you might eventually snowball because you don't lose units and the mop-up crew keeps getting stronger too.
The problem with having a 100% chance of winning is that if the unit never takes damage, it can win over an unlimited number of units. The British army had that idea, but then they were attacked by Zulu warriors and despite it being spearmen vs bench loading rifles, the British lost due to being outnumbered more than 1000 to 1. That's basically the background story for why one army suddenly got interested in investing heavily in machine guns, despite them not really being used in any army at that time.

Even if you make it so you can't lose at a "sure thing", make sure you can get damaged, hence lowering the odds for the next attack and if they are attacked enough without healing time in between, even a super unit can lose.
 
@Nightinggale thanks a lot for the hints, I might have some fun tweaking the game to my needs!
For sure the unit with overwhelming winning chances should still get hit, just not being able to die. I just can't stand having to be anxious when moping up units with my super strong dudes just because oh look that 1% chance of catastrophe is actually 10%.
 
Now that I think about it, it's worth looking into the rules for collateral combat, which already resembles what you want: combat is set to end when the target strength drops below a certain threshold. You could add something similar that instead applies to the attacker strength.
 
I would recommend using an existing mod as a base instead of vanilla. Something like K-mod should contain a lot of useful features without moving the game away from the vanilla gameplay.
On that note, K-Mod also lets Barbarian ships start with a promotion called "Disorganized" that gives them -10% strength. This might reduce the need for a pirate hunting unit.
 
Back
Top Bottom