ID:144828
 
Code:
mob
verb
Shoot()
if(usr.fired == 0)
var/obj/Bullet/O = new /obj/Bullet(src.loc)
step(O,usr.dir)
usr.fired = 1
spawn(15)
usr.fired = 0
del(O)
else
return
proc
Fire()
if(usr.fired == 0)
var/obj/Bullet/O = new /obj/Bullet(src.loc)
step(O,usr.dir)
usr.fired = 1
spawn(15)
usr.fired = 0
del(O)
else
return


Problem description:

When I use the verb "Shoot" or activate the proc "Fire", the bullet appears, but it doesn't step at all. It stays on screen but doesn't move like it should. I also tried changing step(O,usr.dir) to walk(O,usr.dir) but the same problem occurs. The rest of the code isn't shown; it only includes the bump proc (like if the bullet hits an enemy or a wall) and the bullet/enemies description (icon/icon state), and defines variables (health, fired.) if anyone needs the rest of the code to help me out, post saying it and ill be more than happy to post it.
No put usr in proc. Ungh.

Lummox JR
Change src loc to usr loc.also this is mine it works
                                var/obj/revbullet/RB = new /obj/revbullet(usr.loc)
walk_towards(RB,targeted,1)
In response to Buzzertron
Buzzertron wrote:
Change src loc to usr loc.also this is mine it works

No. Changing src to usr is the wrong thing to do here. usr is unsafe in procs, and usr is not always "the user" as some misguided people believe.

~~> Unknown Person
changed usr to src in the proc then instead of the verb doing the entire loop i had the verb execute the proc. same problem occurs.
In response to Unknown Person
Its not a proc its the verb and why does he have a verb of the same thing then has it as a proc
Ok make the bullet appear in the usr loc then change it to walk instead of step then try deleting the Spawn part and replace it with sleep and if that doesnt work well mine does
var/obj/revbullet/RB = new /obj/revbullet(usr.loc)
walk(RB,usr.dir)
Do you have anything under /obj/Bullet/New()?
In response to Buzzertron
Buzzertron wrote:
Its not a proc its the verb and why does he have a verb of the same thing then has it as a proc

You claim something to be true, which you disclaimed to be true in the first place.

O-matic
In response to O-matic
Yeah because he has a proc named fire that does the same thing as the verb name shoot
In response to Buzzertron
Buzzertron wrote:
Yeah because he has a proc named fire that does the same thing as the verb name shoot

Unknown Person wrote:
Buzzertron wrote:
Change src loc to usr loc.also this is mine it works

No. Changing src to usr is the wrong thing to do here. usr is unsafe in procs, and usr is not always "the user" as some misguided people believe.

And then you say "Its not a proc its the verb", while UP simply said that usr was insafe in this case, you disclaim that there is a proc, and in the very same <s>sentence</s>line you suddenly say that there is a proc ("and why does he have a verb of the same thing then has it as a proc"). Kinda odd, isn't it?

If you still don't understand, then try to understand. If I was wrong, then my apologies. Either way, I do not wish to go into an off-topic argue.

O-matic
This should work, fully commented so you can learn from it.

mob
verb
Shoot()//verb name
if(!usr.fired)//If usr fired = 0
var/obj/Bullet/O = new /obj/Bullet(src.loc)//creates a bullet
O.dir=usr.dir//make it so the bullet wont turn when the usr turns
usr.fired=1//changes the fired variable to 1 for the user
while(O)//while the the bullet is stilll there
walk(O,O.dir)//Makes it so the bullet goes in a straight line
sleep(15)//wait 1.5 seconds
usr.fired=0//makes the fired variable 0 for the user.
del(O)//deletes the Bullet

obj
Bullet
//icon info here
density=1//makes it so it can bump
Bump(mob/M)//if it bumps a mob
//if it hits a mob put what happens here
Bump(object,O)//hits a dense object
//if it hits a object put what happens here
Bump(turf,T)//hits a dense turf
//if it hits a turf put what happens here.
In response to Kore2
You can only use one bumb with one object so the last bumb will work make it atom/a