mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 09:42:29 +00:00
* Fixes Hauntium runtiming to hell (get it) due to real fake weakrefs (#64779) Hauntium AI was recently changed to use weakrefs to cut back on hard deletes Unfortunately, not all cases of hauntium AI assigning references were swapped to weakrefs. Meaning the haunting list ended up being some weird combination of hard references to mobs and weak references. These hard references in the list caused a million runtimes a second because the ai was, of course, trying to resolve() hard references which doesn't work and it was doing it every second Hauntium should now properly use weakrefs in the cases it's used in. Spooky things actually haunt again * Fixes Hauntium runtiming to hell (get it) due to real fake weakrefs Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
61 lines
2.7 KiB
Plaintext
61 lines
2.7 KiB
Plaintext
///This behavior is for obj/items, it is used to free themselves out of the hands of whoever is holding them
|
|
/datum/ai_behavior/item_escape_grasp
|
|
|
|
/datum/ai_behavior/item_escape_grasp/perform(delta_time, datum/ai_controller/controller)
|
|
. = ..()
|
|
var/obj/item/item_pawn = controller.pawn
|
|
var/mob/item_holder = item_pawn.loc
|
|
if(!istype(item_holder))
|
|
finish_action(controller, FALSE) //We're no longer beind held. abort abort!!
|
|
item_pawn.visible_message(span_warning("[item_pawn] slips out of the hands of [item_holder]!"))
|
|
item_holder.dropItemToGround(item_pawn, TRUE)
|
|
finish_action(controller, TRUE)
|
|
|
|
|
|
///This behavior is for obj/items, it is used to move closer to a target and throw themselves towards them.
|
|
/datum/ai_behavior/item_move_close_and_attack
|
|
required_distance = 3
|
|
behavior_flags = AI_BEHAVIOR_REQUIRE_MOVEMENT
|
|
action_cooldown = 20
|
|
///Sound to use
|
|
var/attack_sound
|
|
///Max attemps to make
|
|
var/max_attempts = 3
|
|
|
|
/datum/ai_behavior/item_move_close_and_attack/setup(datum/ai_controller/controller, target_key, throw_count_key)
|
|
. = ..()
|
|
var/datum/weakref/target_ref = controller.blackboard[target_key]
|
|
controller.current_movement_target = target_ref?.resolve()
|
|
|
|
/datum/ai_behavior/item_move_close_and_attack/perform(delta_time, datum/ai_controller/controller, target_key, throw_count_key)
|
|
. = ..()
|
|
var/obj/item/item_pawn = controller.pawn
|
|
var/datum/weakref/target_ref = controller.blackboard[target_key]
|
|
var/atom/throw_target = target_ref?.resolve()
|
|
|
|
item_pawn.visible_message(span_warning("[item_pawn] hurls towards [throw_target]!"))
|
|
item_pawn.throw_at(throw_target, rand(4,5), 9)
|
|
playsound(item_pawn.loc, attack_sound, 100, TRUE)
|
|
controller.blackboard[throw_count_key]++
|
|
if(controller.blackboard[throw_count_key] >= max_attempts)
|
|
finish_action(controller, TRUE, target_key, throw_count_key)
|
|
|
|
/datum/ai_behavior/item_move_close_and_attack/finish_action(datum/ai_controller/controller, succeeded, target_key, throw_count_key)
|
|
. = ..()
|
|
reset_blackboard(controller, succeeded, target_key, throw_count_key)
|
|
|
|
/datum/ai_behavior/item_move_close_and_attack/proc/reset_blackboard(datum/ai_controller/controller, succeeded, target_key, throw_count_key)
|
|
controller.blackboard -= target_key
|
|
controller.blackboard[throw_count_key] = 0
|
|
|
|
/datum/ai_behavior/item_move_close_and_attack/ghostly
|
|
attack_sound = 'sound/items/haunted/ghostitemattack.ogg'
|
|
max_attempts = 4
|
|
|
|
/datum/ai_behavior/item_move_close_and_attack/ghostly/haunted
|
|
|
|
/datum/ai_behavior/item_move_close_and_attack/ghostly/haunted/finish_action(datum/ai_controller/controller, succeeded, target_key, throw_count_key)
|
|
var/datum/weakref/target_ref = controller.blackboard[target_key]
|
|
controller.blackboard[BB_TO_HAUNT_LIST][target_ref]--
|
|
return ..()
|