mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-30 23:49:21 +01:00
Merges AI Branch into Master
This commit is contained in:
@@ -9,35 +9,42 @@
|
||||
/atom/movable/proc/guess_threat_level(var/mob/living/threatened)
|
||||
return 0
|
||||
|
||||
/mob/living/simple_animal
|
||||
/mob/living/simple_mob
|
||||
var/threat_level = null // Set this if you want an explicit danger rating.
|
||||
|
||||
/mob/living/simple_animal/guess_threat_level(var/mob/living/threatened)
|
||||
/mob/living/simple_mob/guess_threat_level(var/mob/living/threatened)
|
||||
if(threat_level) // If they have a predefined number, use it.
|
||||
return threat_level
|
||||
// Otherwise we need to guess how scary this thing is.
|
||||
var/threat_guess = 0
|
||||
|
||||
// First lets consider their attack ability.
|
||||
var/will_point_blank = FALSE
|
||||
if(has_AI())
|
||||
will_point_blank = ai_holder.pointblank
|
||||
|
||||
var/potential_damage = 0
|
||||
if(!ranged) //Melee damage.
|
||||
if(!projectiletype || ( get_dist(src, threatened >= 1) && !will_point_blank ) ) // Melee damage.
|
||||
potential_damage = (melee_damage_lower + melee_damage_upper) / 2
|
||||
|
||||
// Treat potential_damage as estimated DPS. If the enemy attacks twice as fast as usual, it will double the number.
|
||||
potential_damage *= 1 SECOND / (base_attack_cooldown + melee_attack_delay)
|
||||
else
|
||||
if(projectiletype)
|
||||
var/obj/item/projectile/P = new projectiletype(src)
|
||||
if(P.nodamage || P.taser_effect) // Tasers are somewhat less scary.
|
||||
potential_damage = P.agony / 2
|
||||
else
|
||||
potential_damage = P.damage
|
||||
if(P.damage_type == HALLOSS) // Not sure if any projectiles do this, but can't be too safe.
|
||||
potential_damage /= 2
|
||||
// Rubber bullets, I guess.
|
||||
potential_damage += P.agony / 2
|
||||
var/obj/item/projectile/P = new projectiletype(src)
|
||||
if(P.nodamage || P.taser_effect) // Tasers are somewhat less scary.
|
||||
potential_damage = P.agony / 2
|
||||
else
|
||||
potential_damage = P.damage
|
||||
if(P.damage_type == HALLOSS) // Not sure if any projectiles do this, but can't be too safe.
|
||||
potential_damage /= 2
|
||||
// Rubber bullets, I guess.
|
||||
potential_damage += P.agony / 2
|
||||
qdel(P)
|
||||
|
||||
if(rapid) // This makes them shoot three times per cycle.
|
||||
potential_damage *= 3
|
||||
potential_damage *= 1 SECOND / (base_attack_cooldown + ranged_attack_delay)
|
||||
|
||||
// Special attacks are ultra-specific to the mob so a generic threat assessment isn't really possible.
|
||||
|
||||
qdel(P)
|
||||
threat_guess += potential_damage
|
||||
|
||||
// Then consider their defense.
|
||||
@@ -50,11 +57,12 @@
|
||||
return 0
|
||||
|
||||
|
||||
/mob/living/simple_animal/get_threat(var/mob/living/threatened)
|
||||
/mob/living/simple_mob/get_threat(var/mob/living/threatened)
|
||||
. = ..()
|
||||
|
||||
if(!hostile)
|
||||
return 0 // Can't hurt anyone.
|
||||
if(has_AI())
|
||||
if(!ai_holder.hostile)
|
||||
return 0 // Can't hurt anyone.
|
||||
|
||||
if(incapacitated(INCAPACITATION_DISABLED))
|
||||
return 0 // Can't currently hurt you if it's stunned.
|
||||
@@ -86,7 +94,7 @@
|
||||
|
||||
// Handle ability to harm.
|
||||
// Being five tiles away from some spiders is a lot less scary than being in melee range of five spiders at once.
|
||||
if(!ranged)
|
||||
if(!projectiletype)
|
||||
threat /= max(get_dist(src, threatened), 1)
|
||||
|
||||
return threat
|
||||
|
||||
Reference in New Issue
Block a user