Skip to content

Commit

Permalink
Merge pull request #4686 from MistakeNot4892/fixes/staging
Browse files Browse the repository at this point in the history
Misc staging fixes.
  • Loading branch information
out-of-phaze authored Jan 2, 2025
2 parents acd8d61 + e6bc444 commit 48d91e1
Show file tree
Hide file tree
Showing 14 changed files with 133 additions and 132 deletions.
22 changes: 1 addition & 21 deletions code/_onclick/click.dm
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,6 @@
var/sdepth = A.storage_depth(src)
if((!isturf(A) && A == loc) || (sdepth != -1 && sdepth <= 1))
if(holding)

// AI driven mobs have a melee telegraph that needs to be handled here.
if(a_intent == I_HURT && istype(A) && (!do_attack_windup_checking(A) || holding != get_active_held_item()))
return TRUE

var/resolved = holding.resolve_attackby(A, src, params)
if(!resolved && A && holding)
holding.afterattack(A, src, 1, params) // 1 indicates adjacency
Expand All @@ -143,10 +138,6 @@
if(A.Adjacent(src)) // see adjacent.dm
if(holding)

// AI driven mobs have a melee telegraph that needs to be handled here.
if(a_intent == I_HURT && istype(A) && (!do_attack_windup_checking(A) || holding != get_active_held_item()))
return TRUE

// Return 1 in attackby() to prevent afterattack() effects (when safely moving items for example)
var/resolved = holding.resolve_attackby(A, src, params)
if(!resolved && A && holding)
Expand Down Expand Up @@ -217,18 +208,7 @@
if(istype(G) && G.Touch(A,1))
return TRUE

// Pick up items.
if(check_dexterity(DEXTERITY_HOLD_ITEM, silent = TRUE))
return A.attack_hand(src)

// TODO: some way to check if we SHOULD be doing an attack windup here;
// corgis attacking a tree, for example, will do the windup animation despite
// having no interaction or message shown at the end of it.
// AI driven mobs have a melee telegraph that needs to be handled here.
if(a_intent == I_HURT && istype(A) && !do_attack_windup_checking(A))
return TRUE

return FALSE
return A.attack_hand(src)

/*
Ranged unarmed attack:
Expand Down
6 changes: 6 additions & 0 deletions code/_onclick/other_mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@
/atom/proc/can_interact_with_storage(user, strict = FALSE)
return isliving(user)

/atom/proc/get_required_interaction_dexterity()
return DEXTERITY_NONE

/atom/proc/attack_hand(mob/user)
SHOULD_CALL_PARENT(TRUE)

if(!user.check_dexterity(get_required_interaction_dexterity(), silent = TRUE))
return FALSE

if(can_interact_with_storage(user, strict = TRUE) && storage && user.check_dexterity((DEXTERITY_HOLD_ITEM|DEXTERITY_EQUIP_ITEM), TRUE))
add_fingerprint(user)
storage.open(user)
Expand Down
60 changes: 36 additions & 24 deletions code/datums/ai/aggressive.dm
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,14 @@
return TRUE

/datum/mob_controller/aggressive/proc/attack_target()

set waitfor = FALSE

var/atom/target = get_target()
if(!istype(target))
lose_target()
return

if(isliving(target) && body.buckled_mob == target && (!body.faction || body.buckled_mob.faction != body.faction))
body.visible_message(SPAN_DANGER("\The [body] attempts to unseat \the [body.buckled_mob]!"))
body.set_dir(pick(global.cardinal))
Expand All @@ -107,11 +111,21 @@
var/mob/living/victim = target
SET_STATUS_MAX(victim, STAT_WEAK, 3)
return target
if(body.Adjacent(target))
body.a_intent = I_HURT
body.ClickOn(target)

if(!body.Adjacent(target))
return target

// AI-driven mobs have a melee telegraph that needs to be handled here.
if(!body.do_attack_windup_checking(target))
return target

if(QDELETED(body) || body.incapacitated() || QDELETED(target))
return target

body.a_intent = I_HURT
body.ClickOn(target)
return target

/datum/mob_controller/aggressive/destroy_surroundings()

if(!body.can_act())
Expand Down Expand Up @@ -174,27 +188,25 @@
if(!(. = ..()))
return

if(!only_attack_enemies)
if(source)
set_target(source)
move_to_target(move_only = TRUE)
return

var/list/allies
var/list/around = view(body, 7)
for(var/atom/movable/A in around)
if(A == body || !isliving(A))
continue
var/mob/living/M = A
if(attack_same_faction || M.faction != body.faction)
add_enemy(M)
else if(istype(M.ai))
LAZYADD(allies, M.ai)

var/list/enemies = get_enemies()
if(LAZYLEN(enemies) && LAZYLEN(allies))
for(var/datum/mob_controller/ally as anything in allies)
ally.add_enemies(enemies)
if(only_attack_enemies)
var/list/allies
var/list/around = view(body, 7)
for(var/atom/movable/A in around)
if(A == body || !isliving(A))
continue
var/mob/living/M = A
if(attack_same_faction || M.faction != body.faction)
add_enemy(M)
else if(istype(M.ai))
LAZYADD(allies, M.ai)
var/list/enemies = get_enemies()
if(LAZYLEN(enemies) && LAZYLEN(allies))
for(var/datum/mob_controller/ally as anything in allies)
ally.add_enemies(enemies)

if(source)
set_target(source)
move_to_target(move_only = TRUE)

/datum/mob_controller/aggressive/move_to_target(var/move_only = FALSE)
if(!body.can_act())
Expand Down
3 changes: 2 additions & 1 deletion code/game/objects/items/__item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
var/paint_verb

/// What dexterity is required to attack with this item?
var/needs_attack_dexterity = DEXTERITY_WIELD_ITEM
var/needs_attack_dexterity = DEXTERITY_WIELD_ITEM
var/needs_interaction_dexterity = DEXTERITY_HOLD_ITEM

/// Vars relating to wielding the item with two or more hands.
var/can_be_twohanded = FALSE
Expand Down
26 changes: 16 additions & 10 deletions code/game/objects/items/_item_melting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,22 @@
try_burn_wearer(holder, holder.get_equipped_slot_for_item(src))

// Temp gate until generalized temperature-based melting works properly.
if(istype(loc, /obj/item/chems/crucible))
// Check if this is meltable at all.
var/list/meltable_materials
for(var/mat in matter)
var/decl/material/melt_material = GET_DECL(mat)
if(!isnull(melt_material.melting_point) && temperature >= melt_material.melting_point)
LAZYDISTINCTADD(meltable_materials, melt_material)
if(length(meltable_materials))
. = null // Don't return PROCESS_KILL here.
handle_melting(meltable_materials)
var/static/list/_melting_containers = list(
/obj/item/chems/crucible,
/obj/item/organ/internal/stomach
)
if(!is_type_in_list(loc, _melting_containers))
return

// Check if this is meltable at all.
var/list/meltable_materials
for(var/mat in matter)
var/decl/material/melt_material = GET_DECL(mat)
if(!isnull(melt_material.melting_point) && temperature >= melt_material.melting_point)
LAZYDISTINCTADD(meltable_materials, melt_material)
if(length(meltable_materials))
. = null // Don't return PROCESS_KILL here.
handle_melting(meltable_materials)

/obj/item/place_melted_product(list/meltable_materials)

Expand Down
8 changes: 4 additions & 4 deletions code/modules/mob/living/bot/bot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,12 @@
/mob/living/bot/proc/lookForTargets()
return

/mob/living/bot/proc/confirmTarget(var/atom/A)
if(A.invisibility >= INVISIBILITY_LEVEL_ONE)
/mob/living/bot/proc/confirmTarget(atom/target)
if(target.invisibility >= INVISIBILITY_LEVEL_ONE)
return 0
if(A in ignore_list)
if(target in ignore_list)
return 0
if(!A.loc)
if(!target.loc)
return 0
return 1

Expand Down
41 changes: 22 additions & 19 deletions code/modules/mob/living/bot/cleanbot.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/mob/living/bot/cleanbot
name = "Cleanbot"
name = "cleanbot"
desc = "A little cleaning robot, he looks so excited!"
icon = 'icons/mob/bot/cleanbot.dmi'
icon_state = "cleanbot0"
Expand Down Expand Up @@ -35,44 +35,47 @@
ignore_list -= g

/mob/living/bot/cleanbot/lookForTargets()
for(var/obj/effect/decal/cleanable/D in view(world.view + 1, src))
if(confirmTarget(D))
target = D
for(var/obj/effect/decal/cleanable/decal in view(world.view + 1, src))
if(confirmTarget(decal))
target = decal
playsound(src, 'sound/machines/boop1.ogg', 30)
return

/mob/living/bot/cleanbot/confirmTarget(var/obj/effect/decal/cleanable/D)
if(!..())
return 0
for(var/T in target_types)
if(istype(D, T))
return 1
return 0
/mob/living/bot/cleanbot/confirmTarget(atom/target)
. = ..()
if(.)
var/turf/decal_turf = get_turf(target)
if(!istype(decal_turf) || decal_turf.contains_dense_objects())
return FALSE // Stop trying to clean under full-tile windows.
if(istype(target, /obj/effect/decal/cleanable/dirt))
var/obj/effect/decal/cleanable/dirt/dirt = target
return dirt.dirt_amount >= 50 // Stop trying to clean invisible dirt.
return is_type_in_list(target, target_types)

/mob/living/bot/cleanbot/handleAdjacentTarget()
if(get_turf(target) == src.loc)
UnarmedAttack(target, TRUE)

/mob/living/bot/cleanbot/UnarmedAttack(var/obj/effect/decal/cleanable/D, var/proximity)
/mob/living/bot/cleanbot/UnarmedAttack(var/obj/effect/decal/cleanable/decal, var/proximity)

. = ..()
if(.)
return

if(!istype(D))
if(!istype(decal))
return TRUE

if(D.loc != loc)
if(decal.loc != loc)
return FALSE

busy = 1
visible_message("\The [src] begins to clean up \the [D].")
visible_message("\The [src] begins to clean up \the [decal].")
update_icon()
var/cleantime = istype(D, /obj/effect/decal/cleanable/dirt) ? 10 : 50
if(do_after(src, cleantime, progress = 0) && !QDELETED(D))
if(D == target)
var/cleantime = istype(decal, /obj/effect/decal/cleanable/dirt) ? 10 : 50
if(do_after(src, cleantime, progress = 0) && !QDELETED(decal))
if(decal == target)
target = null
qdel(D)
qdel(decal)
playsound(src, 'sound/machines/boop2.ogg', 30)
busy = 0
update_icon()
Expand Down
10 changes: 5 additions & 5 deletions code/modules/mob/living/bot/farmbot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -240,21 +240,21 @@
if(prob(50))
new /obj/item/robot_parts/l_arm(my_turf)

/mob/living/bot/farmbot/confirmTarget(var/atom/targ)
/mob/living/bot/farmbot/confirmTarget(atom/target)
if(!..())
return 0

if(emagged && ishuman(targ))
if(targ in view(world.view, src))
if(emagged && ishuman(target))
if(target in view(world.view, src))
return 1
return 0

if(istype(targ, /obj/structure/hygiene/sink))
if(istype(target, /obj/structure/hygiene/sink))
if(!tank || tank.reagents.total_volume >= tank.reagents.maximum_volume)
return 0
return 1

var/obj/machinery/portable_atmospherics/hydroponics/tray = targ
var/obj/machinery/portable_atmospherics/hydroponics/tray = target
if(!istype(tray))
return 0

Expand Down
20 changes: 8 additions & 12 deletions code/modules/mob/living/bot/floorbot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -109,28 +109,24 @@
target = S
return

/mob/living/bot/floorbot/confirmTarget(var/atom/A) // The fact that we do some checks twice may seem confusing but remember that the bot's settings may be toggled while it's moving and we want them to stop in that case
/mob/living/bot/floorbot/confirmTarget(atom/target) // The fact that we do some checks twice may seem confusing but remember that the bot's settings may be toggled while it's moving and we want them to stop in that case
anchored = FALSE
if(!..())
return 0

if(istype(A, /obj/item/stack/tile/floor))
if(istype(target, /obj/item/stack/tile/floor))
return (amount < maxAmount && eattiles)

if(istype(A, /obj/item/stack/material))
var/obj/item/stack/material/S = A
if(istype(target, /obj/item/stack/material))
var/obj/item/stack/material/S = target
if(S.material?.type == /decl/material/solid/metal/steel)
return (amount < maxAmount && maketiles)

if(A.loc.name == "Space")
return 0
var/turf/floor/my_turf = target
if(!istype(my_turf) || (isturf(my_turf) && my_turf.is_open()))
return FALSE

var/turf/floor/T = A
if(istype(T))
if(emagged)
return 1
else
return (amount && (T.is_floor_damaged() || (improvefloors && !T.has_flooring())))
return emagged || (amount && (my_turf.is_floor_damaged() || (improvefloors && !my_turf.has_flooring())))

/mob/living/bot/floorbot/UnarmedAttack(var/atom/A, var/proximity)

Expand Down
Loading

0 comments on commit 48d91e1

Please sign in to comment.