Base Morale on "Impossible"

Base Morale on "Impossible"; support/discussion/questions

Moderator: thunderchero

Post Reply
User avatar
Gowron
Code Master
Code Master
Posts: 304
Joined: Sat Apr 26, 2008 2:00 am
Location: 50° N, 11° E

Base Morale on "Impossible"

Post by Gowron »

As a "side effect" of my hunt for the tech level bonus factors, I've found an entry in trek.exe that determines the base morale "penalty" for starting systems on the "impossible" difficulty level.
(and the tech level bonuses have not been able to hide either, but that will go into another topic later :))

Normally the base morale is 100, but on "impossible" it's reduced by 20 points in starting systems.

This value is stored in trek.exe at position
0x50622.
The default value is 0x14 (=20).
It's length is only 1 byte, and it is signed.
Note that it is subtracted from 100, so positive values will decrease the base morale and negative values will increase it.

Also, you have to follow these limits:
The resulting base morale must be greater than zero. So the highest valid value is 0x63 (=99), leading to a base morale of 1.
On the other hand, the resulting base morale must not be greater than 200. So the lowest valid value is 0x9C (=-100), leading to a base morale of 200.
As always, invalid values will yield a speedy, unbureaucratic return to the desktop ;)
A discovery consists in seeing something everybody has seen and at the same time thinking something nobody has thought yet.
User avatar
DOT
Lieutenant-Commander
Lieutenant-Commander
Posts: 100
Joined: Tue Dec 23, 2008 3:00 am
Location: 49°N, 8°E

Post by DOT »

First: Does this penalty applies only to human player? Or does it affects AI too?

Second:
with small changes it is possible to increase the base moral for starting systems expect on "impossible" level:

Code: Select all

old code:
	0x0505FC	6683 3D44 2B5A 0005	cmp ds:word_5A2B44, 5
			752B			jnz short loc_451231
and:	0x050622	83E8 14			sub eax, 14h
has to be changed to:

Code: Select all

new code:
	0x0505FC	6683 3D44 2B5A 0004	cmp ds:word_5A2B44, 4
			7F2B			jg short loc_451231
	0x050622	83E8 F6			sub eax, -10
What it's worth has to determine everybody on his own... :wink:
life long and prosper
User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2392
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Post by Tethys »

I think it would be interesting for the AI to start with higher Base Morale (Such as 160ish) and your empire starts at 80 to make it MUCH more of a challenge at least (since morale is doubled, thus production of AI is greater)

Also, might you know where the subroutine for the Morale deterioration is? (The morale goes down when Empire is idle.. such as no battles fought, no recent colonization, no declarations of war)
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1884
Joined: Sun Apr 27, 2008 2:00 am

Post by Spocks-cuddly-tribble »

DOT wrote:Does this penalty applies only to human player? Or does it affects AI too?
Self-evident player only ^^.


AI morale bonus on impossible:

0x508B8 (default +10)

At loc_451488 it's possible to free up enough code space for any desired effect.
For example something like Base Morale + ( [difficulty_level-1]*8 ) for AI, should be easy to do.


Tethys wrote:might you know where the subroutine for the Morale deterioration is?
:arrow: how Morale works :idea:

loc_43F41D.. (for AI loc_43F58A..)


0x3E9EA (default 03) AI morale bonus if morale is lower than base morale

Aside of this, the AI is unaffected by additional morale penalties in conquered systems (-1 / home -2).

Also here should be enough code space for any desired modification.
For example AI morale bonus = ([turn_number/64] +1) as compensation for AI weakness in empire development.
Last edited by Spocks-cuddly-tribble on Tue Nov 16, 2010 11:09 am, edited 1 time in total.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
DOT
Lieutenant-Commander
Lieutenant-Commander
Posts: 100
Joined: Tue Dec 23, 2008 3:00 am
Location: 49°N, 8°E

Post by DOT »

Hello,

following the idea of changing AI morale depending on difficulty level I managed to mod some peace of code which also works - makes me wonder since I am an absolute programming beginner... lol

The new code gives AI no morale bonus for difficulty level 1, on level 2 AI gains a +8, on level 3 a +16, on level 4 a +24 and on level 5 a + 32.

Code: Select all

old code:

00451488	mov	dword ptr [edx+4], 1
0045148F	cmp	ds:word_5A2B44, 5
00451497	jnz	loc_451231
0045149D	xor	eax, eax
0045149F	mov	ax, word ptr [esp+168h+var_8]
004514A7	movsx	ax, [esp+eax+168h+var_70]
004514B0	mov	edx, [esp+168h+var_18]
004514B7	add	eax, 1Eh
004514BC	jmp	loc_451223


new code:

00451488	mov	dword ptr [edx+4], 1
0045148F	xor	eax, eax
00451491	mov	ax, word ptr [esp+168h+var_8]
00451499	movsx	ax, [esp+eax+168h+var_70]
004514A2	mov	edx, [esp+168h+var_18]
004514A9	push	ebx
004514AA	xor	ebx, ebx
004514AC	mov	bx, ds:word_5A2B44
004514B3	dec	ebx
004514B4	shl	ebx, 3
004514B7	add	eax, ebx
004514B9	pop	ebx
004514BA	nop
004514BB	nop
004514BC	jmp	loc_451223

for copy&paste new hex code is:

Code: Select all

0x050888:

C742 0401 0000 0031 C066 8B84 2460 0100
0066 0FBE 8404 F800 0000 8B94 2450 0100
0053 31DB 668B 1D44 2B5A 004B C1E3 035B
9090 E962 FDFF FF
What is it worth?
I'd run some test games on large galaxy map with biggest map (52 x forgot squares) with some more mods (mainly some adds for the AI, decreasing money output, increasing morale levels from 5 to 6, increasing system pop and increasing tech level thresholds)
On turn 150 on big map and impossible difficulty level I am near tech level 5 (start was tech level 2 for all) and I am constantly closing the gap between AI empires and me as romulan (taken from game stat overview graph). All AI empires seems to be on at least tech level 5 and since I didn't have any ship on level II the would all outgun me on first contact.
Maybe on turn 300 I will begin to dominate the AI but till that it will be a very hard game. I love it! :D
life long and prosper
User avatar
DOT
Lieutenant-Commander
Lieutenant-Commander
Posts: 100
Joined: Tue Dec 23, 2008 3:00 am
Location: 49°N, 8°E

Post by DOT »

BTW:
Morale bonus for AI seems to be applied only on home and the additional starting systems. New colonized AI systems are not affected by the morale bonus. :evil:
That means that AI gains the morale boost only for starting systems (e.g. science). Since on very big maps first contact most likely occurs not before turn 150+ or so, the impact for new colonies weights harder than starting morale boost for AI.
Spocks-cuddly-tribble wrote:Example for AI morale bonus on new colonies

Code: Select all

remove:
469AE4           jle     CS_production_too_low // redundant

replace: mov with add
469B46           mov     [edx+2F0h], ax // base morale
469B4D           mov     [edx+2DCh], ax // start morale

move this down (code space from skipped redundant):
469D98           jmp     loc_469AB7

and insert:
your AI bonus calulation -> to edx
mov     [eax+2F0h], dx // AI base morale bonus
mov     [eax+2DCh], dx // AI start morale bonus

>>Edit: I mean that on turn 150+ the approx 30 newly founded colonies have a major influence on empire development compared to only up to 4 fully equipped AI starting systems which gaves a morale based bonus on all values. Especially if the biggest new colonies are fully developed and equipped with main buildings at the highes aviable tech level. While AI may have 2 to 5 of them I guess that human players will have 8 or more, and the human player gains morale boni on any system while the new AI systems seems to be immune to nearly any morale influence...<<

So I suggest, if one likes AI to be more challanging till turn 200 to modify the code like this:

Code: Select all

0x050888: 

C742 0401 0000 0031 C066 8B84 2460 0100 
0066 0FBE 8404 F800 0000 8B94 2450 0100 
0053 31DB 668B 1D44 2B5A 004B C1E3 045B 
9090 E962 FDFF FF 
This means in asm:

Code: Select all

004514B4   shl   ebx, 4
This modification gives AI no morale bonus for difficulty level 1, on level 2 AI gains a +16, on level 3 a +32, on level 4 a +48 and on level 5 a + 64.

Or said in other words: on Impossible it should be (nearly) impossible to survive war against AI in the first 100 turns (after all only as long as AI don't act too stupid)
Last edited by DOT on Tue May 18, 2010 10:20 am, edited 2 times in total.
life long and prosper
User avatar
Peter1981
Rear-Admiral
Rear-Admiral
Posts: 1118
Joined: Tue May 06, 2008 2:00 am
Location: England

Post by Peter1981 »

so if i want
level 1, on level 2 AI gains a +4, on level 3 a +8, on level 4 a +12 and on level 5 a + 16

do i substitute

Code: Select all

004514B4   shl   ebx, 5
User avatar
Flocke
BORG Trouble Maker
BORG Trouble Maker
Posts: 3197
Joined: Sun Apr 27, 2008 2:00 am
Location: Hamburg, Germany
Contact:

Post by Flocke »

havn't checked the whole formula, but shl means "shift left" (by appending zeros to the right) so shift left by 5 instead of 4 actually means to double the value in binary number system.
So essentially DOT's code above means to double the value of [difficultylevel-1] four times and add it to the moral.

To achieve your goal you'd need to use

Code: Select all

shl ebx, 2
User avatar
Peter1981
Rear-Admiral
Rear-Admiral
Posts: 1118
Joined: Tue May 06, 2008 2:00 am
Location: England

Post by Peter1981 »

thanks Flock -- i'm still learning the asm stuff yu help is really appriciated thank-you.
User avatar
DOT
Lieutenant-Commander
Lieutenant-Commander
Posts: 100
Joined: Tue Dec 23, 2008 3:00 am
Location: 49°N, 8°E

Post by DOT »

Some month ago, when mikar was thinking about a morale boost of 60 points for AI, I thought "Uh, this is way to much" but since I run some tests on big galaxy with 52 x 38? squares I am convinced that a +64 morale bonus on impossible is more suitable than "only +32".

>>Edit: It was Thetis who had the idea and he posted this in this thread on 24. Jan<<

BTW: The highest morale values could be gained by changing:

Code: Select all

004514B3   dec   ebx 
004514B4   shl   ebx, 3
to

Code: Select all

004514B3   inc   ebx 
004514B4   shl   ebx, 4
which will result in a +32 / +48 / +64 / +80 / +96 morale boost but only on starting systems for AI...
Last edited by DOT on Tue May 18, 2010 10:10 am, edited 2 times in total.
life long and prosper
User avatar
Peter1981
Rear-Admiral
Rear-Admiral
Posts: 1118
Joined: Tue May 06, 2008 2:00 am
Location: England

Post by Peter1981 »

cool this work just need to test for balance thanks to both of you for your help
Post Reply

Return to “Base Morale on "Impossible"”