[NO GBP] simplifying fishing line shitcode. (#78358)

## About The Pull Request
This should also fix the hooked item exploit for real now, but to avoid
further goofs, I'm keeping this as a draft until I finish running the
game locally.

## Why It's Good For The Game
Closes #78357.

## Changelog

🆑
fix: Actually fixed the hooked item exploit.
/🆑
This commit is contained in:
Ghom
2023-09-30 21:49:05 +01:00
committed by GitHub
parent ec6477c5ec
commit 2a9947472b
3 changed files with 34 additions and 47 deletions
@@ -24,8 +24,5 @@
#define COMSIG_FISHING_ROD_CAST "fishing_rod_cast"
#define FISHING_ROD_CAST_HANDLED (1 << 0)
/// Sent when fishing line is snapped
#define COMSIG_FISHING_LINE_SNAPPED "fishing_line_interrupted"
/// Sent when the challenge is to be interrupted: (reason)
#define COMSIG_FISHING_SOURCE_INTERRUPT_CHALLENGE "fishing_spot_interrupt_challenge"
+14 -9
View File
@@ -207,19 +207,20 @@
lure_turf?.balloon_alert(user, message)
/datum/fishing_challenge/proc/on_spot_gone(datum/source)
SIGNAL_HANDLER
send_alert("fishing spot gone!")
interrupt(balloon_alert = FALSE)
interrupt()
/datum/fishing_challenge/proc/interrupt_challenge(datum/source, reason)
if(reason)
send_alert(reason)
interrupt(balloon_alert = FALSE)
interrupt()
/datum/fishing_challenge/proc/start(mob/living/user)
/// Create fishing line visuals
fishing_line = used_rod.create_fishing_line(lure, target_py = 5)
// If fishing line breaks los / rod gets dropped / deleted
RegisterSignal(fishing_line, COMSIG_FISHING_LINE_SNAPPED, PROC_REF(interrupt))
RegisterSignal(fishing_line, COMSIG_QDELETING, PROC_REF(on_line_deleted))
RegisterSignal(used_rod, COMSIG_ITEM_ATTACK_SELF, PROC_REF(on_attack_self))
ADD_TRAIT(user, TRAIT_GONE_FISHING, REF(src))
user.add_mood_event("fishing", /datum/mood_event/fishing)
@@ -228,6 +229,12 @@
to_chat(user, span_notice("You start fishing..."))
playsound(lure, 'sound/effects/splash.ogg', 100)
/datum/fishing_challenge/proc/on_line_deleted(datum/source)
SIGNAL_HANDLER
fishing_line = null
send_alert(user.is_holding(used_rod) ? "line snapped" : "rod dropped")
interrupt()
/datum/fishing_challenge/proc/handle_click(mob/source, atom/target, modifiers)
SIGNAL_HANDLER
//You need to be holding the rod to use it.
@@ -241,12 +248,9 @@
return COMSIG_MOB_CANCEL_CLICKON
/// Challenge interrupted by something external
/datum/fishing_challenge/proc/interrupt(datum/source, balloon_alert = TRUE)
SIGNAL_HANDLER
/datum/fishing_challenge/proc/interrupt()
if(!completed)
experience_multiplier *= 0.5
if(balloon_alert)
send_alert(user.is_holding(used_rod) ? "line snapped" : "tool dropped")
complete(FALSE)
/datum/fishing_challenge/proc/on_attack_self(obj/item/source, mob/user)
@@ -278,7 +282,8 @@
if(reward_path != FISHING_DUD)
playsound(lure, 'sound/effects/bigsplash.ogg', 100)
SEND_SIGNAL(src, COMSIG_FISHING_CHALLENGE_COMPLETED, user, win)
qdel(src)
if(!QDELETED(src))
qdel(src)
/datum/fishing_challenge/proc/start_baiting_phase()
deltimer(next_phase_timer)
@@ -307,7 +312,7 @@
///The player is no longer around to play the minigame, so we interrupt it.
/datum/fishing_challenge/proc/on_user_logout(datum/source)
SIGNAL_HANDLER
interrupt(balloon_alert = FALSE)
interrupt()
/datum/fishing_challenge/proc/win_anyway()
if(!completed)
+20 -35
View File
@@ -30,14 +30,11 @@
var/obj/item/currently_hooked_item
/// Fishing line visual for the hooked item
var/datum/beam/hooked_item_fishing_line
var/datum/beam/fishing_line/fishing_line
/// Are we currently casting
var/casting = FALSE
/// List of fishing line beams
var/list/fishing_lines = list()
/// The default color for the reel overlay if no line is equipped.
var/default_line_color = "gray"
@@ -66,9 +63,7 @@
return NONE
/obj/item/fishing_rod/Destroy(force)
. = ..()
//Remove any leftover fishing lines
QDEL_LIST(fishing_lines)
return ..()
/obj/item/fishing_rod/examine(mob/user)
. = ..()
@@ -140,7 +135,7 @@
// Should probably respect and used force move later
step_towards(currently_hooked_item, get_turf(src))
if(get_dist(currently_hooked_item,get_turf(src)) < 1)
clear_hooked_item()
QDEL_NULL(fishing_line)
/obj/item/fishing_rod/attack_self_secondary(mob/user, modifiers)
. = ..()
@@ -159,30 +154,28 @@
var/mob/user = loc
if(!istype(user))
return
if(fishing_line)
QDEL_NULL(fishing_line)
var/beam_color = line?.line_color || default_line_color
var/datum/beam/fishing_line/fishing_line_beam = new(user, target, icon_state = "fishing_line", beam_color = beam_color, emissive = FALSE, override_target_pixel_y = target_py)
fishing_line_beam.lefthand = user.get_held_index_of_item(src) % 2 == 1
RegisterSignal(fishing_line_beam, COMSIG_BEAM_BEFORE_DRAW, PROC_REF(check_los))
RegisterSignal(fishing_line_beam, COMSIG_QDELETING, PROC_REF(clear_line))
fishing_lines += fishing_line_beam
INVOKE_ASYNC(fishing_line_beam, TYPE_PROC_REF(/datum/beam/, Start))
fishing_line = new(user, target, icon_state = "fishing_line", beam_color = beam_color, emissive = FALSE, override_target_pixel_y = target_py)
fishing_line.lefthand = user.get_held_index_of_item(src) % 2 == 1
RegisterSignal(fishing_line, COMSIG_BEAM_BEFORE_DRAW, PROC_REF(check_los))
RegisterSignal(fishing_line, COMSIG_QDELETING, PROC_REF(clear_line))
INVOKE_ASYNC(fishing_line, TYPE_PROC_REF(/datum/beam/, Start))
user.update_held_items()
return fishing_line_beam
return fishing_line
/obj/item/fishing_rod/proc/clear_line(datum/source)
SIGNAL_HANDLER
fishing_lines -= source
if(ismob(loc))
var/mob/user = loc
user.update_held_items()
fishing_line = null
currently_hooked_item = null
/obj/item/fishing_rod/dropped(mob/user, silent)
. = ..()
if(currently_hooked_item)
clear_hooked_item()
for(var/datum/beam/fishing_line in fishing_lines)
SEND_SIGNAL(fishing_line, COMSIG_FISHING_LINE_SNAPPED)
QDEL_LIST(fishing_lines)
QDEL_NULL(fishing_line)
/// Hooks the item
/obj/item/fishing_rod/proc/hook_item(mob/user, atom/target_atom)
@@ -191,28 +184,20 @@
if(!can_be_hooked(target_atom))
return
currently_hooked_item = target_atom
hooked_item_fishing_line = create_fishing_line(target_atom)
RegisterSignal(hooked_item_fishing_line, COMSIG_FISHING_LINE_SNAPPED, PROC_REF(clear_hooked_item))
create_fishing_line(target_atom)
/// Checks what can be hooked
/obj/item/fishing_rod/proc/can_be_hooked(atom/movable/target)
// Could be made dependent on actual hook, ie magnet to hook metallic items
return isitem(target)
/obj/item/fishing_rod/proc/clear_hooked_item()
SIGNAL_HANDLER
if(!QDELETED(hooked_item_fishing_line))
QDEL_NULL(hooked_item_fishing_line)
currently_hooked_item = null
// Checks fishing line for interruptions and range
/obj/item/fishing_rod/proc/check_los(datum/beam/source)
SIGNAL_HANDLER
. = NONE
if(!isturf(source.origin.loc) || !isturf(source.target.loc) || !CheckToolReach(src, source.target, cast_range))
SEND_SIGNAL(source, COMSIG_FISHING_LINE_SNAPPED) //Stepped out of range or los interrupted
if(!CheckToolReach(src, source.target, cast_range))
qdel(source)
return BEAM_CANCEL_DRAW
/obj/item/fishing_rod/afterattack(atom/target, mob/user, proximity_flag, click_parameters)
@@ -300,7 +285,7 @@
reel_overlay.color = line_color
. += reel_overlay
/// if we don't have anything hooked show the dangling hook & line
if(isinhands && length(fishing_lines) == 0)
if(isinhands && !fishing_line)
var/mutable_appearance/line_overlay = mutable_appearance(icon_file, "line_overlay")
line_overlay.appearance_flags |= RESET_COLOR
line_overlay.color = line_color
@@ -507,8 +492,8 @@
balloon_alert(user, active ? "extended" : "collapsed")
playsound(src, 'sound/weapons/batonextend.ogg', 50, TRUE)
update_appearance(UPDATE_OVERLAYS)
if(currently_hooked_item)
clear_hooked_item()
if(fishing_line)
QDEL_NULL(fishing_line)
return COMPONENT_NO_DEFAULT_MESSAGE
/obj/item/fishing_rod/telescopic/master