ID:162472
 
I need to make this projectile move to the location i click how would i do that??

obj
Bullet
C45B
icon='Gun.dmi'
icon_state = "C45B"
density = 1
Bump(mob/M)
if(istype(M,/mob))//if it is a mob
var/damage
damage = (M.Health - usr.Armor + rand(2,-2))
if(damage >= 1)
M.Health -= damage
M.Death()
del(src)
else
del(src)
else if(istype(M,/obj))
del(src)
return
else if(istype(M,/turf))
del(src)
return

mob
proc
Death()
if(src.Health <= 0)
src.Health = src.MaxHealth
src.loc = locate(1,1,1)



<dm/>
Well I was reading a guide and it had some code with Click()
I'm just saying that it might be useful.

*note*This is just a random noob at coding and forums so I have no idea on what would make it easier to understand.
In response to Loser Mongoose
For a "noob" you are actually right. You would use the Click() proc in conjunction with step_towards() or step_to() to make it go to the place you clicked(look the procs up in the reference.)
In response to Kakashi24142
i would use walk_towards()
In response to Nidaime Hokage
Oh yea, my bad. The walk() procedures would be better for this.
Give this a shot:

obj
Bullet
C45B
icon='Gun.dmi'
icon_state = "C45B"
density = 1
Bump(mob/M)
if(istype(M,/mob))//if it is a mob
var/damage
damage = (M.Health - usr.Armor + rand(2,-2))
if(damage >= 1)
M.Health -= damage
M.Death()
del(src)
else
del(src)
else if(istype(M,/obj))
del(src)
return
else if(istype(M,/turf))
del(src)
return
mob
Click(var/loc)
var/obj/Bullet/C45B/B = new/obj/Bullet/C45B(src.loc)
B.walk_towards(loc)
In response to Mendon
Awh, thats almost correct.
b.walk_towards(loc)

thats wrong, bad arguments. The correct way is
walk_towards(b,loc)


PS
you don't need Click(var/loc) you can leave it as just Click(loc).Also loc is already a var so i wouldn't recommend using it as an argument. newloc or something along those lines.

~Tubby~
Don't use usr in procs. You probably want to be using M.Armor anyway, not usr.Armor.