Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //BinaryFlags.zh
- //Set or Get binary flags for any pointer type.
- //NPC->Misc
- //These set or get a flag from an npc's ->Misc array.
- //Call as: SetFlag(npc_pointer, misc_index, flag, true/false)
- //Example:
- ////npc goblin = Screen->LoadNPC(4);
- // const int MY_FLAG = 0100b;
- // SetFlag(goblin, 6, MY_FLAG, true)
- void SetFlag(npc n, int index, int flag, bool state){
- if ( state ) n->Misc[index] |= flag;
- else n->Misc[index] &= ~flag;
- }
- //This returns the flag from the misc index of an npc
- //Call as getFlag(npc_pointer, index, flag)
- //Example:
- ////npc goblin = Screen->LoadNPC(4);
- // const int MY_FLAG = 0100b;
- // if ( GetFlag(goblin, 6, MY_FLAG ) //The flag is true, do something.
- bool GetFlag(npc n, int index, int flag) {
- return ( n->Misc[index] & flag ) != 0;
- }
- //The same, for lweapons
- void SetFlag(lweapon n, int index, int flag, bool state){
- if ( state ) n->Misc[index] |= flag;
- else n->Misc[index] &= ~flag;
- }
- bool GetFlag(lweapon n, int index, int flag) {
- return ( n->Misc[index] & flag ) != 0;
- }
- //The same, for eweapons
- void SetFlag(eweapon n, int index, int flag, bool state){
- if ( state ) n->Misc[index] |= flag;
- else n->Misc[index] &= ~flag;
- }
- bool GetFlag(eweapon n, int index, int flag) {
- return ( n->Misc[index] & flag ) != 0;
- }
- //The same, for items
- void SetFlag(item n, int index, int flag, bool state){
- if ( state ) n->Misc[index] |= flag;
- else n->Misc[index] &= ~flag;
- }
- bool GetFlag(item n, int index, int flag) {
- return ( n->Misc[index] & flag ) != 0;
- }
- //The same, for ffcs
- void SetFlag(ffc n, int index, int flag, bool state){
- if ( state ) n->Misc[index] |= flag;
- else n->Misc[index] &= ~flag;
- }
- bool GetFlag(ffc n, int index, int flag) {
- return ( n->Misc[index] & flag ) != 0;
- }
- //This will set a binary flag in any array index.
- //Specify the array identifier, index of the array, flag, and state
- //Example:
- // int arr[24];
- // const int MY_FLAG = 0100b;
- // SetFlag(arr, 12, MY_FLAG, true)
- void SetFlag(int n, int index, int flag, bool state){
- if ( state ) n[index] |= flag;
- else n[index] &= ~flag;
- }
- bool GetFlag(int n, int index, int flag) {
- return ( n[index] & flag ) != 0;
- }
- //This will set a binary flag in a Screen->D array index.
- //Example:
- // const int MY_FLAG = 0100b;
- // SetScreenDFlag(5, MY_FLAG, true) ; //Sets Screen->D[6] with a binary flag
- void SetScreenDFlag(int index, int flag, bool state){
- if ( state ) Screen->D[index] |= flag;
- else Screen->D[index] &= ~flag;
- }
- //Gets the binary flag from a Screen->D index
- // Example:
- // if ( GetScreenDFlag(6, MY_FLAG) ) // Evaluates true if this flag is set for Screen->D[6]
- bool GetScreenDFlag(int index, int flag) {
- return ( Screen->D[index] & flag ) != 0;
- }
- //! We need DMAPScreenD
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement