Any ideas on how I make baddy1 stick to his uzi?

builders help builders

Moderator: eTux

sapper
Member
Member
Posts: 129
Joined: 23 Mar 2008 13:07
Contact:

Re: Any ideas on how I make baddy1 stick to his uzi?

Post by sapper » 13 May 2012 12:24

I'm bumping because I have useful info that TREP experts can use to make this patch.

Baddy1's uzi ammo is decremented at the following offset.
Two lines above Baddy1 uzi damage real offset.

Code: Select all

0040C9F5       DEC WORD PTR DS:[ESI+38]      
I do not know enough to make the patch or flipeffect but in ollydbg I changed DEC to INC and Baddy1 never drew his sword since his ammo count increased as he shot.
Probably NOPs would be better.

User avatar
Fluen
Member
Member
Posts: 904
Joined: 01 Mar 2006 18:37
Location: Elsinore, Denmark

Re: Any ideas on how I make baddy1 stick to his uzi?

Post by Fluen » 13 May 2012 14:18

Jesse wrote:So he just needs to conveniently become conscious on top of a mountain of uzi clips? :D
Not quite. Remember, that the ones he stands on, when he's triggered, are the ones Lara is able to pick up after his death - or so I think. Hmmm, more testing I guess. :hammer:

My previous experiments revealed, that he's more concerned with killing Lara. I left 10 uzi clips scattered around in one room, but he only took one set and didn't take another, untill all his supplies were exhausted.

If I lead him through several rooms, he was more prone to take a set in each room. But perhaps this is also a matter of Lara getting too far ahead of him, so he turns to more relevant matters - the nearby ammunition.
sapper wrote:I'm bumping because I have useful info that TREP experts can use to make this patch.

Baddy1's uzi ammo is decremented at the following offset.
Two lines above Baddy1 uzi damage real offset.

Code: Select all

0040C9F5       DEC WORD PTR DS:[ESI+38]      
I do not know enough to make the patch or flipeffect but in ollydbg I changed DEC to INC and Baddy1 never drew his sword since his ammo count increased as he shot.
Probably NOPs would be better.
You mean replace DEC with NOP?

sapper
Member
Member
Posts: 129
Joined: 23 Mar 2008 13:07
Contact:

Re: Any ideas on how I make baddy1 stick to his uzi?

Post by sapper » 13 May 2012 15:22

Yes, create a new custom patch and replace the 4 bytes at the offset with code for 4 NOPs e.g. 90909090.
NOP means the exe will do nothing and so won't decrement the ammo so Baddy1 ammo amount will never change.

I have actually created the custom patch and it seems to work.
Can give you instructions if you want but it means all Baddy1s in all levels will have unlimited ammo.

I will try to learn how it can be made also into a custom flipeffect.

Be aware I'm only new to TREP patching.

User avatar
Fluen
Member
Member
Posts: 904
Joined: 01 Mar 2006 18:37
Location: Elsinore, Denmark

Re: Any ideas on how I make baddy1 stick to his uzi?

Post by Fluen » 13 May 2012 15:43

So am I. You already seem to know more about how to do it than I. I don't even know whay you mean with offset code or were to insert the digits.

And because all baddy1's in my levels are Western mercenaries, the patch you mention sounds like just the thing. :2thumbsup:

uzi master
Member
Member
Posts: 108
Joined: 22 Dec 2010 04:46

Re: Any ideas on how I make baddy1 stick to his uzi?

Post by uzi master » 13 May 2012 21:09

I too would like to know how to change that, if you would be so kind as to explain. :D

I hadn't noticed the problem in my 20x20x20 challenge level, but it has shown up in my next entry and I wouldn't mind my Baddy_1 and 2's not switching to their swords once they pull out an uzi. (it would let me get a better difficulty curve, at the start I make baddies attack you with swords, later when you have more weapons they start shooting you, it's quite annoying if they stop shooting and pull out swords.)

User avatar
Gerty
Mod
Mod
Posts: 9578
Joined: 28 Aug 2001 23:55
Location: Holland

Re: Any ideas on how I make baddy1 stick to his uzi?

Post by Gerty » 13 May 2012 21:11

Fluen, have a look here (thanks to sapper I have to say :) )

http://www.tombraiderforums.com/showthread.php?t=191128
Oops, I did it again... Image

sapper
Member
Member
Posts: 129
Joined: 23 Mar 2008 13:07
Contact:

Re: Any ideas on how I make baddy1 stick to his uzi?

Post by sapper » 15 May 2012 03:36

Fluen wrote:So am I. You already seem to know more about how to do it than I. I don't even know whay you mean with offset code or were to insert the digits.

And because all baddy1's in my levels are Western mercenaries, the patch you mention sounds like just the thing. :2thumbsup:
You can think of a computer program as a very long list of instructions.
Offset means a position in that list.

The trick to patching is knowing whereabouts in the list is the instruction or data you want to modify.

In the downloads section of the TREP homepage are three text files created by the hard work of the TREP authors that tell you where to find the instructions in tomb4.exe for some game data and events but it is far from complete. Note must use euro XP patched or original tomb4.exe which can also be downloaded at the site and this is why TREP cannot be used with the TRNG tomb4.exe

For example the listing tells you where to find the code that sets Baddy1 health points.

+10 OCB doubles the amount of ammo from 24 to 48 and Baddy1 uses 7 ammo every time he shoots.

For instance there must be some code in tomb4.exe that sets a Baddy1's default ammo but I couldn't find it and it wasn't in the published listing.

There must be some code in tomb4.exe that doubles Baddy1's ammo if OCB is +10 but I couldn't find it either.

There must be some code in tomb4.exe that makes Baddy1 shoot seven times each round, but where is it?

EDIT: Tutorial for making the custom patch is here.

http://www.tombraiderforums.com/showthread.php?t=191186
Last edited by sapper on 20 May 2012 13:13, edited 1 time in total.

aktrekker
Newbie
Newbie
Posts: 66
Joined: 28 Sep 2010 08:30

Re: Any ideas on how I make baddy1 stick to his uzi?

Post by aktrekker » 20 May 2012 06:13

The code that sets up BADDY_1 and BADDY_2 is the same. It just tests for which one it is. The code is below in Assembly language with memory offsets. If you can convert the memory offset to a file position you can work on a patch.

Code: Select all

0x0040b2f0	 mov      edx , dword ptr [ esp + 4 ]
0x0040b2f4	 push    ebx
0x0040b2f5	 movsx   eax , dx
0x0040b2f8	 push    ebp
0x0040b2f9	 push    esi
0x0040b2fa	 lea     ecx ,  dword ptr [ eax + 2 * eax ]
0x0040b2fd	 push    edx
0x0040b2fe	 lea     ecx ,  dword ptr [ eax + 4 * ecx ]
0x0040b301	 lea     ecx ,  dword ptr [ ecx + 8 * ecx ]
0x0040b304	 lea     eax ,  dword ptr [ eax + 8 * ecx ]
0x0040b307	 mov      ecx , dword ptr [ Data7fe16c ]
0x0040b30d	 lea     eax ,  dword ptr [ eax + 2 * eax ]
0x0040b310	 lea     esi ,  dword ptr [ ecx + 2 * eax ]
0x0040b313	 call    Fun43f330
0x0040b318	 xor     ecx , ecx
0x0040b31a	 add     esp , 04h
0x0040b31d mov      cl , byte ptr [ Data52c212 ]
0x0040b323	 or      eax , 0FFFFFFFFh
0x0040b326	 and     ecx , 01h
0x0040b329 mov     ebx , 018h    // set the value 24
0x0040b32e add     ecx , ecx
0x0040b330	 or      ecx , 029h
0x0040b333	 cmp      word ptr [ esi + 12 ] , 029h // is this BADDY_1?
0x0040b338	 jne     0x0040b351
// Code for BADDY_1
0x0040b33a	 mov      dword ptr [ esi + 015EEh ] , 07FC010h
0x0040b344 mov      dword ptr [ esi + 8 ] , 0FF81FFFFh
0x0040b34b	 mov      word ptr [ esi + 56 ] , bx   // set initial ammo
0x0040b34f	 jmp     0x0040b364
// Code for BADDY_2
0x0040b351	 mov      dword ptr [ esi + 015EEh ] , 0880h
0x0040b35b	 mov      dword ptr [ esi + 8 ] , eax
0x0040b35e	 mov      word ptr [ esi + 56 ] , 00h   // set initial ammo

0x0040b364	 push    edi
0x0040b365	 mov      di , word ptr [ esi + 44 ] // this is the Timer
0x0040b369	 mov      word ptr [ esi + 54 ] , ax
0x0040b36d	 mov     ebp , 03E8h   // = 1000
0x0040b372	 movsx   eax , di
0x0040b375	 cdq
0x0040b376	 idiv    ebp
0x0040b378	 cmp     dx , 09h  // Timer / 1000 between 10 & 19?
0x0040b37c jle     0x0040b392
0x0040b37e cmp     dx , 014h
0x0040b382 jnl     0x0040b392
0x0040b384 add      word ptr [ esi + 56 ] , bx   // initial ammo +24
0x0040b388 add     edi , 0FFFFFFF6h
0x0040b38b mov      word ptr [ esi + 44 ] , di
0x0040b38f	 sub     edx , 0Ah

0x0040b392	xor     eax , eax
0x0040b394	pop     edi
Do not just try to change ebx, as the 24 it contains is used later to set animation numbers. If you can find a way to set word ptr [esi + 56 ] to -1, this will set unlimited ammo. You could eliminate the addition at 0x0040b384, giving you the bytes to do this, but the code at this address also happens for BADDY_2.
The address 40b2f0 is the entry point for this function.
Hope this helps.

sapper
Member
Member
Posts: 129
Joined: 23 Mar 2008 13:07
Contact:

Re: Any ideas on how I make baddy1 stick to his uzi?

Post by sapper » 20 May 2012 13:11

Thanks aktrekker.

This will help me learn more about disassembly.

What debugger did you use?

EDIT: cannot use -1 for infinite ammo since if the value is negative baddy1 will use sword.
Last edited by sapper on 07 Jul 2012 03:26, edited 1 time in total.

User avatar
Fluen
Member
Member
Posts: 904
Joined: 01 Mar 2006 18:37
Location: Elsinore, Denmark

Re: Any ideas on how I make baddy1 stick to his uzi?

Post by Fluen » 02 Jun 2012 14:01

Thank you, all of you.

I have copied both the tutorial on how to make flipeffects and the specific data supplied by HeinzFritz.

It will be great to finally have a working baddy1. His new appearance has been finished for a long time.

sapper
Member
Member
Posts: 129
Joined: 23 Mar 2008 13:07
Contact:

Re: Any ideas on how I make baddy1 stick to his uzi?

Post by sapper » 07 Jul 2012 03:30

Just found another offset that may be useful.

Code: Select all

0040C9EA    MOV WORD PTR DS:[ESI+32],1                 ;baddy1 gunflash visibility flag
If you replace 1 with 0 the baddy1 gunflash is not visible.

If the gunflash for a custom baddy1 is in the wrong spot you can turn it off altogether.

Better option though is to fix the meshtree with TR Wad Reorganizer since this will also give the baddy1 better aiming.

EDIT: Some more offsets. Position of Baddy1 gunflash relative to UZI mesh number.

Code: Select all

0044F8A7      PUSH -3FFC                                               ;  Baddy1 gunflash rotation
0044F8AC      CALL tomb4.0048E080
0044F8B1      MOV EAX,DWORD PTR DS:[ESI+4ACCF0]          ;  baddy1 gunflash pos backward/forward axis
0044F8B7      MOV ECX,DWORD PTR DS:[ESI+4ACCEC]          ;  baddy1 gunflash pos up/down axis
0044F8BD      MOV EDX,DWORD PTR DS:[ESI+4ACCE8]          ;  baddy1 gunflash pos left/right axis
EDIT2: The above code shows where the values are used. ESI is 0x10 in the code so the data is found at the following offsets.

Code: Select all

004ACD00     ; backward/forward axis default 0x000000B4 (180)
004ACCFC     ; up/down axis default 0xFFFFFFEC (-20)
004ACCF8     ; left/right axis default 0x00000000 (0)
Also I believe the DWORD at offset 004ACD04 is the mesh number the gunflash is hardcoded to, default value 0x0000000B.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests