ID:147285
 
How can i get this code to send EXP to the usr that throws the Shuriken??

obj/Items
Shuriken
icon = 'OBJ.dmi'
icon_state = "Shuriken"
DblClick()
usr.ThrowShuriken()
obj/Weapon
Shuriken
icon = 'GFX.dmi'
icon_state = "Shuriken"
density = 1 //this have to be set to 1 so the bullet can hit people
Bump(mob/M)
if(istype(M,/mob/)) // Make sure what is hit is a mob
M.Chakra -= ATK //Minus one point of health if hit.
if(M.Chakra<=0)//Check if the player's health is eual to or less than 0
M.loc=locate(50,2,1)// Move the mob to the starting position
del(src)// this will delete the bullet when it hits something

mob/proc
ThrowShuriken()
var/obj/Weapon/Shuriken/O = new /obj/Weapon/Shuriken(usr.loc)
O.Owner = usr
O.ATK = usr.AGI
walk(O,usr.dir)//need to add speed
sleep(15)
del(O)
obj/Items
Shuriken
icon = 'OBJ.dmi'
icon_state = "Shuriken"
var
mob
caster = null
DblClick()
usr.ThrowShuriken(usr) //the usr is allowed here
obj/Weapon
Shuriken
icon = 'GFX.dmi'
icon_state = "Shuriken"
density = 1 //this have to be set to 1 so the bullet can hit people
Bump(mob/M)
if(istype(M,/mob/)) // Make sure what is hit is a mob
M.Chakra -= ATK //Minus one point of health if hit.
if(M.Chakra<=0)//Check if the player's health is eual to or less than 0
M.loc=locate(50,2,1)// Move the mob to the starting position
del(src)// this will delete the bullet when it hits something
caster.getexp(caster)

mob
proc
getexp(var/mob/player)
player.exp++ // add 1 to the exp

mob/proc
ThrowShuriken(var/mob/player)

var/obj/Weapon/Shuriken/O = new /obj/Weapon/Shuriken(usr.loc)
O.caster = player
O.Owner = player
O.ATK = player.AGI
walk(O,usr.dir)//need to add speed
sleep(15)
del(O)

rename caster.'getexp'(caster) to your exp proc
and add 'var/mob/player' in the exp proc
demo
yourexpproc() // how u got it
yourexpproc(var/mob/player)

notes
in the EXP proc the player you want to gain exp is called 'player' not 'src'.
In response to Madpeter
Once again:

  • No put usr in proc. Ungh.
  • It's <dm>, not [dm].

    Lummox JR
In response to Lummox JR
Thanks for the help i'm very thankfull.