Explosive Barrel

Users who are viewing this thread

bjorne.

Sergeant Knight
Well. Imade a few play-arounds in the module system and I came up with a very fun idea. How about making a explosive barrel that when you shoot at it. It explodes. Like on the picture in the spoiler below
stupididea.jpg
The problem is that I don't know how to get the damage to the area around, and I don't know how to get the people around the effect to fly away.. Right now. This is all I got...

Code:
####################################
########Grenade START###############
####################################

    ("grenade_smoke", psf_billboard_3d|psf_randomize_size,  "prt_mesh_dust_1",
     500, 13, 15, 7.05, 10.0, 0.2,     #num_particles, life, damping, gravity_strength, turbulance_size, turbulance_strength
     (0.1, 0.5), (1, 0),        #alpha keys
     (0.1, 0.8), (1, 0.8),      #red keys
     (0.1, 0.7),(1, 0.7),       #green keys
     (0.1, 0.6), (1, 0.7),      #blue keys
     (0.0, 4.5),   (1, 1),    #scale keys
     (0.2, 0.2, 0.5),           #emit box size
     (0, 0, 6.05),               #emit velocity
     2,                         #emit dir randomness
     60,                        #rotation speed
     0.1,                       #rotation damping
    ),

    ("grenade_flying_particle1", psf_randomize_rotation,  "prt_gourd_piece_1",
     15, 1, 2, 0.9, 10, 2,     #num_particles, life, damping, gravity_strength, turbulance_size, turbulance_strength
     (0.1, 1), (1, 1),          #alpha keys
     (0.1, 0.6), (1, 0.6),      #red keys
     (0.1, 0.5),(1, 0.5),       #green keys
     (0.1, 0.4), (1, 0.4),      #blue keys
     (0.0, 1),   (1, 1),    #scale keys
     (1.2, 1.2, 1.5),           #emit box size
     (0, 0, 0),                 #emit velocity
     2.3,                       #emit dir randomness
     600,                       #rotation speed
     0,                       #rotation damping
    ),
    
    ("grenade_flying_particle2", psf_randomize_size | psf_randomize_rotation,  "prt_gourd_piece_2",
     50, 1, 2, 0.9, 10, 2,     #num_particles, life, damping, gravity_strength, turbulance_size, turbulance_strength
     (0.1, 1), (1, 1),          #alpha keys
     (0.1, 0.6), (1, 0.6),      #red keys
     (0.1, 0.5),(1, 0.5),       #green keys
     (0.1, 0.4), (1, 0.4),      #blue keys
     (0.0, 1),   (1, 1),    #scale keys
     (0.2, 0.2, 0.5),           #emit box size
     (0, 0, 0),                 #emit velocity
     2.3,                       #emit dir randomness
     600,                       #rotation speed
     0,                       #rotation damping
    ),

    ("grenade_flying_particle3", psf_randomize_size | psf_randomize_rotation,  "prt_gourd_piece_2",
     50, 1, 2, 0.9, 10, 2,     #num_particles, life, damping, gravity_strength, turbulance_size, turbulance_strength
     (0.1, 1), (1, 1),          #alpha keys
     (0.1, 0.6), (1, 0.6),      #red keys
     (0.1, 0.5),(1, 0.5),       #green keys
     (0.1, 0.4), (1, 0.4),      #blue keys
     (0.0, 1),   (1, 1),    #scale keys
     (0.2, 0.2, 0.5),           #emit box size
     (0, 0, 0),                 #emit velocity
     2.3,                       #emit dir randomness
     400,                       #rotation speed
     0,                       #rotation damping
    ),
    ("grenade_flying_particle4", psf_randomize_size | psf_randomize_rotation,  "prt_gourd_piece_2",
     50, 1, 2, 0.9, 10, 2,     #num_particles, life, damping, gravity_strength, turbulance_size, turbulance_strength
     (0.1, 1), (1, 1),          #alpha keys
     (0.1, 0.6), (1, 0.6),      #red keys
     (0.1, 0.5),(1, 0.5),       #green keys
     (0.1, 0.4), (1, 0.4),      #blue keys
     (0.0, 1),   (1, 1),    #scale keys
     (0.2, 0.2, 0.5),           #emit box size
     (0, 0, 0),                 #emit velocity
     2.3,                       #emit dir randomness
     700,                       #rotation speed
     0,                       #rotation damping
    ),

    ("grenade_flying_particle5", psf_randomize_size | psf_randomize_rotation,  "prt_gourd_piece_2",
     50, 1, 2, 0.9, 10, 2,     #num_particles, life, damping, gravity_strength, turbulance_size, turbulance_strength
     (0.1, 1), (1, 1),          #alpha keys
     (0.1, 0.6), (1, 0.6),      #red keys
     (0.1, 0.5),(1, 0.5),       #green keys
     (0.1, 0.4), (1, 0.4),      #blue keys
     (0.0, 1),   (1, 1),    #scale keys
     (0.2, 0.2, 0.5),           #emit box size
     (0, 0, 0),                 #emit velocity
     2.3,                       #emit dir randomness
     300,                       #rotation speed
     0,                       #rotation damping
    ),

    ("grenade_dust_poof", psf_billboard_3d |psf_randomize_size|psf_randomize_rotation,  "prt_mesh_mud_1",
     500, 5.65, 3, 1.5, 0, 0,        #num_particles, life, damping, gravity_strength, turbulance_size, turbulance_strength
     (0.0, 0.7), (0.7, 0.7),          #alpha keys
     (0.1, 0.7), (1, 0.7),      #red keys
     (0.1, 0.7), (1, 0.7),       #green keys
     (0.1, 0.7), (1, 0.7),      #blue keys
     (0.0, 0.015),   (5, 1.418),  #scale keys
     (0, 0.05, 0),               #emit box size
     (0, 2.0, 0.6),                #emit velocity
     0.9,                       #emit dir randomness
     0,                         #rotation speed
     0,                         #rotation damping
    ),

    ("grenade_smoke_big", psf_billboard_3d|psf_global_emit_dir|psf_always_emit|psf_randomize_size|psf_randomize_rotation, "prt_mesh_smoke_1",
     30, 12, 0.3, -1, 50.0, 10.0,     #num_particles, life, damping, gravity_strength, turbulance_size, turbulance_strength
     (0.5, 0.15), (1, 0),        #alpha keys
     (0.2, 0.4), (1, 0.2),      #red keys
     (0.2, 0.4),(1, 0.2),       #green keys
     (0.2, 0.4), (1, 0.2),      #blue keys
     (0, 1),   (1, 4),          #scale keys
     (0.5, 0.5, 1),                 #emit box size
     (0, 0, 15),                 #emit velocity
     1.0,                       #emit dir randomness
     300,                         #rotation speed
     4.1                        #rotation damping
    ), 

    ("grenade_fire", psf_billboard_3d|psf_global_emit_dir|psf_always_emit|psf_randomize_size|psf_randomize_rotation, "prt_mesh_fire_1",
     50, 1.0, 0, -2.2, 25.0, 10.0,     #num_particles, life, damping, gravity_strength, turbulance_size, turbulance_strength
     (0.2, 0.7), (1, 0),        #alpha keys
     (0.2, 1.0), (1, 0.9),      #red keys
     (0.2, 0.7),(1, 0.3),       #green keys
     (0.2, 0.2), (1, 0.0),      #blue keys
     (0, 0.2),   (1, 3),          #scale keys
     (1.2, 1.2, 0.2),           #emit box size
     (0, 0, 3.0),               #emit velocity
     0.8,                       #emit dir randomness
     450,                       #rotation speed
     2.3                        #rotation damping
    ),

    ("after_grenade_smoke", psf_billboard_3d|psf_randomize_size,  "prt_mesh_dust_1",
     700, 38, 15, -0.01, 10.0, 0.2,     #num_particles, life, damping, gravity_strength, turbulance_size, turbulance_strength
     (0.1, 0.5), (1, 0),        #alpha keys
     (0.1, 0.8), (1, 0.8),      #red keys
     (0.1, 0.7),(1, 0.7),       #green keys
     (0.1, 0.6), (1, 0.7),      #blue keys
     (0.0, 4.5),   (1, 5.5),    #scale keys
     (0.2, 0.2, 0.5),           #emit box size
     (0, 0, 6.05),               #emit velocity
     2,                         #emit dir randomness
     10,                        #rotation speed
     0.1,                       #rotation damping
    ),
Code:
  ("bomb_major",sokf_destructible|spr_hit_points(100),"ale_barrel","ale_barrel",
   [
     (ti_on_scene_prop_destroy,
      [
        (store_trigger_param_1, ":instance_no"),
        (val_add, "$g_last_destroyed_gourds", 1),
        (prop_instance_get_position, pos1, ":instance_no"),
        (copy_position, pos2, pos1),
        (position_set_z, pos2, -100000),
        (particle_system_burst, "psys_grenade_smoke", pos1, 2),
        (particle_system_burst, "psys_grenade_flying_particle1", pos1, 1),
        (particle_system_burst, "grenade_flying_particle2", pos1, 5),
        (particle_system_burst, "psys_grenade_firee", pos1, 2),
        (particle_system_burst, "grenade_flying_particle3", pos1, 1),
        (particle_system_burst, "grenade_flying_particle4", pos1, 5),
        (particle_system_burst, "psys_grenade_smoke_big", pos1, 2),
        (particle_system_burst, "grenade_flying_particle5", pos1, 1),
        (particle_system_burst, "psys_grenade_dust_poof", pos1, 5),
        (particle_system_burst, "psys_after_grenade_smoke", pos1, 5),
        (prop_instance_animate_to_position, ":instance_no", pos2, 1),
        (play_sound, "snd_pistol_shot"),
        ]),

   (ti_on_init_scene_prop,
    [
#        (store_time_of_day,reg(12)),
#        (neg|is_between,reg(12),5,20),
        (is_currently_night, 0),
        (set_position_delta,0,-35,48),
        (particle_system_add_new, "psys_torch_fire"),
        (particle_system_add_new, "psys_torch_smoke"),
        (particle_system_add_new, "psys_torch_fire_sparks"),
        (set_position_delta,0,-35,56),
        (particle_system_add_new, "psys_fire_glow_1"),
        (particle_system_emit, "psys_fire_glow_1",9000000),
        (play_sound, "snd_torch_loop", 0),
    ]),
     ]),

Code:
  ("bomb_minor",sokf_destructible|spr_hit_points(10),"amphora_slim","amphora_slim",
   [
     (ti_on_scene_prop_destroy,
      [
        (store_trigger_param_1, ":instance_no"),
        (val_add, "$g_last_destroyed_gourds", 1),
        (prop_instance_get_position, pos1, ":instance_no"),
        (copy_position, pos2, pos1),
        (position_set_z, pos2, -100000),
        (particle_system_burst, "psys_grenade_smoke", pos1, 2),
        (particle_system_burst, "psys_grenade_flying_particle1", pos1, 1),
        (particle_system_burst, "grenade_flying_particle2", pos1, 5),
        (particle_system_burst, "psys_grenade_fire", pos1, 2),
        (particle_system_burst, "grenade_flying_particle3", pos1, 1),
        (particle_system_burst, "psys_grenade_dust_poof", pos1, 5),
        (prop_instance_animate_to_position, ":instance_no", pos2, 1),
        (play_sound, "snd_pistol_shot"),
        ]),

   (ti_on_init_scene_prop,
    [
#        (store_time_of_day,reg(12)),
#        (neg|is_between,reg(12),5,20),
        (is_currently_night, 0),
        (set_position_delta,0,-35,48),
        (particle_system_add_new, "psys_torch_fire"),
        (particle_system_add_new, "psys_torch_smoke"),
        (particle_system_add_new, "psys_torch_fire_sparks"),
        (set_position_delta,0,-35,56),
        (particle_system_add_new, "psys_fire_glow_1"),
        (particle_system_emit, "psys_fire_glow_1",9000000),
        (play_sound, "snd_torch_loop", 0),
    ]),
     ]),


And as you might see. It is only the particle_system effect. Please someone help me to get the area damage and to get the people around it fly away effect...
 
Well, you can probably find how to do both from AoM.  They have rocks they launch into the air that follow a trajectory, and cause area damage when they hit the ground.  So the throwing people through the air code can be stolen from the projectile movement (if they do it manually, or maybe you just move them up and gravity will pull them down), and the blast radius stuff is there too.
 
okey. let's see if I get this right..

I should borrow the area damage from Age of Machinery?
And for the making people to be thrown up in the air of the blast I should do what?.. I don't have a clue of how I should  lift them up in the air.
 
I've never done it before myself, but in AoM they throw bolders in the air.  They have to do that some how.  Don't know if it's a scene prop or what, but the way it is thrown can give you an idea of how to throw people.  You can also do the math manually (but I wouldn't, there should be something built in for gravity) and just move their pos in an upward arc.
 
You can also do the math manually (but I wouldn't, there should be something built in for gravity) and just move their pos in an upward arc.

That seams easier.. how?... where?
 
it would have to be in the trigger that makes the barrel explode.  I won't do the math here, but you would then take the agent's pos and move it up (z) and away from the barrel them move the agent to match where you moved the pos.

Not an easy thing to do, I would look at some of the AoM code and get familiar with moving objects manually.
 
AREA DAMAGE

Code:
                            (try_for_agents,":agent"),
                               (agent_get_position,pos2,":agent"),
                               (get_distance_between_positions,":dist",pos1,pos2),
                               (lt,":dist",300),
                               (agent_set_hit_points,":agent",0,0),
                               (agent_deliver_damage_to_agent,":agent",":agent"),
                            (end_try),

Throw away

Code:
                            (scene_prop_get_instance,":instance", "spr_explosion", 0),
                            (position_copy_origin,pos2,pos1),
                            (prop_instance_set_position,":instance",pos2),
                            (position_move_z,pos2,1000),
                            (prop_instance_animate_to_position,":instance",pos2,175),
                            (assign,reg5,1000),

This is taken from the Curtain of Fire mod's Fire Staff...
And is this what does the area effect and the throw away effect?
 
hmm...  the area damage (though you left out where pos1 is defined) looks right.

the throwaway seems to be for scene props.  the animate to position would not work on agents.  I guess you would have to move it yourself, similar to what they do for the throw away, but you have to do it each step of the animation.  Damn, now you got me thinking physics and it's been a long time...

You would need an equation for an arc.  You would give it number increments (fractions of seconds, since you can read it off the game with a timer trigger), then use this number to define where their next position would be.  You equation would give these results:
t = time
d = move distance (can use the same for z and y, though you would have to set the direction away from the blast)

t=1, d=1
t=2, d=4
t=3, d=6
t=4, d=4
t=5, d=1

Hope you understand what I am pointing at.  Now you would need a equation that would yield the result d for each value of t.
looking up some parabolic math(http://www.mathwarehouse.com/quadratic/parabola/interactive-parabola.php), you would need something like this:
d = -1 *(t-3)(t-3)+1

so where t is 1, the out come is d = -0.1*(1-3)(1-3)+1, which is 0.6.  When t is 3, the outcome is d = -0.1*(3-3)(3-3)+1 is 1 (the apex), and when t is 6, the out come is d= -0.1*(6-3)(6-3)+1 is 0.1

this is just a basic one, and I woul probably multiply the outcomes by 100 for how much to move each second (or part of second).  If this math is too much for you, then I would stop here on this and just use a fall down animation.
 
I look into it....

well that was to damn complex for me to understand right now.. I will get my dad over here so he can help me.. :grin:
 
bjorne. said:
I look into it....

well that was to damn complex for me to understand right now.. I will get my dad over here so he can help me.. :grin:

I'm a dad, and I had to look it up.  Unless he's in a job that uses math a lot, he might have trouble too.  The equation is easy to work with, it's just creating the right one that is hard.  That web site allows you to adjust the parameters to get the kind of parabolic slope you want.  The sub in distance for y ( the outcome) and time for x (how long it's in flight).
 
Back
Top Bottom