Commit e77c4e79 authored by salix5's avatar salix5

GetPreviousCodeOnField()

parent 81cb5b31
...@@ -34,6 +34,7 @@ struct card_data { ...@@ -34,6 +34,7 @@ struct card_data {
struct card_state { struct card_state {
uint32 code; uint32 code;
uint32 code2;
uint32 type; uint32 type;
uint32 level; uint32 level;
uint32 rank; uint32 rank;
......
...@@ -258,6 +258,10 @@ int32 scriptlib:: card_get_previous_code_onfield(lua_State *L) { ...@@ -258,6 +258,10 @@ int32 scriptlib:: card_get_previous_code_onfield(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);
lua_pushinteger(L, pcard->previous.code); lua_pushinteger(L, pcard->previous.code);
if(pcard->previous.code2) {
lua_pushinteger(L, pcard->previous.code2);
return 2;
}
return 1; return 1;
} }
int32 scriptlib::card_get_previous_type_onfield(lua_State *L) { int32 scriptlib::card_get_previous_type_onfield(lua_State *L) {
......
...@@ -3022,6 +3022,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -3022,6 +3022,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
if((pcard->current.location & LOCATION_ONFIELD)) { if((pcard->current.location & LOCATION_ONFIELD)) {
if(pcard->current.position & POS_FACEUP) { if(pcard->current.position & POS_FACEUP) {
pcard->previous.code = pcard->get_code(); pcard->previous.code = pcard->get_code();
pcard->previous.code2 = pcard->get_another_code();
pcard->previous.type = pcard->get_type(); pcard->previous.type = pcard->get_type();
if(pcard->current.location & LOCATION_MZONE) { if(pcard->current.location & LOCATION_MZONE) {
pcard->previous.level = pcard->get_level(); pcard->previous.level = pcard->get_level();
...@@ -3032,7 +3033,16 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -3032,7 +3033,16 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
pcard->previous.defence = pcard->get_defence(); pcard->previous.defence = pcard->get_defence();
} }
} else { } else {
pcard->previous.code = pcard->data.code; if(pcard->data.alias)
pcard->previous.code = pcard->data.alias;
else
pcard->previous.code = pcard->data.code;
effect_set eset;
pcard->filter_effect(EFFECT_ADD_CODE, &eset);
if(eset.size())
pcard->previous.code2 = eset.get_last()->get_value(pcard);
else
pcard->previous.code2 = 0;
pcard->previous.type = pcard->data.type; pcard->previous.type = pcard->data.type;
pcard->previous.level = pcard->data.level; pcard->previous.level = pcard->data.level;
pcard->previous.rank = pcard->data.level; pcard->previous.rank = pcard->data.level;
......
...@@ -12,10 +12,13 @@ function c34460239.initial_effect(c) ...@@ -12,10 +12,13 @@ function c34460239.initial_effect(c)
end end
function c34460239.filter(c,tp) function c34460239.filter(c,tp)
return c:IsFaceup() and c:IsDestructable() return c:IsFaceup() and c:IsDestructable()
and Duel.IsExistingMatchingCard(c34460239.filter2,tp,LOCATION_DECK,0,1,nil,c:GetCode()) and Duel.IsExistingMatchingCard(c34460239.nfilter1,tp,LOCATION_DECK,0,1,nil,c)
end end
function c34460239.filter2(c,code) function c34460239.nfilter1(c,tc)
return c:IsCode(code) and c:IsAbleToHand() return c:IsCode(tc:GetCode()) and c:IsAbleToHand()
end
function c34460239.nfilter2(c,tc)
return c:IsCode(tc:GetPreviousCodeOnField()) and c:IsAbleToHand()
end end
function c34460239.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) function c34460239.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c34460239.filter(chkc,tp) end if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c34460239.filter(chkc,tp) end
...@@ -29,7 +32,8 @@ function c34460239.activate(e,tp,eg,ep,ev,re,r,rp) ...@@ -29,7 +32,8 @@ function c34460239.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget() local tc=Duel.GetFirstTarget()
if tc:IsFaceup() and tc:IsRelateToEffect(e) and Duel.Destroy(tc,REASON_EFFECT)>0 then if tc:IsFaceup() and tc:IsRelateToEffect(e) and Duel.Destroy(tc,REASON_EFFECT)>0 then
Duel.BreakEffect() Duel.BreakEffect()
local hc=Duel.GetFirstMatchingCard(c34460239.filter2,tp,LOCATION_DECK,0,nil,tc:GetCode()) local g=Duel.Duel.SelectMatchingCard(tp,c34460239.nfilter2,tp,LOCATION_DECK,0,1,1,nil,tc)
local hc=g:GetFirst()
if hc then if hc then
Duel.SendtoHand(hc,nil,REASON_EFFECT) Duel.SendtoHand(hc,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,hc) Duel.ConfirmCards(1-tp,hc)
......
...@@ -20,9 +20,9 @@ function c8339504.cfilter(c,e,tp) ...@@ -20,9 +20,9 @@ function c8339504.cfilter(c,e,tp)
local rk=c:GetRank() local rk=c:GetRank()
return rk>0 and Duel.IsExistingMatchingCard(c8339504.spfilter,tp,LOCATION_EXTRA,0,1,nil,rk,c:GetRace(),c:GetAttribute(),c:GetCode(),e,tp) return rk>0 and Duel.IsExistingMatchingCard(c8339504.spfilter,tp,LOCATION_EXTRA,0,1,nil,rk,c:GetRace(),c:GetAttribute(),c:GetCode(),e,tp)
end end
function c8339504.spfilter(c,rk,rc,att,code,e,tp) function c8339504.spfilter(c,tc,e,tp)
return c:GetRank()==rk and c:IsRace(rc) and c:IsAttribute(att) and not c:IsCode(code) return c:GetRank()==tc:GetPreviousRankOnField() and c:IsRace(tc:GetPreviousRaceOnField()) and c:IsAttribute(tc:GetPreviousAttributeOnField())
and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and not c:IsCode(tc:GetPreviousCodeOnField()) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end end
function c8339504.target(e,tp,eg,ep,ev,re,r,rp,chk) function c8339504.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then if chk==0 then
...@@ -42,7 +42,7 @@ function c8339504.activate(e,tp,eg,ep,ev,re,r,rp) ...@@ -42,7 +42,7 @@ function c8339504.activate(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler() local c=e:GetHandler()
local tc=Duel.GetFirstTarget() local tc=Duel.GetFirstTarget()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c8339504.spfilter,tp,LOCATION_EXTRA,0,1,1,nil,tc:GetPreviousRankOnField(),tc:GetPreviousRaceOnField(),tc:GetPreviousAttributeOnField(),tc:GetPreviousCodeOnField(),e,tp) local g=Duel.SelectMatchingCard(tp,c8339504.spfilter,tp,LOCATION_EXTRA,0,1,1,nil,tc,e,tp)
local sc=g:GetFirst() local sc=g:GetFirst()
if sc then if sc then
Duel.SpecialSummon(sc,0,tp,tp,false,false,POS_FACEUP) Duel.SpecialSummon(sc,0,tp,tp,false,false,POS_FACEUP)
......
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