Files
Bubberstation/code/_onclick/hud/screen_objects.dm
Ryll Ryll 5c174800fb Grenades and projectiles can have shrapnel and embed, all carbons can suffer embeds, some bullets can ricochet, sizable refactor of embedding (#49634)
About The Pull Request

It annoyed me that we have a perfectly good frag grenade item, and a perfectly good shrapnel component, but no crossover episode between the two. This remedies that, and does a lot, lot more.

dreamseeker_2020-03-30_05-01-13.png

dreamseeker_2020-03-30_05-01-26.png

Big points:

    Adds new component: pellet_cloud, which can be used by ammo casings, guns, and landmines to spray shrapnel and display aggregate hit messages ("You're hit by 6 buckshot pellets!" vs "You're hit by the buckshot pellet in the X" x6). All gun ammo that shoot multiple pellets now use this component on firing.
    Adds stingbangs, premium less-lethal grenades that shoot off lots of stinger pellets, to cargo. Frag grenades are also reworked to have smaller booms, but shoot off lots of shrapnel shards. You can jump on top of these grenades to absorb a portion of the shrapnel to save those around you! There's an achievement for dying this way, called "Look Out, Sir!"
    Projectiles can now embed items/shrapnel. Adds .38 DumDum ammo to cargo that does less damage and has negative armor pen, but can embed in people. This is the only ammo that currently embeds.
    Bullets can now ricochet off walls, structures, and machinery (harder surfaces are more likely to ricochet). Only standard .38 and Match Grade .38/.357/L6 ammo can ricochet, with Match Grade being much better at ricocheting. You can buy Match Grade .38 from cargo and Match Grade L6 ammo from the nuke uplink, while Match .357 is admin only.
    Armor now protects you from harmful embeds, taking the better of the bullet/bomb armor on the affected limb. Armor penetration can modify this of course, and many blunt embeds like stingbangs and DumDum bullets are significantly worse if you have even 1 armor.

Other misc fixes/changes

    Refactored the embed element a bunch and fixed it creating new elements for every instance rather than expected bespoke behavior. There are new /obj/item helpers for modifying and adding embedding.
    Fixes #49989: Spears can no longer embed in turfs cause their sprite is annoying to me, it's generally harder for most things to embed in turfs
    Fixes #49741: New carbon helpers for removing embedded objects
    Fixes #46416: Handles embedded objects getting qdel'd or moved while embedded
    Renamed the old shrapnel component for RPG loot to MIRV to avoid confusion
    Repathed frag grenades from under minibombs to under base grenades, and added explosion vars to base grenades

Why It's Good For The Game

Fixes a bunch of janky design with embeds, adds lots of new avenues for projectile and grenade variety, ricochets and collateral damage are fun!
Changelog

🆑 Ryll/Shaps
add: Adds stingbangs to cargo (and one in the sec vendor premium), premium less-lethal grenades that shoot off a giant swarm of stingball pellets to help incapacitate swarms of people in tight quarters. You can jump on top of a live one to be a hero and absorb a bunch of shrapnel, same with frag grenades. There's even an achievement for dying to a grenade you jumped on!
add: Projectiles can now embed in people! Or at least grenade shrapnel and the new .38 DumDum ammo, now available in cargo, can. DumDum rounds excel against unarmored targets, but are pricey and do poorly against armored targets.
add: Bullets can now ricochet! Or at least, standard .38 and the new .38/L6 Match Grade ammo can. Match Grade ammo is finely tuned to ricochet easier and seek targets off bounces better, and can be purchased from cargo (for the .38) or nuke ops uplink (for the L6), but standard .38 ammo has a chance to ricochet as well.
tweak: Frag grenades now have smaller explosions but shoot off a bunch of devastating shrapnel, excellent for soft targets!
tweak: Shotguns and other multi-pellet guns now print aggregate messages, so you'll get one "You've been hit by 6 buckshot pellets!" rather than 6 "You've been hit by the buckshot pellet in the X!" messages. Bye bye lag!
balance: Armor can now protect against embedding weapons, taking the best of either the bullet or bomb armor for the limb in question away from the embed chance. Some weapons are better at piercing armor than others!
/🆑
2020-04-03 16:58:38 +13:00

711 lines
18 KiB
Plaintext

/*
Screen objects
Todo: improve/re-implement
Screen objects are only used for the hud and should not appear anywhere "in-game".
They are used with the client/screen list and the screen_loc var.
For more information, see the byond documentation on the screen_loc and screen vars.
*/
/obj/screen
name = ""
icon = 'icons/mob/screen_gen.dmi'
layer = HUD_LAYER
plane = HUD_PLANE
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF
appearance_flags = APPEARANCE_UI
var/obj/master = null //A reference to the object in the slot. Grabs or items, generally.
var/datum/hud/hud = null // A reference to the owner HUD, if any.
/obj/screen/take_damage()
return
/obj/screen/Destroy()
master = null
hud = null
return ..()
/obj/screen/examine(mob/user)
return list()
/obj/screen/orbit()
return
/obj/screen/proc/component_click(obj/screen/component_button/component, params)
return
/obj/screen/text
icon = null
icon_state = null
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
screen_loc = "CENTER-7,CENTER-7"
maptext_height = 480
maptext_width = 480
/obj/screen/swap_hand
layer = HUD_LAYER
plane = HUD_PLANE
name = "swap hand"
/obj/screen/swap_hand/Click()
// At this point in client Click() code we have passed the 1/10 sec check and little else
// We don't even know if it's a middle click
if(world.time <= usr.next_move)
return 1
if(usr.incapacitated())
return 1
if(ismob(usr))
var/mob/M = usr
M.swap_hand()
return 1
/obj/screen/skills
name = "skills"
icon = 'icons/mob/screen_midnight.dmi'
icon_state = "skills"
screen_loc = ui_skill_menu
/obj/screen/skills/Click()
if(ishuman(usr))
var/mob/living/carbon/human/H = usr
H.mind.print_levels(H)
/obj/screen/craft
name = "crafting menu"
icon = 'icons/mob/screen_midnight.dmi'
icon_state = "craft"
screen_loc = ui_crafting
/obj/screen/area_creator
name = "create new area"
icon = 'icons/mob/screen_midnight.dmi'
icon_state = "area_edit"
screen_loc = ui_building
/obj/screen/area_creator/Click()
if(usr.incapacitated() || (isobserver(usr) && !IsAdminGhost(usr)))
return TRUE
var/area/A = get_area(usr)
if(!A.outdoors)
to_chat(usr, "<span class='warning'>There is already a defined structure here.</span>")
return TRUE
create_area(usr)
/obj/screen/language_menu
name = "language menu"
icon = 'icons/mob/screen_midnight.dmi'
icon_state = "talk_wheel"
screen_loc = ui_language_menu
/obj/screen/language_menu/Click()
var/mob/M = usr
var/datum/language_holder/H = M.get_language_holder()
H.open_language_menu(usr)
/obj/screen/inventory
var/slot_id // The indentifier for the slot. It has nothing to do with ID cards.
var/icon_empty // Icon when empty. For now used only by humans.
var/icon_full // Icon when contains an item. For now used only by humans.
var/list/object_overlays = list()
layer = HUD_LAYER
plane = HUD_PLANE
/obj/screen/inventory/Click(location, control, params)
// At this point in client Click() code we have passed the 1/10 sec check and little else
// We don't even know if it's a middle click
if(world.time <= usr.next_move)
return TRUE
if(usr.incapacitated())
return TRUE
if(ismecha(usr.loc)) // stops inventory actions in a mech
return TRUE
if(hud?.mymob && slot_id)
var/obj/item/inv_item = hud.mymob.get_item_by_slot(slot_id)
if(inv_item)
return inv_item.Click(location, control, params)
if(usr.attack_ui(slot_id))
usr.update_inv_hands()
return TRUE
/obj/screen/inventory/MouseEntered()
..()
add_overlays()
/obj/screen/inventory/MouseExited()
..()
cut_overlay(object_overlays)
object_overlays.Cut()
/obj/screen/inventory/update_icon_state()
if(!icon_empty)
icon_empty = icon_state
if(hud?.mymob && slot_id && icon_full)
if(hud.mymob.get_item_by_slot(slot_id))
icon_state = icon_full
else
icon_state = icon_empty
/obj/screen/inventory/proc/add_overlays()
var/mob/user = hud?.mymob
if(!user || !slot_id)
return
var/obj/item/holding = user.get_active_held_item()
if(!holding || user.get_item_by_slot(slot_id))
return
var/image/item_overlay = image(holding)
item_overlay.alpha = 92
if(!user.can_equip(holding, slot_id, TRUE))
item_overlay.color = "#FF0000"
else
item_overlay.color = "#00ff00"
object_overlays += item_overlay
add_overlay(object_overlays)
/obj/screen/inventory/hand
var/mutable_appearance/handcuff_overlay
var/static/mutable_appearance/blocked_overlay = mutable_appearance('icons/mob/screen_gen.dmi', "blocked")
var/held_index = 0
/obj/screen/inventory/hand/update_overlays()
. = ..()
if(!handcuff_overlay)
var/state = (!(held_index % 2)) ? "markus" : "gabrielle"
handcuff_overlay = mutable_appearance('icons/mob/screen_gen.dmi', state)
if(!hud?.mymob)
return
if(iscarbon(hud.mymob))
var/mob/living/carbon/C = hud.mymob
if(C.handcuffed)
. += handcuff_overlay
if(held_index)
if(!C.has_hand_for_held_index(held_index))
. += blocked_overlay
if(held_index == hud.mymob.active_hand_index)
. += "hand_active"
/obj/screen/inventory/hand/Click(location, control, params)
// At this point in client Click() code we have passed the 1/10 sec check and little else
// We don't even know if it's a middle click
var/mob/user = hud?.mymob
if(usr != user)
return TRUE
if(world.time <= user.next_move)
return TRUE
if(user.incapacitated())
return TRUE
if (ismecha(user.loc)) // stops inventory actions in a mech
return TRUE
if(user.active_hand_index == held_index)
var/obj/item/I = user.get_active_held_item()
if(I)
I.Click(location, control, params)
else
user.swap_hand(held_index)
return TRUE
/obj/screen/close
name = "close"
layer = ABOVE_HUD_LAYER
plane = ABOVE_HUD_PLANE
icon_state = "backpack_close"
/obj/screen/close/Initialize(mapload, new_master)
. = ..()
master = new_master
/obj/screen/close/Click()
var/datum/component/storage/S = master
S.hide_from(usr)
return TRUE
/obj/screen/drop
name = "drop"
icon = 'icons/mob/screen_midnight.dmi'
icon_state = "act_drop"
layer = HUD_LAYER
plane = HUD_PLANE
/obj/screen/drop/Click()
if(usr.stat == CONSCIOUS)
usr.dropItemToGround(usr.get_active_held_item())
/obj/screen/act_intent
name = "intent"
icon_state = "help"
screen_loc = ui_acti
/obj/screen/act_intent/Click(location, control, params)
usr.a_intent_change(INTENT_HOTKEY_RIGHT)
/obj/screen/act_intent/segmented/Click(location, control, params)
if(usr.client.prefs.toggles & INTENT_STYLE)
var/_x = text2num(params2list(params)["icon-x"])
var/_y = text2num(params2list(params)["icon-y"])
if(_x<=16 && _y<=16)
usr.a_intent_change(INTENT_HARM)
else if(_x<=16 && _y>=17)
usr.a_intent_change(INTENT_HELP)
else if(_x>=17 && _y<=16)
usr.a_intent_change(INTENT_GRAB)
else if(_x>=17 && _y>=17)
usr.a_intent_change(INTENT_DISARM)
else
return ..()
/obj/screen/act_intent/alien
icon = 'icons/mob/screen_alien.dmi'
screen_loc = ui_movi
/obj/screen/act_intent/robot
icon = 'icons/mob/screen_cyborg.dmi'
screen_loc = ui_borg_intents
/obj/screen/internals
name = "toggle internals"
icon_state = "internal0"
screen_loc = ui_internal
/obj/screen/internals/Click()
if(!iscarbon(usr))
return
var/mob/living/carbon/C = usr
if(C.incapacitated())
return
if(C.internal)
C.internal = null
to_chat(C, "<span class='notice'>You are no longer running on internals.</span>")
icon_state = "internal0"
else
if(!C.getorganslot(ORGAN_SLOT_BREATHING_TUBE))
if(!istype(C.wear_mask, /obj/item/clothing/mask))
to_chat(C, "<span class='warning'>You are not wearing an internals mask!</span>")
return 1
else
var/obj/item/clothing/mask/M = C.wear_mask
if(M.mask_adjusted) // if mask on face but pushed down
M.adjustmask(C) // adjust it back
if( !(M.clothing_flags & MASKINTERNALS) )
to_chat(C, "<span class='warning'>You are not wearing an internals mask!</span>")
return
var/obj/item/I = C.is_holding_item_of_type(/obj/item/tank)
if(I)
to_chat(C, "<span class='notice'>You are now running on internals from [I] in your [C.get_held_index_name(C.get_held_index_of_item(I))].</span>")
C.internal = I
else if(ishuman(C))
var/mob/living/carbon/human/H = C
if(istype(H.s_store, /obj/item/tank))
to_chat(H, "<span class='notice'>You are now running on internals from [H.s_store] on your [H.wear_suit.name].</span>")
H.internal = H.s_store
else if(istype(H.belt, /obj/item/tank))
to_chat(H, "<span class='notice'>You are now running on internals from [H.belt] on your belt.</span>")
H.internal = H.belt
else if(istype(H.l_store, /obj/item/tank))
to_chat(H, "<span class='notice'>You are now running on internals from [H.l_store] in your left pocket.</span>")
H.internal = H.l_store
else if(istype(H.r_store, /obj/item/tank))
to_chat(H, "<span class='notice'>You are now running on internals from [H.r_store] in your right pocket.</span>")
H.internal = H.r_store
//Separate so CO2 jetpacks are a little less cumbersome.
if(!C.internal && istype(C.back, /obj/item/tank))
to_chat(C, "<span class='notice'>You are now running on internals from [C.back] on your back.</span>")
C.internal = C.back
if(C.internal)
icon_state = "internal1"
else
to_chat(C, "<span class='warning'>You don't have an oxygen tank!</span>")
return
C.update_action_buttons_icon()
/obj/screen/spacesuit
name = "Space suit cell status"
icon_state = "spacesuit_0"
screen_loc = ui_spacesuit
/obj/screen/mov_intent
name = "run/walk toggle"
icon = 'icons/mob/screen_midnight.dmi'
icon_state = "running"
/obj/screen/mov_intent/Click()
toggle(usr)
/obj/screen/mov_intent/update_icon_state()
switch(hud?.mymob?.m_intent)
if(MOVE_INTENT_WALK)
icon_state = "walking"
if(MOVE_INTENT_RUN)
icon_state = "running"
/obj/screen/mov_intent/proc/toggle(mob/user)
if(isobserver(user))
return
user.toggle_move_intent(user)
/obj/screen/pull
name = "stop pulling"
icon = 'icons/mob/screen_midnight.dmi'
icon_state = "pull"
/obj/screen/pull/Click()
if(isobserver(usr))
return
usr.stop_pulling()
/obj/screen/pull/update_icon_state()
if(hud?.mymob?.pulling)
icon_state = "pull"
else
icon_state = "pull0"
/obj/screen/resist
name = "resist"
icon = 'icons/mob/screen_midnight.dmi'
icon_state = "act_resist"
layer = HUD_LAYER
plane = HUD_PLANE
/obj/screen/resist/Click()
if(isliving(usr))
var/mob/living/L = usr
L.resist()
/obj/screen/rest
name = "rest"
icon = 'icons/mob/screen_midnight.dmi'
icon_state = "act_rest"
layer = HUD_LAYER
plane = HUD_PLANE
/obj/screen/rest/Click()
if(isliving(usr))
var/mob/living/L = usr
L.lay_down()
/obj/screen/rest/update_icon_state()
var/mob/living/user = hud?.mymob
if(!istype(user))
return
if(!user.resting)
icon_state = "act_rest"
else
icon_state = "act_rest0"
/obj/screen/storage
name = "storage"
icon_state = "block"
screen_loc = "7,7 to 10,8"
layer = HUD_LAYER
plane = HUD_PLANE
/obj/screen/storage/Initialize(mapload, new_master)
. = ..()
master = new_master
/obj/screen/storage/Click(location, control, params)
if(world.time <= usr.next_move)
return TRUE
if(usr.incapacitated())
return TRUE
if (ismecha(usr.loc)) // stops inventory actions in a mech
return TRUE
if(master)
var/obj/item/I = usr.get_active_held_item()
if(I)
master.attackby(null, I, usr, params)
return TRUE
/obj/screen/throw_catch
name = "throw/catch"
icon = 'icons/mob/screen_midnight.dmi'
icon_state = "act_throw_off"
/obj/screen/throw_catch/Click()
if(iscarbon(usr))
var/mob/living/carbon/C = usr
C.toggle_throw_mode()
/obj/screen/zone_sel
name = "damage zone"
icon_state = "zone_sel"
screen_loc = ui_zonesel
var/overlay_icon = 'icons/mob/screen_gen.dmi'
var/static/list/hover_overlays_cache = list()
var/hovering
/obj/screen/zone_sel/Click(location, control,params)
if(isobserver(usr))
return
var/list/PL = params2list(params)
var/icon_x = text2num(PL["icon-x"])
var/icon_y = text2num(PL["icon-y"])
var/choice = get_zone_at(icon_x, icon_y)
if (!choice)
return 1
return set_selected_zone(choice, usr)
/obj/screen/zone_sel/MouseEntered(location, control, params)
MouseMove(location, control, params)
/obj/screen/zone_sel/MouseMove(location, control, params)
if(isobserver(usr))
return
var/list/PL = params2list(params)
var/icon_x = text2num(PL["icon-x"])
var/icon_y = text2num(PL["icon-y"])
var/choice = get_zone_at(icon_x, icon_y)
if(hovering == choice)
return
vis_contents -= hover_overlays_cache[hovering]
hovering = choice
var/obj/effect/overlay/zone_sel/overlay_object = hover_overlays_cache[choice]
if(!overlay_object)
overlay_object = new
overlay_object.icon_state = "[choice]"
hover_overlays_cache[choice] = overlay_object
vis_contents += overlay_object
/obj/effect/overlay/zone_sel
icon = 'icons/mob/screen_gen.dmi'
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
alpha = 128
anchored = TRUE
layer = ABOVE_HUD_LAYER
plane = ABOVE_HUD_PLANE
/obj/screen/zone_sel/MouseExited(location, control, params)
if(!isobserver(usr) && hovering)
vis_contents -= hover_overlays_cache[hovering]
hovering = null
/obj/screen/zone_sel/proc/get_zone_at(icon_x, icon_y)
switch(icon_y)
if(1 to 9) //Legs
switch(icon_x)
if(10 to 15)
return BODY_ZONE_R_LEG
if(17 to 22)
return BODY_ZONE_L_LEG
if(10 to 13) //Hands and groin
switch(icon_x)
if(8 to 11)
return BODY_ZONE_R_ARM
if(12 to 20)
return BODY_ZONE_PRECISE_GROIN
if(21 to 24)
return BODY_ZONE_L_ARM
if(14 to 22) //Chest and arms to shoulders
switch(icon_x)
if(8 to 11)
return BODY_ZONE_R_ARM
if(12 to 20)
return BODY_ZONE_CHEST
if(21 to 24)
return BODY_ZONE_L_ARM
if(23 to 30) //Head, but we need to check for eye or mouth
if(icon_x in 12 to 20)
switch(icon_y)
if(23 to 24)
if(icon_x in 15 to 17)
return BODY_ZONE_PRECISE_MOUTH
if(26) //Eyeline, eyes are on 15 and 17
if(icon_x in 14 to 18)
return BODY_ZONE_PRECISE_EYES
if(25 to 27)
if(icon_x in 15 to 17)
return BODY_ZONE_PRECISE_EYES
return BODY_ZONE_HEAD
/obj/screen/zone_sel/proc/set_selected_zone(choice, mob/user)
if(user != hud?.mymob)
return
if(choice != hud.mymob.zone_selected)
hud.mymob.zone_selected = choice
update_icon()
return TRUE
/obj/screen/zone_sel/update_overlays()
. = ..()
if(!hud?.mymob)
return
. += mutable_appearance(overlay_icon, "[hud.mymob.zone_selected]")
/obj/screen/zone_sel/alien
icon = 'icons/mob/screen_alien.dmi'
overlay_icon = 'icons/mob/screen_alien.dmi'
/obj/screen/zone_sel/robot
icon = 'icons/mob/screen_cyborg.dmi'
/obj/screen/flash
name = "flash"
icon_state = "blank"
blend_mode = BLEND_ADD
screen_loc = "WEST,SOUTH to EAST,NORTH"
layer = FLASH_LAYER
plane = FULLSCREEN_PLANE
/obj/screen/damageoverlay
icon = 'icons/mob/screen_full.dmi'
icon_state = "oxydamageoverlay0"
name = "dmg"
blend_mode = BLEND_MULTIPLY
screen_loc = "CENTER-7,CENTER-7"
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
layer = UI_DAMAGE_LAYER
plane = FULLSCREEN_PLANE
/obj/screen/healths
name = "health"
icon_state = "health0"
screen_loc = ui_health
/obj/screen/healths/alien
icon = 'icons/mob/screen_alien.dmi'
screen_loc = ui_alien_health
/obj/screen/healths/robot
icon = 'icons/mob/screen_cyborg.dmi'
screen_loc = ui_borg_health
/obj/screen/healths/blob
name = "blob health"
icon_state = "block"
screen_loc = ui_internal
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
/obj/screen/healths/blob/naut
name = "health"
icon = 'icons/mob/blob.dmi'
icon_state = "nauthealth"
/obj/screen/healths/blob/naut/core
name = "overmind health"
icon_state = "corehealth"
screen_loc = ui_health
/obj/screen/healths/guardian
name = "summoner health"
icon = 'icons/mob/guardian.dmi'
icon_state = "base"
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
/obj/screen/healths/revenant
name = "essence"
icon = 'icons/mob/actions/backgrounds.dmi'
icon_state = "bg_revenant"
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
/obj/screen/healths/construct
icon = 'icons/mob/screen_construct.dmi'
icon_state = "artificer_health0"
screen_loc = ui_construct_health
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
/obj/screen/healthdoll
name = "health doll"
screen_loc = ui_healthdoll
/obj/screen/healthdoll/Click()
if (iscarbon(usr))
var/mob/living/carbon/C = usr
C.check_self_for_injuries()
/obj/screen/healthdoll/living
icon_state = "fullhealth0"
screen_loc = ui_living_healthdoll
var/filtered = FALSE //so we don't repeatedly create the mask of the mob every update
/obj/screen/mood
name = "mood"
icon_state = "mood5"
screen_loc = ui_mood
/obj/screen/splash
icon = 'icons/blank_title.png'
icon_state = ""
screen_loc = "1,1"
layer = SPLASHSCREEN_LAYER
plane = SPLASHSCREEN_PLANE
var/client/holder
/obj/screen/splash/New(client/C, visible, use_previous_title) //TODO: Make this use INITIALIZE_IMMEDIATE, except its not easy
. = ..()
holder = C
if(!visible)
alpha = 0
if(!use_previous_title)
if(SStitle.icon)
icon = SStitle.icon
else
if(!SStitle.previous_icon)
qdel(src)
return
icon = SStitle.previous_icon
holder.screen += src
/obj/screen/splash/proc/Fade(out, qdel_after = TRUE)
if(QDELETED(src))
return
if(out)
animate(src, alpha = 0, time = 30)
else
alpha = 0
animate(src, alpha = 255, time = 30)
if(qdel_after)
QDEL_IN(src, 30)
/obj/screen/splash/Destroy()
if(holder)
holder.screen -= src
holder = null
return ..()
/obj/screen/component_button
var/obj/screen/parent
/obj/screen/component_button/Initialize(mapload, obj/screen/parent)
. = ..()
src.parent = parent
/obj/screen/component_button/Click(params)
if(parent)
parent.component_click(src, params)