RunCombatSim question

xxhe

Prince
Joined
Mar 10, 2008
Messages
410
Location
California
Hello!
Is there a way to modify the combat result? I remember that we could do it through Events.RunCombatSim in the very early game build, but then a patch destroyed the method. So with the release of BNW, I'm desired to know if we can do it again. Any answer will be appreciated, thank you!

To be more specific, I want to make a civ trait. It works like this: Its units receives combat bonus according to the net happiness of the civ at that time - pretty much like the opposite to the penalty mechanism of being Unhappy in BNW, which is -2% per unhappiness - so in my case, it's +1% strength for every 1 net happiness.

I can't make this trait into a promotion because the bonus is dynamic according to your real-time happiness, while a promotion only provides you with fix bonus.
 
Through the DLL? Yes, you can, and with some experience, quite easily.

Through LUA? Well...I'm not the 100% expert on the LUA, but I don't think this is exactly possible, not the way the C++ is written. All of the LUA methods are Get methods it seems, you need a Set or Change method, and via the Unit API I just don't see what you're looking for.

...maybe somebody else may have a solution.
 
I opened the dll using C++ Express 2008. I found the CvUnitCombat.cpp is related to the combat process. However, the method to calculate the damage etc. (.getCombatDamage()) seems to be put in another file, like the following:

iAttackerDamageInflicted = kAttacker.getCombatDamage(iAttackerStrength, iDefenderStrength, kAttacker.getDamage(), /*bIncludeRand*/ true, /*bAttackerIsCity*/ false, /*bDefenderIsCity*/ true);

I looked at most of the files CvUnitCombat.cpp importing but I could find the class that defines getCombatDamage. Could anyone give me a clue? Thank you!
 
I opened the dll using C++ Express 2008. I found the CvUnitCombat.cpp is related to the combat process. However, the method to calculate the damage etc. (.getCombatDamage()) seems to be put in another file, like the following:

iAttackerDamageInflicted = kAttacker.getCombatDamage(iAttackerStrength, iDefenderStrength, kAttacker.getDamage(), /*bIncludeRand*/ true, /*bAttackerIsCity*/ false, /*bDefenderIsCity*/ true);

I looked at most of the files CvUnitCombat.cpp importing but I could find the class that defines getCombatDamage. Could anyone give me a clue? Thank you!

CvUnit::getCombatDamage? in CvUnit.cpp?

Understand kAttacker is a reference to a CvUnit object (function parameter says (CvUnit& kAttacker...).
 
After some more dig-in. I think I found the right place to modify: CvUnit.cpp for the combat result and EnemyUnitPanel.lua for the tooltips of combat prediction. Is that correct? Forgive me for those many questions...I'm pretty new to the dll modification.

Thank you!
xxhe
 
there is a replacement for RunCombatSim called CombatResult in whoward's DLL (imported from R.E.D. and you can use it with the same parameters you used with the old event...)
 
I meet a problem in editing dll.. I followed this instruction: http://forums.civfanatics.com/showthread.php?t=479374

Then I didn't change anything, and I tried to build the dll by using "Build". What I see is something like this (the build is failed):
"warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss"
There are over 900 bugs like this. I didn't change format nor did anything else.


edit: The warning doesn't really disallow me to do any thing. So I'll just let it be
 
Back
Top Bottom