ID:141370
 
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"
return
else
var/damage1 = round(src.AttackD*src.Level)
var/damage2 = round(src.Attack*2 + damage1)
var/damage3 = round(damage2 - M.Defense)


Problem description:
I get an error src.AttackD, src.Level, src.Attack are all undefined.. But they are defined on that very script.

Why wont src work here (usr. doesnt work it will be 0.AttackD and have thousands of errors)
src and usr aren't your only options. They're both wrong here. usr is, as you correctly noted, not going to be what you want. src is the thing that owns the procedure in question - in this case, the /obj/Thundershock, which, unless I'm very much mistaken, doesn't have an AttackD, Attack, or Level variable.

You want the mob that fired the thundershock object - you need to store a reference to it.

obj
Thundershock
var/mob/attacker

New(a, mob/m)
.=..(a)
attacker = m

Bump(A)
if(ismob(A))
var/mob/M = A
if(M.Faint)
attacker << "The [m.name] is fainted"
else
var/damage1 = attacker.AttackD*attacker.Level
damage1 = attacker.Attack*2 + damage1
damage1 = round(damage1 - M.Defense)


Then you just need to pass a reference to the mob firing the thundershock object when you create the object, like so:

mob
verb
Make_Thundershock()
var/obj/Thundershock/t = new /obj/Thundershock(loc, src)


I'll finish off by noting that the New() procedure for your thundershock object should probably take a direction argument, too, and then make the object move in that direction.