Unifies wield-shotgun and wield-rifle into wield-firearm. (#6591)

Title says it all.

This needed some changes to offhand (which is now a subtype of weapon, not /weapon/gun), but otherwise it seems to work well in testing.
This commit is contained in:
Matt Atlas
2019-07-21 21:53:27 +02:00
committed by Erki
parent e0240180be
commit d9fb393845
13 changed files with 108 additions and 268 deletions

View File

@@ -391,6 +391,7 @@
needspin = TRUE
recoil = 6
is_wieldable = TRUE
release_speed = 5
var/list/belt = new/list()
@@ -399,27 +400,6 @@
accuracy_wielded = -1
fire_delay_wielded = 1
//action button for wielding
action_button_name = "Wield rifle"
/obj/item/weapon/gun/launcher/crossbow/vaurca/can_wield()
return 1
/obj/item/weapon/gun/launcher/crossbow/vaurca/ui_action_click()
if(src in usr)
toggle_wield(usr)
/obj/item/weapon/gun/launcher/crossbow/vaurca/verb/wield_rifle()
set name = "Wield rifle"
set category = "Object"
set src in usr
toggle_wield(usr)
if(istype(usr,/mob/living/carbon/human))
var/mob/living/carbon/human/H = usr
H.update_inv_l_hand()
H.update_inv_r_hand()
/obj/item/weapon/gun/launcher/crossbow/vaurca/update_icon()
if(wielded)
item_state = "gaussrifle-wielded"

View File

@@ -28,8 +28,6 @@
dispersion = list(0)
reliability = 100
action_button_name = "Wield kinetic accelerator"
var/obj/item/projectile/projectile_type = /obj/item/projectile/kinetic
needspin = FALSE
@@ -44,6 +42,8 @@
wielded = 0
needspin = TRUE
is_wieldable = TRUE
var/require_wield = FALSE
var/build_name = ""
@@ -71,17 +71,6 @@
var/can_disassemble_cell = TRUE
var/can_disassemble_barrel = TRUE
/obj/item/weapon/gun/custom_ka/verb/wield_accelerator()
set name = "Wield"
set category = "Object"
set src in usr
toggle_wield(usr)
/obj/item/weapon/gun/custom_ka/ui_action_click()
if(src in usr)
toggle_wield(usr)
/obj/item/weapon/gun/custom_ka/can_wield()
return 1

View File

@@ -83,6 +83,7 @@
var/accuracy_wielded = 0
var/wielded = 0
var/needspin = TRUE
var/is_wieldable = FALSE
//aiming system stuff
@@ -107,6 +108,8 @@
if(pin && needspin)
pin = new pin(src)
update_wield_verb()
queue_icon_update()
/obj/item/weapon/gun/update_icon()
@@ -173,6 +176,30 @@
return 1
/obj/item/weapon/gun/verb/wield_gun()
set name = "Wield Firearm"
set category = "Object"
set src in usr
if(is_wieldable)
toggle_wield(usr)
update_held_icon()
else
to_chat(usr, "<span class='warning'>You can't wield \the [src]!</span>")
/obj/item/weapon/gun/ui_action_click()
if(src in usr)
wield_gun()
/obj/item/weapon/gun/proc/update_wield_verb()
if(is_wieldable) //If the gun is marked as wieldable, make the action button appear and add the verb.
action_button_name = "Wield Firearm"
verbs += /obj/item/weapon/gun/verb/wield_gun
else
action_button_name = ""
verbs -= /obj/item/weapon/gun/verb/wield_gun
/obj/item/weapon/gun/emp_act(severity)
for(var/obj/O in contents)
O.emp_act(severity)
@@ -498,7 +525,7 @@
/obj/item/weapon/gun/zoom()
..()
if(!zoom)
if(can_wield() && wielded)
if(is_wieldable && wielded)
if(accuracy_wielded)
accuracy = accuracy_wielded
else
@@ -544,7 +571,7 @@
return 0
/obj/item/weapon/gun/proc/toggle_wield(mob/user as mob)
if(!can_wield())
if(!is_wieldable)
return
if(!istype(user.get_active_hand(), /obj/item/weapon/gun))
to_chat(user, "<span class='warning'>You need to be holding the [name] in your active hand</span>")
@@ -562,7 +589,7 @@
unwield()
to_chat(user, "<span class='notice'>You are no-longer stabilizing the [name] with both hands.</span>")
var/obj/item/weapon/gun/offhand/O = user.get_inactive_hand()
var/obj/item/weapon/offhand/O = user.get_inactive_hand()
if(O && istype(O))
O.unwield()
else
@@ -579,7 +606,7 @@
wield()
to_chat(user, "<span class='notice'>You stabilize the [initial(name)] with both hands.</span>")
var/obj/item/weapon/gun/offhand/O = new(user)
var/obj/item/weapon/offhand/O = new(user)
O.name = "[initial(name)] - offhand"
O.desc = "Your second grip on the [initial(name)]."
user.put_in_inactive_hand(O)
@@ -612,7 +639,7 @@
/obj/item/weapon/gun/mob_can_equip(M as mob, slot)
//Cannot equip wielded items.
if(can_wield())
if(is_wieldable)
if(wielded)
to_chat(M, "<span class='warning'>Lower the [initial(name)] first!</span>")
return 0
@@ -623,55 +650,54 @@
..()
//Unwields the item when dropped, deletes the offhand
if(can_wield())
if(is_wieldable)
if(user)
var/obj/item/weapon/gun/O = user.get_inactive_hand()
var/obj/item/weapon/offhand/O = user.get_inactive_hand()
if(istype(O))
O.unwield()
return unwield()
/obj/item/weapon/gun/pickup(mob/user)
if(can_wield())
if(is_wieldable)
unwield()
///////////OFFHAND///////////////
/obj/item/weapon/gun/offhand
/obj/item/weapon/offhand
w_class = 5.0
icon = 'icons/obj/weapons.dmi'
icon_state = "offhand"
item_state = "nothing"
name = "offhand"
needspin = FALSE
unwield()
if (ismob(loc))
var/mob/the_mob = loc
the_mob.drop_from_inventory(src)
else
qdel(src)
/obj/item/weapon/offhand/proc/unwield()
if (ismob(loc))
var/mob/the_mob = loc
the_mob.drop_from_inventory(src)
else
qdel(src)
wield()
if (ismob(loc))
var/mob/the_mob = loc
the_mob.drop_from_inventory(src)
else
qdel(src)
/obj/item/weapon/offhand/proc/wield()
if (ismob(loc))
var/mob/the_mob = loc
the_mob.drop_from_inventory(src)
else
qdel(src)
dropped(mob/living/user as mob)
if(user)
var/obj/item/weapon/gun/O = user.get_inactive_hand()
if(istype(O))
to_chat(user, "<span class='notice'>You are no-longer stabilizing the [name] with both hands.</span>")
O.unwield()
unwield()
/obj/item/weapon/offhand/dropped(mob/living/user as mob)
if(user)
var/obj/item/weapon/gun/O = user.get_inactive_hand()
if(istype(O))
to_chat(user, "<span class='notice'>You are no-longer stabilizing the [name] with both hands.</span>")
O.unwield()
unwield()
if (!QDELETED(src))
qdel(src)
if (!QDELETED(src))
qdel(src)
mob_can_equip(M as mob, slot)
/obj/item/weapon/offhand/mob_can_equip(M as mob, slot)
return 0
obj/item/weapon/gun/Destroy()
/obj/item/weapon/gun/Destroy()
if (istype(pin))
QDEL_NULL(pin)
if(bayonet)

View File

@@ -50,7 +50,7 @@
fire_delay_wielded = 10
accuracy_wielded = 0
action_button_name = "Wield rifle"
is_wieldable = TRUE
/obj/item/weapon/gun/energy/blaster/rifle/update_icon()
..()
@@ -60,13 +60,6 @@
item_state = initial(item_state)
update_held_icon()
/obj/item/weapon/gun/energy/blaster/rifle/can_wield()
return 1
/obj/item/weapon/gun/energy/blaster/rifle/ui_action_click()
if(src in usr)
toggle_wield(usr)
/obj/item/weapon/gun/energy/blaster/rifle/verb/scope()
set category = "Object"
set name = "Use Scope"

View File

@@ -131,19 +131,11 @@ obj/item/weapon/gun/energy/retro
turret_sprite_set = "sniper"
turret_is_lethal = 1
is_wieldable = TRUE
fire_delay_wielded = 35
accuracy_wielded = 0
//action button for wielding
action_button_name = "Wield rifle"
/obj/item/weapon/gun/energy/sniperrifle/can_wield()
return 1
/obj/item/weapon/gun/energy/sniperrifle/ui_action_click()
if(src in usr)
toggle_wield(usr)
/obj/item/weapon/gun/energy/sniperrifle/verb/scope()
set category = "Object"
set name = "Use Scope"

View File

@@ -63,6 +63,8 @@
criticality = initial(criticality)
fire_sound = initial(fire_sound)
force = initial(force)
is_wieldable = initial(is_wieldable)
action_button_name = initial(action_button_name)
/obj/item/weapon/gun/energy/laser/prototype/proc/updatetype(var/mob/user)
reset_vars()
@@ -70,21 +72,7 @@
disassemble(user)
return
switch(origin_chassis)
if(CHASSIS_SMALL)
gun_type = CHASSIS_SMALL
slot_flags = SLOT_BELT | SLOT_HOLSTER
item_state = "retro"
if(CHASSIS_MEDIUM)
gun_type = CHASSIS_MEDIUM
slot_flags = SLOT_BELT | SLOT_BACK
item_state = "energystun"
action_button_name = "Wield rifle"
if(CHASSIS_LARGE)
gun_type = CHASSIS_LARGE
slot_flags = SLOT_BACK
item_state = "heavyprotogun"
action_button_name = "Wield rifle"
update_chassis()
if(capacitor.reliability - capacitor.condition <= 0)
if(prob(66))
@@ -125,6 +113,24 @@
w_class = gun_type
reliability = max(reliability, 1)
/obj/item/weapon/gun/energy/laser/prototype/proc/update_chassis()
switch(origin_chassis)
if(CHASSIS_SMALL)
gun_type = CHASSIS_SMALL
slot_flags = SLOT_BELT | SLOT_HOLSTER
item_state = "retro"
if(CHASSIS_MEDIUM)
gun_type = CHASSIS_MEDIUM
slot_flags = SLOT_BELT | SLOT_BACK
item_state = "energystun"
is_wieldable = TRUE
if(CHASSIS_LARGE)
gun_type = CHASSIS_LARGE
slot_flags = SLOT_BACK
item_state = "heavyprotogun"
is_wieldable = TRUE
update_wield_verb()
/obj/item/weapon/gun/energy/laser/prototype/proc/handle_mod()
for(var/obj/item/laser_components/modifier/modifier in gun_mods)
switch(modifier.mod_type)
@@ -242,13 +248,6 @@
if(src in usr)
toggle_wield(usr)
/obj/item/weapon/gun/energy/laser/prototype/verb/wield_shotgun()
set name = "Wield prototype"
set category = "Object"
set src in usr
toggle_wield(usr)
/obj/item/weapon/gun/energy/laser/prototype/verb/scope()
set category = "Object"
set name = "Use Scope"

View File

@@ -26,27 +26,13 @@
origin_tech = list(TECH_COMBAT = 3, TECH_MATERIAL = 2, TECH_MAGNET = 3)
modifystate = "eriflestun"
is_wieldable = TRUE
firemodes = list(
list(mode_name="stun", projectile_type=/obj/item/projectile/beam/stun, modifystate="eriflestun", fire_sound='sound/weapons/Taser.ogg'),
list(mode_name="lethal", projectile_type=/obj/item/projectile/beam, modifystate="eriflekill", fire_sound='sound/weapons/Laser.ogg')
)
//action button for wielding
action_button_name = "Wield rifle"
/obj/item/weapon/gun/energy/rifle/can_wield()
return 1
/obj/item/weapon/gun/energy/rifle/ui_action_click()
if(src in usr)
toggle_wield(usr)
/obj/item/weapon/gun/energy/rifle/verb/wield_rifle()
set name = "Wield rifle"
set category = "Object"
set src in usr
toggle_wield(usr)
/obj/item/weapon/gun/energy/rifle/laser
name = "laser rifle"

View File

@@ -252,28 +252,15 @@
fire_delay = 10
dispersion = GATLINGLASER_DISPERSION_CONCENTRATED
is_wieldable = TRUE
firemodes = list(
list(mode_name="concentrated burst", burst=10, burst_delay = 1, fire_delay = 10, dispersion = GATLINGLASER_DISPERSION_CONCENTRATED),
list(mode_name="spray", burst=20, burst_delay = 1, move_delay = 5, fire_delay = 30, dispersion = GATLINGLASER_DISPERSION_SPRAY)
)
action_button_name = "Wield gatling laser"
charge_cost = 50
/obj/item/weapon/gun/energy/vaurca/gatlinglaser/can_wield()
return 1
/obj/item/weapon/gun/energy/vaurca/gatlinglaser/ui_action_click()
if(src in usr)
toggle_wield(usr)
/obj/item/weapon/gun/energy/vaurca/gatlinglaser/verb/wield_rifle()
set name = "Wield gatling laser"
set category = "Object"
set src in usr
toggle_wield(usr)
/obj/item/weapon/gun/energy/vaurca/gatlinglaser/special_check(var/mob/user)
if(is_charging)
to_chat(user, "<span class='danger'>\The [src] is already spinning!</span>")
@@ -354,22 +341,10 @@
recharge_time = 2
needspin = FALSE
is_wieldable = TRUE
action_button_name = "Wield thermal lance"
/obj/item/weapon/gun/energy/vaurca/typec/can_wield()
return 1
/obj/item/weapon/gun/energy/vaurca/typec/ui_action_click()
if(src in usr)
toggle_wield(usr)
/obj/item/weapon/gun/energy/vaurca/typec/verb/wield_rifle()
set name = "Wield thermal lance"
set category = "Object"
set src in usr
toggle_wield(usr)
/obj/item/weapon/gun/energy/vaurca/typec/attack(mob/living/carbon/human/M as mob, mob/living/carbon/user as mob)
user.setClickCooldown(16)
..()
@@ -450,6 +425,8 @@
can_turret = 1
turret_sprite_set = "thermaldrill"
is_wieldable = TRUE
firemodes = list(
list(mode_name="2 second burst", burst=10, burst_delay = 1, fire_delay = 20),
list(mode_name="4 second burst", burst=20, burst_delay = 1, fire_delay = 40),
@@ -460,20 +437,6 @@
needspin = FALSE
/obj/item/weapon/gun/energy/vaurca/thermaldrill/can_wield()
return 1
/obj/item/weapon/gun/energy/vaurca/thermaldrill/ui_action_click()
if(src in usr)
toggle_wield(usr)
/obj/item/weapon/gun/energy/vaurca/thermaldrill/verb/wield_rifle()
set name = "Wield thermal drill"
set category = "Object"
set src in usr
toggle_wield(usr)
/obj/item/weapon/gun/energy/vaurca/thermaldrill/special_check(var/mob/user)
if(is_charging)
to_chat(user, "<span class='danger'>\The [src] is already charging!</span>")

View File

@@ -104,6 +104,8 @@
magazine_type = /obj/item/ammo_magazine/c762
allowed_magazines = list(/obj/item/ammo_magazine/c762)
is_wieldable = TRUE
firemodes = list(
list(mode_name="semiauto", burst=1, fire_delay=10, move_delay=null, burst_accuracy=null, dispersion=null),
list(mode_name="3-round bursts", burst=3, fire_delay=null, move_delay=2, burst_accuracy=list(1,0,0), dispersion=list(0, 5, 10)),
@@ -118,23 +120,6 @@
fire_delay_wielded = 6
accuracy_wielded = 2
//action button for wielding
action_button_name = "Wield rifle"
/obj/item/weapon/gun/projectile/automatic/rifle/can_wield()
return 1
/obj/item/weapon/gun/projectile/automatic/rifle/ui_action_click()
if(src in usr)
toggle_wield(usr)
/obj/item/weapon/gun/projectile/automatic/rifle/verb/wield_rifle()
set name = "Wield rifle"
set category = "Object"
set src in usr
toggle_wield(usr)
usr.update_icon()
/obj/item/weapon/gun/projectile/automatic/rifle/sts35
name = "assault rifle"
@@ -386,6 +371,8 @@
auto_eject = 1
auto_eject_sound = 'sound/weapons/smg_empty_alarm.ogg'
is_wieldable = TRUE
firemodes = list(
list(mode_name="semiauto", burst=1, move_delay=null, burst_accuracy=null, dispersion=null),
list(mode_name="3-round bursts", burst=3, move_delay=2, burst_accuracy=list(2,1,1), dispersion=list(0, 10, 15)),
@@ -401,8 +388,6 @@
accuracy_wielded = 2
scoped_accuracy = 2
action_button_name = "Wield rifle"
/obj/item/weapon/gun/projectile/automatic/terminator/verb/scope()
set category = "Object"
set name = "Use Scope"
@@ -413,21 +398,6 @@
else
to_chat(usr, "<span class='warning'>You can't look through the scope without stabilizing the rifle!</span>")
/obj/item/weapon/gun/projectile/automatic/terminator/can_wield()
return 1
/obj/item/weapon/gun/projectile/automatic/terminator/ui_action_click()
if(src in usr)
toggle_wield(usr)
/obj/item/weapon/gun/projectile/automatic/terminator/verb/wield_rifle()
set name = "Wield rifle"
set category = "Object"
set src in usr
toggle_wield(usr)
usr.update_icon()
/obj/item/weapon/gun/projectile/automatic/rifle/shotgun
name = "assault shotgun"
desc = "A experimental, semi-automatic combat shotgun, designed for boarding operations and law enforcement agencies."

View File

@@ -19,8 +19,6 @@
can_sawoff = TRUE
sawnoff_workmsg = "shorten the barrel and stock"
action_button_name = "Wield rifle"
/obj/item/weapon/gun/projectile/shotgun/pump/rifle/saw_off(mob/user, obj/item/tool)
icon_state = "obrez"
w_class = 3
@@ -229,7 +227,7 @@
fire_delay_wielded = 10
accuracy_wielded = 2
action_button_name = "Wield rifle"
is_wieldable = TRUE
/obj/item/weapon/gun/projectile/gauss/update_icon()
..()
@@ -243,17 +241,3 @@
update_held_icon()
return
/obj/item/weapon/gun/projectile/gauss/can_wield()
return 1
/obj/item/weapon/gun/projectile/gauss/ui_action_click()
if(src in usr)
toggle_wield(usr)
/obj/item/weapon/gun/projectile/gauss/verb/wield_rifle()
set name = "Wield rifle"
set category = "Object"
set src in usr
toggle_wield(usr)
usr.update_icon()

View File

@@ -53,27 +53,12 @@
ammo_type = /obj/item/ammo_casing/shotgun/beanbag
handle_casings = HOLD_CASINGS
fire_sound = 'sound/weapons/gunshot/gunshot_shotgun2.ogg'
is_wieldable = TRUE
var/recentpump = 0 // to prevent spammage
var/pump_fail_msg = "<span class='warning'>You cannot rack the shotgun without gripping it with both hands!</span>"
var/pump_snd = 'sound/weapons/shotgunpump.ogg'
var/has_wield_state = TRUE
action_button_name = "Wield shotgun"
/obj/item/weapon/gun/projectile/shotgun/pump/can_wield()
return 1
/obj/item/weapon/gun/projectile/shotgun/pump/ui_action_click()
if(src in usr)
toggle_wield(usr)
/obj/item/weapon/gun/projectile/shotgun/pump/verb/wield_shotgun()
set name = "Wield"
set category = "Object"
set src in usr
toggle_wield(usr)
/obj/item/weapon/gun/projectile/shotgun/pump/consume_next_projectile()
if(chambered)
return chambered.BB

View File

@@ -18,29 +18,13 @@
scoped_accuracy = 4
var/bolt_open = 0
is_wieldable = TRUE
fire_sound = 'sound/weapons/gunshot/gunshot_dmr.ogg'
recoil_wielded = 2
accuracy_wielded = -1
//action button for wielding
action_button_name = "Wield rifle"
/obj/item/weapon/gun/projectile/heavysniper/can_wield()
return 1
/obj/item/weapon/gun/projectile/heavysniper/ui_action_click()
if(src in usr)
toggle_wield(usr)
/obj/item/weapon/gun/projectile/heavysniper/verb/wield_rifle()
set name = "Wield rifle"
set category = "Object"
set src in usr
toggle_wield(usr)
usr.update_icon()
/obj/item/weapon/gun/projectile/heavysniper/update_icon()
if(bolt_open)
icon_state = "heavysniper-open"
@@ -153,12 +137,11 @@
accuracy = -4
scoped_accuracy = 3
is_wieldable = TRUE
recoil_wielded = 1
accuracy_wielded = 1
//action button for wielding
action_button_name = "Wield rifle"
/obj/item/weapon/gun/projectile/dragunov/update_icon()
if(ammo_magazine)
@@ -166,20 +149,6 @@
else
icon_state = "dragunov-empty"
/obj/item/weapon/gun/projectile/dragunov/can_wield()
return 1
/obj/item/weapon/gun/projectile/dragunov/ui_action_click()
if(src in usr)
toggle_wield(usr)
/obj/item/weapon/gun/projectile/dragunov/verb/wield_rifle()
set name = "Wield rifle"
set category = "Object"
set src in usr
toggle_wield(usr)
/obj/item/weapon/gun/projectile/dragunov/special_check(mob/user)
if(!wielded)
to_chat(user, "<span class='warning'>You can't fire without stabilizing the rifle!</span>")