PieceOfMind's Advanced Combat Odds

I wanted to get all the bugs ironed out in the switcharoo code, but there are still problems when barbarians are involved.

Everything other than the switcharoo stuff is good to go though, so I'm tempted to just release v0.5 without the switcharoo, and instead try to work it into the next version.

I don't like to release something with the note, "Warning: feature (x) may not be accurate in some instances."
 
I'm tempted to just release v0.5 without the switcharoo, and instead try to work it into the next version.

I think this is the best option as long as doing a release isn't a lot of work. I tended to make releases larger for BUG because the release process was tedious. Now that I have a nice NSIS script that can build releases more easily, I'll be releasing more frequently.

I try to follow the motto:

Release early. Release often.​
 
I'm a bit busy over the next few days... hopefully I can work on getting it up on the weekend. The release does take a bit of time because I need to update the documentation etc., but obviously not nearly as much as for a larger mod.
 
No rush here. I'm getting to the point where I want to put the first version of BULL into our SVN, and I'd like to include this mod. I'm not ready to release BULL for a while anyway. This is just for our code server at the moment.
 
Hey PoM, how is 0.5 coming along?
 
:bump:

Version 1.0 released. :)

For now, I have disabled the Switcharoo code because it was not reliable. It will need to go in a later version.

I'm hoping for this version to make it to BUG.
 
I'm putting this into BULL now and had a quick question. Is getCombatOddsSpecific() a new function created for ACO? If so, I'm going to move it to its own file to avoid including a copy of CvGameCoreUtils.cpp. Yes, it requires adding the file to the build targets in the make file (a PITA to be sure), but it's cleaner IMHO, and I already had to add files to the makefile for BULL.

This doesn't change ACO or require anything on your end. I just wanted to make sure I hadn't missed something. BTW, if it is a new function, you don't need to export it in the DLL since the EXE won't use it.
 
Nice PoM. Too bad about the switcharoo thing, but I agree, if it's not displaying correctly, best to just disable it while you figure out how to squash the bug in it. I will point glider to this so that he knows that there is a new version for the next RevDCM build :)
 
I'm putting this into BULL now and had a quick question. Is getCombatOddsSpecific() a new function created for ACO? If so, I'm going to move it to its own file to avoid including a copy of CvGameCoreUtils.cpp. Yes, it requires adding the file to the build targets in the make file (a PITA to be sure), but it's cleaner IMHO, and I already had to add files to the makefile for BULL.

This doesn't change ACO or require anything on your end. I just wanted to make sure I hadn't missed something. BTW, if it is a new function, you don't need to export it in the DLL since the EXE won't use it.

getCombatOddsSpecific() is the new function I put in ACO, yes. Although the name of it mightn't suggest it, it's actually a more general function than the similar function in the original game getCombatOdds(). The difference is getCombatOddsSpecific() returns the probability of battle outcomes where the number of hits taken by the defender and attacker are specified. So rather than just returning the one value for the combat odds, it can return the several values for each combat outcome.

Do whatever you need to do with it. Perhaps you can make whatever changes you need to then mail it back to me and I'll make it v1.1. I might as well make the latest version be the same as the one you're putting into BULL.

Re it not being needed to be exported to the DLL: lol well I guess I'm a bit of a hack because I did it hoping it would work and it worked so I used it. :D

I'm not a programmer by profession, which you can probably tell by the structure/layout of my code! :lol:

Nice PoM. Too bad about the switcharoo thing, but I agree, if it's not displaying correctly, best to just disable it while you figure out how to squash the bug in it. I will point glider to this so that he knows that there is a new version for the next RevDCM build :)

You might be able to help me get the switcharoo going properly. At the moment, it seems to work alright when there are no combat modifiers from defensive terrain, but it goes stupid when there are. For example, when a sword attacks a sword on a forest, the normal way round works ok but holding ctrl (switcharoo) makes it spit out 0% for every attacker HP outcome (something's obviously going wrong) and still print out the +50% defense as being for the wrong unit (this time for the attacker but the attacker is not on a forest).

It's probably going to involve using some form of plot swapping like EF was talking about a few posts ago but I haven't managed to figure out how exactly to do it.

BTW, the header file name has a typo:

AdvancedCobmatOdds.h​

lol well spotted. You can just remove the file altogether now though right?
 
getCombatOddsSpecific() is the new function I put in ACO, yes.

I missed the similarly named function just above it, but once I saw that I changed my mind. It makes sense to keep it in that file as it is related. Plus it's a serious PITA to change the make file.

Re it not being needed to be exported to the DLL: lol well I guess I'm a bit of a hack because I did it hoping it would work and it worked so I used it. :D

I'm just passing along advice as I go, hopefully without sounding too much like a smart ass. ;)

I'm not a programmer by profession, which you can probably tell by the structure/layout of my code! :lol:

You'd be surprised how much passing it through Visual C++'s Edit : Advanced : Format Code function can help! There's nothing prettier than uniformly-formatted code.

You can just remove the file altogether now though right?

The constants for the levels of detail are useful. In fact, I use them when referring to the default value and using SHIFT to switch to the EVERYTHING level. I renamed the file without any trouble.

As for using the version that goes in BULL, there are two problems with that. First, BULL uses getBugOptionBOOL/INT() to access the options. Second, BULL has a bunch of other changes in CvGameTextMgr.cpp. I only had to modify your code slightly (not counting the reformatting and changing "BOOL" to "bool") to use BUG's method of accessing options.
 
EF do you want me to get a copy of the files you've changed or are you happy for me to just keep working on the mod? If there are things like the BOOL vs bool etc. that I need to change I might as well do it now so there's less work for you if I make any more changes.

I'm gonna have a bit more of a fiddle with the switcharoo stuff. It's really baffling me tbh.
 
Hey PieceOfMind I'm a bit confused as to what's new with 1.0, the changelog doesn't say much to me, am I missing it or can you clear it up?

Not much obvious stuff changed. The interface should look almost identical to v0.4.

Explanations in bold

v0.5
-1 decimal place only for Low setting (minor change)
-Merged HP bars when they were individually less than some cutoff - currently 0.5%. Note the attacker min HP bar was left alone in case retreat odds came into it. (this meant reducing the number of HP bars - important for running the mod at lower screen resolutions because it was possible for there to be too many lines to fit on screen!)
-Added XP modifiers (eg. Great General promotion - Leadership) (try getting the Leadership promo and you will see it tells you the additional XP you will get from battles in cyan)
-Fixed XP range calculations so they will work with mods (minor change - nothing will be noticed in-game)
-Added detail about free wins vs barbs - now shows correct odds for such battles unlike old calculator which lied to the user. (note this only works if defender is barb at the moment) (At difficulties of Prince and lower, the first few battles that are fought with barbarians skew the odds heavily in favour of the human player (possible for the AI as well I'm not sure). After the number of "free wins" have been used up it's combat as normal. "free wins" is a bit of a misnomer because it's still possible to die in one of these battles but the odds are typically 99% or so in favour of the player. Also, if you are unlucky enough to die in one of these battles, it doesn't decrease the counter of free wins remaining. Obviously this figure will only display at Prince difficulty or lower)
-Added correct XP taking barb XP caps into account, including animals. e.g. if on 8XP and killing the barb would normally result in large xp, the shown amount will be only 2. (this just means it won't tell you you'll earn XP over 5XP from animals nor over 10XP from ordinary barbarians.)
-Fixed negative XP bug in barb normalization code (thanks to phungus420) (it was only present in earlier builds of this version) (nothing to notice in-game here)
-Prevented the unit unharmed HP bars from being combined with others. eg. if you use a warrior to attack an infantry it will still show you the bar with the probability of your warrior keeping 100HP or whatever other hitpoints it starts with. (the 100HP bar will always be left alone - not combined with the other HP bars. That is unless the current hitpoints of the unit are less than 100 (ie. injured). In that case, the bar for that number of HP is left alone.)

v0.5 was never released so everything in v0.5 is basically what's new in v1.0. Is that confusing? I could change the readme so it's all under 1.0 but this made more sense to me.
 
CBA reading 13 pages so I will just ask. Can I use ACO together with solver's patch mod and BUG?
 
The answer to your question is no, unless you know what you're doing. In previous versions there were already merged available downloads with Better AI, and the UP. However in this there is no Better AI or UP version up. I'll go ahead and merge those for you (and others), should be up in a day. Merging ACO 0.5 was actually pretty easy, and I think 1.0 should be as well. As far as BUG goes, yes, it merges easily since this mod is all SDK, and BUG has no SDK modifications.

Also PoM sorry about not responding to you about helping with the Switcharoo code, the thing is I don't know C++ very well. For instance I'm currently stuck on how to get the upgrade price to double when an upgrade causes a change in UnitCombatType. That obviously should be trivial, but I can't figure it out :dunno: So I don't really think I can be of any use on the switcharoo code...

By the way, this is what I'm stuck on, in case you have any ideas:

Code:
	iPrice = GC.getDefineINT("BASE_UNIT_UPGRADE_COST");

	iPrice += (std::max(0, (GET_PLAYER(getOwnerINLINE()).getProductionNeeded(eUnit) - GET_PLAYER(getOwnerINLINE()).getProductionNeeded(getUnitType()))) * GC.getDefineINT("UNIT_UPGRADE_COST_PER_PRODUCTION"));
	//phungus ChangeUnitCombatUpgradePrice
		if ( (GET_PLAYER(getOwnerINLINE()).getUnitCombatType(eUnit)) != GET_PLAYER(getOwnerINLINE()).getUnitCombatType(getUnitType()) )
		{
		iPrice *= 2;
		}
	//phungus end
That doesn't work because it says getUnitCombatType isn't a member of CvPlayer :crazyeye:
 
Thanks phungus420! :goodjob:

Muxec, as phungus noted, the merging of this mod with others is generally very easy because this mod only requires insertion of a few blocks of code, and then recompiling the dll (serious modders only). I've beena bit slack with the latest release and haven't merged it with any other mods yet.

I plan to within the next few days merge it with the just released new version of better AI (version 0.70).

If I understand correctly, it's also going to be a feature in the release of the BULL mod. The BULL mod is basically the same as BUG but with a range of DLL-only features included. I'll be making a note in this thread when BULL is released so people will know about it.
 
An idea just came to me, and I haven't thought it out at all yet. I want to capture it before I forget it.

Show which attacker bonuses are subtracted from the defender's strength. For example, CR1, Cover when attacking Archery units, etc.

I was thinking that some defender bonuses apply to the attacker's strength, but upon reflection I don't think that is true. If it is, show those as well.

This should be a simple matter of appending a string to the line items at the bottom of the hover. For a C1 CR1 Cover Swordsman against a C1 Archer:

  • +10% Strength
  • +25% vs. Archery Units [defender]
  • +30% from City (Unit Ability) [defender]
  • +10% Strength
  • ...
A different option would be to simply show them as minuses for the defender. This would require looping over the bonuses twice if you wanted them to remain grouped by att/def. Or you could leave them in-place:

  • +10% Strength
  • -25% vs. Archery Units
  • -30% from City (Unit Ability)
  • +10% Strength
  • ...
Another minor enhancement would be to show the total % applied to each strength:

6.60 [+10%] vs. 7.35 [+145%]
 
Here is your ACO with Better AI (merged source included). I'll build a UP + ACO later, it just takes so damn long for me to compile a gamecore. Also once you upload this to the DB, I'll delete the attachment, so let me know when you pick it up PoM.
 
Top Bottom