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

    1. GTA Online

      1. The Diamond Casino Heist
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
    2. Red Dead Online

      1. Frontier Pursuits
      2. Find Lobbies & Outlaws
      3. Help & Support
    3. Crews

      1. Events
    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Redemption

    1. Grand Theft Auto Series

    2. GTA 6

    3. GTA V

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

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
      5. GTA IV 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 SA Mods
    9. GTA Vice City

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

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

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

    3. Mod Showroom

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

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    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
    3. Gangs

    1. News

    2. Forum Support

    3. Site Suggestions

Sign in to follow this  
ikt

[C#] Can't manage to draw particle FX

Recommended Posts

ikt

Hey there,

 

I'm trying to draw particle FX in C#, but it simply does not seem to show up. The exact same code _does_ work in another mod in C++, so I must be calling a wrong function, I think.

 

First, the C++ variant, which works.

 

// PtfxHandles is a vector of ints, gV has a valid Vehicle member, boneIdxs is also a vector of ints
                RequestEffectLibrary("veh_impexp_rocket");
                GRAPHICS::_USE_PARTICLE_FX_ASSET_NEXT_CALL("veh_impexp_rocket");
                gV.PtfxHandles[i] = GRAPHICS::_START_PARTICLE_FX_LOOPED_ON_ENTITY_BONE(
                    "veh_rocket_boost",
                    gV.Vehicle,
                    -0.15f, 0.0f, 0.0f,
                    0.0f, 0.0f, -90.0f,
                    boneIdxs[i], 1.5f,
                    false, false, false);
                GRAPHICS::SET_PARTICLE_FX_LOOPED_EVOLUTION(gV.PtfxHandles[i], "boost", 0.0f, 0);
                GRAPHICS::SET_PARTICLE_FX_LOOPED_EVOLUTION(gV.PtfxHandles[i], "charge", 1.0f, 0);
                GRAPHICS::SET_PARTICLE_FX_LOOPED_ALPHA(gV.PtfxHandles[i], 255);

void RequestEffectLibrary(const char* lib) {
    STREAMING::REQUEST_NAMED_PTFX_ASSET((char*)lib);
    while (!STREAMING::HAS_NAMED_PTFX_ASSET_LOADED((char*)lib))
        WAIT(0);
}

 

And the C# variant, which does not work.

 

                    RequestEffectLibrary("veh_impexp_rocket");
                    Function.Call(Hash._0x6C38AF3693A69A91, "veh_impexp_rocket"); //USE_PARTICLE_FX_ASSET
                    v.PtfxHandles[i] = Function.Call<int>(Hash._START_PARTICLE_FX_LOOPED_ON_ENTITY_BONE,
                        "veh_rocket_boost",
                        v.Vehicle,
                        -0.15f, 0.0f, 0.0f,
                        0.0f, 0.0f, -90.0f,
                        boneIdxs[i], 1.5f,
                        false, false, false);
                    Function.Call(Hash.SET_PARTICLE_FX_LOOPED_EVOLUTION, v.PtfxHandles[i], "boost", 0.0f, 0);
                    Function.Call(Hash.SET_PARTICLE_FX_LOOPED_EVOLUTION, v.PtfxHandles[i], "charge", 1.0f, 0);
                    Function.Call(Hash.SET_PARTICLE_FX_LOOPED_ALPHA, v.PtfxHandles[i], 255);

    void RequestEffectLibrary(string lib)
    {
        Function.Call(Hash.REQUEST_NAMED_PTFX_ASSET, lib);
        while (!Function.Call<bool>(Hash.HAS_NAMED_PTFX_ASSET_LOADED, lib))
            Wait(0);
    }

I really don't see (pun not intended) what's going on. It seems the particle effect is spawned, as my car was set on fire, but no visual effects were drawn.

 

Share this post


Link to post
Share on other sites
Guest

I haven't used the native to put particles on a vehicle bone, so I've not used those evolution natives... well, other than the alpha one. I honestly can't see why that wouldn't work, unless it's getting hung up in that RequestEffectLibrary function.

 

I've got _SET_PTFX_ASSET_NEXT_CALL in my code, which is just the same as _0x6C38AF3693A69A91 from what I can see.

 

The only other difference is my request code is slightly different but that shouldn't really matter. I do this:

	Function.Call(Hash.REQUEST_NAMED_PTFX_ASSET, FxLibrary);

	if (Function.Call<bool>(Hash.HAS_NAMED_PTFX_ASSET_LOADED, FxLibrary))
	{
		// Spawn the particle code here...
	}

So it's not waiting for it to load, it just doesn't spawn anything until it does.

 

Unless the calls through SHVDN work slightly different, I'm not too sure.

 

Edit: Well I have tried several different ways now and I can't get that effect to appear either. Then again, I don't know if it's for a specific vehicle and a specific bone. I tried it on the voltic2 and the exhaust bone. The particle gets generated, because it creates a valid ID but I get nothing visible.

 

Another Edit: I noticed there's also a _START_PARTICLE_FX_LOOPED_ON_ENTITY_BONE_2 but I can't get it to work with that either.

Edited by Guest

Share this post


Link to post
Share on other sites
ikt

I'm incredibly stupid. The function is SET_PARTICLE_FX_LOOPED_ALPHA(int ptfxHandle, float alpha).

 

Alpha should be between 0.0f and 1.0f. Not 0 and 255.

 

It probably just happened to work in C++ because it implicitly set it to 255.0f. Not sure what it did with my 255, probably turn it into its integer representation.

 

Thank you for taking a look at it and confirming the rest was good.

Share this post


Link to post
Share on other sites
Guest

How on earth did I miss that? I wouldn't mind, in my ground effects, I have this:

public void EvolveAlpha()
{
	Alpha = Math.Max(Math.Min(Alpha, 1f), .1f);
	Function.Call(Hash.SET_PARTICLE_FX_LOOPED_ALPHA, ID, Alpha);
}

But I store all the colours in XML like this, because they're easier to understand as colour values.

<Colour>250,240,219,64</Colour>

I must have looked at the XML and thought... 64, that's an int, so 255 must be right. Glad you figured it out anyway.

Edited by Guest

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

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