ID:265040
 
Code:
world
name = "New World"
turf = /turf/grass

mob
var
maxhealth
health
maxmagic
magic
strength
defence

mob
Login()
usr.icon = 'misc.dmi'
usr.icon_state = "player"
..()

turf
grass
icon = 'misc.dmi'
icon_state = "grass"

mob
player
icon = 'misc.dmi'
icon_state = "player"
maxhealth = 20
health = 20
maxmagic = 15
magic = 15
strength = 10
defence = 8

mob
baddie
icon = 'misc.dmi'
icon_state = "baddie"
maxhealth = 18
health = 18
maxmagic = 15
magic = 15
strength = 9
defence = 7

mob
verb
punch(mob/M as mob in oview(1))
var
damage = usr.strength - M.defence
if(damage <= 0)
usr << "[M] isn't affected by your attack"
else
M.health -= damage
usr << "Your hit [M] for [damage] health!"


Problem description:
This is a little project of mine, the above is all the code I've made in one little 'misc' code file.
My problem is when I 'punch' the 'baddie' it tells me im not hitting him.

Fire Away!
Nowhere in your code are you setting clients as mob/player, so they're not starting with the stats you set for the player. You're not hitting him because your strength is null.
In response to Unwanted4Murder
Awk, I get you.
How would i set the client as the mob 'player'?
In response to Star Knuckles
client
New()
mob = new/mob/Player
..()


Something like that should work.
In response to Unwanted4Murder
Unwanted4Murder wrote:
client
> New()
> mob = new/mob/Player
> ..()

Something like that should work.

The more typical method is to define world/mob, which holds the path to the default mob for new clients.

world/mob = /mob/Player
In response to DarkProtest
DarkProtest wrote:
Unwanted4Murder wrote:
client
> > New()
> > mob = new/mob/Player
> > ..()

Something like that should work.

The more typical method is to define world/mob, which holds the path to the default mob for new clients.

world/mob = /mob/Player


Didn't know that. I had assumed world/mob would define all mobs, not just clients. Thanks for the heads up.
In response to Unwanted4Murder
Cool beans guys
Thank you
In response to Star Knuckles
world
name = "New World"
turf = /turf/grass
mob = /mob/player

tried that and still isnt dealing damage
In response to Star Knuckles
Star Knuckles wrote:
world
name = "New World"
turf = /turf/grass
mob = /mob/player

tried that and still isnt dealing damage

This code is working fine for me:
world
name = "New World"
turf = /turf/grass
mob = /mob/player

mob
var
maxhealth
health
maxmagic
magic
strength
defence

turf
grass
icon = 'misc.dmi'
icon_state = "grass"

mob
player
icon = 'misc.dmi'
icon_state = "player"
maxhealth = 20
health = 20
maxmagic = 15
magic = 15
strength = 10
defence = 8

Login()
world<<"[src.name] enters"
..()

mob
baddie
icon = 'misc.dmi'
icon_state = "baddie"
maxhealth = 18
health = 18
maxmagic = 15
magic = 15
strength = 9
defence = 7

mob
verb
punch(mob/M as mob in oview(1))
var
damage = usr.strength - M.defence
if(damage <= 0)
usr << "[M] isn't affected by your attack"
else
M.health -= damage
usr << "Your hit [M] for [damage] health!"


(I moved Login() to under the /mob/player type, but it worked without that change, too)

Make sure you're attacking a /mob/baddie and not another /mob/player.