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() {
temp.type = 0xffffffff;
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) {
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;
if (current.location != LOCATION_MZONE || status & STATUS_SUMMONING)
return data.attack;
......@@ -423,7 +425,7 @@ int32 card::get_base_attack(uint8 swap) {
int32 card::get_attack() {
if(assume_type == ASSUME_ATTACK)
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;
if (current.location != LOCATION_MZONE || status & STATUS_SUMMONING)
return data.attack;
......@@ -434,7 +436,7 @@ int32 card::get_attack() {
return atk;
}
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;
if (current.location != LOCATION_MZONE || status & STATUS_SUMMONING)
return data.defence;
......@@ -462,7 +464,7 @@ int32 card::get_base_defence(uint8 swap) {
int32 card::get_defence() {
if(assume_type == ASSUME_DEFENCE)
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;
if (current.location != LOCATION_MZONE || status & STATUS_SUMMONING)
return data.defence;
......@@ -612,19 +614,16 @@ void card::calc_attack_defence(int32 *patk, int32 *pdef) {
temp.defence = -1;
}
// Level/Attribute/Race is available for:
// 1. cards in LOCATION_MZONE or
// 2. cards with original type TYPE_MONSTER or
// 3. cards with current type TYPE_MONSTER(Ex. c87772572)
// 1. cards with original type TYPE_MONSTER or
// 2. cards with current type TYPE_MONSTER
// 3. cares with EFFECT_PRE_MONSTER
// 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() {
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;
if(assume_type == ASSUME_LEVEL)
return assume_value;
if(current.location != LOCATION_MZONE && !(data.type & TYPE_MONSTER) && !(get_type() & TYPE_TRAPMONSTER))
return data.level;
if (temp.level != 0xffffffff)
return temp.level;
effect_set effects;
......@@ -751,10 +750,8 @@ uint32 card::check_xyz_level(card* pcard, uint32 lv) {
uint32 card::get_attribute() {
if(assume_type == ASSUME_ATTRIBUTE)
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;
if(current.location != LOCATION_MZONE && !(data.type & TYPE_MONSTER) && !(get_type() & TYPE_TRAPMONSTER))
return data.attribute;
if (temp.attribute != 0xffffffff)
return temp.attribute;
effect_set effects;
......@@ -782,10 +779,8 @@ uint32 card::get_attribute() {
uint32 card::get_race() {
if(assume_type == ASSUME_RACE)
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;
if(current.location != LOCATION_MZONE && !(data.type & TYPE_MONSTER) && !(get_type() & TYPE_TRAPMONSTER))
return data.race;
if (temp.race != 0xffffffff)
return temp.race;
effect_set effects;
......
......@@ -356,7 +356,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EFFECT_NONTUNER 244
#define EFFECT_OVERLAY_REMOVE_REPLACE 245
#define EFFECT_SCRAP_CHIMERA 246
//#define EFFECT_SPSUM_EFFECT_ACTIVATED 250
#define EFFECT_PRE_MONSTER 250
#define EFFECT_MATERIAL_CHECK 251
#define EFFECT_DISABLE_FIELD 260
#define EFFECT_USE_EXTRA_MZONE 261
......
......@@ -207,8 +207,8 @@ static const struct luaL_Reg cardlib[] = {
{ "IsImmuneToEffect", scriptlib::card_is_immune_to_effect },
{ "IsCanBeEffectTarget", scriptlib::card_is_can_be_effect_target },
{ "IsCanBeBattleTarget", scriptlib::card_is_can_be_battle_target },
{ "AddTrapMonsterAttribute", scriptlib::card_add_trap_monster_attribute },
{ "TrapMonsterBlock", scriptlib::card_trap_monster_block },
{ "AddMonsterAttribute", scriptlib::card_add_monster_attribute },
{ "TrapMonsterComplete", scriptlib::card_trap_monster_complete },
{ "CancelToGrave", scriptlib::card_cancel_to_grave },
{ "GetTributeRequirement", scriptlib::card_get_tribute_requirement },
{ "GetBattleTarget", scriptlib::card_get_battle_target },
......
......@@ -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));
return 1;
}
int32 scriptlib::card_add_trap_monster_attribute(lua_State *L) {
check_param_count(L, 7);
int32 scriptlib::card_add_monster_attribute(lua_State *L) {
check_param_count(L, 6);
check_param(L, PARAM_TYPE_CARD, 1);
int32 extra_type = lua_tointeger(L, 2);
int32 attribute = lua_tointeger(L, 3);
int32 race = lua_tointeger(L, 4);
int32 level = lua_tointeger(L, 5);
int32 atk = lua_tointeger(L, 6);
int32 def = lua_tointeger(L, 7);
int32 attribute = lua_tointeger(L, 2);
int32 race = lua_tointeger(L, 3);
int32 level = lua_tointeger(L, 4);
int32 atk = lua_tointeger(L, 5);
int32 def = lua_tointeger(L, 6);
card* pcard = *(card**) lua_touserdata(L, 1);
duel* pduel = pcard->pduel;
//type
pcard->set_status(STATUS_NO_LEVEL, FALSE);
// pre-monster
effect* peffect = pduel->new_effect();
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_ADD_TYPE;
peffect->code = EFFECT_PRE_MONSTER;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = TYPE_MONSTER | TYPE_TRAPMONSTER | extra_type;
peffect->reset_flag = RESET_CHAIN + RESET_EVENT + 0x1fe0000;
pcard->add_effect(peffect);
//attribute
peffect = pduel->new_effect();
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_ADD_ATTRIBUTE;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = attribute;
pcard->add_effect(peffect);
if(attribute) {
peffect = pduel->new_effect();
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_ADD_ATTRIBUTE;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = attribute;
pcard->add_effect(peffect);
}
//race
peffect = pduel->new_effect();
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_ADD_RACE;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = race;
pcard->add_effect(peffect);
if(race) {
peffect = pduel->new_effect();
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_ADD_RACE;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = race;
pcard->add_effect(peffect);
}
//level
peffect = pduel->new_effect();
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_CHANGE_LEVEL;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = level;
pcard->add_effect(peffect);
if(level) {
peffect = pduel->new_effect();
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_CHANGE_LEVEL;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = level;
pcard->add_effect(peffect);
}
//atk
peffect = pduel->new_effect();
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_SET_BASE_ATTACK;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = atk;
pcard->add_effect(peffect);
if(atk) {
peffect = pduel->new_effect();
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_SET_BASE_ATTACK;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = atk;
pcard->add_effect(peffect);
}
//def
peffect = pduel->new_effect();
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_SET_BASE_DEFENCE;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = def;
pcard->add_effect(peffect);
pcard->set_status(STATUS_NO_LEVEL, FALSE);
if(def) {
peffect = pduel->new_effect();
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_SET_BASE_DEFENCE;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = def;
pcard->add_effect(peffect);
}
return 0;
}
int32 scriptlib::card_trap_monster_block(lua_State *L) {
check_param_count(L, 1);
int32 scriptlib::card_trap_monster_complete(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
int32 extra_type = lua_tointeger(L, 2);
duel* pduel = pcard->pduel;
//extra block
// add type
effect* peffect = pduel->new_effect();
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->range = LOCATION_MZONE;
peffect->code = EFFECT_USE_EXTRA_SZONE;
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);
pcard->add_effect(peffect);
return 0;
......
......@@ -209,8 +209,8 @@ public:
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_battle_target(lua_State *L);
static int32 card_add_trap_monster_attribute(lua_State *L);
static int32 card_trap_monster_block(lua_State *L);
static int32 card_add_monster_attribute(lua_State *L);
static int32 card_trap_monster_complete(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_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