[MIRROR] Adds the Intento! (#3617)

* Adds the Intento! (#56770)

Co-authored-by: Jack Edge <yellowbounder@ gmail.com>
Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com>

* Adds the Intento!

Co-authored-by: Fikou <piotrbryla@onet.pl>
Co-authored-by: Jack Edge <yellowbounder@ gmail.com>
Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com>
This commit is contained in:
SkyratBot
2021-02-23 23:19:16 +00:00
committed by GitHub
co-authored by Jack Edge Mothblocks Fikou
parent ccf05c37e8
commit 98d17d7fee
11 changed files with 252 additions and 3 deletions
+239
View File
@@ -178,6 +178,8 @@
inhand_icon_state = "arrestballoon"
random_color = FALSE
#undef BALLOON_COLORS
/*
* Fake singularity
*/
@@ -1571,3 +1573,240 @@
animate(pixel_y = user.pixel_y - (2 * direction), time = 1, easing = SINE_EASING)
animate(pixel_y = user.pixel_y + (1 * direction), time = 1, easing = SINE_EASING)
user.changeNext_move(CLICK_CD_MELEE)
#define HELP "help"
#define DISARM "disarm"
#define GRAB "grab"
#define HARM "harm"
#define ICON_SPLIT world.icon_size/2
// These states do not have any associated processing.
#define STATE_AWAITING_PLAYER_INPUT "awaiting_player_input"
#define STATE_OFF "off"
// When the Intento is in one of these four states, it has an accompanying
// set of code that runs in processing()
#define STATE_STARTING "starting"
#define STATE_DEMO "demo"
#define STATE_END_OF_GAME "end_of_game"
#define STATE_RETALIATION "retaliation"
#define TIME_TO_BEGIN 1.6 SECONDS
#define TIME_PER_DEMO_STEP 0.6 SECONDS
#define TIME_TO_RESET_ICON 0.5 SECONDS
/obj/item/toy/intento
name = "\improper Intento"
desc = "Fundamentally useless for all intentsive purposes."
icon = 'icons/obj/intents.dmi'
icon_state = "blank"
/// Current sequence of intents
var/list/current_sequence = list()
/// Sequence player inputs
var/list/player_sequence = list()
/// Score of the player
var/score = 0
/// Associated list of intents to their sounds
var/static/list/sound_by_intent = list(
HELP = 'sound/items/intents/Help.ogg',
DISARM = 'sound/items/intents/Disarm.ogg',
GRAB = 'sound/items/intents/Grab.ogg',
HARM = 'sound/items/intents/Harm.ogg',
)
/// What state the toy is in.
var/state = STATE_OFF
/// Index used for iteration of steps for both demo and retaliation states
var/index
/// Time to delay until we start processing whatever state we're in
COOLDOWN_DECLARE(next_process)
/// Time until we reset the icon of the Intento
COOLDOWN_DECLARE(next_icon_reset)
/obj/item/toy/intento/attack_self(mob/user, modifiers) //added params to attack_self, the alternative is registering a signal on clickon but i was advised not to
..()
if(state == STATE_OFF)
boot()
return
if(!modifiers)
return
if(state != STATE_AWAITING_PLAYER_INPUT)
return
var/input
var/icon_x = text2num(modifiers["icon-x"])
var/icon_y = text2num(modifiers["icon-y"])
if(icon_x > ICON_SPLIT && icon_y > ICON_SPLIT)
input = DISARM
if(icon_x < ICON_SPLIT && icon_y > ICON_SPLIT)
input = HELP
if(icon_x > ICON_SPLIT && icon_y < ICON_SPLIT)
input = GRAB
if(icon_x < ICON_SPLIT && icon_y < ICON_SPLIT)
input = HARM
player_input(user, input)
/obj/item/toy/intento/proc/boot()
say("Game starting!")
playsound(src, 'sound/machines/synth_yes.ogg', 50, FALSE)
state = STATE_STARTING
COOLDOWN_START(src, next_process, TIME_TO_BEGIN)
START_PROCESSING(SSfastprocess, src)
/obj/item/toy/intento/proc/player_input(mob/player, intent)
// All branches of this proc lead to us wanting to process
START_PROCESSING(SSfastprocess, src)
render(intent)
player_sequence += intent
for(var/i in 1 to player_sequence.len)
if(player_sequence[i] != current_sequence[i])
state = STATE_END_OF_GAME
COOLDOWN_START(src, next_process, TIME_TO_RESET_ICON)
return
if(player_sequence.len == current_sequence.len)
score++
state = STATE_STARTING
COOLDOWN_START(src, next_process, TIME_TO_BEGIN)
/obj/item/toy/intento/process()
if(next_icon_reset && next_icon_reset <= world.time)
icon_state = initial(icon_state)
COOLDOWN_RESET(src, next_icon_reset)
if(next_process && next_process > world.time)
return
switch(state)
if(STATE_STARTING)
process_start()
if(STATE_DEMO)
process_demo()
if(STATE_END_OF_GAME)
process_end(isliving(loc) ? loc : null)
if(STATE_RETALIATION)
process_retaliation()
if(!next_process && !next_icon_reset)
return PROCESS_KILL
/obj/item/toy/intento/proc/process_start()
player_sequence.Cut()
current_sequence += pick(list(HELP, DISARM, GRAB, HARM))
state = STATE_DEMO
next_process = world.time
index = 1
/obj/item/toy/intento/proc/process_demo()
if(index > length(current_sequence))
state = STATE_AWAITING_PLAYER_INPUT
COOLDOWN_RESET(src, next_process)
return
var/intent = current_sequence[index]
render(intent)
index += 1
COOLDOWN_START(src, next_process, TIME_PER_DEMO_STEP)
/obj/item/toy/intento/proc/process_end(mob/user)
if(user)
var/award_score = score
var/award_status = user.client.get_award_status(/datum/award/score/intento_score)
if(award_score - award_status > 0)
award_score -= award_status
user.client.give_award(/datum/award/score/intento_score, user, award_score)
say("GAME OVER. Your score was [score]!")
playsound(src, 'sound/machines/synth_no.ogg', 50, FALSE)
if(user && loc == user && obj_flags & EMAGGED)
ADD_TRAIT(src, TRAIT_NODROP, type)
to_chat(user, "<span class='userdanger'>Bad mistake.</span>")
state = STATE_RETALIATION
next_process = world.time
index = 1
else
cleanup()
/obj/item/toy/intento/proc/process_retaliation()
var/mob/living/victim = loc
if(!isliving(victim) || index > length(current_sequence))
cleanup()
return
var/intent = current_sequence[index]
render(intent)
switch(intent)
if(HELP)
to_chat(victim, "<span class='danger'>[src] hugs you to make you feel better!</span>")
SEND_SIGNAL(victim, COMSIG_ADD_MOOD_EVENT, "hug", /datum/mood_event/hug)
if(DISARM)
to_chat(victim, "<span class='danger'>You're knocked down from a shove by [src]!</span>")
victim.Knockdown(2 SECONDS)
if(GRAB)
to_chat(victim, "<span class='danger'>[src] grabs you aggressively!</span>")
victim.Stun(2 SECONDS)
if(HARM)
to_chat(victim, "<span class='danger'>You're punched by [src]!</span>")
victim.apply_damage(rand(20, 30), BRUTE)
index += 1
COOLDOWN_START(src, next_process, TIME_PER_DEMO_STEP)
/obj/item/toy/intento/proc/cleanup()
score = 0
index = 1
player_sequence.Cut()
current_sequence.Cut()
state = STATE_OFF
COOLDOWN_RESET(src, next_process)
REMOVE_TRAIT(src, TRAIT_NODROP, type)
/obj/item/toy/intento/proc/render(input)
icon_state = input
playsound(src, sound_by_intent[input], 50, FALSE)
START_PROCESSING(SSfastprocess, src)
COOLDOWN_START(src, next_icon_reset, TIME_TO_RESET_ICON)
/obj/item/toy/intento/emag_act(mob/user)
if(obj_flags & EMAGGED)
return
obj_flags |= EMAGGED
to_chat(user, "<span class='notice'>You short-circuit [src], activating the negative feedback loop.</span>")
/obj/item/toy/intento/Destroy()
STOP_PROCESSING(SSfastprocess, src)
return ..()
#undef HELP
#undef DISARM
#undef GRAB
#undef HARM
#undef ICON_SPLIT
#undef STATE_AWAITING_PLAYER_INPUT
#undef STATE_OFF
#undef STATE_STARTING
#undef STATE_DEMO
#undef STATE_END_OF_GAME
#undef STATE_RETALIATION
#undef TIME_TO_BEGIN
#undef TIME_PER_DEMO_STEP
#undef TIME_TO_RESET_ICON