Commit 97fd88a8 authored by Fluorohydride's avatar Fluorohydride

Merge pull request #934 from salix5/patch-hat

fix: Magical Hats
parents 9cb061be b2ef8f9b
...@@ -72,7 +72,7 @@ void ClientCard::UpdateInfo(char* buf) { ...@@ -72,7 +72,7 @@ void ClientCard::UpdateInfo(char* buf) {
type = BufferIO::ReadInt32(buf); type = BufferIO::ReadInt32(buf);
if(flag & QUERY_LEVEL) { if(flag & QUERY_LEVEL) {
pdata = BufferIO::ReadInt32(buf); pdata = BufferIO::ReadInt32(buf);
if(pdata && level != (unsigned int)pdata) { if(level != (unsigned int)pdata) {
level = pdata; level = pdata;
myswprintf(lvstring, L"L%d", level); myswprintf(lvstring, L"L%d", level);
} }
......
...@@ -296,6 +296,8 @@ uint32 card::get_type() { ...@@ -296,6 +296,8 @@ uint32 card::get_type() {
return type; return type;
} }
int32 card::get_base_attack(uint8 swap) { int32 card::get_base_attack(uint8 swap) {
if (current.location != LOCATION_MZONE && data.type & (TYPE_SPELL + TYPE_TRAP))
return 0;
if (current.location != LOCATION_MZONE) if (current.location != LOCATION_MZONE)
return data.attack; return data.attack;
if (temp.base_attack != -1) if (temp.base_attack != -1)
...@@ -322,6 +324,8 @@ int32 card::get_base_attack(uint8 swap) { ...@@ -322,6 +324,8 @@ int32 card::get_base_attack(uint8 swap) {
int32 card::get_attack(uint8 swap) { int32 card::get_attack(uint8 swap) {
if(assume_type == ASSUME_ATTACK) if(assume_type == ASSUME_ATTACK)
return assume_value; return assume_value;
if (current.location != LOCATION_MZONE && data.type & (TYPE_SPELL + TYPE_TRAP))
return 0;
if (current.location != LOCATION_MZONE) if (current.location != LOCATION_MZONE)
return data.attack; return data.attack;
if (temp.attack != -1) if (temp.attack != -1)
...@@ -392,6 +396,8 @@ int32 card::get_attack(uint8 swap) { ...@@ -392,6 +396,8 @@ int32 card::get_attack(uint8 swap) {
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_SPELL + TYPE_TRAP))
return 0;
if (current.location != LOCATION_MZONE) if (current.location != LOCATION_MZONE)
return data.defence; return data.defence;
if (temp.base_defence != -1) if (temp.base_defence != -1)
...@@ -418,6 +424,8 @@ int32 card::get_base_defence(uint8 swap) { ...@@ -418,6 +424,8 @@ int32 card::get_base_defence(uint8 swap) {
int32 card::get_defence(uint8 swap) { int32 card::get_defence(uint8 swap) {
if(assume_type == ASSUME_DEFENCE) if(assume_type == ASSUME_DEFENCE)
return assume_value; return assume_value;
if (current.location != LOCATION_MZONE && data.type & (TYPE_SPELL + TYPE_TRAP))
return 0;
if (current.location != LOCATION_MZONE) if (current.location != LOCATION_MZONE)
return data.defence; return data.defence;
if (temp.defence != -1) if (temp.defence != -1)
...@@ -488,7 +496,7 @@ int32 card::get_defence(uint8 swap) { ...@@ -488,7 +496,7 @@ int32 card::get_defence(uint8 swap) {
return def; return def;
} }
uint32 card::get_level() { uint32 card::get_level() {
if(data.type & TYPE_XYZ) if(data.type & TYPE_XYZ || single_effect.count(0x14d72c34)>0 || (current.location != LOCATION_MZONE && data.type & (TYPE_SPELL + TYPE_TRAP)))
return 0; return 0;
if(assume_type == ASSUME_LEVEL) if(assume_type == ASSUME_LEVEL)
return assume_value; return assume_value;
...@@ -554,7 +562,7 @@ uint32 card::get_rank() { ...@@ -554,7 +562,7 @@ uint32 card::get_rank() {
return rank; return rank;
} }
uint32 card::get_synchro_level(card* pcard) { uint32 card::get_synchro_level(card* pcard) {
if(data.type & TYPE_XYZ) if(data.type & TYPE_XYZ || single_effect.count(0x14d72c34)>0 || (current.location != LOCATION_MZONE && data.type & (TYPE_SPELL + TYPE_TRAP)))
return 0; return 0;
uint32 lev; uint32 lev;
effect_set eset; effect_set eset;
...@@ -566,7 +574,7 @@ uint32 card::get_synchro_level(card* pcard) { ...@@ -566,7 +574,7 @@ uint32 card::get_synchro_level(card* pcard) {
return lev; return lev;
} }
uint32 card::get_ritual_level(card* pcard) { uint32 card::get_ritual_level(card* pcard) {
if(data.type & TYPE_XYZ) if(data.type & TYPE_XYZ || single_effect.count(0x14d72c34)>0 || (current.location != LOCATION_MZONE && data.type & (TYPE_SPELL + TYPE_TRAP)))
return 0; return 0;
uint32 lev; uint32 lev;
effect_set eset; effect_set eset;
...@@ -578,7 +586,7 @@ uint32 card::get_ritual_level(card* pcard) { ...@@ -578,7 +586,7 @@ uint32 card::get_ritual_level(card* pcard) {
return lev; return lev;
} }
uint32 card::is_xyz_level(card* pcard, uint32 lv) { uint32 card::is_xyz_level(card* pcard, uint32 lv) {
if(data.type & TYPE_XYZ) if(data.type & TYPE_XYZ || single_effect.count(0x14d72c34)>0 || (current.location != LOCATION_MZONE && data.type & (TYPE_SPELL + TYPE_TRAP)))
return FALSE; return FALSE;
uint32 lev; uint32 lev;
effect_set eset; effect_set eset;
...@@ -594,10 +602,10 @@ uint32 card::is_xyz_level(card* pcard, uint32 lv) { ...@@ -594,10 +602,10 @@ uint32 card::is_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_SPELL + TYPE_TRAP))
return 0;
if(!(current.location & (LOCATION_MZONE + LOCATION_GRAVE))) if(!(current.location & (LOCATION_MZONE + LOCATION_GRAVE)))
return data.attribute; return data.attribute;
if((current.location == LOCATION_GRAVE) && (data.type & (TYPE_SPELL + TYPE_TRAP)))
return data.attribute;
if (temp.attribute != 0xffffffff) if (temp.attribute != 0xffffffff)
return temp.attribute; return temp.attribute;
effect_set effects; effect_set effects;
...@@ -621,10 +629,10 @@ uint32 card::get_attribute() { ...@@ -621,10 +629,10 @@ 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_SPELL + TYPE_TRAP))
return 0;
if(!(current.location & (LOCATION_MZONE + LOCATION_GRAVE))) if(!(current.location & (LOCATION_MZONE + LOCATION_GRAVE)))
return data.race; return data.race;
if((current.location == LOCATION_GRAVE) && (data.type & (TYPE_SPELL + TYPE_TRAP)))
return data.race;
if (temp.race != 0xffffffff) if (temp.race != 0xffffffff)
return temp.race; return temp.race;
effect_set effects; effect_set effects;
......
...@@ -95,7 +95,7 @@ int32 scriptlib::card_get_origin_level(lua_State *L) { ...@@ -95,7 +95,7 @@ int32 scriptlib::card_get_origin_level(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
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);
if(pcard->data.type & TYPE_XYZ) if(pcard->data.type & TYPE_XYZ || pcard->single_effect.count(0x14d72c34)>0 || (pcard->current.location != LOCATION_MZONE && pcard->data.type & (TYPE_SPELL + TYPE_TRAP)))
lua_pushinteger(L, 0); lua_pushinteger(L, 0);
else else
lua_pushinteger(L, pcard->data.level); lua_pushinteger(L, pcard->data.level);
...@@ -146,7 +146,10 @@ int32 scriptlib::card_get_origin_attribute(lua_State *L) { ...@@ -146,7 +146,10 @@ int32 scriptlib::card_get_origin_attribute(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
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);
lua_pushinteger(L, pcard->data.attribute); if(pcard->single_effect.count(0x14d72c34)>0 || (pcard->current.location != LOCATION_MZONE && pcard->data.type & (TYPE_SPELL + TYPE_TRAP)))
lua_pushinteger(L, 0);
else
lua_pushinteger(L, pcard->data.attribute);
return 1; return 1;
} }
int32 scriptlib::card_get_race(lua_State *L) { int32 scriptlib::card_get_race(lua_State *L) {
...@@ -160,7 +163,10 @@ int32 scriptlib::card_get_origin_race(lua_State *L) { ...@@ -160,7 +163,10 @@ int32 scriptlib::card_get_origin_race(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
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);
lua_pushinteger(L, pcard->data.race); if(pcard->single_effect.count(0x14d72c34)>0 || (pcard->current.location != LOCATION_MZONE && pcard->data.type & (TYPE_SPELL + TYPE_TRAP)))
lua_pushinteger(L, 0);
else
lua_pushinteger(L, pcard->data.race);
return 1; return 1;
} }
int32 scriptlib::card_get_attack(lua_State *L) { int32 scriptlib::card_get_attack(lua_State *L) {
...@@ -181,7 +187,10 @@ int32 scriptlib::card_get_text_attack(lua_State *L) { ...@@ -181,7 +187,10 @@ int32 scriptlib::card_get_text_attack(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
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);
lua_pushinteger(L, pcard->data.attack); if(pcard->single_effect.count(0x14d72c34)>0 || (pcard->current.location != LOCATION_MZONE && pcard->data.type & (TYPE_SPELL + TYPE_TRAP)))
lua_pushinteger(L, 0);
else
lua_pushinteger(L, pcard->data.attack);
return 1; return 1;
} }
int32 scriptlib::card_get_defence(lua_State *L) { int32 scriptlib::card_get_defence(lua_State *L) {
...@@ -202,7 +211,10 @@ int32 scriptlib::card_get_text_defence(lua_State *L) { ...@@ -202,7 +211,10 @@ int32 scriptlib::card_get_text_defence(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
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);
lua_pushinteger(L, pcard->data.defence); if(pcard->single_effect.count(0x14d72c34)>0 || (pcard->current.location != LOCATION_MZONE && pcard->data.type & (TYPE_SPELL + TYPE_TRAP)))
lua_pushinteger(L, 0);
else
lua_pushinteger(L, pcard->data.defence);
return 1; return 1;
} }
int32 scriptlib:: card_get_previous_code_onfield(lua_State *L) { int32 scriptlib:: card_get_previous_code_onfield(lua_State *L) {
...@@ -1509,7 +1521,7 @@ int32 scriptlib::card_is_level_below(lua_State *L) { ...@@ -1509,7 +1521,7 @@ int32 scriptlib::card_is_level_below(lua_State *L) {
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);
uint32 lvl = lua_tointeger(L, 2); uint32 lvl = lua_tointeger(L, 2);
if((pcard->data.type & TYPE_XYZ) || (!(pcard->data.type & TYPE_MONSTER) && !(pcard->current.location & LOCATION_MZONE))) if((pcard->data.type & TYPE_XYZ) || (!(pcard->data.type & TYPE_MONSTER) && !(pcard->current.location & LOCATION_MZONE)) || pcard->single_effect.count(0x14d72c34)>0)
lua_pushboolean(L, 0); lua_pushboolean(L, 0);
else else
lua_pushboolean(L, pcard->get_level() <= lvl); lua_pushboolean(L, pcard->get_level() <= lvl);
...@@ -1520,7 +1532,7 @@ int32 scriptlib::card_is_level_above(lua_State *L) { ...@@ -1520,7 +1532,7 @@ int32 scriptlib::card_is_level_above(lua_State *L) {
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);
uint32 lvl = lua_tointeger(L, 2); uint32 lvl = lua_tointeger(L, 2);
if((pcard->data.type & TYPE_XYZ) || (!(pcard->data.type & TYPE_MONSTER) && !(pcard->current.location & LOCATION_MZONE))) if((pcard->data.type & TYPE_XYZ) || (!(pcard->data.type & TYPE_MONSTER) && !(pcard->current.location & LOCATION_MZONE)) || pcard->single_effect.count(0x14d72c34)>0)
lua_pushboolean(L, 0); lua_pushboolean(L, 0);
else else
lua_pushboolean(L, pcard->get_level() >= lvl); lua_pushboolean(L, pcard->get_level() >= lvl);
......
...@@ -18,7 +18,7 @@ function c81210420.filter(c) ...@@ -18,7 +18,7 @@ function c81210420.filter(c)
return not c:IsType(TYPE_TOKEN) return not c:IsType(TYPE_TOKEN)
end end
function c81210420.spfilter(c,e,tp) function c81210420.spfilter(c,e,tp)
return c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsCanBeSpecialSummoned(e,0,tp,true,false,POS_FACEDOWN) return c:IsType(TYPE_SPELL+TYPE_TRAP) and Duel.IsPlayerCanSpecialSummonMonster(tp,c:GetCode(),0,0x11,0,0,0,0,0)
end end
function c81210420.target(e,tp,eg,ep,ev,re,r,rp,chk) function c81210420.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c81210420.filter,tp,LOCATION_MZONE,0,1,nil) if chk==0 then return Duel.IsExistingMatchingCard(c81210420.filter,tp,LOCATION_MZONE,0,1,nil)
...@@ -43,23 +43,39 @@ function c81210420.activate(e,tp,eg,ep,ev,re,r,rp) ...@@ -43,23 +43,39 @@ function c81210420.activate(e,tp,eg,ep,ev,re,r,rp)
tc:ClearEffectRelation() tc:ClearEffectRelation()
end end
end end
local tg=sg:GetFirst()
while tg do
local e1=Effect.CreateEffect(tg)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CHANGE_TYPE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetValue(TYPE_NORMAL+TYPE_MONSTER)
e1:SetReset(RESET_EVENT+0x47c0000)
tg:RegisterEffect(e1,true)
local e2=e1:Clone()
e2:SetCode(EFFECT_CHANGE_RACE)
e2:SetValue(0)
tg:RegisterEffect(e2,true)
local e3=e1:Clone()
e3:SetCode(EFFECT_CHANGE_ATTRIBUTE)
e3:SetValue(0)
tg:RegisterEffect(e3,true)
local e4=e1:Clone()
e4:SetCode(EFFECT_SET_BASE_ATTACK)
e4:SetValue(0)
tg:RegisterEffect(e4,true)
local e5=e1:Clone()
e5:SetCode(EFFECT_SET_BASE_DEFENCE)
e5:SetValue(0)
tg:RegisterEffect(e5,true)
tg:RegisterFlagEffect(81210420,RESET_EVENT+0x47c0000+RESET_PHASE+PHASE_BATTLE,0,1)
tg=sg:GetNext()
end
Duel.SpecialSummon(sg,0,tp,tp,true,false,POS_FACEDOWN_DEFENCE) Duel.SpecialSummon(sg,0,tp,tp,true,false,POS_FACEDOWN_DEFENCE)
Duel.ConfirmCards(1-tp,sg) Duel.ConfirmCards(1-tp,sg)
sg:AddCard(tc) sg:AddCard(tc)
Duel.ShuffleSetCard(sg) Duel.ShuffleSetCard(sg)
sg:RemoveCard(tc) sg:RemoveCard(tc)
local sc=sg:GetFirst()
sc:RegisterFlagEffect(81210420,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_BATTLE,0,1)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CHANGE_TYPE)
e1:SetValue(TYPE_NORMAL+TYPE_MONSTER)
e1:SetReset(RESET_EVENT+0x1fc0000)
sc:RegisterEffect(e1)
sc=sg:GetNext()
sc:RegisterFlagEffect(81210420,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_BATTLE,0,1)
local e2=e1:Clone()
sc:RegisterEffect(e2)
sg:KeepAlive() sg:KeepAlive()
local de=Effect.CreateEffect(e:GetHandler()) local de=Effect.CreateEffect(e:GetHandler())
de:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) de:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
......
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