Skip to content

Commit

Permalink
preliminary addition
Browse files Browse the repository at this point in the history
  • Loading branch information
CRITAWAKETS committed Jun 12, 2024
1 parent 79a4bfd commit c2bf86c
Show file tree
Hide file tree
Showing 43 changed files with 1,771 additions and 148 deletions.
4 changes: 2 additions & 2 deletions code/_onclick/item_attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
var/list/modifiers = params2list(params)
var/is_right_clicking = LAZYACCESS(modifiers, RIGHT_CLICK)

var/item_interact_result = target.item_interaction(user, src, modifiers, is_right_clicking)
var/item_interact_result = target.base_item_interaction(user, src, modifiers)
if(item_interact_result & ITEM_INTERACT_SUCCESS)
return TRUE
if(item_interact_result & ITEM_INTERACT_BLOCKING)
Expand Down Expand Up @@ -159,7 +159,7 @@
return FALSE
return attacking_item.attack_atom(src, user, params)

/mob/living/item_interaction(mob/living/user, obj/item/tool, list/modifiers, is_right_clicking)
/mob/living/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
// Surgery and such happens very high up in the interaction chain, before parent call
var/attempt_tending = item_tending(user, tool, modifiers)
if(attempt_tending & ITEM_INTERACT_ANY_BLOCKER)
Expand Down
7 changes: 3 additions & 4 deletions code/datums/components/style/style_meter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@
. = ..()
. += span_notice("You feel like a <b>multitool</b> could be used on this.")

/obj/item/style_meter/afterattack(atom/movable/attacked_atom, mob/user, proximity_flag, click_parameters)
. = ..()
if(!istype(attacked_atom, /obj/item/clothing/glasses))
return
/obj/item/style_meter/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
if(!istype(interacting_with, /obj/item/clothing/glasses))
return NONE

forceMove(attacked_atom)
attacked_atom.add_overlay(meter_appearance)
Expand Down
12 changes: 12 additions & 0 deletions code/datums/elements/ridable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,15 @@
to_chat(user, span_notice("You gently let go of [rider]."))
return
return rider

/obj/item/riding_offhand/interact_with_atom(atom/movable/interacting_with, mob/living/user, list/modifiers)
if(!istype(interacting_with) || !interacting_with.can_buckle)
return NONE
if(rider == user) // Piggyback user
return ITEM_INTERACT_BLOCKING

// Handles de-fireman carrying a mob and buckling them onto something (tables, etc)
var/mob/living/former_rider = rider
user.unbuckle_mob(former_rider)
former_rider.forceMove(get_turf(interacting_with))
return interacting_with.mouse_buckle_handling(former_rider, user) ? ITEM_INTERACT_SUCCESS : ITEM_INTERACT_BLOCKING
34 changes: 29 additions & 5 deletions code/game/atom/atom_tool_acts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@
* Handles non-combat iteractions of a tool on this atom,
* such as using a tool on a wall to deconstruct it,
* or scanning someone with a health analyzer
*
* This can be overridden to add custom item interactions to this atom
*
* Do not call this directly
*/
/atom/proc/item_interaction(mob/living/user, obj/item/tool, list/modifiers, is_right_clicking)
/atom/proc/base_item_interaction(mob/living/user, obj/item/tool, list/modifiers)
SHOULD_CALL_PARENT(TRUE)
PROTECTED_PROC(TRUE)

var/is_right_clicking = LAZYACCESS(modifiers, RIGHT_CLICK)
var/is_left_clicking = !is_right_clicking
var/early_sig_return = NONE
if(is_left_clicking)
Expand All @@ -24,6 +21,12 @@
if(early_sig_return)
return early_sig_return

var/self_interaction = is_left_clicking \
? item_interaction(user, tool, modifiers) \
: item_interaction_secondary(user, tool, modifiers)
if(self_interaction)
return self_interaction

var/interact_return = is_left_clicking \
? tool.interact_with_atom(src, user) \
: tool.interact_with_atom_secondary(src, user)
Expand Down Expand Up @@ -75,6 +78,27 @@
SEND_SIGNAL(tool, COMSIG_TOOL_ATOM_ACTED_SECONDARY(tool_type), src)
return act_result

/**
* Called when this atom has an item used on it.
* IE, a mob is clicking on this atom with an item.
*
* Return an ITEM_INTERACT_ flag in the event the interaction was handled, to cancel further interaction code.
* Return NONE to allow default interaction / tool handling.
*/
/atom/proc/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
return NONE

/**
* Called when this atom has an item used on it WITH RIGHT CLICK,
* IE, a mob is right clicking on this atom with an item.
* Default behavior has it run the same code as left click.
*
* Return an ITEM_INTERACT_ flag in the event the interaction was handled, to cancel further interaction code.
* Return NONE to allow default interaction / tool handling.
*/
/atom/proc/item_interaction_secondary(mob/living/user, obj/item/tool, list/modifiers)
return item_interaction(user, tool, modifiers)

/**
* Called when this item is being used to interact with an atom,
* IE, a mob is clicking on an atom with this item.
Expand Down
11 changes: 6 additions & 5 deletions code/game/machinery/_machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -758,13 +758,14 @@
return
update_last_used(user)

/obj/machinery/item_interaction(mob/living/user, obj/item/tool, list/modifiers, is_right_clicking)
/obj/machinery/base_item_interaction(mob/living/user, obj/item/tool, list/modifiers)
if(SEND_SIGNAL(user, COMSIG_TRY_USE_MACHINE, src) & COMPONENT_CANT_USE_MACHINE_TOOLS)
return ITEM_INTERACT_ANY_BLOCKER
return ITEM_INTERACT_BLOCKING

. = ..()
if(. & ITEM_INTERACT_BLOCKING)
return
update_last_used(user)
if(.)
update_last_used(user)
return .

/obj/machinery/_try_interact(mob/user)
if((interaction_flags_machine & INTERACT_MACHINE_WIRES_IF_OPEN) && panel_open && (attempt_wire_interaction(user) == WIRE_INTERACTION_BLOCK))
Expand Down
100 changes: 100 additions & 0 deletions code/game/machinery/computer/arcade/_arcade.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/obj/machinery/computer/arcade
name = "\proper the arcade cabinet which shouldn't exist"
desc = "This arcade cabinet has no games installed, and in fact, should not exist. \
Report the location of this machine to your local diety."
icon_state = "arcade"
icon_keyboard = null
icon_screen = "invaders"
light_color = LIGHT_COLOR_GREEN
interaction_flags_machine = INTERACT_MACHINE_ALLOW_SILICON|INTERACT_MACHINE_REQUIRES_LITERACY

///If set, will dispense these as prizes instead of the default GLOB.arcade_prize_pool
///Like prize pool, it must be a list of the prize and the weight of being selected.
var/list/prize_override

/obj/machinery/computer/arcade/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
if(istype(tool, /obj/item/stack/arcadeticket))
var/obj/item/stack/arcadeticket/tickets = tool
if(!tickets.use(2))
balloon_alert(user, "need 2 tickets!")
return ITEM_INTERACT_BLOCKING

prizevend(user)
balloon_alert(user, "prize claimed")
return ITEM_INTERACT_SUCCESS

if(istype(tool, /obj/item/key/displaycase) || istype(tool, /obj/item/access_key))
var/static/list/radial_menu_options
if(!radial_menu_options)
radial_menu_options = list(
"Reset Cabinet" = image(icon = 'icons/hud/radial.dmi', icon_state = "radial_reset"),
"Cancel" = image(icon = 'icons/hud/radial.dmi', icon_state = "radial_close"),
)
var/radial_reset_menu = show_radial_menu(user, src, radial_menu_options, require_near = TRUE)
if(radial_reset_menu != "Reset Cabinet")
return ITEM_INTERACT_BLOCKING
playsound(loc, 'sound/items/rattling_keys.ogg', 25, TRUE)
if(!do_after(user, 10 SECONDS, src))
return ITEM_INTERACT_BLOCKING
balloon_alert(user, "cabinet reset")
reset_cabinet(user)
return ITEM_INTERACT_SUCCESS

return NONE

/obj/machinery/computer/arcade/screwdriver_act(mob/living/user, obj/item/I)
//you can't stop playing when you start.
if(obj_flags & EMAGGED)
return ITEM_INTERACT_BLOCKING
return ..()

///Performs a factory reset of the cabinet and wipes all its stats.
/obj/machinery/computer/arcade/proc/reset_cabinet(mob/living/user)
SHOULD_CALL_PARENT(TRUE)
obj_flags &= ~EMAGGED
SStgui.update_uis(src)

/obj/machinery/computer/arcade/emp_act(severity)
. = ..()
if((machine_stat & (NOPOWER|BROKEN)) || (. & EMP_PROTECT_SELF))
return

var/empprize = null
var/num_of_prizes = 0
switch(severity)
if(1)
num_of_prizes = rand(1,4)
if(2)
num_of_prizes = rand(0,2)
for(var/i = num_of_prizes; i > 0; i--)
if(prize_override)
empprize = pick_weight(prize_override)
else
empprize = pick_weight(GLOB.arcade_prize_pool)
new empprize(loc)
explosion(src, devastation_range = -1, light_impact_range = 1 + num_of_prizes, flame_range = 1 + num_of_prizes)

///Dispenses the proper prizes and gives them a positive mood event. If valid, has a small chance to give a pulse rifle.
/obj/machinery/computer/arcade/proc/prizevend(mob/living/user, prizes = 1)
SEND_SIGNAL(src, COMSIG_ARCADE_PRIZEVEND, user, prizes)
if(user.mind?.get_skill_level(/datum/skill/gaming) >= SKILL_LEVEL_LEGENDARY && HAS_TRAIT(user, TRAIT_GAMERGOD))
visible_message("<span class='notice'>[user] inputs an intense cheat code!",\
span_notice("You hear a flurry of buttons being pressed."))
say("CODE ACTIVATED: EXTRA PRIZES.")
prizes *= 2
for(var/i in 1 to prizes)
user.add_mood_event("arcade", /datum/mood_event/arcade)
if(prob(0.0001)) //1 in a million
new /obj/item/gun/energy/pulse/prize(src)
visible_message(span_notice("[src] dispenses.. woah, a gun! Way past cool."), span_notice("You hear a chime and a shot."))
user.client.give_award(/datum/award/achievement/misc/pulse, user)
continue

var/prizeselect
if(prize_override)
prizeselect = pick_weight(prize_override)
else
prizeselect = pick_weight(GLOB.arcade_prize_pool)
var/atom/movable/the_prize = new prizeselect(get_turf(src))
playsound(src, 'sound/machines/machine_vend.ogg', 50, TRUE, extrarange = -3)
visible_message(span_notice("[src] dispenses [the_prize]!"), span_notice("You hear a chime and a clunk."))
7 changes: 5 additions & 2 deletions code/game/machinery/computer/buildandrepair.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@

return TRUE

/obj/structure/frame/computer/attackby(obj/item/P, mob/living/user, params)
add_fingerprint(user)
/obj/structure/frame/computer/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
. = ..()
if(. & ITEM_INTERACT_ANY_BLOCKER)
return .

switch(state)
if(0)
if(P.tool_behaviour == TOOL_WRENCH)
Expand Down
Loading

0 comments on commit c2bf86c

Please sign in to comment.