ID:145361
 
Code:
client/Center()
mob.shoot()
mob/verb/Shoot()
shoot()
mob
proc
shoot()
var/obj/H = new/obj/bullet
var/obj/I = new/obj/bullet
var/obj/J = new/obj/bullet
if(src.fired == 0 && clip > 0 && can_shoot == 1)
src.fired = 1
clip -= 1
spawn(1)
src.fired = 0
H.dir = src.dir
H.loc = src.loc
I.dir = src.dir
I.loc = src.loc
J.dir = src.dir
J.loc = src.loc
while(H)
step(H,H.dir)
var/turf/T = H.loc
if(T.density == 1)
del(H)
sleep(1)
while(I)
step(I,I.dir)
var/turf/T = I.loc
if(T.density == 1)
del(I)
sleep(1)
while(J)
step(J,J.dir)
var/turf/T = J.loc
if(T.density == 1)
del(J)
break
for(var/mob/M as mob in T)
if(M == src)
M.HP -= range_damage
usr << "You did [range_damage] damage!"

M.DeathCheck()
del(H)
sleep(1)



Problem description:
Ok i took my shoot and tried to adapt it to shoot 3 bullets everytime the user hits shoot. Obviously it doesn't work, i'm probably taking the wrong approach to this but i couldn't think of any other way. So can someone help me with this?

Also its not doing damage when the bullet hits an enemy. I think i should use Bump() for this but i'm not really sure how to implement that.

Note: Everything compiles and the game runs, but when i shoot it only shoots one bullet instead of three.
It actually shoots 3, yet they shoot at the same time so it looks like 1.
In response to DivineO'peanut
So then how would i make a delay between each shot, would i use sleep?
In response to Dan13
spawn(10) spawn(10) var/obj/J = new/obj/bullet
In response to DivineO'peanut
var/obj/H = new/obj/bulletspawn(10) 
spawn(10) var/obj/I = new/obj/bullet
spawn(10) var/obj/J = new/obj/bullet


when i do this it says all the variables are undefined. Am i using this incorrectly?
In response to Dan13
Sorry, I did a mistake last post and you looked before I edited, hold on, I'll post the code here

[edit] actually, I think my code should work... baah. I'm confused today. Try it anyway.
In response to DivineO'peanut
i tried that and it still says all the variables are undefined.
In response to Dan13
wait, verbs are undefined? you said they just appear as 1...

[edit] oh, var/obj/H = new/obj/bulletspawn(10) delete the spawn(10) here.
In response to DivineO'peanut
when i added the spawn(10) it and compiled it said all the variables were undefined.
In response to Dan13
Dan13 wrote:
> var/obj/H = new/obj/bulletspawn(10) 
> spawn(10) var/obj/I = new/obj/bullet
> spawn(10) var/obj/J = new/obj/bullet
>

when i do this it says all the variables are undefined. Am i using this incorrectly?

Try this:
var/obj/H=new/obj/bullet
var/obj/I
var/obj/J
spawn(10)I=new/obj/bullet
spawn(10)J=new/obj/bullet
In response to Hell Ramen
Hell Ramen wrote:
Dan13 wrote:
> > var/obj/H = new/obj/bulletspawn(10) 
> > spawn(10) var/obj/I = new/obj/bullet
> > spawn(10) var/obj/J = new/obj/bullet
> >

when i do this it says all the variables are undefined. Am i using this incorrectly?

Try this:
> var/obj/H=new/obj/bullet
> var/obj/I
> var/obj/J
> spawn(10)I=new/obj/bullet
> spawn(10)J=new/obj/bullet
>


</spawn>? 0o
In response to DivineO'peanut
ok so now its giving me some incosistent indentation errors. I'll get those sorted out and i'll be back if it still doesn't work.
In response to DivineO'peanut
Eh?

I have no idea what you're talking about!
In response to Dan13
Don't just copy the code; learn from it!
In response to Dan13
Neigh, I'll fix it myself X-x

Next time, don't copy rifthaven's code and say it's yours.. actually, don't copy it at all!

client/Center()
mob.shoot()
mob/verb/Shoot()
shoot()
mob
proc
shoot()
spawn(10) var/obj/H = new/obj/bullet
spawn(20) var/obj/I = new/obj/bullet
var/obj/J = new/obj/bullet

there, that should work.
In response to DivineO'peanut
I used it to learn from, sorry i said it was mine. I'm not actually gonna use it in a game. Thanks for the help guys.
In response to DivineO'peanut
Too bad it won't, I didn't even compile it and I know that. :|
In response to Hell Ramen
the code itself is messy, the part with the spawn is what i fixed.