-
Notifications
You must be signed in to change notification settings - Fork 565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Desk Bell #5330
Closed
Closed
Desk Bell #5330
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9450436
adds bell and underlying code
Birdtalon 91a98af
adds to almayer + cooldown
Birdtalon 08362f6
spans and wrenching message
Birdtalon f0b642d
sounds
Birdtalon d287159
unneeded check
Birdtalon 8894b8e
few more code changes, cooldown declare, punctuation, adds a few more…
Birdtalon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// A receptionist's bell | ||
|
||
/obj/item/desk_bell | ||
name = "desk bell" | ||
desc = "The cornerstone of any customer service job. You feel an unending urge to ring it." | ||
icon = 'icons/obj/objects.dmi' | ||
icon_state = "desk_bell" | ||
w_class = SIZE_SMALL | ||
embeddable = FALSE | ||
/// The amount of times this bell has been rang, used to check the chance it breaks. | ||
var/times_rang = 0 | ||
/// Is this bell broken? | ||
var/broken_ringer = FALSE | ||
/// Holds the time that the bell can next be rang. | ||
COOLDOWN_DECLARE(ring_cooldown) | ||
/// The length of the cooldown. Setting it to 0 will skip all cooldowns alltogether. | ||
var/ring_cooldown_length = 1 SECONDS // This is here to protect against tinnitus. | ||
/// The sound the bell makes. | ||
var/ring_sound = 'sound/misc/desk_bell.ogg' | ||
|
||
/obj/item/desk_bell/attack_hand(mob/living/user) | ||
if(!ishuman(user)) | ||
return FALSE | ||
if(!anchored) | ||
return ..() | ||
if(!COOLDOWN_FINISHED(src, ring_cooldown)) | ||
return FALSE | ||
if(!ring_bell(user)) | ||
to_chat(user, SPAN_NOTICE("[src] is silent. Some idiot broke it.")) | ||
return FALSE | ||
return TRUE | ||
|
||
/obj/item/desk_bell/MouseDrop(atom/over_object) | ||
var/mob/mob = usr | ||
if(!Adjacent(mob) || anchored) | ||
return | ||
if(!ishuman(mob)) | ||
return | ||
|
||
if(over_object == mob) | ||
mob.put_in_hands(src) | ||
|
||
/obj/item/desk_bell/attackby(obj/item/item, mob/user) | ||
//Repair the desk bell if its broken and we're using a screwdriver. | ||
if(HAS_TRAIT(item, TRAIT_TOOL_SCREWDRIVER)) | ||
if(broken_ringer) | ||
visible_message(SPAN_NOTICE("[user] begins repairing [src]..."), SPAN_NOTICE("You begin repairing [src]...")) | ||
if(do_after(user, 5 SECONDS, INTERRUPT_ALL, BUSY_ICON_GENERIC)) | ||
user.visible_message(SPAN_NOTICE("[user] repairs [src]."), SPAN_NOTICE("You repair [src].")) | ||
playsound(src, 'sound/items/Screwdriver.ogg', 50) | ||
broken_ringer = FALSE | ||
times_rang = 0 | ||
return TRUE | ||
return FALSE | ||
|
||
//Return at this point if we're not on a turf so we don't anchor or unanchor inside our bag/hands or inventory. | ||
if(!isturf(loc)) | ||
return | ||
|
||
//Wrenching down and unwrenching. | ||
if(HAS_TRAIT(item, TRAIT_TOOL_WRENCH)) | ||
if(user.a_intent == INTENT_HARM) | ||
visible_message(SPAN_NOTICE("[user] begins taking apart [src]..."), SPAN_NOTICE("You begin taking apart [src]...")) | ||
playsound(src, 'sound/items/deconstruct.ogg', 35) | ||
if(do_after(user, 5 SECONDS, INTERRUPT_ALL, BUSY_ICON_GENERIC)) | ||
visible_message(SPAN_NOTICE("[user] takes apart [src]."), SPAN_NOTICE("You take apart [src].")) | ||
new /obj/item/stack/sheet/metal(get_turf(src)) | ||
qdel(src) | ||
return TRUE | ||
else | ||
user.visible_message("[user] begins [anchored ? "un" : ""]securing [src]...", "You begin [anchored ? "un" : ""]securing [src]...") | ||
playsound(src, 'sound/items/Ratchet.ogg', 35, vary = TRUE) | ||
if(!do_after(user, 2 SECONDS, INTERRUPT_ALL, BUSY_ICON_GENERIC)) | ||
return FALSE | ||
user.visible_message("[user] [anchored ? "un" : ""]secures [src].", "You [anchored ? "un" : ""]secure [src].") | ||
anchored = !anchored | ||
return TRUE | ||
|
||
|
||
/// Check if the clapper breaks, and if it does, break it chance to break is 1% for every 100 rings of the bell. | ||
/obj/item/desk_bell/proc/check_clapper(mob/living/user) | ||
if(prob(times_rang / 100)) | ||
to_chat(user, SPAN_NOTICE("You hear [src]'s clapper fall off of its hinge. Nice job hamfist, you broke it.")) | ||
broken_ringer = TRUE | ||
|
||
/// Ring the bell. | ||
/obj/item/desk_bell/proc/ring_bell(mob/living/user) | ||
if(broken_ringer) | ||
return FALSE | ||
check_clapper(user) | ||
// The lack of varying is intentional. The only variance occurs on the strike the bell breaks. | ||
COOLDOWN_START(src, ring_cooldown, ring_cooldown_length) | ||
playsound(src, ring_sound, 80) | ||
flick("desk_bell_activate", src) | ||
times_rang++ | ||
return TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm