some modules things
This commit is contained in:
@@ -1,22 +1,40 @@
|
||||
#define SOAPSTONE_PREFIX_FILE "strings/soapstone_prefixes.txt"
|
||||
#define SOAPSTONE_SUFFIX_FILE "soapstone_suffixes.json"
|
||||
//Vocabulary lists; soapstones use a prefix and a suffix. Optionally, they can have a prefix and suffix, then a conjunction that links another set.
|
||||
var/global/list/soapstone_prefixes = list() //Read from "strings/soapstone_prefixes.txt"; if you're adding your own, put **** where the subject should be!
|
||||
var/global/list/soapstone_suffixes = list() //Read from "strings/soapstone_suffixes.json"
|
||||
/obj/item/soapstone
|
||||
name = "chisel"
|
||||
desc = "Leave informative messages for the crew, including the crew of future shifts!\nEven if out of uses, it can still be used to remove messages.\n(Not suitable for engraving on shuttles, off station or on cats. Side effects may include beatings, bannings and orbital bombardment.)"
|
||||
desc = "Leave \"informative\" messages for the crew, including the crew of future shifts!\n\
|
||||
(Not suitable for engraving on shuttles, off station or on cats. Side effects may include beatings, bannings and orbital bombardment.)"
|
||||
icon = 'icons/obj/items.dmi'
|
||||
icon_state = "soapstone"
|
||||
throw_speed = 3
|
||||
throw_range = 5
|
||||
w_class = WEIGHT_CLASS_TINY
|
||||
var/tool_speed = 50
|
||||
var/remaining_uses = 3
|
||||
|
||||
var/non_dull_name
|
||||
var/w_engrave = "engrave"
|
||||
var/w_engraving = "engraving"
|
||||
var/w_chipping = "chipping"
|
||||
var/w_dull = "dull"
|
||||
|
||||
/obj/item/soapstone/New()
|
||||
. = ..()
|
||||
if(!soapstone_prefixes.len)
|
||||
soapstone_prefixes = file2list(SOAPSTONE_PREFIX_FILE, "\n")
|
||||
if(!soapstone_suffixes.len)
|
||||
soapstone_suffixes = list(\
|
||||
"Characters" = strings(SOAPSTONE_SUFFIX_FILE, "Characters"), \
|
||||
"Careers" = strings(SOAPSTONE_SUFFIX_FILE, "Careers"), \
|
||||
"Antagonists" = strings(SOAPSTONE_SUFFIX_FILE, "Antagonists"), \
|
||||
"Objects" = strings(SOAPSTONE_SUFFIX_FILE, "Objects"), \
|
||||
"Techniques" = strings(SOAPSTONE_SUFFIX_FILE, "Techniques"), \
|
||||
"Actions" = strings(SOAPSTONE_SUFFIX_FILE, "Actions"), \
|
||||
"Geography" = strings(SOAPSTONE_SUFFIX_FILE, "Geography"), \
|
||||
"Orientation" = strings(SOAPSTONE_SUFFIX_FILE, "Orientation"), \
|
||||
"Body parts" = strings(SOAPSTONE_SUFFIX_FILE, "Body parts"), \
|
||||
"Concepts" = strings(SOAPSTONE_SUFFIX_FILE, "Concepts"), \
|
||||
"Musings" = strings(SOAPSTONE_SUFFIX_FILE, "Musings"), \
|
||||
)
|
||||
random_name()
|
||||
check_name() // could start empty
|
||||
|
||||
@@ -25,9 +43,6 @@
|
||||
non_dull_name = name
|
||||
if(name == "chalk" || name == "magic marker")
|
||||
desc = replacetext(desc, "engraving", "scribbling")
|
||||
w_engrave = "scribble"
|
||||
w_engraving = "scribbling"
|
||||
w_chipping = "sketching"
|
||||
if(name == "chalk")
|
||||
w_dull = "used"
|
||||
if(name == "magic marker")
|
||||
@@ -35,9 +50,6 @@
|
||||
|
||||
if(name == "soapstone" || name == "chisel")
|
||||
desc = replacetext(desc, "scribbling", "engraving")
|
||||
w_engrave = initial(w_engrave)
|
||||
w_engraving = initial(w_engraving)
|
||||
w_chipping = initial(w_chipping)
|
||||
w_dull = "dull"
|
||||
|
||||
/obj/item/soapstone/examine(mob/user)
|
||||
@@ -48,59 +60,48 @@
|
||||
user << "It looks like it can be used an unlimited number of times."
|
||||
|
||||
/obj/item/soapstone/afterattack(atom/target, mob/user, proximity)
|
||||
if(!remaining_uses)
|
||||
user << "<span class='warning'>[src] is [w_dull] and can't be used anymore!</span>"
|
||||
return
|
||||
var/turf/T = get_turf(target)
|
||||
if(!proximity)
|
||||
return
|
||||
|
||||
|
||||
var/obj/structure/chisel_message/already_message = locate(/obj/structure/chisel_message) in T
|
||||
|
||||
var/our_message = FALSE
|
||||
if(already_message)
|
||||
our_message = already_message.creator_key == user.ckey
|
||||
|
||||
if(!remaining_uses && !already_message)
|
||||
// The dull chisel is dull.
|
||||
user << "<span class='warning'>[src] is [w_dull].</span>"
|
||||
return
|
||||
|
||||
if(!good_chisel_message_location(T))
|
||||
user << "<span class='warning'>It's not appropriate to [w_engrave] on [T].</span>"
|
||||
return
|
||||
|
||||
if(already_message)
|
||||
user.visible_message("<span class='notice'>[user] starts erasing [already_message].</span>", "<span class='notice'>You start erasing [already_message].</span>", "<span class='italics'>You hear a [w_chipping] sound.</span>")
|
||||
playsound(loc, 'sound/items/gavel.ogg', 50, 1, -1)
|
||||
|
||||
// Removing our own messages refunds a charge
|
||||
|
||||
if(do_after(user, tool_speed, target=target))
|
||||
user.visible_message("<span class='notice'>[user] has erased [already_message].</span>", "<span class='notice'>You erased [already_message].</span>")
|
||||
already_message.persists = FALSE
|
||||
qdel(already_message)
|
||||
playsound(loc, 'sound/items/gavel.ogg', 50, 1, -1)
|
||||
if(our_message)
|
||||
var/obj/structure/chisel_message/msg = locate() in T
|
||||
if(msg)
|
||||
if(msg.creator_key != user.ckey)
|
||||
user << "<span class='warning'>There's already a message there!</span>"
|
||||
return
|
||||
else
|
||||
if(alert(user, "Erase this message?", name, "Yes", "No") == "Yes")
|
||||
user.visible_message("<span class='notice'>[user] erases [msg].</span>", "<span class='notice'>You permanently erase [msg].</span>")
|
||||
playsound(T, 'sound/items/gavel.ogg', 50, 1)
|
||||
refund_use()
|
||||
msg.persists = 0
|
||||
qdel(msg)
|
||||
return
|
||||
return
|
||||
if(!good_chisel_message_location(T))
|
||||
user << "<span class='warning'>You can't write there!</span>"
|
||||
return
|
||||
|
||||
var/message = stripped_input(user, "What would you like to [w_engrave]?", "[name] Message")
|
||||
if(!message)
|
||||
user << "You decide not to [w_engrave] anything."
|
||||
var/prefix = input(user, "Choose a prefix for your message.", name) as null|anything in soapstone_prefixes
|
||||
if(!prefix)
|
||||
return
|
||||
|
||||
if(!target.Adjacent(user) && locate(/obj/structure/chisel_message) in T)
|
||||
user << "You decide not to [w_engrave] anything."
|
||||
var/suffix_category_string = input(user, "Choose a suffix category.", "[prefix]...") as null|anything in soapstone_suffixes
|
||||
var/list/suffix_category = soapstone_suffixes[suffix_category_string]
|
||||
if(!suffix_category || !suffix_category.len)
|
||||
return
|
||||
|
||||
playsound(loc, 'sound/items/gavel.ogg', 50, 1, -1)
|
||||
user.visible_message("<span class='notice'>[user] starts [w_engraving] a message into [T].</span>", "You start [w_engraving] a message into [T].", "<span class='italics'>You hear a [w_chipping] sound.</span>")
|
||||
if(can_use() && do_after(user, tool_speed, target=T) && can_use())
|
||||
if(!locate(/obj/structure/chisel_message in T))
|
||||
user << "You [w_engrave] a message into [T]."
|
||||
playsound(loc, 'sound/items/gavel.ogg', 50, 1, -1)
|
||||
var/obj/structure/chisel_message/M = new(T)
|
||||
M.register(user, message)
|
||||
remove_use()
|
||||
var/suffix = input(user, "Choose a suffix.", "[prefix]...") as null|anything in suffix_category
|
||||
if(!suffix)
|
||||
return
|
||||
var/processed_message = replacetext(prefix, "****", suffix)
|
||||
if(!user.Adjacent(T) || !good_chisel_message_location(T) || locate(/obj/structure/chisel_message) in T)
|
||||
return
|
||||
user.visible_message("<span class='notice'>[user] writes a message onto [T]!</span>", "<span class='notice'>You write a message onto [T].</span>")
|
||||
playsound(T, 'sound/items/gavel.ogg', 50, 1)
|
||||
var/obj/structure/chisel_message/M = new(T)
|
||||
M.register(user, processed_message)
|
||||
remove_use()
|
||||
return 1
|
||||
|
||||
/obj/item/soapstone/proc/can_use()
|
||||
if(remaining_uses == -1 || remaining_uses >= 0)
|
||||
@@ -171,6 +172,34 @@
|
||||
var/map
|
||||
var/persists = TRUE
|
||||
|
||||
var/positive_ratings = 0
|
||||
var/negative_ratings = 0
|
||||
|
||||
var/list/raters = list() //Ckeys who have rated this message
|
||||
|
||||
/obj/structure/chisel_message/attack_hand(mob/user)
|
||||
if(user.ckey == creator_key)
|
||||
user << "<span class='warning'>You can't rate your own messages!</span>"
|
||||
return
|
||||
if(raters[user.ckey])
|
||||
user << "<span class='warning'>You've already rated this message!</span>"
|
||||
return
|
||||
switch(alert(user, "How would you like to rate this message?", "Message Rating", "Positive", "Negative", "Cancel"))
|
||||
if("Positive")
|
||||
for(var/client/C in clients)
|
||||
if(C.ckey == creator_key)
|
||||
C.mob << "<span class='notice'>One of your messages was rated as positive!</span>"
|
||||
user << "<span class='noticealien'>You rated this message as positive.</span>"
|
||||
positive_ratings++
|
||||
raters[user.ckey] = "positive"
|
||||
if("Negative")
|
||||
for(var/client/C in clients)
|
||||
if(C.ckey == creator_key)
|
||||
C.mob << "<span class='danger'>One of your messages was rated as negative!</span>"
|
||||
user << "<span class='danger'>You rated this message as negative.</span>"
|
||||
negative_ratings++
|
||||
raters[user.ckey] = "negative"
|
||||
|
||||
/obj/structure/chisel_message/New(newloc)
|
||||
..()
|
||||
SSpersistence.chisel_messages += src
|
||||
@@ -190,12 +219,6 @@
|
||||
map = MAP_NAME
|
||||
update_icon()
|
||||
|
||||
/obj/structure/chisel_message/update_icon()
|
||||
..()
|
||||
var/hash = md5(hidden_message)
|
||||
var/newcolor = copytext(hash, 1, 7)
|
||||
add_atom_colour("#[newcolor]", FIXED_COLOUR_PRIORITY)
|
||||
|
||||
/obj/structure/chisel_message/proc/pack()
|
||||
var/list/data = list()
|
||||
data["hidden_message"] = hidden_message
|
||||
@@ -206,6 +229,9 @@
|
||||
var/turf/T = get_turf(src)
|
||||
data["x"] = T.x
|
||||
data["y"] = T.y
|
||||
data["pos_ratings"] = positive_ratings
|
||||
data["neg_ratings"] = positive_ratings
|
||||
data["raters"] = raters
|
||||
return data
|
||||
|
||||
/obj/structure/chisel_message/proc/unpack(list/data)
|
||||
@@ -213,6 +239,9 @@
|
||||
creator_name = data["creator_name"]
|
||||
creator_key = data["creator_key"]
|
||||
realdate = data["realdate"]
|
||||
positive_ratings = data["pos_ratings"]
|
||||
negative_ratings = data["neg_ratings"]
|
||||
raters = data["raters"]
|
||||
|
||||
var/x = data["x"]
|
||||
var/y = data["y"]
|
||||
@@ -222,7 +251,10 @@
|
||||
|
||||
/obj/structure/chisel_message/examine(mob/user)
|
||||
..()
|
||||
user << "<span class='warning'>[hidden_message]</span>"
|
||||
user << "<span class='notice'>[hidden_message]</span>"
|
||||
user << "Ratings: <span class='noticealien'>[positive_ratings]</span> <span class='danger'>[negative_ratings]</span>"
|
||||
if(raters[user.ckey])
|
||||
user << "<i>You rated this message as [raters[user.ckey]].</i>"
|
||||
|
||||
/obj/structure/chisel_message/Destroy()
|
||||
if(persists)
|
||||
|
||||
Reference in New Issue
Block a user