Hi
i have got a shoot command but am a little stuck with Ammo
i made it a var and a stat...
but i cant get it to stop going down when you fire because when you fire it got down to 9 fire again then 8 and so on
but when it gets to 0 you can still fire and it goes in the -'s
thanks
ID:267662
![]() Aug 11 2003, 10:06 am
|
|
i got it all to work with no errors
but you can keep shooting when you have 0 ammo it just got to -1 and -2 to so on |
mob/verb/shoot()
usr.projectile(new/obj/bullet(usr.loc),usr.dir,5) usr.Ammo -= 1 if(usr.Ammo >= 0) else usr<<"You are out of ammo!" //the above obj bullet icon='mob.dmi' icon_state = "fire" density=1 Bump(mob/M) if(istype(M,/mob)) del(M) del(src) mob proc projectile(obj/projectile,var/dir,var/delay) walk(projectile,dir) sleep(delay) del(projectile) i posted it all just incase :-p |
mob/verb/shoot() |
I SAID put the if before the shooting stuff, what the heck do you think I meant?
if(usr.ammo >=1) usr.projectile(new/obj/bullet(usr.loc),usr.dir,5) usr.Ammo -= 1 else usr<<"You are out of ammo!" |
sorry jot...i was a little confused
i got more problems :'( i changed it to a obj verb not a mob verb and now you can shoot to -1 again |
Heres a few tips, if you wana check if something is >=1 like if(usr.Ammo>=1) you can just do if(usr.Ammo)
And if you wana add or substract 1, you can just do ++ or -- Heres the code with does changes mob/verb/shoot() if(usr.Ammo) usr.projectile(new/obj/bullet(usr.loc),usr.dir,5) usr.Ammo-- else usr<<"You are out of ammo!" I made a mistake... if(usr.Ammo) will be true if usr.Ammo not zero so I guess you better use usr.Ammo<=1 |
mob/verb/shoot()
if(usr.ammo >= 1)
//do shooting stuff
else
usr<<"You are out of ammo!"