ID:149504
 
There are some many problems in this code. First you cant attack the wolf or who ever you want to attack. Second whenever the wolf attacks back it says it is attacking a shop keeper and doesnt do any damage any ideas? That isnt all the code. if you need more i will post more

proc/Attack(mob/victim as mob in oview(1))
set src in oview(1)
usr.potential_damage = usr.strength - victim.defense - victim.armor_class
src.icon += rgb(20,0,0)
sleep(10)
src.icon -= rgb(20,0,0)
victim.TakeDamage(usr, potential_damage)




proc/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.
usr.potential_damage -= src.defense

if (usr.potential_damage > 0)
src.hp -= attacker.potential_damage
view(src) << "[attacker] hit [src] for [potential_damage] points damage!"
s_damage(usr ,potential_damage ,"red")
if (isDead())
view(src) << "[attacker] killed [src]!"
src.isdead = 1
Die()
return
else
view(src) << "[attacker]'s attack bounces harmlessly off [src]."

proc/Die()
if(src.compute == 1)//its a monster
src.loc.contents += src.contents
src.icon = 'deadcop.dmi'
del(src)
else if(usr.compute == 1)
src.loc.contents += src.contents
del(src)
else
src.Move(locate(38,25,1))
src.Health=usr.MaxHealth
src.isdead = 0



proc/isDead()
if (hp <= 0)
return 1
return 0
mob/wolf
icon = 'wolf.dmi'
strength = 17
hp = 20
maxhp = 20
speed = 5
defense = 5
contents = newlist(/obj/weapons/Short_Sword,)
TakeAction()
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/wolf) || 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/wolf) || other_mob.isDead() || istype(other_mob, /mob/NPCS/Aracon))

continue

step_towards(src, other_mob)
action_taken = 1

if (action_taken)
return

// No one around, so do the default behavior.
..()
This line stands out:

if (usr.potential_damage > 0)

There is no "usr" in this proc. And since you've alredy supplied a variable called potential_damage in the procs call, just change it to:

if (potential_damage > 0)

There might be more wrong too... just stopped at the first thing I saw.
In response to Skysaw
Ok i changed that but it didnt work. I know there is something wrong but i dont know what?
In response to Mrhat99au
Mrhat99au wrote:
Ok i changed that but it didnt work. I know there is something wrong but i dont know what?

Ok, in Attack(), change all occurances of usr to src (I'm assuming this is a mob/proc).

Later in the code, there are two more occurances of usr that should just be deleted.