ID:155838
 
I have a system where you can shoot little lasers, but I want to be able to make it so that a single player can only have so many lasers fired at a time, like for say...

You can shoot three lasers at a time, so you shoot three lasers. When the lasers do their thing, the player receives the ability to shoot one more laser again.

Currently I'm just subtracting from the player's laser count when they fire one, and give them back a point when the laser obj deletes itself, but this is extremely wonky and not being very consistent. If a player rapidly fires lasers, they can fire more than they should be able to and don't get the right amount back.

...basically I'm looking for a better way to do this.
As long as you're modifying the variable at the right time, there should be no conflicts.
// here comes pseudocode!
mob
var tmp/lasers = 3
proc/shoot_laser() if(lasers)
var laser/laser = new // create the projectile
laser.firer = src
laser.fired()

laser
var mob/firer
fired()
firer.lasers--
// move in a line, do laser stuff, etc.

Del()
if(firer) firer.lasers++
..()
In response to Kaiochao
It seems to work for the most part, but something strange is definitely going on still.

Certain projectiles fire more than one at once, in different formations such as three in a wall formation going in one direction, or three going in different directions.

Depending on how they impact though (based on the terrain), somehow the... number can drop below 0. Or something. I'm not entirely sure but it definitely has something to do with Bump() I think.

http://pastebin.com/HUxKdYCF