Commit f6b9f6d3 authored by Argon's avatar Argon

counter

parent 17fd24d6
......@@ -3074,16 +3074,41 @@ int32 scriptlib::duel_add_custom_activity_counter(lua_State *L) {
int32 counter_filter = interpreter::get_function_handle(L, 3);
duel* pduel = interpreter::get_duel_info(L);
switch(activity_type) {
case 1:
case 1: {
auto iter = pduel->game_field->core.summon_counter.find(counter_id);
if(iter != pduel->game_field->core.summon_counter.end())
break;
pduel->game_field->core.summon_counter[counter_id] = std::make_pair(counter_filter, 0);
break;
case 2:
}
case 2: {
auto iter = pduel->game_field->core.normalsummon_counter.find(counter_id);
if(iter != pduel->game_field->core.normalsummon_counter.end())
break;
pduel->game_field->core.normalsummon_counter[counter_id] = std::make_pair(counter_filter, 0);
break;
case 3:
}
case 3: {
auto iter = pduel->game_field->core.spsummon_counter.find(counter_id);
if(iter != pduel->game_field->core.spsummon_counter.end())
break;
pduel->game_field->core.spsummon_counter[counter_id] = std::make_pair(counter_filter, 0);
break;
case 4:
}
case 4: {
auto iter = pduel->game_field->core.flipsummon_counter.find(counter_id);
if(iter != pduel->game_field->core.flipsummon_counter.end())
break;
pduel->game_field->core.flipsummon_counter[counter_id] = std::make_pair(counter_filter, 0);
break;
case 5:
}
case 5: {
auto iter = pduel->game_field->core.attack_counter.find(counter_id);
if(iter != pduel->game_field->core.attack_counter.end())
break;
pduel->game_field->core.attack_counter[counter_id] = std::make_pair(counter_filter, 0);
break;
}
default:
break;
}
......@@ -3095,20 +3120,45 @@ int32 scriptlib::duel_get_custom_activity_count(lua_State *L) {
int32 playerid = lua_tointeger(L, 2);
int32 activity_type = lua_tointeger(L, 3);
duel* pduel = interpreter::get_duel_info(L);
int32 val = 0;
switch(activity_type) {
case 1:
case 1:{
auto iter = pduel->game_field->core.summon_counter.find(counter_id);
if(iter != pduel->game_field->core.summon_counter.end())
val = iter->second.second;
break;
case 2:
}
case 2: {
auto iter = pduel->game_field->core.normalsummon_counter.find(counter_id);
if(iter != pduel->game_field->core.normalsummon_counter.end())
val = iter->second.second;
break;
case 3:
}
case 3: {
auto iter = pduel->game_field->core.spsummon_counter.find(counter_id);
if(iter != pduel->game_field->core.spsummon_counter.end())
val = iter->second.second;
break;
case 4:
}
case 4: {
auto iter = pduel->game_field->core.flipsummon_counter.find(counter_id);
if(iter != pduel->game_field->core.flipsummon_counter.end())
val = iter->second.second;
break;
case 5:
}
case 5: {
auto iter = pduel->game_field->core.attack_counter.find(counter_id);
if(iter != pduel->game_field->core.attack_counter.end())
val = iter->second.second;
break;
}
default:
break;
}
if(playerid == 0)
lua_pushinteger(L, val & 0xffff);
else
lua_pushinteger(L, (val >> 16) & 0xffff);
return 0;
}
int32 scriptlib::duel_venom_swamp_check(lua_State *L) {
......
......@@ -2006,6 +2006,23 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card * target) {
target->current.reason_effect = peffect;
target->current.reason_player = sumplayer;
target->summon_player = sumplayer;
core.spsummon_state_count[sumplayer]++;
for(auto& iter : core.spsummon_counter) {
auto& info = iter.second;
if(info.first) {
pduel->lua->add_param(peffect, PARAM_TYPE_EFFECT);
pduel->lua->add_param(sumplayer, PARAM_TYPE_INT);
pduel->lua->add_param(target->summon_info & 0xff00ffff, PARAM_TYPE_INT);
pduel->lua->add_param(positions, PARAM_TYPE_INT);
pduel->lua->add_param(sumplayer, PARAM_TYPE_INT);
if(!pduel->lua->check_condition(info.first, 5)) {
if(sumplayer == 0)
info.second += 0x1;
else
info.second += 0x10000;
}
}
}
break_effect();
return FALSE;
}
......@@ -2022,7 +2039,6 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card * target) {
pduel->write_buffer8(target->current.location);
pduel->write_buffer8(target->current.sequence);
pduel->write_buffer8(target->current.position);
core.spsummon_state_count[sumplayer]++;
return FALSE;
}
case 5: {
......@@ -2166,8 +2182,25 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card * target) {
pcard->current.reason_effect = peffect;
pcard->current.reason_player = sumplayer;
pcard->summon_player = sumplayer;
pcard->summon_info = (peffect->get_value(pcard) & 0xf00ffff) | SUMMON_TYPE_SPECIAL | ((uint32)target->current.location << 16);
pcard->summon_info = (peffect->get_value(pcard) & 0xff00ffff) | SUMMON_TYPE_SPECIAL | ((uint32)target->current.location << 16);
move_to_field(pcard, sumplayer, sumplayer, LOCATION_MZONE, POS_FACEUP);
core.spsummon_state_count[sumplayer]++;
for(auto& iter : core.spsummon_counter) {
auto& info = iter.second;
if(info.first) {
pduel->lua->add_param(peffect, PARAM_TYPE_EFFECT);
pduel->lua->add_param(sumplayer, PARAM_TYPE_INT);
pduel->lua->add_param(target->summon_info & 0xff00ffff, PARAM_TYPE_INT);
pduel->lua->add_param(POS_FACEUP, PARAM_TYPE_INT);
pduel->lua->add_param(sumplayer, PARAM_TYPE_INT);
if(!pduel->lua->check_condition(info.first, 5)) {
if(sumplayer == 0)
info.second += 0x1;
else
info.second += 0x10000;
}
}
}
return FALSE;
}
case 24: {
......@@ -2179,7 +2212,6 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card * target) {
pduel->write_buffer8(pcard->current.location);
pduel->write_buffer8(pcard->current.sequence);
pduel->write_buffer8(pcard->current.position);
core.spsummon_state_count[sumplayer]++;
if(pgroup->it != pgroup->container.end())
core.units.begin()->step = 22;
return FALSE;
......@@ -2312,6 +2344,22 @@ int32 field::special_summon_step(uint16 step, group * targets, card * target) {
target->enable_field_effect(FALSE);
target->set_status(STATUS_FLIP_SUMMONED, FALSE);
core.spsummon_state_count[target->summon_player]++;
for(auto& iter : core.spsummon_counter) {
auto& info = iter.second;
if(info.first) {
pduel->lua->add_param(core.reason_effect, PARAM_TYPE_EFFECT);
pduel->lua->add_param(target->summon_player, PARAM_TYPE_INT);
pduel->lua->add_param(target->summon_info & 0xff00ffff, PARAM_TYPE_INT);
pduel->lua->add_param(positions, PARAM_TYPE_INT);
pduel->lua->add_param(playerid, PARAM_TYPE_INT);
if(!pduel->lua->check_condition(info.first, 5)) {
if(playerid == 0)
info.second += 0x1;
else
info.second += 0x10000;
}
}
}
core.hint_timing[target->summon_player] |= TIMING_SPSUMMON;
move_to_field(target, target->summon_player, playerid, LOCATION_MZONE, positions);
return FALSE;
......
......@@ -4000,6 +4000,16 @@ int32 field::process_turn(uint16 step, uint8 turn_player) {
for(auto rit = effects.rechargeable.begin(); rit != effects.rechargeable.end(); ++rit)
if(!((*rit)->flag & EFFECT_FLAG_NO_TURN_RESET))
(*rit)->recharge();
for(auto& iter : core.summon_counter)
iter.second.second = 0;
for(auto& iter : core.normalsummon_counter)
iter.second.second = 0;
for(auto& iter : core.spsummon_counter)
iter.second.second = 0;
for(auto& iter : core.flipsummon_counter)
iter.second.second = 0;
for(auto& iter : core.attack_counter)
iter.second.second = 0;
infos.turn_id++;
infos.turn_player = turn_player;
pduel->write_buffer8(MSG_NEW_TURN);
......
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