ikt Posted April 29, 2019 Share Posted April 29, 2019 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. Link to comment Share on other sites More sharing options...
Guest Posted April 29, 2019 Share Posted April 29, 2019 (edited) 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 April 29, 2019 by Guest Link to comment Share on other sites More sharing options...
ikt Posted April 30, 2019 Author Share Posted April 30, 2019 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. Link to comment Share on other sites More sharing options...
Guest Posted April 30, 2019 Share Posted April 30, 2019 (edited) 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 April 30, 2019 by Guest Link to comment Share on other sites More sharing options...