turf
Battle_Grass
icon = 'Landscapes.dmi'
icon_state="Invis"
Enter()
usr.pkmnbattle()
mob/proc
pkmnbattle(M/mob in oview(2))
usr.random=rand(1,2)
if(usr.random==1)
return
if(usr.random==2)
usr << "<b><font color=purple>Encounter!"
usr.Frozen = 1
if(usr.pokemon=="Chikorita")
usr.random=rand(1,2)
usr.dir = WEST
if(usr.random==1)
usr.loc=locate(7,98,2)
switch(input("Select an Option.")in list("Attack","Run"))
if("Attack")
switch(input("Select an Attack.")in list("Tackle","Leer"))
if("Tackle")
usr << "<font color=white>[pokemon]<font color=purple> used Tackle on the Enemy!"
M.Health -= usr.Strength*3/5
Problem description:
My error is:
155:error:M.Health:undefined var
However; at the top of the complete code I have:
mob/var
tmp/Frozen = 0
tmp/Motion = 0
tmp/Delay = 1
inbattle = 0
tmp/Bnum = 0
Health = 20
Strength = 7
exp = 0
maxexp = 25
Defense = 3
MaxHealth = 20
Level = 5
random = 0
pokemon = ""
As you can see; I clearly made a variable of 'Health' and 'MaxHealth'...
Help? Please? So I could get on with my life!? [ I SERIOUSLY have been working on this for 3 freaking hours finding a combonation that worked within the code... it has something to do with: M/mob in oview(2), right? ]
With that said, if that is really the result of 3 hours of work, I think you should go back to the drawing board and read through the DM Guide and some tutorials.
The most obvious mistake in the proc is your usage of usr. This is a common mistake that many new developers encounter. Understanding and avoiding it is one of the first major hurdles in becoming a decent BYOND developer. Read LummoxJR's BYONDscape article "usr Unfriendly" for more info. To sum it up, don't use usr in procs unless they are a direct result of client interaction (Click, directional stuff, etc).
Next, there are three problems with your proc's argument definition.
1: it's mob/M, not M/mob. The type goes first (mob) followed by the variable name (M)
2: in oview(2) is something you'd add to a verb's argument definition, procs work differently.
3: You're not actually passing arguments to the proc.
It'd take quite a bit of writing to explain these all in detail, and it's kind of late for me. I'd suggest reading Chapter 5 of the DM guide and going through some basic tutorials to get a better understanding of procs.