Limiting projectiles in Developer Help
|
|
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.
|
<dm>
// 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++
..()