[MIRROR] Adds book burning [MDB IGNORE] (#20727)

* 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

🆑
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.
/🆑

---------

Co-authored-by: san7890 <the@ san7890.com>

* Adds book burning

---------

Co-authored-by: ChungusGamer666 <82850673+ChungusGamer666@users.noreply.github.com>
Co-authored-by: san7890 <the@ san7890.com>
This commit is contained in:
SkyratBot
2023-04-23 21:48:48 -04:00
committed by GitHub
co-authored by san7890 ChungusGamer666
parent 8c7492cd29
commit 08f12c62e7
2 changed files with 26 additions and 20 deletions
+14 -11
View File
@@ -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 ..()
+12 -9
View File
@@ -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))