ID:144599
 
obj/gun
obj/bullet
Bump(mob/M)
if(ismob(M)) // If what it bumps into is a mob, then subtract some health.
M.health-=10
del(src) // Delete the bullet, when it's hit anything.
obj/gun
verb
Shoot()
var/obj/bullet/B = new(usr.loc) // Create a new bullet object at the users location, and associate it with the variable 'B'
walk(B,usr.dir,2) // Make the object constantly move in the direction of the user, with a lag of 2.
obj
gun
icon='gun.dmi'
bullet
icon='bullet.dmi'
What's the problem?
In response to Jon88
i can shoot the gun but it does not damage the opponent.
In response to Inuashadragon
obj/gun
obj/bullet
Bump(mob/M)
if(ismob(M)) // If what it bumps into is a mob, then subtract some health.
M.health-=10
del(src) // Delete the bullet, when it's hit anything.
obj/gun
verb
Shoot()
var/obj/bullet/B = new(usr.loc) // Create a new bullet object at the users location, and associate it with the variable 'B'
walk(B,usr.dir,2) // Make the object constantly move in the direction of the user, with a lag of 2.
obj
gun
icon='gun.dmi'
bullet
icon='bullet.dmi'


needed to see it in code form <.< hold on!
In response to Falacy
ok, my guess is that you have object and gun both defined like 3 times, so its most likely taking the bullet closest to the bottom which doesnt have the bump in it <.<
In response to Falacy
obj/bullet
icon='bullet.dmi'
density=1
Bump(mob/M)
if(ismob(M))
M.HP-=15
del(src)


obj/gun
icon='gun.dmi'
verb
Shoot()
var/obj/bullet/B = new(usr.loc)
walk(B,usr.dir,0)

i tried this set up but when it hits the mob it does not damage it
In response to Inuashadragon
Try adding in some debug code, something as simple as

world << "bumped a mob!"


...just after the damaging part, to see if it's even getting to that part of the code or not.
In response to The Conjuror
now it says that it bumbed the mob
In response to Inuashadragon
So if its getting to that code, and its not giving you an error for M.health not being defined, then you must be resetting or cancelling out the health change somewhere else in your code. Look in any other sections of code that you're changing a mob's health variable, and check to see that it wont conflict with the damaging part (possibly resetting the health everytime its lowered, in a deathcheck proc maybe?).
In response to The Conjuror
if you ment like this:
obj/bullet
icon='bullet.dmi'
density=1
Bump(mob/M)
if(ismob(M))
M.HP-=15
world << "bumped a mob!"
del(src)
mob
proc
DeathCheck() if (HP <= 0)
world << "[src] dies!"
del(src)



obj/gun
icon='gun.dmi'
verb
Shoot()
var/obj/bullet/B = new(usr.loc)
walk(B,usr.dir,0)

then that did not work either.
In response to Inuashadragon
I didnt suggest changing any code, I was just saying that there must be code elsewhere in your program that's affecting M's hp. You said that M's hp isn't changing.

Also, make sure you're using the same variable for health. In your first example you used M.health, now you're using M.hp...
In response to The Conjuror
still do not understand.
sorry newbie