ID:149571
 
Can someone help me spiff up this code. It is a modified version of the monster comabt system. I can attack enemies but as much as they attack me they never do any damage. I have even tryed making them have 60 strength but nothing happens. The other problem is that whenever i die it doesnt give me full health and take me back. here is my code


mob
var/tmp
next_move_time = 0
movement_delay = 3
client
Move() // If we've reached the next move time, allow the move.
if (world.time >= mob.next_move_time)
mob.next_move_time = world.time + mob.movement_delay
// Calls the regular Move() function to allow the move to happen.
return ..()
else // Not allowed to move yet.
return 0

mob
var
armor_class = 1
defense = 3


mob


var
next_action_time
action_delay = 10 // How long between actions for an NPC?
movement_probability = 30 // How likely to move in a lifecycle?

verb/attack(mob/victim as mob in oview(1))
if(!victim.isnpc)
src.Attack(victim)
else
src<<"You cannot attack [victim]!"



New()
// Start my action cycle at a random point, to keep cycles spread out.
next_action_time = world.time + rand(10)
return ..()


base_EventCycle(world_time)
/*
This function is called by the EventLoop library once per tick (1/10th a second)
to give me a chance to do something if I want.

I only want to do something if we've reached my next_action_time.
*/
if (next_action_time <= world_time)
if (isDead())
return

// Time to do whatever.
TakeAction()

// Set the next walk time.
next_action_time = world_time + action_delay


Move()
if (isDead())
// Can't move if I'm dead.
return 1

// I'm alive, so do the default movement proc.
return ..()


proc/TakeAction()
// If this is a player, do nothing.
if (client)
return

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

proc/Attack(mob/victim)
usr.potential_damage = usr.strength + rand(1,3)
src.icon += rgb(20,0,0)
sleep(10)
src.icon -= rgb(20,0,0)
victim.TakeDamage(src, 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 -= usr.defense

if (usr.potential_damage > 0)
src.hp -= usr.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.
..()
i am bumping my psot because nobody answered and it has been a day.
In response to Mrhat99au
Mrhat99au wrote:
i am bumping my psot because nobody answered and it has been a day.

I hope you get the answer you seek, but may I offer a suggestion? In all likelyhood, you received no reply because you posted much more code than most of us are willing to try to read through and interpret. I took one look at that page and moved on.

Try distilling your question or problem to its essence, and post the minimum code needed to demonstrate it. You'll much more likely get a response.