From aab43cd8a8789019d6c523bc8563c5f29448c473 Mon Sep 17 00:00:00 2001 From: mister-onion Date: Tue, 17 Dec 2024 14:53:17 +0300 Subject: [PATCH 1/6] shield --- code/datums/personal_statistics.dm | 7 ++ .../castes/warlock/abilities_warlock.dm | 89 +++++++++++++------ 2 files changed, 71 insertions(+), 25 deletions(-) diff --git a/code/datums/personal_statistics.dm b/code/datums/personal_statistics.dm index de5e8e0e1da..90e571a5ad4 100644 --- a/code/datums/personal_statistics.dm +++ b/code/datums/personal_statistics.dm @@ -534,6 +534,13 @@ The alternative is scattering them everywhere under their respective objects whi personal_statistics.projectiles_reflected += amount return TRUE +/// Adds to the personal statistics if the reflected projectile was a rocket. +/obj/effect/xeno/shield/proc/record_rocket_reflection(mob/user, obj/projectile/projectile) + if(!istype(projectile.ammo, /datum/ammo/rocket) || !user.ckey) + return + var/datum/personal_statistics/personal_statistics = GLOB.personal_statistics_list[user.ckey] + personal_statistics.rockets_reflected++ + ///Tally when a structure is constructed /mob/proc/record_structures_built() if(!ckey) diff --git a/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm b/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm index 9461b894c41..8cdbcc5f633 100644 --- a/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm +++ b/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm @@ -59,8 +59,10 @@ KEYBINDING_ALTERNATE = COMSIG_XENOABILITY_TRIGGER_PSYCHIC_SHIELD, ) use_state_flags = ABILITY_USE_BUSY - /// The actual shield object created by this ability + /// The actual shield object created by this ability. var/obj/effect/xeno/shield/active_shield + /// Whether to use the alternative mode of projectile reflection. Makes shields weaker, but sends projectiles toward a selected target. + var/alternative_reflection = FALSE /datum/action/ability/activable/xeno/psychic_shield/remove_action(mob/M) if(active_shield) @@ -77,20 +79,28 @@ if(can_use_ability(null, FALSE, ABILITY_IGNORE_SELECTED_ABILITY)) INVOKE_ASYNC(src, PROC_REF(use_ability)) +/datum/action/ability/activable/xeno/psychic_shield/action_activate() + var/mob/living/carbon/xenomorph/xeno_owner = owner + if(xeno_owner.selected_ability == src && xeno_owner.upgrade == XENO_UPGRADE_PRIMO) + alternative_reflection = !alternative_reflection + // Reflects projectiles toward a target (targetted) / reflects projectiles as if it was bounced (normal). + owner.balloon_alert(owner, alternative_reflection ? "targetted reflection" : "normal reflection") + return ..() -/datum/action/ability/activable/xeno/psychic_shield/use_ability(atom/A) +/datum/action/ability/activable/xeno/psychic_shield/use_ability(atom/targetted_atom) var/mob/living/carbon/xenomorph/xeno_owner = owner if(active_shield) if(ability_cost > xeno_owner.plasma_stored) owner.balloon_alert(owner, "[ability_cost - xeno_owner.plasma_stored] more plasma!") return FALSE if(can_use_action(FALSE, ABILITY_USE_BUSY)) - shield_blast() + shield_blast(targetted_atom) cancel_shield() return - if(A) - owner.dir = get_cardinal_dir(owner, A) //if activated by mouse click, we face the atom clicked + // If activated by mouse click, face the atom clicked. + if(targetted_atom) + owner.dir = get_cardinal_dir(owner, targetted_atom) var/turf/target_turf = get_step(owner, owner.dir) if(target_turf.density) @@ -112,7 +122,10 @@ GLOB.round_statistics.psy_shields++ SSblackbox.record_feedback(FEEDBACK_TALLY, "round_statistics", 1, "psy_shields") - active_shield = new(target_turf, owner) + if(alternative_reflection) + active_shield = new /obj/effect/xeno/shield/special(target_turf, owner) + else + active_shield = new(target_turf, owner) if(!do_after(owner, 6 SECONDS, NONE, owner, BUSY_ICON_DANGER, extra_checks = CALLBACK(src, PROC_REF(can_use_action), FALSE, ABILITY_USE_BUSY))) cancel_shield() return @@ -131,10 +144,10 @@ QDEL_NULL(active_shield) ///AOE knockback triggerable by ending the shield early -/datum/action/ability/activable/xeno/psychic_shield/proc/shield_blast() +/datum/action/ability/activable/xeno/psychic_shield/proc/shield_blast(atom/targetted_atom) succeed_activate() - active_shield.reflect_projectiles() + active_shield.reflect_projectiles(targetted_atom) owner.visible_message(span_xenowarning("[owner] sends out a huge blast of psychic energy!"), span_xenowarning("We send out a huge blast of psychic energy!")) @@ -188,6 +201,8 @@ var/mob/living/carbon/xenomorph/owner ///All the projectiles currently frozen by this obj var/list/frozen_projectiles = list() + /// If reflecting projectiles should go to a targetted atom. + var/alternative_reflection = FALSE /obj/effect/xeno/shield/Initialize(mapload, creator) . = ..() @@ -205,6 +220,8 @@ bound_width = 96 bound_x = -32 pixel_x = -32 + if(alternative_reflection) // The easy alternative to spriting 92 frames. + add_atom_colour("#ff000d", FIXED_COLOR_PRIORITY) /obj/effect/xeno/shield/projectile_hit(obj/projectile/proj, cardinal_move, uncrossing) if(!(cardinal_move & REVERSE_DIR(dir))) @@ -234,28 +251,50 @@ record_projectiles_frozen(owner, LAZYLEN(frozen_projectiles)) ///Reflects projectiles based on their relative incoming angle -/obj/effect/xeno/shield/proc/reflect_projectiles() +/obj/effect/xeno/shield/proc/reflect_projectiles(atom/targetted_atom) playsound(loc, 'sound/effects/portal.ogg', 20) - var/perpendicular_angle = Get_Angle(get_turf(src), get_step(src, dir)) //the angle src is facing, get_turf because pixel_x or y messes with the angle - for(var/obj/projectile/proj AS in frozen_projectiles) - proj.flags_projectile_behavior &= ~PROJECTILE_FROZEN - proj.distance_travelled = 0 //we're effectively firing it fresh - var/new_angle = (perpendicular_angle + (perpendicular_angle - proj.dir_angle - 180)) - if(new_angle < 0) - new_angle += 360 - else if(new_angle > 360) - new_angle -= 360 - proj.fire_at(source = src, angle = new_angle, recursivity = TRUE) - - //Record those sick rocket shots - //Is not part of record_projectiles_frozen() because it is probably bad to be running that for every bullet! - if(istype(proj.ammo, /datum/ammo/rocket) && owner.client) - var/datum/personal_statistics/personal_statistics = GLOB.personal_statistics_list[owner.ckey] - personal_statistics.rockets_reflected++ + + var/direction_to_atom = angle_to_dir(Get_Angle(src, targetted_atom)) + for(var/obj/projectile/reflected_projectile AS in frozen_projectiles) + reflected_projectile.projectile_behavior_flags &= ~PROJECTILE_FROZEN + reflected_projectile.distance_travelled = 0 + + // If alternative reflection is on, try to deflect toward the targetted area that we're facing. + if(alternative_reflection) + var/bad_angle = TRUE + switch(dir) + if(NORTH) + if(direction_to_atom == NORTHWEST || direction_to_atom == NORTH || direction_to_atom == NORTHEAST) + bad_angle = FALSE + if(EAST) + if(direction_to_atom == NORTHEAST || direction_to_atom == EAST || direction_to_atom == SOUTHEAST) + bad_angle = FALSE + if(SOUTH) + if(direction_to_atom == SOUTHEAST || direction_to_atom == SOUTH || direction_to_atom == SOUTHWEST) + bad_angle = FALSE + if(WEST) + if(direction_to_atom == SOUTHWEST || direction_to_atom == WEST || direction_to_atom == NORTHWEST) + bad_angle = FALSE + if(!bad_angle) + reflected_projectile.fire_at(targetted_atom, source = src, recursivity = TRUE) + record_rocket_reflection(owner, reflected_projectile) + continue + + // If alternative reflection is off OR it fails to get an acceptable angle, reflect it as if it bounced off the shield. + var/bounced_angle = perpendicular_angle + (perpendicular_angle - reflected_projectile.dir_angle - 180) + if(bounced_angle < 0) + bounced_angle += 360 + else if(bounced_angle > 360) + bounced_angle -= 360 + reflected_projectile.fire_at(source = src, angle = bounced_angle, recursivity = TRUE) + record_rocket_reflection(owner, reflected_projectile) record_projectiles_frozen(owner, LAZYLEN(frozen_projectiles), TRUE) frozen_projectiles.Cut() +/obj/effect/xeno/shield/special + max_integrity = 325 + alternative_reflection = TRUE // *************************************** // *********** psychic crush From c707ac5e289cc2247842451b0fe3546ed2a02d0f Mon Sep 17 00:00:00 2001 From: mister-onion Date: Tue, 17 Dec 2024 15:59:58 +0300 Subject: [PATCH 2/6] fix --- .../carbon/xenomorph/castes/warlock/abilities_warlock.dm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm b/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm index 8cdbcc5f633..cf1df59c1d4 100644 --- a/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm +++ b/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm @@ -221,7 +221,7 @@ bound_x = -32 pixel_x = -32 if(alternative_reflection) // The easy alternative to spriting 92 frames. - add_atom_colour("#ff000d", FIXED_COLOR_PRIORITY) + add_atom_colour("#ff000d", FIXED_COLOUR_PRIORITY) /obj/effect/xeno/shield/projectile_hit(obj/projectile/proj, cardinal_move, uncrossing) if(!(cardinal_move & REVERSE_DIR(dir))) @@ -254,9 +254,10 @@ /obj/effect/xeno/shield/proc/reflect_projectiles(atom/targetted_atom) playsound(loc, 'sound/effects/portal.ogg', 20) + var/perpendicular_angle = Get_Angle(get_turf(src), get_step(src, dir)) //the angle src is facing, get_turf because pixel_x or y messes with the angle var/direction_to_atom = angle_to_dir(Get_Angle(src, targetted_atom)) for(var/obj/projectile/reflected_projectile AS in frozen_projectiles) - reflected_projectile.projectile_behavior_flags &= ~PROJECTILE_FROZEN + reflected_projectile.flags_projectile_behavior &= ~PROJECTILE_FROZEN reflected_projectile.distance_travelled = 0 // If alternative reflection is on, try to deflect toward the targetted area that we're facing. From 470d39abec9045f8440b30c7fab593fa90d7220b Mon Sep 17 00:00:00 2001 From: mister-onion Date: Tue, 17 Dec 2024 16:01:48 +0300 Subject: [PATCH 3/6] https://github.com/tgstation/TerraGov-Marine-Corps/pull/16772 --- .../living/carbon/xenomorph/castes/warlock/abilities_warlock.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm b/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm index cf1df59c1d4..0e5ee1f51f9 100644 --- a/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm +++ b/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm @@ -191,7 +191,7 @@ SSblackbox.record_feedback(FEEDBACK_TALLY, "round_statistics", 1, "psy_shield_blasts") -/obj/effect/xeno/shield +/obj/effect/xeno/shield //sss icon = 'icons/Xeno/96x96.dmi' icon_state = "shield" resistance_flags = UNACIDABLE|PLASMACUTTER_IMMUNE From 68278374cfedaf9ddb4759208a3e9ef7c04cd54f Mon Sep 17 00:00:00 2001 From: mister-onion Date: Tue, 17 Dec 2024 16:04:37 +0300 Subject: [PATCH 4/6] f --- .../living/carbon/xenomorph/castes/warlock/abilities_warlock.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm b/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm index 0e5ee1f51f9..cf1df59c1d4 100644 --- a/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm +++ b/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm @@ -191,7 +191,7 @@ SSblackbox.record_feedback(FEEDBACK_TALLY, "round_statistics", 1, "psy_shield_blasts") -/obj/effect/xeno/shield //sss +/obj/effect/xeno/shield icon = 'icons/Xeno/96x96.dmi' icon_state = "shield" resistance_flags = UNACIDABLE|PLASMACUTTER_IMMUNE From 7171e882b611f2e2e8ace139ab9b134e6dbc31b1 Mon Sep 17 00:00:00 2001 From: mister-onion Date: Sat, 21 Dec 2024 16:55:01 +0300 Subject: [PATCH 5/6] redcolor --- .../carbon/xenomorph/castes/warlock/abilities_warlock.dm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm b/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm index cf1df59c1d4..fc0469f5ac3 100644 --- a/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm +++ b/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm @@ -220,8 +220,6 @@ bound_width = 96 bound_x = -32 pixel_x = -32 - if(alternative_reflection) // The easy alternative to spriting 92 frames. - add_atom_colour("#ff000d", FIXED_COLOUR_PRIORITY) /obj/effect/xeno/shield/projectile_hit(obj/projectile/proj, cardinal_move, uncrossing) if(!(cardinal_move & REVERSE_DIR(dir))) @@ -296,6 +294,7 @@ /obj/effect/xeno/shield/special max_integrity = 325 alternative_reflection = TRUE + color ="#ff000d" // *************************************** // *********** psychic crush From 0bc213279915a6cb5c9186619a0fe9a0e005414e Mon Sep 17 00:00:00 2001 From: Helg2 <93882977+Helg2@users.noreply.github.com> Date: Sat, 21 Dec 2024 16:00:55 +0200 Subject: [PATCH 6/6] Update code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm Signed-off-by: Helg2 <93882977+Helg2@users.noreply.github.com> --- .../living/carbon/xenomorph/castes/warlock/abilities_warlock.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm b/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm index fc0469f5ac3..dfe97779d17 100644 --- a/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm +++ b/code/modules/mob/living/carbon/xenomorph/castes/warlock/abilities_warlock.dm @@ -294,7 +294,7 @@ /obj/effect/xeno/shield/special max_integrity = 325 alternative_reflection = TRUE - color ="#ff000d" + color = "#ff000d" // *************************************** // *********** psychic crush