Enhances AI some more.

This commit is contained in:
Neerti
2018-09-14 12:55:12 -04:00
parent 16b40f0dcd
commit 1b6ccdabf7
25 changed files with 738 additions and 122 deletions
@@ -15,6 +15,9 @@
/datum/ai_holder/simple_mob/xenobio_slime/sapphire
always_stun = TRUE // They know that stuns are godly.
/datum/ai_holder/simple_mob/xenobio_slime/light_pink
discipline = 5
obedience = 5
/datum/ai_holder/simple_mob/xenobio_slime/New()
..()
@@ -69,6 +72,13 @@
discipline = between(0, discipline + amount, 10)
my_slime.update_mood()
// This slime always enrages if disciplined.
/datum/ai_holder/simple_mob/xenobio_slime/red/adjust_discipline(amount, silent)
if(amount > 0 && !rabid)
holder.say("Grrr...")
holder.add_modifier(/datum/modifier/berserk, 30 SECONDS)
enrage()
/datum/ai_holder/simple_mob/xenobio_slime/handle_special_strategical()
discipline_decay()
+9 -18
View File
@@ -150,9 +150,9 @@
if(target && can_see_target(target))
track_target_position()
if(!can_act())
ai_log("handle_stance_tactical() : Stunned.", AI_LOG_TRACE)
set_stance(STANCE_STUNNED)
if(is_disabled()) // Stunned/confused/etc
ai_log("handle_stance_tactical() : Disabled.", AI_LOG_TRACE)
set_stance(STANCE_DISABLED)
return
if(stance in STANCES_COMBAT)
@@ -217,11 +217,13 @@
ai_log("handle_stance_tactical() : STANCE_FLEE, going to flee_from_target().", AI_LOG_TRACE)
flee_from_target()
if(STANCE_STUNNED)
ai_log("handle_stance_tactical() : STANCE_STUNNED.", AI_LOG_TRACE)
if(can_act())
ai_log("handle_stance_tactical() : No longer stunned.", AI_LOG_TRACE)
if(STANCE_DISABLED)
ai_log("handle_stance_tactical() : STANCE_DISABLED.", AI_LOG_TRACE)
if(!is_disabled())
ai_log("handle_stance_tactical() : No longer disabled.", AI_LOG_TRACE)
set_stance(STANCE_IDLE)
else
handle_disabled()
ai_log("handle_stance_tactical() : Exiting.", AI_LOG_TRACE)
ai_log("========= Fast Process Ending ==========", AI_LOG_TRACE)
@@ -314,17 +316,6 @@
AttackTarget()
*/
// If our holder is able to do anything.
/datum/ai_holder/proc/can_act()
if(holder.stat) // Dead or unconscious.
ai_log("can_act() : Stat was non-zero ([holder.stat]).", AI_LOG_TRACE)
return FALSE
if(holder.incapacitated(INCAPACITATION_DISABLED)) // Stunned in some form.
ai_log("can_act() : Incapacited.", AI_LOG_TRACE)
return FALSE
return TRUE
// Helper proc to turn AI 'busy' mode on or off without having to check if there is an AI, to simplify writing code.
/mob/living/proc/set_AI_busy(value)
if(ai_holder)
+1 -1
View File
@@ -74,7 +74,7 @@
new_color = "#00FFFF" // Cyan
if(STANCE_FLEE)
new_color = "#666666" // Grey
if(STANCE_STUNNED)
if(STANCE_DISABLED)
new_color = "#000000" // Black
holder.color = new_color
+72
View File
@@ -0,0 +1,72 @@
// Handles AI while stunned or otherwise disabled.
/datum/ai_holder
var/respect_confusion = TRUE // If false, the mob won't wander around recklessly.
// If our holder is able to do anything.
/datum/ai_holder/proc/can_act()
if(holder.stat) // Dead or unconscious.
ai_log("can_act() : Stat was non-zero ([holder.stat]).", AI_LOG_TRACE)
return FALSE
if(holder.incapacitated(INCAPACITATION_DISABLED)) // Stunned in some form.
ai_log("can_act() : Incapacited.", AI_LOG_TRACE)
return FALSE
return TRUE
// Test if we should switch to STANCE_DISABLE.
// Currently tests for death, stuns, and confusion.
/datum/ai_holder/proc/is_disabled()
if(!can_act())
return TRUE
if(is_confused())
return TRUE
return FALSE
/datum/ai_holder/proc/is_confused()
return holder.confused > 0 && respect_confusion
// Called by the main loop.
/datum/ai_holder/proc/handle_disabled()
if(!can_act())
return // Just sit there and take it.
else if(is_confused())
dangerous_wander() // Let's bump into allies and hit them.
// Similar to normal wander, but will walk into tiles that are harmful, and attack anything they bump into, including allies.
// Occurs when confused.
/datum/ai_holder/proc/dangerous_wander()
ai_log("dangerous_wander() : Entered.", AI_LOG_DEBUG)
if(isturf(holder.loc) && can_act())
var/moving_to = 0
moving_to = pick(cardinal)
var/turf/T = get_step(holder, moving_to)
holder.set_dir(moving_to)
var/mob/living/L = locate() in T
if(L)
// Attack whoever's on the tile. Even if it's an ally.
melee_attack(L)
else
// Move to the tile. Even if it's unsafe.
holder.IMove(T, safety = FALSE)
ai_log("dangerous_wander() : Exited.", AI_LOG_DEBUG)
/*
// Wanders randomly in cardinal directions.
/datum/ai_holder/proc/handle_wander_movement()
ai_log("handle_wander_movement() : Entered.", AI_LOG_DEBUG)
if(isturf(holder.loc) && can_act())
wander_delay--
if(wander_delay <= 0)
if(!wander_when_pulled && holder.pulledby)
ai_log("handle_wander_movement() : Being pulled and cannot wander. Exiting.", AI_LOG_DEBUG)
return
var/moving_to = 0 // Apparently this is required or it always picks 4, according to the previous developer for simplemob AI.
moving_to = pick(cardinal)
holder.set_dir(moving_to)
holder.IMove(get_step(holder,moving_to))
wander_delay = base_wander_delay
ai_log("handle_wander_movement() : Exited.", AI_LOG_DEBUG)
*/
+6 -2
View File
@@ -65,11 +65,15 @@
return myid.GetID()
// Respects move cooldowns as if it had a client.
/mob/living/proc/IMove(newloc)
// Also tries to avoid being superdumb with moving into certain tiles (unless that's desired).
/mob/living/proc/IMove(turf/newloc, safety = TRUE)
if(check_move_cooldown())
// if(!newdir)
// newdir = get_dir(get_turf(src), newloc)
// Check to make sure moving to newloc won't actually kill us. e.g. we're a slime and trying to walk onto water.
if(istype(newloc))
if(safety && !newloc.is_safe_to_enter(src))
return MOVEMENT_FAILED
// Move()ing to another tile successfully returns 32 because BYOND. Would rather deal with TRUE/FALSE-esque terms.
// Note that moving to the same tile will be 'successful'.
var/turf/old_T = get_turf(src)