[Col] combats

brut

Chieftain
Joined
Aug 18, 2004
Messages
9
Hi there! I want to tell you about how battles work in colonization. I knew it when I was studing cheat mode. I believe you'll be interested it.

So, run colonization, choose spain at viceroy level (i'll explain below why) and turn cheat mode on (alt - WIN). Reveal all the map. Create militia close to indian village. Attack indian village.

Let's see:
Combat analyses

-----------------------------------------------------
Soldiers 2
Attack bonus +50%
Spain bonus +50%

Soldiers +36 (*)
(following string contains a number, for example: +40) (**)

------------------------------------------------------
Braves 1
Village +50%

Braves +6 (***)
+42 (****)

How do you think, what numbers mean? Listen the answer.

(*) is attack value for random generator.
> Soldiers 2
Soldiers' strength is 2.
2 * K = 2 * 8 = 16
> Attack bonus +50%
16 * bonus1 = 16 * 1.5 = 24
> Spain bonus +50%
24 * bonus2 = 24 * 1.5 = 36

In short,
Attack = Strength * K * bonus1 * bonus2 *...
where K = 8

Attack = 2 * 8 * 1.5 * 1.5 = 36

As consequence, two bonuses +50% better than one +100%

(***) is defence value for random generator. Algorithm is the same.
> Braves 1
Braves' strength is 1.
1 * K = 1 * 8 = 8
> Village +50%
8 * bonus1 = 8 * 1.5 = 12

Attention! There's hidden *bonus* -50% if unit's strength is one and it hasn't got rifles and its opponent has.
If you attack indian braves or foreign colonists with your scout then braves or colonists won't get rifle_bonus -50%
Artillery vs. unarmed unit will cause appearance of rifle_bonus to unarmed unit.


Defence = (1 * 8 * 1.5) * rifle_bonus = 12 * 0.5 = 6

(****) is sum of (*) and (***)
Sum = Attack + Defence = 36 + 6 = 42

Next, number (**) is random value from 1 to Sum. Let's call it Result.

If 1 <= Result <= Attack then attack is successful
If Attack < Result <= Defence then attack isn't succesfull

So, if Result = +40 then our militia demote to colonists status. If Result = +15 then our militia win the battle.


This combat system works for ships as well.

If you choose another level, governor or easer, you'll get some bonuses to combat.
Governor: +1 to your final attack/defence
Conquistador: +2 to your final attack/defence

Easer levels will get you even bigger K while your opponents won't.


I run my DOS colonization version under winXP and I have such a bug:
Result (**) in battles has to be RANDOM VALUE. Instead, this value is increasing consecutive from battle to battle and resets when it reaches Sum.

For example, my militia attack braves and Result is +5. Result in next battle of this turn will be +5, +6 or +7. Next - +6, +7, +8 or +9. And so on. So, there'll be line of WONS and then line of LOSES. And this is explanation of question:

>hirleyrocks
>Jun 18, 2004, 03:42 PM
>I recently hauled out my DOS version of Colonization (version 3.0) and
>installed it on WinXP. Using compatibility mode the game works pretty well...
>the sound doesn't work, but the game is very stable, so I can't complain. I
>have run into a couple of bugs though, and I wondered if anyone else has
>noticed these...


>1) Combat 'streak' bug - I still haven't figured out the specifics on this, but
>I'm positive it exists. What happens is, during a given turn, you will win
>every single battle (at least those that you initiate...I'm not sure about
>battles the AI starts) *or* you will lose every single battle. I think moving
>on to the next turn 'resets' the streak, but a new win or loss streak will
>start right up on the next turn. This bug is a gamebreaker because after the
>first battle of any turn, you can predict the outcome of all other battles
>with 100% accuracy.
.....
>I was curious if anybody else had noticed these bugs and/or if they know of
>a way around them. Especially the combat streak bug. It makes the game
>unplayable :(



So, what do you think about it? Have you noticed this bug, or it depends on OS?
 
That's very interesting. Any idea what causes the Random Value bug? I've played the game on many different systems but it only happens in Windows XP.
 
dalgo said:
That's very interesting. Any idea what causes the Random Value bug? I've played the game on many different systems but it only happens in Windows XP.

I've noticed this bug under Win98 and DOS as well. But!!!! I'm now so excited! I think I know how to handle with this bug !!!! SoftICE rules forever! Just wait some time and I'll give patch.

PS I've found some hidden bonuses that are not documented. One of them:
When indian braves are attacking city with artillery chance of braves to win is 0%, and artillery gets additional bonus "artillery vs raid" + 100%
 
I did it! Really, it was very interesting experience!
So, I know how to get rid of Random Generator Bug.

Do following.
1. Open viceroy.exe in your hex-editor.
2. Find such bytes: A3 EE 28 C7 06
3. Replace A3 with 5D, and EE with CB, so you get 5D CB 28 C7 06
4. Bug was removed!

In some days I'll make more comfortable patch in order not to work with hex editors but just run patch.exe

Enjoy!

PS The problem of Random Generator Bug was caused by too frequent calling randomize () that is syncronization of random seed with current time counter (0040:006C). If calling of randomize function is more frequent than time counter changes then random function returns almost the same value.
 
I've made patch for colonization that fixes combat streak bug. You can download it there http://sixdays.narod.ru/canalization.zip

Edit:
1. I've attached patch to post.
2. Patch works for DOS and Win98 only.
3. To run patch under winXP launch "cmd" process in directory where colonization is placed and then type "start.bat". But sometimes the game freezes under winXP, so it's better to play under dos.
 

Attachments

  • canalization.zip
    14.6 KB · Views: 942
I loaded the patch down and it looks like it works OK. A least the combat seems to be more random. Thanks.

I'm running Colonization using the compatibility mode under Win XP. When you say 'better to run under DOS' do you mean on a straight DOS machine or using a simulator under XP? I've tried DOSBox but had some problems with it.
 
I meant straight DOS, so use boot floppy or boot CD-ROM. But under DOS you have to launch "canali~1" and then "viceroy" because of short names of files (I forgot about it when was creating patch)
 
Thank you for this patch. It seemed at times that the game "knew" when you were getting too powerful... I remember getting my drydocks filled with privateers, four or five, on single turns in the past. :suicide:
 
Wow! Thanks Brut! Nice job! :goodjob: This not only solves the 'combat streak bug', but also the fountain of youth bug that I referenced in the original thread...

http://forums.civfanatics.com/showthread.php?t=91531

It looks like they were both stuck on that same random number problem, which makes sense now looking back at it all. Can I ask how you figured this out? How did you know that those hex values related to the random number function?

Thanks again! :D
 
By the way, for people wondering how best to run Colonization under WinXP (I use the original DOS version of Colonization), I just use the WinXP compatibility mode (select Win95) and I have no problems playing the game at all (except that I don't have any sound...but oh well, at least the game is stable). I edited my Viceroy.exe file according to brut's instructions (I didn't download his patch) and everything still works fine the way it is. So, I'm not so sure you really *need* to boot to DOS to play.
 
shirleyrocks said:
Can I ask how you figured this out? How did you know that those hex values related to the random number function?

First, I knew how battles work using cheat mode. Then I found out that results of battles depends on time, so 2 battles, fulfilled close to each other, had the same result ("random" value). But if you wait some seconds between battles last result will increase slightly. What does it mean? The game often synchronize its random seed with timer (by function randomize ()). But this's real bug because game must call randomize just once. So, the task was to take syncronization out from program code.

It's common known that DOS timer located at 40:6c (long word). SoftICE allows to trace reading from given address (bpm 40:6c r) and it wasn't problem to find out which instructions read timer. There was something like that:

random_seed = get_timer ();
random_seed = generate_random_value (random_seed);

Random function (generate_random_value) returns "random" value depending on random seed, and for 2 equal random seeds "random" values will be equal as well. Let's skip this instructions!
A3 EE 28 C7 06 - these are bytes of original instructions.
5D CB 28 C7 06 - these are our overpatching.

Don't think I know this instruction's code by heart, I just used softICE's possibility to assemble code in assembler language and then I wrote down obtained bytes.

But it wasn't end. Without randomize () the game worked better, but random generator was bad anyway. So I decided to replace game's random generator by my generator.

There's one good program, ArtMoney, it allows to find addresses in memory. I found address where battles result is written. Then I wanted to determine which code instructions write to this address. Unpleasant surprise - the address is part of program stack and too many different instructions write to this address. To solve this problem I defined breakpoint with such condition: writing to found address when ax is equal to 80h. 80h - attack value of attacking frigate. Then I attacked enemy frigate with my frigate. Bingo! Breakpoint executed and I found battle procedure. I checked it and found such instructions:

push ax
push 01
call ....:....

This's calling of function which takes two arguments: 1 and ax. ax keeps (attack+defence) value, so this function returns random value from 1 to ax.

Write own random generator's program and make it resident. Change instruction to call your own random function. Go to drink beer :)

There was many indescribable problems and devastating situations, but aim was reached.

Besides, I used cracked version of SoftICE. I know you don't like illegal programs but I can't buy such kind of stuff every time I want to have fun.
 
brut said:
3. To run patch under winXP launch "cmd" process in directory where colonization is placed and then type "start.bat". But sometimes the game freezes under winXP, so it's better to play under dos.
I am using XP and the patch worked OK until I decided to turn 'Combat Analysis' Off. As soon as I started combat the game froze and I had to reinstall. Has anyone else had this problem?
 
Can i use the patch even without version 3?????
 
This is a fantastic patch and I am so glad that you made this. I noticed this bug years ago and for some lame reason never spoke up -- probably because it was just easier to move on to Civ II. I really appreciate this patch and Brut, I wanted you to know that your work is an asset to the community.

You should consider helping out on the FreeCol.org project.

Best regards,

CivPartisan
 
Sorry for respecting dead thread but I have some difficulties with canalization fix.

The biggest issue is that when I choose to start with custom map and if I take same setting I always get same map. This does not happen without fix.

Another thing that can get confusing for those unaware is that canalization tweak modifies viceroy.exe (without backup), in such way that game can't work without starting canalization.exe every time (otherwise it will freeze on first combat).

It's good idea to backup viceroy.exe before experimenting with this fix.


P.S.
Random map issue also happens if just using original HEX edit tweak (that doesn't depend on running canalization.exe).
 
The only workaround that gets on my mind is to make copy of original viceroy.exe and rename it to something else (like col.exe).

Then use it for starting new game, and then use canalization to play rest of the game.
 
The Canalization fix is a good idea and it was fascinating to read about the details of combat BUT it crashed when I tried it. Not right away but after a few moves/combats it locked up hard requiring a hardware reset.
I run Col under pure (no Win at all) DOS 7.1 on my '97 P166MMX with a SB AWE32 card.
As an aside: The sound's not so hot at times, for some reason Col doesn't like my authentic SB as much as it did the Crystal Audio clone in my newer computer. Weird eh? :)
BTW I've found that the streak bug can be worked around simply by not making several attacks in a row. Takes some self control and patience but it seems to help. I just cycle and move a unit or go and fiddle with a colony/check a report, then come back and make another attack.
 
This patch really crashes the game, giving the error of an integer division by zero in dosbox (Happens every time the AI attack each other or the Indians). Nevertheless, changing the viceroy.exe in hex editor worked like a charm ;)
 
It's good though to see this patch is still in use! There is nothing like a good game of col to refresh the mind...
 
Top Bottom