Commit 4daa60d0 authored by argon's avatar argon

update

parent dee0ee0d
......@@ -9,6 +9,7 @@
#include <WinSock2.h>
#include <windows.h>
#include <ws2tcpip.h>
#ifdef _MSC_VER
#define myswprintf _swprintf
......
......@@ -427,7 +427,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
case LOCATION_MZONE: {
ClientCard* pcard = mzone[command_controler][command_sequence];
for(int32 i = 0; i < pcard->overlayed.size(); ++i)
for(int32 i = 0; i < (int32)pcard->overlayed.size(); ++i)
selectable_cards.push_back(pcard->overlayed[i]);
myswprintf(formatBuffer, L"%ls(%d)", dataManager.GetSysString(1007), pcard->overlayed.size());
mainGame->wCardSelect->setText(formatBuffer);
......@@ -861,7 +861,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
case LOCATION_MZONE: {
ClientCard* pcard = deck[hovered_controler][hovered_sequence];
for(int32 i = 0; i < pcard->overlayed.size(); ++i)
for(int32 i = 0; i < (int32)pcard->overlayed.size(); ++i)
selectable_cards.push_back(pcard->overlayed[i]);
myswprintf(formatBuffer, L"%ls(%d)", dataManager.GetSysString(1007), pcard->overlayed.size());
mainGame->wCardSelect->setText(formatBuffer);
......
......@@ -61,6 +61,8 @@ card::card() {
memset(&temp, 0xff, sizeof(card_state));
unique_pos[0] = unique_pos[1] = 0;
unique_code = 0;
assume_type = 0;
assume_value = 0;
current.controler = PLAYER_NONE;
}
card::~card() {
......@@ -195,6 +197,8 @@ uint32 card::get_info_location() {
}
}
uint32 card::get_code() {
if(assume_type == ASSUME_CODE)
return assume_value;
if(!(current.location & 0x1c)) {
if(data.alias)
return data.alias;
......@@ -239,6 +243,8 @@ int32 card::is_set_card(uint32 set_code) {
return FALSE;
}
uint32 card::get_type() {
if(assume_type == ASSUME_TYPE)
return assume_value;
if(!(current.location & 0x1e))
return data.type;
if (temp.type != 0xffffffff)
......@@ -286,6 +292,8 @@ int32 card::get_base_attack(uint8 swap) {
return batk;
}
int32 card::get_attack(uint8 swap) {
if(assume_type == ASSUME_ATTACK)
return assume_value;
if (current.location != LOCATION_MZONE)
return data.attack;
if (temp.attack != -1)
......@@ -371,6 +379,8 @@ int32 card::get_base_defence(uint8 swap) {
return bdef;
}
int32 card::get_defence(uint8 swap) {
if(assume_type == ASSUME_DEFENCE)
return assume_value;
if (current.location != LOCATION_MZONE)
return data.defence;
if (temp.defence != -1)
......@@ -434,6 +444,8 @@ int32 card::get_defence(uint8 swap) {
uint32 card::get_level() {
if(data.type & TYPE_XYZ)
return 0;
if(assume_type == ASSUME_LEVEL)
return assume_value;
if(!(current.location & (LOCATION_MZONE + LOCATION_HAND)))
return data.level;
if (temp.level != 0xffffffff)
......@@ -465,7 +477,35 @@ uint32 card::get_level() {
uint32 card::get_rank() {
if(!(data.type & TYPE_XYZ))
return 0;
return data.level;
if(assume_type == ASSUME_RANK)
return assume_value;
if(!(current.location & LOCATION_MZONE))
return data.level;
if (temp.level != 0xffffffff)
return temp.level;
effect_set effects;
int32 rank = data.level;
temp.level = data.level;
int32 up = 0, upc = 0;
filter_effect(EFFECT_UPDATE_RANK, &effects, FALSE);
filter_effect(EFFECT_CHANGE_RANK, &effects);
for (int32 i = 0; i < effects.count; ++i) {
if (effects[i]->code == EFFECT_UPDATE_LEVEL) {
if ((effects[i]->type & EFFECT_TYPE_SINGLE) && !(effects[i]->flag & EFFECT_FLAG_SINGLE_RANGE))
up += effects[i]->get_value(this);
else
upc += effects[i]->get_value(this);
} else {
rank = effects[i]->get_value(this);
up = 0;
}
temp.level = rank;
}
rank += up + upc;
if(rank < 1 && (get_type() & TYPE_MONSTER))
rank = 1;
temp.level = 0xffffffff;
return rank;
}
uint32 card::get_synchro_level(card* pcard) {
if(data.type & TYPE_XYZ)
......@@ -504,6 +544,8 @@ uint32 card::is_xyz_level(card* pcard, uint32 lv) {
return ((lev & 0xffff) == lv) || ((lev >> 16) == lv);
}
uint32 card::get_attribute() {
if(assume_type == ASSUME_ATTRIBUTE)
return assume_value;
if(!(current.location & (LOCATION_MZONE + LOCATION_GRAVE)))
return data.attribute;
if((current.location == LOCATION_GRAVE) && (data.type & (TYPE_SPELL + TYPE_TRAP)))
......@@ -529,6 +571,8 @@ uint32 card::get_attribute() {
return attribute;
}
uint32 card::get_race() {
if(assume_type == ASSUME_RACE)
return assume_value;
if(!(current.location & (LOCATION_MZONE + LOCATION_GRAVE)))
return data.race;
if((current.location == LOCATION_GRAVE) && (data.type & (TYPE_SPELL + TYPE_TRAP)))
......@@ -899,7 +943,7 @@ int32 card::copy_effect(uint32 code, uint32 reset, uint32 count) {
}
void card::reset(uint32 id, uint32 reset_type) {
effect* peffect;
if (reset_type != RESET_EVENT && reset_type != RESET_PHASE && reset_type != RESET_CODE && reset_type != RESET_COPY)
if (reset_type != RESET_EVENT && reset_type != RESET_PHASE && reset_type != RESET_CODE && reset_type != RESET_COPY && reset_type != RESET_CARD)
return;
if (reset_type == RESET_EVENT) {
for (auto rit = relations.begin(); rit != relations.end();) {
......
......@@ -34,6 +34,7 @@ struct card_state {
uint32 code;
uint32 type;
uint32 level;
uint32 rank;
uint32 attribute;
uint32 race;
int32 attack;
......@@ -102,6 +103,8 @@ public:
uint8 unique_pos[2];
uint16 unique_uid;
uint32 unique_code;
uint8 assume_type;
uint32 assume_value;
effect* unique_effect;
card* equiping_target;
card* pre_equip_target;
......@@ -404,4 +407,12 @@ public:
#define QUERY_IS_DISABLED 0x80000
#define QUERY_IS_PUBLIC 0x100000
#define ASSUME_CODE 1
#define ASSUME_TYPE 2
#define ASSUME_LEVEL 3
#define ASSUME_RANK 4
#define ASSUME_ATTRIBUTE 5
#define ASSUME_RACE 6
#define ASSUME_ATTACK 7
#define ASSUME_DEFENCE 8
#endif /* CARD_H_ */
......@@ -104,6 +104,11 @@ void duel::release_script_group() {
}
sgroups.clear();
}
void duel::restore_assumes() {
for(auto pcard : assumes)
pcard->assume_type = 0;
assumes.clear();
}
void duel::write_buffer32(uint32 value) {
*((uint32*)bufferp) = value;
bufferp += 4;
......
......@@ -33,10 +33,12 @@ public:
field* game_field;
mtrandom random;
std::set<card*> cards;
std::set<card*> assumes;
std::set<group*> groups;
std::set<group*> sgroups;
std::set<effect*> effects;
std::set<effect*> uncopy;
duel();
~duel();
void clear();
......@@ -48,6 +50,7 @@ public:
void delete_group(group* pgroup);
void delete_effect(effect* peffect);
void release_script_group();
void restore_assumes();
int32 read_buffer(byte* buf);
void write_buffer32(uint32 value);
void write_buffer16(uint16 value);
......
......@@ -421,7 +421,7 @@ int32 effect::is_chainable(uint8 tp) {
}
int32 effect::reset(uint32 reset_level, uint32 reset_type) {
switch (reset_type) {
case RESET_EVENT:
case RESET_EVENT: {
if(!(reset_flag & RESET_EVENT))
return FALSE;
if(owner != handler)
......@@ -430,6 +430,11 @@ int32 effect::reset(uint32 reset_level, uint32 reset_type) {
return TRUE;
return FALSE;
break;
}
case RESET_CARD: {
return owner && (owner->data.code == reset_level);
break;
}
case RESET_PHASE: {
if(!(reset_flag & RESET_PHASE))
return FALSE;
......@@ -442,17 +447,15 @@ int32 effect::reset(uint32 reset_level, uint32 reset_type) {
return FALSE;
break;
}
case RESET_CODE:
if(code == reset_level && (type & EFFECT_TYPE_SINGLE) && !(type & EFFECT_TYPE_ACTIONS))
return TRUE;
return FALSE;
case RESET_CODE: {
return (code == reset_level) && (type & EFFECT_TYPE_SINGLE) && !(type & EFFECT_TYPE_ACTIONS);
break;
case RESET_COPY:
if(copy_id == reset_level)
return TRUE;
return FALSE;
}
case RESET_COPY: {
return copy_id == reset_level;
break;
}
}
return FALSE;
}
void effect::dec_count() {
......
......@@ -101,6 +101,7 @@ public:
#define RESET_PHASE 0x0400
#define RESET_CHAIN 0x0800
#define RESET_EVENT 0x1000
#define RESET_CARD 0x2000
#define RESET_CODE 0x4000
#define RESET_COPY 0x8000
......@@ -273,6 +274,8 @@ public:
#define EFFECT_CHANGE_ATTRIBUTE 127 //
#define EFFECT_UPDATE_LEVEL 130 //
#define EFFECT_CHANGE_LEVEL 131 //
#define EFFECT_UPDATE_RANK 132 //
#define EFFECT_CHANGE_RANK 133 //
#define EFFECT_SET_POSITION 140 //
#define EFFECT_SELF_DESTROY 141 //
#define EFFECT_DOUBLE_TRIBUTE 150
......@@ -347,6 +350,7 @@ public:
#define EFFECT_BP_TWICE 296
#define EFFECT_UNIQUE_CHECK 297
#define EFFECT_MATCH_KILL 300
#define EFFECT_SYNCHRO_ASSUME 310
#define EVENT_STARTUP 1000
#define EVENT_FLIP 1001
......
......@@ -1494,8 +1494,12 @@ int32 field::check_synchro_material(card* pcard, int32 findex1, int32 findex2, i
}
int32 field::check_tuner_material(card* pcard, card* tuner, int32 findex1, int32 findex2, int32 min, int32 max) {
effect* peffect;
if(tuner && tuner->is_position(POS_FACEUP) && (tuner->get_type()&TYPE_TUNER) && pduel->lua->check_matching(tuner, findex1, 0)
&& tuner->is_can_be_synchro_material(pcard)) {
effect* passume = tuner->is_affected_by_effect(EFFECT_SYNCHRO_ASSUME);
if(tuner && tuner->is_position(POS_FACEUP) && (tuner->get_type()&TYPE_TUNER) && tuner->is_can_be_synchro_material(pcard)) {
if(passume)
passume->get_value(tuner);
if(!pduel->lua->check_matching(tuner, findex1, 0))
return FALSE;
if((peffect = tuner->is_affected_by_effect(EFFECT_SYNCHRO_MATERIAL_CUSTOM, pcard))) {
if(!peffect->target)
return FALSE;
......
......@@ -37,6 +37,14 @@ static const struct luaL_Reg cardlib[] = {
{ "GetDefence", scriptlib::card_get_defence },
{ "GetBaseDefence", scriptlib::card_get_origin_defence },
{ "GetTextDefence", scriptlib::card_get_text_defence },
{ "GetPreviousCodeOnField", scriptlib::card_get_previous_code_onfield },
{ "GetPreviousTypeOnField", scriptlib::card_get_previous_type_onfield },
{ "GetPreviousLevelOnField", scriptlib::card_get_previous_level_onfield },
{ "GetPreviousRankOnField", scriptlib::card_get_previous_rank_onfield },
{ "GetPreviousAttributeOnField", scriptlib::card_get_previous_attribute_onfield },
{ "GetPreviousRaceOnField", scriptlib::card_get_previous_race_onfield },
{ "GetPreviousAttackOnField", scriptlib::card_get_previous_attack_onfield },
{ "GetPreviousDefenceOnField", scriptlib::card_get_previous_defence_onfield },
{ "GetOwner", scriptlib::card_get_owner },
{ "GetControler", scriptlib::card_get_controler },
{ "GetPreviousControler", scriptlib::card_get_previous_controler },
......@@ -192,6 +200,8 @@ static const struct luaL_Reg cardlib[] = {
{ "ReverseInDeck", scriptlib::card_reverse_in_deck },
{ "SetUniqueOnField", scriptlib::card_set_unique_onfield },
{ "CheckUniqueOnField", scriptlib::card_check_unique_onfield },
{ "ResetNegateEffect", scriptlib::card_reset_negate_effect },
{ "AssumeProperty", scriptlib::card_assume_prop },
{ NULL, NULL }
};
......@@ -750,14 +760,18 @@ int32 interpreter::call_function(int32 f, uint32 param_count, uint32 ret_count)
lua_pop(current_state, 1);
no_action--;
call_depth--;
if(call_depth == 0)
if(call_depth == 0) {
pduel->release_script_group();
pduel->restore_assumes();
}
return OPERATION_FAIL;
}
no_action--;
call_depth--;
if(call_depth == 0)
if(call_depth == 0) {
pduel->release_script_group();
pduel->restore_assumes();
}
return OPERATION_SUCCESS;
}
int32 interpreter::call_card_function(card* pcard, char* f, uint32 param_count, uint32 ret_count) {
......@@ -786,14 +800,18 @@ int32 interpreter::call_card_function(card* pcard, char* f, uint32 param_count,
lua_pop(current_state, 1);
no_action--;
call_depth--;
if(call_depth == 0)
if(call_depth == 0) {
pduel->release_script_group();
pduel->restore_assumes();
}
return OPERATION_FAIL;
}
no_action--;
call_depth--;
if(call_depth == 0)
if(call_depth == 0) {
pduel->release_script_group();
pduel->restore_assumes();
}
return OPERATION_SUCCESS;
}
int32 interpreter::call_code_function(uint32 code, char* f, uint32 param_count, uint32 ret_count) {
......@@ -822,14 +840,18 @@ int32 interpreter::call_code_function(uint32 code, char* f, uint32 param_count,
lua_pop(current_state, 1);
no_action--;
call_depth--;
if(call_depth == 0)
if(call_depth == 0) {
pduel->release_script_group();
pduel->restore_assumes();
}
return OPERATION_FAIL;
}
no_action--;
call_depth--;
if(call_depth == 0)
if(call_depth == 0) {
pduel->release_script_group();
pduel->restore_assumes();
}
return OPERATION_SUCCESS;
}
int32 interpreter::check_condition(int32 f, uint32 param_count) {
......@@ -845,14 +867,18 @@ int32 interpreter::check_condition(int32 f, uint32 param_count) {
lua_pop(current_state, 1);
no_action--;
call_depth--;
if(call_depth == 0)
if(call_depth == 0) {
pduel->release_script_group();
pduel->restore_assumes();
}
return result;
}
no_action--;
call_depth--;
if(call_depth == 0)
if(call_depth == 0) {
pduel->release_script_group();
pduel->restore_assumes();
}
return OPERATION_FAIL;
}
int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) {
......@@ -871,16 +897,20 @@ int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) {
lua_pop(current_state, 1);
no_action--;
call_depth--;
if(call_depth == 0)
if(call_depth == 0) {
pduel->release_script_group();
pduel->restore_assumes();
}
return OPERATION_FAIL;
}
result = lua_toboolean(current_state, -1);
lua_pop(current_state, 1);
no_action--;
call_depth--;
if(call_depth == 0)
if(call_depth == 0) {
pduel->release_script_group();
pduel->restore_assumes();
}
return result;
}
int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraargs) {
......@@ -899,16 +929,20 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg
lua_pop(current_state, 1);
no_action--;
call_depth--;
if(call_depth == 0)
if(call_depth == 0) {
pduel->release_script_group();
pduel->restore_assumes();
}
return OPERATION_FAIL;
}
result = lua_tointeger(current_state, -1);
lua_pop(current_state, 1);
no_action--;
call_depth--;
if(call_depth == 0)
if(call_depth == 0) {
pduel->release_script_group();
pduel->restore_assumes();
}
return result;
}
int32 interpreter::get_function_value(int32 f, uint32 param_count) {
......@@ -927,14 +961,18 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count) {
lua_pop(current_state, 1);
no_action--;
call_depth--;
if(call_depth == 0)
if(call_depth == 0) {
pduel->release_script_group();
pduel->restore_assumes();
}
return result;
}
no_action--;
call_depth--;
if(call_depth == 0)
if(call_depth == 0) {
pduel->release_script_group();
pduel->restore_assumes();
}
return OPERATION_FAIL;
}
int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_value, uint16 step) {
......@@ -972,8 +1010,10 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
handle_message(pduel, 1);
params.clear();
call_depth--;
if(call_depth == 0)
if(call_depth == 0) {
pduel->release_script_group();
pduel->restore_assumes();
}
return OPERATION_FAIL;
}
}
......@@ -986,8 +1026,10 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
*yield_value = lua_isboolean(rthread, -1) ? lua_toboolean(rthread, -1) : lua_tointeger(rthread, -1);
current_state = lua_state;
call_depth--;
if(call_depth == 0)
if(call_depth == 0) {
pduel->release_script_group();
pduel->restore_assumes();
}
return COROUTINE_FINISH;
} else if (result == LUA_YIELD) {
return COROUTINE_YIELD;
......@@ -998,8 +1040,10 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
lua_pop(rthread, 1);
current_state = lua_state;
call_depth--;
if(call_depth == 0)
if(call_depth == 0) {
pduel->release_script_group();
pduel->restore_assumes();
}
return COROUTINE_ERROR;
}
}
......
......@@ -176,6 +176,62 @@ int32 scriptlib::card_get_text_defence(lua_State *L) {
lua_pushinteger(L, pcard->data.defence);
return 1;
}
int32 scriptlib:: card_get_previous_code_onfield(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->previous.code);
return 1;
}
int32 scriptlib::card_get_previous_type_onfield(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->previous.type);
return 1;
}
int32 scriptlib::card_get_previous_level_onfield(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->previous.level);
return 1;
}
int32 scriptlib::card_get_previous_rank_onfield(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->previous.rank);
return 1;
}
int32 scriptlib::card_get_previous_attribute_onfield(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->previous.attribute);
return 1;
}
int32 scriptlib::card_get_previous_race_onfield(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->previous.race);
return 1;
}
int32 scriptlib::card_get_previous_attack_onfield(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->previous.attack);
return 1;
}
int32 scriptlib::card_get_previous_defence_onfield(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->previous.defence);
return 1;
}
int32 scriptlib::card_get_owner(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
......@@ -1907,3 +1963,21 @@ int32 scriptlib::card_check_unique_onfield(lua_State *L) {
lua_pushboolean(L, pcard->pduel->game_field->check_unique_onfield(pcard, check_player) ? 0 : 1);
return 1;
}
int32 scriptlib::card_reset_negate_effect(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
int32 count = lua_gettop(L) - 1;
for(int32 i = 0; i < count; ++i)
pcard->reset(lua_tointeger(L, i + 2), RESET_CARD);
return 0;
}
int32 scriptlib::card_assume_prop(lua_State *L) {
check_param_count(L, 3);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
pcard->assume_type = lua_tointeger(L, 2);
pcard->assume_value = lua_tointeger(L, 3);
pcard->pduel->assumes.insert(pcard);
return 0;
}
......@@ -2652,6 +2652,29 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
raise_single_event(pcard, 0, EVENT_LEAVE_FIELD_P, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0);
leave_p.insert(pcard);
}
if((pcard->current.location & LOCATION_ONFIELD)) {
if(pcard->current.position & POS_FACEUP) {
pcard->previous.code = pcard->get_code();
pcard->previous.type = pcard->get_type();
if(pcard->current.location & LOCATION_MZONE) {
pcard->previous.level = pcard->get_level();
pcard->previous.rank = pcard->get_rank();
pcard->previous.attribute = pcard->get_attribute();
pcard->previous.race = pcard->get_race();
pcard->previous.attack = pcard->get_attack();
pcard->previous.defence = pcard->get_defence();
}
} else {
pcard->previous.code = pcard->data.code;
pcard->previous.type = pcard->data.type;
pcard->previous.level = pcard->data.level;
pcard->previous.rank = pcard->data.level;
pcard->previous.attribute = pcard->data.attribute;
pcard->previous.race = pcard->data.race;
pcard->previous.attack = pcard->data.attack;
pcard->previous.defence = pcard->data.defence;
}
}
}
if(leave_p.size())
raise_event(&leave_p, EVENT_LEAVE_FIELD_P, reason_effect, reason, reason_player, 0, 0);
......
......@@ -39,6 +39,14 @@ public:
static int32 card_get_defence(lua_State *L);
static int32 card_get_origin_defence(lua_State *L);
static int32 card_get_text_defence(lua_State *L);
static int32 card_get_previous_code_onfield(lua_State *L);
static int32 card_get_previous_type_onfield(lua_State *L);
static int32 card_get_previous_level_onfield(lua_State *L);
static int32 card_get_previous_rank_onfield(lua_State *L);
static int32 card_get_previous_attribute_onfield(lua_State *L);
static int32 card_get_previous_race_onfield(lua_State *L);
static int32 card_get_previous_attack_onfield(lua_State *L);
static int32 card_get_previous_defence_onfield(lua_State *L);
static int32 card_get_owner(lua_State *L);
static int32 card_get_controler(lua_State *L);
static int32 card_get_previous_controler(lua_State *L);
......@@ -194,7 +202,9 @@ public:
static int32 card_reverse_in_deck(lua_State *L);
static int32 card_set_unique_onfield(lua_State *L);
static int32 card_check_unique_onfield(lua_State *L);
static int32 card_reset_negate_effect(lua_State *L);
static int32 card_assume_prop(lua_State *L);
//Effect functions
static int32 effect_new(lua_State *L);
static int32 effect_newex(lua_State *L);
......
......@@ -7,40 +7,24 @@ function c15854426.initial_effect(c)
c:RegisterEffect(e1)
--special summon
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetCode(EVENT_LEAVE_FIELD_P)
e2:SetDescription(aux.Stringid(15854426,0))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e2:SetProperty(EFFECT_FLAG_DELAY)
e2:SetRange(LOCATION_SZONE)
e2:SetOperation(c15854426.check)
e2:SetCode(EVENT_TO_HAND)
e2:SetCountLimit(1)
e2:SetCondition(c15854426.condition)
e2:SetTarget(c15854426.target)
e2:SetOperation(c15854426.operation)
c:RegisterEffect(e2)
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(15854426,0))
e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e3:SetProperty(EFFECT_FLAG_DELAY)
e3:SetRange(LOCATION_SZONE)
e3:SetCode(EVENT_TO_HAND)
e3:SetCountLimit(1)
e3:SetCondition(c15854426.condition)
e3:SetTarget(c15854426.target)
e3:SetOperation(c15854426.operation)
c:RegisterEffect(e3)
end
function c15854426.check(e,tp,eg,ep,ev,re,r,rp)
local tc=eg:GetFirst()
while tc do
if tc:IsControler(tp) and tc:IsLocation(LOCATION_MZONE)
and tc:IsFaceup() and tc:IsAttribute(ATTRIBUTE_WIND) and tc:GetDestination()==LOCATION_HAND then
tc:RegisterFlagEffect(15854426,RESET_EVENT+0x15e0000,0,1)
end
tc=eg:GetNext()
end
end
function c15854426.cfilter(c)
return c:GetFlagEffect(15854426)~=0
function c15854426.cfilter(c,tp)
return c:GetPreviousControler()==tp and c:IsPreviousLocation(LOCATION_MZONE)
and bit.band(c:GetPreviousAttributeOnField(),ATTRIBUTE_WIND)~=0
end
function c15854426.condition(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(c15854426.cfilter,1,nil)
return eg:IsExists(c15854426.cfilter,1,nil,tp)
end
function c15854426.filter(c,e,tp)
return c:IsLevelBelow(4) and c:IsAttribute(ATTRIBUTE_WIND)
......
......@@ -65,6 +65,7 @@ function c26732909.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c26732909.filter1,tp,LOCATION_DECK,0,1,nil)
and Duel.IsExistingMatchingCard(c26732909.filter2,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,2,tp,LOCATION_DECK)
e:GetHandler():ResetNegateEffect(25789292,97268402)
end
function c26732909.thop(e,tp,eg,ep,ev,re,r,rp)
local g1=Duel.GetMatchingGroup(c26732909.filter1,tp,LOCATION_DECK,0,nil)
......
......@@ -23,6 +23,7 @@ end
function c32339440.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c32339440.filter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
e:GetHandler():ResetNegateEffect(25789292,97268402)
end
function c32339440.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
......
......@@ -2,40 +2,21 @@
function c46668237.initial_effect(c)
--spsummon
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetDescription(aux.Stringid(46668237,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e1:SetRange(LOCATION_HAND+LOCATION_GRAVE)
e1:SetCode(EVENT_DESTROY)
e1:SetOperation(c46668237.adjop)
e1:SetProperty(EFFECT_FLAG_CHAIN_UNIQUE)
e1:SetCode(EVENT_TO_GRAVE)
e1:SetCondition(c46668237.condition)
e1:SetCost(c46668237.cost)
e1:SetTarget(c46668237.target)
e1:SetOperation(c46668237.operation)
c:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(46668237,0))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e2:SetRange(LOCATION_HAND+LOCATION_GRAVE)
e2:SetProperty(EFFECT_FLAG_CHAIN_UNIQUE)
e2:SetCode(EVENT_TO_GRAVE)
e2:SetLabelObject(e1)
e2:SetCondition(c46668237.condition)
e2:SetCost(c46668237.cost)
e2:SetTarget(c46668237.target)
e2:SetOperation(c46668237.operation)
c:RegisterEffect(e2)
end
function c46668237.filter(c)
return c:IsFaceup() and c:IsLocation(LOCATION_MZONE) and c:IsRace(RACE_BEAST)
end
function c46668237.adjop(e,tp,eg,ep,ev,re,r,rp)
local g=eg:Filter(c46668237.filter,nil)
local tc=g:GetFirst()
while tc do
if tc:GetFlagEffect(46668237)==0 then
tc:RegisterFlagEffect(46668237,RESET_EVENT+0x17a0000+RESET_PHASE+PHASE_END,0,1)
end
tc=g:GetNext()
end
end
function c46668237.cfilter(c,tp)
return c:IsType(TYPE_MONSTER) and c:IsRace(RACE_BEAST) and c:GetPreviousControler()==tp and c:GetFlagEffect(46668237)~=0
return c:IsType(TYPE_MONSTER) and c:IsRace(RACE_BEAST) and c:GetPreviousControler()==tp and c:IsPreviousPosition(POS_FACEUP)
and bit.band(c:GetPreviousRaceOnField(),RACE_BEAST)~=0
end
function c46668237.condition(e,tp,eg,ep,ev,re,r,rp)
return not eg:IsContains(e:GetHandler()) and eg:IsExists(c46668237.cfilter,1,nil,tp)
......
......@@ -36,6 +36,9 @@ function c48934760.activate(e,tp,eg,ep,ev,re,r,rp)
else
Duel.MoveToField(tc,tp,tp,LOCATION_SZONE,POS_FACEUP,true)
end
local te=tc:GetActivateEffect()
local cost=te:GetCost()
if cost then cost(te,tep,eg,ep,ev,re,r,rp,1) end
Duel.RaiseEvent(tc,EVENT_CHAIN_SOLVED,tc:GetActivateEffect(),0,tp,tp,Duel.GetCurrentChain())
end
end
......@@ -37,11 +37,11 @@ function c55727845.atkop(e,tp,eg,ep,ev,re,r,rp)
tc:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE+EFFECT_FLAG_CANNOT_DISABLE)
e2:SetRange(LOCATION_MZONE)
e2:SetCode(EFFECT_UPDATE_ATTACK)
e2:SetValue(atk)
e2:SetReset(RESET_EVENT+0x1ff0000)
e2:SetReset(RESET_EVENT+0x1fe0000)
c:RegisterEffect(e2)
end
end
......@@ -15,20 +15,14 @@ function c58712976.initial_effect(c)
c:RegisterEffect(e1)
--destroy
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_DESTROY)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetOperation(c58712976.desop)
e2:SetDescription(aux.Stringid(58712976,1))
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetCode(EVENT_DESTROYED)
e2:SetCondition(c58712976.rmcon)
e2:SetTarget(c58712976.rmtg)
e2:SetOperation(c58712976.rmop)
c:RegisterEffect(e2)
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(58712976,1))
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
e3:SetCode(EVENT_DESTROYED)
e3:SetCondition(c58712976.rmcon)
e3:SetTarget(c58712976.rmtg)
e3:SetOperation(c58712976.rmop)
c:RegisterEffect(e3)
end
function c58712976.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_COST) end
......@@ -46,13 +40,8 @@ function c58712976.operation(e,tp,eg,ep,ev,re,r,rp)
c:RegisterEffect(e1)
end
end
function c58712976.desop(e,tp,eg,ep,ev,re,r,rp)
if e:GetHandler():GetAttack()>=2500 then
e:GetHandler():RegisterFlagEffect(58712976,RESET_PHASE+PHASE_END,0,1)
end
end
function c58712976.rmcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():GetFlagEffect(58712976)~=0
return e:GetHandler():GetPreviousAttackOnField()>=2500
end
function c58712976.filter(c)
return c:IsType(TYPE_MONSTER) and c:IsAbleToRemove()
......@@ -65,7 +54,6 @@ function c58712976.rmtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
local g=Duel.SelectTarget(tp,c58712976.filter,tp,LOCATION_GRAVE,LOCATION_GRAVE,3,3,nil)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,3,0,0)
end
e:GetHandler():ResetFlagEffect(58712976)
end
function c58712976.rmop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
......
......@@ -2,46 +2,24 @@
function c65303664.initial_effect(c)
--spsummon
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetDescription(aux.Stringid(65303664,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e1:SetRange(LOCATION_HAND)
e1:SetCode(EVENT_DESTROY)
e1:SetOperation(c65303664.adjop)
e1:SetCode(EVENT_BATTLE_DESTROYED)
e1:SetCondition(c65303664.condition)
e1:SetCost(c65303664.cost)
e1:SetTarget(c65303664.target)
e1:SetOperation(c65303664.operation)
c:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(65303664,0))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e2:SetRange(LOCATION_HAND)
e2:SetCode(EVENT_BATTLE_DESTROYED)
e2:SetLabelObject(e1)
e2:SetCondition(c65303664.condition)
e2:SetCost(c65303664.cost)
e2:SetTarget(c65303664.target)
e2:SetOperation(c65303664.operation)
c:RegisterEffect(e2)
end
function c65303664.filter(c,tp)
return c:IsLocation(LOCATION_MZONE) and c:IsFaceup() and c:IsControler(tp) and c:IsRace(RACE_BEAST)
end
function c65303664.adjop(e,tp,eg,ep,ev,re,r,rp)
if bit.band(r,REASON_BATTLE)==0 then return end
local pg=e:GetLabelObject()
if pg then pg:DeleteGroup() end
local dg=eg:Filter(c65303664.filter,nil,tp)
e:SetLabelObject(dg)
dg:KeepAlive()
end
function c65303664.cfilter(c,dg)
return c:IsLocation(LOCATION_GRAVE) and c:IsType(TYPE_MONSTER) and c:IsRace(RACE_BEAST) and c:IsReason(REASON_BATTLE) and dg:IsContains(c)
function c65303664.cfilter(c)
return c:IsLocation(LOCATION_GRAVE) and c:IsType(TYPE_MONSTER) and c:IsRace(RACE_BEAST) and c:IsReason(REASON_BATTLE)
and c:IsPreviousPosition(POS_FACEUP) and c:GetPreviousControler()==tp
and bit.band(c:GetPreviousRaceOnField(),RACE_BEAST)~=0
end
function c65303664.condition(e,tp,eg,ep,ev,re,r,rp)
local de=e:GetLabelObject()
local dg=de:GetLabelObject()
if not dg then return false end
local res=eg:IsExists(c65303664.cfilter,1,nil,dg)
dg:DeleteGroup()
de:SetLabelObject(nil)
return res
return eg:IsExists(c65303664.cfilter,1,nil)
end
function c65303664.rfiletr(c)
return c:IsRace(RACE_BEAST) and c:IsAbleToRemoveAsCost()
......
--
--獣神ヴァルカン
function c98012938.initial_effect(c)
--synchro summon
aux.AddSynchroProcedure(c,nil,aux.NonTuner(nil),1)
......
......@@ -140,6 +140,15 @@ STATUS_JUST_POS =0x1000000 --
STATUS_CONTINUOUS_POS =0x2000000 --
STATUS_IS_PUBLIC =0x4000000 --
STATUS_ACT_FROM_HAND =0x8000000 --
--Assume
ASSUME_CODE =1
ASSUME_TYPE =2
ASSUME_LEVEL =3
ASSUME_RANK =4
ASSUME_ATTRIBUTE =5
ASSUME_RACE =6
ASSUME_ATTACK =7
ASSUME_DEFENCE =8
--Counter
COUNTER_NEED_PERMIT =0x1000
COUNTER_NEED_ENABLE =0x2000
......@@ -184,6 +193,7 @@ RESET_OPPO_TURN =0x0200
RESET_PHASE =0x0400
RESET_CHAIN =0x0800
RESET_EVENT =0x1000
RESET_CARD =0x2000
RESET_CODE =0x4000
RESET_COPY =0x8000
RESET_DISABLE =0x00010000
......@@ -354,6 +364,8 @@ EFFECT_REMOVE_ATTRIBUTE =126 --
EFFECT_CHANGE_ATTRIBUTE =127 --
EFFECT_UPDATE_LEVEL =130 --
EFFECT_CHANGE_LEVEL =131 --
EFFECT_UPDATE_RANK =132 --
EFFECT_CHANGE_RANK =133 --
EFFECT_SET_POSITION =140 --
EFFECT_SELF_DESTROY =141 --
EFFECT_DOUBLE_TRIBUTE =150
......@@ -428,6 +440,7 @@ EFFECT_REMOVE_BRAINWASHING =295
EFFECT_BP_TWICE =296
EFFECT_UNIQUE_CHECK =297
EFFECT_MATCH_KILL =300
EFFECT_SYNCHRO_ASSUME =310
EVENT_STARTUP =1000
EVENT_FLIP =1001
......
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