Commit f9d20320 authored by purerosefallen's avatar purerosefallen

updatecore

parent df1d76b4
...@@ -2146,7 +2146,7 @@ int32 card::destination_redirect(uint8 destination, uint32 reason) { ...@@ -2146,7 +2146,7 @@ int32 card::destination_redirect(uint8 destination, uint32 reason) {
// cmit->second[0]: permanent // cmit->second[0]: permanent
// cmit->second[1]: reset while negated // cmit->second[1]: reset while negated
int32 card::add_counter(uint8 playerid, uint16 countertype, uint16 count, uint8 singly) { int32 card::add_counter(uint8 playerid, uint16 countertype, uint16 count, uint8 singly) {
if(!is_can_add_counter(playerid, countertype, count, singly)) if(!is_can_add_counter(playerid, countertype, count, singly, 0))
return FALSE; return FALSE;
uint16 cttype = countertype & ~COUNTER_NEED_ENABLE; uint16 cttype = countertype & ~COUNTER_NEED_ENABLE;
auto pr = counters.insert(std::make_pair(cttype, counter_map::mapped_type())); auto pr = counters.insert(std::make_pair(cttype, counter_map::mapped_type()));
...@@ -2204,15 +2204,27 @@ int32 card::remove_counter(uint16 countertype, uint16 count) { ...@@ -2204,15 +2204,27 @@ int32 card::remove_counter(uint16 countertype, uint16 count) {
pduel->write_buffer16(count); pduel->write_buffer16(count);
return TRUE; return TRUE;
} }
int32 card::is_can_add_counter(uint8 playerid, uint16 countertype, uint16 count, uint8 singly) { int32 card::is_can_add_counter(uint8 playerid, uint16 countertype, uint16 count, uint8 singly, uint32 loc) {
effect_set eset; effect_set eset;
if(!pduel->game_field->is_player_can_place_counter(playerid, this, countertype, count)) if(!pduel->game_field->is_player_can_place_counter(playerid, this, countertype, count))
return FALSE; return FALSE;
if(!(current.location & LOCATION_ONFIELD) || !is_position(POS_FACEUP))
return FALSE;
if((countertype & COUNTER_NEED_ENABLE) && is_status(STATUS_DISABLED)) if((countertype & COUNTER_NEED_ENABLE) && is_status(STATUS_DISABLED))
return FALSE; return FALSE;
if(!(countertype & COUNTER_WITHOUT_PERMIT) && !is_affected_by_effect(EFFECT_COUNTER_PERMIT + (countertype & 0xffff))) uint32 check = countertype & COUNTER_WITHOUT_PERMIT;
if(!check) {
filter_effect(EFFECT_COUNTER_PERMIT + (countertype & 0xffff), &eset);
for(int32 i = 0; i < eset.size(); ++i) {
uint32 prange = eset[i]->get_value();
if(loc)
check = loc & prange;
else
check = current.is_location(prange) && is_position(POS_FACEUP);
if(check)
break;
}
eset.clear();
}
if(!check)
return FALSE; return FALSE;
uint16 cttype = countertype & ~COUNTER_NEED_ENABLE; uint16 cttype = countertype & ~COUNTER_NEED_ENABLE;
int32 limit = -1; int32 limit = -1;
......
...@@ -106,7 +106,7 @@ public: ...@@ -106,7 +106,7 @@ public:
}; };
//222DIY //222DIY
uint32 set_entity_code(uint32 entity_code, bool remove_alias = false); uint32 set_entity_code(uint32 entity_code, bool remove_alias = false);
struct sendto_param_t { struct sendto_param_t {
void set(uint8 p, uint8 pos, uint8 loc, uint8 seq = 0) { void set(uint8 p, uint8 pos, uint8 loc, uint8 seq = 0) {
playerid = p; playerid = p;
...@@ -268,7 +268,7 @@ public: ...@@ -268,7 +268,7 @@ public:
int32 destination_redirect(uint8 destination, uint32 reason); int32 destination_redirect(uint8 destination, uint32 reason);
int32 add_counter(uint8 playerid, uint16 countertype, uint16 count, uint8 singly); int32 add_counter(uint8 playerid, uint16 countertype, uint16 count, uint8 singly);
int32 remove_counter(uint16 countertype, uint16 count); int32 remove_counter(uint16 countertype, uint16 count);
int32 is_can_add_counter(uint8 playerid, uint16 countertype, uint16 count, uint8 singly); int32 is_can_add_counter(uint8 playerid, uint16 countertype, uint16 count, uint8 singly, uint32 loc);
int32 get_counter(uint16 countertype); int32 get_counter(uint16 countertype);
void set_material(card_set* materials); void set_material(card_set* materials);
void add_card_target(card* pcard); void add_card_target(card* pcard);
...@@ -499,8 +499,6 @@ public: ...@@ -499,8 +499,6 @@ public:
#define STATUS_OPPO_BATTLE 0x10000000 #define STATUS_OPPO_BATTLE 0x10000000
#define STATUS_FLIP_SUMMON_TURN 0x20000000 #define STATUS_FLIP_SUMMON_TURN 0x20000000
#define STATUS_SPSUMMON_TURN 0x40000000 #define STATUS_SPSUMMON_TURN 0x40000000
//222DIY
#define STATUS_TO_LEAVE_FROMEX 0x80000000
//Counter //Counter
#define COUNTER_WITHOUT_PERMIT 0x1000 #define COUNTER_WITHOUT_PERMIT 0x1000
#define COUNTER_NEED_ENABLE 0x2000 #define COUNTER_NEED_ENABLE 0x2000
......
...@@ -20,10 +20,8 @@ static const struct luaL_Reg cardlib[] = { ...@@ -20,10 +20,8 @@ static const struct luaL_Reg cardlib[] = {
{ "GetAffectingEffect", scriptlib::card_get_affecting_effect }, { "GetAffectingEffect", scriptlib::card_get_affecting_effect },
{ "FilterEffect", scriptlib::card_filter_effect }, { "FilterEffect", scriptlib::card_filter_effect },
{ "SetEntityCode", scriptlib::card_set_entity_code }, { "SetEntityCode", scriptlib::card_set_entity_code },
{ "IsLinkBelow", scriptlib::card_is_link_below },
{ "IsLinkAbove", scriptlib::card_is_link_above },
{ "SetCardData", scriptlib::card_set_card_data }, { "SetCardData", scriptlib::card_set_card_data },
{ "GetCode", scriptlib::card_get_code }, { "GetCode", scriptlib::card_get_code },
{ "GetOriginalCode", scriptlib::card_get_origin_code }, { "GetOriginalCode", scriptlib::card_get_origin_code },
{ "GetOriginalCodeRule", scriptlib::card_get_origin_code_rule }, { "GetOriginalCodeRule", scriptlib::card_get_origin_code_rule },
...@@ -216,6 +214,8 @@ static const struct luaL_Reg cardlib[] = { ...@@ -216,6 +214,8 @@ static const struct luaL_Reg cardlib[] = {
{ "IsLevelAbove", scriptlib::card_is_level_above }, { "IsLevelAbove", scriptlib::card_is_level_above },
{ "IsRankBelow", scriptlib::card_is_rank_below }, { "IsRankBelow", scriptlib::card_is_rank_below },
{ "IsRankAbove", scriptlib::card_is_rank_above }, { "IsRankAbove", scriptlib::card_is_rank_above },
{ "IsLinkBelow", scriptlib::card_is_link_below },
{ "IsLinkAbove", scriptlib::card_is_link_above },
{ "IsAttackBelow", scriptlib::card_is_attack_below }, { "IsAttackBelow", scriptlib::card_is_attack_below },
{ "IsAttackAbove", scriptlib::card_is_attack_above }, { "IsAttackAbove", scriptlib::card_is_attack_above },
{ "IsDefenseBelow", scriptlib::card_is_defense_below }, { "IsDefenseBelow", scriptlib::card_is_defense_below },
...@@ -361,7 +361,7 @@ static const struct luaL_Reg duellib[] = { ...@@ -361,7 +361,7 @@ static const struct luaL_Reg duellib[] = {
{ "ReadCard", scriptlib::duel_read_card }, { "ReadCard", scriptlib::duel_read_card },
{ "Exile", scriptlib::duel_exile }, { "Exile", scriptlib::duel_exile },
{ "DisableActionCheck", scriptlib::duel_disable_action_check }, { "DisableActionCheck", scriptlib::duel_disable_action_check },
{ "EnableGlobalFlag", scriptlib::duel_enable_global_flag }, { "EnableGlobalFlag", scriptlib::duel_enable_global_flag },
{ "GetLP", scriptlib::duel_get_lp }, { "GetLP", scriptlib::duel_get_lp },
{ "SetLP", scriptlib::duel_set_lp }, { "SetLP", scriptlib::duel_set_lp },
...@@ -587,7 +587,7 @@ interpreter::interpreter(duel* pd): coroutines(256) { ...@@ -587,7 +587,7 @@ interpreter::interpreter(duel* pd): coroutines(256) {
call_depth = 0; call_depth = 0;
//222DIY //222DIY
disable_action_check = 0; disable_action_check = 0;
set_duel_info(lua_state, pd); set_duel_info(lua_state, pd);
//Initial //Initial
luaL_openlibs(lua_state); luaL_openlibs(lua_state);
......
...@@ -55,30 +55,6 @@ int32 scriptlib::card_set_entity_code(lua_State *L) { ...@@ -55,30 +55,6 @@ int32 scriptlib::card_set_entity_code(lua_State *L) {
lua_pushinteger(L, pcard->set_entity_code(trace, remove_alias)); lua_pushinteger(L, pcard->set_entity_code(trace, remove_alias));
return 1; return 1;
} }
int32 scriptlib::card_is_link_below(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
uint32 lnk = lua_tointeger(L, 2);
if(!(pcard->data.type & TYPE_LINK) || (pcard->status & STATUS_NO_LEVEL)
|| (!(pcard->data.type & TYPE_MONSTER) && !(pcard->current.location & LOCATION_MZONE)))
lua_pushboolean(L, 0);
else
lua_pushboolean(L, pcard->get_link() <= lnk);
return 1;
}
int32 scriptlib::card_is_link_above(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
uint32 lnk = lua_tointeger(L, 2);
if(!(pcard->data.type & TYPE_LINK) || (pcard->status & STATUS_NO_LEVEL)
|| (!(pcard->data.type & TYPE_MONSTER) && !(pcard->current.location & LOCATION_MZONE)))
lua_pushboolean(L, 0);
else
lua_pushboolean(L, pcard->get_link() >= lnk);
return 1;
}
int32 scriptlib::card_set_card_data(lua_State *L) { int32 scriptlib::card_set_card_data(lua_State *L) {
check_param_count(L, 3); check_param_count(L, 3);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
...@@ -2128,6 +2104,30 @@ int32 scriptlib::card_is_rank_above(lua_State *L) { ...@@ -2128,6 +2104,30 @@ int32 scriptlib::card_is_rank_above(lua_State *L) {
lua_pushboolean(L, pcard->get_rank() >= rnk); lua_pushboolean(L, pcard->get_rank() >= rnk);
return 1; return 1;
} }
int32 scriptlib::card_is_link_below(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
uint32 lnk = lua_tointeger(L, 2);
if(!(pcard->data.type & TYPE_LINK) || (pcard->status & STATUS_NO_LEVEL)
|| (!(pcard->data.type & TYPE_MONSTER) && !(pcard->current.location & LOCATION_MZONE)))
lua_pushboolean(L, 0);
else
lua_pushboolean(L, pcard->get_link() <= lnk);
return 1;
}
int32 scriptlib::card_is_link_above(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
uint32 lnk = lua_tointeger(L, 2);
if(!(pcard->data.type & TYPE_LINK) || (pcard->status & STATUS_NO_LEVEL)
|| (!(pcard->data.type & TYPE_MONSTER) && !(pcard->current.location & LOCATION_MZONE)))
lua_pushboolean(L, 0);
else
lua_pushboolean(L, pcard->get_link() >= lnk);
return 1;
}
int32 scriptlib::card_is_attack_below(lua_State *L) { int32 scriptlib::card_is_attack_below(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
...@@ -2289,8 +2289,7 @@ int32 scriptlib::card_enable_counter_permit(lua_State *L) { ...@@ -2289,8 +2289,7 @@ int32 scriptlib::card_enable_counter_permit(lua_State *L) {
peffect->owner = pcard; peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE; peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_COUNTER_PERMIT | countertype; peffect->code = EFFECT_COUNTER_PERMIT | countertype;
peffect->flag[0] = EFFECT_FLAG_SINGLE_RANGE; peffect->value = prange;
peffect->range = prange;
pcard->add_effect(peffect); pcard->add_effect(peffect);
return 0; return 0;
} }
...@@ -2330,7 +2329,10 @@ int32 scriptlib::card_is_can_add_counter(lua_State *L) { ...@@ -2330,7 +2329,10 @@ int32 scriptlib::card_is_can_add_counter(lua_State *L) {
uint8 singly = FALSE; uint8 singly = FALSE;
if(lua_gettop(L) > 3) if(lua_gettop(L) > 3)
singly = lua_toboolean(L, 4); singly = lua_toboolean(L, 4);
lua_pushboolean(L, pcard->is_can_add_counter(pcard->pduel->game_field->core.reason_player, countertype, count, singly)); uint32 loc = 0;
if(lua_gettop(L) > 4)
loc = lua_tointeger(L, 5);
lua_pushboolean(L, pcard->is_can_add_counter(pcard->pduel->game_field->core.reason_player, countertype, count, singly, loc));
return 1; return 1;
} }
int32 scriptlib::card_is_can_remove_counter(lua_State *L) { int32 scriptlib::card_is_can_remove_counter(lua_State *L) {
......
...@@ -20,8 +20,6 @@ public: ...@@ -20,8 +20,6 @@ public:
static int32 card_get_affecting_effect(lua_State *L); static int32 card_get_affecting_effect(lua_State *L);
static int32 card_set_entity_code(lua_State *L); static int32 card_set_entity_code(lua_State *L);
static int32 card_filter_effect(lua_State *L); static int32 card_filter_effect(lua_State *L);
static int32 card_is_link_below(lua_State *L);
static int32 card_is_link_above(lua_State *L);
static int32 card_set_card_data(lua_State *L); static int32 card_set_card_data(lua_State *L);
static int32 effect_set_owner(lua_State *L); static int32 effect_set_owner(lua_State *L);
static int32 effect_get_range(lua_State *L); static int32 effect_get_range(lua_State *L);
...@@ -226,6 +224,8 @@ public: ...@@ -226,6 +224,8 @@ public:
static int32 card_is_level_above(lua_State *L); static int32 card_is_level_above(lua_State *L);
static int32 card_is_rank_below(lua_State *L); static int32 card_is_rank_below(lua_State *L);
static int32 card_is_rank_above(lua_State *L); static int32 card_is_rank_above(lua_State *L);
static int32 card_is_link_below(lua_State *L);
static int32 card_is_link_above(lua_State *L);
static int32 card_is_attack_below(lua_State *L); static int32 card_is_attack_below(lua_State *L);
static int32 card_is_attack_above(lua_State *L); static int32 card_is_attack_above(lua_State *L);
static int32 card_is_defense_below(lua_State *L); static int32 card_is_defense_below(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