-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathbasic_targetting_datum.dm
55 lines (44 loc) · 1.91 KB
/
basic_targetting_datum.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
///Datum for basic mobs to define what they can attack.
/datum/targetting_datum
///Returns true or false depending on if the target can be attacked by the mob
/datum/targetting_datum/proc/can_attack(mob/living/living_mob, atom/target)
return
///Returns something the target might be hiding inside of
/datum/targetting_datum/proc/find_hidden_mobs(mob/living/living_mob, atom/target)
var/atom/target_hiding_location
if(istype(target.loc, /obj/structure/closet) || istype(target.loc, /obj/machinery/disposal) || istype(target.loc, /obj/machinery/sleeper))
target_hiding_location = target.loc
return target_hiding_location
/datum/targetting_datum/basic
/datum/targetting_datum/basic/can_attack(mob/living/living_mob, atom/the_target)
if(isturf(the_target) || !the_target) // bail out on invalids
return FALSE
if(ismob(the_target)) //Target is in godmode, ignore it.
var/mob/M = the_target
if(M.status_flags & GODMODE)
return FALSE
if(living_mob.see_invisible < the_target.invisibility)//Target's invisible to us, forget it
return FALSE
if(living_mob.z != the_target.z)
return FALSE
if(isliving(the_target)) //Targetting vs living mobs
var/mob/living/L = the_target
var/faction_check = living_mob.faction_check_mob(L)
if(faction_check || L.stat)
return FALSE
return TRUE
if(ismecha(the_target)) //Targetting vs mechas
var/obj/vehicle/sealed/mecha/M = the_target
for(var/occupant in M.occupants)
if(can_attack(living_mob, occupant)) //Can we attack any of the occupants?
return TRUE
if(istype(the_target, /obj/machinery/porta_turret)) //Cringe turret! kill it!
var/obj/machinery/porta_turret/P = the_target
if(P.in_faction(living_mob)) //Don't attack if the turret is in the same faction
return FALSE
if(P.has_cover && !P.raised) //Don't attack invincible turrets
return FALSE
if(P.machine_stat & BROKEN) //Or turrets that are already broken
return FALSE
return TRUE
return FALSE