ID:141911
 
Code:
    Enemy
icon = 'Unknown.dmi'
hp = new(200,200)
str = new(33,33)
def = new(8,8)
New()
. = ..()
AI()
proc
AI()
while(src)
var/c = 0
for(var/mob/M in oview(5,src))
if(M.client)
c = 1
if(c)
for(var/mob/M in oview(5,src))
if(M.client)
step_towards(src,M)
else
walk(src,0)
sleep(3)
Bump(mob/M)
if(src.canattack)
src.canattack = 0
spawn( rand(3, 5) ) canattack = 1
var/dmg = round( (rand(src.str.val * 0.8, src.str.val * 1.2) ) - (rand(M.def.val * 0.5, M.def.val * 1.1) ) )
if(dmg <= 0) view() << "<i>[src] misses [M]!"
else
M.hp.val -= dmg
view() << "<i>[src] attacked [M] for [dmg] damage!"
M.Death(src)


Problem description:k, that works, but thats the ONLY enemy that works.
Ultimate
icon = 'ZKR.dmi'
hp = new(500,500)
str = new(40,40)
def = new(8,8)
New()
. = ..()
AI()
proc
AI()
while(src)
var/c = 0
for(var/mob/M in oview(5,src))
if(M.client)
c = 1
if(c)
for(var/mob/M in oview(5,src))
if(M.client)
step_towards(src,M)
else
walk(src,0)
sleep(3)
Bump(mob/M)
if(src.canattack)
src.canattack = 0
spawn( rand(3, 5) ) canattack = 1
var/dmg = round( (rand(src.str.val * 0.8, src.str.val * 1.2) ) - (rand(M.def.val * 0.5, M.def.val * 1.1) ) )
if(dmg <= 0) view() << "<i>[src] misses [M]!"
else
M.hp.val -= dmg
view() << "<i>[src] attacked [M] for [dmg] damage!"
M.Death(src)

This one doesn't work, neither does any of my other enemies besides Enemy. I don't get it. When ever there health goes to 0, they still live and health goes down to negative. Can anyone help me?

(I used resource for the enemy, and edited it to make the others)
I think you should add a del(src) at the end.
Everything looks the same besides the HP and name. Other then that is "ultimate" tabbed like Enemy or is it just not tabbed in your post?
        hp = new(200,200)
str = new(33,33)
def = new(8,8)


What are you even trying to do there? It makes nearly no sense, unless hp, str, and def are datums/some higher object (which is pretty stupid, considering all you should need is a number!).
In response to Jeff8500
Yes, Uktimate is tabbed in the code, i forgot to tab it here. Besides, it would come up with some indentation error if it didn't. The new(200,200) is because they slowly recharge, the second number shows their MaxHP, including when u are nearby an enemy, a tab with their name will comeup, in there you can see their stats.
(Same with other players.)
In response to Jeff8500
Jeff8500 wrote:
>         hp = new(200,200)
> str = new(33,33)
> def = new(8,8)
>
>

What are you even trying to do there? It makes nearly no sense, unless hp, str, and def are datums/some higher object (which is pretty stupid, considering all you should need is a number!).

And saying that things are stupid don't help fix the problem. If you really want to help, then do so instead of bagging on others, otherwise, don't reply
In response to Zkrbot
It still is rather silly. You could just create a loop under the player, and roll with that. It would be much simpler!

Also, the problem is that your loop is while(src). Therefore, if you don't delete the src, it will keep attacking. Forever. You should delete it. for() is more efficient then while(src), by the way, and does the same thing unless you're changing the value of src.
In response to Jeff8500
So how come it works with the normal Enemy?
(sorry, im a noob at coding, i guess u could call me that.)
As i said before, i used mostly rescources in my coding.
In response to ZKR
It's probably deleted somewhere along the lines. Not sure; either way, you should read my article on modular programming and try to stray away from resources that aren't in the dream makers guild (most of which are bad!).
In response to Jeff8500
This is completely off subject, but awesome avatar pic