ID:180519
 
atom/movable
var
hit_points = 10
armor_class = 0
defense = 0


mob
hit_points = 10

var
strength = 5

lifecycle_delay = 10 // How long between actions for an NPC?
movement_probability = 50 // How likely to move in a lifecycle?

verb
attack(mob/victim as mob in oview(1))
Attack(victim)




say(msg as text) //what the usr says is passed into "msg" as text
world << "[usr]: [msg]" //the world sees chatroom-like output


proc
Attack(mob/victim)
var/potential_damage = strength
victim.TakeDamage(src, potential_damage)

TakeDamage(mob/attacker, potential_damage)
// Can't kill me if I'm already dead.
if (isDead())
view(src) << "[attacker] hits [src]'s dead body!"
return

// Damage is reduced based on my armor class and defense.
var/defense_modifier = armor_class + defense
potential_damage -= defense_modifier

if (potential_damage > 0)
hit_points -= potential_damage
view(src) << "[attacker] hit [src] for [potential_damage] points damage!"

if (isDead())
view(src) << "[attacker] killed [src]!"
Die()
return
else
view(src) << "[attacker]'s attack bounces harmlessly off [src]."

Die()
icon = 'skull.dmi'

isDead()
if (hit_points <= 0)
return 1
return 0

LifeCycle()
// For handling NPC behavior, so if this mob has a client (player), skip this.
if (client || isDead())
return

// By default just have them walk around.
if (prob(movement_probability))
step_rand(src)

spawn(lifecycle_delay)
LifeCycle()

mob/Sabiaman
icon = 'Sabaiman.dmi'

New()
// First do default stuff.
..()

// Start my lifecycle at a random point.
spawn(rand(10))
LifeCycle()
return

LifeCycle()
if (client || isDead())
return

var/action_taken

// Before moving, NPC cops see if there is someone to attack within 1 space.
for (var/mob/other_mob in oview(1, src))
// But don't attack if it's another cop or they are dead...
if (istype(other_mob, /mob/Sabiaman) || other_mob.isDead())
continue

Attack(other_mob)
action_taken = 1

// No one to attack, so see if a non-cop is within 3 spaces to move toward.
for (var/mob/other_mob in oview(3, src))
if (istype(other_mob, /mob/Sabiaman) || other_mob.isDead())
continue

view(src) << "[src] is going after [other_mob]!"
step_towards(src, other_mob)
action_taken = 1

if (action_taken)
spawn(lifecycle_delay)
LifeCycle()
return

// No one around, so do the default behavior.
..()


Thats my code for my NPC attacking. BUT...HE IS JUST TOOOOOOO STRONG, HE WONT DIE AT ALL.