ID:143803
 
Code:
mob
verb/Punch(mob/M in oview(1))
set category = "Combat"
var/damage = src.Strength - M.Defense
if(M.client)
M.Health -= damage
src <<"You attack [M] for [damage]!"
M <<"You are being attacked by [src]!"
src.Level_UP()
M.death_check(src)
else
M.Health -= damage
src <<"You attack [M] for [damage]!"
M <<"You are being attacked by [src]!"
var/random = rand(1,3)
if(random == 1)
src.Exp += 14
if(random == 2)
src.Exp += 3
if(random == 3)
src.Exp ++
src.Level_UP()
M.death_check(src)


Problem description:


if a person has more def than the attacker it adds health how do i stop this ???
mob
verb/Punch(mob/M in oview(1))
set category = "Combat"
var/damage = src.Strength - M.Defense
if(M.client)
if(damage>0)
M.Health -= damage
else
damage = 0
src <<"You attack [M] for [damage]!"
M <<"You are being attacked by [src]!"
src.Level_UP()
M.death_check(src)
else
M.Health -= damage
src <<"You attack [M] for [damage]!"
M <<"You are being attacked by [src]!"
var/random = rand(1,3)
if(random == 1)
src.Exp += 14
if(random == 2)
src.Exp += 3
if(random == 3)
src.Exp ++
src.Level_UP()
M.death_check(src)
You might want to double check on the mob after the initial argument. If there are multiple targets in oview(1) the attacker can actually click the verb a few times and wait until later to confirm the target and start the attack. It'll look redundant, but it's safer. You can also shorten this considerably by only branching off when necessary.
mob
verb/Punch(mob/M in oview(1))
set category = "Combat"
if(M in oview(1))
var/damage = max(src.Strength - M.Defense, 0) // max() returns the highest number.
M.Health -= damage
src <<"You attack [M] for [damage]!"
M <<"You are being attacked by [src]!"
if(!M.client)
src.Exp+=pick(14,3,1)
src.Level_UP()
M.death_check(src)
Gebsbo wrote:
Code:
> mob
> verb/Punch(mob/M in oview(1))
> set category = "Combat"
> var/damage = src.Strength - M.Defense
> if(M.client)
> M.Health -= damage
> src <<"You attack [M] for [damage]!"
> M <<"You are being attacked by [src]!"
> src.Level_UP()
> M.death_check(src)
> else
> M.Health -= damage
> src <<"You attack [M] for [damage]!"
> M <<"You are being attacked by [src]!"
> var/random = rand(1,3)
> if(random == 1)
> src.Exp += 14
> if(random == 2)
> src.Exp += 3
> if(random == 3)
> src.Exp ++
> src.Level_UP()
> M.death_check(src)
>
>
>

Problem description:


if a person has more def than the attacker it adds health how do i stop this ???

Dont do Strength - Defense. Do Strength / Defense. And make HP never go past 100. That way if you and your opponent have equal Strength and Defense, you will do 1% damage each hit. And if your opponent has 2x as much defense than your strength, they take half damage.