mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-18 11:36:24 +01:00
Experiment with replacing weakrefs in AI blackboard with deleting signals, ideally making it easier to work with and harder to cause hard deletes (#74791)
## About The Pull Request Replaces weakref usage in AI blackboards with deleting signals All blackboard var setting must go through setters rather than directly ## Why It's Good For The Game This both makes it a ton easier to develop AI for, and also makes it harder for hard deletes to sneak in, as has been seen with recent 515 prs showing hard deletes in AI blackboards (To quantify "making it easier to develop AI", I found multiple bugs in existing AI code due to the usage of weakrefs.) I'm looking for `@Jacquerel` `@tralezab` 's opinions on the matter, also maybe `@LemonInTheDark` if they're interested ## Changelog 🆑 Melbert refactor: Mob ai refactored once again /🆑
This commit is contained in:
@@ -52,7 +52,7 @@ have ways of interacting with a specific mob and control it.
|
||||
. = ..()
|
||||
if(. & AI_CONTROLLER_INCOMPATIBLE)
|
||||
return
|
||||
blackboard[BB_MONKEY_AGGRESSIVE] = TRUE //Angry cunt
|
||||
set_blackboard_key(BB_MONKEY_AGGRESSIVE, TRUE) //Angry cunt
|
||||
|
||||
/datum/ai_controller/monkey/TryPossessPawn(atom/new_pawn)
|
||||
if(!isliving(new_pawn))
|
||||
@@ -103,8 +103,8 @@ have ways of interacting with a specific mob and control it.
|
||||
/datum/ai_controller/monkey/proc/TryFindWeapon()
|
||||
var/mob/living/living_pawn = pawn
|
||||
|
||||
if(!locate(/obj/item) in living_pawn.held_items)
|
||||
blackboard[BB_MONKEY_BEST_FORCE_FOUND] = 0
|
||||
if(!(locate(/obj/item) in living_pawn.held_items))
|
||||
set_blackboard_key(BB_MONKEY_BEST_FORCE_FOUND, 0)
|
||||
|
||||
if(blackboard[BB_MONKEY_GUN_NEURONS_ACTIVATED] && (locate(/obj/item/gun) in living_pawn.held_items))
|
||||
// We have a gun, what could we possibly want?
|
||||
@@ -135,7 +135,7 @@ have ways of interacting with a specific mob and control it.
|
||||
if(weapon.force < 2) // our bite does 2 damage on avarage, no point in settling for anything less
|
||||
return FALSE
|
||||
|
||||
blackboard[BB_MONKEY_PICKUPTARGET] = weapon
|
||||
set_blackboard_key(BB_MONKEY_PICKUPTARGET, weapon)
|
||||
set_movement_target(type, weapon)
|
||||
if(pickpocket)
|
||||
queue_behavior(/datum/ai_behavior/monkey_equip/pickpocket)
|
||||
@@ -145,8 +145,7 @@ have ways of interacting with a specific mob and control it.
|
||||
|
||||
///Reactive events to being hit
|
||||
/datum/ai_controller/monkey/proc/retaliate(mob/living/L)
|
||||
var/list/enemies = blackboard[BB_MONKEY_ENEMIES]
|
||||
enemies[WEAKREF(L)] += MONKEY_HATRED_AMOUNT
|
||||
add_blackboard_key_assoc(BB_MONKEY_ENEMIES, L, MONKEY_HATRED_AMOUNT)
|
||||
|
||||
/datum/ai_controller/monkey/proc/on_attacked(datum/source, mob/attacker)
|
||||
SIGNAL_HANDLER
|
||||
@@ -175,7 +174,3 @@ have ways of interacting with a specific mob and control it.
|
||||
/datum/ai_controller/monkey/proc/update_movespeed(mob/living/pawn)
|
||||
SIGNAL_HANDLER
|
||||
movement_delay = pawn.cached_multiplicative_slowdown
|
||||
|
||||
/datum/ai_controller/monkey/proc/target_del(target)
|
||||
SIGNAL_HANDLER
|
||||
blackboard[BB_MONKEY_BLACKLISTITEMS] -= target
|
||||
|
||||
Reference in New Issue
Block a user