Commit 6e4ed055 authored by nanahira's avatar nanahira

Merge branch '2pick' of ../../../koishi_ocgupd/ygopro-7210srv

parents 6598eccf d1e41aba
...@@ -1174,12 +1174,22 @@ uint32 card::get_link_marker() { ...@@ -1174,12 +1174,22 @@ uint32 card::get_link_marker() {
if(!(data.type & TYPE_LINK)) if(!(data.type & TYPE_LINK))
return 0; return 0;
effect_set effects; effect_set effects;
effect_set effects2;
uint32 link_marker = data.link_marker; uint32 link_marker = data.link_marker;
filter_effect(710253, &effects); filter_effect(EFFECT_ADD_LINK_MARKER_KOISHI, &effects, FALSE);
for (int32 i = 0; i < effects.size(); ++i){ filter_effect(EFFECT_REMOVE_LINK_MARKER_KOISHI, &effects);
filter_effect(EFFECT_CHANGE_LINK_MARKER_KOISHI, &effects2);
for (int32 i = 0; i < effects.size(); ++i) {
card* ocard = effects[i]->get_handler(); card* ocard = effects[i]->get_handler();
if (!(effects[i]->type & EFFECT_TYPE_FIELD) || !(ocard && ocard->get_status(STATUS_TO_LEAVE_FROMEX))) if (effects[i]->code == EFFECT_ADD_LINK_MARKER_KOISHI && (!(effects[i]->type & EFFECT_TYPE_FIELD) || !(ocard && ocard->get_status(STATUS_TO_LEAVE_FROMEX))))
link_marker = effects[i]->get_value(this); link_marker |= effects[i]->get_value(this);
else if (effects[i]->code == EFFECT_REMOVE_LINK_MARKER_KOISHI && (!(effects[i]->type & EFFECT_TYPE_FIELD) || !(ocard && ocard->get_status(STATUS_TO_LEAVE_FROMEX))))
link_marker &= ~(effects[i]->get_value(this));
}
for (int32 i = 0; i < effects2.size(); ++i) {
card* ocard = effects2[i]->get_handler();
if (!(effects2[i]->type & EFFECT_TYPE_FIELD) || !(ocard && ocard->get_status(STATUS_TO_LEAVE_FROMEX)))
link_marker = effects2[i]->get_value(this);
} }
return link_marker; return link_marker;
} }
......
...@@ -107,6 +107,12 @@ public: ...@@ -107,6 +107,12 @@ public:
} }
}; };
// KoishiPro effects
#define EFFECT_CHANGE_LINK_MARKER_KOISHI 710253
#define EFFECT_ADD_LINK_MARKER_KOISHI 37564151
#define EFFECT_REMOVE_LINK_MARKER_KOISHI 37564152
#define EFFECT_CANNOT_LOSE_KOISHI 37564153
//status //status
#define EFFECT_STATUS_AVAILABLE 0x0001 #define EFFECT_STATUS_AVAILABLE 0x0001
//#define EFFECT_STATUS_ACTIVATED 0x0002 //#define EFFECT_STATUS_ACTIVATED 0x0002
......
...@@ -21,6 +21,8 @@ static const struct luaL_Reg cardlib[] = { ...@@ -21,6 +21,8 @@ static const struct luaL_Reg cardlib[] = {
//modded //modded
{ "SetEntityCode", scriptlib::card_set_entity_code }, { "SetEntityCode", scriptlib::card_set_entity_code },
{ "SetCardData", scriptlib::card_set_card_data }, { "SetCardData", scriptlib::card_set_card_data },
{ "GetLinkMarker", scriptlib::card_get_link_marker },
{ "GetOriginalLinkMarker", scriptlib::card_get_origin_link_marker },
{ "GetCode", scriptlib::card_get_code }, { "GetCode", scriptlib::card_get_code },
{ "GetOriginalCode", scriptlib::card_get_origin_code }, { "GetOriginalCode", scriptlib::card_get_origin_code },
...@@ -608,12 +610,14 @@ interpreter::interpreter(duel* pd): coroutines(256) { ...@@ -608,12 +610,14 @@ interpreter::interpreter(duel* pd): coroutines(256) {
set_duel_info(lua_state, pd); set_duel_info(lua_state, pd);
//Initial //Initial
luaL_openlibs(lua_state); luaL_openlibs(lua_state);
/*
lua_pushnil(lua_state); lua_pushnil(lua_state);
lua_setglobal(lua_state, "file"); lua_setglobal(lua_state, "file");
lua_pushnil(lua_state); lua_pushnil(lua_state);
lua_setglobal(lua_state, "io"); lua_setglobal(lua_state, "io");
lua_pushnil(lua_state); lua_pushnil(lua_state);
lua_setglobal(lua_state, "os"); lua_setglobal(lua_state, "os");
*/
lua_getglobal(lua_state, "bit32"); lua_getglobal(lua_state, "bit32");
lua_setglobal(lua_state, "bit"); lua_setglobal(lua_state, "bit");
//open all libs //open all libs
...@@ -639,8 +643,19 @@ interpreter::interpreter(duel* pd): coroutines(256) { ...@@ -639,8 +643,19 @@ interpreter::interpreter(duel* pd): coroutines(256) {
//extra scripts //extra scripts
load_script((char*) "./script/constant.lua"); load_script((char*) "./script/constant.lua");
load_script((char*) "./script/utility.lua"); load_script((char*) "./script/utility.lua");
//load kpro constant
lua_pushinteger(lua_state, EFFECT_CHANGE_LINK_MARKER_KOISHI);
lua_setglobal(lua_state, "EFFECT_CHANGE_LINK_MARKER_KOISHI");
lua_pushinteger(lua_state, EFFECT_ADD_LINK_MARKER_KOISHI);
lua_setglobal(lua_state, "EFFECT_ADD_LINK_MARKER_KOISHI");
lua_pushinteger(lua_state, EFFECT_REMOVE_LINK_MARKER_KOISHI);
lua_setglobal(lua_state, "EFFECT_REMOVE_LINK_MARKER_KOISHI");
lua_pushinteger(lua_state, EFFECT_CANNOT_LOSE_KOISHI);
lua_setglobal(lua_state, "EFFECT_CANNOT_LOSE_KOISHI");
//2pick rule
load_script((char*) "./2pick/pick.lua"); load_script((char*) "./2pick/pick.lua");
//load init.lua by MLD
load_script((char*) "./expansions/script/init.lua");
} }
interpreter::~interpreter() { interpreter::~interpreter() {
lua_close(lua_state); lua_close(lua_state);
......
...@@ -83,6 +83,23 @@ int32 scriptlib::card_set_card_data(lua_State *L) { ...@@ -83,6 +83,23 @@ int32 scriptlib::card_set_card_data(lua_State *L) {
} }
return 0; return 0;
} }
int32 scriptlib::card_get_link_marker(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_link_marker());
return 1;
}
int32 scriptlib::card_get_origin_link_marker(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
if(pcard->status & STATUS_NO_LEVEL)
lua_pushinteger(L, 0);
else
lua_pushinteger(L, pcard->data.link_marker);
return 1;
}
int32 scriptlib::card_get_code(lua_State *L) { int32 scriptlib::card_get_code(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
......
...@@ -510,7 +510,7 @@ int32 field::damage(uint16 step, effect* reason_effect, uint32 reason, uint8 rea ...@@ -510,7 +510,7 @@ int32 field::damage(uint16 step, effect* reason_effect, uint32 reason, uint8 rea
pduel->write_buffer32(amount); pduel->write_buffer32(amount);
raise_event(reason_card, EVENT_DAMAGE, reason_effect, reason, reason_player, playerid, amount); raise_event(reason_card, EVENT_DAMAGE, reason_effect, reason, reason_player, playerid, amount);
if(reason == REASON_BATTLE && reason_card) { if(reason == REASON_BATTLE && reason_card) {
if((player[playerid].lp <= 0) && (core.attack_target == 0) && reason_card->is_affected_by_effect(EFFECT_MATCH_KILL)) { if((player[playerid].lp <= 0) && (core.attack_target == 0) && reason_card->is_affected_by_effect(EFFECT_MATCH_KILL) && !(is_player_affected_by_effect(playerid, EFFECT_CANNOT_LOSE_KOISHI))) {
pduel->write_buffer8(MSG_MATCH_KILL); pduel->write_buffer8(MSG_MATCH_KILL);
pduel->write_buffer32(reason_card->data.code); pduel->write_buffer32(reason_card->data.code);
} }
......
...@@ -5136,7 +5136,9 @@ int32 field::adjust_step(uint16 step) { ...@@ -5136,7 +5136,9 @@ int32 field::adjust_step(uint16 step) {
case 1: { case 1: {
//win check(deck=0 or lp=0) //win check(deck=0 or lp=0)
uint32 winp = 5, rea = 1; uint32 winp = 5, rea = 1;
if(player[0].lp <= 0 && player[1].lp > 0) { bool lp_zero_0 = (player[0].lp <= 0 && !is_player_affected_by_effect(0, EFFECT_CANNOT_LOSE_KOISHI));
bool lp_zero_1 = (player[1].lp <= 0 && !is_player_affected_by_effect(1, EFFECT_CANNOT_LOSE_KOISHI));
if(lp_zero_0 && !lp_zero_1) {
winp = 1; winp = 1;
rea = 1; rea = 1;
} }
...@@ -5144,7 +5146,7 @@ int32 field::adjust_step(uint16 step) { ...@@ -5144,7 +5146,7 @@ int32 field::adjust_step(uint16 step) {
winp = 1; winp = 1;
rea = 2; rea = 2;
} }
if(player[1].lp <= 0 && player[0].lp > 0) { if(lp_zero_1 && !lp_zero_0) {
winp = 0; winp = 0;
rea = 1; rea = 1;
} }
...@@ -5152,7 +5154,7 @@ int32 field::adjust_step(uint16 step) { ...@@ -5152,7 +5154,7 @@ int32 field::adjust_step(uint16 step) {
winp = 0; winp = 0;
rea = 2; rea = 2;
} }
if(player[1].lp <= 0 && player[0].lp <= 0) { if(lp_zero_0 && lp_zero_1) {
winp = PLAYER_NONE; winp = PLAYER_NONE;
rea = 1; rea = 1;
} }
......
...@@ -21,6 +21,8 @@ public: ...@@ -21,6 +21,8 @@ public:
//modded //modded
static int32 card_set_entity_code(lua_State *L); static int32 card_set_entity_code(lua_State *L);
static int32 card_set_card_data(lua_State *L); static int32 card_set_card_data(lua_State *L);
static int32 card_get_link_marker(lua_State *L);
static int32 card_get_origin_link_marker(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);
static int32 effect_get_count_limit(lua_State *L); static int32 effect_get_count_limit(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