Commit 60eb0252 authored by salix5's avatar salix5

Card.AddMonsterAttribute(), Card.TrapMonsterComplete()

EFFECT_PRE_MONSTER
Allow a spell/trap card to have a monster status.

Card.AddMonsterAttribute
Add EFFECT_PRE_MONSTER and necessary information.

Card.TrapMonsterComplete
Add EFFECT_ADD_TYPE and EFFECT_USE_EXTRA_SZONE.
parent 44a7289d
...@@ -394,8 +394,10 @@ uint32 card::get_type() { ...@@ -394,8 +394,10 @@ uint32 card::get_type() {
temp.type = 0xffffffff; temp.type = 0xffffffff;
return type; return type;
} }
// Atk and def are sepcial cases since text atk/def ? are involved.
// Asuumption: we can only change the atk/def of cards in LOCATION_MZONE.
int32 card::get_base_attack(uint8 swap) { int32 card::get_base_attack(uint8 swap) {
if (current.location != LOCATION_MZONE && !(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER)) if(!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER) && !is_affected_by_effect(EFFECT_PRE_MONSTER))
return 0; return 0;
if (current.location != LOCATION_MZONE || status & STATUS_SUMMONING) if (current.location != LOCATION_MZONE || status & STATUS_SUMMONING)
return data.attack; return data.attack;
...@@ -423,7 +425,7 @@ int32 card::get_base_attack(uint8 swap) { ...@@ -423,7 +425,7 @@ int32 card::get_base_attack(uint8 swap) {
int32 card::get_attack() { int32 card::get_attack() {
if(assume_type == ASSUME_ATTACK) if(assume_type == ASSUME_ATTACK)
return assume_value; return assume_value;
if (current.location != LOCATION_MZONE && !(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER)) if(!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER) && !is_affected_by_effect(EFFECT_PRE_MONSTER))
return 0; return 0;
if (current.location != LOCATION_MZONE || status & STATUS_SUMMONING) if (current.location != LOCATION_MZONE || status & STATUS_SUMMONING)
return data.attack; return data.attack;
...@@ -434,7 +436,7 @@ int32 card::get_attack() { ...@@ -434,7 +436,7 @@ int32 card::get_attack() {
return atk; return atk;
} }
int32 card::get_base_defence(uint8 swap) { int32 card::get_base_defence(uint8 swap) {
if (current.location != LOCATION_MZONE && !(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER)) if(!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER) && !is_affected_by_effect(EFFECT_PRE_MONSTER))
return 0; return 0;
if (current.location != LOCATION_MZONE || status & STATUS_SUMMONING) if (current.location != LOCATION_MZONE || status & STATUS_SUMMONING)
return data.defence; return data.defence;
...@@ -462,7 +464,7 @@ int32 card::get_base_defence(uint8 swap) { ...@@ -462,7 +464,7 @@ int32 card::get_base_defence(uint8 swap) {
int32 card::get_defence() { int32 card::get_defence() {
if(assume_type == ASSUME_DEFENCE) if(assume_type == ASSUME_DEFENCE)
return assume_value; return assume_value;
if (current.location != LOCATION_MZONE && !(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER)) if(!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER) && !is_affected_by_effect(EFFECT_PRE_MONSTER))
return 0; return 0;
if (current.location != LOCATION_MZONE || status & STATUS_SUMMONING) if (current.location != LOCATION_MZONE || status & STATUS_SUMMONING)
return data.defence; return data.defence;
...@@ -612,19 +614,16 @@ void card::calc_attack_defence(int32 *patk, int32 *pdef) { ...@@ -612,19 +614,16 @@ void card::calc_attack_defence(int32 *patk, int32 *pdef) {
temp.defence = -1; temp.defence = -1;
} }
// Level/Attribute/Race is available for: // Level/Attribute/Race is available for:
// 1. cards in LOCATION_MZONE or // 1. cards with original type TYPE_MONSTER or
// 2. cards with original type TYPE_MONSTER or // 2. cards with current type TYPE_MONSTER
// 3. cards with current type TYPE_MONSTER(Ex. c87772572) // 3. cares with EFFECT_PRE_MONSTER
// They can be changed for cards satisfying 1 or 2 or current type TYPE_TRAPMONSTER. // They can be changed for cards satisfying 1 or 2 or current type TYPE_TRAPMONSTER.
// This is because some Phantom Knights is changed into TYPE_MONSTER but is not affected by Zombie World.
uint32 card::get_level() { uint32 card::get_level() {
if((data.type & TYPE_XYZ) || (status & STATUS_NO_LEVEL) if((data.type & TYPE_XYZ) || (status & STATUS_NO_LEVEL)
|| (current.location != LOCATION_MZONE && !(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER))) || (!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER) && !is_affected_by_effect(EFFECT_PRE_MONSTER)))
return 0; return 0;
if(assume_type == ASSUME_LEVEL) if(assume_type == ASSUME_LEVEL)
return assume_value; return assume_value;
if(current.location != LOCATION_MZONE && !(data.type & TYPE_MONSTER) && !(get_type() & TYPE_TRAPMONSTER))
return data.level;
if (temp.level != 0xffffffff) if (temp.level != 0xffffffff)
return temp.level; return temp.level;
effect_set effects; effect_set effects;
...@@ -751,10 +750,8 @@ uint32 card::check_xyz_level(card* pcard, uint32 lv) { ...@@ -751,10 +750,8 @@ uint32 card::check_xyz_level(card* pcard, uint32 lv) {
uint32 card::get_attribute() { uint32 card::get_attribute() {
if(assume_type == ASSUME_ATTRIBUTE) if(assume_type == ASSUME_ATTRIBUTE)
return assume_value; return assume_value;
if(current.location != LOCATION_MZONE && !(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER)) if(!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER) && !is_affected_by_effect(EFFECT_PRE_MONSTER))
return 0; return 0;
if(current.location != LOCATION_MZONE && !(data.type & TYPE_MONSTER) && !(get_type() & TYPE_TRAPMONSTER))
return data.attribute;
if (temp.attribute != 0xffffffff) if (temp.attribute != 0xffffffff)
return temp.attribute; return temp.attribute;
effect_set effects; effect_set effects;
...@@ -782,10 +779,8 @@ uint32 card::get_attribute() { ...@@ -782,10 +779,8 @@ uint32 card::get_attribute() {
uint32 card::get_race() { uint32 card::get_race() {
if(assume_type == ASSUME_RACE) if(assume_type == ASSUME_RACE)
return assume_value; return assume_value;
if(current.location != LOCATION_MZONE && !(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER)) if(!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER) && !is_affected_by_effect(EFFECT_PRE_MONSTER))
return 0; return 0;
if(current.location != LOCATION_MZONE && !(data.type & TYPE_MONSTER) && !(get_type() & TYPE_TRAPMONSTER))
return data.race;
if (temp.race != 0xffffffff) if (temp.race != 0xffffffff)
return temp.race; return temp.race;
effect_set effects; effect_set effects;
......
...@@ -356,7 +356,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2) ...@@ -356,7 +356,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EFFECT_NONTUNER 244 #define EFFECT_NONTUNER 244
#define EFFECT_OVERLAY_REMOVE_REPLACE 245 #define EFFECT_OVERLAY_REMOVE_REPLACE 245
#define EFFECT_SCRAP_CHIMERA 246 #define EFFECT_SCRAP_CHIMERA 246
//#define EFFECT_SPSUM_EFFECT_ACTIVATED 250 #define EFFECT_PRE_MONSTER 250
#define EFFECT_MATERIAL_CHECK 251 #define EFFECT_MATERIAL_CHECK 251
#define EFFECT_DISABLE_FIELD 260 #define EFFECT_DISABLE_FIELD 260
#define EFFECT_USE_EXTRA_MZONE 261 #define EFFECT_USE_EXTRA_MZONE 261
......
...@@ -207,8 +207,8 @@ static const struct luaL_Reg cardlib[] = { ...@@ -207,8 +207,8 @@ static const struct luaL_Reg cardlib[] = {
{ "IsImmuneToEffect", scriptlib::card_is_immune_to_effect }, { "IsImmuneToEffect", scriptlib::card_is_immune_to_effect },
{ "IsCanBeEffectTarget", scriptlib::card_is_can_be_effect_target }, { "IsCanBeEffectTarget", scriptlib::card_is_can_be_effect_target },
{ "IsCanBeBattleTarget", scriptlib::card_is_can_be_battle_target }, { "IsCanBeBattleTarget", scriptlib::card_is_can_be_battle_target },
{ "AddTrapMonsterAttribute", scriptlib::card_add_trap_monster_attribute }, { "AddMonsterAttribute", scriptlib::card_add_monster_attribute },
{ "TrapMonsterBlock", scriptlib::card_trap_monster_block }, { "TrapMonsterComplete", scriptlib::card_trap_monster_complete },
{ "CancelToGrave", scriptlib::card_cancel_to_grave }, { "CancelToGrave", scriptlib::card_cancel_to_grave },
{ "GetTributeRequirement", scriptlib::card_get_tribute_requirement }, { "GetTributeRequirement", scriptlib::card_get_tribute_requirement },
{ "GetBattleTarget", scriptlib::card_get_battle_target }, { "GetBattleTarget", scriptlib::card_get_battle_target },
......
...@@ -2059,87 +2059,105 @@ int32 scriptlib::card_is_can_be_battle_target(lua_State *L) { ...@@ -2059,87 +2059,105 @@ int32 scriptlib::card_is_can_be_battle_target(lua_State *L) {
lua_pushboolean(L, pcard->is_capable_be_battle_target(bcard)); lua_pushboolean(L, pcard->is_capable_be_battle_target(bcard));
return 1; return 1;
} }
int32 scriptlib::card_add_trap_monster_attribute(lua_State *L) { int32 scriptlib::card_add_monster_attribute(lua_State *L) {
check_param_count(L, 7); check_param_count(L, 6);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
int32 extra_type = lua_tointeger(L, 2); int32 attribute = lua_tointeger(L, 2);
int32 attribute = lua_tointeger(L, 3); int32 race = lua_tointeger(L, 3);
int32 race = lua_tointeger(L, 4); int32 level = lua_tointeger(L, 4);
int32 level = lua_tointeger(L, 5); int32 atk = lua_tointeger(L, 5);
int32 atk = lua_tointeger(L, 6); int32 def = lua_tointeger(L, 6);
int32 def = lua_tointeger(L, 7);
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
duel* pduel = pcard->pduel; duel* pduel = pcard->pduel;
//type pcard->set_status(STATUS_NO_LEVEL, FALSE);
// pre-monster
effect* peffect = pduel->new_effect(); effect* peffect = pduel->new_effect();
peffect->owner = pcard; peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE; peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_ADD_TYPE; peffect->code = EFFECT_PRE_MONSTER;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE; peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000; peffect->reset_flag = RESET_CHAIN + RESET_EVENT + 0x1fe0000;
peffect->value = TYPE_MONSTER | TYPE_TRAPMONSTER | extra_type;
pcard->add_effect(peffect); pcard->add_effect(peffect);
//attribute //attribute
peffect = pduel->new_effect(); if(attribute) {
peffect->owner = pcard; peffect = pduel->new_effect();
peffect->type = EFFECT_TYPE_SINGLE; peffect->owner = pcard;
peffect->code = EFFECT_ADD_ATTRIBUTE; peffect->type = EFFECT_TYPE_SINGLE;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE; peffect->code = EFFECT_ADD_ATTRIBUTE;
peffect->reset_flag = RESET_EVENT + 0x47e0000; peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->value = attribute; peffect->reset_flag = RESET_EVENT + 0x47e0000;
pcard->add_effect(peffect); peffect->value = attribute;
pcard->add_effect(peffect);
}
//race //race
peffect = pduel->new_effect(); if(race) {
peffect->owner = pcard; peffect = pduel->new_effect();
peffect->type = EFFECT_TYPE_SINGLE; peffect->owner = pcard;
peffect->code = EFFECT_ADD_RACE; peffect->type = EFFECT_TYPE_SINGLE;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE; peffect->code = EFFECT_ADD_RACE;
peffect->reset_flag = RESET_EVENT + 0x47e0000; peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->value = race; peffect->reset_flag = RESET_EVENT + 0x47e0000;
pcard->add_effect(peffect); peffect->value = race;
pcard->add_effect(peffect);
}
//level //level
peffect = pduel->new_effect(); if(level) {
peffect->owner = pcard; peffect = pduel->new_effect();
peffect->type = EFFECT_TYPE_SINGLE; peffect->owner = pcard;
peffect->code = EFFECT_CHANGE_LEVEL; peffect->type = EFFECT_TYPE_SINGLE;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE; peffect->code = EFFECT_CHANGE_LEVEL;
peffect->reset_flag = RESET_EVENT + 0x47e0000; peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->value = level; peffect->reset_flag = RESET_EVENT + 0x47e0000;
pcard->add_effect(peffect); peffect->value = level;
pcard->add_effect(peffect);
}
//atk //atk
peffect = pduel->new_effect(); if(atk) {
peffect->owner = pcard; peffect = pduel->new_effect();
peffect->type = EFFECT_TYPE_SINGLE; peffect->owner = pcard;
peffect->code = EFFECT_SET_BASE_ATTACK; peffect->type = EFFECT_TYPE_SINGLE;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE; peffect->code = EFFECT_SET_BASE_ATTACK;
peffect->reset_flag = RESET_EVENT + 0x47e0000; peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->value = atk; peffect->reset_flag = RESET_EVENT + 0x47e0000;
pcard->add_effect(peffect); peffect->value = atk;
pcard->add_effect(peffect);
}
//def //def
peffect = pduel->new_effect(); if(def) {
peffect->owner = pcard; peffect = pduel->new_effect();
peffect->type = EFFECT_TYPE_SINGLE; peffect->owner = pcard;
peffect->code = EFFECT_SET_BASE_DEFENCE; peffect->type = EFFECT_TYPE_SINGLE;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE; peffect->code = EFFECT_SET_BASE_DEFENCE;
peffect->reset_flag = RESET_EVENT + 0x47e0000; peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->value = def; peffect->reset_flag = RESET_EVENT + 0x47e0000;
pcard->add_effect(peffect); peffect->value = def;
pcard->set_status(STATUS_NO_LEVEL, FALSE); pcard->add_effect(peffect);
}
return 0; return 0;
} }
int32 scriptlib::card_trap_monster_block(lua_State *L) { int32 scriptlib::card_trap_monster_complete(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
int32 extra_type = lua_tointeger(L, 2);
duel* pduel = pcard->pduel; duel* pduel = pcard->pduel;
//extra block // add type
effect* peffect = pduel->new_effect(); effect* peffect = pduel->new_effect();
peffect->owner = pcard; peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_ADD_TYPE;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x1fe0000;
peffect->value = TYPE_MONSTER | TYPE_TRAPMONSTER | extra_type;
pcard->add_effect(peffect);
// extra block
peffect = pduel->new_effect();
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_FIELD; peffect->type = EFFECT_TYPE_FIELD;
peffect->range = LOCATION_MZONE; peffect->range = LOCATION_MZONE;
peffect->code = EFFECT_USE_EXTRA_SZONE; peffect->code = EFFECT_USE_EXTRA_SZONE;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE; peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x5fe0000; peffect->reset_flag = RESET_EVENT + 0x1fe0000;
peffect->value = 1 + (0x10000 << pcard->previous.sequence); peffect->value = 1 + (0x10000 << pcard->previous.sequence);
pcard->add_effect(peffect); pcard->add_effect(peffect);
return 0; return 0;
......
...@@ -209,8 +209,8 @@ public: ...@@ -209,8 +209,8 @@ public:
static int32 card_is_immune_to_effect(lua_State *L); static int32 card_is_immune_to_effect(lua_State *L);
static int32 card_is_can_be_effect_target(lua_State *L); static int32 card_is_can_be_effect_target(lua_State *L);
static int32 card_is_can_be_battle_target(lua_State *L); static int32 card_is_can_be_battle_target(lua_State *L);
static int32 card_add_trap_monster_attribute(lua_State *L); static int32 card_add_monster_attribute(lua_State *L);
static int32 card_trap_monster_block(lua_State *L); static int32 card_trap_monster_complete(lua_State *L);
static int32 card_cancel_to_grave(lua_State *L); static int32 card_cancel_to_grave(lua_State *L);
static int32 card_get_tribute_requirement(lua_State *L); static int32 card_get_tribute_requirement(lua_State *L);
static int32 card_get_battle_target(lua_State *L); static int32 card_get_battle_target(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