Commit 4291281e authored by mercury233's avatar mercury233
parents 45f3eb3d 2835740b
...@@ -1170,8 +1170,8 @@ void card::get_linked_cards(card_set* cset) { ...@@ -1170,8 +1170,8 @@ void card::get_linked_cards(card_set* cset) {
return; return;
int32 p = current.controler; int32 p = current.controler;
uint32 linked_zone = get_linked_zone(); uint32 linked_zone = get_linked_zone();
pduel->game_field->get_cards_in_zone(cset, linked_zone, p); pduel->game_field->get_cards_in_zone(cset, linked_zone, p, LOCATION_MZONE);
pduel->game_field->get_cards_in_zone(cset, linked_zone >> 16, 1 - p); pduel->game_field->get_cards_in_zone(cset, linked_zone >> 16, 1 - p, LOCATION_MZONE);
} }
uint32 card::get_mutual_linked_zone() { uint32 card::get_mutual_linked_zone() {
if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE) if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE)
...@@ -1303,6 +1303,15 @@ uint32 card::get_mutual_linked_zone() { ...@@ -1303,6 +1303,15 @@ uint32 card::get_mutual_linked_zone() {
} }
return zones; return zones;
} }
void card::get_mutual_linked_cards(card_set* cset) {
cset->clear();
if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE)
return;
int32 p = current.controler;
uint32 mutual_linked_zone = get_mutual_linked_zone();
pduel->game_field->get_cards_in_zone(cset, mutual_linked_zone, p, LOCATION_MZONE);
pduel->game_field->get_cards_in_zone(cset, mutual_linked_zone >> 16, 1 - p, LOCATION_MZONE);
}
int32 card::is_link_state() { int32 card::is_link_state() {
if(current.location != LOCATION_MZONE) if(current.location != LOCATION_MZONE)
return FALSE; return FALSE;
...@@ -1335,6 +1344,89 @@ int32 card::is_status(uint32 status) { ...@@ -1335,6 +1344,89 @@ int32 card::is_status(uint32 status) {
return TRUE; return TRUE;
return FALSE; return FALSE;
} }
uint32 card::get_column_zone(int32 loc1, int32 left, int32 right) {
int32 zones = 0;
int32 loc2 = current.location;
int32 s = current.sequence;
if(!(loc1 & LOCATION_ONFIELD) || !(loc2 & LOCATION_ONFIELD) || loc2 == LOCATION_SZONE && s >=5 || left < 0 || right < 0)
return 0;
if(s <= 4) {
if(loc1 != loc2)
zones |= 1u << s;
zones |= 1u << (16 + (4 - s));
if(loc1 & LOCATION_MZONE) {
if(s == 1)
zones |= (1u << 5) | (1u << (16 + 6));
if(s == 3)
zones |= (1u << 6) | (1u << (16 + 5));
}
}
if(s == 5)
zones |= (1u << 1) | (1u << (16 + 3));
if(s == 6)
zones |= (1u << 3) | (1u << (16 + 1));
for (int32 i = 1; i <= left; ++i) {
int32 seq = s - i;
if(seq >= 0) {
if(seq <= 4) {
zones |= 1u << seq | 1u << (16 + (4 - seq));
if(loc1 & LOCATION_MZONE) {
if(seq == 1)
zones |= (1u << 5) | (1u << (16 + 6));
if(seq == 3)
zones |= (1u << 6) | (1u << (16 + 5));
}
}
if(seq == 5)
zones |= (1u << 1) | (1u << (16 + 3));
if(seq == 6)
zones |= (1u << 3) | (1u << (16 + 1));
}
}
for (int32 i = 1; i <= right; ++i) {
int32 seq = s + i;
if(seq <= 6) {
if(seq <= 4) {
zones |= 1u << seq | 1u << (16 + (4 - seq));
if(loc1 & LOCATION_MZONE) {
if(seq == 1)
zones |= (1u << 5) | (1u << (16 + 6));
if(seq == 3)
zones |= (1u << 6) | (1u << (16 + 5));
}
}
if(seq == 5)
zones |= (1u << 1) | (1u << (16 + 3));
if(seq == 6)
zones |= (1u << 3) | (1u << (16 + 1));
}
}
return zones;
}
void card::get_column_cards(card_set* cset, int32 left, int32 right) {
cset->clear();
if(!(current.location & LOCATION_ONFIELD))
return;
int32 p = current.controler;
uint32 column_mzone = get_column_zone(LOCATION_MZONE, left, right);
uint32 column_szone = get_column_zone(LOCATION_SZONE, left, right);
pduel->game_field->get_cards_in_zone(cset, column_mzone, p, LOCATION_MZONE);
pduel->game_field->get_cards_in_zone(cset, column_mzone >> 16, 1 - p, LOCATION_MZONE);
pduel->game_field->get_cards_in_zone(cset, column_szone, p, LOCATION_SZONE);
pduel->game_field->get_cards_in_zone(cset, column_szone >> 16, 1 - p, LOCATION_SZONE);
}
int32 card::is_all_column() {
if(!(current.location & LOCATION_ONFIELD))
return FALSE;
card_set cset;
get_column_cards(&cset, 0, 0);
int32 full = 3;
if(pduel->game_field->core.duel_rule >= 4 && (current.sequence == 1 || current.sequence == 3))
full++;
if(cset.size() == full)
return TRUE;
return FALSE;
}
void card::equip(card *target, uint32 send_msg) { void card::equip(card *target, uint32 send_msg) {
if (equiping_target) if (equiping_target)
return; return;
......
...@@ -126,6 +126,7 @@ public: ...@@ -126,6 +126,7 @@ public:
uint8 announce_count; uint8 announce_count;
uint8 attacked_count; uint8 attacked_count;
uint8 attack_all_target; uint8 attack_all_target;
uint8 attack_controler;
uint16 cardid; uint16 cardid;
uint32 fieldid; uint32 fieldid;
uint32 fieldid_r; uint32 fieldid_r;
...@@ -201,11 +202,15 @@ public: ...@@ -201,11 +202,15 @@ public:
uint32 get_linked_zone(); uint32 get_linked_zone();
void get_linked_cards(card_set* cset); void get_linked_cards(card_set* cset);
uint32 get_mutual_linked_zone(); uint32 get_mutual_linked_zone();
void get_mutual_linked_cards(card_set * cset);
int32 is_link_state(); int32 is_link_state();
int32 is_position(int32 pos); int32 is_position(int32 pos);
void set_status(uint32 status, int32 enabled); void set_status(uint32 status, int32 enabled);
int32 get_status(uint32 status); int32 get_status(uint32 status);
int32 is_status(uint32 status); int32 is_status(uint32 status);
uint32 get_column_zone(int32 loc1, int32 left, int32 right);
void get_column_cards(card_set* cset, int32 left, int32 right);
int32 is_all_column();
void equip(card *target, uint32 send_msg = TRUE); void equip(card *target, uint32 send_msg = TRUE);
void unequip(); void unequip();
......
...@@ -515,18 +515,18 @@ int32 effect::is_chainable(uint8 tp) { ...@@ -515,18 +515,18 @@ int32 effect::is_chainable(uint8 tp) {
} else if(sp < pduel->game_field->core.current_chain.rbegin()->triggering_effect->get_speed()) } else if(sp < pduel->game_field->core.current_chain.rbegin()->triggering_effect->get_speed())
return FALSE; return FALSE;
} }
if(pduel->game_field->core.chain_limit) { for(auto it = pduel->game_field->core.chain_limit.begin(); it != pduel->game_field->core.chain_limit.end(); ++it) {
pduel->lua->add_param(this, PARAM_TYPE_EFFECT); pduel->lua->add_param(this, PARAM_TYPE_EFFECT);
pduel->lua->add_param(pduel->game_field->core.chain_limp, PARAM_TYPE_INT); pduel->lua->add_param(it->player, PARAM_TYPE_INT);
pduel->lua->add_param(tp, PARAM_TYPE_INT); pduel->lua->add_param(tp, PARAM_TYPE_INT);
if(!pduel->lua->check_condition(pduel->game_field->core.chain_limit, 3)) if(!pduel->lua->check_condition(it->function, 3))
return FALSE; return FALSE;
} }
if(pduel->game_field->core.chain_limit_p) { for(auto it = pduel->game_field->core.chain_limit_p.begin(); it != pduel->game_field->core.chain_limit_p.end(); ++it) {
pduel->lua->add_param(this, PARAM_TYPE_EFFECT); pduel->lua->add_param(this, PARAM_TYPE_EFFECT);
pduel->lua->add_param(pduel->game_field->core.chain_limp_p, PARAM_TYPE_INT); pduel->lua->add_param(it->player, PARAM_TYPE_INT);
pduel->lua->add_param(tp, PARAM_TYPE_INT); pduel->lua->add_param(tp, PARAM_TYPE_INT);
if(!pduel->lua->check_condition(pduel->game_field->core.chain_limit_p, 3)) if(!pduel->lua->check_condition(it->function, 3))
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
......
...@@ -72,8 +72,8 @@ field::field(duel* pduel) { ...@@ -72,8 +72,8 @@ field::field(duel* pduel) {
core.summoning_card = 0; core.summoning_card = 0;
core.summon_depth = 0; core.summon_depth = 0;
core.summon_cancelable = FALSE; core.summon_cancelable = FALSE;
core.chain_limit = 0; core.chain_limit.clear();
core.chain_limit_p = 0; core.chain_limit_p.clear();
core.chain_solving = FALSE; core.chain_solving = FALSE;
core.conti_solving = FALSE; core.conti_solving = FALSE;
core.conti_player = PLAYER_NONE; core.conti_player = PLAYER_NONE;
...@@ -710,7 +710,7 @@ void field::get_linked_cards(uint8 self, uint8 s, uint8 o, card_set* cset) { ...@@ -710,7 +710,7 @@ void field::get_linked_cards(uint8 self, uint8 s, uint8 o, card_set* cset) {
for(int32 p = 0; p < 2; ++p) { for(int32 p = 0; p < 2; ++p) {
if(c) { if(c) {
uint32 linked_zone = get_linked_zone(self); uint32 linked_zone = get_linked_zone(self);
get_cards_in_zone(cset, linked_zone, self); get_cards_in_zone(cset, linked_zone, self, LOCATION_MZONE);
} }
self = 1 - self; self = 1 - self;
c = o; c = o;
...@@ -773,9 +773,12 @@ int32 field::check_extra_link(int32 playerid, card* pcard, int32 sequence) { ...@@ -773,9 +773,12 @@ int32 field::check_extra_link(int32 playerid, card* pcard, int32 sequence) {
pcard->current.sequence = cur_sequence; pcard->current.sequence = cur_sequence;
return ret; return ret;
} }
void field::get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid) { void field::get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid, int32 location) {
if(!(location & LOCATION_ONFIELD))
return;
card_vector& svector = (location == LOCATION_MZONE) ? player[playerid].list_mzone : player[playerid].list_szone;
uint32 icheck = 0x1; uint32 icheck = 0x1;
for(auto it = player[playerid].list_mzone.begin(); it != player[playerid].list_mzone.end(); ++it) { for(auto it = svector.begin(); it != svector.end(); ++it) {
if(zone & icheck) { if(zone & icheck) {
card* pcard = *it; card* pcard = *it;
if(pcard) if(pcard)
...@@ -2440,7 +2443,7 @@ int32 field::check_tuner_material(card* pcard, card* tuner, int32 findex1, int32 ...@@ -2440,7 +2443,7 @@ int32 field::check_tuner_material(card* pcard, card* tuner, int32 findex1, int32
card_set linked_cards; card_set linked_cards;
if(ct <= 0) { if(ct <= 0) {
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f; uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone, playerid); get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE);
if(linked_cards.find(tuner) != linked_cards.end()) if(linked_cards.find(tuner) != linked_cards.end())
ct++; ct++;
} }
...@@ -2741,7 +2744,7 @@ int32 field::check_xyz_material(card* scard, int32 findex, int32 lv, int32 min, ...@@ -2741,7 +2744,7 @@ int32 field::check_xyz_material(card* scard, int32 findex, int32 lv, int32 min,
if(ct <= 0) { if(ct <= 0) {
int32 ft = ct; int32 ft = ct;
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f; uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone, playerid); get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE);
for(auto cit = core.xmaterial_lst.begin(); cit != core.xmaterial_lst.end(); ++cit) { for(auto cit = core.xmaterial_lst.begin(); cit != core.xmaterial_lst.end(); ++cit) {
card* pcard = cit->second; card* pcard = cit->second;
if(linked_cards.find(pcard) != linked_cards.end()) if(linked_cards.find(pcard) != linked_cards.end())
...@@ -3182,6 +3185,16 @@ int32 field::check_chain_target(uint8 chaincount, card * pcard) { ...@@ -3182,6 +3185,16 @@ int32 field::check_chain_target(uint8 chaincount, card * pcard) {
pduel->lua->add_param(pcard, PARAM_TYPE_CARD); pduel->lua->add_param(pcard, PARAM_TYPE_CARD);
return pduel->lua->check_condition(peffect->target, 10); return pduel->lua->check_condition(peffect->target, 10);
} }
chain* field::get_chain(uint32 chaincount) {
if(chaincount == 0 && core.continuous_chain.size() && (core.reason_effect->type & EFFECT_TYPE_CONTINUOUS))
return &core.continuous_chain.back();
if(chaincount == 0 || chaincount > core.current_chain.size()) {
chaincount = core.current_chain.size();
if(chaincount == 0)
return 0;
}
return &core.current_chain[chaincount - 1];
}
int32 field::is_able_to_enter_bp() { int32 field::is_able_to_enter_bp() {
return ((core.duel_options & DUEL_ATTACK_FIRST_TURN) || infos.turn_id != 1) return ((core.duel_options & DUEL_ATTACK_FIRST_TURN) || infos.turn_id != 1)
&& infos.phase < PHASE_BATTLE_START && infos.phase < PHASE_BATTLE_START
......
...@@ -155,6 +155,12 @@ struct processor { ...@@ -155,6 +155,12 @@ struct processor {
typedef std::list<processor_unit> processor_list; typedef std::list<processor_unit> processor_list;
typedef std::set<card*, card_sort> card_set; typedef std::set<card*, card_sort> card_set;
typedef std::set<std::pair<effect*, tevent> > delayed_effect_collection; typedef std::set<std::pair<effect*, tevent> > delayed_effect_collection;
struct chain_limit_t {
chain_limit_t(int32 f, int32 p): function(f), player(p) {}
int32 function;
int32 player;
};
typedef std::vector<chain_limit_t> chain_limit_list;
processor_list units; processor_list units;
processor_list subunits; processor_list subunits;
...@@ -233,10 +239,8 @@ struct processor { ...@@ -233,10 +239,8 @@ struct processor {
uint32 global_flag; uint32 global_flag;
uint16 pre_field[2]; uint16 pre_field[2];
uint16 opp_mzone[7]; uint16 opp_mzone[7];
int32 chain_limit; chain_limit_list chain_limit;
uint8 chain_limp; chain_limit_list chain_limit_p;
int32 chain_limit_p;
uint8 chain_limp_p;
uint8 chain_solving; uint8 chain_solving;
uint8 conti_solving; uint8 conti_solving;
uint8 win_player; uint8 win_player;
...@@ -354,7 +358,7 @@ public: ...@@ -354,7 +358,7 @@ public:
void get_linked_cards(uint8 self, uint8 s, uint8 o, card_set* cset); void get_linked_cards(uint8 self, uint8 s, uint8 o, card_set* cset);
int32 check_extra_link(int32 playerid); int32 check_extra_link(int32 playerid);
int32 check_extra_link(int32 playerid, card* pcard, int32 sequence); int32 check_extra_link(int32 playerid, card* pcard, int32 sequence);
void get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid); void get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid, int32 location);
void shuffle(uint8 playerid, uint8 location); void shuffle(uint8 playerid, uint8 location);
void reset_sequence(uint8 playerid, uint8 location); void reset_sequence(uint8 playerid, uint8 location);
void swap_deck_and_grave(uint8 playerid); void swap_deck_and_grave(uint8 playerid);
...@@ -446,6 +450,7 @@ public: ...@@ -446,6 +450,7 @@ public:
int32 is_chain_disablable(uint8 chaincount); int32 is_chain_disablable(uint8 chaincount);
int32 is_chain_disabled(uint8 chaincount); int32 is_chain_disabled(uint8 chaincount);
int32 check_chain_target(uint8 chaincount, card* pcard); int32 check_chain_target(uint8 chaincount, card* pcard);
chain* get_chain(uint32 chaincount);
int32 is_able_to_enter_bp(); int32 is_able_to_enter_bp();
void add_process(uint16 type, uint16 step, effect* peffect, group* target, ptr arg1, ptr arg2, ptr arg3 = 0, ptr arg4 = 0, void* ptr1 = NULL, void* ptr2 = NULL); void add_process(uint16 type, uint16 step, effect* peffect, group* target, ptr arg1, ptr arg2, ptr arg3 = 0, ptr arg4 = 0, void* ptr1 = NULL, void* ptr2 = NULL);
...@@ -543,6 +548,7 @@ public: ...@@ -543,6 +548,7 @@ public:
int32 move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, uint32 is_equip, uint32 zone); int32 move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, uint32 is_equip, uint32 zone);
int32 change_position(uint16 step, group* targets, effect* reason_effect, uint8 reason_player, uint32 enable); int32 change_position(uint16 step, group* targets, effect* reason_effect, uint8 reason_player, uint32 enable);
int32 operation_replace(uint16 step, effect* replace_effect, group* targets, card* arg, ptr replace_type); int32 operation_replace(uint16 step, effect* replace_effect, group* targets, card* arg, ptr replace_type);
int32 activate_effect(uint16 step, effect* peffect);
int32 select_synchro_material(int16 step, uint8 playerid, card* pcard, int32 min, int32 max, card* smat, group* mg); int32 select_synchro_material(int16 step, uint8 playerid, card* pcard, int32 min, int32 max, card* smat, group* mg);
int32 select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* pcard, int32 min, int32 max); int32 select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* pcard, int32 min, int32 max);
int32 select_release_cards(int16 step, uint8 playerid, uint8 check_field, uint8 cancelable, int32 min, int32 max); int32 select_release_cards(int16 step, uint8 playerid, uint8 check_field, uint8 cancelable, int32 min, int32 max);
...@@ -553,7 +559,7 @@ public: ...@@ -553,7 +559,7 @@ public:
int32 select_battle_command(uint16 step, uint8 playerid); int32 select_battle_command(uint16 step, uint8 playerid);
int32 select_idle_command(uint16 step, uint8 playerid); int32 select_idle_command(uint16 step, uint8 playerid);
int32 select_effect_yes_no(uint16 step, uint8 playerid, card* pcard); int32 select_effect_yes_no(uint16 step, uint8 playerid, uint32 description, card* pcard);
int32 select_yes_no(uint16 step, uint8 playerid, uint32 description); int32 select_yes_no(uint16 step, uint8 playerid, uint32 description);
int32 select_option(uint16 step, uint8 playerid); int32 select_option(uint16 step, uint8 playerid);
int32 select_card(uint16 step, uint8 playerid, uint8 cancelable, uint8 min, uint8 max); int32 select_card(uint16 step, uint8 playerid, uint8 cancelable, uint8 min, uint8 max);
...@@ -577,6 +583,7 @@ public: ...@@ -577,6 +583,7 @@ public:
#define CHAIN_DISABLE_ACTIVATE 0x01 #define CHAIN_DISABLE_ACTIVATE 0x01
#define CHAIN_DISABLE_EFFECT 0x02 #define CHAIN_DISABLE_EFFECT 0x02
#define CHAIN_HAND_EFFECT 0x04 #define CHAIN_HAND_EFFECT 0x04
#define CHAIN_CONTINUOUS_CARD 0x08
#define CHAININFO_CHAIN_COUNT 0x01 #define CHAININFO_CHAIN_COUNT 0x01
#define CHAININFO_TRIGGERING_EFFECT 0x02 #define CHAININFO_TRIGGERING_EFFECT 0x02
#define CHAININFO_TRIGGERING_PLAYER 0x04 #define CHAININFO_TRIGGERING_PLAYER 0x04
...@@ -698,6 +705,7 @@ public: ...@@ -698,6 +705,7 @@ public:
#define PROCESSOR_PAY_LPCOST 80 #define PROCESSOR_PAY_LPCOST 80
#define PROCESSOR_REMOVE_COUNTER 81 #define PROCESSOR_REMOVE_COUNTER 81
#define PROCESSOR_ATTACK_DISABLE 82 #define PROCESSOR_ATTACK_DISABLE 82
#define PROCESSOR_ACTIVATE_EFFECT 83
#define PROCESSOR_DESTROY_S 100 #define PROCESSOR_DESTROY_S 100
#define PROCESSOR_RELEASE_S 101 #define PROCESSOR_RELEASE_S 101
......
...@@ -47,7 +47,13 @@ static const struct luaL_Reg cardlib[] = { ...@@ -47,7 +47,13 @@ static const struct luaL_Reg cardlib[] = {
{ "GetLinkedGroup", scriptlib::card_get_linked_group }, { "GetLinkedGroup", scriptlib::card_get_linked_group },
{ "GetLinkedGroupCount", scriptlib::card_get_linked_group_count }, { "GetLinkedGroupCount", scriptlib::card_get_linked_group_count },
{ "GetLinkedZone", scriptlib::card_get_linked_zone }, { "GetLinkedZone", scriptlib::card_get_linked_zone },
{ "GetMutualLinkedGroup", scriptlib::card_get_mutual_linked_group },
{ "GetMutualLinkedGroupCount", scriptlib::card_get_mutual_linked_group_count },
{ "GetMutualLinkedZone", scriptlib::card_get_mutual_linked_zone },
{ "IsLinkState", scriptlib::card_is_link_state }, { "IsLinkState", scriptlib::card_is_link_state },
{ "GetColumnGroup", scriptlib::card_get_column_group },
{ "GetColumnGroupCount", scriptlib::card_get_column_group_count },
{ "IsAllColumn", scriptlib::card_is_all_column },
{ "GetAttribute", scriptlib::card_get_attribute }, { "GetAttribute", scriptlib::card_get_attribute },
{ "GetOriginalAttribute", scriptlib::card_get_origin_attribute }, { "GetOriginalAttribute", scriptlib::card_get_origin_attribute },
{ "GetFusionAttribute", scriptlib::card_get_fusion_attribute }, { "GetFusionAttribute", scriptlib::card_get_fusion_attribute },
...@@ -371,6 +377,7 @@ static const struct luaL_Reg duellib[] = { ...@@ -371,6 +377,7 @@ static const struct luaL_Reg duellib[] = {
{ "ReturnToField", scriptlib::duel_return_to_field }, { "ReturnToField", scriptlib::duel_return_to_field },
{ "MoveSequence", scriptlib::duel_move_sequence }, { "MoveSequence", scriptlib::duel_move_sequence },
{ "SwapSequence", scriptlib::duel_swap_sequence }, { "SwapSequence", scriptlib::duel_swap_sequence },
{ "Activate", scriptlib::duel_activate_effect },
{ "SetChainLimit", scriptlib::duel_set_chain_limit }, { "SetChainLimit", scriptlib::duel_set_chain_limit },
{ "SetChainLimitTillChainEnd", scriptlib::duel_set_chain_limit_p }, { "SetChainLimitTillChainEnd", scriptlib::duel_set_chain_limit_p },
{ "GetChainMaterial", scriptlib::duel_get_chain_material }, { "GetChainMaterial", scriptlib::duel_get_chain_material },
......
...@@ -311,6 +311,32 @@ int32 scriptlib::card_get_linked_zone(lua_State *L) { ...@@ -311,6 +311,32 @@ int32 scriptlib::card_get_linked_zone(lua_State *L) {
lua_pushinteger(L, pcard->get_linked_zone()); lua_pushinteger(L, pcard->get_linked_zone());
return 1; return 1;
} }
int32 scriptlib::card_get_mutual_linked_group(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**)lua_touserdata(L, 1);
card::card_set cset;
pcard->get_mutual_linked_cards(&cset);
group* pgroup = pcard->pduel->new_group(cset);
interpreter::group2value(L, pgroup);
return 1;
}
int32 scriptlib::card_get_mutual_linked_group_count(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**)lua_touserdata(L, 1);
card::card_set cset;
pcard->get_mutual_linked_cards(&cset);
lua_pushinteger(L, cset.size());
return 1;
}
int32 scriptlib::card_get_mutual_linked_zone(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**)lua_touserdata(L, 1);
lua_pushinteger(L, pcard->get_mutual_linked_zone());
return 1;
}
int32 scriptlib::card_is_link_state(lua_State *L) { int32 scriptlib::card_is_link_state(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
...@@ -318,6 +344,44 @@ int32 scriptlib::card_is_link_state(lua_State *L) { ...@@ -318,6 +344,44 @@ int32 scriptlib::card_is_link_state(lua_State *L) {
lua_pushboolean(L, pcard->is_link_state()); lua_pushboolean(L, pcard->is_link_state());
return 1; return 1;
} }
int32 scriptlib::card_get_column_group(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
int32 left = 0;
int32 right = 0;
if(lua_gettop(L) >= 2)
left = lua_tointeger(L, 2);
if(lua_gettop(L) >= 3)
right = lua_tointeger(L, 3);
card::card_set cset;
pcard->get_column_cards(&cset, left, right);
group* pgroup = pcard->pduel->new_group(cset);
interpreter::group2value(L, pgroup);
return 1;
}
int32 scriptlib::card_get_column_group_count(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
int32 left = 0;
int32 right = 0;
if(lua_gettop(L) >= 2)
left = lua_tointeger(L, 2);
if(lua_gettop(L) >= 3)
right = lua_tointeger(L, 3);
card::card_set cset;
pcard->get_column_cards(&cset, left, right);
lua_pushinteger(L, cset.size());
return 1;
}
int32 scriptlib::card_is_all_column(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
lua_pushboolean(L, pcard->is_all_column());
return 1;
}
int32 scriptlib::card_get_attribute(lua_State *L) { int32 scriptlib::card_get_attribute(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
...@@ -2553,7 +2617,7 @@ int32 scriptlib::card_check_mzone_from_ex(lua_State *L) { ...@@ -2553,7 +2617,7 @@ int32 scriptlib::card_check_mzone_from_ex(lua_State *L) {
duel* pduel = pcard->pduel; duel* pduel = pcard->pduel;
field::card_set linked_cards; field::card_set linked_cards;
uint32 linked_zone = pduel->game_field->core.duel_rule >= 4 ? pduel->game_field->get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f; uint32 linked_zone = pduel->game_field->core.duel_rule >= 4 ? pduel->game_field->get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
pduel->game_field->get_cards_in_zone(&linked_cards, linked_zone, playerid); pduel->game_field->get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE);
if(linked_cards.find(pcard) != linked_cards.end()) if(linked_cards.find(pcard) != linked_cards.end())
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
else else
......
...@@ -40,9 +40,14 @@ int32 scriptlib::debug_add_card(lua_State *L) { ...@@ -40,9 +40,14 @@ int32 scriptlib::debug_add_card(lua_State *L) {
card* pcard = pduel->new_card(code); card* pcard = pduel->new_card(code);
pcard->owner = owner; pcard->owner = owner;
pcard->operation_param = position << 24; pcard->operation_param = position << 24;
pduel->game_field->add_card(playerid, pcard, location, sequence); if(location == LOCATION_PZONE) {
int32 seq = pduel->game_field->core.duel_rule >= 4 ? sequence * 4 : sequence + 6;
pduel->game_field->add_card(playerid, pcard, LOCATION_SZONE, seq, TRUE);
} else {
pduel->game_field->add_card(playerid, pcard, location, sequence);
}
pcard->current.position = position; pcard->current.position = position;
if(!(location & LOCATION_ONFIELD) || (position & POS_FACEUP)) { if(!(location & (LOCATION_ONFIELD + LOCATION_PZONE)) || (position & POS_FACEUP)) {
pcard->enable_field_effect(true); pcard->enable_field_effect(true);
pduel->game_field->adjust_instant(); pduel->game_field->adjust_instant();
} }
......
This diff is collapsed.
...@@ -44,15 +44,10 @@ byte* default_script_reader(const char* script_name, int* slen) { ...@@ -44,15 +44,10 @@ byte* default_script_reader(const char* script_name, int* slen) {
fp = fopen(script_name, "rb"); fp = fopen(script_name, "rb");
if (!fp) if (!fp)
return 0; return 0;
fseek(fp, 0, SEEK_END); int len = fread(buffer, 1, sizeof(buffer), fp);
uint32 len = ftell(fp);
if (len > sizeof(buffer)) {
fclose(fp);
return 0;
}
fseek(fp, 0, SEEK_SET);
fread(buffer, len, 1, fp);
fclose(fp); fclose(fp);
if(len >= sizeof(buffer))
return 0;
*slen = len; *slen = len;
return buffer; return buffer;
} }
......
...@@ -4606,6 +4606,48 @@ int32 field::operation_replace(uint16 step, effect * replace_effect, group * tar ...@@ -4606,6 +4606,48 @@ int32 field::operation_replace(uint16 step, effect * replace_effect, group * tar
} }
return TRUE; return TRUE;
} }
int32 field::activate_effect(uint16 step, effect* peffect) {
switch(step) {
case 0: {
card* phandler = peffect->get_handler();
int32 playerid = phandler->current.controler;
nil_event.event_code = EVENT_FREE_CHAIN;
if(!peffect->is_activateable(playerid, nil_event))
return TRUE;
chain newchain;
newchain.flag = 0;
newchain.chain_id = infos.field_id++;
newchain.evt.event_code = peffect->code;
newchain.evt.event_player = PLAYER_NONE;
newchain.evt.event_value = 0;
newchain.evt.event_cards = 0;
newchain.evt.reason = 0;
newchain.evt.reason_effect = 0;
newchain.evt.reason_player = PLAYER_NONE;
newchain.triggering_effect = peffect;
newchain.set_triggering_place(phandler);
newchain.triggering_player = playerid;
core.new_chains.push_back(newchain);
phandler->set_status(STATUS_CHAINING, TRUE);
peffect->dec_count(playerid);
add_process(PROCESSOR_ADD_CHAIN, 0, 0, 0, 0, 0);
add_process(PROCESSOR_QUICK_EFFECT, 0, 0, 0, FALSE, 1 - playerid);
infos.priorities[0] = 0;
infos.priorities[1] = 0;
return FALSE;
}
case 1: {
for(auto it = core.chain_limit.begin(); it != core.chain_limit.end(); ++it)
luaL_unref(pduel->lua->lua_state, LUA_REGISTRYINDEX, it->function);
core.chain_limit.clear();
for(auto cait = core.current_chain.begin(); cait != core.current_chain.end(); ++cait)
cait->triggering_effect->get_handler()->set_status(STATUS_CHAINING, FALSE);
add_process(PROCESSOR_SOLVE_CHAIN, 0, 0, 0, FALSE, 0);
return TRUE;
}
}
return TRUE;
}
int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, int32 min, int32 max, card* smat, group* mg) { int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, int32 min, int32 max, card* smat, group* mg) {
switch(step) { switch(step) {
case 0: { case 0: {
...@@ -4811,7 +4853,7 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in ...@@ -4811,7 +4853,7 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in
} }
card_set linked_cards; card_set linked_cards;
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f; uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone, playerid); get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE);
if(linked_cards.find(tuner) != linked_cards.end()) if(linked_cards.find(tuner) != linked_cards.end())
ct++; ct++;
if(smat && linked_cards.find(smat) != linked_cards.end()) if(smat && linked_cards.find(smat) != linked_cards.end())
...@@ -4979,7 +5021,7 @@ int32 field::select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* sc ...@@ -4979,7 +5021,7 @@ int32 field::select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* sc
card_set linked_cards; card_set linked_cards;
if(ct <= 0) { if(ct <= 0) {
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f; uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone, playerid); get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE);
} }
for(auto cit = core.xmaterial_lst.begin(); cit != core.xmaterial_lst.end(); ++cit) for(auto cit = core.xmaterial_lst.begin(); cit != core.xmaterial_lst.end(); ++cit)
cit->second->sum_param = 0; cit->second->sum_param = 0;
...@@ -5047,7 +5089,7 @@ int32 field::select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* sc ...@@ -5047,7 +5089,7 @@ int32 field::select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* sc
} }
card_set linked_cards; card_set linked_cards;
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f; uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone, playerid); get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE);
int32 mmax = 0; int32 mmax = 0;
core.select_cards.clear(); core.select_cards.clear();
for(auto iter = core.xmaterial_lst.begin(); iter != core.xmaterial_lst.end(); ++iter) { for(auto iter = core.xmaterial_lst.begin(); iter != core.xmaterial_lst.end(); ++iter) {
...@@ -5223,7 +5265,7 @@ int32 field::select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* sc ...@@ -5223,7 +5265,7 @@ int32 field::select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* sc
return FALSE; return FALSE;
card_set linked_cards; card_set linked_cards;
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f; uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone, playerid); get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE);
core.select_cards.clear(); core.select_cards.clear();
for(auto iter = core.xmaterial_lst.begin(); iter != core.xmaterial_lst.end(); ++iter) { for(auto iter = core.xmaterial_lst.begin(); iter != core.xmaterial_lst.end(); ++iter) {
card* pcard = iter->second; card* pcard = iter->second;
......
...@@ -165,7 +165,7 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) { ...@@ -165,7 +165,7 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) {
return TRUE; return TRUE;
} }
} }
int32 field::select_effect_yes_no(uint16 step, uint8 playerid, card* pcard) { int32 field::select_effect_yes_no(uint16 step, uint8 playerid, uint32 description, card* pcard) {
if(step == 0) { if(step == 0) {
if((playerid == 1) && (core.duel_options & DUEL_SIMPLE_AI)) { if((playerid == 1) && (core.duel_options & DUEL_SIMPLE_AI)) {
returns.ivalue[0] = 1; returns.ivalue[0] = 1;
...@@ -175,6 +175,7 @@ int32 field::select_effect_yes_no(uint16 step, uint8 playerid, card* pcard) { ...@@ -175,6 +175,7 @@ int32 field::select_effect_yes_no(uint16 step, uint8 playerid, card* pcard) {
pduel->write_buffer8(playerid); pduel->write_buffer8(playerid);
pduel->write_buffer32(pcard->data.code); pduel->write_buffer32(pcard->data.code);
pduel->write_buffer32(pcard->get_info_location()); pduel->write_buffer32(pcard->get_info_location());
pduel->write_buffer32(description);
returns.ivalue[0] = -1; returns.ivalue[0] = -1;
return FALSE; return FALSE;
} else { } else {
......
This diff is collapsed.
...@@ -49,7 +49,13 @@ public: ...@@ -49,7 +49,13 @@ public:
static int32 card_get_linked_group(lua_State *L); static int32 card_get_linked_group(lua_State *L);
static int32 card_get_linked_group_count(lua_State *L); static int32 card_get_linked_group_count(lua_State *L);
static int32 card_get_linked_zone(lua_State *L); static int32 card_get_linked_zone(lua_State *L);
static int32 card_get_mutual_linked_group(lua_State *L);
static int32 card_get_mutual_linked_group_count(lua_State *L);
static int32 card_get_mutual_linked_zone(lua_State *L);
static int32 card_is_link_state(lua_State *L); static int32 card_is_link_state(lua_State *L);
static int32 card_get_column_group(lua_State *L);
static int32 card_get_column_group_count(lua_State *L);
static int32 card_is_all_column(lua_State *L);
static int32 card_get_attribute(lua_State *L); static int32 card_get_attribute(lua_State *L);
static int32 card_get_origin_attribute(lua_State *L); static int32 card_get_origin_attribute(lua_State *L);
static int32 card_get_fusion_attribute(lua_State *L); static int32 card_get_fusion_attribute(lua_State *L);
...@@ -367,6 +373,7 @@ public: ...@@ -367,6 +373,7 @@ public:
static int32 duel_return_to_field(lua_State *L); static int32 duel_return_to_field(lua_State *L);
static int32 duel_move_sequence(lua_State *L); static int32 duel_move_sequence(lua_State *L);
static int32 duel_swap_sequence(lua_State *L); static int32 duel_swap_sequence(lua_State *L);
static int32 duel_activate_effect(lua_State *L);
static int32 duel_set_chain_limit(lua_State *L); static int32 duel_set_chain_limit(lua_State *L);
static int32 duel_set_chain_limit_p(lua_State *L); static int32 duel_set_chain_limit_p(lua_State *L);
static int32 duel_get_chain_material(lua_State *L); static int32 duel_get_chain_material(lua_State *L);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment