ID:146140
 
This is my code very basic i think so...


icon = 'person.dmi'
var
hp = 10
str = 5
def = 2
turf
grass
icon = 'person.dmi'
icon_state = "grass"

turf
water
icon = 'person.dmi'
icon_state = "water"
density = 1

world
name = "My First Game."
turf = /turf/grass
mob
Login()
usr.icon_state = input("What gender?") in list ("male","female")
usr.Move(locate(1,1,1))
mob
verb
Attack(mob/M as mob in oview(1))
var/damage = usr.str - M.def
if(damage <= 0)
usr << "[M] easily dodges your attack!"
M << "You easily dodge [usr]'s attack."
else
M.hp -= damage
view() << "[usr] attacks [M] for [damage] HP!"
M:deathcheck()
mob
proc
deathcheck()
if(src.hp <= 0)
view() << "[src] dies!"
src.hp = 10
src.Move(locate(1,1,1))
usr.str += 1
usr.def += 1

Now I didn't have any error before i put this little bit of a demo in it and now it has 9 errors and it keeps saying that the usr.str and etc is undefinded var. Please help im a first time devolper and dont know what to do.
Ok, but please when you are posting code please use the < .dm> <./dm> tags, of course without the periods.
turf
grass
icon = 'person.dmi'
icon_state = "grass"

turf
water
icon = 'person.dmi'
icon_state = "water"
density = 1

world
name = "My First Game."
turf = /turf/grass
mob
Login()
usr.icon_state = input("What gender?") in list("male","female") //usr abuse, please see for the link below
usr.Move(locate(1,1,1))// Same as above
mob
verb
Attack(mob/M as mob in oview(1)) // This will make it so you wouldn't have to face the person you are attacking. In your DM press F1 and search for get_step()
var/damage = usr.str - M.def
if(damage <= 0)
usr << "[M] easily dodges your attack!"
M << "You easily dodge [usr]'s attack."
else
M.hp -= damage
view() << "[usr] attacks [M] for [damage] HP!"
M:deathcheck()//Instead of the : operator I would use .
mob
proc
deathcheck()
if(src.hp <= 0)
view(src) << "[src] dies!"// View() defaults as usr
src.hp = 10
src.Move(locate(1,1,1))
usr.str += 1//Please do not use the usr in proc, see bottom of post for link
usr.def += 1//link below
And for you're problem try this.
mob     // It is for a mob
var // There will be variables defined for mobs.
str = 5
def = 5
Please read this, http://bwicki.byond.com/ByondBwicki.dmb?UsrLecture.
In response to Cheetoz
thanks for the help it fixed that problem but now i have problems with this bit

mob
proc
deathcheck()
if(src.hp <= 0)
view() << "[src] dies!"
src.hp = 10
src.Move(locate(1,1,1))
usr.str += 1
usr.def += 1
undefinded var on this parts right here

if(src.hp <= 0)

src.hp = 10

mob
verb
Attack(mob/M as mob in oview(1))
var/damage = usr.str - M.def
if(damage <= 0)
usr << "[M] easily dodges your attack!"
M << "You easily dodge [usr]'s attack."
else
M.hp -= damage
view() << "[usr] attacks [M] for [damage] HP!"
M:deathcheck()

and finally here

icon = 'person.dmi' undefined vars on mostly all

In response to Nick789
Just a suggestion, stop using the : operator. I'm getting very angery with people using the : operator. Just switch to the . operator.
In response to Nick789
dude read his post lol . To define a variable just do this.And next time you post put the code inside this(erase the *) <*DM>Code<*/DM>

mob
var
VariableGoesHere
turf
icon='person.dmi'
/* Declares all turf shall come from one icon file,
rather than having to add in an extra string for each turf branch. */

grass
icon_state = "grass"
water
icon_state = "water"
density = 1

world
name = "My First Game"
turf = /turf/grass
mob
Login()
icon='person.dmi' // No need for src. Defaults to src.
icon_state = input("What gender?") in list("male","female")
loc=locate(1,1,1) // People will start at the bottom left corner.
verb
Attack(mob/M as mob in get_step(usr,usr.dir)) // You can attack people in your direction.
var/damage = round(usr.str - M.def)
if(damage <= 0)
usr << "[M] easily dodges your attack!"
M << "You easily dodge [usr]'s attack."
else
M.hp -= damage
view() << "[usr] attacks [M] for [damage] HP!"
deathcheck(M)
proc
deathcheck()
if(src.hp <= 0)
view() << "[src] dies!"
src.hp=src.maxhp
/* Rather than set it to a set amount, try having it set to maxhp
or maxhp divided by, say, 5. If you did that, it would look like
"src.hp=round(src.maxhp/5)". */

src.loc=locate(1,1,1)
src.str++
src.def++ // ++ means +=1, with one less character.


Hope that helped.
-Sin()
In response to Sinoflife
thanks for the help sin it did help get rid of 1 more error but like i said turle i am completly new to coding and not exactly sure what to do. Now i have a couple more undefined vars but im not sure what to type them in like soo could some1 help me i have undefined vars in these lines.

src.hp=src.maxhp
theres 2 undefinded vars in that one

if(src.hp <= 0)

just 1 undefinded var in there

M.hp -= damage
and finally just 1 here.
In response to Nick789
Mmmm...Perhaps this will solve you problems...

mob/var{hp;maxhp}


..maybe
In response to Sinoflife
Sinoflife wrote:
    proc
> deathcheck()
> if(src.hp <= 0)
> view() << "[src] dies!"
> src.hp=src.maxhp
> /* Rather than set it to a set amount, try having it set to maxhp
> or maxhp divided by, say, 5. If you did that, it would look like
> "src.hp=round(src.maxhp/5)". */

> src.loc=locate(1,1,1)
> src.str++
> src.def++ // ++ means +=1, with one less character.


Wow, that was brilliantly and completely wrong. You just changed usr to src indiscriminately. You may as well have put garbage text in there instead.

Obviously usr has no place in deathcheck(), but that does not mean src is the correct replacement. Since src is the victim, obviously you don't want to give those str and def bonuses to src, but to the killer. The problem is, the proc doesn't know who the killer is, because it was never told.

The only correct way to write a deathcheck() proc--at least, one where knowing the killer is important--is to send the killer as an argument.

Lummox JR
In response to Lummox JR
Sorry, wrote that REALLY early in the morning(5AM) when I just woke up. :\
-Sin()