ID:176758
 
how do i make it so the bullet disapears after it hits something? my code is:

mob/verb/Fireball()
var/obj/fireball/fireball = new /obj/fireball(src.loc)
walk(fireball,src.dir)


obj/fireball
icon = 'spells.dmi'
icon_state = "fireball"
density = 1

Bump(atom/O)
if(ismob(O))
usr << "[O] is hit by a firball!"
Bump(atom/O)
if(ismob(O))
usr << "[O] is hit by a firball!"
del(src)
In response to Nick231
thanks
Koolguy900095 wrote:
how do i make it so the bullet disapears after it hits something? my code is:

mob/verb/Fireball()
var/obj/fireball/fireball = new /obj/fireball(src.loc)
walk(fireball,src.dir)

obj/fireball
icon = 'spells.dmi'
icon_state = "fireball"
density = 1

Bump(atom/O)
if(ismob(O))
usr << "[O] is hit by a firball!"

Problem: usr has no place in Bump(). If you want to know who fired the fireball, then add a var to your obj/fireball so it knows who fired it:
obj/fireball
... // your icon and density code here
var/atom/firedby

New(newloc,atom/A)
..()
firedby=A
walk(src,A.dir) // helps to move the walk() here
// optional line for limited range:
// spawn(amount_of_time) del(src)

Bump(atom/O)
if(ismob(O))
firedby << "You hit [O] with a fireball!"
O << "[firedby] hits you with a fireball!"
oview(src)-O-firedby << "[firedby] hits [O] with a fireball!"
O.TakeDamage(firedby,src,5) // damage something like a wall or dense obj or mob
// delete whether a mob was hit or not
del(src)

atom
proc/TakeDamage(atom/attacker,atom/weapon,damage)
// do nothing; some atoms will use this proc, some won't
// mobs can use this to reduce hit points and do a death check

mob
verb/Fireball()
new /obj/fireball(loc,src) // tell the fireball who fired it