Files
Bubberstation/code/datums/ai/monkey/monkey_subtrees.dm
MrMelbertandGitHub 70a8df9135 Angry monkeys are violent again (#93581)
## About The Pull Request

### Fix

If a monkey has no enemies, it will not attack anything.

For normal monkeys, this just caused nothing to happen. 

For angry monkeys, this allowed them to run `monkey_set_combat_target`
and pick a target from view rather than enemies list.

However, when determining "am I allowed to attack this guy", it checked
the enemies list. Which is still empty. Meaning angry monkeys would not
attack the target they just selected.

I fixed this by adding a check for target in addition to a check for
enemies.

### Other

I also reduced the chance of screeching from 100% to 25% (or 10% for
humans).

## Why It's Good For The Game

- Bugfix

- In testing this bugfix, monkeys screeching literally every attack is a
bit excessive and spammy, especially if you're not a monkey. Bumping the
odds down keeps the "rabid monkey" effect without overdoing it.

## Changelog

🆑 Melbert
fix: Angry monkeys (and the primal instincts trauma) are VIOLENT again
qol: Monkeys no longer screech every tick they are attacking someone
(now ~1 in 4 ticks, or ~1 in 10 for primal instincts)
/🆑
2025-10-24 00:54:33 +02:00

73 lines
3.1 KiB
Plaintext

/datum/ai_planning_subtree/monkey_shenanigans/SelectBehaviors(datum/ai_controller/monkey/controller, seconds_per_tick)
if(prob(5))
controller.queue_behavior(/datum/ai_behavior/use_in_hand)
if(!SPT_PROB(MONKEY_SHENANIGAN_PROB, seconds_per_tick))
return
if(!controller.blackboard[BB_MONKEY_CURRENT_PRESS_TARGET])
controller.queue_behavior(/datum/ai_behavior/find_nearby, BB_MONKEY_CURRENT_PRESS_TARGET)
return
if(prob(50))
controller.queue_behavior(/datum/ai_behavior/use_on_object, BB_MONKEY_CURRENT_PRESS_TARGET)
return SUBTREE_RETURN_FINISH_PLANNING
if(!controller.blackboard[BB_MONKEY_CURRENT_GIVE_TARGET])
controller.queue_behavior(/datum/ai_behavior/find_and_set/pawn_must_hold_item, BB_MONKEY_CURRENT_GIVE_TARGET, /mob/living, 2)
else
if(prob(5))
controller.queue_behavior(/datum/ai_behavior/give, BB_MONKEY_CURRENT_GIVE_TARGET)
return SUBTREE_RETURN_FINISH_PLANNING
controller.TryFindWeapon()
///monkey combat subtree.
/datum/ai_planning_subtree/monkey_combat/SelectBehaviors(datum/ai_controller/monkey/controller, seconds_per_tick)
var/mob/living/living_pawn = controller.pawn
var/list/enemies = controller.blackboard[BB_MONKEY_ENEMIES]
if((HAS_TRAIT(controller.pawn, TRAIT_PACIFISM)) || (!length(enemies) && !controller.blackboard[BB_MONKEY_AGGRESSIVE])) //Pacifist, or we have no enemies and we're not pissed
living_pawn.set_combat_mode(FALSE)
return
if(!controller.blackboard[BB_MONKEY_CURRENT_ATTACK_TARGET])
controller.queue_behavior(/datum/ai_behavior/monkey_set_combat_target, BB_MONKEY_CURRENT_ATTACK_TARGET, BB_MONKEY_ENEMIES)
living_pawn.set_combat_mode(FALSE)
return SUBTREE_RETURN_FINISH_PLANNING
var/mob/living/selected_enemy = controller.blackboard[BB_MONKEY_CURRENT_ATTACK_TARGET]
if(QDELETED(selected_enemy))
living_pawn.set_combat_mode(FALSE)
return
if(!selected_enemy.stat) //He's up, get him!
if(living_pawn.health < MONKEY_FLEE_HEALTH) //Time to skeddadle
controller.queue_behavior(/datum/ai_behavior/monkey_flee)
return SUBTREE_RETURN_FINISH_PLANNING //I'm running fuck you guys
if(controller.TryFindWeapon()) //Getting a weapon is higher priority if im not fleeing.
return SUBTREE_RETURN_FINISH_PLANNING
if(controller.blackboard[BB_MONKEY_RECRUIT_COOLDOWN] < world.time)
controller.queue_behavior(/datum/ai_behavior/recruit_monkeys, BB_MONKEY_CURRENT_ATTACK_TARGET)
return
if(SPT_PROB(ismonkey(living_pawn) ? 25 : 10, seconds_per_tick))
controller.queue_behavior(/datum/ai_behavior/battle_screech/monkey)
controller.queue_behavior(/datum/ai_behavior/monkey_attack_mob, BB_MONKEY_CURRENT_ATTACK_TARGET)
return SUBTREE_RETURN_FINISH_PLANNING
//by this point we have a target but they're down, let's try dumpstering this loser
living_pawn.set_combat_mode(FALSE)
if(!controller.blackboard[BB_MONKEY_TARGET_DISPOSAL])
controller.queue_behavior(/datum/ai_behavior/find_and_set, BB_MONKEY_TARGET_DISPOSAL, /obj/machinery/disposal, MONKEY_ENEMY_VISION)
return
controller.queue_behavior(/datum/ai_behavior/disposal_mob, BB_MONKEY_CURRENT_ATTACK_TARGET, BB_MONKEY_TARGET_DISPOSAL)
return SUBTREE_RETURN_FINISH_PLANNING