From 0d75ee8e6e025a29f970731d2dfd27f9d62c0aba Mon Sep 17 00:00:00 2001 From: ChungusGamer666 <82850673+ChungusGamer666@users.noreply.github.com> Date: Sun, 23 Apr 2023 20:26:17 -0300 Subject: [PATCH] Adds book burning (#74873) ## About The Pull Request For some reason, unlike other paper items, you couldn't ignite books with a lighter or other hot item. Now, you can! (Also made it so the odd obscure mechanic of cutting pages out of books can be done by any sharp item, not just wirecutters or knives) ## Why It's Good For The Game Consistency. ~~Burning copies of WGW.~~ ## Changelog :cl: add: Books can now be burned just like any other paper item. add: You can cut pages out of books with any sharp item, not just knives or wirecutters. /:cl: --------- Co-authored-by: san7890 --- code/modules/library/book.dm | 25 ++++++++++++++----------- code/modules/paperwork/paper.dm | 21 ++++++++++++--------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/code/modules/library/book.dm b/code/modules/library/book.dm index 23a5ecd4656..662d8417c68 100644 --- a/code/modules/library/book.dm +++ b/code/modules/library/book.dm @@ -139,9 +139,12 @@ user.visible_message(span_notice("[user] opens a book titled \"[book_data.title]\" and begins reading intently.")) on_read(user) -/obj/item/book/attackby(obj/item/I, mob/user, params) - if(istype(I, /obj/item/pen)) - if(!user.can_perform_action(src) || !user.can_write(I)) +/obj/item/book/attackby(obj/item/attacking_item, mob/user, params) + if(burn_paper_product_attackby_check(attacking_item, user)) + return + + if(istype(attacking_item, /obj/item/pen)) + if(!user.can_perform_action(src) || !user.can_write(attacking_item)) return if(user.is_blind()) to_chat(user, span_warning("As you are trying to write on the book, you suddenly feel very stupid!")) @@ -153,12 +156,12 @@ var/choice = tgui_input_list(usr, "What would you like to change?", "Book Alteration", list("Title", "Contents", "Author", "Cancel")) if(isnull(choice)) return - if(!user.can_perform_action(src) || !user.can_write(I)) + if(!user.can_perform_action(src) || !user.can_write(attacking_item)) return switch(choice) if("Title") var/newtitle = reject_bad_text(tgui_input_text(user, "Write a new title", "Book Title", max_length = 30)) - if(!user.can_perform_action(src) || !user.can_write(I)) + if(!user.can_perform_action(src) || !user.can_write(attacking_item)) return if (length_char(newtitle) > 30) to_chat(user, span_warning("That title won't fit on the cover!")) @@ -170,7 +173,7 @@ book_data.set_title(html_decode(newtitle)) //Don't want to double encode here if("Contents") var/content = tgui_input_text(user, "Write your book's contents (HTML NOT allowed)", "Book Contents", multiline = TRUE) - if(!user.can_perform_action(src) || !user.can_write(I)) + if(!user.can_perform_action(src) || !user.can_write(attacking_item)) return if(!content) to_chat(user, span_warning("The content is invalid.")) @@ -178,7 +181,7 @@ book_data.set_content(html_decode(content)) if("Author") var/author = tgui_input_text(user, "Write the author's name", "Author Name") - if(!user.can_perform_action(src) || !user.can_write(I)) + if(!user.can_perform_action(src) || !user.can_write(attacking_item)) return if(!author) to_chat(user, span_warning("The name is invalid.")) @@ -187,8 +190,8 @@ else return - else if(istype(I, /obj/item/barcodescanner)) - var/obj/item/barcodescanner/scanner = I + else if(istype(attacking_item, /obj/item/barcodescanner)) + var/obj/item/barcodescanner/scanner = attacking_item var/obj/machinery/computer/libraryconsole/bookmanagement/computer = scanner.computer_ref?.resolve() if(!computer) to_chat(user, span_alert("[scanner]'s screen flashes: 'No associated computer found!'")) @@ -219,7 +222,7 @@ computer.inventory_update() to_chat(user, span_notice("[scanner]'s screen flashes: 'Book stored in buffer. Title added to general inventory.'")) - else if((istype(I, /obj/item/knife) || I.tool_behaviour == TOOL_WIRECUTTER) && !(flags_1 & HOLOGRAM_1)) + else if(((attacking_item.sharpness & SHARP_EDGED) || (attacking_item.tool_behaviour == TOOL_KNIFE) || (attacking_item.tool_behaviour == TOOL_WIRECUTTER)) && !(flags_1 & HOLOGRAM_1)) to_chat(user, span_notice("You begin to carve out [book_data.title]...")) if(do_after(user, 30, target = src)) to_chat(user, span_notice("You carve out the pages from [book_data.title]! You didn't want to read it anyway.")) @@ -237,4 +240,4 @@ return return else - ..() + return ..() diff --git a/code/modules/paperwork/paper.dm b/code/modules/paperwork/paper.dm index b9e401f3127..c7c08ef0d46 100644 --- a/code/modules/paperwork/paper.dm +++ b/code/modules/paperwork/paper.dm @@ -351,25 +351,28 @@ return TRUE return ..() -/obj/item/proc/burn_paper_product_attackby_check(obj/item/I, mob/living/user, bypass_clumsy) - var/ignition_message = I.ignition_effect(src, user) +/obj/item/proc/burn_paper_product_attackby_check(obj/item/attacking_item, mob/living/user, bypass_clumsy = FALSE) + //can't be put on fire! + if((resistance_flags & FIRE_PROOF) || !(resistance_flags & FLAMMABLE)) + return FALSE + var/ignition_message = attacking_item.ignition_effect(src, user) if(!ignition_message) - return - . = TRUE + return FALSE if(!bypass_clumsy && HAS_TRAIT(user, TRAIT_CLUMSY) && prob(10) && Adjacent(user)) user.visible_message(span_warning("[user] accidentally ignites [user.p_them()]self!"), \ span_userdanger("You miss [src] and accidentally light yourself on fire!")) - if(user.is_holding(I)) //checking if they're holding it in case TK is involved - user.dropItemToGround(I) - user.adjust_fire_stacks(1) + if(user.is_holding(attacking_item)) //checking if they're holding it in case TK is involved + user.dropItemToGround(attacking_item) + user.adjust_fire_stacks(attacking_item) user.ignite_mob() - return + return TRUE if(user.is_holding(src)) //no TK shit here. user.dropItemToGround(src) user.visible_message(ignition_message) add_fingerprint(user) - fire_act(I.get_temperature()) + fire_act(attacking_item.get_temperature()) + return TRUE /obj/item/paper/attackby(obj/item/attacking_item, mob/living/user, params) if(burn_paper_product_attackby_check(attacking_item, user))