mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-20 04:26:03 +01:00
[MIRROR] Makes the Haunted Eight Ball work(?) (better?) [MDB IGNORE] (#23606)
* Makes the Haunted Eight Ball work(?) (better?) (#78196) ## About The Pull Request From my recollection the haunted eight ball has been "broken" for like 3 or 4 years. So uh... yea Makes the Haunted Eight Ball actually, like, work good. - Fixes all votes counting to 0 - Fixes votes being reported as their vote key and not a flavor message - Allows ghosts to change their vote - General small code cleanup - Calls parent in topic so stat panel clicks work - Fixes #41718 , again? If it was actually ever fixed, not sure ## Changelog 🆑 Melbert qol: Haunted 8-ball no longer requires the ghost orbit the petitioner to submit votes qol: Haunted 8-ball ghosts can now change their vote after submitting it fix: Haunted 8-ball no longer always reports "yes" fix: Haunted 8-ball no longer always reports default "yes", "no", or "maybe" and now gives a proper eight ball response fix: Haunted 8-ball can be picked up via the stat panel /🆑 * Makes the Haunted Eight Ball work(?) (better?) --------- Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
var/shaking = FALSE
|
||||
var/on_cooldown = FALSE
|
||||
|
||||
var/shake_time = 50
|
||||
var/cooldown_time = 100
|
||||
var/shake_time = 5 SECONDS
|
||||
var/cooldown_time = 10 SECONDS
|
||||
|
||||
var/static/list/possible_answers = list(
|
||||
"It is certain",
|
||||
@@ -42,11 +42,16 @@
|
||||
return INITIALIZE_HINT_QDEL
|
||||
|
||||
/obj/item/toy/eightball/proc/MakeHaunted()
|
||||
. = prob(1)
|
||||
if(.)
|
||||
if(prob(1))
|
||||
new /obj/item/toy/eightball/haunted(loc)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
/obj/item/toy/eightball/attack_self(mob/user)
|
||||
if(..())
|
||||
return
|
||||
|
||||
. = TRUE
|
||||
if(shaking)
|
||||
return
|
||||
|
||||
@@ -60,23 +65,19 @@
|
||||
|
||||
start_shaking(user)
|
||||
if(do_after(user, shake_time))
|
||||
var/answer = get_answer()
|
||||
say(answer)
|
||||
say(get_answer())
|
||||
|
||||
on_cooldown = TRUE
|
||||
addtimer(CALLBACK(src, PROC_REF(clear_cooldown)), cooldown_time)
|
||||
addtimer(VARSET_CALLBACK(src, on_cooldown, FALSE), cooldown_time)
|
||||
|
||||
shaking = FALSE
|
||||
|
||||
/obj/item/toy/eightball/proc/start_shaking(user)
|
||||
/obj/item/toy/eightball/proc/start_shaking(mob/user)
|
||||
return
|
||||
|
||||
/obj/item/toy/eightball/proc/get_answer()
|
||||
return pick(possible_answers)
|
||||
|
||||
/obj/item/toy/eightball/proc/clear_cooldown()
|
||||
on_cooldown = FALSE
|
||||
|
||||
// A broken magic eightball, it only says "YOU SUCK" over and over again.
|
||||
|
||||
/obj/item/toy/eightball/broken
|
||||
@@ -97,7 +98,7 @@
|
||||
/obj/item/toy/eightball/haunted
|
||||
shake_time = 30 SECONDS
|
||||
cooldown_time = 3 MINUTES
|
||||
var/last_message
|
||||
var/last_message = "Nothing!"
|
||||
var/selected_message
|
||||
//these kind of store the same thing but one is easier to work with.
|
||||
var/list/votes = list()
|
||||
@@ -160,6 +161,7 @@
|
||||
notify_ghosts("[user] is shaking [src], hoping to get an answer to \"[selected_message]\"", source=src, enter_link="<a href=?src=[REF(src)];interact=1>(Click to help)</a>", action=NOTIFY_ATTACK, header = "Magic eightball")
|
||||
|
||||
/obj/item/toy/eightball/haunted/Topic(href, href_list)
|
||||
. = ..()
|
||||
if(href_list["interact"])
|
||||
if(isobserver(usr))
|
||||
interact(usr)
|
||||
@@ -169,7 +171,7 @@
|
||||
var/top_vote
|
||||
|
||||
for(var/vote in votes)
|
||||
var/amount_of_votes = length(votes[vote])
|
||||
var/amount_of_votes = votes[vote]
|
||||
if(amount_of_votes > top_amount)
|
||||
top_vote = vote
|
||||
top_amount = amount_of_votes
|
||||
@@ -186,12 +188,19 @@
|
||||
|
||||
voted.Cut()
|
||||
|
||||
return top_vote
|
||||
var/list/top_options = haunted_answers[top_vote]
|
||||
return pick(top_options)
|
||||
|
||||
// Only ghosts can interact because only ghosts can open the ui
|
||||
/obj/item/toy/eightball/haunted/can_interact(mob/living/user)
|
||||
return isobserver(user)
|
||||
|
||||
/obj/item/toy/eightball/haunted/ui_state(mob/user)
|
||||
return GLOB.observer_state
|
||||
|
||||
/obj/item/toy/eightball/haunted/ui_interact(mob/user, datum/tgui/ui)
|
||||
if(!isobserver(user))
|
||||
return
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if(!ui)
|
||||
ui = new(user, src, "EightBallVote", name)
|
||||
@@ -224,9 +233,11 @@
|
||||
var/selected_answer = params["answer"]
|
||||
if(!(selected_answer in haunted_answers))
|
||||
return
|
||||
if(user.ckey in voted)
|
||||
return
|
||||
else
|
||||
votes[selected_answer] += 1
|
||||
voted[user.ckey] = selected_answer
|
||||
. = TRUE
|
||||
var/oldvote = voted[user.ckey]
|
||||
if(oldvote)
|
||||
// detract their old vote
|
||||
votes[oldvote] -= 1
|
||||
|
||||
votes[selected_answer] += 1
|
||||
voted[user.ckey] = selected_answer
|
||||
return TRUE
|
||||
|
||||
Reference in New Issue
Block a user