ID:141371
 
Code:
mob/Pokemon
verb
Attack()
set category="Pokemon Commands"
set name="Attack(Close)"
for(var/mob/M in get_step(usr,usr.dir))
if(M.Faint>=1)
usr<<"This Pokemon is fainted"
else
var/damage = round(usr.Attack*2 - M.Defense)
M.HP -= damage
view() << "[usr.name] did [damage] damage to [M]"
if(M.HP<=0)
M.HP=0
if(M.owner=="None")
del(M)
else
Faint(M)
mob/Pikachu
verb
Thunderschock()
set category="Pokemon Commands"
set name="Thundershock"
if(firing>=1)
return
else
var/obj/Thundershock/A = new/obj/Thundershock
firing=1
A.loc = usr.loc
if(usr.dir==NORTH)
A.y-=1
if(usr.dir==SOUTH)
A.y+=1
if(usr.dir==WEST)
A.x+=1
if(usr.dir==EAST)
A.x-=1
walk(A,usr.dir)
sleep(10)
firing=0
obj
Thundershock
icon='thundershock.dmi'
density=1
Bump(A)
if(ismob(A))
var/mob/M = A
if(M.Faint>=1)
usr<<"This Pokemon is fainted"
else
var/damage1 = round(usr.AttackD*usr.Level)
var/damage2 = round(usr.Attack*2 + damage1)
var/damage3 = round(damage2 - M.Defense)
M.HP -= damage3
view() << "[usr.name] did [damage3] damage to [M]"
if(M.HP<=0)
M.HP=0
if(M.owner=="None")
del(M)
else
Faint(M)
mob
proc
Faint(mob/M)
M<<"Your Pokemon fainted. Please return it now."
M.overlays+='pokeball.dmi'
M.Faint=1


Problem description:
It says Faint is an undefined proc. The weird thing is, it only says it for the Thundershock definition, not for Attack.. Why? What can I do to fix this?
Xyphon101 wrote:
Code:
> obj
> Thundershock
> icon='thundershock.dmi'
> density=1
> Bump(A)
> if(ismob(A))
> var/mob/M = A
> if(M.Faint>=1)
> usr<<"This Pokemon is fainted"
> else
> var/damage1 = round(usr.AttackD*usr.Level)
> var/damage2 = round(usr.Attack*2 + damage1)
> var/damage3 = round(damage2 - M.Defense)
> M.HP -= damage3
> view() << "[usr.name] did [damage3] damage to [M]"
> if(M.HP<=0)
> M.HP=0
> if(M.owner=="None")
> del(M)
> else
> Faint(M)
> mob
> proc
> Faint(mob/M)
> M<<"Your Pokemon fainted. Please return it now."
> M.overlays+='pokeball.dmi'
> M.Faint=1
>

Faint() is defined as /mob/proc/Faint(), meaning that when you call Faint(), you need to have a mob to the left of the proc call. i.e. M.Faint(). If you leave out the left side part, it either assumes the proc is global or belongs to src (src.Faint()). Since there is no global Faint() proc, and since Thundershock is an /obj (hence doesn't have a src.Faint()) proc, you get an undefined proc error.

You should also re-examine what your Faint() proc does (for example, who it outputs text to) and how it's structured. Probably a more reasonable declaration would be:
mob/proc/Faint(mob/owner) // use pokemon.Faint(pokemonOwner) to call