Skip to content

Commit

Permalink
why did i do this to myself
Browse files Browse the repository at this point in the history
  • Loading branch information
silicons committed Dec 26, 2024
1 parent 514d051 commit 33d4414
Show file tree
Hide file tree
Showing 93 changed files with 157 additions and 215 deletions.
5 changes: 4 additions & 1 deletion code/__DEFINES/_cooldowns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,7 @@
#define CD_INTERNET_SOUND "internet_sound"

//* /mob
#define CD_INDEX_MOB_VERB_INVERT_SELF "mob-verb-invert-self"
#define TIMER_CD_INDEX_MOB_VERB_INVERT_SELF "mob-verb-invert_self"

//* /client
#define TIMER_CD_INDEX_CLIENT_CHARACTER_DIRECTORY "client-verb-character_directory"
92 changes: 19 additions & 73 deletions code/game/click/click.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* Backend clickcode.
*
* * Things in this file are **not** part of the clickchain, instead being the machinery that initiates the clickchain.
*/

/*
Before anything else, defer these calls to a per-mobtype handler. This allows us to
Expand Down Expand Up @@ -98,7 +103,7 @@
return M.click_action(A, src, params)

if(restrained())
setClickCooldown(10)
setClickCooldownLegacy(10)
RestrainedClickOn(A)
return 1

Expand Down Expand Up @@ -147,7 +152,9 @@
trigger_aiming(TARGET_CAN_CLICK)
return

/mob/proc/setClickCooldown(var/timeout)
// todo: this is legacy because majority of calls to it are unaudited and unnecessary; new system
// handles melee cooldown at clickcode level.
/mob/proc/setClickCooldownLegacy(var/timeout)
next_move = max(world.time + timeout, next_move)

/mob/proc/canClick()
Expand Down Expand Up @@ -206,59 +213,28 @@
/mob/proc/RestrainedClickOn(var/atom/A)
return

/*
Middle click
Only used for swapping hands
*/
/mob/proc/MiddleClickOn(var/atom/A)
swap_hand()
return

// In case of use break glass
/*
/atom/proc/MiddleClick(var/mob/M as mob)
return
*/

/*
Shift middle click
Used for pointing.
*/
/mob/proc/ShiftMiddleClickOn(atom/A)
pointed(A)
return

/*
Shift click
For most mobs, examine.
This is overridden in ai.dm
*/
/mob/proc/ShiftClickOn(var/atom/A)
A.ShiftClick(src)
return

/atom/proc/ShiftClick(var/mob/user)
if(user.client && user.allow_examine(src))
user.examinate(src)

/*
Ctrl click
For most objects, pull
*/
/mob/proc/CtrlClickOn(var/atom/A)
A.CtrlClick(src)
return

/atom/proc/CtrlClick(var/mob/user)
return

/atom/movable/CtrlClick(var/mob/user)
if(Adjacent(user))
user.start_pulling(src)

/*
Alt click
Unused except for AI
*/
/mob/proc/AltClickOn(atom/A)
if(!A.AltClick(src))
altclick_listed_turf(A)
Expand Down Expand Up @@ -286,28 +262,18 @@
/mob/proc/TurfAdjacent(var/turf/T)
return T.AdjacentQuick(src)

/*
Control+Shift click
Unused except for AI
*/
/mob/proc/CtrlShiftClickOn(var/atom/A)
A.CtrlShiftClick(src)
return

/atom/proc/CtrlShiftClick(var/mob/user)
return

/*
Misc helpers
Laser Eyes: as the name implies, handles this since nothing else does currently
face_atom: turns the mob towards what you clicked on
*/
/mob/proc/LaserEyes(atom/A, params)
return

/mob/living/LaserEyes(atom/A, params)
setClickCooldown(4)
setClickCooldownLegacy(4)
var/turf/T = get_turf(src)

var/obj/projectile/beam/LE = new (T)
Expand All @@ -326,7 +292,6 @@
else
to_chat(src, "<span class='warning'>You're out of energy! You need food!</span>")


/// Simple helper to face what you clicked on, in case it should be needed in more than one place.
/mob/proc/face_atom(var/atom/atom_to_face)
if(buckled || stat != CONSCIOUS || !atom_to_face || !x || !y || !atom_to_face.x || !atom_to_face.y)
Expand Down Expand Up @@ -358,33 +323,14 @@
else
setDir(WEST)

/atom/movable/screen/click_catcher
name = ""
icon = 'icons/mob/screen_gen.dmi'
icon_state = "click_catcher"
plane = CLICKCATCHER_PLANE
mouse_opacity = MOUSE_OPACITY_OPAQUE
screen_loc = "CENTER-7,CENTER-7"

/atom/movable/screen/click_catcher/proc/MakeGreed()
. = list()
for(var/i = 0, i<15, i++)
for(var/j = 0, j<15, j++)
var/atom/movable/screen/click_catcher/CC = new()
CC.screen_loc = "NORTH-[i],EAST-[j]"
. += CC

/atom/movable/screen/click_catcher/Click(location, control, params)
var/list/modifiers = params2list(params)
if(modifiers["middle"] && istype(usr, /mob/living/carbon))
var/mob/living/carbon/C = usr
C.swap_hand()
else
var/turf/T = screen_loc2turf(screen_loc, get_turf(usr))
if(T)
T.Click(location, control, params)
. = 1

/// MouseWheelOn
/mob/proc/MouseWheelOn(atom/A, delta_x, delta_y, params)
SEND_SIGNAL(src, COMSIG_MOUSE_SCROLL_ON, A, delta_x, delta_y, params)

//* Click Cooldown *//

/**
* Prevents a mob from acting again until time has passed.
*/
/mob/proc/apply_click_cooldown(time)
next_move = max(world.time + time, next_move)
4 changes: 2 additions & 2 deletions code/game/click/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
L.lastattacker = user
// click cooldown
// todo: clickcd rework
user.setClickCooldown(user.get_attack_speed_legacy(src))
user.setClickCooldownLegacy(user.get_attack_speed_legacy(src))
// animation
user.animate_swing_at_target(L)
// resolve accuracy
Expand Down Expand Up @@ -350,7 +350,7 @@
clickchain.melee_damage_multiplier *= mult
// click cooldown
// todo: clickcd rework
clickchain.performer.setClickCooldown(clickchain.performer.get_attack_speed_legacy(src))
clickchain.performer.setClickCooldownLegacy(clickchain.performer.get_attack_speed_legacy(src))
// animation
clickchain.performer.animate_swing_at_target(target)
// perform the hit
Expand Down
4 changes: 2 additions & 2 deletions code/game/click/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/mob/proc/melee_interaction_chain(atom/target, clickchain_flags, list/params)
// todo: refactor cooldown handling
if(ismob(target))
setClickCooldown(get_attack_speed_legacy())
setClickCooldownLegacy(get_attack_speed_legacy())
UnarmedAttack(target, clickchain_flags & CLICKCHAIN_HAS_PROXIMITY)

/**
Expand Down Expand Up @@ -81,7 +81,7 @@
clickchain.performer.break_cloak()

// todo: clickcd rework
clickchain.performer.setClickCooldown(clickchain.performer.get_attack_speed_legacy())
clickchain.performer.setClickCooldownLegacy(clickchain.performer.get_attack_speed_legacy())
// todo: animation might need to depend on if it hits
animate_swing_at_target(target)

Expand Down
2 changes: 1 addition & 1 deletion code/game/click/observer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
ShiftMiddleClickOn(A)
return
if(!canClick()) return
setClickCooldown(4)
setClickCooldownLegacy(4)
// You are responsible for checking config_legacy.ghost_interaction when you override this function
// Not all of them require checking, see below
A.attack_ghost(src)
Expand Down
2 changes: 1 addition & 1 deletion code/game/click/other_mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
if(!..())
return FALSE

setClickCooldown(get_attack_speed_legacy())
setClickCooldownLegacy(get_attack_speed_legacy())
A.attack_generic(src,rand(5,6),"bitten")

/*
Expand Down
2 changes: 1 addition & 1 deletion code/game/click/rig.dm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
return 0
hardsuit.selected_module.engage(A, alert_ai)
if(ismob(A)) // No instant mob attacking - though modules have their own cooldowns
setClickCooldown(get_attack_speed_legacy())
setClickCooldownLegacy(get_attack_speed_legacy())
return 1
return 0

Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/cult/construct_spells.dm
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@
on_ranged_cast(target, user)
if(cooldown)
var/effective_cooldown = round(cooldown, 5)
user.setClickCooldown(effective_cooldown)
user.setClickCooldownLegacy(effective_cooldown)
flick("cooldown_[effective_cooldown]",src)

/obj/item/spell/construct/projectile //This makes me angry, but we need the template, and we can't use it because special check overrides on the base.
Expand Down
10 changes: 5 additions & 5 deletions code/game/gamemodes/technomancer/assistance/golem.dm
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,19 @@
add_overlay(I)

/mob/living/simple_animal/technomancer_golem/proc/spellcast_pre_animation()
setClickCooldown(5)
setClickCooldownLegacy(5)
manual_flick(spell_pre_attack_states, spell_image, reset_to = "golem_spell_attack_3")

/mob/living/simple_animal/technomancer_golem/proc/spellcast_post_animation()
setClickCooldown(8)
setClickCooldownLegacy(8)
manual_flick(spell_post_attack_states, spell_image, reset_to = "golem_spell")

/mob/living/simple_animal/technomancer_golem/proc/sword_pre_animation()
setClickCooldown(6)
setClickCooldownLegacy(6)
manual_flick(sword_pre_attack_states, sword_image)

/mob/living/simple_animal/technomancer_golem/proc/sword_post_animation()
setClickCooldown(3)
setClickCooldownLegacy(3)
manual_flick(sword_post_attack_states, sword_image, reset_to = "golem_sword")

/mob/living/simple_animal/technomancer_golem/DoPunch(var/atom/A)
Expand Down Expand Up @@ -196,7 +196,7 @@
else if(active_spell.cast_methods & CAST_RANGED)
active_spell.on_ranged_cast(A, src)
spellcast_post_animation()
src.setClickCooldown(effective_cooldown)
src.setClickCooldownLegacy(effective_cooldown)
else
..()

Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/technomancer/spell_objs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
on_ranged_cast(target, user)
if(cooldown)
var/effective_cooldown = round(cooldown * core.cooldown_modifier, 5)
user.setClickCooldown(effective_cooldown)
user.setClickCooldownLegacy(effective_cooldown)
flick("cooldown_[effective_cooldown]",src)

// Proc: place_spell_in_hand()
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/technomancer/spells/control.dm
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
log_and_message_admins("has commanded their army of [controlled_mobs.len] to attack [L].")
to_chat(user, "<span class='notice'>You command your [controlled_mobs.len > 1 ? "entities" : "[controlled_mobs[1]]"] to attack \the [L].</span>")
//This is to stop someone from controlling beepsky and getting him to stun someone 5 times a second.
user.setClickCooldown(8)
user.setClickCooldownLegacy(8)
adjust_instability(controlled_mobs.len)

else if(isturf(hit_atom))
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/technomancer/spells/warp_strike.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
if(!within_range(T))
return
//First, we handle who to teleport to.
user.setClickCooldown(5)
user.setClickCooldownLegacy(5)
var/mob/living/chosen_target = targeting_assist(T,5) //The person who's about to get attacked.

if(!chosen_target)
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/camera/camera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ CREATE_WALL_MOUNTING_TYPES(/obj/machinery/camera)
if(L.species.can_shred(L))
set_status(0)
L.do_attack_animation(src)
L.setClickCooldown(L.get_attack_speed_legacy())
L.setClickCooldownLegacy(L.get_attack_speed_legacy())
visible_message("<span class='warning'>\The [L] slashes at [src]!</span>")
playsound(src.loc, 'sound/weapons/slash.ogg', 100, 1)
add_hiddenprint(L)
Expand All @@ -129,7 +129,7 @@ CREATE_WALL_MOUNTING_TYPES(/obj/machinery/camera)
var/mob/living/simple_mob/S = user
set_status(0)
S.do_attack_animation(src)
S.setClickCooldown(user.get_attack_speed_legacy())
S.setClickCooldownLegacy(user.get_attack_speed_legacy())
visible_message("<span class='warning'>\The [user] [pick(S.attacktext)] \the [src]!</span>")
playsound(src.loc, S.attack_sound, 100, 1)
add_hiddenprint(user)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/deployable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/obj/machinery/deployable/barrier/attackby(obj/item/I, mob/living/user, list/params, clickchain_flags, damage_multiplier)
if(user.a_intent == INTENT_HARM)
return ..()
user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN)
user.setClickCooldownLegacy(DEFAULT_ATTACK_COOLDOWN)
if(istype(I, /obj/item/card/id/))
if(allowed(user))
if (emagged < 2)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/doorbell_vr.dm
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
icon_state = "doorbell-standby"

/obj/machinery/button/doorbell/attack_hand(mob/user, datum/event_args/actor/clickchain/e_args)
user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN)
user.setClickCooldownLegacy(DEFAULT_ATTACK_COOLDOWN)
if(..())
return
use_power(5)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@

add_attack_logs(user,M,"Attack eyes with [name]")

user.setClickCooldown(user.get_attack_speed_legacy())
user.setClickCooldownLegacy(user.get_attack_speed_legacy())
user.do_attack_animation(M)

src.add_fingerprint(user)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/body_snatcher_vr.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/obj/item/bodysnatcher/proc/attempt_swap(mob/living/M, mob/living/user)
if(!isliving(M) || !isliving(user))
return
user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN)
user.setClickCooldownLegacy(DEFAULT_ATTACK_COOLDOWN)
if(ishuman(M) || issilicon(M)) //Allows body swapping with humans, synths, and pAI's/borgs since they all have a mind.
if(user == M)
to_chat(user,"<span class='warning'> A message pops up on the LED display, informing you that you that the mind transfer to yourself was successful... Wait, did that even do anything?</span>")
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/devices/flash.dm
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@

add_attack_logs(user,M,"Flashed (attempt) with [src]")

user.setClickCooldown(user.get_attack_speed_legacy(src))
user.setClickCooldownLegacy(user.get_attack_speed_legacy(src))
user.do_attack_animation(M)

if(!clown_check(user))
Expand Down Expand Up @@ -247,7 +247,7 @@
if(!user || !clown_check(user))
return

user.setClickCooldown(user.get_attack_speed_legacy(src))
user.setClickCooldownLegacy(user.get_attack_speed_legacy(src))

if(broken)
user.show_message("<span class='warning'>The [src.name] is broken</span>", 2)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/flashlight.dm
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
else
to_chat(user, SPAN_NOTICE("\The [L]'s pupils narrow."))

user.setClickCooldown(user.get_attack_speed_legacy(src)) //can be used offensively
user.setClickCooldownLegacy(user.get_attack_speed_legacy(src)) //can be used offensively
L.flash_eyes()
return CLICKCHAIN_DO_NOT_PROPAGATE
return ..()
Expand Down
Loading

0 comments on commit 33d4414

Please sign in to comment.