MongooseMod SDK Stuff

Actually, regardless of whether chance returns 0 or 1, or something from 0 to 0.999999 recur, if a unit has a first strike, either natural or promotion, then setCombatFirstStrikes will always be non-zero. This is because firstStrikes() returns natural + promotions. So your example of "Assume zero full first strikes. If you have 5 fs chances" is invalid because firstStrikes() will return the addition of both parts, not one of the two parts.

If a unit has 1 first strike under vanilla code, then the "else" becomes 1 + random chance. Now, even if the chance is 0 there will always be 1 first strike.

If a unit has 1 first strike under your code, then the "else" becomes 1 + random chance + 1. This gives the unit a minimum of 2 first strikes in combat even though the abilities give it 1.

I think your code is giving an extra first strike for free.

Dale
 
Dale said:
I think your code is giving an extra first strike for free.
That much is obvious. And I'm still rather certain you're wrong, no offense. Maybe if you weren't so convinced I don't know what I'm talking about it'd be easier to show you the truth.

Dale said:
or something from 0 to 0.999999 recur,
That is impossible, b/c it returns integers.

Dale said:
if a unit has a first strike, either natural or promotion, then setCombatFirstStrikes will always be non-zero. This is because firstStrikes() returns natural + promotions. So your example of "Assume zero full first strikes. If you have 5 fs chances" is invalid because firstStrikes() will return the addition of both parts, not one of the two parts.
So? You are completely missing the point. I am NOT saying setCombatFirstStrikes will or will not always be anything. I am taking issue with how it converts FS Chances into actual FS's. I meant assume the unit has 0 full fs's and 5 fs chances IN THE XML or with promotions, going INTO setCombatFirstStrikes.

Dale said:
If a unit has 1 first strike under vanilla code, then the "else" becomes 1 + random chance. Now, even if the chance is 0 there will always be 1 first strike.
Yep. No argument here.

Dale said:
If a unit has 1 first strike under your code, then the "else" becomes 1 + random chance + 1. This gives the unit a minimum of 2 first strikes in combat even though the abilities give it 1.
False. Because Soren(1) still always returns 0. My +1 is in the Soren argument, not added to its result.

Remember, 0 to x-1 with a minimum of 0 is the range on the result, I'm certain of it having gone over the code. (There's also several dozen instances of vanilla code calling Soren in other places that assumes this. Take any instance -- and there are many -- of odds = some integer i, like 60. The test that follows is Soren(100) < i. Not <=. That can only be right if the range is 0 to x-1. Meaning in this case 0 to 59. Which is exactly 60 actual numbers, counting them. The remaining set is 60 to 99, or 40 actual numbers. 60 / (60 + 40) = 60%.)

The fundamental problem is that, in my 15+ years of computer programming, I have never seen a random function that didn't return EITHER (0 to x-1) OR (1 to x). It's common sense that if you pass the argument 5 you want the return range to encompass 5 numbers. It's also tradition and precedent that it's done this way. With First Strike CHANCES, you want the ENTIRE range returned. 5 chances means you could get none of them. You could get all of them. Or anything in-between. That's 6 total values: 0 1 2 3 4 5. It means Soren(chances+1) has to be used regardless. If the function returns (1 to x) you have to subtract off 1 afterward but the bound still has to be expanded to encompass the extra value.

If anyone else wants to jump in and back me up on this, *please* feel free.

On a side note, just picking a random like this is the same as doing a coin flip FS-Chances times and adding up the resulting 0's and 1's, except that the distribution is different. The coin flip method gets you a Bell Curve; the single-random-from-the-whole-range gets you a horizontal line. I like the latter better in this case personally.
 
Okay okay, no need to get heated up.

I only wanted to find out "why" the fix is needed. To some of us, no matter how correct you are you can't just say you are correct and the fix is needed (like you do in your first post). Some of us need to know the whys and hows because we have our own mods relying on the same code you're fixing (IE: my combat mod). Also, there are still some of us that would be horrified to think our opponent is getting free first strikes over what they should be.

I will agree on one thing, it's not the standard way to get a random number, but necessary due to multiplayer and avoiding OOS's. But that's another story.

Dale
 
soren random numeber function is essentially works like this ...

generate some unsigned long random number r_long
r_short = truncate r_long to unisigned short ( ( r_long & MAX_UNSIGNED_SHORT)
result = ( r_short* argument) / (MAX_UNSIGNED_SHORT + 1)

so if arugment is 0 or 1, it allways evaluated to 0.
sorenRNG(100) will yield only 0 ... 99 as result.

So sorenRNG( FS_chance ) will yield actually (FS_chance -1) chance of FS.
This is not what we (and game designer) intended.
We expect FS = 1 will yield 0.5 FS on average, FS = 2 will yield 1.0 FS on averge.

Good find, Mongoose... I think your fix should be included in next official patch/expansion.
 
LunarMongoose said:
Remember, 0 to x-1 with a minimum of 0 is the range on the result...

...With First Strike CHANCES, you want the ENTIRE range returned. 5 chances means you could get none of them. You could get all of them. Or anything in-between. That's 6 total values: 0 1 2 3 4 5. It means Soren(chances+1) has to be used regardless...
You should add this to your explanation of the fix on the first post (maybe slightly rephrased), this will make it much clearer. :trophy:
 
I think your mod is great! I want to add it to my second compilation of small mods, but since I am also loooking to include:

Cultural Influences
By: TheLopez
http://forums.civfanatics.com/showthread.php?t=170884

And this mod contains a dll change as well, I am doubtful I can do this on my own.

I have read the instructions on using the SDK and understand that fine and think I might be able to attempt the merger, but when I look at the source files included in the Cultural Influences mod something does not seem right to me. There seem to be two instances of two different files, how they relate is what is confusing me.

If you could provide any help (or of course make the necessary changes :blush: ) I would be very thankfull.
 
Top post updated again. Added the TextColorMod. Added some extra stuff (not documented in top post) in support of my version of Teg's UnitStatisticsMod, which you'll be getting in my Full Mod which should be going up in another day or so. No other changes.

Rabbit said:
You should add this to your explanation of the fix on the first post (maybe slightly rephrased), this will make it much clearer. :trophy:
I would've Rabbit, but someone on here (not sure if I'm allowed to say who, heh), being an official Civ4 beta tester, was kind enough to relay the fix to Firaxis and it made it into Warlords a week or two ago. Sadly I won't be getting my name in the credits for it (pfft), though I was told if there'd been more than one bugfix that might've happened. Oh well. So yeah, no point updating the description when I'm just gonna have to take it down in a few days.
 
LunarMongoose said:
Top post updated again. Added the TextColorMod. Added some extra stuff (not documented in top post) in support of my version of Teg's UnitStatisticsMod, which you'll be getting in my Full Mod which should be going up in another day or so. No other changes.


I would've Rabbit, but someone on here (not sure if I'm allowed to say who, heh), being an official Civ4 beta tester, was kind enough to relay the fix to Firaxis and it made it into Warlords a week or two ago. Sadly I won't be getting my name in the credits for it (pfft), though I was told if there'd been more than one bugfix that might've happened. Oh well. So yeah, no point updating the description when I'm just gonna have to take it down in a few days.
Screw credits, you know you came up with the fix, and we know you came up with the fix, so it's all good, and all the better for being included in the official expansion. :goodjob:
 
LunarMongoose said:
Mongoose AirLethalityMod 1.2 (CvUnit.cpp, CvUnit.h, CvInfos.cpp, CvInfos.h, CyInfoInterface1.cpp)

This modifies how damage dealt on interception is calculated. Originally it used an internal lookup table, but that had to be configured for each mod it was used with and changing the values required recompiling the DLL. It also had some limitations in differentiating units with the same intercept chance.

So! The <iInterceptionLethality> XML tag is now supported. It comes right after the <iInterceptionProbability> tag. (I threw the schema file in with the zip; it also has the <bFlying> tag in it.) Acceptable values for this tag are (-99 to -1), 0, and (1 to 100). They all do different things. Using 0 makes a unit do no damage on interception (though it'll stop the thing it intercepted from completing its air mission as you'd expect). (1 to 100) specifies the chance an intercept will be lethal. Using negatives in the range (-1 to -99) tells it to be non-lethal, with the damage done capped at the percent the sign-flipped version of your number specifies. (-40 will mean non-lethal, with damage ranging from 1% to 40% of the target's max HP. Things like this can still kill the target if it was not at full health to begin with.) The function "int getInterceptionLethality()" is available to Python as a member of CvUnitInfo (not CvUnit).

Just to be clear on this: an interceptor with -40% Intercept Lethality will never kill, but will do damage up to 40% of the target's health, whilst an interceptor with +40% Intercept Lethality might kill, but if it doesn't it will still do damage up to 40% of the target's health?

What determines the chance of a lethal intercept? Would it be (in this example) 0% for the interceptor with -40% and 40% for the interceptor with +40%?
 
Rabbit said:
Screw credits, you know you came up with the fix, and we know you came up with the fix, so it's all good, and all the better for being included in the official expansion. :goodjob:
"A cornered rabbit is more dangerous than a wounded jackal..." -- MGS1, modified

Anyway thanks for your support. :)

zulu9812 said:
Just to be clear on this: an interceptor with -40% Intercept Lethality will never kill, but will do damage up to 40% of the target's health
Up to 40% of the target's max health, yes. So it can kill if the target was badly hurt going in. I'm not using this feature personally, just thought it'd be cool to throw in for completeness. :)

zulu9812 said:
whilst an interceptor with +40% Intercept Lethality might kill, but if it doesn't it will still do damage up to 40% of the target's health?

What determines the chance of a lethal intercept? Would it be (in this example) 0% for the interceptor with -40% and 40% for the interceptor with +40%?
If it's set to +40%, then it has a 40% chance to be lethal. If it fails that roll, then it does damage randomly between 1% and 99% of the target's max health.
 
New version posted that is Warlords-compatible. Don't think I made any mistakes in the conversion but could stand to double-check sometime.

Also, contrary to what I'd been told, it seems the FirstStrikeFix was not, I repeat NOT, put in the expansion. At least, it's not in the SDK source files provided with the expansion, which I can only assume are the same ones they used to compile their DLL. The modification dates on their source files (and the DLL) only go up to June 27 so it's likely the fix simply didn't make the shipping version and will be in a future patch. I'm going to continue providing it until then however. :)
 
I actually told you it missed the release, and would show up in a future patch.

Dale
 
Dale said:
I actually told you it missed the release, and would show up in a future patch.Dale
Well you may have meant to, but I have no recollection of that and can't find that you said that anywhere.
 
Top post updated again. New version contains the following changes:

AirLethalityMod updated: UI support for iInterceptionLethality
FlyingModExtension added: UI support for bFlying
UnitNameMod added: see top post for effect
StatisticsMod now documented
CityHappyStringMod now documented
 
I have a request though I'm not sure you're open to any. But since you dipped into firststrikes already I hope you are for this one:
The display of combat odds usually gets messed up by firststrikes especially if units have multiple ones. If you could fix this your Firststrike fix would indeed have to be deemed complete:)
I really could use this for my mod but I'm sure others would be happy as well.
 
Another thing, when a unit has -1 movement cost the info get some random very small/large number, like "-1764524 movement cost".
 
Version 1.6 posted, minor update, just added one component: CityTileCommerceMod.

Next thing, which is relatively high priority, is gonna have to be fixing the unit models not respawning as units heal thing in Warlords, since nobody replied to my inquiry thread.

Glovz said:
Maybe you should add "Dale's Combat Mod!" into yours.
http://forums.civfanatics.com/showthread.php?t=168966
Looks like it may be a good fit.
I did give that a look a long time ago but I'm sure it's grown since then. We'll see, though I'm honestly pretty satisfied with vanilla combat as-is. Regardless I don't have any spare time at the moment for optional additions.
 
Back
Top Bottom