Quantcast

Jump to content

» «
Photo

Change Motorcyle body

3 replies to this topic
Odyne
  • Odyne

    Player Hater

  • Members
  • Joined: 17 Jul 2011

#1

Posted 21 October 2013 - 02:14 PM

Hello,

 

is it possible to change the motorcycle body with a cleo script?

For example the BF-400 has 3 versions, streetfighter (no fairing), half fairing and full fairing. 

 

Spoiler

 

Maybe with a menu where you can select the type?

 

Possible or not?

 

Thanks


Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci
  • Joined: 19 Aug 2006
  • Unknown
  • Contribution Award [Mods]

#2

Posted 21 October 2013 - 06:32 PM Edited by Wesser, 31 October 2013 - 11:31 AM.

I'll prepare the script tomorrow. The idea is hiding all of the current vehicle's extras and make only those desired visible. Stay tuned. :)
 
//Edit: I apologize for not keeping my promise completely but better late than never:
{$CLEO}

0000: NOP

const
    CARCOMPS_EXTRA1 = 2
    CARCOMPS_EXTRA2 = 4
end
const
    PAD1           = 0
end
const
    LEFTSHOULDER1  = 4
end
const
    MODELTYPE_BOAT = 5
    MODELTYPE_BIKE = 9
    MODELTYPE_BMX  = 10
end
const
    _HOOK_004C96F5_CModelCars__cloneData = 29@
    _HOOK_004C9763_CModelCars__cloneData = 28@
    _getModelPtr                         = 0x00403DA0
    _rwFrameClone                        = 27@
    _rwFrameAddChild                     = 26@
    _rwFrameDestroy                      = 25@
    _rwFrameFindNodeByName               = 0x004C5400
    _rwFrameGetNodeName                  = 0x0072FB30
    _rpClumpAddAtomic                    = 24@
    _rpClumpRemoveAtomic                 = 23@
    _rpClumpFindFrameById                = 0x004C53C0
    _rpAtomicClone                       = 22@
    _rpAtomicSetFrame                    = 21@
    _rpAtomicDestroy                     = 20@
    _rpAtomicSetCarMatFX                 = 0x004C9410
end

0A9F: 31@ = current_thread_pointer
0A8E: 30@ = 31@ + 0x10 // CScriptThread.m_iBaseAddress
0A8D: 30@ = read_memory 30@ size 4 virtual_protect 0

0A8F: _HOOK_004C96F5_CModelCars__cloneData = 30@ - @HOOK_004C96F5_CModelCars__cloneData
0A8F: _HOOK_004C9763_CModelCars__cloneData = 30@ - @HOOK_004C9763_CModelCars__cloneData
0A8E: 0@ = 0x00537338 + 0x01
0A8E: 1@ = 0@ + 0x04
0A8D: 2@ = read_memory 0@ size 4 virtual_protect 1
0A8E: _rwFrameClone = 1@ + 2@
0A8E: 0@ = 0x004C9269 + 0x01
0A8E: 1@ = 0@ + 0x04
0A8D: 2@ = read_memory 0@ size 4 virtual_protect 1
0A8E: _rwFrameAddChild = 1@ + 2@
0A8E: 0@ = 0x004C4473 + 0x01
0A8E: 1@ = 0@ + 0x04
0A8D: 2@ = read_memory 0@ size 4 virtual_protect 1
0A8E: _rwFrameDestroy = 1@ + 2@
0A8E: 0@ = 0x004C6CC1 + 0x01
0A8E: 1@ = 0@ + 0x04
0A8D: 2@ = read_memory 0@ size 4 virtual_protect 1
0A8E: _rpClumpAddAtomic = 1@ + 2@
0A8E: 0@ = 0x004C6CBA + 0x01
0A8E: 1@ = 0@ + 0x04
0A8D: 2@ = read_memory 0@ size 4 virtual_protect 1
0A8E: _rpClumpRemoveAtomic = 1@ + 2@
0A8E: 0@ = 0x004C44EE + 0x01
0A8E: 1@ = 0@ + 0x04
0A8D: 2@ = read_memory 0@ size 4 virtual_protect 1
0A8E: _rpAtomicClone = 1@ + 2@
0A8E: 0@ = 0x004C450A + 0x01
0A8E: 1@ = 0@ + 0x04
0A8D: 2@ = read_memory 0@ size 4 virtual_protect 1
0A8E: _rpAtomicSetFrame = 1@ + 2@
0A8E: 0@ = 0x004C446D + 0x01
0A8E: 1@ = 0@ + 0x04
0A8D: 2@ = read_memory 0@ size 4 virtual_protect 1
0A8E: _rpAtomicDestroy = 1@ + 2@

// Make CModelCars__cloneData cloning the primary extra frame to copy also the node name.
0A8E: 0@ = 0x004C96F5 + 0x05
0A8F: 1@ = _HOOK_004C96F5_CModelCars__cloneData - 0@
0A8C: write_memory 0x004C96F5 size 1 value 0xE9 virtual_protect 1
0A8C: write_memory 0x004C96F6 size 4 value 1@ virtual_protect 1
0A8E: 0@ = _HOOK_004C96F5_CModelCars__cloneData + 0x08
0A8E: 1@ = 0@ + 0x04
0A8F: 2@ = _rwFrameClone - 1@
0A8C: write_memory 0@ size 4 value 2@ virtual_protect 1
0A8E: 0@ = _HOOK_004C96F5_CModelCars__cloneData + 0x0F
0A8E: 1@ = 0@ + 0x04
0A8F: 2@ = 0x004C9715 - 1@
0A8C: write_memory 0@ size 4 value 2@ virtual_protect 1
0A8C: write_memory 0x004C971F size 1 value 0x24 virtual_protect 1
0A8C: write_memory 0x004C972A size 1 value 0x28 virtual_protect 1
0A8C: write_memory 0x004C9735 size 1 value 0x34 virtual_protect 1
0A8C: write_memory 0x004C9738 size 1 value 0x20 virtual_protect 1
// Do the same thing for the secondary extra frame.
0A8E: 0@ = 0x004C9763 + 0x05
0A8F: 1@ = _HOOK_004C9763_CModelCars__cloneData - 0@
0A8C: write_memory 0x004C9763 size 1 value 0xE9 virtual_protect 1
0A8C: write_memory 0x004C9764 size 4 value 1@ virtual_protect 1
0A8E: 0@ = _HOOK_004C9763_CModelCars__cloneData + 0x08
0A8E: 1@ = 0@ + 0x04
0A8F: 2@ = _rwFrameClone - 1@
0A8C: write_memory 0@ size 4 value 2@ virtual_protect 1
0A8E: 0@ = _HOOK_004C9763_CModelCars__cloneData + 0x0F
0A8E: 1@ = 0@ + 0x04
0A8F: 2@ = 0x004C9783 - 1@
0A8C: write_memory 0@ size 4 value 2@ virtual_protect 1
0A8C: write_memory 0x004C978D size 1 value 0x24 virtual_protect 1
0A8C: write_memory 0x004C9798 size 1 value 0x28 virtual_protect 1
0A8C: write_memory 0x004C97A3 size 1 value 0x34 virtual_protect 1
0A8C: write_memory 0x004C97A6 size 1 value 0x20 virtual_protect 1

while true
    if
    00DD:  actor $PLAYER_ACTOR driving_car_with_model #BF400
    then
        03C0: 0@ = actor $PLAYER_ACTOR car
        0441: 1@ = car 0@ model
        if
        00E1:  player PAD1 pressed_key LEFTSHOULDER1 // Secondary Fire
        then
            0AA7: call_function _getModelPtr num_params 1 pop 1 iId 1@ pclInfo 2@
            2@ += 0x5C // CModelCars.m_paclVehicleStruct
            0A8D: 2@ = read_memory 2@ size 4 virtual_protect 0
            0A8E: 3@ = 2@ + 0x030C // CVehicleStruct.m_iNumExtras
            0A8D: 3@ = read_memory 3@ size 1 virtual_protect 0
            if
                3@ > 0
            then
                0A8E: 4@ = 2@ + 0x3C // CModelCars.m_eType
                0A8D: 4@ = read_memory 4@ size 4 virtual_protect 0
                0A97: 5@ = car 0@ struct
                0A8E: 6@ = 5@ + 0x0018 // CVehicle.m_clEntity.m_pstRpClump
                0A8D: 6@ = read_memory 6@ size 4 virtual_protect 0
                if and
                    4@ >= MODELTYPE_BOAT
                    4@ <> MODELTYPE_BIKE
                    4@ <> MODELTYPE_BMX
                then
                    0A8E: 7@ = 6@ + 0x04 // SRpClump.m_stObject.m_pstParent
                    0A8D: 7@ = read_memory 7@ size 4 virtual_protect 0
                else
                    0AA7: call_function _rpClumpFindFrameById num_params 2 pop 2 iHierarchyId 1 pstRpClump 6@ pstRwFrame 7@
                    if
                        7@ == 0x00000000
                    then
                        0A8E: 7@ = 6@ + 0x04 // SRpClump.m_stObject.m_pstParent
                        0A8D: 7@ = read_memory 7@ size 4 virtual_protect 0
                    end
                end
                0A8E: 8@ = 2@ + 0x02F4 // CVehicleStruct.m_apstExtraAtomics (array_sizeof = 6)
                0A8E: 9@ = 5@ + 0x0438 // CVehicle.m_cPrimaryExtraId
                0A8D: 10@ = read_memory 9@ size 1 virtual_protect 0
                if
                88B7:  not test 10@ bit 7
                then
                    0A90: 11@ = 10@ * 0x04 // sizeof(SRwFrame *)
                    005A: 11@ += 8@
                    0A8D: 11@ = read_memory 11@ size 4 virtual_protect 0
                    0A8E: 12@ = 11@ + 0x04 // SRpAtomic.m_stObject.m_stObject.m_pstParent
                    0A8D: 12@ = read_memory 12@ size 4 virtual_protect 0
                    if
                        11@ <> 0x00000000
                    then
                        0AA7: call_function _rwFrameGetNodeName num_params 1 pop 1 pstRwFrame 12@ pszNodeName 13@
                        0AA7: call_function _rwFrameFindNodeByName num_params 2 pop 2 pszNodeName 13@ pstRwFrame 7@ pstRwFrame 14@
                        if
                            14@ <> 0x00000000
                        then
                            0A8E: 15@ = 14@ + 0x90 // SRwFrame.m_stAtomicList.m_pstNext
                            0A8D: 15@ = read_memory 15@ size 4 virtual_protect 0
                            15@ -= 0x08 // SRpAtomic
                            0AA5: call _rpClumpRemoveAtomic num_params 2 pop 2 pstRpAtomic 15@ pstRpClump 6@
                            0AA5: call _rpAtomicDestroy num_params 1 pop 1 pstRpAtomic 15@
                            0AA5: call _rwFrameDestroy num_params 1 pop 1 pstRwFrame 14@
                        end
                    end
                end
                0A90: 11@ = CARCOMPS_EXTRA1 * 0x04 // sizeof(SRwFrame *)
                005A: 11@ += 8@
                0A8D: 11@ = read_memory 11@ size 4 virtual_protect 0
                if
                    11@ <> 0x00000000
                then
                    0A8E: 12@ = 11@ + 0x04 // SRpAtomic.m_stObject.m_stObject.m_pstParent
                    0A8D: 12@ = read_memory 12@ size 4 virtual_protect 0
                    0AA7: call_function _rpAtomicClone num_params 1 pop 1 pstRpAtomic 11@ pstRpAtomic 13@
                    0AA7: call_function _rwFrameClone num_params 1 pop 1 pstRwFrame 12@ pstRwFrame 15@
                    0AA5: call _rpAtomicSetFrame num_params 2 pop 2 pstRwFrame 15@ pstRpAtomic 13@
                    0AA5: call _rpClumpAddAtomic num_params 2 pop 2 pstRpAtomic 13@ pstRpClump 6@
                    0AA5: call _rwFrameAddChild num_params 2 pop 2 pstRwChild 15@ pstRwFrame 7@
                    0AA5: call _rpAtomicSetCarMatFX num_params 2 pop 2 iMaterialId 0 pstRpAtomic 13@
                    0A8C: write_memory 9@ size 1 value CARCOMPS_EXTRA1 virtual_protect 0
                end
                0A8E: 9@ = 5@ + 0x0439 // CVehicle.m_cSecondaryExtraId
                0A8D: 10@ = read_memory 9@ size 1 virtual_protect 0
                if
                88B7:  not test 10@ bit 7
                then
                    0A90: 11@ = 10@ * 0x04 // sizeof(SRwFrame *)
                    005A: 11@ += 8@
                    0A8D: 11@ = read_memory 11@ size 4 virtual_protect 0
                    if
                        11@ <> 0x00000000
                    then
                        0A8E: 12@ = 11@ + 0x04 // SRpAtomic.m_stObject.m_stObject.m_pstParent
                        0A8D: 12@ = read_memory 12@ size 4 virtual_protect 0
                        0AA7: call_function _rwFrameGetNodeName num_params 1 pop 1 pstRwFrame 12@ pszNodeName 13@
                        0AA7: call_function _rwFrameFindNodeByName num_params 2 pop 2 pszNodeName 13@ pstRwFrame 7@ pstRwFrame 14@
                        if
                            14@ <> 0x00000000
                        then
                            0A8E: 15@ = 14@ + 0x90 // SRwFrame.m_stAtomicList.m_pstNext
                            0A8D: 15@ = read_memory 15@ size 4 virtual_protect 0
                            15@ -= 0x08 // SRpAtomic
                            0AA5: call _rpClumpRemoveAtomic num_params 2 pop 2 pstRpAtomic 15@ pstRpClump 6@
                            0AA5: call _rpAtomicDestroy num_params 1 pop 1 pstRpAtomic 15@
                            0AA5: call _rwFrameDestroy num_params 1 pop 1 pstRwFrame 14@
                        end
                    end
                end
                0A90: 11@ = CARCOMPS_EXTRA2 * 0x04 // sizeof(SRwFrame *)
                005A: 11@ += 8@
                0A8D: 11@ = read_memory 11@ size 4 virtual_protect 0
                if
                    11@ <> 0x00000000
                then
                    0A8E: 12@ = 11@ + 0x04 // SRpAtomic.m_stObject.m_stObject.m_pstParent
                    0A8D: 12@ = read_memory 12@ size 4 virtual_protect 0
                    0AA7: call_function _rpAtomicClone num_params 1 pop 1 pstRpAtomic 11@ pstRpAtomic 13@
                    0AA7: call_function _rwFrameClone num_params 1 pop 1 pstRwFrame 12@ pstRwFrame 15@
                    0AA5: call _rpAtomicSetFrame num_params 2 pop 2 pstRwFrame 15@ pstRpAtomic 13@
                    0AA5: call _rpClumpAddAtomic num_params 2 pop 2 pstRpAtomic 13@ pstRpClump 6@
                    0AA5: call _rwFrameAddChild num_params 2 pop 2 pstRwChild 15@ pstRwFrame 7@
                    0AA5: call _rpAtomicSetCarMatFX num_params 2 pop 2 iMaterialId 0 pstRpAtomic 13@
                    0A8C: write_memory 9@ size 1 value CARCOMPS_EXTRA2 virtual_protect 0
                end
            end
            while 00E1:  player PAD1 pressed_key LEFTSHOULDER1 // Secondary Fire
                wait 0
            end
        end
    end
    wait 0
end

:HOOK_004C96F5_CModelCars__cloneData
hex
    8B0C24      // mov     ecx, dword ptr [esp]
    8B51 04     // mov     edx, [ecx+SRpAtomic.m_stObject.m_stObject.m_pstParent]
    52          // push    edx
    E8 00000000 // call    rwFrameClone
    8BF8        // mov     edi, eax
    E9 00000000 // jmp     4C9715h
end

:HOOK_004C9763_CModelCars__cloneData
hex
    8B0C24      // mov     ecx, dword ptr [esp]
    8B51 04     // mov     edx, [ecx+SRpAtomic.m_stObject.m_stObject.m_pstParent]
    52          // push    edx
    E8 00000000 // call    rwFrameClone
    8BF8        // mov     edi, eax
    E9 00000000 // jmp     4C9783h
end
  • Silent likes this

Odyne
  • Odyne

    Player Hater

  • Members
  • Joined: 17 Jul 2011

#3

Posted 22 October 2013 - 10:39 AM Edited by Odyne, 22 October 2013 - 10:49 AM.

I found the opcode it's: 0506: set_vehicle_model #nrg500 next_variation 0 0

 

See sannybuilder help > scm documentation > gta sa > car variations

 

But how do you use it?

 

 

EDIT:

 

Got it. My question is answered.


Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci
  • Joined: 19 Aug 2006
  • Unknown
  • Contribution Award [Mods]

#4

Posted 30 October 2013 - 05:33 PM

You should have specified that you were also accepting to change the extra components of a new vehicle, it's far simpler.

By the way, if anyone is interested, I updated my previous post by showing the script for setting the primary and secondary extra components of a spawned vehicle.




2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users