Allow click-dragging things into rechargers (#6749)

This commit is contained in:
TheGreatKitsune
2023-08-08 01:01:05 -05:00
committed by GitHub
parent 99aa54e36b
commit 8384f27582
2 changed files with 95 additions and 69 deletions

View File

@@ -31,70 +31,94 @@
if(C) // Sometimes we get things without cells in it. if(C) // Sometimes we get things without cells in it.
. += "Current charge: [C.charge] / [C.maxcharge]" . += "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) /obj/machinery/recharger/attackby(obj/item/weapon/G as obj, mob/user as mob)
var/allowed = 0 var/allowed = 0
for (var/allowed_type in allowed_devices) for (var/allowed_type in allowed_devices)
if(istype(G, allowed_type)) allowed = 1 if(istype(G, allowed_type)) allowed = 1
if(allowed) if(allowed)
if(charging) //CHOMPEdit Start - move checks into their own proc
to_chat(user, "<span class='warning'>\A [charging] is already charging here.</span>") if(!do_allowed_checks(G, user))
return return
// Checks to make sure he's not in space doing it, and that the area got proper power. //CHOMPEdit End
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
user.drop_item() user.drop_item()
G.loc = src G.loc = src

View File

@@ -311,13 +311,15 @@
if(!canremove) if(!canremove)
return 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 (ishuman(usr) || issmall(usr)) //so monkeys can take off their backpacks -- Urist
//CHOMPEdit End
if (istype(usr.loc,/obj/mecha)) // stops inventory actions in a mech. why?
return
if (!( istype(over_object, /obj/screen) ))
return ..()
//makes sure that the thing is equipped, so that we can't drag it into our hand from miles away. //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. //there's got to be a better way of doing this.
@@ -438,7 +440,7 @@
else else
set_light(0) set_light(0)
//VOREStation Edit End //VOREStation Edit End
//YAWNEDIT: Recoil knockdown for micros, ported from CHOMPStation //YAWNEDIT: Recoil knockdown for micros, ported from CHOMPStation
if(recoil_mode && iscarbon(user)) if(recoil_mode && iscarbon(user))
var/mob/living/carbon/nerd = 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>") to_chat(nerd, "<span class='danger'>You're so tiny that you drop the gun and hurt yourself from the recoil!</span>")
else else
to_chat(nerd, "<span class='danger'>You're so tiny that the pull of the trigger causes you to drop the gun!</span>") 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 //YAWNEDIT: Knockdown code end
user.hud_used.update_ammo_hud(user, src) 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. // 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() /obj/item/weapon/gun/proc/get_ammo_count()
return FALSE 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. /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) if(slot == slot_l_hand || slot == slot_r_hand)
user.hud_used.add_ammo_hud(user, src) user.hud_used.add_ammo_hud(user, src)
else else
user.hud_used.remove_ammo_hud(user, src) user.hud_used.remove_ammo_hud(user, src)
return ..() 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. /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) user.hud_used.remove_ammo_hud(user, src)
..() ..()