gta-chaos-mod / Trilogy-ASI-Script

The ASI script for the GTA Trilogy (SA only for now, 3 and VC may follow later on)
GNU General Public License v3.0
141 stars 21 forks source link

New effect: `Invisible fire` #216

Closed gromchek closed 1 year ago

gromchek commented 1 year ago

This disables rendering most of game particles: smoke grenades, explosions, fire (car's fire, fire on ground, ped's, jetpack/hydra nozzle), spraycan, fire extinguisher, smoke on a rooftop (while Riot effect is enabled), car's smoke

Lordmau5 commented 1 year ago

Seeing as this also disables rendering for non-fire particles I wonder if renaming it do Disable FX or similar might be a better idea instead?

That or only hooking the calls/jumps that are fire related

gromchek commented 1 year ago

Seeing as this also disables rendering for non-fire particles I wonder if renaming it do Disable FX or similar might be a better idea instead?

Car's sparks are displayed, blood is displayed (when hit by a weapon), sparks are also displayed when the player shoots at a car or to the ground. So not all of the particles are disabled.

I checked FxManager_c::Render. This may disable all particle rendering (probably).

Lordmau5 commented 1 year ago

So not all of the particles are disabled.

Hmm but the spraycan isn't really fire, neither is the fire extinguisher... smoke on a rooftop and car's smoke I can still get behind but yeah

Lordmau5 commented 1 year ago

Alright, so checking where FxSystem_c::Play is being called from brings up a bunch of locations. image

Would you be fine with cherry-picking which ones we might need from those?

I notice the very first one is CRunningScript::ProcessCommands which means it's an opcode - you can check on opcodes here: https://library.sannybuilder.com/#/sa

I can also see 3 calls in CAutomobile::DoNitroEffect - I'm not sure if we'd want those disabled since they might not be considered "fire"

Also: There's an IDA plugin called LazyIDA which allows you to click on a function call and press W to copy the address it's at into your clipboard. Makes copying addresses much easier

gromchek commented 1 year ago

Now I did it in right way. Deep inside in FxManager_c::CreateFxSystem the game looks up the particle by hash (CKeyGen::GetUppercaseKey). I thought I could disable particle rendering if the hash matches and it worked. These effects are disabled:

fire_bike 2287826537
fire_car 4166829922
overheat_car 445182679
overheat_car_electric 1046403207

https://gtamodding.ru/wiki/Визуальные_эффекты_в_скриптинге#San_Andreas here a list of special effects. So if in the future we want to disable other particles, we should just calculate the hash. auto hash = CKeyGen::GetUppercaseKey("fire_bike"); //2287826537

Lordmau5 commented 1 year ago

Could you maybe add a comment next to the hash in the invalidHashes list so we know what effects those are?

Also same-line return for the if (hash == fx->m_nNameKey) line Also renaming the static Hook method to something like... Hooked_FxManager__CreateFxSystem or similar

Besides that it looks alright to me.

Jersukai commented 1 year ago

Is this effect working correctly for you?

Engine fires are working correctly, but other fires are still visible. Except for one time after playing for a while those fires were invisible too, even when the effect wasn't active.

gromchek commented 1 year ago

This effect disable rendering motobike and car smoke/fire effect only. Plane's smoke/fire is still visible.

@Jersukai can you please write how to reproduce this:

Except for one time after playing for a while those fires were invisible too, even when the effect wasn't active.

Jersukai commented 1 year ago

It should disable fire on ground too, right?

I don't know, It happened only that one time.

gromchek commented 1 year ago

@Jersukai sorry for late answer. The fire on the ground should work as usual.