ID:264034
 
Title, read comments too. I didnt get any errors and I cant test it atm, but would it work?
mob/proc
attack(mob/DM) //other people
if(DM.pvpguard==1) //do they have pvpguard on?
usr<<"\white <b><center>[DM] has PVP-Guard on. You cant attack [DM].</b>" //apperantly so
return //then it wont go on.
else //if not
var/Damage=(src.str * 2 / (1.1 * DM.def)) //damage is your strength * 2, and divided by 1.1\
their defense.

DM.hp-=Damage
usr<<"\red <b><i>You dealt [Damage]damage to [DM]!</b></i>"
attack_it() //a proc to check if you CAN attack
for(var/mob/M in oview(1)) //for any mobs in a 1 tile range
sleep(usr.agl) //sleeps on the amount of your agl
attack(M) //attacks whatever mob was in view
deathcheck(mob/K,mob/DM) //mob/K is the killer, mob/DM is the killed one...
if(src.hp<=0) //less then 0 HP?
if(client) //you a client?
usr<<"\red <center>[usr] died from the [DM]." //supposed to read like (if i'm getting killed):\
King of Slimes got killed by the [DM].

usr.loc = locate(respawnpoint) //it spawns you back to your respawnpoint
usr.hp=usr.mhp //restores hp
usr.death++ //you now have 1 more death to the count
else //if it isnt a client
view()<<"\red <b><center>[DM] was killed by [usr]" //nice lil' message
give_rewards(K) //gives rewards to the killer.
del DM //deletes the killed thing
give_rewards(mob/K,mob/DM) //K = killer, DM = killed
K.exp+=DM.expg //your exp is boosted by the DM's expg
K.gold+=DM.goldg //same as above, but for gold

client
Center() //press center ;D
mob.attack_it() //you attack it :P
No.

First of all, you're misusing usr all over the place. Every instance of usr should be replaced with src. Similarly, view() should be replaced with view(src), and the same with oview().

Putting a sleep in your attack_it() proc like that is going to cause unintended behavior:

1) If you are surrounded by enemies, it will attack them one at a time.
2) You will hit things after they move out of range.
3) It does not reduce the rate at which you can attack in any way.

You need to be setting up a variable that says when you can next attack. Like so:

mob/var/nextattack = 0

mob/proc/attack_it()
if(nextattack < world.time)
return
else
nextattack = world.time + delay
stuff


Also: you never call deathcheck().
In response to Garthor
o_o... other then that, what should I do?
In response to King of Slimes
How about starting with what I told you?
In response to Garthor
Like this?

mob/proc
attack(mob/DM) //other people
if(DM.pvpguard==1) //do they have pvpguard on?
src<<"\white <b><center>[DM] has PVP-Guard on. You cant attack [DM].</b>" //apperantly so
return //then it wont go on.
else //if not
var/Damage=(src.str * 2 / (1.1 * DM.def)) //damage is your strength * 2, and divided by 1.1\
their defense.

DM.hp-=Damage
src<<"\red <b><i>You dealt [Damage]damage to [DM]!</b></i>"
attack_it() //a proc to check if you CAN attack
if(src.can_attack)
for(var/mob/M in oview(1)) //for any mobs in a 1 tile range
src.can_attack=0
sleep(src.agl) //sleeps on the amount of your agl
attack(M) //attacks whatever mob was in view
src.can_attack=1
else
usr<<"\red You cant attack now!"
deathcheck(mob/K,mob/DM) //mob/K is the killer, mob/DM is the killed one...
if(src.hp<=0) //less then 0 HP?
if(client) //you a client?
view(src)<<"\red <center>[usr] died from the [DM]." //supposed to read like (if i'm getting killed):\
King of Slimes got killed by the [DM].

src.loc = locate(respawnpoint) //it spawns you back to your respawnpoint
src.hp=usr.mhp //restores hp
src.death++ //you now have 1 more death to the count
else //if it isnt a client
view(src)<<"\red <b><center>[DM] was killed by [usr]" //nice lil' message
give_rewards(K) //gives rewards to the killer.
del DM //deletes the killed thing
give_rewards(mob/K,mob/DM) //K = killer, DM = killed
K.exp+=DM.expg //your exp is boosted by the DM's expg
K.gold+=DM.goldg //same as above, but for gold

client
Center() //press center ;D
mob.attack_it() //you attack it :P

mob/var
can_attack=1
In response to King of Slimes
No, because you didn't make the changes I told you to make.

Also, your deathcheck() proc is out of whack. src should be the one dying, and the only argument should be the one killing src.
In response to Garthor
Garthor wrote:
No, because you didn't make the changes I told you to make.

Also, your deathcheck() proc is out of whack. src should be the one dying, and the only argument should be the one killing src.

The whole "nextattack < world.time" thing is odd.

Your making it do stuff if world.time is... greater then nextattack? Whats THAT about? O_o
In response to King of Slimes
It's about not allowing an attack before you are allowed to make your next attack.
In response to Garthor
Garthor wrote:
It's about not allowing an attack before you are allowed to make your next attack.

If every class has the same attack speed, some awkward crap could be happening.

Fighter is supposed to be the frail, but speedy attacker.
If he attacks slowly, his work is futile.
In response to King of Slimes
What an excellent point that has nothing to do with what you just quoted.
In response to Garthor
And I have a question...

sleep(src.agl) sleeps for the amount of your agl.

What would happen if your agl goes NEGATIVE? O_o
In response to King of Slimes
In response to Garthor
Garthor wrote:
http://www.byond.com/docs/ref/info.html#/proc/sleep
So it doesnt get faster then no sleep? O-o
In response to King of Slimes
Can't you read the reference? Sleeping for a negative amount of time executes code IN THE PAST. Just be careful not to cause a paradox, or you'll destroy the universe.
In response to Garthor
So...
mob/verb
yay()
name="Yay!!!"
src.happiness / 0 //DIVISION BY ZERO. UNIVERSAL MELTDOWN.


.>
In response to King of Slimes
King of Slimes wrote:
So...
> mob/verb
> yay()
> name="Yay!!!"
> src.happiness / 0 //DIVISION BY ZERO. UNIVERSAL MELTDOWN.


Nope, it won't affect the universe. It should produce a "statement has no effect" warning.
In response to Jtgibson
Jtgibson wrote:
King of Slimes wrote:
So...
> > mob/verb
> > yay()
> > name="Yay!!!"
> > src.happiness / 0 //DIVISION BY ZERO. UNIVERSAL MELTDOWN.

Nope, it won't affect the universe. It should produce a "statement has no effect" warning.

Which is totally wrong, because the effect is to crash the proc.