The Shadow
Recruit
cdvader messaged me on another site a while ago, asking me to post this. Never got around to it, download link expired, so kudos to mr.master to actually sending me his mod's source code to extract it from.
It does autofire all right, it just lacks proper hitboxes, and ammunition consumption. (Feedback from WEe)
I took a look, and couldn't crack the nut, but then again, I'm not all that great. So for now, it's partially functional, if you can improve it, and make it fully functional, the community will love you.
For now, the code:
header_common.py
module_items.py
(Under the last line of imodbits)
(At the bottom)
module_mission_templates.py
(Code continued in next message. I hit the character limit.)
It does autofire all right, it just lacks proper hitboxes, and ammunition consumption. (Feedback from WEe)
I took a look, and couldn't crack the nut, but then again, I'm not all that great. So for now, it's partially functional, if you can improve it, and make it fully functional, the community will love you.
For now, the code:
header_common.py
Code:
#Vader begin
autofire_event_damage_enemy = 121
#Vader end
module_items.py
(Under the last line of imodbits)
Code:
#Vader begin
imodbits_smg = 0
#Vader end
(At the bottom)
Code:
#Vader begin
["smg_1", "SMG-1", [("crossbow_a", 0)], itp_type_crossbow|itp_primary|itp_two_handed, itcf_shoot_crossbow|itcf_carry_crossbow_back, 100, weight(1)|difficulty(0)|spd_rtng(50)|shoot_speed(999999)|thrust_damage(20, pierce)|max_ammo(30), imodbits_smg],
["smg_2", "SMG-2", [("crossbow_a", 0)], itp_type_crossbow|itp_primary|itp_two_handed, itcf_shoot_crossbow|itcf_carry_crossbow_back, 100, weight(1)|difficulty(0)|spd_rtng(50)|shoot_speed(999999)|thrust_damage(50, pierce)|max_ammo(30), imodbits_smg],
["smg_end", "smg_end", [("crossbow_a", 0)], itp_type_crossbow|itp_primary|itp_two_handed, itcf_shoot_crossbow|itcf_carry_crossbow_back, 100, weight(1)|difficulty(0)|spd_rtng(50)|shoot_speed(999999)|thrust_damage(1, pierce)|max_ammo(30), imodbits_smg],
["shotgun_1", "Shotgun", [("crossbow_a", 0)], itp_type_crossbow|itp_primary|itp_two_handed, itcf_shoot_crossbow|itcf_carry_crossbow_back, 100, weight(1)|difficulty(0)|spd_rtng(50)|shoot_speed(999999)|thrust_damage(20, pierce)|max_ammo(7), imodbits_smg],
["shotgun_2", "Shotgun", [("crossbow_a", 0)], itp_type_crossbow|itp_primary|itp_two_handed, itcf_shoot_crossbow|itcf_carry_crossbow_back, 100, weight(1)|difficulty(0)|spd_rtng(50)|shoot_speed(999999)|thrust_damage(50, pierce)|max_ammo(7), imodbits_smg],
["shotgun_end", "shotgun_end", [("crossbow_a", 0)], itp_type_crossbow|itp_primary|itp_two_handed, itcf_shoot_crossbow|itcf_carry_crossbow_back, 100, weight(1)|difficulty(0)|spd_rtng(50)|shoot_speed(999999)|thrust_damage(1, pierce)|max_ammo(7), imodbits_smg],
#Vader end
module_mission_templates.py
Code:
#Vader begin
### Notes ###
# I wanted to create near-perfect collision detection with props,
# but I couldn't test it because my damn dedicated server
# won't just display my server in the master list (ports forwarded etc).
# So, I couldn't debug! I've commented anything related to the prop
# collision detection out. You can de-comment it and test it, but
# I don't guarantee it will work.
# The rest of the code should work anyway.
# I've created two types of weapons. The SMG (automatic) weapon and
# the Shotgun type. As I said before, I couldn't test either one so
# it's up to you to do something with this code base I've given you.
# Anyway, I wish you good luck with your mod! It sounds awesome.
# Maybe you can finish what I left unfinished.
autofire_smg1 = (
0.025, 0.05, 0,
[
#Check if we have the buttons down.
(game_key_is_down, gk_attack),
#(game_key_is_down, key_f),
#Get the player and make sure it's agent exists.
(multiplayer_get_my_player, ":player"),
(player_get_agent_id, ":agent", ":player"),
(ge, ":agent", 0),
#Check if the player has the right weapons..
(call_script, "script_autofire_check_items_equipped", ":agent", "itm_suomikp", "itm_saloranta"),
(eq, reg0, 1),
#Make sure the player is able to fire.
(agent_is_alive, ":agent"),
(agent_get_attack_action, ":action", ":agent"),
(eq, ":action", 1), #Readying attack.
],
[
#Get the player and agent again.
(multiplayer_get_my_player, ":player"),
(player_get_agent_id, ":agent", ":player"),
(ge, ":agent", 0),
(agent_get_wielded_item, ":gun", ":agent", 0), #get currently wielded item
#The shoot position.
(agent_get_look_position, pos1, ":agent"),
(position_move_z, pos1, 220),
#Make the agents list for better performance & handling.
(assign, ":agent_list", -1),
(try_for_agents, reg1),
(val_add, ":agent_list", 1),
(try_end),
#Remove bullets.
(agent_get_slot, ":bullet_count", ":agent", slot_agent_suomikp_bullet_count),
(gt, ":bullet_count", 0), #Don't fire at all when the bullet count is less than or equal to 0.
(val_sub, ":bullet_count", 1),
(agent_set_ammo, ":agent", "itm_cartridges", ":bullet_count"),
(agent_set_slot, ":agent", slot_agent_suomikp_bullet_count, ":bullet_count"), #SINISTERIUS -- This must be here as well.
#Play sound.
(try_begin),
(item_get_slot, ":sound", ":gun", slot_item_sound), #define and assign a sound to this slot
(gt, ":sound", 0), #if a sound was assigned (0 is default)
(multiplayer_send_int_to_server,multiplayer_event_sound_at_player,":sound"),
(try_end),
#Fire the bullet.
(assign, ":end_cond", 75),
(try_for_range, reg1, 1, ":end_cond"),
(position_move_y, pos1, 40),
#Calculate rotation.
(store_random_in_range, ":rand_x", -10, 11),
(store_random_in_range, ":rand_z", -10, 11),
(position_move_x, pos1, ":rand_x"),
(position_move_z, pos1, ":rand_z"),
#Check if the bullet has hit the ground.
(try_begin),
(position_get_distance_to_ground_level, ":distance", pos1),
(le, ":distance", 10),
(particle_system_burst, "psys_gourd_smoke", pos1, 20),
#End the loops.
(assign, ":end_cond", 0),
(try_end),
#Check if the bullet has hit an agent.
(try_for_range, ":enemy_agent", 0, ":agent_list"),
(agent_is_active, ":enemy_agent"),
(agent_is_alive, ":enemy_agent"),
#Get the distance between the bullet and the possible enemy agent.
(agent_get_position, pos2, ":enemy_agent"),
(get_distance_between_positions, ":distance", pos1, pos2),
#Damage agent if distance is sufficient and end the loops.
(le, ":distance", 100), #75
(multiplayer_send_int_to_server, autofire_event_damage_enemy, ":enemy_agent"),
(particle_system_burst, "psys_gourd_smoke", pos1, 20),
#End the loops.
(assign, ":agent_list", 0),
(assign, ":end_cond", 0),
(try_end),
(try_end),
])
autofire_smg2 = (
0.025, 0.05, 0,
[
#Check if we have the buttons down.
(game_key_is_down, gk_attack),
#(game_key_is_down, key_f),
#Get the player and make sure it's agent exists.
(multiplayer_get_my_player, ":player"),
(player_get_agent_id, ":agent", ":player"),
(ge, ":agent", 0),
#Check if the player has the right weapons..
(call_script, "script_autofire_check_items_equipped", ":agent", "itm_saloranta", "itm_ppsh"),
(eq, reg0, 1),
#Make sure the player is able to fire.
(agent_is_alive, ":agent"),
(agent_get_attack_action, ":action", ":agent"),
(eq, ":action", 1), #Readying attack.
],
[
#Get the player and agent again.
(multiplayer_get_my_player, ":player"),
(player_get_agent_id, ":agent", ":player"),
(ge, ":agent", 0),
(agent_get_wielded_item, ":gun", ":agent", 0), #get currently wielded item
#The shoot position.
(agent_get_look_position, pos1, ":agent"),
(position_move_z, pos1, 220),
#Make the agents list for better performance & handling.
(assign, ":agent_list", -1),
(try_for_agents, reg1),
(val_add, ":agent_list", 1),
(try_end),
#Remove bullets.
(agent_get_slot, ":bullet_count", ":agent", slot_agent_saloranta_bullet_count),
(gt, ":bullet_count", 0), #Don't fire at all when the bullet count is less than or equal to 0.
(val_sub, ":bullet_count", 1),
(agent_set_ammo, ":agent", ":gun", ":bullet_count"),
(agent_set_slot, ":agent", slot_agent_saloranta_bullet_count, ":bullet_count"), #SINISTERIUS -- This must be here as well.
#Play sound.
(try_begin),
(item_get_slot, ":sound", ":gun", slot_item_sound), #define and assign a sound to this slot
(gt, ":sound", 0), #if a sound was assigned (0 is default)
(multiplayer_send_int_to_server,multiplayer_event_sound_at_player,":sound"),
(try_end),
#Fire the bullet.
(assign, ":end_cond", 75),
(try_for_range, reg1, 1, ":end_cond"),
(position_move_y, pos1, 40),
#Calculate rotation.
(store_random_in_range, ":rand_x", -10, 11),
(store_random_in_range, ":rand_z", -10, 11),
(position_move_x, pos1, ":rand_x"),
(position_move_z, pos1, ":rand_z"),
#Check if the bullet has hit the ground.
(try_begin),
(position_get_distance_to_ground_level, ":distance", pos1),
(le, ":distance", 10),
(particle_system_burst, "psys_gourd_smoke", pos1, 20),
#End the loops.
(assign, ":end_cond", 0),
(try_end),
#Check if the bullet has hit an agent.
(try_for_range, ":enemy_agent", 0, ":agent_list"),
(agent_is_active, ":enemy_agent"),
(agent_is_alive, ":enemy_agent"),
#Get the distance between the bullet and the possible enemy agent.
(agent_get_position, pos2, ":enemy_agent"),
(get_distance_between_positions, ":distance", pos1, pos2),
#Damage agent if distance is sufficient and end the loops.
(le, ":distance", 100), #75
(multiplayer_send_int_to_server, autofire_event_damage_enemy, ":enemy_agent"),
(particle_system_burst, "psys_gourd_smoke", pos1, 20),
#End the loops.
(assign, ":agent_list", 0),
(assign, ":end_cond", 0),
(try_end),
(try_end),
])
autofire_smg3 = (
0.025, 0.05, 0,
[
#Check if we have the buttons down.
(game_key_is_down, gk_attack),
#(game_key_is_down, key_f),
#Get the player and make sure it's agent exists.
(multiplayer_get_my_player, ":player"),
(player_get_agent_id, ":agent", ":player"),
(ge, ":agent", 0),
#Check if the player has the right weapons..
(call_script, "script_autofire_check_items_equipped", ":agent", "itm_ppsh", "itm_dp27"),
(eq, reg0, 1),
#Make sure the player is able to fire.
(agent_is_alive, ":agent"),
(agent_get_attack_action, ":action", ":agent"),
(eq, ":action", 1), #Readying attack.
],
[
#Get the player and agent again.
(multiplayer_get_my_player, ":player"),
(player_get_agent_id, ":agent", ":player"),
(ge, ":agent", 0),
(agent_get_wielded_item, ":gun", ":agent", 0), #get currently wielded item
#The shoot position.
(agent_get_look_position, pos1, ":agent"),
(position_move_z, pos1, 220),
#Make the agents list for better performance & handling.
(assign, ":agent_list", -1),
(try_for_agents, reg1),
(val_add, ":agent_list", 1),
(try_end),
#Remove bullets.
(agent_get_slot, ":bullet_count", ":agent", slot_agent_ppsh_bullet_count),
(gt, ":bullet_count", 0), #Don't fire at all when the bullet count is less than or equal to 0.
(val_sub, ":bullet_count", 1),
(agent_set_ammo, ":agent", ":gun", ":bullet_count"),
(agent_set_slot, ":agent", slot_agent_ppsh_bullet_count, ":bullet_count"), #SINISTERIUS -- This must be here as well.
#Play sound.
(try_begin),
(item_get_slot, ":sound", ":gun", slot_item_sound), #define and assign a sound to this slot
(gt, ":sound", 0), #if a sound was assigned (0 is default)
(multiplayer_send_int_to_server,multiplayer_event_sound_at_player,":sound"),
(try_end),
#Fire the bullet.
(assign, ":end_cond", 75),
(try_for_range, reg1, 1, ":end_cond"),
(position_move_y, pos1, 40),
#Calculate rotation.
(store_random_in_range, ":rand_x", -10, 11),
(store_random_in_range, ":rand_z", -10, 11),
(position_move_x, pos1, ":rand_x"),
(position_move_z, pos1, ":rand_z"),
#Check if the bullet has hit the ground.
(try_begin),
(position_get_distance_to_ground_level, ":distance", pos1),
(le, ":distance", 10),
(particle_system_burst, "psys_gourd_smoke", pos1, 20),
#End the loops.
(assign, ":end_cond", 0),
(try_end),
#Check if the bullet has hit an agent.
(try_for_range, ":enemy_agent", 0, ":agent_list"),
(agent_is_active, ":enemy_agent"),
(agent_is_alive, ":enemy_agent"),
#Get the distance between the bullet and the possible enemy agent.
(agent_get_position, pos2, ":enemy_agent"),
(get_distance_between_positions, ":distance", pos1, pos2),
#Damage agent if distance is sufficient and end the loops.
(le, ":distance", 100), #75
(multiplayer_send_int_to_server, autofire_event_damage_enemy, ":enemy_agent"),
(particle_system_burst, "psys_gourd_smoke", pos1, 20),
#End the loops.
(assign, ":agent_list", 0),
(assign, ":end_cond", 0),
(try_end),
(try_end),
])
autofire_smg4 = (
0.025, 0.05, 0,
[
#Check if we have the buttons down.
(game_key_is_down, gk_attack),
#(game_key_is_down, key_f),
#Get the player and make sure it's agent exists.
(multiplayer_get_my_player, ":player"),
(player_get_agent_id, ":agent", ":player"),
(ge, ":agent", 0),
#Check if the player has the right weapons..
(call_script, "script_autofire_check_items_equipped", ":agent", "itm_dp27", "itm_peltiheikki"),
(eq, reg0, 1),
#Make sure the player is able to fire.
(agent_is_alive, ":agent"),
(agent_get_attack_action, ":action", ":agent"),
(eq, ":action", 1), #Readying attack.
],
[
#Get the player and agent again.
(multiplayer_get_my_player, ":player"),
(player_get_agent_id, ":agent", ":player"),
(ge, ":agent", 0),
(agent_get_wielded_item, ":gun", ":agent", 0), #get currently wielded item
#The shoot position.
(agent_get_look_position, pos1, ":agent"),
(position_move_z, pos1, 220),
#Make the agents list for better performance & handling.
(assign, ":agent_list", -1),
(try_for_agents, reg1),
(val_add, ":agent_list", 1),
(try_end),
#Remove bullets.
(agent_get_slot, ":bullet_count", ":agent", slot_agent_dp27_bullet_count),
(gt, ":bullet_count", 0), #Don't fire at all when the bullet count is less than or equal to 0.
(val_sub, ":bullet_count", 1),
(agent_set_ammo, ":agent", ":gun", ":bullet_count"),
(agent_set_slot, ":agent", slot_agent_dp27_bullet_count, ":bullet_count"), #SINISTERIUS -- This must be here as well.
#Play sound.
(try_begin),
(item_get_slot, ":sound", ":gun", slot_item_sound), #define and assign a sound to this slot
(gt, ":sound", 0), #if a sound was assigned (0 is default)
(multiplayer_send_int_to_server,multiplayer_event_sound_at_player,":sound"),
(try_end),
#Fire the bullet.
(assign, ":end_cond", 75),
(try_for_range, reg1, 1, ":end_cond"),
(position_move_y, pos1, 40),
#Calculate rotation.
(store_random_in_range, ":rand_x", -10, 11),
(store_random_in_range, ":rand_z", -10, 11),
(position_move_x, pos1, ":rand_x"),
(position_move_z, pos1, ":rand_z"),
#Check if the bullet has hit the ground.
(try_begin),
(position_get_distance_to_ground_level, ":distance", pos1),
(le, ":distance", 10),
(particle_system_burst, "psys_gourd_smoke", pos1, 20),
#End the loops.
(assign, ":end_cond", 0),
(try_end),
#Check if the bullet has hit an agent.
(try_for_range, ":enemy_agent", 0, ":agent_list"),
(agent_is_active, ":enemy_agent"),
(agent_is_alive, ":enemy_agent"),
#Get the distance between the bullet and the possible enemy agent.
(agent_get_position, pos2, ":enemy_agent"),
(get_distance_between_positions, ":distance", pos1, pos2),
#Damage agent if distance is sufficient and end the loops.
(le, ":distance", 100), #75
(multiplayer_send_int_to_server, autofire_event_damage_enemy, ":enemy_agent"),
(particle_system_burst, "psys_gourd_smoke", pos1, 20),
#End the loops.
(assign, ":agent_list", 0),
(assign, ":end_cond", 0),
(try_end),
(try_end),
])
autofire_smg5 = (
0.025, 0.05, 0,
[
#Check if we have the buttons down.
(game_key_is_down, gk_attack),
#(game_key_is_down, key_f),
#Get the player and make sure it's agent exists.
(multiplayer_get_my_player, ":player"),
(player_get_agent_id, ":agent", ":player"),
(ge, ":agent", 0),
#Check if the player has the right weapons..
(call_script, "script_autofire_check_items_equipped", ":agent", "itm_peltiheikki", "itm_ppsh_42"),
(eq, reg0, 1),
#Make sure the player is able to fire.
(agent_is_alive, ":agent"),
(agent_get_attack_action, ":action", ":agent"),
(eq, ":action", 1), #Readying attack.
],
[
#Get the player and agent again.
(multiplayer_get_my_player, ":player"),
(player_get_agent_id, ":agent", ":player"),
(ge, ":agent", 0),
(agent_get_wielded_item, ":gun", ":agent", 0), #get currently wielded item
#The shoot position.
(agent_get_look_position, pos1, ":agent"),
(position_move_z, pos1, 220),
#Make the agents list for better performance & handling.
(assign, ":agent_list", -1),
(try_for_agents, reg1),
(val_add, ":agent_list", 1),
(try_end),
#Remove bullets.
(agent_get_slot, ":bullet_count", ":agent", slot_agent_ppsh_42_bullet_count),
(gt, ":bullet_count", 0), #Don't fire at all when the bullet count is less than or equal to 0.
(val_sub, ":bullet_count", 1),
(agent_set_ammo, ":agent", ":gun", ":bullet_count"),
(agent_set_slot, ":agent", slot_agent_ppsh_42_bullet_count, ":bullet_count"), #SINISTERIUS -- This must be here as well.
#Play sound.
(try_begin),
(item_get_slot, ":sound", ":gun", slot_item_sound), #define and assign a sound to this slot
(gt, ":sound", 0), #if a sound was assigned (0 is default)
(multiplayer_send_int_to_server,multiplayer_event_sound_at_player,":sound"),
(try_end),
#Fire the bullet.
(assign, ":end_cond", 75),
(try_for_range, reg1, 1, ":end_cond"),
(position_move_y, pos1, 40),
#Calculate rotation.
(store_random_in_range, ":rand_x", -10, 11),
(store_random_in_range, ":rand_z", -10, 11),
(position_move_x, pos1, ":rand_x"),
(position_move_z, pos1, ":rand_z"),
#Check if the bullet has hit the ground.
(try_begin),
(position_get_distance_to_ground_level, ":distance", pos1),
(le, ":distance", 10),
(particle_system_burst, "psys_gourd_smoke", pos1, 20),
#End the loops.
(assign, ":end_cond", 0),
(try_end),
#Check if the bullet has hit an agent.
(try_for_range, ":enemy_agent", 0, ":agent_list"),
(agent_is_active, ":enemy_agent"),
(agent_is_alive, ":enemy_agent"),
#Get the distance between the bullet and the possible enemy agent.
(agent_get_position, pos2, ":enemy_agent"),
(get_distance_between_positions, ":distance", pos1, pos2),
#Damage agent if distance is sufficient and end the loops.
(le, ":distance", 100), #75
(multiplayer_send_int_to_server, autofire_event_damage_enemy, ":enemy_agent"),
(particle_system_burst, "psys_gourd_smoke", pos1, 20),
#End the loops.
(assign, ":agent_list", 0),
(assign, ":end_cond", 0),
(try_end),
(try_end),
])
(Code continued in next message. I hit the character limit.)