ID:2070265
 
(See the best response by Kozuma3.)
//What I'm trying to do is get a OBJ sent from the USR
//to bump into a MOB then compare stats to calculate damage.

//Example:
Code:
obj/Projectile
icon = 'Projectile.dmi'
icon_state = "Projectile"
density = 0
New(var/mob/M)
src.loc=M.loc
walk(src,M.dir,0)
spawn(20) del(src)
Crossed(var/mob/M)
var/damage = rand(1,10)+USR.PjtDam-M.PjtDam


//Here is how I would spawn the projectile.

//Example:
Code:
mob/verb
Shoot_Projectile()
new/obj/Projectile(usr)


//Problem: In the damage calculation, It can't find USR to read thier stats.
//How do I get the OBJ to read the USR's stats?
kek
That's very helpful, Thanks.
Something like this?

obj/projectile
icon = 'Projectile.dmi'
icon_state = "Projectile"
density = TRUE
New(LOC,mob/TARGET)
src.loc = LOC
while(TARGET && step_towards(src,TARGET))
sleep(world.tick_lag)
loc = null
Bump(O)
if(istype(O,/mob))
//.. stuff here
..()
I added it in but its saying undefined type: TARGET
In response to Cjs378
Cjs378 wrote:
I added it in but its saying undefined type: TARGET

That can be fixed by changing the second parameter in New() from target/TARGET to mob/TARGET

You'll need to modify it to fit your use.
I appreciate your help.

That part is working now, but there is a new problem.

TARGET is an undefined var when used in the Bump proc
The O parameter in Bump() will be the object that was bumped.
Sorry for not being clear.

I'm not having issues with change O's vars

I'm having issues changing the vars of the usr attacking O in Bump

O.HP -= usr.ATT+O.ATT, usr is an undefined var
The first parameter for New() in the code I posted should be a location/turf so you'd call it like

new/obj/projectile(src.loc,THE_TARGET)


src being the mob or object that call the proc/verb containing that piece of code and .loc accessing the src's loc variable. THE_TARGET being the object or w/e you're moving towards.
In response to Cjs378
O.HP -= usr.ATT+O.ATT, usr is an undefined var

What is usr.ATT expose to be? If it's the owner of the projectile you'll need a third argument in New() for the projectile to keep a reference of its user.
Yeah, That's what i'm trying to do. I just can't figure out how to keep a reference of user
Best response
obj/projectile
icon = 'Projectile.dmi'
icon_state = "Projectile"
density = TRUE

var/tmp/mob/owner

New(mob/OWNER,mob/TARGET)
src.owner = OWNER
src.loc = OWNER.loc
while(TARGET && src.owner && step_towards(src,TARGET))
sleep(world.tick_lag)

Bump(mob/O)
if(istype(O,/mob))
O.HP -= src.owner.ATT + O.ATT
loc = null
..()

mob/verb/Test()
new/obj/projectile(src,THE_TARGET)
that doesn't set OWNER too the creator of the projectile, sorry.

EDIT: I think I about got it, Problem Solved.