mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-23 23:54:45 +00:00
Adjusts the click code to not use client/Click(). The code is largely unchanged, except that it allows the compiler default behaviour of calling atom/Click(), and then forwards the call to mob/ClickOn(). I had some reports that melee combat mixed with movement was behaving oddly, and I believe it may be due to the use of client/Click; the byond documentation says that redefining client/Click() causes additional overhead, and it isn't strictly necessary. Alters the way double clicks are handled, in an attempt to better handle clickspam, as often occurs during pitched combat. This may also be responsible for the above, but I don't know. Inserts proximity (aka flag) checks in all afterattack() procs. The old assumption was that unless an item used the USEDELAY flag, afterattack() was only called when adjacent, but this is no longer true. This led to beakers, soap, crayons, etc, all being usable at all ranges. Removes the NODELAY flag, which was unused. Removes all existing uses of the USEDELAY flag so that it can be readded to things that need extra delay. Removes the hand_* procs, previously used by restrained actions. Instead, the mob helper mob/RestrainedClickOn() has abosrbed basically all the functionality they were used for, which is really only monkeys with jungle fever. Adds a special case of the Adjacency() proc for doors. This fixes #136, airlocks being unreachable due to border fire doors. However, this only takes us back to the unpleasant position where you have to open-hand the door, switch to a crowbar, and pry open the firedoor; it still needs a better fix.
138 lines
3.6 KiB
Plaintext
138 lines
3.6 KiB
Plaintext
/obj/item/weapon/gun
|
|
name = "gun"
|
|
desc = "Its a gun. It's pretty terrible, though."
|
|
icon = 'icons/obj/gun.dmi'
|
|
icon_state = "detective"
|
|
item_state = "gun"
|
|
flags = FPRINT | TABLEPASS | CONDUCT
|
|
slot_flags = SLOT_BELT
|
|
m_amt = 2000
|
|
w_class = 3.0
|
|
throwforce = 5
|
|
throw_speed = 4
|
|
throw_range = 5
|
|
force = 5.0
|
|
origin_tech = "combat=1"
|
|
attack_verb = list("struck", "hit", "bashed")
|
|
|
|
var/fire_sound = "gunshot"
|
|
var/obj/item/projectile/in_chamber = null
|
|
var/caliber = ""
|
|
var/silenced = 0
|
|
var/recoil = 0
|
|
var/ejectshell = 1
|
|
var/clumsy_check = 1
|
|
|
|
proc/load_into_chamber()
|
|
return 0
|
|
|
|
proc/special_check(var/mob/M) //Placeholder for any special checks, like detective's revolver.
|
|
return 1
|
|
|
|
proc/prepare_shot(var/obj/item/projectile/proj) //Transfer properties from the gun to the bullet
|
|
proj.shot_from = src
|
|
proj.silenced = silenced
|
|
return
|
|
|
|
|
|
emp_act(severity)
|
|
for(var/obj/O in contents)
|
|
O.emp_act(severity)
|
|
|
|
|
|
afterattack(atom/target as mob|obj|turf, mob/living/user as mob|obj, flag, params)//TODO: go over this
|
|
if(flag) //It's adjacent, is the user, or is on the user's person
|
|
return
|
|
|
|
//Exclude lasertag guns from the CLUMSY check.
|
|
if(clumsy_check)
|
|
if(istype(user, /mob/living))
|
|
var/mob/living/M = user
|
|
if ((CLUMSY in M.mutations) && prob(40))
|
|
M << "<span class='danger'>You shoot yourself in the foot with the [src]!</span>"
|
|
afterattack(user, user)
|
|
M.drop_item()
|
|
return
|
|
|
|
if (!user.IsAdvancedToolUser())
|
|
user << "<span class='notice'>You don't have the dexterity to do this!</span>"
|
|
return
|
|
if(istype(user, /mob/living))
|
|
var/mob/living/M = user
|
|
if (HULK in M.mutations)
|
|
M << "<span class='notice'>Your meaty finger is much too large for the trigger guard!</span>"
|
|
return
|
|
if(ishuman(user))
|
|
var/mob/living/carbon/human/H = user
|
|
if(H.dna && H.dna.mutantrace == "adamantine")
|
|
user << "<span class='notice'>Your metal fingers don't fit in the trigger guard!</span>"
|
|
return
|
|
|
|
add_fingerprint(user)
|
|
|
|
var/turf/curloc = user.loc
|
|
var/turf/targloc = get_turf(target)
|
|
if (!istype(targloc) || !istype(curloc))
|
|
return
|
|
|
|
if(!special_check(user))
|
|
return
|
|
if(!load_into_chamber())
|
|
user << "<span class='warning'>*click*</span>"
|
|
return
|
|
|
|
if(!in_chamber)
|
|
return
|
|
|
|
in_chamber.firer = user
|
|
in_chamber.def_zone = user.zone_sel.selecting
|
|
|
|
|
|
if(recoil)
|
|
spawn()
|
|
shake_camera(user, recoil + 1, recoil)
|
|
|
|
if(silenced)
|
|
playsound(user, fire_sound, 10, 1)
|
|
else
|
|
playsound(user, fire_sound, 50, 1)
|
|
user.visible_message("<span class='danger'>[user] fires [src]!</span>", "<span class='danger'>You fire [src]!</span>", "You hear a [istype(in_chamber, /obj/item/projectile/beam) ? "laser blast" : "gunshot"]!")
|
|
|
|
prepare_shot(in_chamber) //Set the projectile's properties
|
|
|
|
|
|
|
|
if(targloc == curloc) //Fire the projectile
|
|
user.bullet_act(in_chamber)
|
|
del(in_chamber)
|
|
update_icon()
|
|
return
|
|
in_chamber.original = target
|
|
in_chamber.loc = get_turf(user)
|
|
in_chamber.starting = get_turf(user)
|
|
in_chamber.current = curloc
|
|
in_chamber.yo = targloc.y - curloc.y
|
|
in_chamber.xo = targloc.x - curloc.x
|
|
user.next_move = world.time + 4
|
|
|
|
if(params)
|
|
var/list/mouse_control = params2list(params)
|
|
if(mouse_control["icon-x"])
|
|
in_chamber.p_x = text2num(mouse_control["icon-x"])
|
|
if(mouse_control["icon-y"])
|
|
in_chamber.p_y = text2num(mouse_control["icon-y"])
|
|
|
|
spawn()
|
|
if(in_chamber)
|
|
in_chamber.process()
|
|
sleep(1)
|
|
in_chamber = null
|
|
|
|
update_icon()
|
|
|
|
if(user.hand)
|
|
user.update_inv_l_hand(0)
|
|
else
|
|
user.update_inv_r_hand(0)
|
|
|