Today let's play with particle effects, it's simple and give an good look to the script effects.
Download the project here.
As you probably know an particle effect (PTFX) in GTA IV is the effect of bullet impacts, water splash, explosions, fire, water fountain, weapons muzzle, sparks, etc.. They are almost everywhere in the game.
In this video i show some interesting particle effects, take a look :)
To call this effects we can use the following methods:
START_PTFX
START_PTFX_ON_OBJ
START_PTFX_ON_OBJ_BONE
START_PTFX_ON_PED
START_PTFX_ON_PED_BONE
START_PTFX_ON_VEH
TRIGGER_PTFX
TRIGGER_PTFX_ON_OBJ
TRIGGER_PTFX_ON_OBJ_BONE
TRIGGER_PTFX_ON_PED
TRIGGER_PTFX_ON_PED_BONE
TRIGGER_PTFX_ON_VEH
As you can see we have two types of method, START and TRIGGER, the difference is that START will return an Particle Effect ID, and with this ID we have some control over the PTFX, we can stop the effect when we want for example, or change the particle effect Offset too.
The TRIGGER will only call the particle effect and don't will return any ID, not all particle effects can be used with trigger, some only work with start method.
We use trigger in particle effects that will end automatically, for example to simulate an shoot we can trigger the muz_pistol to make the muzzle effect, i use this effect in Iron Man script to simulate the effect in his boots and hands when he is flying.
Important: If you want restart an PTFX satrted using START method, always stop the previous, otherwise you can create an "bug" in the game and the particle effects don't will work anymore for your script until you reopen the game :(
We have a lot of particle effects to use in this game, so i made an small script to preview this particle effects in game, you can download it here, extract the .net.dll and .txt file into your GTA Scripts folder, to activate the script type the console command "pd" and use the command "pfilter filter_word" to filter the list if you wish:
Another interesting thing about particle effects is that some particle effects has sounds and interact with game physics and pedestrians/vehicles, for example, the ambient_fire_generic will burn any ped that touches it, the fire_chopper_tail will produce fire sound :)
Let's start with the more basic TRIGGER method:
What happens here is that when i press number 0 i will get an position in front of player then call the TRIGGER_PTFX method using that position.
The parameters are:
Easy no? Now let's use one more advanced: TRIGGER_PTFX_ON_PED_BONE:
We are making the player bleed with the PTFX blood_gun_entry_arterial
The parameters are similar:
Basically what is new is the Ped ID and the Ped Bone ID.
Now let's use an START method, i wanna be able to control when it will end:
The PTFX water_carwash_drips never ends.
Here I'm storing the ID returned by START_PTFX_ON_PED_BONE into tmpID variable, an int32 type. As you can see the parameters are just the same type used in TRIGGER_PTFX_ON_PED_BONE.
After 10 seconds i will use the method STOP_PTFX to stop the effect, as parameter we need the ID returned by the start method.
Also we can remove the effect using:
REMOVE_PTFX_FROM_PED
REMOVE_PTFX_FROM_OBJECT
REMOVE_PTFX_FROM_VEHICLE
Those methods will remove all PTFX from the ped/object/vehicle.
The EVOLVE_PTFX method will make some changes in the PTFX, i never used this but i can demonstrate the functionality based on SCOCL files :)
Here we call the EVOLVE_PTFX method and use the param "fade" and an float number to reduce the opacity of the smoke effect, 0 = full opacity ~1.8 = no opacity.
The parameters are:
PTFX ID (tmpID)
Attribute to change ("fade")
Attribute value (c)
This is the original code from SCOCL:
Easy to read? Never ^^, but very useful.
The UPDATE_PTFX_OFFSETS method will update the offset (or start position) and rotation of the PTFX:
Parameters:
PTFX ID (tmpID)
X, Y, Z offset/position (0, 0, c)
Pitch, Yaw, Roll rotation (0, 0, 0)
With this method we can make an spinning PTFX changing one of the last three parameters :)