Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lurker: bug fix, var disambiguation and redundant type checks #4922

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@
if (istype(lurker_invis))
lurker_invis.invisibility_off()

/datum/action/xeno_action/activable/pounce/lurker/additional_effects(mob/living/L)
var/mob/living/carbon/xenomorph/X = owner
if (!istype(X))
/datum/action/xeno_action/activable/pounce/lurker/additional_effects(mob/living/living_mob)
var/mob/living/carbon/xenomorph/xeno = owner
if (!istype(xeno))
return

if (X.mutation_type == LURKER_NORMAL)
RegisterSignal(X, COMSIG_XENO_SLASH_ADDITIONAL_EFFECTS_SELF, PROC_REF(remove_freeze), TRUE) // Suppresses runtime ever we pounce again before slashing
if (xeno.mutation_type == LURKER_NORMAL)
RegisterSignal(xeno, COMSIG_XENO_SLASH_ADDITIONAL_EFFECTS_SELF, PROC_REF(remove_freeze), TRUE) // Suppresses runtime ever we pounce again before slashing

/datum/action/xeno_action/activable/pounce/lurker/proc/remove_freeze(mob/living/carbon/xenomorph/X)
/datum/action/xeno_action/activable/pounce/lurker/proc/remove_freeze(mob/living/carbon/xenomorph/xeno)
SIGNAL_HANDLER

var/datum/behavior_delegate/lurker_base/BD = X.behavior_delegate
if (istype(BD))
UnregisterSignal(X, COMSIG_XENO_SLASH_ADDITIONAL_EFFECTS_SELF)
var/datum/behavior_delegate/lurker_base/behaviour_del = xeno.behavior_delegate
if (istype(behaviour_del))
UnregisterSignal(xeno, COMSIG_XENO_SLASH_ADDITIONAL_EFFECTS_SELF)
end_pounce_freeze()

/datum/action/xeno_action/onclick/lurker_invisibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@
xeno.visible_message(SPAN_XENOWARNING("\The [xeno] strikes the window with their tail!"), SPAN_XENOWARNING("You strike the window with your tail!"))
apply_cooldown(cooldown_modifier = 0.5)
return
if(current_structure.density)
to_chat(xeno, SPAN_WARNING("There's something blocking you from striking!"))
return

if(!isxeno_human(hit_target) || xeno.can_not_harm(hit_target) || hit_target.stat == DEAD)
xeno.visible_message(SPAN_XENOWARNING("\The [xeno] swipes their tail through the air!"), SPAN_XENOWARNING("You swipe your tail through the air!"))
Expand Down
36 changes: 18 additions & 18 deletions code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
target_carbon.set_effect(get_xeno_stun_duration(target_carbon, 3), SUPERSLOW)
next_slash_buffed = FALSE
var/datum/action/xeno_action/onclick/lurker_assassinate/ability = get_xeno_action_by_type(bound_xeno, /datum/action/xeno_action/onclick/lurker_assassinate)
if (ability && istype(ability))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already typechecked in get_xeno_action_by_type() so this should be redundant.

/proc/get_xeno_action_by_type(mob/living/carbon/xenomorph/X, typepath)
if (!istype(X))
CRASH("xeno_action.dm: get_xeno_action_by_type invoked with non-xeno first argument.")
for (var/datum/action/xeno_action/XA in X.actions)
if (istype(XA, typepath))
return XA
return null

if (ability)
ability.button.icon_state = "template"

return original_damage
Expand All @@ -110,33 +110,33 @@
/datum/behavior_delegate/lurker_base/melee_attack_additional_effects_self()
..()

var/datum/action/xeno_action/onclick/lurker_invisibility/LIA = get_xeno_action_by_type(bound_xeno, /datum/action/xeno_action/onclick/lurker_invisibility)
if (LIA && istype(LIA))
LIA.invisibility_off()
var/datum/action/xeno_action/onclick/lurker_invisibility/lurker_invis_action = get_xeno_action_by_type(bound_xeno, /datum/action/xeno_action/onclick/lurker_invisibility)
if (lurker_invis_action)
lurker_invis_action.invisibility_off()

/datum/behavior_delegate/lurker_base/proc/decloak_handler(mob/source)
SIGNAL_HANDLER
var/datum/action/xeno_action/onclick/lurker_invisibility/LIA = get_xeno_action_by_type(bound_xeno, /datum/action/xeno_action/onclick/lurker_invisibility)
if(istype(LIA))
LIA.invisibility_off()
var/datum/action/xeno_action/onclick/lurker_invisibility/lurker_invis_action = get_xeno_action_by_type(bound_xeno, /datum/action/xeno_action/onclick/lurker_invisibility)
if(istype(lurker_invis_action))
lurker_invis_action.invisibility_off()

// What to do when we go invisible
/datum/behavior_delegate/lurker_base/proc/on_invisibility()
var/datum/action/xeno_action/activable/pounce/lurker/LPA = get_xeno_action_by_type(bound_xeno, /datum/action/xeno_action/activable/pounce/lurker)
if (LPA && istype(LPA))
LPA.knockdown = TRUE // pounce knocks down
LPA.freeze_self = TRUE
var/datum/action/xeno_action/activable/pounce/lurker/lurker_pounce_action = get_xeno_action_by_type(bound_xeno, /datum/action/xeno_action/activable/pounce/lurker)
if (lurker_pounce_action)
lurker_pounce_action.knockdown = TRUE // pounce knocks down
lurker_pounce_action.freeze_self = TRUE
ADD_TRAIT(bound_xeno, TRAIT_CLOAKED, TRAIT_SOURCE_ABILITY("cloak"))
RegisterSignal(bound_xeno, COMSIG_MOB_EFFECT_CLOAK_CANCEL, PROC_REF(decloak_handler))
bound_xeno.stealth = TRUE
can_go_invisible = FALSE
invis_start_time = world.time

/datum/behavior_delegate/lurker_base/proc/on_invisibility_off()
var/datum/action/xeno_action/activable/pounce/lurker/LPA = get_xeno_action_by_type(bound_xeno, /datum/action/xeno_action/activable/pounce/lurker)
if (LPA && istype(LPA))
LPA.knockdown = FALSE // pounce no longer knocks down
LPA.freeze_self = FALSE
var/datum/action/xeno_action/activable/pounce/lurker/lurker_pounce_action = get_xeno_action_by_type(bound_xeno, /datum/action/xeno_action/activable/pounce/lurker)
if (lurker_pounce_action)
lurker_pounce_action.knockdown = FALSE // pounce no longer knocks down
lurker_pounce_action.freeze_self = FALSE
bound_xeno.stealth = FALSE
REMOVE_TRAIT(bound_xeno, TRAIT_CLOAKED, TRAIT_SOURCE_ABILITY("cloak"))
UnregisterSignal(bound_xeno, COMSIG_MOB_EFFECT_CLOAK_CANCEL)
Expand All @@ -153,9 +153,9 @@

can_go_invisible = TRUE
if(bound_xeno)
var/datum/action/xeno_action/onclick/lurker_invisibility/LIA = get_xeno_action_by_type(bound_xeno, /datum/action/xeno_action/onclick/lurker_invisibility)
if(LIA && istype(LIA))
LIA.end_cooldown()
var/datum/action/xeno_action/onclick/lurker_invisibility/lurker_invisibility_action = get_xeno_action_by_type(bound_xeno, /datum/action/xeno_action/onclick/lurker_invisibility)
if(lurker_invisibility_action)
lurker_invisibility_action.end_cooldown()

/datum/behavior_delegate/lurker_base/append_to_stat()
. = list()
Expand Down
Loading