Quantcast

Jump to content

» «
Photo

Acess to *_dam's RwFrame

12 replies to this topic
Junior_Djjr
  • Junior_Djjr

    BMS - Brazilian Modding Studio

  • Members
  • Joined: 16 Dec 2011
  • Brazil

#1

Posted 11 June 2014 - 07:35 AM

helu again

 

i'm trying to make a new system of damage, multi layers, and fix some original gta's damage bugs

i need only one more thing to continue this project... i'm trying this when i'm creating my Tuning Mod, i aready tried to this, but... nothing....

 

i need to get the acess of *_dam parts, the RwFrame

 

i get the RwFrame of any part, using "rwFrameFindNodeByName (0x4C5400)" or manually using memory addresses like next/prev frame... but i never can get the *_dam part with this two methods .-.

 

what is the secret?


Shmoopy
  • Shmoopy

    Thug (͡ ͜ʖ ͡)

  • Members
  • Joined: 16 Jun 2009
  • None

#2

Posted 11 June 2014 - 11:38 AM Edited by Manfred Von Karma, 11 June 2014 - 11:39 AM.

All the findings are of _DK

0AA7: call_function 0x4C5400  2  2 _nodname "bump_front_dummy" _rwClump 0@ _storeRwFrame 1@

2@ = 0
3@ = 0
0AA5: call 0x7F1200 num_params 3 pop 3 _GetData 2@v _callback 0x4C7BD0 _RwFrame 1@

It returns the RpAtomic of the damaged (3@) and not damaged (2@) parts:

RwFrame(bump_front_dummy)
   RpAtomic(bump_front_ok)2@
   RpAtomic(bump_front_dam)3@

Junior_Djjr
  • Junior_Djjr

    BMS - Brazilian Modding Studio

  • Members
  • Joined: 16 Dec 2011
  • Brazil

#3

Posted 12 June 2014 - 10:22 AM

thanks man!

 

 

but.. elegy have a plate_ok in the child of bump_front_dam, when i try to get the bump_front_dam, gets the plate_ok of bump_front_dam, infernus don't have the plate_ok in the child, then works all fine

gta-sa21.jpg

good, i tried to get a parent of plate_ok's rpatomic, then returns the sh*t of bump_front_dummy's rwframe .-.

(i know of this is bump_front_dummy and don't bump_front_ok cause when i read the "next" rwframe, gets the bonnet_dummy)

 

anyone can help me? now i'm using the rpatomic render flag to enable/disable the part, but anything to enable/disable a *_dam part will help me 


Shmoopy
  • Shmoopy

    Thug (͡ ͜ʖ ͡)

  • Members
  • Joined: 16 Jun 2009
  • None

#4

Posted 12 June 2014 - 02:46 PM

Try moving to the next or previous atomic by 0x8C , i think that if you do 2@ += 0x8C you'll be at the bump_front_ok atomic


Junior_Djjr
  • Junior_Djjr

    BMS - Brazilian Modding Studio

  • Members
  • Joined: 16 Dec 2011
  • Brazil

#5

Posted 12 June 2014 - 03:30 PM

0x8C? the struct size of rpatomic is 0x70

i think of you meant 0x9C, and this is the next of rwframe, will go to "bellow" of plate_ok (and don't have nothing there lol), the correct is go to parent, to go back and get acess to the bump_front_dam, but i already tried... for some reason, this go to bump_front_dummy

 

anyway, i'm making the mod even with this bug while i have no solution, i got make all cars don't have damage and controll the damage of all cars via cleo script, i'm free to controll this poor damage system fixing bugs and adding more "layers" of damage :p 


Shmoopy
  • Shmoopy

    Thug (͡ ͜ʖ ͡)

  • Members
  • Joined: 16 Jun 2009
  • None

#6

Posted 12 June 2014 - 03:48 PM Edited by Manfred Von Karma, 12 June 2014 - 04:39 PM.

will go to "bellow" of plate_ok (and don't have nothing there lol), the correct is go to parent, to go back and get acess to the bump_front_dam, but i already tried... for some reason, this go to bump_front_dummy

But i guess that the game considers all of them as 4 children of bump_front_dummy

RwFrame(bump_front_dummy)
   RpAtomic(plate_ok)
   RpAtomic(bump_front_ok)
   RpAtomic(plate_dam)
   RpAtomic(bump_front_dam)
 
I may be wrong
0AA7: call_function 0x4C5400  2  2 _nodname "bump_front_dummy" _rwClump 0@ _storeRwFrame 1@    2@ = 0    3@ = 0    0AA5: call 0x7F1200 num_params 3 pop 3 _GetData 2@v _callback 0x4C7BD0 _RwFrame 1@    2@ += 0x8C // Next atomic , in this case it will be front_bump_ok    2@ += 2 // Atomic visibility 5 = Visible 0 = Not visible    0A8C: write_memory 2@ size 1 value 0 virtual_protect 0 // hide front_bump_ok
Between , have you tried vertex morphing ?

Junior_Djjr
  • Junior_Djjr

    BMS - Brazilian Modding Studio

  • Members
  • Joined: 16 Dec 2011
  • Brazil

#7

Posted 12 June 2014 - 04:22 PM Edited by Junior_Djjr, 12 June 2014 - 04:24 PM.

    0AA7: call_function 0x4C5400  2  2 _nodname "bump_front_dummy" _rwClump 0@ _storeRwFrame 1@
    2@ = 0
    3@ = 0
    0AA5: call 0x7F1200 num_params 3 pop 3 _GetData 2@v _callback 0x4C7BD0 _RwFrame 1@
    2@ += 0x8C // Next atomic , in this case it will be front_bump_ok
    2@ += 3 // Atomic visibility 5 = Visible 0 = Not visible
    0A8C: write_memory 2@ size 1 value 0 virtual_protect 0 // hide front_bump_ok

 

you tested?

don't worked here, and i think of rpatomic don't have "next" (and this script is wrong), only rwframe, and are 0x9C, and, i want to get bump_front_dam, when i have plate_dam (sorry before i said plate_ok, but is plate_dam), in this case, plate_dam is the child of bump_front_dam, and the bump_front_dam is the parent of plate_dam, not the next or prev

but...... is impossible to get the *_dam using parent/child, i don't know why, always go to bump_front_dummy... using this function of you passed to me worked in cars of don't have plate_dam, gets the bump_front_dam without problems... but elegy have plate_dam, and then gets the plate_dam instead bump_front_dam

 

 

and i recommend to use this method to edit the flag of rpatomic:

0AA5: call 0x7F1200 num_params 3 pop 3 _GetData 10@v _callback 0x4C7BD0 _RwFrame 9@
              
11@ += 0x2 //flags
0A8D: 30@ = read_memory 11@ size 1 virtual_protect 0 
        
08C3: clear 30@ bit 2 //disable rendering
//08BD: set 30@ bit 2 //enable rendering
        
0A8C: write_memory 11@ size 1 value 30@ virtual_protect 0

Shmoopy
  • Shmoopy

    Thug (͡ ͜ʖ ͡)

  • Members
  • Joined: 16 Jun 2009
  • None

#8

Posted 12 June 2014 - 04:36 PM Edited by Manfred Von Karma, 12 June 2014 - 10:36 PM.

I made a mistake its += 2 not 3 . I tested it and it worked , between , this may help :

:GeometryMorph //0AB1: call_scm_func @GeometryMorph 5 rpGeometry 3@ array 1 xyz 0.05 0.0 0.0
1@ -= 1
1@ *= 12
0085: 5@ = 0@ 
0085: 6@ = 0@ 
0085: 7@ = 0@ 
7@ += 0x14 // vertex count
6@ += 0x58 // morph update   
0A8C: write_memory 6@ size 4 value 0 virtual_protect 0                     
5@ += 0x5C
0A8D: 5@ = read_memory 5@ size 4 virtual_protect 0 // morph target 
                  
5@ += 0x14
0A8D: 5@ = read_memory 5@ size 4 virtual_protect 0 // vertices array  
005A: 5@ += 1@  
0A8D: 8@ = read_memory 5@ size 4 virtual_protect 0 // read x
5@ += 4
0A8D: 9@ = read_memory 5@ size 4 virtual_protect 0 // read y
5@ += 4
0A8D: 10@ = read_memory 5@ size 4 virtual_protect 0 // read z
5@ -= 8
005B: 8@ += 2@  // x
005B: 9@ += 3@  // y
005B: 10@ += 4@  // z
0A8C: write_memory 5@ size 4 value 8@ virtual_protect 0
5@ += 4
0A8C: write_memory 5@ size 4 value 9@ virtual_protect 0
5@ += 4
0A8C: write_memory 5@ size 4 value 10@ virtual_protect 0
0AB2: ret 0

Junior_Djjr
  • Junior_Djjr

    BMS - Brazilian Modding Studio

  • Members
  • Joined: 16 Dec 2011
  • Brazil

#9

Posted 13 June 2014 - 04:40 AM

man, i only wanna get acess to *_dam parts, this "dynamic" damage is not a good thing to use in game, is a slow process, may cause lags and is not effective, mainly in high poly vehicles

 

anyway, i think of this will be good in a other mod (tuning mod? i think no)


Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci Racing
  • Joined: 19 Aug 2006
  • Unknown

#10

Posted 13 June 2014 - 06:23 PM

Damaged and undamaged atomics do not follow the DFF's sub-hierarchy which is somewhat dissolved in CVehicleModelInfo::PreprocessHierarchy (0x004C8E60). Take this code to get a list of both *_ok and *_dam atomics:
 
{$CLEO}

0000: NOP

const
    _CVisibilityPlugins__GetAtomicId = 0x00732370
end
const
    _GetOkAtomicsCB            = 30@
    _GetOkAtomics              = 29@
    _GetDamagedAtomicsCB       = 28@
    _GetDamagedAtomics         = 27@
    _RwFrameForAllObjects      = 26@
    _nVehicleVisibleAtomics    = 25@
    _nMaxVehicleVisibleAtomics = 24@
    _OkAtomics                 = 23@
    _DamagedAtomics            = 22@
end

0A9F: 31@ = current_thread_pointer

0A8E: _OkAtomics = 31@ + 0x40 // CRunningScript.m_tls[1]
0A8E: _DamagedAtomics = 31@ + 0x4C // CRunningScript.m_tls[4]

0A8E: 31@ = 31@ + 0x10 // CRunningScript.m_ip
0A8D: 31@ = read_memory 31@ size 4 vp 0

0A8F: _GetOkAtomicsCB = 31@ - @_GetOkAtomicsCB
0A8F: _GetOkAtomics = 31@ - @_GetOkAtomics
0A8F: _GetDamagedAtomicsCB = 31@ - @_GetDamagedAtomicsCB
0A8F: _GetDamagedAtomics = 31@ - @_GetDamagedAtomics
0A8F: _nVehicleVisibleAtomics = 31@ - @_nVehicleVisibleAtomics
0A8F: _nMaxVehicleVisibleAtomics = 31@ - @_nMaxVehicleVisibleAtomics

0A8D: _RwFrameForAllObjects = read_memory 0x004C7C3C size 4 vp 1
_RwFrameForAllObjects += 0x004C7C40

0A8E: 0@ = _GetOkAtomicsCB + 7
0A8E: 1@ = 0@ + 4
0A8F: 2@ = _CVisibilityPlugins__GetAtomicId - 1@
0A8C: write_memory 0@ size 4 value 2@ vp 0
0A8E: 0@ = _GetOkAtomicsCB + 0x17
0A8C: write_memory 0@ size 4 value _nVehicleVisibleAtomics vp 0
0A8E: 0@ = _GetOkAtomicsCB + 0x20
0A8C: write_memory 0@ size 4 value _nVehicleVisibleAtomics vp 0
0A8E: 0@ = _GetOkAtomicsCB + 0x26
0A8C: write_memory 0@ size 4 value _nMaxVehicleVisibleAtomics vp 0

0A8E: 0@ = _GetOkAtomics + 3
0A8C: write_memory 0@ size 4 value _nVehicleVisibleAtomics vp 0
0A8E: 0@ = _GetOkAtomics + 0x0D
0A8C: write_memory 0@ size 4 value _nMaxVehicleVisibleAtomics vp 0
0A8E: 0@ = _GetOkAtomics + 0x17
0A8C: write_memory 0@ size 4 value _GetOkAtomicsCB vp 0
0A8E: 0@ = _GetOkAtomics + 0x21
0A8E: 1@ = 0@ + 4
0A8F: 2@ = _RwFrameForAllObjects - 1@
0A8C: write_memory 0@ size 4 value 2@ vp 0
0A8E: 0@ = _GetOkAtomics + 0x29
0A8C: write_memory 0@ size 4 value _nVehicleVisibleAtomics vp 0

0A8E: 0@ = _GetDamagedAtomicsCB + 7
0A8E: 1@ = 0@ + 4
0A8F: 2@ = _CVisibilityPlugins__GetAtomicId - 1@
0A8C: write_memory 0@ size 4 value 2@ vp 0
0A8E: 0@ = _GetDamagedAtomicsCB + 0x17
0A8C: write_memory 0@ size 4 value _nVehicleVisibleAtomics vp 0
0A8E: 0@ = _GetDamagedAtomicsCB + 0x20
0A8C: write_memory 0@ size 4 value _nVehicleVisibleAtomics vp 0
0A8E: 0@ = _GetDamagedAtomicsCB + 0x26
0A8C: write_memory 0@ size 4 value _nMaxVehicleVisibleAtomics vp 0

0A8E: 0@ = _GetDamagedAtomics + 3
0A8C: write_memory 0@ size 4 value _nVehicleVisibleAtomics vp 0
0A8E: 0@ = _GetDamagedAtomics + 0x0D
0A8C: write_memory 0@ size 4 value _nMaxVehicleVisibleAtomics vp 0
0A8E: 0@ = _GetDamagedAtomics + 0x17
0A8C: write_memory 0@ size 4 value _GetDamagedAtomicsCB vp 0
0A8E: 0@ = _GetDamagedAtomics + 0x21
0A8E: 1@ = 0@ + 4
0A8F: 2@ = _RwFrameForAllObjects - 1@
0A8C: write_memory 0@ size 4 value 2@ vp 0
0A8E: 0@ = _GetDamagedAtomics + 0x29
0A8C: write_memory 0@ size 4 value _nVehicleVisibleAtomics vp 0

[...]

0AA7: call_function _GetOkAtomics num_params 3 pop 3 nCount 2 pAtomicList _OkAtomics pFrame 0@ nRetCount 3@
if
    3@ > 0
then
    // 1@ handles the first *_ok atomic found (i.e. bump_front_ok).
    if
        3@ > 1
    then
        // 2@ handles the second *_ok atomic found (i.e. plate_front_ok).
    end
end
0AA7: call_function _GetDamagedAtomics num_params 3 pop 3 nCount 2 pAtomicList _DamagedAtomics pFrame 0@ nRetCount 6@
if
    6@ > 0
then
    // 4@ handles the first *_dam atomic found (i.e. bump_front_dam).
    if
        6@ > 1
    then
        // 5@ handles the second *_dam atomic found (i.e. plate_front_dam).
    end
end

[...]

{
    enum eAtomicId
    (
    	ATOMICID_FLAG_OK  = 1,
    	ATOMICID_FLAG_DAM
    );
}

{
    RwObject *GetOkAtomicsCB(RwObject *pObject, void *pData)
    (
    	RpAtomic *pAtomic = (RpAtomic *)pObject, **pList = (RpAtomic **)pData;

    	if(CVisibilityPlugins__GetAtomicId(pAtomic) & ATOMICID_FLAG_OK)
    	(
    		pList[nVehicleVisibleAtomics++] = pAtomic;
    		return nVehicleVisibleAtomics != nMaxVehicleVisibleAtomics ? pObject : nullptr;
    	)

    	return pObject;
    )
}
:_GetOkAtomicsCB
hex
    56            // 00000000 push    esi
    8B7424 08     // 00000001 mov     esi, [esp+4+pObject]
    56            // 00000005 push    esi
    E8 00000000   // 00000006 call    CVisibilityPlugins__GetAtomicId
    83C4 04       // 0000000B add     esp, 4
    A8 01         // 0000000E test    al, ATOMICID_FLAG_OK
    74 20         // 00000010 jz      not_atomic_ok
    8B4C24 0C     // 00000012 mov     ecx, [esp+4+pData]
    A1 00000000   // 00000016 mov     eax, nVehicleVisibleAtomics
    893481        // 0000001B mov     [ecx+eax*4], esi
    40            // 0000001E inc     eax
    A3 00000000   // 0000001F mov     nVehicleVisibleAtomics, eax
    2B05 00000000 // 00000024 sub     eax, nMaxVehicleVisibleAtomics
    F7D8          // 0000002A neg     eax
    1BC0          // 0000002C sbb     eax, eax
    23C6          // 0000002E and     eax, esi
    5E            // 00000030 pop     esi
    C3            // 00000031 ret
                  // 00000032 not_atomic_ok:
    8BC6          // 00000032 mov     eax, esi
    5E            // 00000034 pop     esi
    C3            // 00000035 ret
    90            // 00000036 nop
    90            // 00000037 nop
    90            // 00000038 nop
    90            // 00000039 nop
    90            // 0000003A nop
    90            // 0000003B nop
    90            // 0000003C nop
    90            // 0000003D nop
    90            // 0000003E nop
    90            // 0000003F nop
end

{
    int GetOkAtomics(RwFrame *pFrame, void *pAtomicList, int nCount)
    (
    	nVehicleVisibleAtomics = 0;
    	nMaxVehicleVisibleAtomics = nCount;
    	RwFrameForAllObjects(pFrame, GetOkAtomicsCB, pAtomicList);
    	return nVehicleVisibleAtomics;
    )
}
:_GetOkAtomics
hex
    33C0          // 00000000 xor     eax, eax
    A3 00000000   // 00000002 mov     nVehicleVisibleAtomics, eax
    8B4C24 0C     // 00000007 mov     ecx, [esp+nCount]
    890D 00000000 // 0000000B mov     nMaxVehicleVisibleAtomics, ecx
    8B5424 08     // 00000011 mov     edx, [esp+pAtomicList]
    52            // 00000015 push    edx
    68 00000000   // 00000016 push    offset GetOkAtomicsCB
    8B4C24 0C     // 0000001B mov     ecx, [esp+8+pFrame]
    51            // 0000001F push    ecx
    E8 00000000   // 00000020 call    RwFrameForAllObjects
    83C4 0C       // 00000025 add     esp, 0Ch
    A1 00000000   // 00000028 mov     eax, nVehicleVisibleAtomics
    C3            // 0000002D ret
    90            // 0000002E nop
    90            // 0000002F nop
end

{
    RwObject *GetDamagedAtomicsCB(RwObject *pObject, void *pData)
    (
    	RpAtomic *pAtomic = (RpAtomic *)pObject, **pList = (RpAtomic **)pData;

    	if(CVisibilityPlugins__GetAtomicId(pAtomic) & ATOMICID_FLAG_DAM)
    	(
    		pList[nVehicleVisibleAtomics++] = pAtomic;
    		return nVehicleVisibleAtomics != nMaxVehicleVisibleAtomics ? pObject : nullptr;
    	)

    	return pObject;
    )
}
:_GetDamagedAtomicsCB
hex
    56            // 00000000 push    esi
    8B7424 08     // 00000001 mov     esi, [esp+4+pObject]
    56            // 00000005 push    esi
    E8 00000000   // 00000006 call    CVisibilityPlugins__GetAtomicId
    83C4 04       // 0000000B add     esp, 4
    A8 02         // 0000000E test    al, ATOMICID_FLAG_DAM
    74 20         // 00000010 jz      not_atomic_dam
    8B4C24 0C     // 00000012 mov     ecx, [esp+4+pData]
    A1 00000000   // 00000016 mov     eax, nVehicleVisibleAtomics
    893481        // 0000001B mov     [ecx+eax*4], esi
    40            // 0000001E inc     eax
    A3 00000000   // 0000001F mov     nVehicleVisibleAtomics, eax
    2B05 00000000 // 00000024 sub     eax, nMaxVehicleVisibleAtomics
    F7D8          // 0000002A neg     eax
    1BC0          // 0000002C sbb     eax, eax
    23C6          // 0000002E and     eax, esi
    5E            // 00000030 pop     esi
    C3            // 00000031 ret
                  // 00000032 not_atomic_dam:
    8BC6          // 00000032 mov     eax, esi
    5E            // 00000034 pop     esi
    C3            // 00000035 ret
    90            // 00000036 nop
    90            // 00000037 nop
    90            // 00000038 nop
    90            // 00000039 nop
    90            // 0000003A nop
    90            // 0000003B nop
    90            // 0000003C nop
    90            // 0000003D nop
    90            // 0000003E nop
    90            // 0000003F nop
end

{
    int GetDamagedAtomics(RwFrame *pFrame, void *pAtomicList, int nCount)
    (
    	nVehicleVisibleAtomics = 0;
    	nMaxVehicleVisibleAtomics = nCount;
    	RwFrameForAllObjects(pFrame, GetDamagedAtomicsCB, pAtomicList);
    	return nVehicleVisibleAtomics;
    )
}
:_GetDamagedAtomics
hex
    33C0          // 00000000 xor     eax, eax
    A3 00000000   // 00000002 mov     nVehicleVisibleAtomics, eax
    8B4C24 0C     // 00000007 mov     ecx, [esp+nCount]
    890D 00000000 // 0000000B mov     nMaxVehicleVisibleAtomics, ecx
    8B5424 08     // 00000011 mov     edx, [esp+pAtomicList]
    52            // 00000015 push    edx
    68 00000000   // 00000016 push    offset GetDamagedAtomicsCB
    8B4C24 0C     // 0000001B mov     ecx, [esp+8+pFrame]
    51            // 0000001F push    ecx
    E8 00000000   // 00000020 call    RwFrameForAllObjects
    83C4 0C       // 00000025 add     esp, 0Ch
    A1 00000000   // 00000028 mov     eax, nVehicleVisibleAtomics
    C3            // 0000002D ret
    90            // 0000002E nop
    90            // 0000002F nop
end

// int nVehicleVisibleAtomics
:_nVehicleVisibleAtomics
hex
    00000000
end

// int nMaxVehicleVisibleAtomics;
:_nMaxVehicleVisibleAtomics
hex
    00000000
end

_DK
  • _DK

    Homie

  • Feroci Racing
  • Joined: 12 Apr 2009
  • Ukraine

#11

Posted 13 June 2014 - 07:55 PM Edited by _DK, 13 June 2014 - 07:58 PM.

The code looks great, but you know it's stupid to write scripts when you use asm only. Such kind of coding is uncomfortable and the code itself is unreadable.
Well, I just thought we left this idea few years ago.

Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci Racing
  • Joined: 19 Aug 2006
  • Unknown

#12

Posted 13 June 2014 - 11:26 PM

That's not the case indeed. You forget the code is supposed to take part of a CLEO mod, such as the one the OP is working on. It shows a native way to achieve the whole matter by providing the source of the assembled code and of each ASM line, therefore even though it seems to be uncomfortable it isn't unreadable at all.

Junior_Djjr
  • Junior_Djjr

    BMS - Brazilian Modding Studio

  • Members
  • Joined: 16 Dec 2011
  • Brazil

#13

Posted 14 June 2014 - 03:14 AM Edited by Junior_Djjr, 14 June 2014 - 03:27 AM.

wow @_@

 

this code is amazing

 

thanks again, when i'm creating the Tuning Mod and you send to me a code, i did not know what they were lol, after i learned VERY MUCH :p





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users