ID:262044
 
OK what I want to happen is when the monster is attacked the monster repsonds and it attacks back, but that's the problem... Its not happening.. So what you need/want(this is at will you know ;))to help me with is it needs to attack back, here.. Take a look.



mob
verb
Attack(mob/M in get_step(src, dir))
if(recover==1) return
recover=1
spawn(10) recover=0
var/damage = rand(0, src.strength)
var/guard = rand(0, M.defense)
damage -= guard
if(damage < 0)
damage = 0
M.HP -= damage
s_damage(M, damage, "#FF0000")
M.DeathCheck()

proc
MonAttack(mob/M)
var/damage = rand(0, src.strength)
var/guard = rand(0, usr.defense)

damage -= guard
if(damage < 0)
damage = 0
usr.HP -= damage
s_damage(usr, damage, "#FF0000")
usr.DeathCheck()



PS. Noobies steal this I ono what will happen, this is not a coding for grabs -_-.. Yes I do relize that I posted the exact same thing in newbie centeral.. But for some reason no one will help, so I am leaving this to you guys..Thanks IN Advance.
King_Dragoon wrote:
OK what I want to happen is when the monster is attacked the monster repsonds and it attacks back, but that's the problem... Its not happening.. So what you need/want(this is at will you know ;))to help me with is it needs to attack back, here.. Take a look.



mob
verb
Attack(mob/M in get_step(src, dir))
if(recover==1) return
recover=1
spawn(10) recover=0
var/damage = rand(0, src.strength)
var/guard = rand(0, M.defense)
damage -= guard
if(damage < 0)
damage = 0
M.HP -= damage
s_damage(M, damage, "#FF0000")
M.DeathCheck()

proc
MonAttack(mob/M)
var/damage = rand(0, src.strength)
var/guard = rand(0, usr.defense)

damage -= guard
if(damage < 0)
damage = 0
usr.HP -= damage
s_damage(usr, damage, "#FF0000")
usr.DeathCheck()

Replace every "usr" in those two procs with "M".

Usr is unsafe in procedures.



At the end of your Attack procedure, add in a check.

if The opponent is not dead
if They are a monster (using istype())
call M's MonAttack() procedure

It should look simular to this:
(Please note that I am assuming you have these variables)
if(!M.dead) // if they aren't dead
if(istype(M,/mob/monster))
M.MonAttack()

In response to Unknown Person
You forgot to pass the parameter to MonAttack() in your example. It should look closer to this:
if(!M.dead) // if they aren't dead
if(istype(M,/mob/monster))
M.MonAttack(src)
In response to Jon88
This is why I shouldn't type while tired. :/
In response to Unknown Person
  • proc
    MonAttack(mob/M)
    var/damage = rand(0, src.strength)
    var/guard = rand(0, M.defense)

    damage -= guard
    if(damage < 0)
    damage = 0
    M.HP -= damage
    s_damage(usr, damage, "#FF0000")
    if(!M.dead) // if they aren't dead
    if(istype(M,/mob/monster))
    M.MonAttack(src)
    M.DeathCheck()


  • Something like that?
In response to Unknown Person
Sorry guys but my friend is actualy doing the battle system and I am trying to help him out, so please could you tell me the placement orders to these procs and junk(Junk is a refferal to the coding..)?
In response to King_Dragoon
Why in gods name did you double post here and in newbie central? Please only keep the same topic in one place :)
In response to XzDoG
Xzdog the reason is was because I wanted to change the area where I was posting this in, since some users couldn't help me in newbie centeral I moved it into here..
In response to King_Dragoon
King_Dragoon wrote:
Xzdog the reason is was because I wanted to change the area where I was posting this in, since some users couldn't help me in newbie centeral I moved it into here..

Make your post in a single place. If it needs moving, the mods will deal with it.
In response to Jon88
No one was answering my question on my battle system delema so I moved it here.. -_-
In response to King_Dragoon
I am the one doing the coding, the problem is. The zmonster is attacking, but only once. Because I call it in my attack verb, it attacks and thats it. I want it to continually attack. Oh, and the reaosn i am using usr, is because i tried it with M instead and it was giving me a bunch of errors. Says it cant locate the info or something. Please help