Commit 5b961215 authored by Fluorohydride's avatar Fluorohydride

update

parent a0ffc09d
......@@ -273,6 +273,8 @@ uint32 card::get_type() {
return assume_value;
if(!(current.location & 0x1e))
return data.type;
if((current.location == LOCATION_SZONE) && (current.position >= 6))
return TYPE_PENDULUM + TYPE_SPELL;
if (temp.type != 0xffffffff)
return temp.type;
effect_set effects;
......
......@@ -32,6 +32,7 @@ effect::effect() {
o_range = 0;
reset_count = 0;
reset_flag = 0;
count_code = 0;
category = 0;
label = 0;
label_object = 0;
......@@ -116,8 +117,21 @@ int32 effect::is_available() {
int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_cond, int32 neglect_cost, int32 neglect_target) {
if(!(type & EFFECT_TYPE_ACTIONS))
return FALSE;
if((flag & EFFECT_FLAG_COUNT_LIMIT) && (reset_count & 0xf00) == 0)
return FALSE;
if((flag & EFFECT_FLAG_COUNT_LIMIT)) {
if(count_code == 0) {
if((reset_count & 0xf00) == 0)
return FALSE;
} else {
uint32 code = count_code & 0x7fffffff;
if(code == 1) {
if(pduel->game_field->get_effect_code((count_code & 0x80000000) | handler->fieldid) >= ((reset_count >> 12) & 0xf))
return false;
} else {
if(pduel->game_field->get_effect_code(count_code) >= ((reset_count >> 12) & 0xf))
return false;
}
}
}
if (!(flag & EFFECT_FLAG_FIELD_ONLY)) {
if (type & EFFECT_TYPE_ACTIVATE) {
if(handler->current.controler != playerid)
......@@ -466,12 +480,20 @@ int32 effect::reset(uint32 reset_level, uint32 reset_type) {
void effect::dec_count() {
if(!(flag & EFFECT_FLAG_COUNT_LIMIT))
return;
if((reset_count & 0xf00) == 0)
return;
reset_count -= 0x100;
if(count_code == 0) {
if((reset_count & 0xf00) == 0)
return;
reset_count -= 0x100;
} else {
uint32 code = count_code & 0x7fffffff;
if(code == 1)
pduel->game_field->add_effect_code((count_code & 0x80000000) | handler->fieldid);
else
pduel->game_field->add_effect_code(count_code);
}
}
void effect::recharge() {
if(flag & EFFECT_FLAG_COUNT_LIMIT) {
if((flag & EFFECT_FLAG_COUNT_LIMIT) && (count_code == 0)) {
reset_count &= 0xf0ff;
reset_count |= (reset_count >> 4) & 0xf00;
}
......
......@@ -44,6 +44,7 @@ public:
uint16 o_range;
uint16 reset_count;
uint32 reset_flag;
uint32 count_code;
uint32 category;
uint32 label;
uint32 hint_timing[2];
......
......@@ -813,6 +813,22 @@ void field::reset_chain() {
(*rm)->handler->remove_effect((*rm));
}
}
void field::add_effect_code(uint32 code) {
core.effect_count_code[code]++;
}
uint32 field::get_effect_code(uint32 code) {
auto iter = core.effect_count_code.find(code);
if(iter == core.effect_count_code.end())
return 0;
return iter->second;
}
void field::dec_effect_code(uint32 code){
auto iter = core.effect_count_code.find(code);
if(iter == core.effect_count_code.end())
return;
if(iter->second > 0)
iter->second--;
}
void field::filter_field_effect(uint32 code, effect_set* eset, uint8 sort) {
effect* peffect;
auto rg = effects.aura_effect.equal_range(code);
......
......@@ -212,6 +212,7 @@ struct processor {
event_list delayed_ntev;
std::unordered_map<card*, uint32> readjust_map;
std::unordered_set<card*> unique_cards[2];
std::unordered_map<uint32, uint32> effect_count_code;
ptr temp_var[4];
uint32 global_flag;
uint16 pre_field[2];
......@@ -320,6 +321,10 @@ public:
void reset_effect(uint32 id, uint32 reset_type);
void reset_phase(uint32 phase);
void reset_chain();
void add_effect_code(uint32 code);
uint32 get_effect_code(uint32 code);
void dec_effect_code(uint32 code);
void filter_field_effect(uint32 code, effect_set* eset, uint8 sort = TRUE);
void filter_affected_cards(effect* peffect, card_set* cset);
void filter_player_effect(uint8 playerid, uint32 code, effect_set* eset, uint8 sort = TRUE);
......
......@@ -220,6 +220,7 @@ static const struct luaL_Reg effectlib[] = {
{ "SetTargetRange", scriptlib::effect_set_target_range },
{ "SetAbsoluteRange", scriptlib::effect_set_absolute_range },
{ "SetCountLimit", scriptlib::effect_set_count_limit },
{ "SetCountCode", scriptlib::effect_set_count_code },
{ "SetReset", scriptlib::effect_set_reset },
{ "SetType", scriptlib::effect_set_type },
{ "SetProperty", scriptlib::effect_set_property },
......
......@@ -145,6 +145,14 @@ int32 scriptlib::effect_set_count_limit(lua_State *L) {
peffect->reset_count |= ((v << 12) & 0xf000) | ((v << 8) & 0xf00);
return 0;
}
int32 scriptlib::effect_set_count_code(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 v = lua_tointeger(L, 2);
peffect->count_code = v;
return 0;
}
int32 scriptlib::effect_set_reset(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1);
......
......@@ -3221,7 +3221,8 @@ int32 field::move_to_field(uint16 step, card * target, uint32 enable, uint32 ret
if(!is_equip && location == LOCATION_SZONE && (target->data.type & TYPE_FIELD) && (target->data.type & TYPE_SPELL)) {
card* pcard = get_field_card(playerid, LOCATION_SZONE, 5);
if(pcard) {
destroy(pcard, 0, REASON_RULE, pcard->current.controler);
//destroy(pcard, 0, REASON_RULE, pcard->current.controler);
send_to(pcard, 0, REASON_RULE, pcard->current.controler, PLAYER_NONE, LOCATION_GRAVE, 0, 0);
adjust_all();
}
} else if(!is_equip && location == LOCATION_SZONE && (target->data.type & TYPE_PENDULUM)) {
......
......@@ -3830,6 +3830,7 @@ int32 field::process_turn(uint16 step, uint8 turn_player) {
pduel->delete_effect(*eit);
}
core.reseted_effects.clear();
core.effect_count_code.clear();
for(uint8 p = 0; p < 2; ++p) {
for(uint8 i = 0; i < 5; ++i) {
pcard = player[p].list_mzone[i];
......@@ -3908,11 +3909,13 @@ int32 field::process_turn(uint16 step, uint8 turn_player) {
return FALSE;
}
case 2: {
//Draw
int32 count = get_draw_count(infos.turn_player);
if(count > 0) {
draw(0, REASON_RULE, turn_player, turn_player, count);
add_process(PROCESSOR_POINT_EVENT, 0, 0, 0, 0, 0);
// Draw, new ruling
if(infos.turn_id > 1) {
int32 count = get_draw_count(infos.turn_player);
if(count > 0) {
draw(0, REASON_RULE, turn_player, turn_player, count);
add_process(PROCESSOR_POINT_EVENT, 0, 0, 0, 0, 0);
}
}
add_process(PROCESSOR_PHASE_EVENT, 0, 0, 0, PHASE_DRAW, 0);
return FALSE;
......@@ -4137,17 +4140,6 @@ int32 field::add_chain(uint16 step) {
clit->triggering_controler = phandler->current.controler;
clit->triggering_location = phandler->current.location;
clit->triggering_sequence = phandler->current.sequence;
if(phandler->data.type & TYPE_PENDULUM) {
effect* ceffect = pduel->new_effect();
ceffect->owner = phandler;
ceffect->handler = phandler;
ceffect->type = EFFECT_TYPE_SINGLE;
ceffect->code = EFFECT_CHANGE_TYPE;
ceffect->value = TYPE_PENDULUM + TYPE_SPELL;
ceffect->flag = EFFECT_FLAG_CANNOT_DISABLE;
ceffect->reset_flag = RESET_EVENT + 0x1fe0000;
phandler->add_effect(ceffect);
}
}
pduel->write_buffer8(MSG_CHAINING);
pduel->write_buffer32(phandler->data.code);
......@@ -4342,8 +4334,15 @@ int32 field::solve_chain(uint16 step, uint32 skip_new) {
effect* peffect = cait->triggering_effect;
if(cait->flag & CHAIN_DISABLE_ACTIVATE && is_chain_negatable(cait->chain_count)) {
remove_oath_effect(peffect);
if((peffect->flag & EFFECT_FLAG_COUNT_LIMIT) && (peffect->flag & EFFECT_FLAG_REPEAT))
peffect->reset_count += 0x100;
if((peffect->flag & EFFECT_FLAG_COUNT_LIMIT)) {
if(peffect->count_code == 0) {
if((peffect->flag & EFFECT_FLAG_REPEAT))
peffect->reset_count += 0x100;
} else {
if(peffect->count_code & 0x80000000)
dec_effect_code(peffect->count_code);
}
}
raise_event((card*)0, EVENT_CHAIN_NEGATED, peffect, 0, cait->triggering_player, cait->triggering_player, cait->chain_count);
process_instant_event();
core.units.begin()->step = 9;
......@@ -4360,11 +4359,11 @@ int32 field::solve_chain(uint16 step, uint32 skip_new) {
if((peffect->type & EFFECT_TYPE_ACTIVATE) && pcard->is_has_relation(peffect)) {
pcard->set_status(STATUS_ACTIVATED, TRUE);
pcard->enable_field_effect(TRUE);
if(pcard->data.type & TYPE_FIELD) {
card* fscard = player[1 - pcard->current.controler].list_szone[5];
if(fscard && fscard->is_position(POS_FACEUP))
fscard->enable_field_effect(FALSE);
}
// if(pcard->data.type & TYPE_FIELD) {
// card* fscard = player[1 - pcard->current.controler].list_szone[5];
// if(fscard && fscard->is_position(POS_FACEUP))
// fscard->enable_field_effect(FALSE);
// }
adjust_instant();
}
raise_event((card*)0, EVENT_CHAIN_SOLVING, peffect, 0, cait->triggering_player, cait->triggering_player, cait->chain_count);
......@@ -4439,12 +4438,13 @@ int32 field::solve_chain(uint16 step, uint32 skip_new) {
if((pcard->data.type & TYPE_EQUIP) && (cait->triggering_effect->type & EFFECT_TYPE_ACTIVATE)
&& !pcard->equiping_target && (pcard->current.location == LOCATION_SZONE))
pcard->set_status(STATUS_LEAVE_CONFIRMED, TRUE);
if((pcard->data.type & TYPE_FIELD) && (cait->triggering_effect->type & EFFECT_TYPE_ACTIVATE)
&& !pcard->is_status(STATUS_LEAVE_CONFIRMED) && pcard->is_has_relation(cait->triggering_effect)) {
card* fscard = player[1 - pcard->current.controler].list_szone[5];
if(fscard && fscard->is_position(POS_FACEUP))
destroy(fscard, 0, REASON_RULE, 1 - pcard->current.controler);
}
// new ruling allows 2 field cards
// if((pcard->data.type & TYPE_FIELD) && (cait->triggering_effect->type & EFFECT_TYPE_ACTIVATE)
// && !pcard->is_status(STATUS_LEAVE_CONFIRMED) && pcard->is_has_relation(cait->triggering_effect)) {
// card* fscard = player[1 - pcard->current.controler].list_szone[5];
// if(fscard && fscard->is_position(POS_FACEUP))
// destroy(fscard, 0, REASON_RULE, 1 - pcard->current.controler);
// }
pcard->release_relation(cait->triggering_effect);
if(cait->target_cards)
pduel->delete_group(cait->target_cards);
......
......@@ -220,6 +220,7 @@ public:
static int32 effect_set_target_range(lua_State *L);
static int32 effect_set_absolute_range(lua_State *L);
static int32 effect_set_count_limit(lua_State *L);
static int32 effect_set_count_code(lua_State *L);
static int32 effect_set_reset(lua_State *L);
static int32 effect_set_type(lua_State *L);
static int32 effect_set_property(lua_State *L);
......
......@@ -9,11 +9,17 @@ function c32646477.initial_effect(c)
e1:SetCategory(CATEGORY_DAMAGE)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1)
e1:SetCountCode(32646477)
e1:SetCondition(c32646477.condition)
e1:SetCost(c32646477.cost)
e1:SetTarget(c32646477.target)
e1:SetOperation(c32646477.operation)
c:RegisterEffect(e1)
end
function c32646477.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCurrentPhase()==PHASE_MAIN1
end
function c32646477.costfilter(c)
return c:GetLevel()>0
end
......
......@@ -6,6 +6,8 @@ function c98645731.initial_effect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCountLimit(1)
e1:SetCountCode(98645731+EFFECT_COUNT_CODE_OATH)
e1:SetCost(c98645731.cost)
e1:SetTarget(c98645731.target)
e1:SetOperation(c98645731.activate)
......
......@@ -9,6 +9,8 @@ function c9888196.initial_effect(c)
e1:SetCategory(CATEGORY_DESTROY)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetCountLimit(1)
e1:SetCountCode(EFFECT_COUNT_CODE_SINGLE)
e1:SetRange(LOCATION_MZONE)
e1:SetCondition(c9888196.con)
e1:SetTarget(c9888196.destg1)
......@@ -19,6 +21,8 @@ function c9888196.initial_effect(c)
e2:SetDescription(aux.Stringid(9888196,1))
e2:SetCategory(CATEGORY_DESTROY)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetCountLimit(1)
e2:SetCountCode(EFFECT_COUNT_CODE_SINGLE)
e2:SetRange(LOCATION_MZONE)
e2:SetCondition(c9888196.con)
e2:SetCost(c9888196.descost2)
......@@ -30,6 +34,8 @@ function c9888196.initial_effect(c)
e3:SetDescription(aux.Stringid(9888196,2))
e3:SetCategory(CATEGORY_HANDES+CATEGORY_TOGRAVE+CATEGORY_DAMAGE)
e3:SetType(EFFECT_TYPE_IGNITION)
e3:SetCountLimit(1)
e3:SetCountCode(EFFECT_COUNT_CODE_SINGLE)
e3:SetRange(LOCATION_MZONE)
e3:SetCondition(c9888196.con)
e3:SetCost(c9888196.hdcost)
......@@ -41,8 +47,7 @@ function c9888196.confilter(c)
return c:IsFaceup() and c:IsAttribute(ATTRIBUTE_LIGHT)
end
function c9888196.con(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():GetFlagEffect(9888196)==0
and Duel.IsExistingMatchingCard(c9888196.confilter,tp,0,LOCATION_MZONE,1,nil)
return Duel.IsExistingMatchingCard(c9888196.confilter,tp,0,LOCATION_MZONE,1,nil)
end
function c9888196.filter1(c)
return c:IsFacedown() and c:IsDestructable()
......@@ -53,7 +58,6 @@ function c9888196.destg1(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectTarget(tp,c9888196.filter1,tp,0,LOCATION_ONFIELD,1,1,nil)
e:GetHandler():RegisterFlagEffect(9888196,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0)
end
function c9888196.desop1(e,tp,eg,ep,ev,re,r,rp)
......@@ -76,7 +80,6 @@ function c9888196.destg2(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c9888196.filter2,tp,0,LOCATION_ONFIELD,1,nil) end
local g=Duel.GetMatchingGroup(c9888196.filter2,tp,0,LOCATION_ONFIELD,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0)
e:GetHandler():RegisterFlagEffect(9888196,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1)
end
function c9888196.desop2(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(c9888196.filter2,tp,0,LOCATION_ONFIELD,nil)
......@@ -92,7 +95,6 @@ function c9888196.hdtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetFieldGroupCount(tp,0,LOCATION_HAND)>0 end
Duel.SetOperationInfo(0,CATEGORY_HANDES,nil,0,1-tp,0)
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,0,1-tp,LOCATION_HAND)
e:GetHandler():RegisterFlagEffect(9888196,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1)
end
function c9888196.hdop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetFieldGroup(tp,0,LOCATION_HAND)
......
......@@ -639,6 +639,9 @@ GLOBALFLAG_DELAYED_QUICKEFFECT =0x8
GLOBALFLAG_DETACH_EVENT =0x10
GLOBALFLAG_MUST_BE_SMATERIAL =0x20
--
EFFECT_COUNT_CODE_OATH =0x80000000
EFFECT_COUNT_CODE_SINGLE =0x1
--
DUEL_TEST_MODE =0x01
DUEL_ATTACK_FIRST_TURN =0x02
DUEL_NO_CHAIN_HINT =0x04
......
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