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'
ID:144599
![]() Oct 18 2006, 10:38 am
|
|
![]() Oct 18 2006, 10:42 am
|
|
What's the problem?
|
obj/gun needed to see it in code form <.< hold on! |
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 <.<
|
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 |
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. |
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?).
|
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. |
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... |