ID:162563
 
I haven't used BYOND in a while, so I am wondering how exactly would I do to make a combat code. Like:
mob
proc
Attack()
//code


One thing I am really looking for is where exactly to put the while command (before or after(I know, I sound like a noob)).
Thank you for anybody who helps.
You can use the simple easy way...
(Note: This is not the best code for combat, but it does work.)
mob/verb/punch(mob/M in oview(1))
M.hp-=usr.str
if(M.hp < 1){M<<"You die!";M.loc=locate(/turf/wherever/);M.hp=M.maxhp}else{return 0}
In response to Dalkon_101
How about a more complex way. I could do that, but I mean where you deal damage then your enemy and so forth till one mob dies.
In response to DadGun
mob/proc/attack(var/mob/M)
if(M.hp / src.damage > M.damage / src.hp)
src << "You die!"
else
src << "They die!"
In response to Garthor
Okay, I think I can go with that. Or am I just being less specific?
In response to DadGun
Alright I got a good combat code, but now where do I put the while code?
mob
proc
Attack()
//do I put the while here?
//combat code
//or here?
In response to DadGun
You put in whatever you want to happen.

What I am not getting is what are you trying to actually do with a while().

From the posts you have made, I suggest you relearn the basics:


http://members.byond.com/ DreamMakers?command=view_post&post=36143
http://www.byond.com/developer/?page=Start
In response to GhostAnime
Like:
while(usr.hp > 0 && src.hp > 0)

It loops over and over until one loses all its health.