Skip to content

Commit

Permalink
TGS Test Merge (#21025)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yogbot-13 committed Mar 23, 2024
2 parents 32a122f + afe2d1b commit 889f220
Show file tree
Hide file tree
Showing 31 changed files with 266 additions and 47 deletions.
5 changes: 5 additions & 0 deletions code/__DEFINES/dcs/signals/signals_object.dm
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@
#define COMSIG_ITEM_HIT_REACT "item_hit_react"
#define COMPONENT_HIT_REACTION_BLOCK (1<<0)

/// from /datum/component/cleave_attack/perform_sweep(): (atom/target, obj/item/item, mob/living/user, params)
#define COMSIG_ATOM_CLEAVE_ATTACK "atom_cleave_attack"
// allows cleave attack to hit things it normally wouldn't
#define ATOM_ALLOW_CLEAVE_ATTACK (1<<0)

/// Called before an item is embedded (mob/living/carbon/target = carbon that it is getting embedded into)
#define COMSIG_ITEM_EMBEDDED "mob_carbon_embedded"
// Prevents the embed
Expand Down
2 changes: 2 additions & 0 deletions code/__DEFINES/traits/declarations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define TRAIT_APC_SHOCKING "apc_shocking"
/// Properly wielded two handed item
#define TRAIT_WIELDED "wielded"
/// This item is currently performing a cleaving attack
#define TRAIT_CLEAVING "cleaving"
/// A transforming item that is actively extended / transformed
#define TRAIT_TRANSFORM_ACTIVE "active_transform"
/// Buckling yourself to objects with this trait won't immobilize you
Expand Down
141 changes: 141 additions & 0 deletions code/datums/components/cleave_attack.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/datum/component/cleave_attack
dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS
/// Size of the attack arc in degrees
var/arc_size
/// Make this TRUE for two-handed weapons like axes
var/requires_wielded
/// How much slower is it to swing
var/swing_speed_mod
/// Which effect should this use
var/cleave_effect
/// Whether this item is disallowed from hitting more than one target
var/no_multi_hit
/// Callback when the cleave attack is finished
var/datum/callback/cleave_end_callback

/datum/component/cleave_attack/Initialize(
arc_size=90,
swing_speed_mod=1.25,
requires_wielded=FALSE,
no_multi_hit=FALSE,
datum/callback/cleave_end_callback,
cleave_effect,
...
)

if(!isitem(parent))
return COMPONENT_INCOMPATIBLE

src.arc_size = arc_size
src.swing_speed_mod = swing_speed_mod
src.requires_wielded = requires_wielded
src.no_multi_hit = no_multi_hit
src.cleave_end_callback = cleave_end_callback
set_cleave_effect(cleave_effect) // set it based on arc size if an effect wasn't specified

/datum/component/cleave_attack/InheritComponent(
datum/component/C,
i_am_original,
arc_size,
swing_speed_mod,
requires_wielded,
datum/callback/cleave_end_callback,
cleave_effect
)

if(!i_am_original)
return
if(arc_size)
src.arc_size = arc_size
if(swing_speed_mod)
src.swing_speed_mod = swing_speed_mod
if(requires_wielded)
src.requires_wielded = requires_wielded
if(no_multi_hit)
src.no_multi_hit = no_multi_hit
if(cleave_end_callback)
src.cleave_end_callback = cleave_end_callback
set_cleave_effect(cleave_effect)

/// Sets the cleave effect to the specified effect, or based on arc size if one wasn't specified.
/datum/component/cleave_attack/proc/set_cleave_effect(new_effect)
if(new_effect)
cleave_effect = new_effect
return
switch(arc_size)
if(0 to 120)
cleave_effect = /obj/effect/temp_visual/dir_setting/firing_effect/sweep_attack
if(120 to 240)
cleave_effect = /obj/effect/temp_visual/dir_setting/firing_effect/sweep_attack/semicircle
else
cleave_effect = /obj/effect/temp_visual/dir_setting/firing_effect/sweep_attack/full_circle

/datum/component/cleave_attack/RegisterWithParent()
RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine))
RegisterSignal(parent, COMSIG_ITEM_AFTERATTACK, PROC_REF(on_afterattack))

/datum/component/cleave_attack/UnregisterFromParent()
UnregisterSignal(parent, list(COMSIG_ATOM_EXAMINE, COMSIG_ITEM_AFTERATTACK))

/datum/component/cleave_attack/proc/on_examine(atom/examined_item, mob/user, list/examine_list)
var/arc_desc
switch(arc_size)
if(0 to 90)
arc_desc = "narrow arc"
if(90 to 180)
arc_desc = "wide arc"
if(180 to 270)
arc_desc = "very wide arc"
if(270 to INFINITY)
arc_desc = "full circle"
examine_list += "It can swing in a [arc_desc]."

/datum/component/cleave_attack/proc/on_afterattack(obj/item/item, atom/target, mob/user, proximity_flag, click_parameters)
if(proximity_flag || user.a_intent != INTENT_HARM)
return // don't sweep on precise hits or non-harmful intents
perform_sweep(item, target, user, click_parameters)

/datum/component/cleave_attack/proc/perform_sweep(obj/item/item, atom/target, mob/living/user, params)
if(user.next_move > world.time)
return // don't spam it
if(requires_wielded && !HAS_TRAIT(item, TRAIT_WIELDED))
return // if it needs to be wielded, check to make sure it is

// some information we're going to need later
var/turf/user_turf = get_turf(user)
var/turf/center_turf = get_turf_in_angle(get_angle(user, target), user_turf)
var/facing_dir = get_dir(user, center_turf)
var/swing_direction = (user.active_hand_index % 2) ? -1 : 1

// make a list of turfs to swing across
var/list/turf_list = list()
var/turfs_count = round(arc_size / 90, 1)
for(var/i in -min(turfs_count, 3) to min(turfs_count, 4)) // do NOT hit the same tile more than once
turf_list.Add(get_step(user_turf, turn(facing_dir, i * 45 * swing_direction)))

// do some effects so everyone knows you're swinging a weapon
playsound(item, 'sound/weapons/punchmiss.ogg', 50, TRUE)
new cleave_effect(user_turf, facing_dir)

// now swing across those turfs
ADD_TRAIT(item, TRAIT_CLEAVING, REF(src))
attack_loop:
for(var/turf/T as anything in turf_list)
for(var/atom/movable/hit_atom in T)
if(hit_atom == user || hit_atom == target)
continue // why are you hitting yourself
if(!(SEND_SIGNAL(hit_atom, COMSIG_ATOM_CLEAVE_ATTACK, item, user) & ATOM_ALLOW_CLEAVE_ATTACK))
if(hit_atom.pass_flags & LETPASSTHROW)
continue // if you can throw something over it, you can swing over it too
if(!hit_atom.density && hit_atom.uses_integrity)
continue
item.melee_attack_chain(user, hit_atom, params)
if(no_multi_hit && isliving(hit_atom))
break attack_loop
REMOVE_TRAIT(item, TRAIT_CLEAVING, REF(src))

// do these last so they don't get overridden during the attack loop
cleave_end_callback?.Invoke(item, user)
user.do_attack_animation(center_turf, no_effect=TRUE)
user.changeNext_move(CLICK_CD_MELEE * item.weapon_stats[SWING_SPEED] * swing_speed_mod)
user.weapon_slow(item)
1 change: 1 addition & 0 deletions code/datums/martial/sleeping_carp.dm
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
AddComponent(/datum/component/two_handed, \
force_wielded = 14, \
)
AddComponent(/datum/component/cleave_attack, arc_size=180, requires_wielded=TRUE)

/obj/item/melee/bostaff/update_icon_state()
. = ..()
Expand Down
8 changes: 3 additions & 5 deletions code/game/mecha/equipment/weapons/melee_weapons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
/// Effect on hitting something
var/hit_effect = ATTACK_EFFECT_SLASH
/// Effect of the cleave attack
var/cleave_effect = /obj/effect/temp_visual/dir_setting/firing_effect/mecha_swipe
var/cleave_effect = /obj/effect/temp_visual/dir_setting/firing_effect/sweep_attack

/obj/item/mecha_parts/mecha_equipment/melee_weapon/can_attach(obj/mecha/M)
if(!..())
Expand Down Expand Up @@ -210,8 +210,7 @@
O.visible_message(span_danger("[chassis.name] strikes [O] with a wide swing of [src]!")) //Don't really need to make a message for EVERY object, just important ones
playsound(O,'sound/weapons/smash.ogg', 50) //metallic bonk noise

var/turf/cleave_effect_loc = get_step(get_turf(src), SOUTHWEST)
new cleave_effect(cleave_effect_loc, chassis.dir)
new cleave_effect(get_turf(src), chassis.dir)

/obj/item/mecha_parts/mecha_equipment/melee_weapon/sword/precise_attack(atom/target)
special_hit(target)
Expand Down Expand Up @@ -649,8 +648,7 @@
playsound(chassis, attack_sound, 50, 1)
for(var/turf/T in list(get_turf(chassis), get_step(chassis, chassis.dir), get_step(chassis, turn(chassis.dir, -45)), get_step(chassis, turn(chassis.dir, 45))))
do_mop(chassis, T, 3) // mop the floor with them!
var/turf/cleave_effect_loc = get_step(get_turf(src), SOUTHWEST)
new cleave_effect(cleave_effect_loc, chassis.dir)
new cleave_effect(get_turf(src), chassis.dir)

/obj/item/mecha_parts/mecha_equipment/melee_weapon/flyswatter
name = "comically large flyswatter"
Expand Down
51 changes: 30 additions & 21 deletions code/game/objects/effects/temporary_visuals/miscellaneous.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@
. = ..()
if(set_color)
color = set_color
var/target_pixel_x = 0
var/target_pixel_y = 0
var/target_pixel_x = pixel_x
var/target_pixel_y = pixel_y
switch(set_dir)
if(NORTH)
target_pixel_y = 16
target_pixel_y += 16
if(SOUTH)
target_pixel_y = -16
target_pixel_y += -16
layer = ABOVE_MOB_LAYER
if(EAST)
target_pixel_x = 16
target_pixel_x += 16
if(WEST)
target_pixel_x = -16
target_pixel_x += -16
if(NORTHEAST)
target_pixel_x = 16
target_pixel_y = 16
target_pixel_x += 16
target_pixel_y += 16
if(NORTHWEST)
target_pixel_x = -16
target_pixel_y = 16
target_pixel_x += -16
target_pixel_y += 16
if(SOUTHEAST)
target_pixel_x = 16
target_pixel_y = -16
target_pixel_x += 16
target_pixel_y += -16
layer = ABOVE_MOB_LAYER
if(SOUTHWEST)
target_pixel_x = -16
target_pixel_y = -16
target_pixel_x += -16
target_pixel_y += -16
layer = ABOVE_MOB_LAYER
animate(src, pixel_x = target_pixel_x, pixel_y = target_pixel_y, alpha = 0, time = duration)

Expand All @@ -71,14 +71,14 @@
switch(newdir)
if(NORTH)
layer = BELOW_MOB_LAYER
pixel_x = rand(-3,3)
pixel_y = rand(4,6)
pixel_x += rand(-3,3)
pixel_y += rand(4,6)
if(SOUTH)
pixel_x = rand(-3,3)
pixel_y = rand(-1,1)
pixel_x += rand(-3,3)
pixel_y += rand(-1,1)
else
pixel_x = rand(-1,1)
pixel_y = rand(-1,1)
pixel_x += rand(-1,1)
pixel_y += rand(-1,1)
..()

/obj/effect/temp_visual/dir_setting/firing_effect/energy
Expand All @@ -89,11 +89,20 @@
icon_state = "shieldsparkles"
duration = 0.3 SECONDS

/obj/effect/temp_visual/dir_setting/firing_effect/mecha_swipe
/obj/effect/temp_visual/dir_setting/firing_effect/sweep_attack
icon = 'icons/effects/96x96.dmi'
icon_state = "big_slash"
pixel_x = -32
pixel_y = -32
duration = 0.3 SECONDS

/obj/effect/temp_visual/dir_setting/firing_effect/sweep_attack/semicircle
icon_state = "big_slash_180"

/obj/effect/temp_visual/dir_setting/firing_effect/sweep_attack/full_circle
icon_state = "big_slash_360"
duration = 0.4 SECONDS

/obj/effect/temp_visual/dir_setting/ninja
name = "ninja shadow"
icon = 'icons/mob/mob.dmi'
Expand Down
18 changes: 18 additions & 0 deletions code/game/objects/items/holy_weapons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@
menutab = MENU_WEAPON
additional_desc = "An exceptionally large sword, capable of occasionally deflecting blows."

/obj/item/nullrod/claymore/Initialize(mapload)
. = ..()
AddComponent(/datum/component/cleave_attack)

/obj/item/nullrod/claymore/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
if(attack_type == PROJECTILE_ATTACK)
final_block_chance = 0 //Don't bring a sword to a gunfight
Expand Down Expand Up @@ -359,6 +363,10 @@
menutab = MENU_WEAPON
additional_desc = "The weapon of choice for a devout monk. Block incoming blows while striking weak points until your opponent is too exhausted to continue."

/obj/item/nullrod/bostaff/Initialize(mapload)
. = ..()
AddComponent(/datum/component/cleave_attack, arc_size=180)

/obj/item/nullrod/bostaff/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
if(attack_type == PROJECTILE_ATTACK)
final_block_chance = 0 //Don't bring a stick to a gunfight
Expand Down Expand Up @@ -610,6 +618,7 @@
. = ..()
ADD_TRAIT(src, TRAIT_NODROP, HAND_REPLACEMENT_TRAIT)
AddComponent(/datum/component/butchering, 30, 100, 0, hitsound)
AddComponent(/datum/component/cleave_attack)

/obj/item/nullrod/armblade
name = "dark blessing"
Expand All @@ -633,6 +642,7 @@
. = ..()
ADD_TRAIT(src, TRAIT_NODROP, HAND_REPLACEMENT_TRAIT)
AddComponent(/datum/component/butchering, 80, 70)
AddComponent(/datum/component/cleave_attack)

/obj/item/nullrod/armblade/tentacle
name = "unholy blessing"
Expand Down Expand Up @@ -1040,6 +1050,10 @@ it also swaps back if it gets thrown into the chaplain, but the chaplain catches
menutab = MENU_MISC
additional_desc = "You feel an unwoken presence in this one."

/obj/item/nullrod/talking/Initialize(mapload)
. = ..()
AddComponent(/datum/component/cleave_attack)

/obj/item/nullrod/talking/relaymove(mob/user)
return //stops buckled message spam for the ghost.

Expand Down Expand Up @@ -1340,6 +1354,10 @@ it also swaps back if it gets thrown into the chaplain, but the chaplain catches
menutab = MENU_MISC //banish it from being associated with proper weapons
additional_desc = "Hey, God here. Asking you to pick literally anything else as your implement of justice."

/obj/item/nullrod/sord/Initialize(mapload)
. = ..()
AddComponent(/datum/component/cleave_attack) // i guess???

//NOT CHAPLAIN SPAWNABLE
/obj/item/nullrod/talking/chainsword
name = "possessed chainsaw sword"
Expand Down
4 changes: 4 additions & 0 deletions code/game/objects/items/melee/energy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@
block_chance = 50
saber_color = "green"

/obj/item/melee/transforming/energy/sword/Initialize(mapload)
. = ..()
AddComponent(/datum/component/cleave_attack) // very cool

/obj/item/melee/transforming/energy/sword/attackby(obj/item/I, mob/living/user, params)
if(istype(I, /obj/item/melee/transforming/energy/sword))
if(HAS_TRAIT(I, TRAIT_NODROP) || HAS_TRAIT(src, TRAIT_NODROP))
Expand Down
5 changes: 5 additions & 0 deletions code/game/objects/items/melee/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,13 @@
hitsound = 'sound/weapons/rapierhit.ogg'
materials = list(/datum/material/iron = 1000)

/obj/item/melee/cutlass/Initialize(mapload)
. = ..()
AddComponent(/datum/component/cleave_attack)

/obj/item/melee/sabre/Initialize(mapload)
. = ..()
AddComponent(/datum/component/cleave_attack) // YES
AddComponent(/datum/component/butchering, 30, 95, 5) //fast and effective, but as a sword, it might damage the results.

/obj/item/melee/sabre/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
Expand Down
1 change: 1 addition & 0 deletions code/game/objects/items/singularityhammer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
force_wielded = 20, \
icon_wielded = "[base_icon_state]1", \
)
AddComponent(/datum/component/cleave_attack, arc_size=180, requires_wielded=TRUE)

/obj/item/mjolnir/update_icon_state()
. = ..()
Expand Down
4 changes: 4 additions & 0 deletions code/game/objects/items/tools/crowbar.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
item_state = "crowbar"
toolspeed = 0.7

/obj/item/crowbar/large/Initialize(mapload)
. = ..()
AddComponent(/datum/component/cleave_attack, no_multi_hit=TRUE) // it's big

/obj/item/crowbar/cyborg
name = "hydraulic crowbar"
desc = "A hydraulic prying tool, compact but powerful. Designed to replace crowbar in construction cyborgs."
Expand Down
Loading

0 comments on commit 889f220

Please sign in to comment.