OSP Code Optimisation Drifting Musket Smoke Effects: Optomised for Performance

Users who are viewing this thread

I've got a thing for battlefield smoke, so after a long while of tinkering around with particle effects in my mod, I've come up with something that performs well without being a single puff of ugly grainy smoke. my computer isn't great, yet still runs this fairly well. I did some tests involving 400 bots all  firing, and it didn't cause much lag.

Nothing special, but hopefully this will save time for people who aren't prepared to spend hours trial-ing and error-ing with the module system.
It's comprised of three particle effects in succession, and allow smoke to drift away in a single direction, without using the unpredictable "turbulence" effect.

1. Muzzle flare.
2. Normal muzzle smoke: Smoke fired from in the direction of fire. Lasts 5 seconds.
3. Drifting smoke: Smoke that drifts slowly in the same global direction to simulate wind. Lasts 20 seconds.

Add these lines to module_particle_systems.py

("pistol_flare", psf_billboard_3d, "prt_mesh_fire_1",
    30, 0.2, 0.2, 0.0, 10.0, 0.0,    #num_particles, life, damping, gravity_strength, turbulance_size, turbulance_strength
    (0, 1.0), (1, 0),        #alpha keys
    (0, 1.0), (0.4, 0.7),      #red keys
    (0, 0.5),(0.4, 0.1),      #green keys
    (0, 0.3), (0.4, 0.2),      #blue keys
    (0, 0.4),  (1, 1.0),  #scale keys
    (0.04, 0.04, 0.01),      #emit box size
    (0, 3, 0),              #emit velocity
    0.2,                      #emit dir randomness
    200,                      #rotation speed
    0.2                        #rotation damping
    ),

    ("pistol_smoke", psf_billboard_3d, "prt_mesh_dust_1",
    5, 4, 0.6, 0, 80.0, 2,  #(was 30. 1.5)  #num_particles, life, damping, gravity_strength, turbulance_size, turbulance_strength
#for testing purposes of the below, life has been changed to 5.
    (0.0, 0.3), (1, 0),      #alpha keys
    (0.0, 0.62), (1, 0.3),      #red keys
    (0.0, 0.63),(1, 0.31),      #green keys
    (0.0, 0.63), (1, 0.4),      #blue keys
    (0, 2.5),  (1, 20.0),  #scale keys
    (0.1, 0.1, 0.1),          #emit box size
    (0, 1.5, 0),                #emit velocity
    0.23                        #emit dir randomness
    ),

("pistol_smoke_large", psf_billboard_3d|psf_global_emit_dir, "prt_mesh_dust_1",
    1, 20, 0, -0.01, 80.0, 1,  #(was 30. 1.5)  #num_particles, life, damping, gravity_strength, turbulance_size, turbulance_strength
    (0.0, 0.3), (1, 0),      #alpha keys
    (0.0, 0.3), (1, 0.3),      #red keys
    (0.0, 0.31),(1, 0.31),      #green keys
    (0.0, 0.4), (1, 0.4),      #blue keys
    (0, 2.5),  (0.3, 10.0),  #scale keys
    (1, 1, 1),          #emit box size
    (0.5, 1.5, 0),                #emit velocity
    0.1                        #emit dir randomness
    ),


And add this trigger to each firearm. For pistols, simply omit psys_pistol_smoke_large, which is the drifting smoke element.

Finally, install this texture.

https://drive.google.com/file/d/0By7KvxJ31VhtMVh2VW9xam13TE0/edit?usp=sharing

[(ti_on_weapon_attack,[(position_move_x,pos1,0),(position_move_y,pos1,112),(particle_system_burst,"psys_pistol_smoke",pos1,15),(particle_system_burst,"psys_pistol_flare",pos1,15),(particle_system_burst,"psys_pistol_smoke_large",pos1,5)])]

Screenshots don't do it much justice, but here you go anyway:

5E59EB5E1E005FC43B6E648025942E34AB8B3F63

9FE0F06B07761152BB4FEC5B1C720EBC7BB2C23B

FF24F27CA79C2CEBE591C68525EEE98A21E5ACC9

A12112B3E34DCDA13F6F89EE4B62A655A5CB1DE3
 
Why the heck are you guys allways using the weapon attack trigger to apply sound- and particle effects?
This is horrible when it comes to network traffic, cause you'd have to synce the effects to all clients.

Use a game engine script instead, which is fired server- and clientside everytime a missile launches.
Code:
  # script_game_missile_launch
  # Input: arg1 = shooter_agent_id, arg2 = weapon_item_id, pos1 = weapon_item_position
  # Output: none 
  ("game_missile_launch",
  [
    (store_script_param, ":shooter_agent", 1),
    (store_script_param, ":item_id", 2),
...
...
Cheers!
 
Back
Top Bottom