ID:140725
 
Code:
mob
proc
Fire()
if(!src.weapon||src.fired||src.reloading)return
var/obj/Pickup/guns/G = src.weapon
if(G.Cap<=0)
if(src.LocateAmmo()){src.reloading=1;src.Reload()}
else src << "You need more ammo"
return
src.fired = 1
var/damage = round(rand(G.Fire_Power/2,G.Fire_Power))
spawn(G.FireRate)
if(src)
GunshotAlert()
src.fired=0
G.Cap--
G.suffix="[G.Cap]/[G.MaxCap]"
src.target = locate(/mob)in oview(5)
if(!usr.target) return
var/obj/Bullets/proj = new(src)


GunshotAlert()
for(var/mob/NPC/m in oview(src.weapon.GUN_SOUND_RANGE))
for(var/mob/M in oview(5))
if(M.fired)
walk_to(M,src,10)


Problem description:

when i make it src.fired = 0, it doesn't reset for any reason and i'm not sure why is it not reseting.
You probably want it like this
            GunshotAlert()
spawn(G.FireRate)
src.fired=0


And if you determined that it was the fired var because there was no bullet this could also be the problem...
if(!usr.target) return
Using usr in a custom proc usually results in problems.


If what I said doesn't fix it I would recommend adding this to the beginning of the fire proc, running it a few times, and post what it returns...
world<<"Weapon: [src.weapon.type] Is-fired: [src.fired] Is-Reloading: [src.reloading]"
In response to Chowder
mob/var/mob/target
mob
proc
Fire()
if(!src.weapon||src.fired||src.reloading)return
var/obj/Pickup/guns/G = src.weapon
if(G.Cap<=0)
if(src.LocateAmmo()){src.reloading=1;src.Reload()}
else src << "You need more ammo"
return
src.fired = 1
var/damage = round(rand(G.Fire_Power/2,G.Fire_Power))
if(src)
GunshotAlert()
spawn(G.FireRate)
src.fired=0
G.Cap--
G.suffix="[G.Cap]/[G.MaxCap]"
src.target = locate(/mob)in oview(5)
if(!src.target) return
var/obj/Bullets/proj = new(src)


GunshotAlert()
for(var/mob/NPC/m in oview(src.weapon.GUN_SOUND_RANGE))
for(var/mob/M in oview(5))
if(M.fired)
walk_to(M,src,10)


Made the changes still not working.
In response to Gamemakingdude
Reread my post I was playing with it... Also remove that if(src) bit its really useless...
After all if theirs no src there's nothing running that code...
In response to Chowder

Weapon: /obj/Pickup/guns/Test Is-fired: Is-Reloading: 11
Weapon: /obj/Pickup/guns/Test Is-fired: 1 Is-Reloading: 19
Weapon: /obj/Pickup/guns/Test Is-fired: 1 Is-Reloading: 29
Weapon: /obj/Pickup/guns/Test Is-fired: 0 Is-Reloading: 23

mob/var/mob/target
mob
proc
Fire()
if(!src.weapon||src.fired||src.reloading)return
world<<"Weapon: [src.weapon.type] Is-fired: [src.fired] Is-Reloading: [src.reloading] [__LINE__]"
var/obj/Pickup/guns/G = src.weapon
if(G.Cap<=0)
if(src.LocateAmmo()){src.reloading=1;src.Reload()}
else src << "You need more ammo"
return
src.fired = 1
var/damage = round(rand(G.Fire_Power/2,G.Fire_Power))
world<<"Weapon: [src.weapon.type] Is-fired: [src.fired] Is-Reloading: [src.reloading] [__LINE__]"
GunshotAlert()
spawn(G.FireRate)
src.fired=0
world<<"Weapon: [src.weapon.type] Is-fired: [src.fired] Is-Reloading: [src.reloading] [__LINE__]"
G.Cap--
G.suffix="[G.Cap]/[G.MaxCap]"
src.target = locate(/mob)in oview(5)
if(!src.target) return
var/obj/Bullets/proj = new(src)
world<<"Weapon: [src.weapon.type] Is-fired: [src.fired] Is-Reloading: [src.reloading] [__LINE__]"


GunshotAlert()
for(var/mob/NPC/m in oview(src.weapon.GUN_SOUND_RANGE))
for(var/mob/M in oview(5))
if(M.fired)
walk_to(M,src,10)


Ok There's the results.
In response to Gamemakingdude
Bingo we have a few problems

Is-fired: Is-Reloading: 11
The fact that fired is blank means you have it initalized sorta like this

mob/var/fired

when it needs to be

mob/var/fired=0

But whats really causing problems is that reloading var

Whats setting it? Whats its start value? Wheres it used? Whats it used for?
Post some code and info on it.
In response to Chowder
        Reload()
if(!src.weapon){src.reloading=0;return}
var/i=src.weapon
src<<"<i><font size=2>Reloading..."
sleep(src.weapon.ReloadTime)
if(!src.weapon){src.reloading=0;return}
else if(i==src.weapon)
var/obj/Pickup/ammo/A=locate(src.weapon.Ammo_Path) in src.contents
if(A)
var/take=src.weapon.MaxCap
take-=src.weapon.Cap
if(A.ammo<take)take=A.ammo
src.weapon.Cap+=take
src.weapon.suffix="[src.weapon.Cap]/[src.weapon.MaxCap]"
A.ammo-=take
if(A.ammo<=0)del(A)
else A.suffix="[A.ammo]/[A.mammo]"
src<<"<i><font size=2>...Reloaded!"
sleep(10)
src.reloading=0
LocateAmmo()
if(!src.weapon)return 0
var/A=locate(src.weapon.Ammo_Path) in src.contents
if(A)return 1
else return 0
//Reloading procs

mob
var
tmp
reloading
fired = 0
obj/Pickup/guns/weapon
kills
In response to Chowder
Actually, none of that is relevant. There are only really two questions here:

1) What the hell is the issue? "fired = 1 doesn't reset" is not even close to a description of the problem. You need to say what SHOULD happen, what DOES happen and how what DOES happen is not what you want to happen.

2) Why haven't you fixed those goddamned ugly nested for() loops in the GunshotAlert() proc like I told you to? They don't even come close to doing what you want and are just a huge waste of cycles.
In response to Gamemakingdude
I didn't notice you modified my test...
Anyways initialize reloading to 0.
mob
var
tmp
reloading=0

And this time with my test click fire multiple times..
In response to Chowder
Its not spawning the bullet. BTW chowder do you have msn so its faster to reply?? [email protected]

And Garthor, in case you didn't notice the one of the loops is from the user sight and the other one is from the monster sight...
In response to Gamemakingdude
Gamemakingdude wrote:
And Garthor, in case you didn't notice the one of the loops is from the user sight and the other one is from the monster sight...

No, that is not actually the case at all. One is oview(src), the other is oview(usr).

And you still have not provided a useful description of what the problem is.
In response to Garthor
Its fixed anyway.
In response to Gamemakingdude
This has nothing to do with the problem, but you might want to make your mob/target var a temporary var, because you really don't want an entire other mob to be saved in your own mob's save file...

mob/var/tmp/mob/target

In response to Garthor
The problem most likely was that 'fired' variable not changing back to 0 after the firing delay.
In response to Nielz
Actually the problem turned out to be that he was using a custom proc named bumped instead of bump in the bullet and he wasn't spawning a subtype of bullet so it had no icon. So it appeared not to be firing and he guessed that it was the fired var.
In response to Gamemakingdude
I wonder if it really is fixed, or does it still have the same ugly loops-in-loops (amongst other things).
In response to Vic Rattlehead
Chowder has added me on msn and will help in future problems if he doesn't mind.