ID:145179
May 27 2006, 6:34 pm
|
|
mob proc shoot() var/obj/H = new/obj/bullet if(src.fired == 0) src.fired = 1 spawn(15) src.fired = 0 H.dir = src.dir H.loc = src.loc while(H) step(H,H.dir) var/turf/T = H.loc if(T.density == 1) del(H) break for(var/mob/M as mob in T) if(M == src) continue src<< "you shot the enemy" M.health -= 2 del(H) sleep(1) mob The current code works in shotting the bullet but once fired it doesn't move. It just stays in one spot and doesn't get cut. Can you please help me fix the problem? Thanks |
May 27 2006, 8:45 pm
|
|
Instead of using if(src.fired==0), make it if(!src.fired). You can also turn if(src.fired==1) into if(src.fired) if you wanted. Also, you might want to undent sleep(1) one tab.
|
In response to Aaiko
|
|
Aaiko wrote:
Instead of using if(src.fired==0), make it if(!src.fired). You can also turn if(src.fired==1) into if(src.fired) if you wanted. Also, you might want to undent sleep(1) one tab. Thanks for the help! I changed what you said and I've been looking at demos to try to help me. Still cant figure out the problem. It dont want to move once i fire it. Im mostly new to this so I really appreciate the help |
In response to Ryng35
|
|
You're not getting past if(src.fired==0) because fired is equal to something other than 0. If you put if(!src.fired) and it still did not work, then you have fired set to something other than 0 or nothing at all. Find where you declared fired, mob/var/fired or something like that, and make sure it is either equal to 0 or nothing at all. If it is equal to 0 or nothing, then somewhere else in your code you have fired being set to something, which is causing your problem.
|
In response to Aaiko
|
|
I set src.fired to nothing. I also went and checked at the mob/var/fired and it is equal to zero. I was thinking that maybe it's not working cuz I set up constant moving on the game to. Will that interfeer?
|
In response to Ryng35
|
|
mob
proc shoot() var/obj/H = new/obj/bullet if(!src.fired) src.fired = 0 spawn(15) src.fired = 0 H.dir = src.dir H.loc = src.loc while(H) step(H,H.dir) var/turf/T = H.loc if(T.density == 1) del(H) break for(var/mob/M as mob in T) if(M == src) continue src<< "you shot the enemy" M.health -= 2 del(H) sleep(1) I still am not able to get the bullet to move forward. I appreciate all the help I can get. Thanks |
In response to Ryng35
|
|
Could you all please use the <dm>CODE HERE<dm/> tags please. the code looks ugly otherwise.
|
In response to A.T.H.K
|
|
if(!src.fired) this isnt your problem but right here your saying if src.fired = 0 make scr.fired = 0 then wait 1.5 seconds then make src.fired = 0. + your problem could be your using src.fired try usr.fired |
In response to Flame500
|
|
No usr in proc....
|
Well, I will go the easy way and post a handgun example from my game.
obj/items And here is the projectile itself, which can be used and edited universally. obj/attack/blast |