/* * common.h * * Created on: 2009-1-7 * Author: Argon.Sun */ #ifndef COMMON_H_ #define COMMON_H_ #include #include typedef unsigned char byte; inline bool check_playerid(int32_t playerid) { return playerid >= 0 && playerid <= 1; } enum LuaParamType : int32_t { PARAM_TYPE_INT = 0x01, PARAM_TYPE_STRING = 0x02, PARAM_TYPE_CARD = 0x04, PARAM_TYPE_GROUP = 0x08, PARAM_TYPE_EFFECT = 0x10, PARAM_TYPE_FUNCTION = 0x20, PARAM_TYPE_BOOLEAN = 0x40, PARAM_TYPE_INDEX = 0x80, }; #define MATCH_ALL(x,y) (((x)&(y))==(y)) #define MATCH_ANY(x,y) ((x)&(y)) #define ADD_BIT(x,y) ((x)|=(y)) #define REMOVE_BIT(x,y) ((x)&=~(y)) #define OPERATION_SUCCESS 1 #define OPERATION_FAIL 0 #define OPERATION_CANCELED -1 #define TRUE 1 #define FALSE 0 #define SIZE_MESSAGE_BUFFER 0x2000u #define SIZE_RETURN_VALUE 256u #define SIZE_AI_NAME 128u #define SIZE_HINT_MSG 1024u #define PROCESSOR_BUFFER_LEN 0x0fffffff #define PROCESSOR_FLAG 0xf0000000 #define PROCESSOR_NONE 0 #define PROCESSOR_WAITING 0x10000000 #define PROCESSOR_END 0x20000000 #define MASTER_RULE3 3 //Master Rule 3 (2014) #define NEW_MASTER_RULE 4 //New Master Rule (2017) #define MASTER_RULE_2020 5 //Master Rule 2020 #define CURRENT_RULE 5 // Duel creation flags #define OCGCORE_CREATE_ENABLE_LUA_COVERAGE 0x00000001u //Locations #define LOCATION_DECK 0x01U #define LOCATION_HAND 0x02U #define LOCATION_MZONE 0x04U #define LOCATION_SZONE 0x08U #define LOCATION_GRAVE 0x10U #define LOCATION_REMOVED 0x20U #define LOCATION_EXTRA 0x40U #define LOCATION_OVERLAY 0x80U #define LOCATION_ONFIELD (LOCATION_MZONE | LOCATION_SZONE) #define LOCATION_FZONE 0x100U #define LOCATION_PZONE 0x200U //For redirect #define LOCATION_DECKBOT 0x10001 //Return to deck bottom #define LOCATION_DECKSHF 0x20001 //Return to deck and shuffle //For Duel.SendtoDeck #define SEQ_DECKTOP 0 //Return to deck top #define SEQ_DECKBOTTOM 1 //Return to deck bottom #define SEQ_DECKSHUFFLE 2 //Return to deck and shuffle //Positions #define POS_FACEUP_ATTACK 0x1 #define POS_FACEDOWN_ATTACK 0x2 #define POS_FACEUP_DEFENSE 0x4 #define POS_FACEDOWN_DEFENSE 0x8 #define POS_FACEUP 0x5 #define POS_FACEDOWN 0xa #define POS_ATTACK 0x3 #define POS_DEFENSE 0xc #define POS_REVEAL 0x80 //Flip effect flags #define NO_FLIP_EFFECT 0x10000 //Move to field flags #define RETURN_TEMP_REMOVE_TO_FIELD 1 #define RETURN_TRAP_MONSTER_TO_SZONE 2 //Types #define TYPE_MONSTER 0x1 // #define TYPE_SPELL 0x2 // #define TYPE_TRAP 0x4 // #define TYPE_NORMAL 0x10 // #define TYPE_EFFECT 0x20 // #define TYPE_FUSION 0x40 // #define TYPE_RITUAL 0x80 // #define TYPE_TRAPMONSTER 0x100 // #define TYPE_SPIRIT 0x200 // #define TYPE_UNION 0x400 // #define TYPE_DUAL 0x800 // #define TYPE_TUNER 0x1000 // #define TYPE_SYNCHRO 0x2000 // #define TYPE_TOKEN 0x4000 // #define TYPE_QUICKPLAY 0x10000 // #define TYPE_CONTINUOUS 0x20000 // #define TYPE_EQUIP 0x40000 // #define TYPE_FIELD 0x80000 // #define TYPE_COUNTER 0x100000 // #define TYPE_FLIP 0x200000 // #define TYPE_TOON 0x400000 // #define TYPE_XYZ 0x800000 // #define TYPE_PENDULUM 0x1000000 // #define TYPE_SPSUMMON 0x2000000 // #define TYPE_LINK 0x4000000 // //[YGOL] Reserved setcode: "this Token is allowed to exist face-down". // The OCG rule is that a Token is never face-down; the core hard-codes that in // card::get_spsummonable_position and card::is_removeable. Rather than lift the rule // for every Token, a Token opts in by carrying this setcode on its cdb row. // A setcode is the ONLY carrier that works: field::is_player_can_spsummon_monster // probes a scratch temp_card built from card_data alone (no script, no registered // effects), so an effect-based opt-in is invisible to the legality check and the card // ends up unactivatable. A correctly typed Token is also TYPE_NORMAL, and // interpreter::is_load_script skips Normal monsters, so a Token cannot register // anything from its own Lua either. // card_data::is_setcode matches on the low 12 bits, so this permanently burns // archetype id 0xFDF -- never reuse it for a real archetype. // First user: "WANTED! Rushing Roulette" (810000327) and its two Tokens. #define SETCODE_FACEDOWN_TOKEN 0xFDF #define TYPES_EXTRA_DECK (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK) //Attributes #define ATTRIBUTES_COUNT 7 #define ATTRIBUTE_ALL 0x7f // #define ATTRIBUTE_EARTH 0x01 // #define ATTRIBUTE_WATER 0x02 // #define ATTRIBUTE_FIRE 0x04 // #define ATTRIBUTE_WIND 0x08 // #define ATTRIBUTE_LIGHT 0x10 // #define ATTRIBUTE_DARK 0x20 // #define ATTRIBUTE_DEVINE 0x40 // //Races #define RACES_COUNT 26 #define RACE_ALL 0x3ffffff #define RACE_WARRIOR 0x1 // #define RACE_SPELLCASTER 0x2 // #define RACE_FAIRY 0x4 // #define RACE_FIEND 0x8 // #define RACE_ZOMBIE 0x10 // #define RACE_MACHINE 0x20 // #define RACE_AQUA 0x40 // #define RACE_PYRO 0x80 // #define RACE_ROCK 0x100 // #define RACE_WINDBEAST 0x200 // #define RACE_PLANT 0x400 // #define RACE_INSECT 0x800 // #define RACE_THUNDER 0x1000 // #define RACE_DRAGON 0x2000 // #define RACE_BEAST 0x4000 // #define RACE_BEASTWARRIOR 0x8000 // #define RACE_DINOSAUR 0x10000 // #define RACE_FISH 0x20000 // #define RACE_SEASERPENT 0x40000 // #define RACE_REPTILE 0x80000 // #define RACE_PSYCHO 0x100000 // #define RACE_DEVINE 0x200000 // #define RACE_CREATORGOD 0x400000 // #define RACE_WYRM 0x800000 // #define RACE_CYBERSE 0x1000000 // #define RACE_ILLUSION 0x2000000 // //Reason #define REASON_DESTROY 0x1 // #define REASON_RELEASE 0x2 // #define REASON_TEMPORARY 0x4 // #define REASON_MATERIAL 0x8 // #define REASON_SUMMON 0x10 // #define REASON_BATTLE 0x20 // #define REASON_EFFECT 0x40 // #define REASON_COST 0x80 // #define REASON_ADJUST 0x100 // #define REASON_LOST_TARGET 0x200 // #define REASON_RULE 0x400 // #define REASON_SPSUMMON 0x800 // #define REASON_DISSUMMON 0x1000 // #define REASON_FLIP 0x2000 // #define REASON_DISCARD 0x4000 // #define REASON_RDAMAGE 0x8000 // #define REASON_RRECOVER 0x10000 // #define REASON_RETURN 0x20000 // #define REASON_FUSION 0x40000 // #define REASON_SYNCHRO 0x80000 // #define REASON_RITUAL 0x100000 // #define REASON_XYZ 0x200000 // #define REASON_REPLACE 0x1000000 // #define REASON_DRAW 0x2000000 // #define REASON_REDIRECT 0x4000000 // #define REASON_REVEAL 0x8000000 // #define REASON_LINK 0x10000000 // #define REASON_LOST_OVERLAY 0x20000000 // #define REASON_MAINTENANCE 0x40000000 // #define REASON_ACTION 0x80000000 // #define REASONS_PROCEDURE (REASON_SYNCHRO | REASON_XYZ | REASON_LINK) //Status #define STATUS_DISABLED 0x0001 #define STATUS_TO_ENABLE 0x0002 #define STATUS_TO_DISABLE 0x0004 #define STATUS_PROC_COMPLETE 0x0008 #define STATUS_SET_TURN 0x0010 #define STATUS_NO_LEVEL 0x0020 #define STATUS_BATTLE_RESULT 0x0040 #define STATUS_SPSUMMON_STEP 0x0080 #define STATUS_CANNOT_CHANGE_FORM 0x0100 #define STATUS_SUMMONING 0x0200 #define STATUS_EFFECT_ENABLED 0x0400 #define STATUS_SUMMON_TURN 0x0800 #define STATUS_DESTROY_CONFIRMED 0x1000 #define STATUS_LEAVE_CONFIRMED 0x2000 #define STATUS_BATTLE_DESTROYED 0x4000 #define STATUS_COPYING_EFFECT 0x8000 #define STATUS_CHAINING 0x10000 #define STATUS_SUMMON_DISABLED 0x20000 #define STATUS_ACTIVATE_DISABLED 0x40000 #define STATUS_EFFECT_REPLACED 0x80000 #define STATUS_FLIP_SUMMONING 0x100000 #define STATUS_ATTACK_CANCELED 0x200000 #define STATUS_INITIALIZING 0x400000 #define STATUS_TO_HAND_WITHOUT_CONFIRM 0x800000 #define STATUS_JUST_POS 0x1000000 #define STATUS_CONTINUOUS_POS 0x2000000 #define STATUS_FORBIDDEN 0x4000000 #define STATUS_ACT_FROM_HAND 0x8000000 #define STATUS_OPPO_BATTLE 0x10000000 #define STATUS_FLIP_SUMMON_TURN 0x20000000 #define STATUS_SPSUMMON_TURN 0x40000000 #define STATUS_FLIP_SUMMON_DISABLED 0x80000000 //Query list #define QUERY_CODE 0x1 #define QUERY_POSITION 0x2 #define QUERY_ALIAS 0x4 #define QUERY_TYPE 0x8 #define QUERY_LEVEL 0x10 #define QUERY_RANK 0x20 #define QUERY_ATTRIBUTE 0x40 #define QUERY_RACE 0x80 #define QUERY_ATTACK 0x100 #define QUERY_DEFENSE 0x200 #define QUERY_BASE_ATTACK 0x400 #define QUERY_BASE_DEFENSE 0x800 #define QUERY_REASON 0x1000 #define QUERY_REASON_CARD 0x2000 #define QUERY_EQUIP_CARD 0x4000 #define QUERY_TARGET_CARD 0x8000 #define QUERY_OVERLAY_CARD 0x10000 #define QUERY_COUNTERS 0x20000 #define QUERY_OWNER 0x40000 #define QUERY_STATUS 0x80000 #define QUERY_LSCALE 0x200000 #define QUERY_RSCALE 0x400000 #define QUERY_LINK 0x800000 //Link markers #define LINK_MARKER_BOTTOM_LEFT 0x001 #define LINK_MARKER_BOTTOM 0x002 #define LINK_MARKER_BOTTOM_RIGHT 0x004 #define LINK_MARKER_LEFT 0x008 #define LINK_MARKER_RIGHT 0x020 #define LINK_MARKER_TOP_LEFT 0x040 #define LINK_MARKER_TOP 0x080 #define LINK_MARKER_TOP_RIGHT 0x100 //Messages #define MSG_RETRY 1 #define MSG_HINT 2 //#define MSG_WAITING 3 //#define MSG_START 4 #define MSG_WIN 5 //#define MSG_UPDATE_DATA 6 #define MSG_UPDATE_CARD 7 //#define MSG_REQUEST_DECK 8 #define MSG_SELECT_BATTLECMD 10 #define MSG_SELECT_IDLECMD 11 #define MSG_SELECT_EFFECTYN 12 #define MSG_SELECT_YESNO 13 #define MSG_SELECT_OPTION 14 #define MSG_SELECT_CARD 15 #define MSG_SELECT_CHAIN 16 #define MSG_SELECT_PLACE 18 #define MSG_SELECT_POSITION 19 #define MSG_SELECT_TRIBUTE 20 #define MSG_SELECT_COUNTER 22 #define MSG_SELECT_SUM 23 #define MSG_SELECT_DISFIELD 24 #define MSG_SORT_CARD 25 #define MSG_SELECT_UNSELECT_CARD 26 #define MSG_CONFIRM_DECKTOP 30 #define MSG_CONFIRM_CARDS 31 #define MSG_SHUFFLE_DECK 32 #define MSG_SHUFFLE_HAND 33 //#define MSG_REFRESH_DECK 34 #define MSG_SWAP_GRAVE_DECK 35 #define MSG_SHUFFLE_SET_CARD 36 #define MSG_REVERSE_DECK 37 #define MSG_DECK_TOP 38 #define MSG_SHUFFLE_EXTRA 39 #define MSG_NEW_TURN 40 #define MSG_NEW_PHASE 41 #define MSG_CONFIRM_EXTRATOP 42 #define MSG_MOVE 50 #define MSG_POS_CHANGE 53 #define MSG_SET 54 #define MSG_SWAP 55 #define MSG_FIELD_DISABLED 56 #define MSG_SUMMONING 60 #define MSG_SUMMONED 61 #define MSG_SPSUMMONING 62 #define MSG_SPSUMMONED 63 #define MSG_FLIPSUMMONING 64 #define MSG_FLIPSUMMONED 65 #define MSG_CHAINING 70 #define MSG_CHAINED 71 #define MSG_CHAIN_SOLVING 72 #define MSG_CHAIN_SOLVED 73 #define MSG_CHAIN_END 74 #define MSG_CHAIN_NEGATED 75 #define MSG_CHAIN_DISABLED 76 //#define MSG_CARD_SELECTED 80 #define MSG_RANDOM_SELECTED 81 #define MSG_BECOME_TARGET 83 #define MSG_DRAW 90 #define MSG_DAMAGE 91 #define MSG_RECOVER 92 #define MSG_EQUIP 93 #define MSG_LPUPDATE 94 //#define MSG_UNEQUIP 95 #define MSG_CARD_TARGET 96 #define MSG_CANCEL_TARGET 97 #define MSG_PAY_LPCOST 100 #define MSG_ADD_COUNTER 101 #define MSG_REMOVE_COUNTER 102 #define MSG_ATTACK 110 #define MSG_BATTLE 111 #define MSG_ATTACK_DISABLED 112 #define MSG_DAMAGE_STEP_START 113 #define MSG_DAMAGE_STEP_END 114 #define MSG_MISSED_EFFECT 120 //#define MSG_BE_CHAIN_TARGET 121 //#define MSG_CREATE_RELATION 122 //#define MSG_RELEASE_RELATION 123 #define MSG_TOSS_COIN 130 #define MSG_TOSS_DICE 131 #define MSG_ROCK_PAPER_SCISSORS 132 #define MSG_HAND_RES 133 #define MSG_ANNOUNCE_RACE 140 #define MSG_ANNOUNCE_ATTRIB 141 #define MSG_ANNOUNCE_CARD 142 #define MSG_ANNOUNCE_NUMBER 143 #define MSG_CARD_HINT 160 #define MSG_TAG_SWAP 161 #define MSG_RELOAD_FIELD 162 // Debug.ReloadFieldEnd() or query_field_info() #define MSG_AI_NAME 163 // Debug.AIName() #define MSG_SHOW_HINT 164 // Debug.ShowHint() #define MSG_PLAYER_HINT 165 #define MSG_MATCH_KILL 170 #define MSG_CUSTOM_MSG 180 #define MSG_RESET_TIME 221 //Hints #define HINT_EVENT 1 #define HINT_MESSAGE 2 #define HINT_SELECTMSG 3 #define HINT_OPSELECTED 4 #define HINT_EFFECT 5 #define HINT_RACE 6 #define HINT_ATTRIB 7 #define HINT_CODE 8 #define HINT_NUMBER 9 #define HINT_CARD 10 #define HINT_ZONE 11 //custom hints in KoishiPro for custom sound #define HINT_MUSIC 21 #define HINT_SOUND 22 #define HINT_MUSIC_OGG 23 // #define CHINT_TURN 1 #define CHINT_CARD 2 #define CHINT_RACE 3 #define CHINT_ATTRIBUTE 4 #define CHINT_NUMBER 5 #define CHINT_DESC_ADD 6 #define CHINT_DESC_REMOVE 7 // #define PHINT_DESC_ADD 6 #define PHINT_DESC_REMOVE 7 // #define EDESC_OPERATION 1 #define EDESC_RESET 2 // #define OPCODE_ADD 0x40000000 #define OPCODE_SUB 0x40000001 #define OPCODE_MUL 0x40000002 #define OPCODE_DIV 0x40000003 #define OPCODE_AND 0x40000004 #define OPCODE_OR 0x40000005 #define OPCODE_NEG 0x40000006 #define OPCODE_NOT 0x40000007 #define OPCODE_ISCODE 0x40000100 #define OPCODE_ISSETCARD 0x40000101 #define OPCODE_ISTYPE 0x40000102 #define OPCODE_ISRACE 0x40000103 #define OPCODE_ISATTRIBUTE 0x40000104 //Player #define PLAYER_NONE 2 // #define PLAYER_ALL 3 // #define PLAYER_SELFDES 5 // //Phase #define PHASE_DRAW 0x01 #define PHASE_STANDBY 0x02 #define PHASE_MAIN1 0x04 #define PHASE_BATTLE_START 0x08 #define PHASE_BATTLE_STEP 0x10 #define PHASE_DAMAGE 0x20 #define PHASE_DAMAGE_CAL 0x40 #define PHASE_BATTLE 0x80 #define PHASE_MAIN2 0x100 #define PHASE_END 0x200 //Options #define DUEL_TEST_MODE 0x01 #define DUEL_ATTACK_FIRST_TURN 0x02 //#define DUEL_OLD_REPLAY 0x04 #define DUEL_OBSOLETE_RULING 0x08 #define DUEL_PSEUDO_SHUFFLE 0x10 #define DUEL_TAG_MODE 0x20 #define DUEL_SIMPLE_AI 0x40 #define DUEL_RETURN_DECK_TOP 0x80 #define DUEL_REVEAL_DECK_SEQ 0x100 //Activity #define ACTIVITY_SUMMON 1 #define ACTIVITY_NORMALSUMMON 2 #define ACTIVITY_SPSUMMON 3 #define ACTIVITY_FLIPSUMMON 4 #define ACTIVITY_ATTACK 5 #define ACTIVITY_BATTLE_PHASE 6 #define ACTIVITY_CHAIN 7 //card datas for Duel.ReadCard / Card.SetCardData, arranged by database format #define CARDDATA_CODE 1 #define CARDDATA_ALIAS 2 #define CARDDATA_SETCODE 3 #define CARDDATA_TYPE 4 #define CARDDATA_LEVEL 5 #define CARDDATA_ATTRIBUTE 6 #define CARDDATA_RACE 7 #define CARDDATA_ATTACK 8 #define CARDDATA_DEFENSE 9 #define CARDDATA_LSCALE 10 #define CARDDATA_RSCALE 11 #define CARDDATA_LINK_MARKER 12 //get effects for Card.GetCardRegistered #define GETEFFECT_INITIAL 0x1 #define GETEFFECT_GAIN 0x2 #define GETEFFECT_COPY 0x4 #define GETEFFECT_GRANT 0x8 #define GETEFFECT_ALL 0xf #endif /* COMMON_H_ */