Skip to content

Commit

Permalink
more throwbug fixes (#14306)
Browse files Browse the repository at this point in the history
* THROWCODEPLEASE

* fixes pounce bump

* fixes facehugger visual again

* mild hugger refactor
  • Loading branch information
Lumipharon authored Oct 31, 2023
1 parent 588aaa3 commit 7a90650
Show file tree
Hide file tree
Showing 18 changed files with 105 additions and 75 deletions.
1 change: 1 addition & 0 deletions code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ directive is properly returned.
/atom/proc/hitby(atom/movable/AM, speed = 5)
if(density)
AM.stop_throw()
return TRUE


/atom/proc/GenerateTag()
Expand Down
21 changes: 9 additions & 12 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
return COMPONENT_BUMP_RESOLVED
. = ..()
if(throwing)
. = throw_impact(A)
. = !throw_impact(A)
if(QDELETED(A))
return
A.Bumped(src)
Expand Down Expand Up @@ -469,19 +469,16 @@
for(var/atom/movable/location AS in nested_locs)
LAZYORASSOCLIST(location.important_recursive_contents, channel, arrived.important_recursive_contents[channel])

//called when src is thrown into hit_atom
///called when src is thrown into hit_atom
/atom/movable/proc/throw_impact(atom/hit_atom, speed, bounce = TRUE)
if(isliving(hit_atom))
var/mob/living/M = hit_atom
M.hitby(src, speed)

else
var/old_throw_source = throw_source
hit_atom.hitby(src, speed)
if(bounce && hit_atom.density)
var/hit_successful
var/old_throw_source = throw_source
hit_successful = hit_atom.hitby(src, speed)
if(hit_successful)
SEND_SIGNAL(src, COMSIG_MOVABLE_IMPACT, hit_atom)
if(bounce && hit_atom.density && !isliving(hit_atom))
INVOKE_NEXT_TICK(src, PROC_REF(throw_bounce), hit_atom, old_throw_source)

SEND_SIGNAL(src, COMSIG_MOVABLE_IMPACT, hit_atom)
return hit_successful //if the throw missed, it continues

///Bounces the AM off hit_atom
/atom/movable/proc/throw_bounce(atom/hit_atom, turf/old_throw_source)
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 @@ -332,7 +332,7 @@ GLOBAL_DATUM_INIT(welding_sparks_prepdoor, /mutable_appearance, mutable_appearan
///When hit by a thrown object, play the associated hitsound of the object
/obj/item/throw_impact(atom/hit_atom, speed, bounce)
. = ..()
if(isliving(hit_atom))
if(. && isliving(hit_atom))
playsound(src, hitsound, 50)

// apparently called whenever an item is removed from a slot, container, or anything else.
Expand Down
16 changes: 13 additions & 3 deletions code/game/objects/items/explosives/grenades/marines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@

/obj/item/explosive/grenade/sticky/throw_impact(atom/hit_atom, speed)
. = ..()
if(!.)
return
if(!active || stuck_to || isturf(hit_atom))
return TRUE
return
var/image/stuck_overlay = image(icon, hit_atom, initial(icon_state) + "_stuck")
stuck_overlay.pixel_x = rand(-5, 5)
stuck_overlay.pixel_y = rand(-7, 7)
Expand Down Expand Up @@ -129,7 +131,7 @@

/obj/item/explosive/grenade/sticky/trailblazer/throw_impact(atom/hit_atom, speed)
. = ..()
if(.)
if(!.)
return
RegisterSignal(stuck_to, COMSIG_MOVABLE_MOVED, PROC_REF(make_fire))
var/turf/T = get_turf(src)
Expand Down Expand Up @@ -171,7 +173,7 @@

/obj/item/explosive/grenade/sticky/cloaker/throw_impact(atom/hit_atom, speed)
. = ..()
if(.)
if(!.)
return
RegisterSignal(stuck_to, COMSIG_MOVABLE_MOVED, PROC_REF(make_smoke))

Expand Down Expand Up @@ -239,6 +241,8 @@

/obj/item/explosive/grenade/incendiary/molotov/throw_impact(atom/hit_atom, speed, bounce = TRUE)
. = ..()
if(!.)
return
if(!hit_atom.density || prob(35))
return
prime()
Expand Down Expand Up @@ -411,6 +415,8 @@

/obj/item/explosive/grenade/impact/throw_impact(atom/hit_atom, speed)
. = ..()
if(!.)
return
if(launched && active && !istype(hit_atom, /turf/open)) //Only contact det if active, we actually hit something, and we're fired from a grenade launcher.
explosion(loc, light_impact_range = 1, flash_range = 2)
qdel(src)
Expand Down Expand Up @@ -522,6 +528,8 @@

/obj/item/explosive/grenade/flare/throw_impact(atom/hit_atom, speed)
. = ..()
if(!.)
return
if(!active)
return

Expand Down Expand Up @@ -592,6 +600,8 @@

/obj/item/explosive/grenade/flare/strongerflare/throw_impact(atom/hit_atom, speed)
. = ..()
if(!.)
return
anchored = TRUE//prevents marines from picking up and running around with a stronger flare

/obj/item/explosive/grenade/flare/strongerflare/update_brightness()
Expand Down
4 changes: 3 additions & 1 deletion code/game/objects/items/reagent_containers/food/piecake.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
bitesize = 3

/obj/item/reagent_containers/food/snacks/pastries/pie/throw_impact(atom/hit_atom)
..()
. = ..()
if(!.)
return
new /obj/effect/decal/cleanable/pie_smudge(loc)
visible_message(span_warning(" [src.name] splats."),span_warning(" You hear a splat."))
qdel(src)
Expand Down
4 changes: 3 additions & 1 deletion code/game/objects/items/reagent_containers/food/snacks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,9 @@
tastes = list("egg" = 1)

/obj/item/reagent_containers/food/snacks/egg/throw_impact(atom/hit_atom)
..()
. = ..()
if(!.)
return
new/obj/effect/decal/cleanable/egg_smudge(src.loc)
src.reagents.reaction(hit_atom, TOUCH)
src.visible_message(span_warning(" [src.name] has been squashed."),span_warning(" You hear a smack."))
Expand Down
16 changes: 12 additions & 4 deletions code/game/objects/items/reagent_containers/food/snacks/grown.dm
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,9 @@
plantname = "tomato"

/obj/item/reagent_containers/food/snacks/grown/tomato/throw_impact(atom/hit_atom)
..()
. = ..()
if(!.)
return
new/obj/effect/decal/cleanable/tomato_smudge(src.loc)
src.visible_message(span_notice("The [src.name] has been squashed."),span_moderate("You hear a smack."))
qdel(src)
Expand All @@ -348,7 +350,9 @@
plantname = "bloodtomato"

/obj/item/reagent_containers/food/snacks/grown/bloodtomato/throw_impact(atom/hit_atom)
..()
. = ..()
if(!.)
return
new/obj/effect/decal/cleanable/blood/splatter(src.loc)
src.visible_message(span_notice("The [src.name] has been squashed."),span_moderate("You hear a smack."))
src.reagents.reaction(get_turf(hit_atom))
Expand All @@ -370,7 +374,9 @@
AddComponent(/datum/component/slippery, 0.8 SECONDS, 0.5 SECONDS)

/obj/item/reagent_containers/food/snacks/grown/bluetomato/throw_impact(atom/hit_atom)
..()
. = ..()
if(!.)
return
new/obj/effect/decal/cleanable/blood/oil(src.loc)
src.visible_message(span_notice("The [src.name] has been squashed."),span_moderate("You hear a smack."))
src.reagents.reaction(get_turf(hit_atom))
Expand Down Expand Up @@ -506,7 +512,9 @@
plantname = "bluespacetomato"

/obj/item/reagent_containers/food/snacks/grown/bluespacetomato/throw_impact(atom/hit_atom)
..()
. = ..()
if(!.)
return
var/mob/M = usr
var/outer_teleport_radius = potency/10 //Plant potency determines radius of teleport.
var/inner_teleport_radius = potency/15
Expand Down
7 changes: 6 additions & 1 deletion code/game/objects/items/toys/toys.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@


/obj/item/toy/balloon/throw_impact(atom/hit_atom)
. = ..()
if(!.)
return
if(src.reagents.total_volume >= 1)
src.visible_message(span_warning(" The [src] bursts!"),"You hear a pop and a splash.")
src.reagents.reaction(get_turf(hit_atom), TOUCH)
Expand Down Expand Up @@ -174,7 +177,9 @@
AddElement(/datum/element/connect_loc, connections)

/obj/item/toy/snappop/throw_impact(atom/hit_atom)
..()
. = ..()
if(!.)
return
var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread
s.set_up(3, 1, src)
s.start()
Expand Down
3 changes: 0 additions & 3 deletions code/game/objects/items/weapons/twohanded.dm
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,6 @@
transform = rotate_me
return ..()

/obj/item/weapon/twohanded/spear/throw_impact(atom/hit_atom, speed, bounce = FALSE)
. = ..()

/obj/item/weapon/twohanded/spear/pickup(mob/user)
. = ..()
if(initial(current_angle) == current_angle)
Expand Down
2 changes: 2 additions & 0 deletions code/game/objects/obj_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@

/obj/hitby(atom/movable/AM, speed = 5)
. = ..()
if(!.)
return
if(!anchored && (move_resist < MOVE_FORCE_STRONG))
step(src, AM.dir)
visible_message(span_warning("[src] was hit by [AM]."), visible_message_flags = COMBAT_MESSAGE)
Expand Down
1 change: 1 addition & 0 deletions code/game/turfs/closed.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
/turf/closed/hitby(atom/movable/AM, speed = 5)
AM.stop_throw()
AM.turf_collision(src, speed)
return TRUE

/turf/closed/mineral
name = "rock"
Expand Down
2 changes: 2 additions & 0 deletions code/modules/assembly/infrared.dm
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@

/obj/item/assembly/infra/throw_impact(atom/hit_atom)
. = ..()
if(!.)
return
if(!olddir)
return
setDir(olddir)
Expand Down
3 changes: 3 additions & 0 deletions code/modules/flufftext/Hallucination.dm
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ GLOBAL_LIST_INIT(hallucination_list, list(
name = "Mature Runner ([rand(100, 999)])"

/obj/effect/hallucination/simple/xeno/throw_impact(atom/hit_atom, speed)
. = ..()
if(!.)
return
if(hit_atom == target && target.stat != DEAD)
target.Paralyze(3 SECONDS, TRUE, TRUE)
target.visible_message(span_danger("[target] flails around wildly."),span_xenowarning("\The [src] pounces at [target]!"))
Expand Down
27 changes: 14 additions & 13 deletions code/modules/mob/living/carbon/human/human_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ Contains most of the procs that are called when a mob is attacked by something
throw_mode_off()
if(living_thrower)
log_combat(living_thrower, src, "thrown at", thrown_item, "(FAILED: caught)")
return
return TRUE

throw_damage = thrown_item.throwforce * speed * 0.2

Expand All @@ -259,7 +259,7 @@ Contains most of the procs that are called when a mob is attacked by something
visible_message(span_notice(" \The [thrown_item] misses [src] narrowly!"), null, null, 5)
if(living_thrower)
log_combat(living_thrower, src, "thrown at", thrown_item, "(FAILED: missed)")
return
return FALSE

if(thrown_item.thrower != src)
throw_damage = check_shields(COMBAT_MELEE_ATTACK, throw_damage, MELEE)
Expand All @@ -268,21 +268,21 @@ Contains most of the procs that are called when a mob is attacked by something
visible_message(span_danger("[src] deflects \the [thrown_item]!"))
if(living_thrower)
log_combat(living_thrower, src, "thrown at", thrown_item, "(FAILED: shield blocked)")
return
return TRUE

var/datum/limb/affecting = get_limb(zone)

if(affecting.limb_status & LIMB_DESTROYED)
log_combat(living_thrower, src, "thrown at", thrown_item, "(FAILED: target limb missing)")
return
return FALSE

thrown_item.stop_throw() // Hit the limb.
var/applied_damage = modify_by_armor(throw_damage, MELEE, thrown_item.penetration, zone)

if(applied_damage <= 0)
visible_message(span_notice("\The [thrown_item] bounces on [src]'s armor!"), null, null, 5)
log_combat(living_thrower, src, "thrown at", thrown_item, "(FAILED: armor blocked)")
return
return TRUE

visible_message(span_warning("[src] has been hit in the [affecting.display_name] by \the [thrown_item]."), null, null, 5)

Expand All @@ -307,14 +307,15 @@ Contains most of the procs that are called when a mob is attacked by something
throw_at(get_edge_target_turf(src, get_dir(AM.throw_source, src)), 1, speed * 0.5)
hit_report += "(thrown away)"

if(!living_thrower)
return
log_combat(living_thrower, src, "thrown at", AM, "[hit_report.Join(" ")]")
if(throw_damage && !living_thrower.mind?.bypass_ff && !mind?.bypass_ff && living_thrower.faction == faction)
var/turf/T = get_turf(src)
living_thrower.ff_check(throw_damage, src)
log_ffattack("[key_name(living_thrower)] hit [key_name(src)] with \the [AM] (thrown) in [AREACOORD(T)] [hit_report.Join(" ")].")
msg_admin_ff("[ADMIN_TPMONTY(living_thrower)] hit [ADMIN_TPMONTY(src)] with \the [AM] (thrown) in [ADMIN_VERBOSEJMP(T)] [hit_report.Join(" ")].")
if(living_thrower)
log_combat(living_thrower, src, "thrown at", AM, "[hit_report.Join(" ")]")
if(throw_damage && !living_thrower.mind?.bypass_ff && !mind?.bypass_ff && living_thrower.faction == faction)
var/turf/T = get_turf(src)
living_thrower.ff_check(throw_damage, src)
log_ffattack("[key_name(living_thrower)] hit [key_name(src)] with \the [AM] (thrown) in [AREACOORD(T)] [hit_report.Join(" ")].")
msg_admin_ff("[ADMIN_TPMONTY(living_thrower)] hit [ADMIN_TPMONTY(src)] with \the [AM] (thrown) in [ADMIN_VERBOSEJMP(T)] [hit_report.Join(" ")].")

return TRUE


/mob/living/carbon/human/resist_fire(datum/source)
Expand Down
Loading

0 comments on commit 7a90650

Please sign in to comment.