spashing water on missile hit

Users who are viewing this thread

_Sebastian_

Punkbuster 2.0
Baron
Hi guys.
I want to add a spashing water particle effect to Warband, but I need some help to do that.

The whole code I need could be found in M&B WFAS.
I found this code in module_scripts.py
Code:
  # script_game_missile_dives_into_water
  # Input: arg1 = missile_item_id, pos1 = missile_position_on_water
  # Output: none 
  ("game_missile_dives_into_water",
    [ 
	#(store_script_param, ":missile_item_id", 1),
	(copy_position, pos51, pos1), 
	(particle_system_burst_no_sync, "psys_water_hit_a", pos51, 8),
	(position_move_z, pos51, 5, 1),
	(particle_system_burst_no_sync, "psys_water_hit_b", pos51, 4),
  ]),
And this in module_particle_systems.py
Code:
		##### WATER HIT ######
		
		("water_hit_a", psf_billboard_3d | psf_randomize_size | psf_randomize_rotation | psf_global_emit_dir, "prtcl_splash_b",
        80, 1.5, 4, 0.8, 0, 0, #num_particles, life, damping, gravity_strength, turbulance_size, turbulance_strength
        (0.0, 1), (1, 0),     #alpha keys
        (0.0, 0.95), (1, 0.95),          #red keys
        (0.0, 0.90), (1, 0.90),           #green keys
        (0.0, 0.70), (1, 0.70),          #blue keys
        (0, 0.3), (1, 2),  #scale keys
        (0, 0, 0),         #emit box size
        (0, 0, 6),               #emit velocity
        0,                      #emit dir randomness
        100,                     #rotation speed
        0.2                       #rotation damping
        ),
		
		("water_hit_b",psf_randomize_size | psf_randomize_rotation | psf_turn_to_velocity|psf_global_emit_dir, "prtcl_splash_b",
        4, 3, 0, 0, 0, 0, #num_particles, life, damping, gravity_strength, turbulance_size, turbulance_strength
        (0.0, 1), (1, 0),     #alpha keys
        (0.0, 0.95), (1, 0.95),          #red keys
        (0.0, 0.90), (1, 0.90),           #green keys
        (0.0, 0.70), (1, 0.70),          #blue keys
        (0, 1), (1, 5),  #scale keys
        (0.1, 0.1, 0),         #emit box size
        (0, 0, -0.01),               #emit velocity
        0,                      #emit dir randomness
        25,                     #rotation speed
        0.15                       #rotation damping
        ),

But what I cant find is the trigger of the script "game_missile_dives_into_water".
I don't know in which .py file of WFAS the trigger is located or how I could write it.

I hope someone can help me.
Thanks.
 
There isn't any trigger; that's something the game engine calls automatically.

Try adding this code to Warband, tell us if it works.  If not, there is another way.

 
xenoargh said:
There isn't any trigger; that's something the game engine calls automatically.

Try adding this code to Warband, tell us if it works.  If not, there is another way.
No it doesn't work.

cmpxchg8b said:
game_missile_dives_into_water works only on WFaS, not on Warband.
Ah ok.
Is there another way to code it in the game?
I saw the splashing water effect in The Deluge mod.
 
Yeah, it's really easy.

Code:
 (ti_on_missile_hit,
      [
         #pos1 - Missile hit position
         #param_1 - Shooter agent
(copy_position, pos63, pos1),     
  (position_get_z, ":z_pos", pos63),
(try_begin),
(gt, ":z_pos", -1),
(particle_system_burst,"psys_bullet_dust",pos63,1),
(else_try),
	(particle_system_burst, "psys_water_hit_a", pos63, 8),
	(position_move_z, pos63, 5, 1),
	(particle_system_burst, "psys_water_hit_b", pos63, 4),
(try_end),
]),
 
Yup.  Same difference, as far as the player's concerned though, and you can always add a cutoff for really deep water if you want, move it to exactly water-level or whatever.  That's just the very cheap version.
 
xenoargh said:
Yeah, it's really easy.

Code:
 (ti_on_missile_hit,
      [
         #pos1 - Missile hit position
         #param_1 - Shooter agent
(copy_position, pos63, pos1),     
  (position_get_z, ":z_pos", pos63),
(try_begin),
(gt, ":z_pos", -1),
(particle_system_burst,"psys_bullet_dust",pos63,1),
(else_try),
	(particle_system_burst, "psys_water_hit_a", pos63, 8),
	(position_move_z, pos63, 5, 1),
	(particle_system_burst, "psys_water_hit_b", pos63, 4),
(try_end),
]),

Thank you for this.
But now the particles appear under water on the missile hit position and not at the correct position where the missile hit's the water.

Could you tell me how to fix this?
I'm just at the begining of my warband coding career  :wink:
 
Just raise the position 50 cm on the z axis, or better yet, set the position to -50cm, no matter where it goes, or zero, and then simply adjust your particle system. 

You're going to need to figure this out; if I write it all for you, you aren't learning anything.  Look for set_fixed_point_multiplier and position_set in header_operations.
 
I tested half-meter rise, 3-meter max; no problems.  Unless your projectiles are moving at incredibly slow speeds, you won't see the lag in those scenarios- a typical crossbow bolt in my mod is traveling somewhere > 60 M/S, so 3 meters is not a big lag.  For deeper water, it'd be problematic, to be sure, but meh, most mods keep the standard water depths for outdoors scenes, since looking at guys walking around underwater is kind of meh.
 
Finally...
I finished the script with WSE and it works fine.

Now all arrows, bolts and bullets are using the splashing water effect.
Here is my code;

module_items
Code:
#whalebone crossbow, yew bow, war bow, arming sword 
 ["arrows","Arrows", [("arrow",0),("flying_missile",ixmesh_flying_ammo),("quiver", ixmesh_carry)], itp_type_arrows|itp_merchandise|itp_default_ammo, itcf_carry_quiver_back, 72,weight(3)|abundance(160)|weapon_length(95)|thrust_damage(1,pierce)|max_ammo(30),imodbits_missile,
  [(ti_on_missile_dive, [(call_script, "script_on_missile_water_hit"), ])]],
 ["khergit_arrows","Khergit Arrows", [("arrow_b",0),("flying_missile",ixmesh_flying_ammo),("quiver_b", ixmesh_carry)], itp_type_arrows|itp_merchandise, itcf_carry_quiver_back_right, 410,weight(3.5)|abundance(30)|weapon_length(95)|thrust_damage(3,pierce)|max_ammo(30),imodbits_missile,
  [(ti_on_missile_dive, [(call_script, "script_on_missile_water_hit"), ])]],
 ["barbed_arrows","Barbed Arrows", [("barbed_arrow",0),("flying_missile",ixmesh_flying_ammo),("quiver_d", ixmesh_carry)], itp_type_arrows|itp_merchandise, itcf_carry_quiver_back_right, 124,weight(3)|abundance(70)|weapon_length(95)|thrust_damage(2,pierce)|max_ammo(30),imodbits_missile,
  [(ti_on_missile_dive, [(call_script, "script_on_missile_water_hit"), ])]],
 ["bodkin_arrows","Bodkin Arrows", [("piercing_arrow",0),("flying_missile",ixmesh_flying_ammo),("quiver_c", ixmesh_carry)], itp_type_arrows|itp_merchandise, itcf_carry_quiver_back_right, 350,weight(3)|abundance(50)|weapon_length(91)|thrust_damage(3,pierce)|max_ammo(28),imodbits_missile,
  [(ti_on_missile_dive, [(call_script, "script_on_missile_water_hit"), ])]],
 ["bolts","Bolts", [("bolt",0),("flying_missile",ixmesh_flying_ammo),("bolt_bag", ixmesh_carry),("bolt_bag_b", ixmesh_carry|imodbit_large_bag)], itp_type_bolts|itp_merchandise|itp_default_ammo|itp_can_penetrate_shield, itcf_carry_quiver_right_vertical, 64,weight(2.25)|abundance(90)|weapon_length(63)|thrust_damage(1,pierce)|max_ammo(29),imodbits_missile,
  [(ti_on_missile_dive, [(call_script, "script_on_missile_water_hit"), ])]],
 ["steel_bolts","Steel Bolts", [("bolt",0),("flying_missile",ixmesh_flying_ammo),("bolt_bag_c", ixmesh_carry)], itp_type_bolts|itp_merchandise|itp_can_penetrate_shield, itcf_carry_quiver_right_vertical, 210,weight(2.5)|abundance(20)|weapon_length(63)|thrust_damage(2,pierce)|max_ammo(29),imodbits_missile,
  [(ti_on_missile_dive, [(call_script, "script_on_missile_water_hit"), ])]],
 ["cartridges","Cartridges", [("cartridge_a",0)], itp_type_bullets|itp_merchandise|itp_can_penetrate_shield|itp_default_ammo, 0, 41,weight(2.25)|abundance(90)|weapon_length(3)|thrust_damage(1,pierce)|max_ammo(50),imodbits_missile,
  [(ti_on_missile_dive, [(call_script, "script_on_missile_water_hit"), ])]],
module_scripts
Code:
    # script_on_missile_water_hit
  # pos1 = missile_position_on_water
  # input:
  ("on_missile_water_hit",
    [ 
	(particle_system_burst, "psys_water_hit_a", pos0, 8),
	(position_move_z, pos0, 5, 1),
	(particle_system_burst, "psys_water_hit_b", pos0, 4),
  ]),
module_particle_systems
Code:
##### WATER HIT ######
	("water_hit_a", psf_billboard_3d | psf_randomize_size | psf_randomize_rotation | psf_global_emit_dir, "prtcl_splash_b",
	 80, 1.5, 4, 0.8, 0, 0, #num_particles, life, damping, gravity_strength, turbulance_size, turbulance_strength
	 (0.0, 1), (1, 0),     #alpha keys
	 (0.0, 0.95), (1, 0.95),          #red keys
	 (0.0, 0.90), (1, 0.90),           #green keys
	 (0.0, 0.70), (1, 0.70),          #blue keys
	 (0, 0.3), (1, 2),  #scale keys
	 (0, 0, 0),         #emit box size
	 (0, 0, 6),               #emit velocity
	  0,                      #emit dir randomness
	  100,                     #rotation speed
	  0.2                       #rotation damping
	),
		
	("water_hit_b",psf_randomize_size | psf_randomize_rotation | psf_turn_to_velocity|psf_global_emit_dir, "prtcl_splash_b",
	 4, 3, 0, 0, 0, 0, #num_particles, life, damping, gravity_strength, turbulance_size, turbulance_strength
	 (0.0, 1), (1, 0),     #alpha keys
	 (0.0, 0.95), (1, 0.95),          #red keys
	 (0.0, 0.90), (1, 0.90),           #green keys
	 (0.0, 0.70), (1, 0.70),          #blue keys
	 (0, 1), (1, 5),  #scale keys
	 (0.1, 0.1, 0),         #emit box size
	 (0, 0, -0.01),               #emit velocity
	  0,                      #emit dir randomness
	  25,                     #rotation speed
	  0.15                       #rotation damping
	),
 
Back
Top Bottom