Files
CHOMPStation2/code/modules/critters/critterAI.dm
mport2004@gmail.com c9bb9c2e5f Doors now check for critter access.
Cleaned up the objectives a bit and made a new "kill" one for rev.
Cleaned up implants and implanters a bit.
Cleaned up the prisoner computer a bit.
Sec Huds can be placed on security helmets (Still needs a sprite)
The beachball now has in hand sprites (Kor)

Cult:
Heads other than the Captain and HoS are now able to start as or be converted to a cultist.
Loyalty implants will block conversion but will not unconvert cultists.

Rev:
Station Heads or Head Revs who leave z1 will count as dead so long as they are off of the z level.
Loyalty implants will block conversion and will unconvert revs upon injection.
Once a mind has been unconverted it may not be reconverted

New items:
Loyalty implants, small implant that prevents reving/cult
The Captain, Warden, Officers, and Detective all start with one already implanted
Loyalty Implanter machine on the prison station that implants loyalty implants and may regen implants after a cooldown.


git-svn-id: http://tgstation13.googlecode.com/svn/trunk@2049 316c924e-a436-60f5-8080-3fe189b3f50e
2011-08-26 07:41:37 +00:00

185 lines
5.2 KiB
Plaintext

/obj/critter
New()
spawn(0) process()//I really dont like this much but it seems to work well
..()
process()
set background = 1
if (!src.alive) return
switch(task)
if("thinking")
src.attack = 0
src.target = null
sleep(15)
walk_to(src,0)
if (src.aggressive) seek_target()
if (src.wanderer && !src.target) src.task = "wandering"
if("chasing")
if (src.frustration >= max_frustration)
src.target = null
src.last_found = world.time
src.frustration = 0
src.task = "thinking"
walk_to(src,0)
if (target)
if (get_dist(src, src.target) <= 1)
var/mob/living/carbon/M = src.target
ChaseAttack()
src.task = "attacking"
src.anchored = 1
src.target_lastloc = M.loc
else
var/turf/olddist = get_dist(src, src.target)
walk_to(src, src.target,1,4)
if ((get_dist(src, src.target)) >= (olddist))
src.frustration++
else
src.frustration = 0
sleep(5)
else src.task = "thinking"
if("attacking")
// see if he got away
if ((get_dist(src, src.target) > 1) || ((src.target:loc != src.target_lastloc)))
src.anchored = 0
src.task = "chasing"
else
if (get_dist(src, src.target) <= 1)
var/mob/living/carbon/M = src.target
if(!src.attacking) RunAttack()
if(!src.aggressive)
src.task = "thinking"
src.target = null
src.anchored = 0
src.last_found = world.time
src.frustration = 0
src.attacking = 0
else
if(M!=null)
if(M.health < 0)
src.task = "thinking"
src.target = null
src.anchored = 0
src.last_found = world.time
src.frustration = 0
src.attacking = 0
else
src.anchored = 0
src.attacking = 0
src.task = "chasing"
if("wandering")
patrol_step()
sleep(10)
spawn(8)
process()
return
patrol_step()
var/moveto = locate(src.x + rand(-1,1),src.y + rand(-1, 1),src.z)
if (istype(moveto, /turf/simulated/floor) || istype(moveto, /turf/simulated/shuttle/floor) || istype(moveto, /turf/unsimulated/floor)) step_towards(src, moveto)
if(src.aggressive) seek_target()
steps += 1
if (steps == rand(5,20)) src.task = "thinking"
Bump(M as mob|obj)//TODO: Add access levels here
spawn(0)
if((istype(M, /obj/machinery/door)))
if(src.opensdoors)
M:open()
src.frustration = 0
else src.frustration ++
if((istype(M, /mob/living/)) && (!src.anchored))
src.loc = M:loc
src.frustration = 0
return
return
Bumped(M as mob|obj)
spawn(0)
var/turf/T = get_turf(src)
M:loc = T
seek_target()
src.anchored = 0
var/T = null
for(var/mob/living/C in view(src.seekrange,src))//TODO: mess with this
if (src.target)
src.task = "chasing"
break
if((C.name == src.oldtarget_name) && (world.time < src.last_found + 100)) continue
if(istype(C, /mob/living/carbon/) && !src.atkcarbon) continue
if(istype(C, /mob/living/silicon/) && !src.atksilicon) continue
if(C.health < 0) continue
if(istype(C, /mob/living/carbon/) && src.atkcarbon) src.attack = 1
if(istype(C, /mob/living/silicon/) && src.atksilicon) src.attack = 1
if(src.attack)
T = C
break
if(!src.attack)
for(var/obj/critter/C in view(src.seekrange,src))
if(istype(C, /obj/critter) && !src.atkcritter) continue
if(istype(C, /obj/mecha) && !src.atkmech) continue
if(C.health <= 0) continue
if(istype(C, /obj/critter) && src.atkcritter)
if((istype(C, src.type) && !src.atksame) || (C == src)) continue
src.attack = 1
if(istype(C, /obj/mecha) && src.atkmech) src.attack = 1
if(src.attack)
T = C
break
if(src.attack)
src.target = T
src.oldtarget_name = T:name
src.task = "chasing"
return
ChaseAttack()
for(var/mob/O in viewers(src, null))
O.show_message("\red <B>[src]</B> [src.angertext] at [src.target]!", 1)
return
RunAttack()
src.attacking = 1
for(var/mob/O in viewers(src, null))
O.show_message("\red <B>[src]</B> [src.attacktext] [src.target]!", 1)
if(ismob(src.target))
src.target:bruteloss += rand(melee_damage_lower,melee_damage_upper)
if(isobj(src.target))
if(istype(target, /obj/mecha))
src.target:take_damage(rand(melee_damage_lower,melee_damage_upper))
else
src.target:TakeDamage(rand(melee_damage_lower,melee_damage_upper))
spawn(25)
src.attacking = 0
return
/*TODO: Figure out how to handle special things like this dont really want to give it to every critter
/obj/critter/proc/CritterTeleport(var/telerange, var/dospark, var/dosmoke)
if (!src.alive) return
var/list/randomturfs = new/list()
for(var/turf/T in orange(src, telerange))
if(istype(T, /turf/space) || T.density) continue
randomturfs.Add(T)
src.loc = pick(randomturfs)
if (dospark)
var/datum/effects/system/spark_spread/s = new /datum/effects/system/spark_spread
s.set_up(5, 1, src)
s.start()
if (dosmoke)
var/datum/effects/system/harmless_smoke_spread/smoke = new /datum/effects/system/harmless_smoke_spread()
smoke.set_up(10, 0, src.loc)
smoke.start()
src.task = "thinking"
*/