ID:166592
 
Okay here's the deal. Mobs in my game can shoot ki blasts. The verb creates the ki blast as an object and tells it to walk forward. Simple Enough? Well in the code for the ki blast object, I made a variable called shooter. When the Ki blast is made the shooter is saved to that variable so if it kills the person it can announce to the world that the creator has killed whoever it hit. Now that works fine but i'm also trying to give the person who shot the blast experience points via the shooter variable like this:

obj/Ki_Blast
var/mob/shooter as mob
var/damage
icon= 'Ki Blast.dmi'
density= 1
//blah blah blah so more code

if(M.Death_Check())
world<< "[BATTLEINFOFONT][M] has been killed by [shooter]![FONTCLOSURE]"
shooter.exp+= M.expgiven


But sadly the experience is not given to the shooter. What should I do to fix this?
change
var/mob/shooter as mob

to
var/mob/shooter = null

then check to see if all mobs have access to the exp var
and then add a message telling them they got the exp

oh yer add some checks in to make sure that shooter is not null and make sure your setting shooter when you fire it <+<
In response to Zmadpeter
That didn't work too well. Same thing :(
I believe you'll prefer to do your Death Check like some and just pass the attacker as an argument and do all experience gain/loss. Show us where you create the blast.
In response to Audeuro
mob/verb
Ki_Blast()
set category = "Techniques"
var/kicost= 5
stamcost= 5
if(src.Tired_Check())
src<< "[RESTRICTIVEFONT]You are too tired to do that. Maybe you should get some rest.[FONTCLOSURE]"
return

Busy()
if(!busy)

if(src.ki<= kicost)
src << "[RESTRICTIVEFONT]You can't seem to gather enough energy.[FONTCLOSURE]"

if(src.ki >= kicost)
busy= 1
sleep(4)
src.ki-= kicost
src.stamina-= stamcost
view(src)<< sound('Ki Blast.wav')
var/obj/Ki_Blast/O = new /obj/Ki_Blast(src.loc)
O.shooter= src
O.damage= src.pl/5
walk(O,src.dir)
busy= 0