Merge branch 'master' of https://github.com/PolarisSS13/Polaris into attackcall

This commit is contained in:
Yoshax
2016-05-29 00:56:57 +01:00
50 changed files with 2642 additions and 642 deletions
@@ -57,16 +57,16 @@
switch(stance)
if(HOSTILE_STANCE_TIRED)
if(STANCE_TIRED)
stop_automated_movement = 1
stance_step++
if(stance_step >= 10) //rests for 10 ticks
if(target_mob && target_mob in ListTargets(10))
stance = HOSTILE_STANCE_ATTACK //If the mob he was chasing is still nearby, resume the attack, otherwise go idle.
stance = STANCE_ATTACK //If the mob he was chasing is still nearby, resume the attack, otherwise go idle.
else
stance = HOSTILE_STANCE_IDLE
stance = STANCE_IDLE
if(HOSTILE_STANCE_ALERT)
if(STANCE_ALERT)
stop_automated_movement = 1
var/found_mob = 0
if(target_mob && target_mob in ListTargets(10))
@@ -84,14 +84,14 @@
stance_step--
if(stance_step <= -20) //If we have not found a mob for 20-ish ticks, revert to idle mode
stance = HOSTILE_STANCE_IDLE
stance = STANCE_IDLE
if(stance_step >= 7) //If we have been staring at a mob for 7 ticks,
stance = HOSTILE_STANCE_ATTACK
stance = STANCE_ATTACK
if(HOSTILE_STANCE_ATTACKING)
if(STANCE_ATTACKING)
if(stance_step >= 20) //attacks for 20 ticks, then it gets tired and needs to rest
custom_emote(1, "is worn out and needs to rest." )
stance = HOSTILE_STANCE_TIRED
stance = STANCE_TIRED
stance_step = 0
walk(src, 0) //This stops the bear's walking
return
@@ -99,15 +99,15 @@
/mob/living/simple_animal/hostile/bear/attackby(var/obj/item/O as obj, var/mob/user as mob)
if(stance != HOSTILE_STANCE_ATTACK && stance != HOSTILE_STANCE_ATTACKING)
stance = HOSTILE_STANCE_ALERT
if(stance != STANCE_ATTACK && stance != STANCE_ATTACKING)
stance = STANCE_ALERT
stance_step = 6
target_mob = user
..()
/mob/living/simple_animal/hostile/bear/attack_hand(mob/living/carbon/human/M as mob)
if(stance != HOSTILE_STANCE_ATTACK && stance != HOSTILE_STANCE_ATTACKING)
stance = HOSTILE_STANCE_ALERT
if(stance != STANCE_ATTACK && stance != STANCE_ATTACKING)
stance = STANCE_ALERT
stance_step = 6
target_mob = M
..()
@@ -119,7 +119,7 @@
. = ..()
if(.)
custom_emote(1,"stares alertly at [.]")
stance = HOSTILE_STANCE_ALERT
stance = STANCE_ALERT
/mob/living/simple_animal/hostile/bear/LoseTarget()
..(5)
@@ -90,7 +90,7 @@
/mob/living/simple_animal/hostile/giant_spider/Life()
..()
if(!stat)
if(stance == HOSTILE_STANCE_IDLE)
if(stance == STANCE_IDLE)
//1% chance to skitter madly away
if(!busy && prob(1))
/*var/list/move_targets = list()
@@ -113,7 +113,7 @@
/mob/living/simple_animal/hostile/giant_spider/nurse/Life()
..()
if(!stat)
if(stance == HOSTILE_STANCE_IDLE)
if(stance == STANCE_IDLE)
var/list/can_see = view(src, 10)
//30% chance to stop wandering and do something
if(!busy && prob(30))
@@ -1,234 +1,15 @@
/mob/living/simple_animal/hostile
faction = "hostile"
var/stance = HOSTILE_STANCE_IDLE //Used to determine behavior
var/mob/living/target_mob
var/attack_same = 0
var/ranged = 0
var/rapid = 0
var/projectiletype
var/projectilesound
var/casingtype
var/move_to_delay = 4 //delay for the automated movement.
var/list/friends = list()
var/break_stuff_probability = 10
break_stuff_probability = 10
stop_automated_movement_when_pulled = 0
var/destroy_surroundings = 1
destroy_surroundings = 1
a_intent = I_HURT
hostile = 1
var/shuttletarget = null
var/enroute = 0
/mob/living/simple_animal/hostile/proc/FindTarget()
var/atom/T = null
stop_automated_movement = 0
for(var/atom/A in ListTargets(10))
if(A == src)
continue
var/atom/F = Found(A)
if(F)
T = F
break
if(isliving(A))
var/mob/living/L = A
if(L.faction == src.faction && !attack_same)
continue
else if(L in friends)
continue
else
if(!L.stat)
stance = HOSTILE_STANCE_ATTACK
T = L
break
else if(istype(A, /obj/mecha)) // Our line of sight stuff was already done in ListTargets().
var/obj/mecha/M = A
if (M.occupant)
stance = HOSTILE_STANCE_ATTACK
T = M
break
return T
/mob/living/simple_animal/hostile/proc/Found(var/atom/A)
return
/mob/living/simple_animal/hostile/proc/MoveToTarget()
stop_automated_movement = 1
if(!target_mob || SA_attackable(target_mob))
stance = HOSTILE_STANCE_IDLE
if(target_mob in ListTargets(10))
if(ranged)
if(get_dist(src, target_mob) <= 6)
OpenFire(target_mob)
else
walk_to(src, target_mob, 1, move_to_delay)
else
stance = HOSTILE_STANCE_ATTACKING
walk_to(src, target_mob, 1, move_to_delay)
/mob/living/simple_animal/hostile/proc/AttackTarget()
stop_automated_movement = 1
if(!target_mob || SA_attackable(target_mob))
LoseTarget()
return 0
if(!(target_mob in ListTargets(10)))
LostTarget()
return 0
if(get_dist(src, target_mob) <= 1) //Attacking
AttackingTarget()
return 1
/mob/living/simple_animal/hostile/proc/AttackingTarget()
if(!Adjacent(target_mob))
return
if(isliving(target_mob))
var/mob/living/L = target_mob
L.attack_generic(src,rand(melee_damage_lower,melee_damage_upper),attacktext)
return L
if(istype(target_mob,/obj/mecha))
var/obj/mecha/M = target_mob
M.attack_generic(src,rand(melee_damage_lower,melee_damage_upper),attacktext)
return M
/mob/living/simple_animal/hostile/proc/LoseTarget()
stance = HOSTILE_STANCE_IDLE
target_mob = null
walk(src, 0)
/mob/living/simple_animal/hostile/proc/LostTarget()
stance = HOSTILE_STANCE_IDLE
walk(src, 0)
/mob/living/simple_animal/hostile/proc/ListTargets(var/dist = 7)
var/list/L = hearers(src, dist)
for (var/obj/mecha/M in mechas_list)
if (M.z == src.z && get_dist(src, M) <= dist)
L += M
return L
/mob/living/simple_animal/hostile/death()
..()
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)
target_mob = FindTarget()
if(HOSTILE_STANCE_ATTACK)
if(destroy_surroundings)
DestroySurroundings()
MoveToTarget()
if(HOSTILE_STANCE_ATTACKING)
if(destroy_surroundings)
DestroySurroundings()
AttackTarget()
/mob/living/simple_animal/hostile/proc/OpenFire(target_mob)
var/target = target_mob
visible_message("\red <b>[src]</b> fires at [target]!", 1)
var/tturf = get_turf(target)
if(rapid)
spawn(1)
Shoot(tturf, src.loc, src)
if(casingtype)
new casingtype(get_turf(src))
spawn(4)
Shoot(tturf, src.loc, src)
if(casingtype)
new casingtype(get_turf(src))
spawn(6)
Shoot(tturf, src.loc, src)
if(casingtype)
new casingtype(get_turf(src))
else
Shoot(tturf, src.loc, src)
if(casingtype)
new casingtype
stance = HOSTILE_STANCE_IDLE
target_mob = null
return
/mob/living/simple_animal/hostile/proc/Shoot(var/target, var/start, var/user, var/bullet = 0)
if(target == start)
return
var/obj/item/projectile/A = new projectiletype(user:loc)
playsound(user, projectilesound, 100, 1)
if(!A) return
if (!istype(target, /turf))
qdel(A)
return
A.launch(target)
return
/mob/living/simple_animal/hostile/proc/DestroySurroundings()
if(prob(break_stuff_probability))
for(var/dir in cardinal) // North, South, East, West
for(var/obj/structure/window/obstacle in get_step(src, dir))
if(obstacle.dir == reverse_dir[dir]) // So that windows get smashed in the right order
obstacle.attack_generic(src,rand(melee_damage_lower,melee_damage_upper),attacktext)
return
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_generic(src,rand(melee_damage_lower,melee_damage_upper),attacktext)
/mob/living/simple_animal/hostile/proc/check_horde()
return 0
if(emergency_shuttle.shuttle.location)
if(!enroute && !target_mob) //The shuttle docked, all monsters rush for the escape hallway
if(!shuttletarget && escape_list.len) //Make sure we didn't already assign it a target, and that there are targets to pick
shuttletarget = pick(escape_list) //Pick a shuttle target
enroute = 1
stop_automated_movement = 1
spawn()
if(!src.stat)
horde()
if(get_dist(src, shuttletarget) <= 2) //The monster reached the escape hallway
enroute = 0
stop_automated_movement = 0
/mob/living/simple_animal/hostile/proc/horde()
var/turf/T = get_step_to(src, shuttletarget)
for(var/atom/A in T)
if(istype(A,/obj/machinery/door/airlock))
var/obj/machinery/door/airlock/D = A
D.open(1)
else if(istype(A,/obj/structure/simple_door))
var/obj/structure/simple_door/D = A
if(D.density)
D.Open()
else if(istype(A,/obj/structure/cult/pylon))
A.attack_generic(src, rand(melee_damage_lower, melee_damage_upper))
else if(istype(A, /obj/structure/window) || istype(A, /obj/structure/closet) || istype(A, /obj/structure/table) || istype(A, /obj/structure/grille))
A.attack_generic(src, rand(melee_damage_lower, melee_damage_upper))
Move(T)
FindTarget()
if(!target_mob || enroute)
spawn(10)
if(!src.stat)
horde()
return 0
@@ -5,14 +5,14 @@
if(isliving(A))
var/mob/living/L = A
if(!L.stat)
stance = HOSTILE_STANCE_ATTACK
stance = STANCE_ATTACK
return L
else
enemies -= L
else if(istype(A, /obj/mecha))
var/obj/mecha/M = A
if(M.occupant)
stance = HOSTILE_STANCE_ATTACK
stance = STANCE_ATTACK
return A
/mob/living/simple_animal/hostile/retaliate/ListTargets()
@@ -66,6 +66,33 @@
var/supernatural = 0
var/purge = 0
//Pulling hostile mob vars down
var/stance = STANCE_IDLE //Used to determine behavior
var/mob/living/target_mob
var/attack_same = 0
var/ranged = 0
var/rapid = 0
var/projectiletype
var/projectilesound
var/casingtype
var/move_to_delay = 4 //delay for the automated movement.
var/list/friends = list()
var/break_stuff_probability = 0
var/destroy_surroundings = 0
var/shuttletarget = null
var/enroute = 0
var/list/resistances = list(
HALLOSS = 0,
BRUTE = 1,
BURN = 1,
TOX = 1,
OXY = 0,
CLONE = 0
)
var/hostile = 0
/mob/living/simple_animal/New()
..()
verbs -= /mob/verb/observe
@@ -204,6 +231,23 @@
if(!atmos_suitable)
adjustBruteLoss(unsuitable_atoms_damage)
//Hostility
if(!stat && !client && hostile)
switch(stance)
if(STANCE_IDLE)
target_mob = FindTarget()
if(STANCE_ATTACK)
if(destroy_surroundings)
DestroySurroundings()
MoveToTarget()
if(STANCE_ATTACKING)
if(destroy_surroundings)
DestroySurroundings()
AttackTarget()
return 1
/mob/living/simple_animal/proc/handle_supernatural()
@@ -299,7 +343,7 @@
if(O.force <= resistance)
user << "<span class='danger'>This weapon is ineffective, it does no damage.</span>"
return 2
var/damage = O.force
if (O.damtype == HALLOSS)
damage = 0
@@ -402,3 +446,191 @@
return
/mob/living/simple_animal/ExtinguishMob()
return
//Hostile procs moved down
/mob/living/simple_animal/proc/FindTarget()
var/atom/T = null
stop_automated_movement = 0
for(var/atom/A in ListTargets(10))
if(A == src)
continue
var/atom/F = Found(A)
if(F)
T = F
break
if(isliving(A))
var/mob/living/L = A
if(L.faction == src.faction && !attack_same)
continue
else if(L in friends)
continue
else
if(!L.stat)
stance = STANCE_ATTACK
T = L
break
else if(istype(A, /obj/mecha)) // Our line of sight stuff was already done in ListTargets().
var/obj/mecha/M = A
if (M.occupant)
stance = STANCE_ATTACK
T = M
break
return T
/mob/living/simple_animal/proc/Found(var/atom/A)
return
/mob/living/simple_animal/proc/MoveToTarget()
stop_automated_movement = 1
if(!target_mob || SA_attackable(target_mob))
stance = STANCE_IDLE
if(target_mob in ListTargets(10))
if(ranged)
if(get_dist(src, target_mob) <= 6)
OpenFire(target_mob)
else
walk_to(src, target_mob, 1, move_to_delay)
else
stance = STANCE_ATTACKING
walk_to(src, target_mob, 1, move_to_delay)
/mob/living/simple_animal/proc/AttackTarget()
stop_automated_movement = 1
if(!target_mob || SA_attackable(target_mob))
LoseTarget()
return 0
if(!(target_mob in ListTargets(10)))
LostTarget()
return 0
if(get_dist(src, target_mob) <= 1) //Attacking
AttackingTarget()
return 1
/mob/living/simple_animal/proc/AttackingTarget()
if(!Adjacent(target_mob))
return
if(isliving(target_mob))
var/mob/living/L = target_mob
L.attack_generic(src,rand(melee_damage_lower,melee_damage_upper),attacktext)
return L
if(istype(target_mob,/obj/mecha))
var/obj/mecha/M = target_mob
M.attack_generic(src,rand(melee_damage_lower,melee_damage_upper),attacktext)
return M
/mob/living/simple_animal/proc/LoseTarget()
stance = STANCE_IDLE
target_mob = null
walk(src, 0)
/mob/living/simple_animal/proc/LostTarget()
stance = STANCE_IDLE
walk(src, 0)
/mob/living/simple_animal/proc/ListTargets(var/dist = 7)
var/list/L = hearers(src, dist)
for (var/obj/mecha/M in mechas_list)
if (M.z == src.z && get_dist(src, M) <= dist)
L += M
return L
/mob/living/simple_animal/proc/OpenFire(target_mob)
var/target = target_mob
visible_message("\red <b>[src]</b> fires at [target]!", 1)
var/tturf = get_turf(target)
if(rapid)
spawn(1)
Shoot(tturf, src.loc, src)
if(casingtype)
new casingtype(get_turf(src))
spawn(4)
Shoot(tturf, src.loc, src)
if(casingtype)
new casingtype(get_turf(src))
spawn(6)
Shoot(tturf, src.loc, src)
if(casingtype)
new casingtype(get_turf(src))
else
Shoot(tturf, src.loc, src)
if(casingtype)
new casingtype
stance = STANCE_IDLE
target_mob = null
return
/mob/living/simple_animal/proc/Shoot(var/target, var/start, var/user, var/bullet = 0)
if(target == start)
return
var/obj/item/projectile/A = new projectiletype(user:loc)
playsound(user, projectilesound, 100, 1)
if(!A) return
if (!istype(target, /turf))
qdel(A)
return
A.launch(target)
return
/mob/living/simple_animal/proc/DestroySurroundings()
if(prob(break_stuff_probability))
for(var/dir in cardinal) // North, South, East, West
for(var/obj/structure/window/obstacle in get_step(src, dir))
if(obstacle.dir == reverse_dir[dir]) // So that windows get smashed in the right order
obstacle.attack_generic(src,rand(melee_damage_lower,melee_damage_upper),attacktext)
return
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_generic(src,rand(melee_damage_lower,melee_damage_upper),attacktext)
/mob/living/simple_animal/proc/check_horde()
return 0
if(emergency_shuttle.shuttle.location)
if(!enroute && !target_mob) //The shuttle docked, all monsters rush for the escape hallway
if(!shuttletarget && escape_list.len) //Make sure we didn't already assign it a target, and that there are targets to pick
shuttletarget = pick(escape_list) //Pick a shuttle target
enroute = 1
stop_automated_movement = 1
spawn()
if(!src.stat)
horde()
if(get_dist(src, shuttletarget) <= 2) //The monster reached the escape hallway
enroute = 0
stop_automated_movement = 0
/mob/living/simple_animal/proc/horde()
var/turf/T = get_step_to(src, shuttletarget)
for(var/atom/A in T)
if(istype(A,/obj/machinery/door/airlock))
var/obj/machinery/door/airlock/D = A
D.open(1)
else if(istype(A,/obj/structure/simple_door))
var/obj/structure/simple_door/D = A
if(D.density)
D.Open()
else if(istype(A,/obj/structure/cult/pylon))
A.attack_generic(src, rand(melee_damage_lower, melee_damage_upper))
else if(istype(A, /obj/structure/window) || istype(A, /obj/structure/closet) || istype(A, /obj/structure/table) || istype(A, /obj/structure/grille))
A.attack_generic(src, rand(melee_damage_lower, melee_damage_upper))
Move(T)
FindTarget()
if(!target_mob || enroute)
spawn(10)
if(!src.stat)
horde()