by Karatorian » Sun Sep 05, 2010 7:44 pm
These behaviors are all caused by something pretty basic, failing to clear self.impulse after declining to act on it's value, which causes the value to be there the next time the impulse handler is called.
In the case of the default attack_finished, the reason is that W_WeaponFrame (called from PlayerPostThink) returns before calling ImpulseCommands if attack_finished is greater than the current time. This works well in the stock QuakeC because it prevents someone from switching guns while still firing, but allows the switch to happen as soon as they're done.
As for the morph stuff, it's hard to say exactly what's going wrong without seeing the source, but somehow the impulse isn't being cleared after deciding not to allow the morph.
In the case of the mystery box, you didn't give any details, but if it uses impulses, it's probably the same issue.
When changing any of this, carefully consider that the standard behavior is generally correct. If you clear the impulse, make sure that you do so only in cases where you feel you must.
For example, in standard Quake, trying to switch weapons while still firing the current one doesn't work, but it doesn't clear the impulse. If it did, switching weapons would require that the player make sure to do so only while not still in an attack. However, realistically, that isn't going to happen. Instead, players will complain that weapon switching seems to randomly not work.
In general, when making a mod, you should consider refactoring the impulse handling system. The standard code delays all impulses until attacks are finished and then executes them as soon as possible. This makes sense, because the only thing the stock game uses impulses for is weapon switching. (And the cheat code, but pfft.) As you add more impulses, the default handling (including being called from W_WeaponFrame) starts to not make sense. For instance, why should adding a bot need to wait until the current attack is finished. (Not that the delay is very long, or even noticeable, but it's silly.)
As such, I recommend that you consider impulse handling a little more deeply than just adding more if statements to ImpulseCommand. Decide which impulses should be handled (at this time) and which shouldn't. And for those that aren't handled, decide which should be cleared, and which should just be delayed. Try to keep things clean and modular.