Skip to content

Commit

Permalink
Merge pull request #5265 from Superlagg/feels-about-half-hasnt-been-u…
Browse files Browse the repository at this point in the history
…sed-thats-it-three-two-one

Update ammo count overlay for guns
  • Loading branch information
Kilmented authored Jun 15, 2024
2 parents d9fc3f3 + 60e60a0 commit ad6e1ac
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 1 deletion.
13 changes: 12 additions & 1 deletion code/datums/traits/clams.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
mob_overlay_icon = 'icons/mob/clothing/clam_onmob.dmi'
inedible = TRUE // sorta
tastes = list("seafood" = 4, "dirt" = 1, "shrapnel" = 1)
w_class = WEIGHT_CLASS_TINY
list_reagents = list(
/datum/reagent/consumable/nutriment = 4,
/datum/reagent/water = 2,
Expand Down Expand Up @@ -207,7 +208,10 @@
if(!guts)
to_chat(likcer, span_alert(oysterclam("You fish your tongue around in there for a bit, but aw man, there's no meat!", likcer)))
return // no guts no glory
likcer.visible_message(oysterclam("Wizh a deft flick of your tongue, you dart in between a gap in the shell and lap out the meat!", likcer))
likcer.visible_message(
self_message = oysterclam("Wizh a deft flick of your tongue, you dart in between a gap in the shell and lap out the meat!", likcer),
message = oysterclam("[likcer] licks the clam!", likcer),
)
eviscerate_clam(likcer, TRUE, tongue)

/obj/item/reagent_containers/food/snacks/clam/proc/screw_clam(mob/living/carbon/likcer, obj/item/screwer)
Expand Down Expand Up @@ -363,6 +367,7 @@
icon = 'icons/mob/clothing/clam.dmi'
mob_overlay_icon = 'icons/mob/clothing/clam_onmob.dmi'
tastes = list("seafood" = 4, "dirt" = 1, "weh" = 1)
w_class = WEIGHT_CLASS_TINY
list_reagents = list(
/datum/reagent/consumable/nutriment = 4,
/datum/reagent/water = 2,
Expand Down Expand Up @@ -391,6 +396,7 @@
icon_state = "clam_shell"
slot_flags = INV_SLOTBIT_HEAD // as a tiny dorky hat
tastes = list("shell" = 4, "dirt" = 1, "weh" = 1)
w_class = WEIGHT_CLASS_TINY
list_reagents = list(
/datum/reagent/shell_shrapnel = 5,
/datum/reagent/calciumcarbonate = 2,
Expand Down Expand Up @@ -420,6 +426,7 @@
icon_state = "pearl"
mob_overlay_icon = 'icons/mob/clothing/clam_onmob.dmi'
tastes = list("pearl" = 4, "dirt" = 1)
w_class = WEIGHT_CLASS_TINY
grind_results = list(
/datum/reagent/medicine/bicaridine = 4,
/datum/reagent/medicine/kelotane = 4,
Expand All @@ -444,6 +451,7 @@
desc = "A dainty little necklace made from pearls strung up on some kind of string. \
It is very pretty and clearly someone put a lot of effort into making it. \
Some say you can get one for free, granted you have the right assets."
w_class = WEIGHT_CLASS_TINY
icon = 'icons/mob/clothing/clam.dmi'
icon_state = "pearl_necklace"
mob_overlay_icon = 'icons/mob/clothing/clam_onmob.dmi'
Expand All @@ -455,6 +463,7 @@
name = "seashell bra"
desc = "A cute tropical bra made from seashells and string. It's as cute as it is impractical and utterly lacking in support, \
which is saying something cus this bra is really really cute! Perfect for flat chested weird rats on stilts to pretend they have boobs."
w_class = WEIGHT_CLASS_TINY
icon = 'icons/mob/clothing/clam.dmi'
mob_overlay_icon = 'icons/mob/clothing/clam_onmob.dmi'
icon_state = "clam_bra"
Expand All @@ -473,6 +482,7 @@
name = "seashell codpiece"
desc = "A cute tropical codpiece made from a seashell and string. It's as cute as it is impractical for anyone even remotely hung, \
which is saying something cus this codpiece is really really cute! Perfect for weird rats on stilts to pretend they have a bulge."
w_class = WEIGHT_CLASS_TINY
icon = 'icons/mob/clothing/clam.dmi'
mob_overlay_icon = 'icons/mob/clothing/clam_onmob.dmi'
icon_state = "clam_codpiece"
Expand All @@ -491,6 +501,7 @@
name = "seashell bikini"
desc = "A cute tropical bikini made from seashells and string. It's as cute as it is impractical and utterly lacking in support, \
which is saying something cus this bikini is really really cute! Perfect for flat chested weird rats on stilts to pretend they have boobs and or a bulge."
w_class = WEIGHT_CLASS_TINY
icon = 'icons/mob/clothing/clam.dmi'
icon_state = "clam_bikini"
mob_overlay_icon = 'icons/mob/clothing/clam_onmob.dmi'
Expand Down
18 changes: 18 additions & 0 deletions code/modules/projectiles/gun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ ATTACHMENTS
var/reloading = FALSE
/// This is the base reload speed, which is modified by things like the size of the magazine in use.
var/reloading_time = 1 SECONDS
maptext_width = 48 //prevents ammo count from wrapping down into two lines
maptext_x = 4
maptext_y = 2

/obj/item/gun/Initialize()
recoil_tag = SSrecoil.give_recoil_tag(init_recoil)
Expand Down Expand Up @@ -377,6 +380,7 @@ ATTACHMENTS
if(!(. & EMP_PROTECT_CONTENTS))
for(var/obj/O in contents)
O.emp_act(severity)
update_icon()

/obj/item/gun/attack(mob/living/M, mob/user)
if(bayonet && user.a_intent == INTENT_HARM)
Expand All @@ -385,6 +389,7 @@ ATTACHMENTS
. = ..()
if(!(. & DISCARD_LAST_ACTION))
user.DelayNextAction(attack_speed)
update_icon()

/obj/item/gun/attack_obj(obj/O, mob/user)
if(bayonet && user.a_intent == INTENT_HARM) // Must run BEFORE parent call, so we don't smack them with the gun body too.
Expand All @@ -393,6 +398,7 @@ ATTACHMENTS
. = ..()
if(!(. & DISCARD_LAST_ACTION))
user.DelayNextAction(attack_speed)
update_icon()

/obj/item/gun/afterattack(atom/target, mob/living/user, flag, params)
. = ..()
Expand Down Expand Up @@ -1068,6 +1074,18 @@ ATTACHMENTS
if("Weapon Info")
ui_interact(user)

/// Updates the ammo count number that renders on top of the icon
/obj/item/gun/proc/UpdateAmmoCountOverlay()
return

/obj/item/gun/doMove(atom/destination)
. = ..()
UpdateAmmoCountOverlay()

/obj/item/gun/update_icon()
. = ..()
UpdateAmmoCountOverlay()

/obj/item/gun/proc/toggle_scope(mob/living/user)
//looking through a scope limits your periphereal vision
//still, increase the view size by a tiny amount so that sniping isn't too restricted to NSEW
Expand Down
28 changes: 28 additions & 0 deletions code/modules/projectiles/guns/ballistic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,34 @@ GLOBAL_LIST_EMPTY(gun_accepted_magazines)
return
return SEND_SIGNAL(magazine, COMSIG_GUN_MAG_ADMIN_RELOAD) // get relayed, noob

/obj/item/gun/ballistic/UpdateAmmoCountOverlay()
if(isturf(loc))//Only show th ammo count if the magazine is, like, in an inventory or something. Mags on the ground don't need a big number on them, that's ugly.
maptext = ""
else
var/ammos = get_ammo()
var/ammomax = get_max_ammo()
var/textt = ""
var/culur = "#FF0000"
if(ammomax == 0)
culur = "#FFFFFF"
else if(ammos == ammomax)
culur = "#00FFFF"
else if(ammos > ammomax * 0.75)
culur = "#00FF00"
else if(ammos > ammomax * 0.5)
culur = "#FFFF00"
else if(ammos > ammomax * 0.25)
culur = "#FFA500"
else if(ammos > 0)
culur = "#FF0000"
else
culur = "#FF00FF"
if(ammos > 0)
textt = "[ammos]/[get_max_ammo()]"
else
textt = "0/[get_max_ammo()]"
maptext = "<font color='[culur]'><b>[textt]</b></font>"

/obj/item/gun/ballistic/update_icon_state()
if(SEND_SIGNAL(src, COMSIG_ITEM_UPDATE_RESKIN))
return // all done!
Expand Down
30 changes: 30 additions & 0 deletions code/modules/projectiles/guns/ballistic/flintlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,29 @@
..()
gun_tags |= GUN_PROJECTILE

/obj/item/gun/flintlock/UpdateAmmoCountOverlay()
if(isturf(loc))//Only show th ammo count if the magazine is, like, in an inventory or something. Mags on the ground don't need a big number on them, that's ugly.
maptext = ""
else
var/txte = ""
var/culur = "#FF0000"
if(chambered)
if(cocked)
txte = "1/1 !C!"
culur = "#00FFFF"
else
txte = "1/1"
culur = "#FFFF00"
else
if(cocked)
txte = "0/1 !C!"
culur = "#FF0000"
else
txte = "0/1"
culur = "#FF0000"
maptext = "<font color='[culur]'><b>[txte]</b></font>"


/obj/item/gun/flintlock/ui_data(mob/user)
var/list/data = ..()
data["cockable"] = TRUE
Expand Down Expand Up @@ -195,6 +218,13 @@
shoot_with_empty_chamber(user)
return FALSE
var/atom/tar_get = user?.client?.mouseObject
if(istype(tar_get, /atom/movable/screen)) // we clicked the ~void~, and now we need to do math
tar_get = null
if(user?.client)
var/angel = mouse_angle_from_client(user.client)
var/turf/shootat = get_turf_in_angle(angel, get_turf(src), 20) // sure
if(shootat)
tar_get = shootat
/// this is if they disconnect, or tossed the gun before it fired, or ceased to exist, or something
if(!tar_get || !user || loc != user)
tar_get = null
Expand Down
29 changes: 29 additions & 0 deletions code/modules/projectiles/guns/energy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,35 @@
if(can_remove == 1)
. += span_notice("Alt-click to eject the battery.")

/obj/item/gun/energy/UpdateAmmoCountOverlay()
if(isturf(loc))//Only show th ammo count if the magazine is, like, in an inventory or something. Mags on the ground don't need a big number on them, that's ugly.
maptext = ""
else
var/txte = ""
var/culur = "#FF0000"
if(!cell)
culur = "#FF0000"
txte = "-/-"
if(cell)
var/obj/item/ammo_casing/energy/shot = ammo_type[current_firemode_index]
var/c_mult = get_charge_cost_mult()
var/shots_max = round(cell.maxcharge / max(shot?.e_cost * c_mult, 0.01))
var/shots_remaining = round(cell.charge / max(shot?.e_cost * c_mult, 0.01))
if(shots_remaining >= shots_max)
culur = "#00FFFF"
else if(shots_remaining >= shots_max * 0.75)
culur = "#00FF00"
else if(shots_remaining >= shots_max * 0.5)
culur = "#FFFF00"
else if(shots_remaining >= shots_max * 0.25)
culur = "#FFA500"
else if(shots_remaining > 0)
culur = "#FF0000"
else
culur = "#FF00FF"
txte = "[shots_remaining]/[shots_max]"
maptext = "<font color='[culur]'><b>[txte]</b></font>"

/obj/item/gun/energy/ui_data(mob/user)
var/list/data = ..()
var/obj/item/ammo_casing/energy/shot = ammo_type[current_firemode_index]
Expand Down
23 changes: 23 additions & 0 deletions code/modules/projectiles/guns/magic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,29 @@
charges++
charge_timer = addtimer(CALLBACK(src,PROC_REF(charge)), recharge_rate, TIMER_UNIQUE|TIMER_STOPPABLE)

/obj/item/gun/magic/UpdateAmmoCountOverlay()
if(isturf(loc))//Only show th ammo count if the magazine is, like, in an inventory or something. Mags on the ground don't need a big number on them, that's ugly.
maptext = ""
else
var/txte = ""
var/culur = "#FF0000"
var/shots_max = max_charges
var/shots_remaining = charges
if(shots_remaining >= shots_max)
culur = "#00FFFF"
else if(shots_remaining >= shots_max * 0.75)
culur = "#00FF00"
else if(shots_remaining >= shots_max * 0.5)
culur = "#FFFF00"
else if(shots_remaining >= shots_max * 0.25)
culur = "#FFA500"
else if(shots_remaining > 0)
culur = "#FF0000"
else
culur = "#FF00FF"
txte = "[shots_remaining]/[shots_max]"
maptext = "<font color='[culur]'><b>[txte]</b></font>"

/obj/item/gun/magic/vv_edit_var(var_name, var_value)
. = ..()
switch(var_name)
Expand Down

0 comments on commit ad6e1ac

Please sign in to comment.