mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-20 20:45:28 +01:00
* Hard Del Fixes, Ref Tracking Changes
This commit is contained in:
@@ -2,13 +2,14 @@
|
||||
var/obj/item/item_pawn = controller.pawn
|
||||
|
||||
//make sure we have a target
|
||||
var/mob/living/carbon/curse_target = controller.blackboard[BB_ITEM_TARGET]
|
||||
var/datum/weakref/target_ref = controller.blackboard[BB_ITEM_TARGET]
|
||||
var/mob/living/carbon/curse_target = target_ref?.resolve()
|
||||
|
||||
if(curse_target && get_dist(curse_target, item_pawn) > ITEM_AGGRO_VIEW_RANGE)
|
||||
controller.blackboard[BB_ITEM_TARGET] = null
|
||||
return
|
||||
|
||||
if(!controller.blackboard[BB_ITEM_TARGET])
|
||||
if(!curse_target)
|
||||
controller.queue_behavior(/datum/ai_behavior/find_and_set/item_target, BB_ITEM_TARGET, /mob/living/carbon, ITEM_AGGRO_VIEW_RANGE)
|
||||
|
||||
controller.queue_behavior(/datum/ai_behavior/item_move_close_and_attack/ghostly, BB_ITEM_TARGET, BB_ITEM_THROW_ATTEMPT_COUNT)
|
||||
|
||||
@@ -11,45 +11,3 @@
|
||||
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 attempts to make
|
||||
var/max_attempts = 3
|
||||
|
||||
|
||||
/datum/ai_behavior/item_move_close_and_attack/setup(datum/ai_controller/controller, aggro_list_key, target_key, throw_count_key)
|
||||
. = ..()
|
||||
controller.current_movement_target = controller.blackboard[target_key]
|
||||
|
||||
|
||||
/datum/ai_behavior/item_move_close_and_attack/perform(delta_time, datum/ai_controller/controller, aggro_list_key, target_key, throw_count_key)
|
||||
. = ..()
|
||||
var/obj/item/item_pawn = controller.pawn
|
||||
var/atom/throw_target = controller.blackboard[target_key]
|
||||
|
||||
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, aggro_list_key, target_key, throw_count_key)
|
||||
. = ..()
|
||||
var/atom/throw_target = controller.blackboard[target_key]
|
||||
|
||||
controller.blackboard -= target_key
|
||||
controller.blackboard[throw_count_key] = 0
|
||||
if(aggro_list_key)
|
||||
var/list/aggro_list = controller.blackboard[aggro_list_key]
|
||||
aggro_list[throw_target]--
|
||||
|
||||
/datum/ai_behavior/item_move_close_and_attack/ghostly
|
||||
attack_sound = 'sound/items/haunted/ghostitemattack.ogg'
|
||||
max_attempts = 4
|
||||
|
||||
Reference in New Issue
Block a user