map conflict any%
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
#define BOOKCASE_UNANCHORED 0
|
||||
#define BOOKCASE_ANCHORED 1
|
||||
#define BOOKCASE_FINISHED 2
|
||||
|
||||
/* Library Items
|
||||
*
|
||||
* Contains:
|
||||
@@ -17,69 +21,85 @@
|
||||
desc = "A great place for storing knowledge."
|
||||
anchored = FALSE
|
||||
density = TRUE
|
||||
opacity = 0
|
||||
opacity = FALSE
|
||||
resistance_flags = FLAMMABLE
|
||||
max_integrity = 200
|
||||
armor = list("melee" = 0, "bullet" = 0, "laser" = 0, "energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 50, "acid" = 0)
|
||||
var/state = 0
|
||||
var/list/allowed_books = list(/obj/item/book, /obj/item/spellbook, /obj/item/storage/book, /obj/item/gun/magic/wand/book) //Things allowed in the bookcase
|
||||
var/state = BOOKCASE_UNANCHORED
|
||||
/// When enabled, books_to_load number of random books will be generated for this bookcase when first interacted with.
|
||||
var/load_random_books = FALSE
|
||||
/// The category of books to pick from when populating random books.
|
||||
var/random_category = null
|
||||
/// How many random books to generate.
|
||||
var/books_to_load = 0
|
||||
|
||||
/obj/structure/bookcase/examine(mob/user)
|
||||
. = ..()
|
||||
if(!anchored)
|
||||
. += "<span class='notice'>The <i>bolts</i> on the bottom are unsecured.</span>"
|
||||
if(anchored)
|
||||
else
|
||||
. += "<span class='notice'>It's secured in place with <b>bolts</b>.</span>"
|
||||
switch(state)
|
||||
if(0)
|
||||
if(BOOKCASE_UNANCHORED)
|
||||
. += "<span class='notice'>There's a <b>small crack</b> visible on the back panel.</span>"
|
||||
if(1)
|
||||
if(BOOKCASE_ANCHORED)
|
||||
. += "<span class='notice'>There's space inside for a <i>wooden</i> shelf.</span>"
|
||||
if(2)
|
||||
if(BOOKCASE_FINISHED)
|
||||
. += "<span class='notice'>There's a <b>small crack</b> visible on the shelf.</span>"
|
||||
|
||||
/obj/structure/bookcase/Initialize(mapload)
|
||||
. = ..()
|
||||
if(!mapload)
|
||||
return
|
||||
state = 2
|
||||
icon_state = "book-0"
|
||||
anchored = TRUE
|
||||
set_anchored(TRUE)
|
||||
state = BOOKCASE_FINISHED
|
||||
for(var/obj/item/I in loc)
|
||||
if(istype(I, /obj/item/book))
|
||||
I.forceMove(src)
|
||||
if(!isbook(I))
|
||||
continue
|
||||
I.forceMove(src)
|
||||
update_icon()
|
||||
|
||||
/obj/structure/bookcase/set_anchored(anchorvalue)
|
||||
. = ..()
|
||||
if(isnull(.))
|
||||
return
|
||||
state = anchorvalue
|
||||
if(!anchorvalue) //in case we were vareditted or uprooted by a hostile mob, ensure we drop all our books instead of having them disappear till we're rebuild.
|
||||
var/atom/Tsec = drop_location()
|
||||
for(var/obj/I in contents)
|
||||
if(!isbook(I))
|
||||
continue
|
||||
I.forceMove(Tsec)
|
||||
update_icon()
|
||||
|
||||
/obj/structure/bookcase/attackby(obj/item/I, mob/user, params)
|
||||
switch(state)
|
||||
if(0)
|
||||
if(istype(I, /obj/item/wrench))
|
||||
if(BOOKCASE_UNANCHORED)
|
||||
if(I.tool_behaviour == TOOL_WRENCH)
|
||||
if(I.use_tool(src, user, 20, volume=50))
|
||||
to_chat(user, "<span class='notice'>You wrench the frame into place.</span>")
|
||||
anchored = TRUE
|
||||
state = 1
|
||||
if(istype(I, /obj/item/crowbar))
|
||||
set_anchored(TRUE)
|
||||
else if(I.tool_behaviour == TOOL_CROWBAR)
|
||||
if(I.use_tool(src, user, 20, volume=50))
|
||||
to_chat(user, "<span class='notice'>You pry the frame apart.</span>")
|
||||
deconstruct(TRUE)
|
||||
|
||||
if(1)
|
||||
if(BOOKCASE_ANCHORED)
|
||||
if(istype(I, /obj/item/stack/sheet/mineral/wood))
|
||||
var/obj/item/stack/sheet/mineral/wood/W = I
|
||||
if(W.get_amount() >= 2)
|
||||
W.use(2)
|
||||
to_chat(user, "<span class='notice'>You add a shelf.</span>")
|
||||
state = 2
|
||||
icon_state = "book-0"
|
||||
if(istype(I, /obj/item/wrench))
|
||||
state = BOOKCASE_FINISHED
|
||||
update_icon()
|
||||
else if(I.tool_behaviour == TOOL_WRENCH)
|
||||
I.play_tool_sound(src, 100)
|
||||
to_chat(user, "<span class='notice'>You unwrench the frame.</span>")
|
||||
anchored = FALSE
|
||||
state = 0
|
||||
set_anchored(FALSE)
|
||||
|
||||
if(2)
|
||||
if(BOOKCASE_FINISHED)
|
||||
var/datum/component/storage/STR = I.GetComponent(/datum/component/storage)
|
||||
if(is_type_in_list(I, allowed_books))
|
||||
if(isbook(I))
|
||||
if(!user.transferItemToLoc(I, src))
|
||||
return
|
||||
update_icon()
|
||||
@@ -100,26 +120,29 @@
|
||||
return
|
||||
else
|
||||
name = "bookcase ([sanitize(newname)])"
|
||||
else if(istype(I, /obj/item/crowbar))
|
||||
else if(I.tool_behaviour == TOOL_CROWBAR)
|
||||
if(contents.len)
|
||||
to_chat(user, "<span class='warning'>You need to remove the books first!</span>")
|
||||
else
|
||||
I.play_tool_sound(src, 100)
|
||||
to_chat(user, "<span class='notice'>You pry the shelf out.</span>")
|
||||
new /obj/item/stack/sheet/mineral/wood(drop_location(), 2)
|
||||
state = 1
|
||||
icon_state = "bookempty"
|
||||
state = BOOKCASE_ANCHORED
|
||||
update_icon()
|
||||
else
|
||||
return ..()
|
||||
|
||||
/obj/structure/bookcase/on_attack_hand(mob/living/user, act_intent = user.a_intent, unarmed_attack_flags)
|
||||
. = ..()
|
||||
if(. || !istype(user))
|
||||
|
||||
/obj/structure/bookcase/on_attack_hand(mob/living/user)
|
||||
if(!istype(user))
|
||||
return
|
||||
if(load_random_books)
|
||||
create_random_books(books_to_load, src, FALSE, random_category)
|
||||
load_random_books = FALSE
|
||||
if(contents.len)
|
||||
var/obj/item/book/choice = input("Which book would you like to remove from the shelf?") as null|obj in contents
|
||||
var/obj/item/book/choice = input(user, "Which book would you like to remove from the shelf?") as null|obj in sortNames(contents.Copy())
|
||||
if(choice)
|
||||
if(!CHECK_MOBILITY(user, MOBILITY_USE) || !in_range(loc, user))
|
||||
if(!(user.mobility_flags & MOBILITY_USE) || user.stat != CONSCIOUS || !in_range(loc, user))
|
||||
return
|
||||
if(ishuman(user))
|
||||
if(!user.get_active_held_item())
|
||||
@@ -128,36 +151,25 @@
|
||||
choice.forceMove(drop_location())
|
||||
update_icon()
|
||||
|
||||
/obj/structure/bookcase/attack_ghost(mob/dead/observer/user)
|
||||
. = ..()
|
||||
if(!length(contents))
|
||||
to_chat(user, "<span class='warning'>It's empty!</span>")
|
||||
return
|
||||
var/obj/item/book/choice = input("Which book would you like to read?") as null|obj in contents
|
||||
if(choice)
|
||||
if(!istype(choice)) //spellbook, cult tome, or the one weird bible storage
|
||||
to_chat(user,"A mysterious force is keeping you from reading that.")
|
||||
return
|
||||
choice.attack_ghost(user)
|
||||
|
||||
/obj/structure/bookcase/deconstruct(disassembled = TRUE)
|
||||
new /obj/item/stack/sheet/mineral/wood(loc, 4)
|
||||
for(var/obj/item/book/B in contents)
|
||||
B.forceMove(get_turf(src))
|
||||
qdel(src)
|
||||
var/atom/Tsec = drop_location()
|
||||
new /obj/item/stack/sheet/mineral/wood(Tsec, 4)
|
||||
for(var/obj/item/I in contents)
|
||||
if(!isbook(I))
|
||||
continue
|
||||
I.forceMove(Tsec)
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/structure/bookcase/update_icon_state()
|
||||
icon_state = "book-[min(length(contents), 5)]"
|
||||
|
||||
|
||||
/obj/structure/bookcase/manuals/medical
|
||||
name = "medical manuals bookcase"
|
||||
|
||||
/obj/structure/bookcase/manuals/medical/Initialize()
|
||||
. = ..()
|
||||
new /obj/item/book/manual/wiki/medical_cloning(src)
|
||||
update_icon()
|
||||
if(state == BOOKCASE_UNANCHORED || state == BOOKCASE_ANCHORED)
|
||||
icon_state = "bookempty"
|
||||
return
|
||||
var/amount = contents.len
|
||||
if(load_random_books)
|
||||
amount += books_to_load
|
||||
icon_state = "book-[clamp(amount, 0, 5)]"
|
||||
|
||||
|
||||
/obj/structure/bookcase/manuals/engineering
|
||||
@@ -198,34 +210,27 @@
|
||||
var/dat //Actual page content
|
||||
var/due_date = 0 //Game time in 1/10th seconds
|
||||
var/author //Who wrote the thing, can be changed by pen or PC. It is not automatically assigned
|
||||
var/unique = 0 //0 - Normal book, 1 - Should not be treated as normal book, unable to be copied, unable to be modified
|
||||
var/unique = FALSE //false - Normal book, true - Should not be treated as normal book, unable to be copied, unable to be modified
|
||||
var/title //The real name of the book.
|
||||
var/window_size = null // Specific window size for the book, i.e: "1920x1080", Size x Width
|
||||
|
||||
|
||||
/obj/item/book/attack_self(mob/user)
|
||||
if(is_blind(user))
|
||||
to_chat(user, "<span class='warning'>As you are trying to read, you suddenly feel very stupid!</span>")
|
||||
return
|
||||
if(ismonkey(user))
|
||||
to_chat(user, "<span class='notice'>You skim through the book but can't comprehend any of it.</span>")
|
||||
if(!user.can_read(src))
|
||||
return
|
||||
if(dat)
|
||||
show_to(user)
|
||||
user.visible_message("[user] opens a book titled \"[title]\" and begins reading intently.")
|
||||
user << browse("<TT><I>Penned by [author].</I></TT> <BR>" + "[dat]", "window=book[window_size != null ? ";size=[window_size]" : ""]")
|
||||
user.visible_message("<span class='notice'>[user] opens a book titled \"[title]\" and begins reading intently.</span>")
|
||||
// SEND_SIGNAL(user, COMSIG_ADD_MOOD_EVENT, "book_nerd", /datum/mood_event/book_nerd)
|
||||
onclose(user, "book")
|
||||
else
|
||||
to_chat(user, "<span class='notice'>This book is completely blank!</span>")
|
||||
|
||||
/obj/item/book/attack_ghost(mob/dead/observer/O)
|
||||
. = ..()
|
||||
show_to(O)
|
||||
|
||||
/obj/item/book/proc/show_to(mob/user)
|
||||
user << browse("<TT><I>Penned by [author].</I></TT> <BR>" + "[dat]", "window=book[window_size != null ? ";size=[window_size]" : ""]")
|
||||
|
||||
/obj/item/book/attackby(obj/item/I, mob/user, params)
|
||||
if(istype(I, /obj/item/pen))
|
||||
if(is_blind(user))
|
||||
to_chat(user, "<span class='warning'> As you are trying to write on the book, you suddenly feel very stupid!</span>")
|
||||
if(user.is_blind())
|
||||
to_chat(user, "<span class='warning'>As you are trying to write on the book, you suddenly feel very stupid!</span>")
|
||||
return
|
||||
if(unique)
|
||||
to_chat(user, "<span class='warning'>These pages don't seem to take the ink well! Looks like you can't modify it.</span>")
|
||||
@@ -243,10 +248,10 @@
|
||||
if(!user.canUseTopic(src, BE_CLOSE, literate))
|
||||
return
|
||||
if (length(newtitle) > 20)
|
||||
to_chat(user, "That title won't fit on the cover!")
|
||||
to_chat(user, "<span class='warning'>That title won't fit on the cover!</span>")
|
||||
return
|
||||
if(!newtitle)
|
||||
to_chat(user, "That title is invalid.")
|
||||
to_chat(user, "<span class='warning'>That title is invalid.</span>")
|
||||
return
|
||||
else
|
||||
name = newtitle
|
||||
@@ -256,7 +261,7 @@
|
||||
if(!user.canUseTopic(src, BE_CLOSE, literate))
|
||||
return
|
||||
if(!content)
|
||||
to_chat(user, "The content is invalid.")
|
||||
to_chat(user, "<span class='warning'>The content is invalid.</span>")
|
||||
return
|
||||
else
|
||||
dat += content
|
||||
@@ -265,7 +270,7 @@
|
||||
if(!user.canUseTopic(src, BE_CLOSE, literate))
|
||||
return
|
||||
if(!newauthor)
|
||||
to_chat(user, "The name is invalid.")
|
||||
to_chat(user, "<span class='warning'>The name is invalid.</span>")
|
||||
return
|
||||
else
|
||||
author = newauthor
|
||||
@@ -275,34 +280,34 @@
|
||||
else if(istype(I, /obj/item/barcodescanner))
|
||||
var/obj/item/barcodescanner/scanner = I
|
||||
if(!scanner.computer)
|
||||
to_chat(user, "[I]'s screen flashes: 'No associated computer found!'")
|
||||
to_chat(user, "<span class='alert'>[I]'s screen flashes: 'No associated computer found!'</span>")
|
||||
else
|
||||
switch(scanner.mode)
|
||||
if(0)
|
||||
scanner.book = src
|
||||
to_chat(user, "[I]'s screen flashes: 'Book stored in buffer.'")
|
||||
to_chat(user, "<span class='notice'>[I]'s screen flashes: 'Book stored in buffer.'</span>")
|
||||
if(1)
|
||||
scanner.book = src
|
||||
scanner.computer.buffer_book = name
|
||||
to_chat(user, "[I]'s screen flashes: 'Book stored in buffer. Book title stored in associated computer buffer.'")
|
||||
to_chat(user, "<span class='notice'>[I]'s screen flashes: 'Book stored in buffer. Book title stored in associated computer buffer.'</span>")
|
||||
if(2)
|
||||
scanner.book = src
|
||||
for(var/datum/borrowbook/b in scanner.computer.checkouts)
|
||||
if(b.bookname == name)
|
||||
scanner.computer.checkouts.Remove(b)
|
||||
to_chat(user, "[I]'s screen flashes: 'Book stored in buffer. Book has been checked in.'")
|
||||
to_chat(user, "<span class='notice'>[I]'s screen flashes: 'Book stored in buffer. Book has been checked in.'</span>")
|
||||
return
|
||||
to_chat(user, "[I]'s screen flashes: 'Book stored in buffer. No active check-out record found for current title.'")
|
||||
to_chat(user, "<span class='notice'>[I]'s screen flashes: 'Book stored in buffer. No active check-out record found for current title.'</span>")
|
||||
if(3)
|
||||
scanner.book = src
|
||||
for(var/obj/item/book in scanner.computer.inventory)
|
||||
if(book == src)
|
||||
to_chat(user, "[I]'s screen flashes: 'Book stored in buffer. Title already present in inventory, aborting to avoid duplicate entry.'")
|
||||
to_chat(user, "<span class='alert'>[I]'s screen flashes: 'Book stored in buffer. Title already present in inventory, aborting to avoid duplicate entry.'</span>")
|
||||
return
|
||||
scanner.computer.inventory.Add(src)
|
||||
to_chat(user, "[I]'s screen flashes: 'Book stored in buffer. Title added to general inventory.'")
|
||||
to_chat(user, "<span class='notice'>[I]'s screen flashes: 'Book stored in buffer. Title added to general inventory.'</span>")
|
||||
|
||||
else if(istype(I, /obj/item/kitchen/knife) || istype(I, /obj/item/wirecutters))
|
||||
else if(istype(I, /obj/item/kitchen/knife) || I.tool_behaviour == TOOL_WIRECUTTER)
|
||||
to_chat(user, "<span class='notice'>You begin to carve out [title]...</span>")
|
||||
if(do_after(user, 30, target = src))
|
||||
to_chat(user, "<span class='notice'>You carve out the pages from [title]! You didn't want to read it anyway.</span>")
|
||||
@@ -361,3 +366,8 @@
|
||||
else
|
||||
to_chat(user, "<font color=red>No associated computer found. Only local scans will function properly.</font>")
|
||||
to_chat(user, "\n")
|
||||
|
||||
|
||||
#undef BOOKCASE_UNANCHORED
|
||||
#undef BOOKCASE_ANCHORED
|
||||
#undef BOOKCASE_FINISHED
|
||||
|
||||
Reference in New Issue
Block a user