mp_cannon_physics2 = (
0.8, 0, 0, [],
[
(scene_prop_get_num_instances, ":num_instances", "spr_mp_cannonball_projectile"),
(try_for_range, ":cur_instance", 0, ":num_instances"),
(scene_prop_get_instance, ":instance", "spr_mp_cannonball_projectile", ":cur_instance"),
(scene_prop_get_slot, ":decay", ":instance", mp_cannonball_decay),
(scene_prop_get_slot, ":speed", ":instance", mp_cannonball_speed),
(scene_prop_get_slot, ":cannon", ":instance", mp_cannonball_cannon),
(prop_instance_get_scene_prop_kind, ":cannon_type", ":cannon"),
(try_begin),
(eq, ":cannon_type", "spr_sp_cannon_3lb"),
(val_sub, ":decay", 16),#8
(val_sub, ":speed", 2),#9
(else_try),
(eq, ":cannon_type", "spr_sp_cannon_bote"),
(val_sub, ":decay", 16),
(val_sub, ":speed", 2),
(else_try),
(eq, ":cannon_type", "spr_mp_cannon_12lb"),
(val_sub, ":decay", 6),
(val_sub, ":speed", 7),
(try_end),
(try_begin),
(lt, ":speed", 10),#10
(assign, ":speed", 0),
(try_end),
(scene_prop_set_slot, ":instance", mp_cannonball_decay, ":decay"),
(scene_prop_set_slot, ":instance", mp_cannonball_speed, ":speed"),
(try_end),
])
mp_cannon_projectile2 = (
0.025, 0, 0, [],
[
#Handle cannonball props.
(scene_prop_get_num_instances, ":num_instances", "spr_mp_cannonball_projectile"),
(try_for_range, ":cur_instance", 0, ":num_instances"),
(scene_prop_get_instance, ":instance", "spr_mp_cannonball_projectile", ":cur_instance"),
(scene_prop_slot_eq, ":instance", mp_projectile_active, 1),
(assign, ":collision", 0),
(scene_prop_get_slot, ":cannonball_cannon", ":instance", mp_cannonball_cannon),
(prop_instance_get_scene_prop_kind, ":cannon_type", ":cannonball_cannon"),
#Remove previous animations.
(try_begin),
(prop_instance_is_animating, ":is_animating", ":instance"),
(eq, ":is_animating", 1),
(prop_instance_stop_animating, ":instance"),
(try_end),
#Move.
(prop_instance_get_position, pos1, ":instance"),
(scene_prop_get_slot, ":decay", ":instance", mp_cannonball_decay),
(scene_prop_get_slot, ":speed", ":instance", mp_cannonball_speed),
(position_move_y, pos1, ":speed"), #Travels (1/0.025)*125=4000 in one second.
(position_move_z, pos1, ":decay"), #Decay
(prop_instance_animate_to_position, ":instance", pos1, 3),
#Agent collision.
(scene_prop_get_slot, ":shooter", ":instance", mp_projectile_shooter),
(try_for_agents, ":agent"),
(agent_is_alive, ":agent"),
(agent_get_position, pos2, ":agent"),
(position_move_z, pos2, 60),
(get_distance_between_positions, ":distance", pos1, pos2),
(try_begin),
(eq, ":cannon_type", "spr_sp_cannon_3lb"),
(assign, ":min_dist", 160),#80
(else_try),
(eq, ":cannon_type", "spr_sp_cannon_bote"),
(assign, ":min_dist", 120),
(else_try),
(assign, ":min_dist", 120),
(try_end),
(try_begin),
(neg|agent_is_human, ":agent"), #Horse.
(val_add, ":min_dist", 75),
(try_end),
(le, ":distance", ":min_dist"),
#Calculate & deliver damage.
(try_begin),
(agent_is_active, ":shooter"),
(agent_deliver_damage_to_agent, ":shooter", ":agent", 250),#150
(else_try),
(agent_deliver_damage_to_agent, ":agent", ":agent", 250),#150
(try_end),
(try_end),
#Ground collision.
(try_begin),
(position_get_distance_to_ground_level, ":distance", pos1),
(le, ":distance", 15),#15
(assign, ":collision", 1),
(position_set_z_to_ground_level, pos1),
(try_begin),
(play_sound_at_position, "snd_explosion",0),
(particle_system_burst,"psys_explosion_flash",pos1,500),
(particle_system_burst,"psys_war_smoke_tall",pos1,150),
(particle_system_burst,"psys_explosion_smoke",pos1,100),
(particle_system_burst,"psys_explosion_smoke2",pos1,100),
(try_for_agents, ":agent"),
(agent_is_alive, ":agent"),
(agent_get_position, pos2, ":agent"),
(get_distance_between_positions, ":distance", pos1, pos2),
(try_begin),
(eq, ":cannon_type", "spr_sp_cannon_3lb"),
(assign, ":dist_max", 185),#175
(assign, ":damage_min", 175),#125
(assign, ":damage_max", 250),#175
(else_try),
(eq, ":cannon_type", "spr_sp_cannon_bote"),
(assign, ":dist_max", 160),
(assign, ":damage_min", 125),
(assign, ":damage_max", 210),
(else_try),
(eq, ":cannon_type", "spr_mp_cannon_12lb"),
(assign, ":dist_max", 245),
(assign, ":damage_min", 125),
(assign, ":damage_max", 545),#245
(try_end),
(le, ":distance", ":dist_max"),
#Play sound & particles.
(position_move_z, pos2, 50),
(particle_system_burst, "psys_game_blood", pos2, 100), #This plays at the agents chest.
(play_sound_at_position, "snd_explosion",0),
(particle_system_burst,"psys_explosion_flash",pos1,100),
(particle_system_burst,"psys_war_smoke_tall",pos1,150),
(particle_system_burst,"psys_explosion_smoke",pos1,100),
(particle_system_burst,"psys_explosion_smoke2",pos1,100),
#Calculate & deliver damage.
(store_random_in_range, ":rand", ":damage_min", ":damage_max"), #Base damage
(val_sub, ":rand", ":distance"), #The farther away the target is, the less damage it receives
(try_begin),
(agent_is_active, ":shooter"),
(agent_deliver_damage_to_agent, ":shooter", ":agent", ":rand"),
(else_try),
(agent_deliver_damage_to_agent, ":agent", ":agent", ":rand"),
(try_end),
(try_end),
(try_end),
(try_end),
#Finalize.
(try_begin),
(eq, ":collision", 1),
(scene_prop_set_slot, ":instance", mp_projectile_active, 0),
(scene_prop_set_slot, ":instance", mp_projectile_shooter, -1),
(try_end),
(try_end),
])
mp_cannon_cart = (
0.06, 0, 0, [],
[
(try_for_agents, ":horse"),
(agent_get_slot, ":horse_cart_instance", ":horse", mp_cannon_horse_cart),
(agent_get_position, pos1, ":horse"),
(try_begin),
(gt, ":horse_cart_instance", 0),
(position_set_z_to_ground_level, pos1),
(prop_instance_animate_to_position, ":horse_cart_instance", pos1, 40),
(try_end),
(try_end),
])
mp_cannon_cart_unpack = (
ti_on_agent_dismount, 0, 0, [],
[
(store_trigger_param_2, ":horse"),
# (multiplayer_is_server),
(agent_get_slot, ":cart", ":horse", mp_cannon_horse_cart),
(agent_get_position, pos1, ":horse"),
(agent_get_item_id, ":horse_type", ":horse"),
(copy_position, pos2, pos1),
(try_begin),
(gt, ":cart", 0),
(scene_prop_get_slot, ":cannon", ":cart", mp_cannon_horse_cart_cannon),
(position_rotate_z, pos1, 180),
(position_move_y, pos1, 260),
(try_begin),
(gt, ":cannon", 0),
(prop_instance_animate_to_position, ":cannon", pos1, 5),
(else_try),
(set_spawn_position, pos1),
(try_begin),
(eq, ":horse_type", "itm_artillery_horse_3lb"),
(assign, ":cannon_prop", "spr_sp_cannon_3lb"),
(spawn_scene_prop, ":cannon_prop"),
(assign, ":cannon", reg0),
(try_end),
(try_end),
(position_set_z, pos2, -1200),
(prop_instance_animate_to_position, ":cart", pos2, 5),
(agent_set_slot, ":horse", mp_cannon_horse_cart, -1),
(scene_prop_set_slot, ":cart", mp_cannon_horse_cart_cannon, -1),
(scene_prop_set_slot, ":cart", mp_cannon_horse_cart_active, 0),
(prop_instance_enable_physics, ":cannon", 1),
(try_end),
])
mp_cannon_rotate2 = (
0, 0, 0.05,
[],
[
(try_begin),
(key_is_down, key_up),
(scene_prop_get_instance,":ship_instance", "spr_sp_cannon_3lb", 0),
(prop_instance_get_position,pos1,":ship_instance"),
(position_rotate_x,pos1,2),
(prop_instance_animate_to_position,":ship_instance",pos1,25),
(else_try),
(key_is_down, key_down),
(scene_prop_get_instance,":ship_instance", "spr_sp_cannon_3lb", 0),
(prop_instance_get_position,pos1,":ship_instance"),
(position_rotate_x,pos1,-2),
(prop_instance_animate_to_position,":ship_instance",pos1,25),
(else_try),
(key_is_down, key_right),
(scene_prop_get_instance,":ship_instance", "spr_sp_cannon_3lb", 0),
(prop_instance_get_position,pos1,":ship_instance"),
(position_rotate_z,pos1,-2),
(prop_instance_animate_to_position,":ship_instance",pos1,25),
(else_try),
(key_is_down, key_left),
(scene_prop_get_instance,":ship_instance", "spr_sp_cannon_3lb", 0),
(prop_instance_get_position,pos1,":ship_instance"),
(position_rotate_z,pos1,2),
(prop_instance_animate_to_position,":ship_instance",pos1,25),
(try_end),
])
mp_cannon_agent_spawn = (
ti_on_agent_spawn, 0, 0,
[],
[
(store_trigger_param_1, ":horse"), #Get the horse that just spawned
(agent_get_item_id, ":horse_type", ":horse"), #Get the type of horse
(agent_get_position, pos1, ":horse"), #Get the horses position
(assign, ":cart_kind", -1), #So if the horse isn't any of these type, we won't do anything
(try_begin),
(eq, ":horse_type", "itm_artillery_horse_3lb"),
(assign, ":cart_kind", "spr_sp_cannon_a_cart"),
(try_end),
(assign, ":cart_instance", -1), #So if there aren't any existing unused carts, we'll spawn a new one
(try_begin),
(gt, ":cart_kind", -1),
(scene_prop_get_num_instances, ":num_instances", ":cart_kind"),
(try_for_range, ":cur_instance", 0, ":num_instances"),
(scene_prop_get_instance, ":cart_instance", ":cart_kind", ":cur_instance"),
(neg|scene_prop_slot_eq, ":cart_instance", mp_cannon_horse_cart_active, 1),
(assign, ":num_instances", 0), #End loop.
(prop_instance_animate_to_position, ":cart_instance", pos1, 5),
(try_end),
(try_begin),
(eq, ":cart_instance", -1),
(set_spawn_position, pos1),
(spawn_scene_prop, ":cart_kind"),
(assign, ":cart_instance", reg0),
(try_end),
(try_end),
(agent_set_slot, ":horse", mp_cannon_horse_cart, ":cart_instance"), #Tell the horse what cart is following it
])
mp_cannon_triggers2 = [
mp_cannon_physics2,
mp_cannon_projectile2,
mp_cannon_cart,
mp_cannon_cart_unpack,
mp_cannon_rotate2,
mp_cannon_agent_spawn,