mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 02:34:00 +00:00
Allow click-dragging things into rechargers (#6749)
This commit is contained in:
@@ -31,70 +31,94 @@
|
||||
if(C) // Sometimes we get things without cells in it.
|
||||
. += "Current charge: [C.charge] / [C.maxcharge]"
|
||||
|
||||
//CHOMPEdit Start - Let borgs clickdrag things into chargers
|
||||
/obj/machinery/recharger/proc/do_allowed_checks(obj/item/G, mob/user)
|
||||
. = FALSE
|
||||
if(charging)
|
||||
to_chat(user, "<span class='warning'>\A [charging] is already charging here.</span>")
|
||||
return
|
||||
// Checks to make sure he's not in space doing it, and that the area got proper power.
|
||||
if(!powered())
|
||||
to_chat(user, "<span class='warning'>\The [src] blinks red as you try to insert [G]!</span>")
|
||||
return
|
||||
if(istype(G, /obj/item/weapon/gun/energy))
|
||||
var/obj/item/weapon/gun/energy/E = G
|
||||
if(E.self_recharge)
|
||||
to_chat(user, "<span class='notice'>\The [E] has no recharge port.</span>")
|
||||
return
|
||||
if(istype(G, /obj/item/modular_computer))
|
||||
var/obj/item/modular_computer/C = G
|
||||
if(!C.battery_module)
|
||||
to_chat(user, "<span class='notice'>\The [C] does not have a battery installed. </span>")
|
||||
return
|
||||
if(istype(G, /obj/item/weapon/melee/baton))
|
||||
var/obj/item/weapon/melee/baton/B = G
|
||||
if(B.use_external_power)
|
||||
to_chat(user, "<span class='notice'>\The [B] has no recharge port.</span>")
|
||||
return
|
||||
if(istype(G, /obj/item/device/flash))
|
||||
var/obj/item/device/flash/F = G
|
||||
if(F.use_external_power)
|
||||
to_chat(user, "<span class='notice'>\The [F] has no recharge port.</span>")
|
||||
return
|
||||
if(istype(G, /obj/item/weapon/weldingtool/electric))
|
||||
var/obj/item/weapon/weldingtool/electric/EW = G
|
||||
if(EW.use_external_power)
|
||||
to_chat(user, "<span class='notice'>\The [EW] has no recharge port.</span>")
|
||||
return
|
||||
else if(istype(G, /obj/item/ammo_magazine/cell_mag)) // CHOMPedit start
|
||||
var/obj/item/ammo_magazine/cell_mag/maggy = G
|
||||
if(maggy.stored_ammo.len < 1)
|
||||
to_chat(user, "\The [G] does not have any cells installed.")
|
||||
return
|
||||
else if(istype(G, /obj/item/weapon/gun/projectile/cell_loaded))
|
||||
var/obj/item/weapon/gun/projectile/cell_loaded/gunny = G
|
||||
if(gunny.ammo_magazine)
|
||||
var/obj/item/ammo_magazine/cell_mag/maggy = gunny.ammo_magazine
|
||||
if(maggy.stored_ammo.len < 1)
|
||||
to_chat(user, "\The [G] does not have any cell in its magazine installed.")
|
||||
return
|
||||
else
|
||||
to_chat(user, "\The [G] does not have a magazine installed..") // CHOMPedit end
|
||||
if(istype(G, /obj/item/device/paicard))
|
||||
var/obj/item/device/paicard/ourcard = G
|
||||
if(ourcard.panel_open)
|
||||
to_chat(user, "<span class='warning'>\The [ourcard] won't fit in the recharger with its panel open.</span>")
|
||||
return
|
||||
if(ourcard.pai)
|
||||
if(ourcard.pai.stat == CONSCIOUS)
|
||||
to_chat(user, "<span class='warning'>\The [ourcard] boops... it doesn't need to be recharged!</span>")
|
||||
return
|
||||
else
|
||||
to_chat(user, "<span class='warning'>\The [ourcard] doesn't have a personality!</span>")
|
||||
return
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/recharger/MouseDrop_T(obj/item/weapon/G as obj, mob/user as mob)
|
||||
var/allowed = 0
|
||||
for (var/allowed_type in allowed_devices)
|
||||
if(istype(G, allowed_type)) allowed = 1
|
||||
|
||||
if(allowed)
|
||||
if(!do_allowed_checks(G, user))
|
||||
return
|
||||
|
||||
G.loc = src
|
||||
charging = G
|
||||
update_icon()
|
||||
user.visible_message("[user] inserts [charging] into [src].", "You insert [charging] into [src].")
|
||||
//CHOMPEdit End
|
||||
|
||||
/obj/machinery/recharger/attackby(obj/item/weapon/G as obj, mob/user as mob)
|
||||
var/allowed = 0
|
||||
for (var/allowed_type in allowed_devices)
|
||||
if(istype(G, allowed_type)) allowed = 1
|
||||
|
||||
if(allowed)
|
||||
if(charging)
|
||||
to_chat(user, "<span class='warning'>\A [charging] is already charging here.</span>")
|
||||
//CHOMPEdit Start - move checks into their own proc
|
||||
if(!do_allowed_checks(G, user))
|
||||
return
|
||||
// Checks to make sure he's not in space doing it, and that the area got proper power.
|
||||
if(!powered())
|
||||
to_chat(user, "<span class='warning'>\The [src] blinks red as you try to insert [G]!</span>")
|
||||
return
|
||||
if(istype(G, /obj/item/weapon/gun/energy))
|
||||
var/obj/item/weapon/gun/energy/E = G
|
||||
if(E.self_recharge)
|
||||
to_chat(user, "<span class='notice'>\The [E] has no recharge port.</span>")
|
||||
return
|
||||
if(istype(G, /obj/item/modular_computer))
|
||||
var/obj/item/modular_computer/C = G
|
||||
if(!C.battery_module)
|
||||
to_chat(user, "<span class='notice'>\The [C] does not have a battery installed. </span>")
|
||||
return
|
||||
if(istype(G, /obj/item/weapon/melee/baton))
|
||||
var/obj/item/weapon/melee/baton/B = G
|
||||
if(B.use_external_power)
|
||||
to_chat(user, "<span class='notice'>\The [B] has no recharge port.</span>")
|
||||
return
|
||||
if(istype(G, /obj/item/device/flash))
|
||||
var/obj/item/device/flash/F = G
|
||||
if(F.use_external_power)
|
||||
to_chat(user, "<span class='notice'>\The [F] has no recharge port.</span>")
|
||||
return
|
||||
if(istype(G, /obj/item/weapon/weldingtool/electric))
|
||||
var/obj/item/weapon/weldingtool/electric/EW = G
|
||||
if(EW.use_external_power)
|
||||
to_chat(user, "<span class='notice'>\The [EW] has no recharge port.</span>")
|
||||
return
|
||||
else if(istype(G, /obj/item/ammo_magazine/cell_mag)) // CHOMPedit start
|
||||
var/obj/item/ammo_magazine/cell_mag/maggy = G
|
||||
if(maggy.stored_ammo.len < 1)
|
||||
to_chat(user, "\The [G] does not have any cells installed.")
|
||||
return
|
||||
else if(istype(G, /obj/item/weapon/gun/projectile/cell_loaded))
|
||||
var/obj/item/weapon/gun/projectile/cell_loaded/gunny = G
|
||||
if(gunny.ammo_magazine)
|
||||
var/obj/item/ammo_magazine/cell_mag/maggy = gunny.ammo_magazine
|
||||
if(maggy.stored_ammo.len < 1)
|
||||
to_chat(user, "\The [G] does not have any cell in its magazine installed.")
|
||||
return
|
||||
else
|
||||
to_chat(user, "\The [G] does not have a magazine installed..") // CHOMPedit end
|
||||
if(istype(G, /obj/item/device/paicard))
|
||||
var/obj/item/device/paicard/ourcard = G
|
||||
if(ourcard.panel_open)
|
||||
to_chat(user, "<span class='warning'>\The [ourcard] won't fit in the recharger with its panel open.</span>")
|
||||
return
|
||||
if(ourcard.pai)
|
||||
if(ourcard.pai.stat == CONSCIOUS)
|
||||
to_chat(user, "<span class='warning'>\The [ourcard] boops... it doesn't need to be recharged!</span>")
|
||||
return
|
||||
else
|
||||
to_chat(user, "<span class='warning'>\The [ourcard] doesn't have a personality!</span>")
|
||||
return
|
||||
//CHOMPEdit End
|
||||
|
||||
user.drop_item()
|
||||
G.loc = src
|
||||
|
||||
@@ -311,13 +311,15 @@
|
||||
if(!canremove)
|
||||
return
|
||||
|
||||
//CHOMPEdit start - move these around so that nonhumans can actually click-drag guns at all
|
||||
if (istype(usr.loc,/obj/mecha)) // stops inventory actions in a mech. why?
|
||||
return
|
||||
|
||||
if (!( istype(over_object, /obj/screen) ))
|
||||
return ..()
|
||||
|
||||
if (ishuman(usr) || issmall(usr)) //so monkeys can take off their backpacks -- Urist
|
||||
|
||||
if (istype(usr.loc,/obj/mecha)) // stops inventory actions in a mech. why?
|
||||
return
|
||||
|
||||
if (!( istype(over_object, /obj/screen) ))
|
||||
return ..()
|
||||
//CHOMPEdit End
|
||||
|
||||
//makes sure that the thing is equipped, so that we can't drag it into our hand from miles away.
|
||||
//there's got to be a better way of doing this.
|
||||
@@ -438,7 +440,7 @@
|
||||
else
|
||||
set_light(0)
|
||||
//VOREStation Edit End
|
||||
|
||||
|
||||
//YAWNEDIT: Recoil knockdown for micros, ported from CHOMPStation
|
||||
if(recoil_mode && iscarbon(user))
|
||||
var/mob/living/carbon/nerd = user
|
||||
@@ -451,9 +453,9 @@
|
||||
to_chat(nerd, "<span class='danger'>You're so tiny that you drop the gun and hurt yourself from the recoil!</span>")
|
||||
else
|
||||
to_chat(nerd, "<span class='danger'>You're so tiny that the pull of the trigger causes you to drop the gun!</span>")
|
||||
|
||||
|
||||
//YAWNEDIT: Knockdown code end
|
||||
|
||||
|
||||
user.hud_used.update_ammo_hud(user, src)
|
||||
|
||||
// Similar to the above proc, but does not require a user, which is ideal for things like turrets.
|
||||
@@ -804,16 +806,16 @@
|
||||
|
||||
/obj/item/weapon/gun/proc/get_ammo_count()
|
||||
return FALSE
|
||||
|
||||
|
||||
/obj/item/weapon/gun/equipped(mob/living/user, slot) // When a gun is equipped to your hands, we'll add the HUD to the user. Pending porting over TGMC guncode where wielding is far more sensible.
|
||||
if(slot == slot_l_hand || slot == slot_r_hand)
|
||||
user.hud_used.add_ammo_hud(user, src)
|
||||
else
|
||||
user.hud_used.remove_ammo_hud(user, src)
|
||||
|
||||
|
||||
return ..()
|
||||
|
||||
/obj/item/weapon/gun/dropped(mob/living/user) // Ditto as above, we remove the HUD. Pending porting TGMC code to clean up this fucking nightmare of spaghetti.
|
||||
user.hud_used.remove_ammo_hud(user, src)
|
||||
|
||||
|
||||
..()
|
||||
|
||||
Reference in New Issue
Block a user