I'm wondering what I should do for a monster & spell system, bitflags or to where I have to set some vars. They'd be the same, but which executes faster?
bitflags should be marginally faster is some instances or very fast in others.
the downside to bitflags is that you should to comment your code liberally enough to know what you were using all the flags for. alternatively, separate variable definitions help make your code readable to yourself (later on down the road), or to others who use your code.
often times i develop the 'long way' (ie, use long-named-descriptive variables) to make sure things work, then later reduce like-groups of variables (say: monster options) into a single bitflag.
I'm wondering what I should do for a monster & spell system, bitflags or to where I have to set some vars. They'd be the same, but which executes faster?
The bitflags will be a lot slower(relativly) since to preform any bitwise operations BYOND must convert the variable from a float to an int, preform the operation, then convert back. Compared to just doing a test for not being zero this is slower on several orders of magnitude. If speed is concerned just use a variable as a boolean. However using a variable as a bit array you get 16 flags per variable which is very good for savefiles since you considerably compact the data. Also if every mob has this set of flags you can save a lot of RAM especially if you have a lot of them.
While bitflags are slower they are still generally good to use since they aren't that slow just slow relative to a boolean variable. So as long as you aren't trying to optimize some tight loop which needs to execute many many times quickly bitflags should be fine. And since it sounds like you're just using them as a check to see if a player does or doesn't have something it should be fine to use bitflags.
the downside to bitflags is that you should to comment your code liberally enough to know what you were using all the flags for. alternatively, separate variable definitions help make your code readable to yourself (later on down the road), or to others who use your code.
often times i develop the 'long way' (ie, use long-named-descriptive variables) to make sure things work, then later reduce like-groups of variables (say: monster options) into a single bitflag.