More hostile mob work with behavior vars, getting rid of idle_env_destroyer nobody uses it, other tweaks

Conflicts:
	code/modules/mob/living/simple_animal/hostile/hostile.dm
	code/modules/mob/living/simple_animal/hostile/mining_mobs.dm
This commit is contained in:
Ergovisavi
2014-01-21 22:15:28 -08:00
committed by ZomgPonies
parent 78bea65a44
commit 7bd3df0b3b
5 changed files with 94 additions and 118 deletions
+6 -3
View File
@@ -124,10 +124,13 @@
/turf/simulated/wall/attack_animal(var/mob/living/simple_animal/M)
if(M.wall_smash)
if (istype(src, /turf/simulated/wall/r_wall))
M << text("\blue This wall is far too strong for you to destroy.")
return
if(M.wall_smash == 2)
dismantle_wall(1)
M << "<span class='info'>You smash through the wall.</span>"
else
M << "<span class='info'>This wall is far too strong for you to destroy.</span>"
else
M << text("\blue You smash through the wall.")
M << "<span class='info'>You smash through the wall.</span>"
dismantle_wall(1)
return
@@ -29,7 +29,6 @@
max_n2 = 0
unsuitable_atoms_damage = 15
faction = "alien"
wall_smash = 1
status_flags = CANPUSH
minbodytemp = 0
heat_damage_per_tick = 20
@@ -1,9 +1,10 @@
/mob/living/simple_animal/hostile
faction = "hostile"
mouse_opacity = 2 //This makes it easier to hit hostile mobs, you only need to click on their tile, and is set back to 1 when they die
stop_automated_movement_when_pulled = 0
var/stance = HOSTILE_STANCE_IDLE //Used to determine behavior
var/atom/target
var/attack_same = 0
var/attack_same = 0 //Set us to 1 to allow us to attack our own faction, or 2, to only ever attack our own faction
var/ranged = 0
var/rapid = 0
var/projectiletype
@@ -12,42 +13,69 @@
var/move_to_delay = 2 //delay for the automated movement.
var/list/friends = list()
var/vision_range = 9 //How big of an area to search for targets in, a vision of 9 attempts to find targets as soon as they walk into screen view
var/idle_env_destroyer = 0
stop_automated_movement_when_pulled = 0
var/icon_aggro = null // If we swap our icon to something else when we're aggressive, put it here
var/aggro_vision_range = 9 //If a mob is aggro, it's searching for targets in a much wider range than normal
var/idle_vision_range = 9 //If a mob is just idling around, it's vision range is limited to this. Defaults to 9 for legacy purposes.
var/aggro_vision_range = 9 //If a mob is aggro, we search in this radius. Defaults to 9 to keep in line with original simple mob aggro radius
var/idle_vision_range = 9 //If a mob is just idling around, it's vision range is limited to this. Defaults to 9 to keep in line with original simple mob aggro radius
var/ranged_message = "fires" //Fluff text for ranged mobs
var/ranged_cooldown = 2 //What the starting cooldown is on ranged attacks
var/ranged_cooldown = 0 //What the starting cooldown is on ranged attacks
var/ranged_cooldown_cap = 3 //What ranged attacks, after being used are set to, to go back on cooldown, defaults to 3 life() ticks
var/retreat_distance = null //If our mob runs from players when they're too close, set in tile distance. By default, mobs do not retreat.
var/minimum_distance = 1 //Minimum approach distance, so ranged mobs chase targets down, but still keep their distance set in tiles to the target, set higher to make mobs keep distance
var/search_objects = 0 //If we want to consider objects when searching around, set this to 1. If you want to search for objects while also ignoring mobs, set it to 2.
var/search_objects = 0 //If we want to consider objects when searching around, set this to 1. If you want to search for objects while also ignoring mobs until hurt, set it to 2. To completely ignore mobs, even when attacked, set it to 3
var/list/wanted_objects = list() //A list of objects that will be checked against to attack, should we have search_objects enabled
var/execute = 0 //Mobs with execute set to 1 will attempt to attack things that are unconscious, Mobs with execute set to 2 will attempt to attack the dead.
/mob/living/simple_animal/hostile/Life()
. = ..()
if(!.)
walk(src, 0)
return 0
if(client)
return 0
if(!stat)
switch(stance)
if(HOSTILE_STANCE_IDLE)
var/new_target = FindTarget()
GiveTarget(new_target)
if(HOSTILE_STANCE_ATTACK)
MoveToTarget()
DestroySurroundings()
if(HOSTILE_STANCE_ATTACKING)
AttackTarget()
DestroySurroundings()
if(ranged)
ranged_cooldown--
//////////////HOSTILE MOB TARGETTING AND AGGRESSION////////////
/mob/living/simple_animal/hostile/proc/ListTargets(var/override = -1)
if(override == -1)
override = vision_range
var/list/L = hearers(src, override)
/mob/living/simple_animal/hostile/proc/ListTargets()//Step 1, find out what we can see
var/list/L = list()
if(search_objects < 2)
var/list/Mobs = hearers(src, vision_range)
for(var/mob/living/G in Mobs)
L.Add(G)
L.Remove(src)//So we don't suicide because we listed ourselves as a target!
if(search_objects)
var/list/Objects = oview(vision_range, src)
for(var/obj/O in Objects)
L.Add(O)
else
for(var/obj/mecha/M in mechas_list)
if(get_dist(M, src) <= override && can_see(src, M, override))
if(get_dist(M, src) <= vision_range && can_see(src, M, vision_range))
L += M
return L
/mob/living/simple_animal/hostile/proc/FindTarget()//Step 2, filter down possible targets to things we actually care about
var/list/Targets = list()
var/Target
stop_automated_movement = 0
for(var/atom/A in ListTargets())
if(Found(A))//Just in case people want to override targetting IE: Dire rat sees cheese
if(Found(A))//Just in case people want to override targetting
var/list/FoundTarget = list()
FoundTarget.Add(A)
Targets = FoundTarget
@@ -76,44 +104,35 @@
/mob/living/simple_animal/hostile/CanAttack(var/atom/the_target)//Can we actually attack a possible target?
if(see_invisible < the_target.invisibility)//Target's invisible to us, forget it
return 0
if(isobj(the_target) && search_objects >= 1)//If search for objects, check it against the items we actually care about
if(isobj(the_target) && search_objects)
if(the_target.type in wanted_objects)
return 1
if(isliving(the_target) && search_objects < 2)
var/mob/living/L = the_target
if(L.stat != CONSCIOUS || L.faction == src.faction && !attack_same)//If they're unconscious, or in our faction, forget it
if(L.stat > execute)
return 0
if(L.faction == src.faction && !attack_same || L.faction != src.faction && attack_same == 2)
return 0
if(L in friends)
return 0
return 1
if(istype(the_target, /obj/mecha) && search_objects < 2)
if(istype(the_target, /obj/mecha))
var/obj/mecha/M = the_target
if(M.occupant)//Just so we don't attack empty mechs
return 1
return 0
/*/mob/living/simple_animal/hostile/proc/GiveTarget(var/new_target)//Step 4, give us our chosen target, and set us to aggressive
/mob/living/simple_animal/hostile/proc/GiveTarget(var/new_target)//Step 4, give us our selected target
target = new_target
if(target != null)
Aggro()
stance = HOSTILE_STANCE_ATTACK
return*/
/mob/living/simple_animal/hostile/proc/GiveTarget(var/new_target)
target = new_target
if(target != null)
if(isobj(target))
stance = HOSTILE_STANCE_ATTACK
if(isliving(target) && search_objects < 2)
Aggro()
stance = HOSTILE_STANCE_ATTACK
return
/mob/living/simple_animal/hostile/proc/MoveToTarget()//Step 5, handle movement between us and our target
stop_automated_movement = 1
if(!target || SA_attackable(target))
LoseTarget()
world << "Our target was null, or we didnt consider that we were able to attack it"
if(target in ListTargets())
var/TargetDistance = get_dist(src,target)
if(ranged)//We ranged? Shoot at em
@@ -122,8 +141,10 @@
if(retreat_distance != null)//If we have a retreat distance, check if we need to run from our target
if(TargetDistance <= retreat_distance)//If target's closer than our retreat distance, run
walk_away(src,target,retreat_distance,move_to_delay)
else Goto(target,move_to_delay,minimum_distance)//Otherwise, get to our minimum distance to shoot at them, so we chase them
else Goto(target,move_to_delay,minimum_distance)
else
Goto(target,move_to_delay,minimum_distance)//Otherwise, get to our minimum distance so we chase them
else
Goto(target,move_to_delay,minimum_distance)
if(isturf(loc) && target.Adjacent(src)) //If they're next to us, attack
AttackingTarget()
return
@@ -134,10 +155,11 @@
/mob/living/simple_animal/hostile/adjustBruteLoss(var/damage)
..(damage)
if(!stat)
if(!stat && search_objects < 3)//Not unconscious, and we don't ignore mobs
if(search_objects)//Turn off item searching and ignore whatever item we were looking at, we're more concerned with fight or flight
search_objects = 0
target = null
if(stance == HOSTILE_STANCE_IDLE)//If we took damage while idle, immediately attempt to find the source of it so we find a living target
if(search_objects)//Turn off item searching, we're more concerned with fight or flight
search_objects = 0
Aggro()
var/new_target = FindTarget()
GiveTarget(new_target)
@@ -164,13 +186,10 @@
/mob/living/simple_animal/hostile/proc/Aggro()
vision_range = aggro_vision_range
if(icon_aggro != null)
icon_state = icon_aggro
/mob/living/simple_animal/hostile/proc/LoseAggro()
stop_automated_movement = 0
vision_range = idle_vision_range
if(icon_state != icon_living)
icon_state = icon_living
/mob/living/simple_animal/hostile/proc/LoseTarget()
stance = HOSTILE_STANCE_IDLE
@@ -191,33 +210,6 @@
..()
walk(src, 0)
/mob/living/simple_animal/hostile/Life()
. = ..()
if(!.)
walk(src, 0)
return 0
if(client)
return 0
if(!stat)
switch(stance)
if(HOSTILE_STANCE_IDLE)
var/new_target = FindTarget()
GiveTarget(new_target)
if(idle_env_destroyer)
DestroySurroundings()
if(HOSTILE_STANCE_ATTACK)
DestroySurroundings()
MoveToTarget()
if(HOSTILE_STANCE_ATTACKING)
DestroySurroundings()
AttackTarget()
if(ranged)
ranged_cooldown--
/mob/living/simple_animal/hostile/proc/OpenFire(var/the_target)
var/target = the_target
visible_message("\red <b>[src]</b> [ranged_message] at [target]!", 1)
@@ -268,24 +260,8 @@
var/list/directions = cardinal.Copy()
for(var/dir in directions)
var/turf/T = get_step(src, dir)
if(istype(T, /turf/simulated/wall) || istype(T, /turf/simulated/mineral))
if(istype(T, /turf/simulated/wall) && wall_smash)
T.attack_animal(src)
for(var/atom/A in T)
if(istype(A, /obj/structure/window) || istype(A, /obj/structure/closet) || istype(A, /obj/structure/table) || istype(A, /obj/structure/grille))
if(istype(A, /obj/structure/window) || istype(A, /obj/structure/closet) || istype(A, /obj/structure/table) || istype(A, /obj/structure/grille) || istype(A, /obj/structure/rack))
A.attack_animal(src)
/*/mob/living/simple_animal/hostile/proc/DestroySurroundings()
for(var/dir in cardinal) // North, South, East, West
var/obj/structure/obstacle = locate(/obj/structure, get_step(src, dir))
if(istype(obstacle, /obj/structure/window) || istype(obstacle, /obj/structure/closet) || istype(obstacle, /obj/structure/table) || istype(obstacle, /obj/structure/grille))
obstacle.attack_animal(src)
/obj/effect/goliath_tentacle/original/New()
var/list/directions = cardinal.Copy()
var/counter
for(counter = 1, counter <= 3, counter++)
var/spawndir = pick(directions)
directions -= spawndir
var/turf/T = get_step(src,spawndir)
new /obj/effect/goliath_tentacle(T)
..()*/
@@ -19,6 +19,15 @@
status_flags = 0
a_intent = "harm"
var/throw_message = "bounces off of"
var/icon_aggro = null // for swapping to when we get aggressive
/mob/living/simple_animal/hostile/asteroid/Aggro()
..()
icon_state = icon_aggro
/mob/living/simple_animal/hostile/asteroid/LoseAggro()
..()
icon_state = icon_living
/mob/living/simple_animal/hostile/asteroid/bullet_act(var/obj/item/projectile/P)//Limits the weapons available to kill them at range
if(P.damage < 30)
@@ -36,7 +45,7 @@
..()
/mob/living/simple_animal/hostile/asteroid/basilisk
name = "Basilisk"
name = "basilisk"
desc = "A territorial beast, covered in a thick shell that absorbs energy. Its stare causes victims to freeze from the inside."
icon = 'icons/mob/animal.dmi'
icon_state = "Basilisk"
@@ -86,7 +95,7 @@
return
/mob/living/simple_animal/hostile/asteroid/Goldgrub
name = "Goldgrub"
name = "goldgrub"
desc = "A worm that grows fat from eating everything in its sight. Seems to enjoy precious metals and other shiny things, hence the name."
icon = 'icons/mob/animal.dmi'
icon_state = "Goldgrub"
@@ -94,6 +103,7 @@
icon_aggro = "Goldgrub_alert"
icon_dead = "Goldgrub_dead"
icon_gib = "syndicate_gib"
vision_range = 6
move_to_delay = 3
friendly = "harmlessly rolls into"
maxHealth = 45
@@ -110,11 +120,6 @@
/obj/item/weapon/ore/uranium, /obj/item/weapon/ore/iron, /obj/item/weapon/ore/clown)
var/alerted = 0
/mob/living/simple_animal/hostile/asteroid/Goldgrub/Found(var/new_target)
if(istype(new_target, /obj/item/weapon/ore) && stance == HOSTILE_STANCE_IDLE)
return 1
return 0
/mob/living/simple_animal/hostile/asteroid/Goldgrub/GiveTarget(var/new_target)
target = new_target
if(target != null)
@@ -143,10 +148,6 @@
visible_message("<span class='danger'>The [src.name] buries into the ground, vanishing from sight!</span>")
del(src)
/mob/living/simple_animal/hostile/asteroid/Goldgrub/adjustBruteLoss(var/damage)
search_objects = 0 //Stop looking for items if we've been hurt by someone, so we can run!
..()
/mob/living/simple_animal/hostile/asteroid/Goldgrub/bullet_act(var/obj/item/projectile/P)
visible_message("<span class='danger'>The [P.name] was repelled by [src.name]'s girth!</span>")
return
@@ -156,7 +157,7 @@
..()
/mob/living/simple_animal/hostile/asteroid/Hivelord
name = "Hivelord"
name = "hivelord"
desc = "A truly alien creature, it is a mass of unknown organic material, constantly fluctuating. When attacking, pieces of it split off and attack in tandem with the original."
icon = 'icons/mob/animal.dmi'
icon_state = "Hivelord"
@@ -192,7 +193,7 @@
..()
/mob/living/simple_animal/hostile/asteroid/Hivelordbrood
name = "Hivelord brood"
name = "hivelord brood"
desc = "A fragment of the original Hivelord, rallying behind its original. One isn't much of a threat, but..."
icon = 'icons/mob/animal.dmi'
icon_state = "Hivelordbrood"
@@ -222,7 +223,7 @@
del(src)
/mob/living/simple_animal/hostile/asteroid/Goliath
name = "Goliath"
name = "goliath"
desc = "A massive beast that uses long tentacles to ensare its prey, threatening them is not advised under any conditions."
icon = 'icons/mob/animal.dmi'
icon_state = "Goliath"
@@ -245,6 +246,17 @@
attacktext = "pulverizes"
throw_message = "does nothing to the rocky hide of the "
/mob/living/simple_animal/hostile/asteroid/Goliath/OpenFire()
visible_message("<span class='warning'>The [src.name] digs its tentacles under [target.name]!</span>")
var/tturf = get_turf(target)
new /obj/effect/goliath_tentacle/original(tturf)
ranged_cooldown = ranged_cooldown_cap
return
/mob/living/simple_animal/hostile/asteroid/Goliath/adjustBruteLoss(var/damage)
ranged_cooldown--
..()
/obj/effect/goliath_tentacle/
name = "Goliath tentacle"
icon = 'icons/mob/animal.dmi'
@@ -255,7 +267,8 @@
if(istype(turftype, /turf/simulated/mineral))
var/turf/simulated/mineral/M = turftype
M.GetDrilled()
..()
spawn(20)
Trip()
/obj/effect/goliath_tentacle/original
@@ -269,10 +282,6 @@
new /obj/effect/goliath_tentacle(T)
..()
/obj/effect/goliath_tentacle/New()
spawn(20)
Trip()
/obj/effect/goliath_tentacle/proc/Trip()
for(var/mob/living/M in src.loc)
M.Weaken(5)
@@ -285,13 +294,3 @@
return
..()
/mob/living/simple_animal/hostile/asteroid/Goliath/OpenFire()
visible_message("<span class='warning'>The [src.name] digs its tentacles under [target.name]!</span>")
var/tturf = get_turf(target)
new /obj/effect/goliath_tentacle/original(tturf)
ranged_cooldown = ranged_cooldown_cap
return
/mob/living/simple_animal/hostile/asteroid/Goliath/adjustBruteLoss(var/damage)
ranged_cooldown--
..()
@@ -31,7 +31,6 @@
min_n2 = 0
max_n2 = 0
unsuitable_atoms_damage = 15
wall_smash = 1
faction = "syndicate"
status_flags = CANPUSH