



grailknighthero 说:Just out of curiosity, what use do we have for bitwise functions? Allows us to mess around with header file hex code more?
('toggle_bit',
[
(store_script_param,':flag',1),
(store_script_param,':bit_num',2),
(store_script_param,':operation',3),
(try_begin),
(eq,':operation',set_bit),
(val_or,':flag',':bit_num'),
(else_try),
(val_sub,':flag',':bit_num'),
(try_end),
(assign,reg0,':flag'),
]
),
('check_bit',
[
(store_script_param,':flag',1),
(store_script_param,':bit_num',2),
(store_and,':result',':flag',':bit_num'),
(try_begin),
(gt,':result',0),
(assign,reg0,true),
(else_try),
(assign,reg0,false),
(try_end),
]
),

Fujiwara 说:I use a lot of custom bitfields in Onin no Ran (example: you can set up quests with multiple intermediate goals, that aren't necessarily linear, without a whole bunch of global tracking variables), and I had to write bin->dec and dec->bin converters, plus code to breakout a bitfield (which was really a decimal number consisting of just 1's and 0's) into an array of 1's and 0's, and code to check the bit I wanted to look at. A huge, complicated suite of scripts. This is going cut all that down to two scripts: one to set/unset bits, and one to check if a bit is set:
All games have limits. Armagan did not know in the beginning that M&B would get this far. The old limit used to be 512.Thymo 说:

grailknighthero 说:Fujiwara 说:I use a lot of custom bitfields in Onin no Ran (example: you can set up quests with multiple intermediate goals, that aren't necessarily linear, without a whole bunch of global tracking variables), and I had to write bin->dec and dec->bin converters, plus code to breakout a bitfield (which was really a decimal number consisting of just 1's and 0's) into an array of 1's and 0's, and code to check the bit I wanted to look at. A huge, complicated suite of scripts. This is going cut all that down to two scripts: one to set/unset bits, and one to check if a bit is set:
Crazy, I never thought people would be using that kind of stuff in M&B.
Oh yeah...it started out as something I needed before we had check_quest_concluded, etc. The original implementation was with slots, which was horrible. I had hand roll a store_power script to get the original dec->bin converters to work before we had the store_pow opcode. Now, I only to need to store the flag value in one slot, and the power of it is pretty amazing: you can have up to 28 custom flags for any object for each integer (max integer value I've seen is 400,000,000, which is actually kinda weird, since even a signed 32-bit integer tops out at 2,147,483,647).



armagan 说:Thank you so much for all those kind words.
There shouldn't be an upper limit on troops (or anything other than factions) in the new version.
Porting is pretty easy
