Commit 1fca74fe authored by argon.sun's avatar argon.sun

fix

parent 53576ec9
......@@ -439,6 +439,7 @@ public:
int32 flip_summon(uint16 step, uint8 sumplayer, card* target);
int32 mset(uint16 step, uint8 setplayer, card* ptarget, effect* proc, uint8 ignore_count);
int32 sset(uint16 step, uint8 setplayer, uint8 toplayer, card* ptarget);
int32 sset_g(uint16 step, uint8 setplayer, uint8 toplayer, group* ptarget);
int32 special_summon_rule(uint16 step, uint8 sumplayer, card* target);
int32 special_summon_step(uint16 step, group* targets, card* target);
int32 special_summon(uint16 step, effect* reason_effect, uint8 reason_player, group* targets);
......@@ -584,6 +585,7 @@ public:
#define PROCESSOR_MSET 64
#define PROCESSOR_SSET 65
#define PROCESSOR_SPSUMMON_STEP 66
#define PROCESSOR_SSET_G 67
#define PROCESSOR_DRAW 70
#define PROCESSOR_DAMAGE 71
#define PROCESSOR_RECOVER 72
......
......@@ -1270,6 +1270,7 @@ int32 scriptlib::card_is_chain_attackable(lua_State *L) {
card* attacker = pduel->game_field->core.attacker;
if(pduel->game_field->core.effect_damage_step
|| attacker->is_status(STATUS_BATTLE_DESTROYED)
|| attacker->current.controler != pduel->game_field->infos.turn_player
|| attacker->fieldid_r != pduel->game_field->core.pre_field[0]
|| !attacker->is_capable_attack_announce(pduel->game_field->infos.turn_player)
|| attacker->announce_count >= ac) {
......
......@@ -288,7 +288,6 @@ int32 scriptlib::duel_setm(lua_State *L) {
int32 scriptlib::duel_sets(lua_State *L) {
check_action_permission(L);
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 2);
uint32 playerid = lua_tointeger(L, 1);
if(playerid != 0 && playerid != 1)
return 0;
......@@ -297,9 +296,21 @@ int32 scriptlib::duel_sets(lua_State *L) {
toplayer = lua_tointeger(L, 3);
if(toplayer != 0 && toplayer != 1)
toplayer = playerid;
card* pcard = *(card**)lua_touserdata(L, 2);
duel * pduel = pcard->pduel;
card* pcard = 0;
group* pgroup = 0;
duel* pduel = 0;
if(check_param(L, PARAM_TYPE_CARD, 2, TRUE)) {
pcard = *(card**) lua_touserdata(L, 2);
pduel = pcard->pduel;
} else if(check_param(L, PARAM_TYPE_GROUP, 2, TRUE)) {
pgroup = *(group**) lua_touserdata(L, 2);
pduel = pgroup->pduel;
} else
luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 2);
if(pcard)
pduel->game_field->add_process(PROCESSOR_SSET, 0, 0, (group*)pcard, playerid, toplayer);
else
pduel->game_field->add_process(PROCESSOR_SSET_G, 0, 0, pgroup, playerid, toplayer);
return lua_yield(L, 0);
}
int32 scriptlib::duel_create_token(lua_State *L) {
......@@ -1128,6 +1139,11 @@ int32 scriptlib::duel_change_battle_damage(lua_State *L) {
int32 dam = lua_tointeger(L, 2);
if(playerid != 0 && playerid != 1)
return 0;
int32 check = TRUE;
if(lua_gettop(L) >= 3)
check = lua_toboolean(L, 3);
if(check && dam == 0)
return 0;
pduel->game_field->core.battle_damage[playerid] = dam;
return 0;
}
......
......@@ -800,6 +800,7 @@ int32 field::get_control(uint16 step, effect * reason_effect, uint8 reason_playe
return TRUE;
pcard->filter_disable_related_cards();
move_to_field(pcard, playerid, playerid, LOCATION_MZONE, pcard->current.position);
pcard->set_status(STATUS_ATTACK_CANCELED, TRUE);
return FALSE;
}
case 1: {
......@@ -852,6 +853,8 @@ int32 field::swap_control(uint16 step, effect * reason_effect, uint8 reason_play
pcard2->reset(RESET_CONTROL, RESET_EVENT);
pcard1->filter_disable_related_cards();
pcard2->filter_disable_related_cards();
pcard1->set_status(STATUS_ATTACK_CANCELED, TRUE);
pcard2->set_status(STATUS_ATTACK_CANCELED, TRUE);
adjust_instant();
return FALSE;
}
......@@ -1728,6 +1731,78 @@ int32 field::sset(uint16 step, uint8 setplayer, uint8 toplayer, card * target) {
}
return TRUE;
}
int32 field::sset_g(uint16 step, uint8 setplayer, uint8 toplayer, group* ptarget) {
switch(step) {
case 0: {
card_set* set_cards = new card_set;
core.operated_set.clear();
for(auto cit = ptarget->container.begin(); cit != ptarget->container.end(); ++cit) {
card* target = *cit;
if((!(target->data.type & TYPE_FIELD) && get_useable_count(toplayer, LOCATION_SZONE, setplayer, LOCATION_REASON_TOFIELD) <= 0)
|| (target->data.type & TYPE_MONSTER && !target->is_affected_by_effect(EFFECT_MONSTER_SSET))
|| (target->current.location == LOCATION_SZONE)
|| (!is_player_can_sset(setplayer, target))
|| (target->is_affected_by_effect(EFFECT_CANNOT_SSET))) {
continue;
}
set_cards->insert(target);
}
if(set_cards->empty()) {
delete set_cards;
returns.ivalue[0] = 0;
return TRUE;
}
core.phase_action = TRUE;
core.units.begin()->ptarget = (group*)set_cards;
return FALSE;
}
case 1: {
card_set* set_cards = (card_set*)ptarget;
card* target = *set_cards->begin();
target->enable_field_effect(FALSE);
move_to_field(target, setplayer, toplayer, LOCATION_SZONE, POS_FACEDOWN, FALSE);
return FALSE;
}
case 2: {
card_set* set_cards = (card_set*)ptarget;
card* target = *set_cards->begin();
target->set_status(STATUS_SET_TURN, TRUE);
if(target->data.type & TYPE_MONSTER) {
effect* peffect = target->is_affected_by_effect(EFFECT_MONSTER_SSET);
int32 type_val = peffect->get_value();
peffect = pduel->new_effect();
peffect->owner = target;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_CHANGE_TYPE;
peffect->reset_flag = RESET_EVENT + 0x1fe0000;
peffect->value = type_val;
target->add_effect(peffect);
}
pduel->write_buffer8(MSG_SET);
pduel->write_buffer32(target->data.code);
pduel->write_buffer8(target->current.controler);
pduel->write_buffer8(target->current.location);
pduel->write_buffer8(target->current.sequence);
pduel->write_buffer8(target->current.position);
core.operated_set.insert(target);
set_cards->erase(target);
if(!set_cards->empty())
core.units.begin()->step = 0;
else
delete set_cards;
return FALSE;
}
case 3: {
returns.ivalue[0] = core.operated_set.size();
adjust_instant();
raise_event(&core.operated_set, EVENT_SSET, 0, 0, setplayer, setplayer, 0);
process_instant_event();
adjust_all();
return TRUE;
}
}
return TRUE;
}
int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card * target) {
switch(step) {
case 0: {
......
......@@ -395,6 +395,14 @@ int32 field::process() {
core.units.begin()->step++;
return pduel->bufferlen;
}
case PROCESSOR_SSET_G: {
if (sset_g(it->step, it->arg1, it->arg2, it->ptarget)) {
pduel->lua->add_param(returns.ivalue[0], PARAM_TYPE_INT);
core.units.pop_front();
} else
core.units.begin()->step++;
return pduel->bufferlen;
}
case PROCESSOR_DRAW : {
if (draw(it->step, it->peffect, it->arg1, (it->arg2 >> 28) & 0xf, (it->arg2 >> 24) & 0xf, it->arg2 & 0xffffff))
core.units.pop_front();
......@@ -3497,7 +3505,7 @@ int32 field::process_battle_command(uint16 step) {
return TRUE;
if(core.chain_attack) {
if(core.attacker->is_status(STATUS_BATTLE_DESTROYED) || core.attacker->fieldid_r != core.pre_field[0]
|| !core.attacker->is_capable_attack_announce(infos.turn_player))
|| (core.attacker->current.controler != infos.turn_player) || !core.attacker->is_capable_attack_announce(infos.turn_player))
return FALSE;
if(core.chain_attack_target) {
if(!core.chain_attack_target->is_capable_be_battle_target(core.attacker)
......
......@@ -33,6 +33,7 @@ function c12014404.operation(e,tp,eg,ep,ev,re,r,rp)
elseif c:IsPosition(POS_FACEUP_ATTACK) then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetCode(EVENT_BATTLE_START)
e1:SetCountLimit(1)
e1:SetOperation(c12014404.atkop)
......
......@@ -15,7 +15,7 @@ function c15341821.condition(e,tp,eg,ep,ev,re,r,rp)
return not e:GetHandler():IsReason(REASON_RETURN)
end
function c15341821.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
if chk==0 then return not e:GetHandler():IsLocation(LOCATION_HAND+LOCATION_DECK) end
Duel.SetOperationInfo(0,CATEGORY_TOKEN,nil,2,0,0)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,2,0,0)
end
......
......@@ -18,5 +18,5 @@ function c28120197.dcon(e,tp,eg,ep,ev,re,r,rp)
return eg:GetFirst():IsDefencePos() and eg:GetFirst():IsRace(RACE_ROCK)
end
function c28120197.dop(e,tp,eg,ep,ev,re,r,rp)
Duel.ChangeBattleDamage(ep,Duel.GetBattleDamage(ep)*2)
Duel.ChangeBattleDamage(ep,ev*2)
end
......@@ -14,5 +14,5 @@ function c31812496.dcon(e,tp,eg,ep,ev,re,r,rp)
return ep~=tp and Duel.GetAttackTarget()==c
end
function c31812496.dop(e,tp,eg,ep,ev,re,r,rp)
Duel.ChangeBattleDamage(ep,Duel.GetBattleDamage(ep)*2)
Duel.ChangeBattleDamage(ep,ev*2)
end
......@@ -48,5 +48,5 @@ function c32933942.rdcon(e,tp,eg,ep,ev,re,r,rp)
and c:GetEffectCount(EFFECT_DIRECT_ATTACK)<2 and Duel.GetFieldGroupCount(tp,0,LOCATION_MZONE)>0
end
function c32933942.rdop(e,tp,eg,ep,ev,re,r,rp)
Duel.ChangeBattleDamage(ep,Duel.GetBattleDamage(ep)/2)
Duel.ChangeBattleDamage(ep,ev/2)
end
\ No newline at end of file
......@@ -134,7 +134,7 @@ function c34487429.rdcon(e,tp,eg,ep,ev,re,r,rp)
end
function c34487429.rdop(e,tp,eg,ep,ev,re,r,rp)
if Duel.SelectEffectYesNo(tp,e:GetHandler()) then
Duel.ChangeBattleDamage(tp,Duel.GetBattleDamage(tp)/2)
Duel.ChangeBattleDamage(tp,ev/2)
e:GetHandler():RegisterFlagEffect(34487429,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1)
end
end
......@@ -40,7 +40,7 @@ function c37083210.dcon(e,tp,eg,ep,ev,re,r,rp)
return ep~=tp and Duel.GetAttackTarget()==c
end
function c37083210.dop(e,tp,eg,ep,ev,re,r,rp)
Duel.ChangeBattleDamage(ep,Duel.GetBattleDamage(ep)*2)
Duel.ChangeBattleDamage(ep,ev*2)
end
function c37083210.desop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetAttacker():IsRelateToBattle() then
......
......@@ -32,7 +32,7 @@ function c37104630.desfilter(c)
end
function c37104630.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsOnField() and chkc:IsControler(1-tp) and c37104630.desfilter(chkc) end
if chk==0 then return true end
if chk==0 then return not e:GetHandler():IsLocation(LOCATION_HAND+LOCATION_DECK) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectTarget(tp,c37104630.desfilter,tp,0,LOCATION_ONFIELD,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0)
......
......@@ -31,7 +31,7 @@ function c40473581.dcon(e,tp,eg,ep,ev,re,r,rp)
return ep~=tp and (c==Duel.GetAttacker() or c==Duel.GetAttackTarget())
end
function c40473581.dop(e,tp,eg,ep,ev,re,r,rp)
Duel.ChangeBattleDamage(ep,Duel.GetBattleDamage(ep)/2)
Duel.ChangeBattleDamage(ep,ev/2)
end
function c40473581.retreg(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
......
......@@ -83,5 +83,5 @@ function c41753322.dcon(e,tp,eg,ep,ev,re,r,rp)
return ep~=tp and Duel.GetAttackTarget()==c
end
function c41753322.dop(e,tp,eg,ep,ev,re,r,rp)
Duel.ChangeBattleDamage(ep,Duel.GetBattleDamage(ep)*2)
Duel.ChangeBattleDamage(ep,ev*2)
end
......@@ -82,5 +82,5 @@ function c49551909.damcon(e,tp,eg,ep,ev,re,r,rp)
return ec and ep==tp and (Duel.GetAttacker()==ec or Duel.GetAttackTarget()==ec)
end
function c49551909.damop(e,tp,eg,ep,ev,re,r,rp)
Duel.ChangeBattleDamage(1-tp,ev)
Duel.ChangeBattleDamage(1-tp,ev,false)
end
......@@ -14,5 +14,5 @@ function c50823978.dcon(e,tp,eg,ep,ev,re,r,rp)
return ep~=tp and c==Duel.GetAttacker() and Duel.GetAttackTarget()==nil
end
function c50823978.dop(e,tp,eg,ep,ev,re,r,rp)
Duel.ChangeBattleDamage(ep,Duel.GetBattleDamage(ep)*2)
Duel.ChangeBattleDamage(ep,ev*2)
end
......@@ -62,5 +62,5 @@ function c52977572.rdcon(e,tp,eg,ep,ev,re,r,rp)
and c:GetEffectCount(EFFECT_DIRECT_ATTACK)<2 and Duel.GetFieldGroupCount(tp,0,LOCATION_MZONE)>0
end
function c52977572.rdop(e,tp,eg,ep,ev,re,r,rp)
Duel.ChangeBattleDamage(ep,Duel.GetBattleDamage(ep)/2)
Duel.ChangeBattleDamage(ep,ev/2)
end
......@@ -13,5 +13,5 @@ function c64145892.rdcon(e,tp,eg,ep,ev,re,r,rp)
return ep==tp and (c==Duel.GetAttacker() or c==Duel.GetAttackTarget())
end
function c64145892.rdop(e,tp,eg,ep,ev,re,r,rp)
Duel.ChangeBattleDamage(ep,Duel.GetBattleDamage(ep)/2)
Duel.ChangeBattleDamage(ep,ev/2)
end
......@@ -50,7 +50,7 @@ function c67630339.clear(e,tp,eg,ep,ev,re,r,rp)
end
function c67630339.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()~=tp and Duel.GetAttackTarget()==nil and c67630339[tp]==2
and c67630339[2]:GetFlagEffect(67630339)~=0
and c67630339[2]:GetFlagEffect(67630339)~=0 and Duel.GetAttacker()~=c67630339[2]
end
function c67630339.operation(e,tp,eg,ep,ev,re,r,rp)
local a=Duel.GetAttacker()
......
......@@ -51,7 +51,7 @@ function c706925.desfilter(c)
end
function c706925.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsOnField() and chkc:IsControler(1-tp) and c706925.desfilter(chkc) end
if chk==0 then return true end
if chk==0 then return not e:GetHandler():IsLocation(LOCATION_HAND+LOCATION_DECK) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectTarget(tp,c706925.desfilter,tp,0,LOCATION_ONFIELD,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0)
......
......@@ -30,7 +30,7 @@ function c74311226.thfilter(c)
return not c:IsCode(74311226) and c:IsRace(RACE_SEASERPENT) and c:IsAbleToHand()
end
function c74311226.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
if chk==0 then return not e:GetHandler():IsLocation(LOCATION_HAND+LOCATION_DECK) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c74311226.thop(e,tp,eg,ep,ev,re,r,rp,c)
......
......@@ -50,5 +50,5 @@ function c9603356.rdcon(e,tp,eg,ep,ev,re,r,rp)
return ep~=tp and e:GetHandler()==Duel.GetAttacker()
end
function c9603356.rdop(e,tp,eg,ep,ev,re,r,rp)
Duel.ChangeBattleDamage(ep,Duel.GetBattleDamage(ep)/2)
Duel.ChangeBattleDamage(ep,ev/2)
end
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