Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    2. News

    1. Red Dead Redemption 2

    1. GTA Online

      1. After Hours
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Forum Support

    2. Site Suggestions

pep legal

[SA] Transparency without changing all Instances.

Recommended Posts

pep legal

.

As well known, tweaking model's alpha affects all instances of that model (working on cars mostly).

 

Have tried individual transparency by cloning some frame/atomics (in cleo scripts) of some parts, but no success. :/

 

Not sure if it is necessary to clone rpGeometry as well.

 

Also have tried to migrate an atomic (chassis) from a car to an object ==> crash !

 

Studying the possibility of a total duplication of a specific car model (in memory)...and create a car using that model clone. Need more info about model loading though.

 

Not really necessary that the "transparent instance" must be fully functional. Just a "dummy" object with chassis, doors and wheels would be excelent.

 

 

Some tips from PROs would be very welcome ! :cool:

 

 

.

Edited by pep legal

Share this post


Link to post
Share on other sites
Junior_Djjr

What you're asking is something similar to the one I asked in the old days (and I have not been able to do it until now, but I have not tried it again in a long time).

Basically, you want the changes of a rpatomic's material to be individual for each entity, right? The maximum I got caused the rpatomic to be totally black or random colors at each vertex.

Share this post


Link to post
Share on other sites
DK22Pac

It's not really necessary to create unique materials for each clump/atomic.

R* solved this 'problem' in this way: they saved material data before atomic/clump rendering, changed material properties, and then restored saved data after atomic/clump was rendered.

 

// save materials parameters// edit materials parametersClump/Atomic rendering// restore materials parameters
Also, cloning geometries (thus, making them 'unique') could be an idea. Could you share your code? Edited by DK22Pac

Share this post


Link to post
Share on other sites
pep legal

.

After digging for info, I got some light from old topics in this forum... here goes some feedback :

 

- Gave up of tweaking vertex alpha (it affects all instances)....Material alpha seems to be easier.

 

- I succeed in cloning Geometry, Material List and all its Materials from a car chassis...but for some obscure reason, changing rwRGBA value (offset 0x04) of the cloned Mat does NOTHING at all. But...If I change rwRGBA of original Mat, just before "_rpMaterialClone", then the copy (and the original of course) has its color changed.

 

 

 

//Thanks to Wesser, Junior and DK...with my personal [email protected] += 0x18   //original RpGeometry0A8D: [email protected] = read_memory [email protected] size 4 vp 00A8E: [email protected] = [email protected] + 0x24 //numMaterials0A8D: [email protected] = read_memory [email protected] size 4 vp 00AA7: call_function_return _malloc 1 1 params Size RPGEOMETRY_SIZE StoreTo [email protected]: call_function _memcpy num_params 3 pop 3 params Size RPGEOMETRY_SIZE RpGeometry [email protected] CopyTo [email protected]: write_memory [email protected] size 4 value [email protected] vp 0 // replace with the cloned [email protected] += 0x20 // original [email protected] += 0x20 // waiting for the new RpMaterialList0AA7: call_function_return _rpMaterialListAlloc 1 1 params numMat [email protected] StoreTo [email protected]: write_memory [email protected] size 4 value [email protected] vp 0 // put back New Mat Array0AA5: call_function _rpMaterialListInitialize num_params 1 pop 1 pstMatList [email protected]   //resets to No [email protected] -= 1  //zero based indexfor [email protected] = 0 to [email protected] // For all materials    0AA7: call_function_return _rpMaterialListGetMaterial num_params 2 pop 2 matIndex [email protected] matList [email protected] storeMat [email protected]    0AA7: call_function_return _rpMaterialClone num_params 1 pop 1 [email protected] storeClone [email protected]    0AA5: call_function _rpMaterialListAppendMaterial num_params 2 pop 2 pstMat [email protected] pstMatList [email protected]

 

 

 

- Another question : Provided that I have a cloned rpAtomic, is it possible to create an object (no hierarchy) using that Atomic ? - All my attempts to overwrite CEntity:rwObject (offset 0x18) with that cloned Atomic result in CRASH.

 

 

Looking forward to any help. :santa:

 

 

.

Edited by pep legal

Share this post


Link to post
Share on other sites
pep legal
Posted (edited)

Harder than I thought...but it's done.

 

( Tires still not so good )

 

 

Next step, remove out all the "core" atomics (seats, steer wheel, extras), keeping only the visible "shell" (chassis, doors, wheels).

 

 

Need a way to know if an Atomic is tottaly occluded (behind another atomic).

 

 

Thanks for the attention !

 

 

 

 

d1fNnER.jpg

Edited by pep legal

Share this post


Link to post
Share on other sites
Junior_Djjr
Posted (edited)

Do you fixed this issue?

 

- I succeed in cloning Geometry, Material List and all its Materials from a car chassis...but for some obscure reason, changing rwRGBA value (offset 0x04) of the cloned Mat does NOTHING at all. But...If I change rwRGBA of original Mat, just before "_rpMaterialClone", then the copy (and the original of course) has its color changed.

This will be very useful for me (it's the main problem of Tuning Mod).

 

 

- Another question : Provided that I have a cloned rpAtomic, is it possible to create an object (no hierarchy) using that Atomic ? - All my attempts to overwrite CEntity:rwObject (offset 0x18) with that cloned Atomic result in CRASH.

Do you tried the Tuning Mod's clone function? (Extra - Add.txt) Edited by Junior_Djjr

Share this post


Link to post
Share on other sites
pep legal
Posted (edited)

.
I've solved both problems above mentioned (completely the first one...partially the second)

I didn't know you have published a separated source code for Tunning Mod.

Now looking at your "Clone function", I see it is not complete...still persists some kind of dependency among instances. Not a problem if you don't need to make deep changes (alpha, for example) in one instance, without changing others.

Edited by pep legal

Share this post


Link to post
Share on other sites
pep legal
Posted (edited)

.

EDIT : For the sake of correctness, the previous script was fixed.

 

No more doubts. Thread can be closed.

.

Edited by pep legal

Share this post


Link to post
Share on other sites
Junior_Djjr

Nice :)

Check my "Search Parts - Funcs.txt", there's a much better way to make your "Walk through Linked List of RwFrames".

Share this post


Link to post
Share on other sites
Junior_Djjr
Posted (edited)

After a lot of message edits, rewriting this:

 

I noticed this:

 

0AA5: call_function _memcpy num_params 3 pop 3 params Size 60 block [email protected] CopyTo [email protected] //copy part of original RpGeometry to the new one
"Size 60"

In fact, is 0x60.

 

But, well, all vehicles occasionally bugs after cloning, like this.

If not bugs, it crashes at d3d9.dll.

Tested cloning just one RpAtomic (bonnet, chassis, door...)

 

Only here?

Edited by Junior_Djjr

Share this post


Link to post
Share on other sites
pep legal
Posted (edited)

After a lot of message edits, rewriting this:

:blink: - I didn't know message edits send messages...I usually put a lot of care on writings.

 

 

 

 

"Size 60"

In fact, is 0x60.

Nope...Its 60 (decimal). It's a partial copy...not full (he..he...pegadinha do malandro !)

 

 

 

But, well, all vehicles occasionally bugs after cloning,

Works great here ! Actually I took a 30 minute ride on a transparent cloned car. No problem at all.

 

But I'm sure that a cloned car cannot be re-cloned. Still missing some refs. Additionally, I'm not sure the game releases those allocated objects created by the Clone function.

 

I'm still doing tests on traffic cars....so far, so good.

 

 

 

 

Check my "Search Parts - Funcs.txt", there's a much better way to make your "Walk through Linked List of RwFrames".

I see...recursion is a classical solution for Linked List, but SCM functions put a fuc* overhead on calls, and T&T is already a 20 thounsand lines piece of software. I need to be cautious about performance.

 

The "fixed" version I wrote above works good enough (not great), and it can be easily extended to increase deeper searches.

 

Anyway, I'm thinking about using pointers to data arrays to "simulate" recursion, instead of fixed variables. Then I would have the same performance I already have, plus variable deep searches (I don't have).

 

 

.

Edited by pep legal

Share this post


Link to post
Share on other sites
DK22Pac
Posted (edited)

Nice, but do you think writing an assembly byte-code is a proper way of 'coding'!?

Anyway, I thought about some another solution (not the 'classical R* way') and I made this.
https://drive.google.com/uc?export=download&id=1e1LJU7lXVFEVJP5UGq3tMl8COP92iQzD

* [ ] keys are used to change transparency; it works for current player car only.

Edited by DK22Pac

Share this post


Link to post
Share on other sites
pep legal
Posted (edited)

.

Oh gosh...finally we've got some divine intervention ! :santa:

 

 

 

 

Nice, but do you think writing an assembly byte-code is a proper way of 'coding'!?

Still learning....I will try doing better next time ! :sigh:

 

 

 

Anyway, I thought about some another solution

Apart trying to find out the keys to proper control it (probably due to different keyboard layout)...I loved the way CJ becomes a Ghost !

 

It would be great if you have done that for Cars...and not the Player !

 

--------------------------------------------------------------------------

 

EDIT :

 

Fuc* !!! Your transparency is far better than mine.

 

Tweaking material alpha of every cloned atomic (like I did) gives an UGLY view of the car skeleton.

 

Your solution keeps the original way of looking...just merging softly with the ambient.

 

Perfect !

 

What about giving us an API in order to use your ASI from a Cleo Script ? (All credits given, of course).

 

 

PS.: It's not compatible with SkyGfx (from TheHero/aap) - it changes only CJ transparency.

 

Thanks.

 

 

 

 

 

 

 

 

 

.

Edited by pep legal

Share this post


Link to post
Share on other sites
DK22Pac
Posted (edited)

Yes, it may not work with custom rendering pipelines (or shaders).

 

So what I made here:

there are 2 hooks, one is for storing currently rendered entity (but only if it's a vehicle), and another for changing D3D material properties, right before mesh is rendered.

In the second hook, we check if a mesh is a part of a vehicle and, if so, apply new material properties.

 

 

Entity renderer > Our hook : save vehicle ptr to a variable (if that's not a vehicle, a variable will stay unchanged (it will be a null-pointer)){    // ...    Mesh rendering > Our hook : check if we render a vehicle (i.e., if variable is not a null-pointer) and apply new material properties    {    }        // ...}> Our hook : clear entity ptr (set variable to null-pointer)
#include "plugin.h"#include "CHud.h"#include <d3d9.h> using namespace plugin; class VehicleTransparency {    struct Transparency {        float mValue = 1.0f; // default vehicle transparency        Transparency(CVehicle *) {} // dummy constructor    };     inline static VehicleExtendedData<Transparency> TransparencyInfo; // extender instance    inline static CVehicle *CurrentVehicle = nullptr; // we store current renderer vehicle here    inline static D3DMATERIAL9 CurrMaterial; // storage for materialpublic:    // get/set transparency for vehicle    static void Set(CVehicle *vehicle, float value) { TransparencyInfo.Get(vehicle).mValue = value; }    static float Get(CVehicle *vehicle) { return TransparencyInfo.Get(vehicle).mValue; }     VehicleTransparency() {        static CdeclEvent<AddressList<0x757018, H_CALL, 0x757043, H_CALL, 0x7572F2, H_CALL, 0x75731D, H_CALL, 0x7FA320,            H_CALL, 0x7FA360, H_CALL>, PRIORITY_AFTER, ArgPickNone, void()> myOnFlushRenderStates; // before primitive render        static CdeclEvent<AddressList<0x553C52, H_CALL, 0x553CB8, H_CALL, 0x553D8F, H_CALL, 0x732C48, H_CALL>,            PRIORITY_AFTER, ArgPickN<CVehicle *, 0>, void(CVehicle *)> myOnEntityRenderer; // entity renderer         myOnEntityRenderer.before += [](CVehicle *entity) { // store entity if it's a vehicle            CurrentVehicle = (entity->m_nType == ENTITY_TYPE_VEHICLE) ? entity : nullptr;        };         myOnEntityRenderer.after += [](CVehicle *entity) { // clear in any case            CurrentVehicle = nullptr;        };         myOnFlushRenderStates += [] {            if (CurrentVehicle && VehicleTransparency::Get(CurrentVehicle) != 1.0f) { // if transparent vehicle                CurrMaterial = *reinterpret_cast<D3DMATERIAL9 *>(0xC98AF8); // get last material parameters                CurrMaterial.Diffuse.a *= VehicleTransparency::Get(CurrentVehicle); // change material alpha                RwD3D9SetMaterial(&CurrMaterial); // apply new material parameters                SetRenderState(rwRENDERSTATEVERTEXALPHAENABLE, true); // enable transparency                SetRenderState(rwRENDERSTATECULLMODE, rwCULLMODECULLBACK); // enable culling                SetRenderState(rwRENDERSTATEALPHATESTFUNCTION, rwALPHATESTFUNCTIONGREATER); // change alpha-test                SetRenderState(rwRENDERSTATEALPHATESTFUNCTIONREF, 0); // reference value                _rwD3D9RenderStateFlushCache(); // apply rendering parameters            }        };    }} vehicleTransparency; class Test {public:    Test() {        Events::gameProcessEvent += [] {            static bool messageDisplayed = false;            CVehicle *playaCar = FindPlayerVehicle(0, false);            if (playaCar) {                float alpha = VehicleTransparency::Get(playaCar);                if (KeyPressed(VK_OEM_4)) // [                    alpha -= 0.01f;                else if (KeyPressed(VK_OEM_6)) // ]                    alpha += 0.01f;                alpha = std::clamp(alpha, 0.0f, 1.0f);                VehicleTransparency::Set(playaCar, alpha); // set transparency for player's current car                if (!messageDisplayed) {                    CHud::SetHelpMessage("Use [ ] keys to control vehicle transparency", false, false, false);                    messageDisplayed = true;                }            }        };    }} test;
As you already found, it doesn't work SkyGfx - because it introduces a new rendering pipeline for vehicles (so it ignores myOnFlushRenderStates hook).

For a better compatibility, I'd go with that 'classical R*'s solution'.

Edited by DK22Pac

Share this post


Link to post
Share on other sites
Junior_Djjr
Posted (edited)

Nope...Its 60 (decimal). It's a partial copy...not full (he..he...pegadinha do malandro !)

It's a f*cking coincidence :monocle:

 

I would love a good solution in .asi that makes all materials independent, being able to change the RGBA of them.

I think some API would be nice, where you send a vehicle and it does all the service. Doing such a thing with cleo isn't really cool...

Edited by Junior_Djjr

Share this post


Link to post
Share on other sites
SHIFAAH9

how about in LUA..?

Share this post


Link to post
Share on other sites
pep legal
Posted (edited)

Previous code rewriten ! :whistle:

 

- Stability and Performance improvements

 

- Recursion used to walk through frame hierarchy (but not using SCM funtions)

 

- Cosmetic tweaks.

Edited by pep legal

Share this post


Link to post
Share on other sites
Junior_Djjr
Posted (edited)

Why don't use atomicList? (like I used on Search Parts - Funcs.txt). Why do you need these _GetOkAtomics etc?

 

 

constAtomicList = 0x8RpAtomicOnList = 0x40RwObjectParent = 0x4end:ListWalk {RpClump [email protected]}   [email protected] += AtomicList0A8D: [email protected] = read_memory [email protected] size 4 vp falseif [email protected] > 0 // firstthen    0085: [email protected] = [email protected] // store first    repeat            // Get RpAtomic        0A8F: [email protected] = [email protected] - RpAtomicOnList                // Get RwFrame        0A8E: [email protected] = [email protected] + RwObjectParent        0A8D: [email protected] = read_memory [email protected] size 4 vp false                // Do anything...                 // Next                                          0A8D: [email protected] = read_memory [email protected] size 4 vp false            until 003B:   [email protected] == [email protected] // check if current is first (end of list)end0AB2: ret 0
Edited by Junior_Djjr

Share this post


Link to post
Share on other sites
pep legal
Posted (edited)

Why don't use atomicList? (like I used on Search Parts - Funcs.txt).

 

 

No strong reasons. Excess of cautiousness maybe.

 

I though would be safer to replace atomics following clump hierarchy. I mean, first cut the leaves, then the branches, and last the trunk.

 

I'm not applying transparency under laboratory conditions...instead I'm doing it on traffic cars, in large scale.

 

But I will give a try to your way.

 

 

Why do you need these _GetOkAtomics etc?

 

 

Previously I was being very selective about which atomic would be transparent, or which one would be deleted.

 

_GetOkAtomics acts as a filter.

 

But I think your question is : Why to use callbacks ? ==> Performance !

.

.

 

Edited by pep legal

Share this post


Link to post
Share on other sites
pep legal
Posted (edited)

Small fixes on previous code. Just to keep it updated with the last founds.

 

 

Question.: Does anyone know if the game "re-instance" a set of RxD3D9InstanceData ?

 

...and how to avoid that for a specific geometry ?

 

 

 

 

{$CLEO .cs}thread 'CLONING'0000:const    Matrix_Ptr  =   [email protected]    Matrix_Car  =   [email protected]    Clone_Done  =   [email protected]_Done = 0Matrix_Car = 0while true    wait 0        if         Actor.Driving($PLAYER_ACTOR)    then                0811: Matrix_Car = actor $PLAYER_ACTOR used_car        Clone_Done = 0                else        if and            Matrix_Car > 0            Clone_Done == 0                                        then            Clone_Done = 1                        0A97: Matrix_Ptr = car Matrix_Car struct             0AB1: call_scm_func @alphaVehicle numParams 2 vehiclePTR Matrix_Ptr alphaValue 256 //values above 255 only creates a geometry clone of the vehicle                        0AB1: call_scm_func @alphaVehicle numParams 2 vehiclePTR Matrix_Ptr alphaValue 128  //values below 256 actually changes alpha                                                end    endend      //====================================================================================            :alphaVehicle   //Thanks for valuable tips from Wesser (GTAforums.com)              const    _CarPtr                         = [email protected]    _alphaCar                       = [email protected]    _carClump                       = [email protected]    _levelIDX                       = [email protected]                _temp_0_                        = [email protected]    _MatArray                       = [email protected]    _loopCount_2                    = [email protected]        _temp_1_                        = [email protected]    _temp_2_                        = [email protected]        _instData_MatOff                = [email protected]            _numMaterials                   = [email protected]    _orgResEntry                    = [email protected]    _resEntry_Material              = [email protected]    _newResEntry                    = [email protected]    _orgMaterial                    = [email protected]    _newMaterial                    = [email protected]    _resEntry_Size                  = [email protected]    _loopCount_1                    = [email protected]    _clonedAtomic                   = [email protected]    _newGeometry                    = [email protected]    _newMaterialList                = [email protected]    _currAtomic                     = [email protected]    _orgGeometry                    = [email protected]      _orgMaterialList                = [email protected]    _atomicCounter                  = [email protected]    _totalAtomic                    = [email protected]    _nMaxVehicleVisibleAtomics      = [email protected]    _nVehicleVisibleAtomics         = [email protected]    _RwFrameForAllObjects           = [email protected]    _GetOkAtomics                   = [email protected]    _GetOkAtomicsCB                 = [email protected]    _RpGeometryForAllMaterials      = [email protected]    _RpClumpForAllAtomics           = [email protected]    _setMaterialColorCB             = [email protected]    _atomicSetColorForAllMaterials  = [email protected]    _OkAtomics                      = [email protected]    _threadPTR                      = [email protected]    _Node                           = [email protected]    _currNode                       = [email protected](_levelIDX,1i)                    _memcpy                         = 0x00822A20    _malloc                         = 0x00824257    _rwFrameFindNodeByName          = 0x004C5400    _rwFrameGetNodeName             = 0x0072FB30    _rpClumpAddAtomic               = 0x0074A490    _rpClumpRemoveAtomic            = 0x0074A4C0    _rpClumpGetNumAtomics           = 0x007498E0      _rpClumpGetBoundingSphere       = 0x00734FC0      _rpAtomicGetWorldBoundingSphere = 0x00749330            _rpAtomicClone                  = 0x00749E60    _rpAtomicSetFrame               = 0x0074BF20    _rpAtomicDestroy                = 0x00749DC0    _rpAtomicSetGeometry            = 0x00749D40     _rpGeometryCreate               = 0x0074CA90           _rpMaterialClone                = 0x0074DA80        _rpMaterialListAlloc            = 0x0074E1C0            _rpMaterialListAppendMaterial   = 0x0074E350        _rpMaterialListGetMaterial      = 0x0074E2B0        _rpMaterialListInitialize       = 0x0074E1B0    _rwResourcesAllocateResEntry    = 0x00807ED0        _GetAtomicId                    = 0x00732370          end var    [email protected]  : int    [email protected]  : int    [email protected]  : int    [email protected]  : int    [email protected]  : int    [email protected]  : int    [email protected]  : int    [email protected]  : int    [email protected]  : int    [email protected]  : int        [email protected] : int    [email protected] : int    [email protected] : int    [email protected] : int    [email protected] : int    [email protected] : int    [email protected] : int    [email protected] : int    [email protected] : int        [email protected] : int    [email protected] : int    [email protected] : int    [email protected] : int    [email protected] : int    [email protected] : int    [email protected] : int    [email protected] : int    [email protected] : int    [email protected] : int    [email protected] : int    [email protected] : int    [email protected] : int    [email protected] : int    [email protected] : int    end                          0A9F: _threadPTR = current_thread_pointer0A8E: _threadPTR = _threadPTR + 0x10 // CRunningScript_m_iBaseAddress0A8D: _threadPTR = read_memory _threadPTR size 4 virtual_protect 00A8F: _atomicSetColorForAllMaterials = _threadPTR - @_atomicSetColorForAllMaterials0A8F: _setMaterialColorCB = _threadPTR - @_setMaterialColorCB0A8F: _GetOkAtomicsCB = _threadPTR - @_GetOkAtomicsCB0A8F: _GetOkAtomics = _threadPTR - @_GetOkAtomics0A8F: _nVehicleVisibleAtomics = _threadPTR - @_nVehicleVisibleAtomics0A8F: _nMaxVehicleVisibleAtomics = _threadPTR - @_nMaxVehicleVisibleAtomics0A8D: _RpClumpForAllAtomics = read_memory 0x00479143 size 4 virtual_protect 1_RpClumpForAllAtomics += 0x004791470A8D: _RpGeometryForAllMaterials = read_memory 0x004C781E size 4 virtual_protect 1_RpGeometryForAllMaterials += 0x004C78220A8D: _RwFrameForAllObjects = read_memory 0x004C7C3C size 4 vp 1_RwFrameForAllObjects += 0x004C7C400A8E: _temp_0_ = _atomicSetColorForAllMaterials + 0x110A8C: write_memory _temp_0_ size 4 value _setMaterialColorCB virtual_protect 00A8E: _temp_0_ = _atomicSetColorForAllMaterials + 0x170A8E: _temp_1_ = _temp_0_ + 40A8F: _temp_2_ = _RpGeometryForAllMaterials - _temp_1_0A8C: write_memory _temp_0_ size 4 value _temp_2_ virtual_protect 00A8E: _carClump = _CarPtr + 0x18 // CEntity.m_pRwObject (clump)        0A8D: _carClump = read_memory _carClump size 4 virtual_protect 0if    _alphaCar <= 255then    0B16: _alphaCar = _alphaCar SHL 24        0AA5: call _RpClumpForAllAtomics num_params 3 pop 3 stColor _alphaCar pcbAtomic _atomicSetColorForAllMaterials pstClump _carClump    0AB2: ret 0end0A8E: _temp_0_ = _GetOkAtomicsCB + 70A8E: _temp_1_ = _temp_0_ + 40A8F: _temp_2_ = _GetAtomicId - _temp_1_0A8C: write_memory _temp_0_ size 4 value _temp_2_ vp 00A8E: _temp_0_ = _GetOkAtomicsCB + 0x170A8C: write_memory _temp_0_ size 4 value _nVehicleVisibleAtomics vp 00A8E: _temp_0_ = _GetOkAtomicsCB + 0x200A8C: write_memory _temp_0_ size 4 value _nVehicleVisibleAtomics vp 00A8E: _temp_0_ = _GetOkAtomicsCB + 0x260A8C: write_memory _temp_0_ size 4 value _nMaxVehicleVisibleAtomics vp 00A8E: _temp_0_ = _GetOkAtomics + 30A8C: write_memory _temp_0_ size 4 value _nVehicleVisibleAtomics vp 00A8E: _temp_0_ = _GetOkAtomics + 0x0D0A8C: write_memory _temp_0_ size 4 value _nMaxVehicleVisibleAtomics vp 00A8E: _temp_0_ = _GetOkAtomics + 0x170A8C: write_memory _temp_0_ size 4 value _GetOkAtomicsCB vp 00A8E: _temp_0_ = _GetOkAtomics + 0x210A8E: _temp_1_ = _temp_0_ + 40A8F: _temp_2_ = _RwFrameForAllObjects - _temp_1_0A8C: write_memory _temp_0_ size 4 value _temp_2_ vp 00A8E: _temp_0_ = _GetOkAtomics + 0x290A8C: write_memory _temp_0_ size 4 value _nVehicleVisibleAtomics vp 0//Prepare Linked List buffer0AC7: _temp_1_ = var [email protected] offset                0AC6: _temp_2_ = label @LinkedListBuffer             0A8F: _levelIDX = _temp_2_ - _temp_1_       _levelIDX /= 4_levelIDX++0AA7: call_function _rpClumpGetNumAtomics num_params 1 pop 1 pRpClump _carClump numAtomics_to _totalAtomic                       0D4E: _currNode = struct _carClump offset 0x04 size 4  // parent (rwFrame)   0D4E: _currNode = struct _currNode offset 0x98 size 4 // child                                                                        gosub @ListWalk                                                0AB2: ret 0//--------------------------------------------------:processNode            0AC6: _OkAtomics = label @OK_Atomics offset             0AA7: call_function _GetOkAtomics num_params 3 pop 3 nCount 8 pAtomicList _OkAtomics pFrame _currNode nRetCount _atomicCounter          0A8D: _temp_2_ = read_memory _currNode size 2 virtual_protect 0  if and    _atomicCounter > 0    _temp_2_ == 0then      repeat                                _atomicCounter--                                _totalAtomic--                                            0A8D: _currAtomic = read_memory _OkAtomics size 4 virtual_protect 0  // rpAtomic from OkAtomic list                    0A8D: _temp_2_ = read_memory _currAtomic size 2 virtual_protect 0                      if            _temp_2_ <> 0x01    //check atomic type        then            continue                     end                                                                      0D4E: _orgGeometry = struct _currAtomic offset 0x18 size 4 // rpAtomic.rpGeometry                                    0D4E: _temp_2_ = struct _orgGeometry offset 0x58 size 4 //rpGeometry.resEntry        if            _temp_2_ == 0   //if no resEntry...skip geometry replication        then            continue        end                                                        gosub @clone_Geom_Mat                     0AA7: call_function _rpAtomicClone num_params 1 pop 1 pstRpAtomic _currAtomic pstRpAtomic _clonedAtomic                                0D4E: _temp_1_ = struct _orgGeometry offset 0x08 size 4 //geometry flags                                0AA5: call _rpAtomicSetGeometry num_params 3 pop 3 pstRpAtomic geomFlags _temp_1_ pGeometry _newGeometry pstRpAtomic _clonedAtomic                    0AA5: call _rpAtomicSetFrame num_params 2 pop 2 pstRwFrame _currNode pstRpAtomic _clonedAtomic        0AA5: call _rpClumpAddAtomic num_params 2 pop 2 pstRpAtomic _clonedAtomic pstRpClump _carClump                    0AA5: call _rpClumpRemoveAtomic num_params 2 pop 2 pstRpAtomic _currAtomic pstRwClump _carClump                0AA5: call _rpAtomicDestroy num_params 1 pop 1 pstRpAtomic _currAtomic                                                          _OkAtomics += 4                                                          until _atomicCounter == 0         end    return     //--------------------------------------------------:ListWalkif    _totalAtomic > 0        //emergency exitthen        0D4E: _Node = struct _currNode offset 0x98 size 4 // child    if        _Node <> 0   //there is child                                                 then              _levelIDX++             //go child            _currNode = _Node       //register node addr            gosub @ListWalk                _levelIDX--             //back to current            end        gosub @processNode        0D4E: _Node = struct _currNode offset 0x9C size 4 //check brother    if        _Node <> 0          //there is brother    then          _currNode = _Node   //brother is the current            goto @ListWalk     //go brother            end        endreturn    //--------------------------------------------------      :clone_Geom_Mat0AA7: call_function_return _malloc 1 1 params Size 0x60 StoreTo _newGeometry0AA5: call_function _memcpy num_params 3 pop 3 params Size 0x60 RpGeometry _orgGeometry CopyTo _newGeometry                           0A8E: _temp_1_ = _newGeometry + 0x0E    //refCount 0A8C: write_memory _temp_1_ size 2 value 1 vp 0  //     0D4E: _orgResEntry = struct _orgGeometry offset 0x58 size 4 //resEntry original//take care of resEntry part of Geometry0D4E: _resEntry_Size = struct _orgResEntry offset 0x08 size 4  //size (original)0AA7: call_function_return _rwResourcesAllocateResEntry num_params 4 pop 4 destroy 0 size _resEntry_Size ownerRef 0 owner _newGeometry storeRes _newResEntry //create a new resEntry0A8E: _temp_1_ = _newGeometry + 0x58 0A8C: write_memory _temp_1_ size 4 value _newResEntry vp 0  //  put the new resEntry into the new rpGeometry//copy part of original resEntry_newResEntry += 0x18     //sizeOf(RwResEntry)_orgResEntry += 0x18     //idem0AA5: call_function _memcpy num_params 3 pop 3 params Size _resEntry_Size block _orgResEntry CopyTo _newResEntry//new Material List (initially empty)0D4E: _numMaterials = struct _orgGeometry offset 0x24 size 4 //numMaterials_orgMaterialList += 0x20  // old RpMaterialList_newMaterialList += 0x20  // new RpMaterialList0AA7: call_function_return _rpMaterialListAlloc 1 1 params numMat _numMaterials StoreTo _MatArray0A8C: write_memory _newMaterialList size 4 value _MatArray vp 0    // put back New Mat Array0AA5: call_function _rpMaterialListInitialize num_params 1 pop 1 pstMatList _newMaterialList   _numMaterials -= 1for _loopCount_1 = 0 to _numMaterials  //clone each material from original Material List, putting them into the new Material List        0AA7: call_function_return _rpMaterialListGetMaterial num_params 2 pop 2 matIndex _loopCount_1 matList _orgMaterialList storeMat _orgMaterial        if        _orgMaterial == 0    then        continue    end                0AA7: call_function_return _rpMaterialClone num_params 1 pop 1 _orgMaterial storeClone _newMaterial        0AA5: call_function _rpMaterialListAppendMaterial num_params 2 pop 2 pstMat _newMaterial pstMatList _newMaterialList        //update each material of resEntry with the cloned materials from Material List        for _loopCount_2 = 0 to _numMaterials            0A90: _instData_MatOff = _loopCount_2 * 36  //sizeOf(RxD3D9InstanceData)            _instData_MatOff += 72 //sizeOf (RxD3D9ResEntryHeader) + RpMaterial offset            0D4E: _resEntry_Material = struct _orgResEntry offset _instData_MatOff size 4  // RpMaterial from each RxD3D9InstanceData (original)            if            _resEntry_Material == _orgMaterial     //RpMaterial from RxD3D9InstanceData correspond to RpMaterial from RpMaterialList         then                0A8E: _temp_1_ = _instData_MatOff + _newResEntry            0A8C: write_memory _temp_1_ size 4 value _newMaterial vp 0    //update RpMaterial of the new ResEntry above created        end    end       end _newGeometry -= 0x20_orgGeometry -= 0x20return //-------------------------------------------------- :_atomicSetColorForAllMaterialshex    8B4424 04       // 00000000 mov     eax, [esp+pstAtomic]    8B40 18         // 00000004 mov     eax, [eax+SRpAtomic.m_pstGeometry]    804808 40       // 00000007 or      [eax+SRpGeometry.m_uiFlags], 40h    8B4C24 08       // 0000000B mov     ecx, [esp+stColor]    51              // 0000000F push    ecx    68 00000000     // 00000010 push    offset setMaterialColorCB    50              // 00000015 push    eax    E8 00000000     // 00000016 call    RpGeometryForAllMaterials    83C4 0C         // 0000001B add     esp, 0Ch    C3              // 0000001E retn//  90              // 0000001F nopend:_setMaterialColorCBhex    8b 44 24 04             //mov    eax,DWORD PTR [esp+pstMaterial]    8b 40 04                //mov    eax,DWORD PTR [eax+m_stColor]    8b 4c 24 08             //mov    ecx,DWORD PTR [esp+stColor]    25 ff ff ff 00          //and    eax,0xffffff    81 e1 00 00 00 ff       //and    ecx,0xff000000    01 c8                   //add    eax,ecx    8b 4c 24 04             //mov    ecx,DWORD PTR [esp+pstMaterial]    89 41 04                //mov    DWORD PTR [ecx+m_stColor],eax    c3                      //ret end :_GetOkAtomicsCBhex    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    75 20         // 00000010 jnz     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 nopend:_GetOkAtomicshex    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 nopend:_nVehicleVisibleAtomicshex    00000000end:_nMaxVehicleVisibleAtomicshex    00000000end:OK_Atomicshex    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00end:LinkedListBufferhex    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00end

 

 

Edited by pep legal

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.