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.
ID:146140
![]() Aug 25 2005, 3:19 pm
|
|
![]() Aug 25 2005, 3:36 pm
|
|
Ok, but please when you are posting code please use the < .dm> <./dm> tags, of course without the periods.
|
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 |
Just a suggestion, stop using the : operator. I'm getting very angery with people using the : operator. Just switch to the . operator.
|
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 |
turf Hope that helped. -Sin() |
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. |
Sinoflife wrote:
proc 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 |