Question description:
ok so i want to make it so if someone is already busy they cannot fire a projectile because they are either stunned or swimming. how would i go about this?
Thank you for reading my post :D.
You're generating excess proc overhead for no real reason here, if IsOccupied() did more than return a boolean value it would be more reasonable but in this case you're going to end up generating a ton more overhead any time you call Fire() when you could just be checking occupied_state directly.
|
It could be excessive; it depends on exactly what you want to do on down the line, so it's just a very general purpose solution. In this situation, the overhead concerns should be quite minor given that they should be irregular in the sense of happening far less than once per tick.
If you know for sure you're not going to be going more complex than that, though, it can be cut down for sure. |
In response to Louisthe10
|
|
Are you actually calling the Occupied() and NotOccupied() methods to set their state when the relevant conditions are satisfied?
|
Another way to approach a problem like this: Many games have several different things that can interfere with casting spells or moving. They end up with all kinds of conditions, like this:
if(dead || sleeping || walking || casting || brushing_teeth || ...) When you have a bunch of possible yes/no conditions like that, that's when bitflags come to the rescue. #define DEAD 1 So in most of your verbs, you'd do something like this: mob/verb/Fire() Movement would be the same way. mob/Move(newloc,newdir) |
Then if you want to keep them from firing a projectile, in your fire method you'd have something like
Whenever a mob becomes occupied, you call Occupied() which sets the occupied flag on. Whenever they're no longer occupied, you call NotOccupied() turning it off.