Skip to content

Commit

Permalink
fix & new scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Fluorohydride committed Mar 1, 2012
1 parent 380b599 commit f05fcc2
Show file tree
Hide file tree
Showing 46 changed files with 1,180 additions and 114 deletions.
3 changes: 2 additions & 1 deletion gframe/deck_con.cpp
Expand Up @@ -462,7 +462,8 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
deckManager.current_deck.side.insert(deckManager.current_deck.side.begin() + hovered_seq, draging_pointer);
else deckManager.current_deck.side.push_back(draging_pointer);
is_draging = false;
}
} else if (hovered_pos == 4)
is_draging = false;
} else {
if((hovered_pos == 1 && (draging_pointer->second.type & 0x802040)) || (hovered_pos == 2 && !(draging_pointer->second.type & 0x802040)) || hovered_pos == 4)
hovered_pos = 0;
Expand Down
30 changes: 1 addition & 29 deletions ocgcore/card.cpp
Expand Up @@ -1411,10 +1411,6 @@ int32 card::is_can_be_summoned(uint8 playerid, uint8 ignore_count, effect* peffe
effect_set eset;
filter_effect(EFFECT_SUMMON_COST, &eset);
for(int32 i = 0; i < eset.count; ++i) {
pduel->lua->add_param(this, PARAM_TYPE_CARD);
pduel->lua->add_param(playerid, PARAM_TYPE_INT);
if(!eset[i]->check_value_condition(2))
continue;
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(this, PARAM_TYPE_CARD);
pduel->lua->add_param(playerid, PARAM_TYPE_INT);
Expand Down Expand Up @@ -1508,10 +1504,6 @@ int32 card::is_can_be_flip_summoned(uint8 playerid) {
effect_set eset;
filter_effect(EFFECT_FLIPSUMMON_COST, &eset);
for(int32 i = 0; i < eset.count; ++i) {
pduel->lua->add_param(this, PARAM_TYPE_CARD);
pduel->lua->add_param(playerid, PARAM_TYPE_INT);
if(!eset[i]->check_value_condition(2))
continue;
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(this, PARAM_TYPE_CARD);
pduel->lua->add_param(playerid, PARAM_TYPE_INT);
Expand All @@ -1536,10 +1528,6 @@ int32 card::is_special_summonable(uint8 playerid) {
effect_set eset;
filter_effect(EFFECT_SPSUMMON_COST, &eset);
for(int32 i = 0; i < eset.count; ++i) {
pduel->lua->add_param(this, PARAM_TYPE_CARD);
pduel->lua->add_param(playerid, PARAM_TYPE_INT);
if(!eset[i]->check_value_condition(2))
continue;
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(this, PARAM_TYPE_CARD);
pduel->lua->add_param(playerid, PARAM_TYPE_INT);
Expand Down Expand Up @@ -1572,10 +1560,6 @@ int32 card::is_can_be_special_summoned(effect * reason_effect, uint32 sumtype, u
effect_set eset;
filter_effect(EFFECT_SPSUMMON_COST, &eset);
for(int32 i = 0; i < eset.count; ++i) {
pduel->lua->add_param(this, PARAM_TYPE_CARD);
pduel->lua->add_param(sumplayer, PARAM_TYPE_INT);
if(!eset[i]->check_value_condition(2))
continue;
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(this, PARAM_TYPE_CARD);
pduel->lua->add_param(sumplayer, PARAM_TYPE_INT);
Expand Down Expand Up @@ -1624,10 +1608,6 @@ int32 card::is_setable_mzone(uint8 playerid, uint8 ignore_count, effect* peffect
effect_set eset;
filter_effect(EFFECT_MSET_COST, &eset);
for(int32 i = 0; i < eset.count; ++i) {
pduel->lua->add_param(this, PARAM_TYPE_CARD);
pduel->lua->add_param(playerid, PARAM_TYPE_INT);
if(!eset[i]->check_value_condition(2))
continue;
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(this, PARAM_TYPE_CARD);
pduel->lua->add_param(playerid, PARAM_TYPE_INT);
Expand Down Expand Up @@ -1660,10 +1640,6 @@ int32 card::is_setable_szone(uint8 playerid) {
effect_set eset;
filter_effect(EFFECT_SSET_COST, &eset);
for(int32 i = 0; i < eset.count; ++i) {
pduel->lua->add_param(this, PARAM_TYPE_CARD);
pduel->lua->add_param(playerid, PARAM_TYPE_INT);
if(!eset[i]->check_value_condition(2))
continue;
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(this, PARAM_TYPE_CARD);
pduel->lua->add_param(playerid, PARAM_TYPE_INT);
Expand Down Expand Up @@ -1890,13 +1866,9 @@ int32 card::is_capable_attack_announce(uint8 playerid) {
return FALSE;
pduel->game_field->save_lp_cost();
effect_set eset;
pduel->game_field->filter_player_effect(playerid, EFFECT_ATTACK_COST, &eset);
pduel->game_field->filter_player_effect(playerid, EFFECT_ATTACK_COST, &eset, FALSE);
filter_effect(EFFECT_ATTACK_COST, &eset);
for(int32 i = 0; i < eset.count; ++i) {
pduel->lua->add_param(this, PARAM_TYPE_CARD);
pduel->lua->add_param(playerid, PARAM_TYPE_INT);
if(!eset[i]->check_value_condition(2))
continue;
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(this, PARAM_TYPE_CARD);
pduel->lua->add_param(playerid, PARAM_TYPE_INT);
Expand Down
4 changes: 0 additions & 4 deletions ocgcore/effect.cpp
Expand Up @@ -205,10 +205,6 @@ int32 effect::is_action_check(uint8 playerid) {
eset.clear();
pduel->game_field->filter_player_effect(playerid, EFFECT_ACTIVATE_COST, &eset);
for(int i = 0; i < eset.count; ++i) {
pduel->lua->add_param(this, PARAM_TYPE_EFFECT);
pduel->lua->add_param(playerid, PARAM_TYPE_INT);
if(!eset[i]->check_value_condition(2))
continue;
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(this, PARAM_TYPE_EFFECT);
pduel->lua->add_param(playerid, PARAM_TYPE_INT);
Expand Down
5 changes: 4 additions & 1 deletion ocgcore/libcard.cpp
Expand Up @@ -1175,10 +1175,13 @@ int32 scriptlib::card_is_chain_attackable(lua_State *L) {
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
duel* pduel = pcard->pduel;
int32 ac = 2;
if(lua_gettop(L) > 1)
ac = lua_tointeger(L, 2);
card* attacker = pduel->game_field->core.attacker;
if(attacker->is_status(STATUS_BATTLE_DESTROYED) || attacker->fieldid != pduel->game_field->core.pre_field[0]
|| !attacker->is_capable_attack_announce(pduel->game_field->infos.turn_player)
|| attacker->announce_count > 1) {
|| attacker->announce_count >= ac) {
lua_pushboolean(L, 0);
return 1;
}
Expand Down
8 changes: 7 additions & 1 deletion ocgcore/libduel.cpp
Expand Up @@ -581,8 +581,14 @@ int32 scriptlib::duel_confirm_decktop(lua_State *L) {
return 0;
uint32 count = lua_tointeger(L, 2);
duel* pduel = interpreter::get_duel_info(L);
if(count > pduel->game_field->player[playerid].list_main.size())
if(count >= pduel->game_field->player[playerid].list_main.size())
count = pduel->game_field->player[playerid].list_main.size();
else if(pduel->game_field->core.deck_reversed) {
pduel->write_buffer8(MSG_DECK_TOP);
pduel->write_buffer8(playerid);
pduel->write_buffer8(count);
pduel->write_buffer32((*(pduel->game_field->player[playerid].list_main.rbegin() + count))->data.code);
}
auto cit = pduel->game_field->player[playerid].list_main.rbegin();
pduel->write_buffer8(MSG_CONFIRM_DECKTOP);
pduel->write_buffer8(playerid);
Expand Down
30 changes: 18 additions & 12 deletions ocgcore/operations.cpp
Expand Up @@ -946,11 +946,12 @@ int32 field::summon(uint16 step, uint8 sumplayer, card* target, effect* proc, ui
effect_set eset;
target->filter_effect(EFFECT_SUMMON_COST, &eset);
for(int32 i = 0; i < eset.count; ++i) {
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(target, PARAM_TYPE_CARD);
pduel->lua->add_param(sumplayer, PARAM_TYPE_INT);
if(!eset[i]->check_value_condition(2))
if(!pduel->lua->check_condition(eset[i]->cost, 3))
continue;
if(eset[i]->cost) {
if(eset[i]->operation) {
core.sub_solving_event.push_back(nil_event);
add_process(PROCESSOR_EXECUTE_OPERATION, 0, eset[i], 0, sumplayer, 0);
}
Expand Down Expand Up @@ -1234,11 +1235,12 @@ int32 field::flip_summon(uint16 step, uint8 sumplayer, card * target) {
effect_set eset;
target->filter_effect(EFFECT_FLIPSUMMON_COST, &eset);
for(int32 i = 0; i < eset.count; ++i) {
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(target, PARAM_TYPE_CARD);
pduel->lua->add_param(sumplayer, PARAM_TYPE_INT);
if(!eset[i]->check_value_condition(2))
if(!pduel->lua->check_condition(eset[i]->cost, 3))
continue;
if(eset[i]->cost) {
if(eset[i]->operation) {
core.sub_solving_event.push_back(nil_event);
add_process(PROCESSOR_EXECUTE_OPERATION, 0, eset[i], 0, sumplayer, 0);
}
Expand Down Expand Up @@ -1314,11 +1316,12 @@ int32 field::mset(uint16 step, uint8 setplayer, card * target, effect * proc, ui
effect_set eset;
target->filter_effect(EFFECT_MSET_COST, &eset);
for(int32 i = 0; i < eset.count; ++i) {
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(target, PARAM_TYPE_CARD);
pduel->lua->add_param(setplayer, PARAM_TYPE_INT);
if(!eset[i]->check_value_condition(2))
if(!pduel->lua->check_condition(eset[i]->cost, 3))
continue;
if(eset[i]->cost) {
if(eset[i]->operation) {
core.sub_solving_event.push_back(nil_event);
add_process(PROCESSOR_EXECUTE_OPERATION, 0, eset[i], 0, setplayer, 0);
}
Expand Down Expand Up @@ -1496,11 +1499,12 @@ int32 field::sset(uint16 step, uint8 setplayer, uint8 toplayer, card * target) {
effect_set eset;
target->filter_effect(EFFECT_SSET_COST, &eset);
for(int32 i = 0; i < eset.count; ++i) {
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(target, PARAM_TYPE_CARD);
pduel->lua->add_param(setplayer, PARAM_TYPE_INT);
if(!eset[i]->check_value_condition(2))
if(!pduel->lua->check_condition(eset[i]->cost, 3))
continue;
if(eset[i]->cost) {
if(eset[i]->operation) {
core.sub_solving_event.push_back(nil_event);
add_process(PROCESSOR_EXECUTE_OPERATION, 0, eset[i], 0, setplayer, 0);
}
Expand Down Expand Up @@ -1545,11 +1549,12 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card * target) {
effect_set eset;
target->filter_effect(EFFECT_SPSUMMON_COST, &eset);
for(int32 i = 0; i < eset.count; ++i) {
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(target, PARAM_TYPE_CARD);
pduel->lua->add_param(sumplayer, PARAM_TYPE_INT);
if(!eset[i]->check_value_condition(2))
if(!pduel->lua->check_condition(eset[i]->cost, 3))
continue;
if(eset[i]->cost) {
if(eset[i]->operation) {
core.sub_solving_event.push_back(nil_event);
add_process(PROCESSOR_EXECUTE_OPERATION, 0, eset[i], 0, sumplayer, 0);
}
Expand Down Expand Up @@ -1743,11 +1748,12 @@ int32 field::special_summon_step(uint16 step, group * targets, card * target) {
eset.clear();
target->filter_effect(EFFECT_SPSUMMON_COST, &eset);
for(int32 i = 0; i < eset.count; ++i) {
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(target, PARAM_TYPE_CARD);
pduel->lua->add_param(target->summon_player, PARAM_TYPE_INT);
if(!eset[i]->check_value_condition(2))
if(!pduel->lua->check_condition(eset[i]->cost, 3))
continue;
if(eset[i]->cost) {
if(eset[i]->operation) {
core.sub_solving_event.push_back(nil_event);
add_process(PROCESSOR_EXECUTE_OPERATION, 0, eset[i], 0, target->summon_player, 0);
}
Expand Down
18 changes: 10 additions & 8 deletions ocgcore/processor.cpp
Expand Up @@ -2444,11 +2444,12 @@ int32 field::process_battle_command(uint16 step) {
filter_player_effect(infos.turn_player, EFFECT_ATTACK_COST, &eset, FALSE);
core.attacker->filter_effect(EFFECT_ATTACK_COST, &eset);
for(int32 i = 0; i < eset.count; ++i) {
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(core.attacker, PARAM_TYPE_CARD);
pduel->lua->add_param(infos.turn_player, PARAM_TYPE_INT);
if(!eset[i]->check_value_condition(2))
if(!pduel->lua->check_condition(eset[i]->cost, 3))
continue;
if(eset[i]->cost) {
if(eset[i]->operation) {
core.attack_cancelable = FALSE;
core.sub_solving_event.push_back(nil_event);
add_process(PROCESSOR_EXECUTE_OPERATION, 0, eset[i], 0, infos.turn_player, 0);
Expand Down Expand Up @@ -3246,8 +3247,7 @@ int32 field::process_battle_command(uint16 step) {
adjust_all();
if(core.chain_attack) {
if(core.attacker->is_status(STATUS_BATTLE_DESTROYED) || core.attacker->fieldid != core.pre_field[0]
|| !core.attacker->is_capable_attack_announce(infos.turn_player)
|| core.attacker->announce_count > 1)
|| !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)
Expand All @@ -3263,11 +3263,12 @@ int32 field::process_battle_command(uint16 step) {
filter_player_effect(infos.turn_player, EFFECT_ATTACK_COST, &eset, FALSE);
core.attacker->filter_effect(EFFECT_ATTACK_COST, &eset);
for(int32 i = 0; i < eset.count; ++i) {
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(core.attacker, PARAM_TYPE_CARD);
pduel->lua->add_param(infos.turn_player, PARAM_TYPE_INT);
if(!eset[i]->check_value_condition(2))
if(!pduel->lua->check_condition(eset[i]->cost, 3))
continue;
if(eset[i]->cost) {
if(eset[i]->operation) {
core.sub_solving_event.push_back(nil_event);
add_process(PROCESSOR_EXECUTE_OPERATION, 0, eset[i], 0, infos.turn_player, 0);
}
Expand Down Expand Up @@ -3545,11 +3546,12 @@ int32 field::add_chain(uint16 step) {
effect_set eset;
filter_player_effect(clit->triggering_player, EFFECT_ACTIVATE_COST, &eset);
for(int32 i = 0; i < eset.count; ++i) {
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(clit->triggering_effect, PARAM_TYPE_EFFECT);
pduel->lua->add_param(clit->triggering_player, PARAM_TYPE_INT);
if(!eset[i]->check_value_condition(2))
if(!pduel->lua->check_condition(eset[i]->cost, 3))
continue;
if(eset[i]->cost) {
if(eset[i]->operation) {
core.sub_solving_event.push_back(clit->evt);
add_process(PROCESSOR_EXECUTE_OPERATION, 0, eset[i], 0, clit->triggering_player, 0);
}
Expand Down
22 changes: 12 additions & 10 deletions script/c102380.lua
Expand Up @@ -25,18 +25,18 @@ function c102380.initial_effect(c)
e2:SetTarget(c102380.damtg)
e2:SetOperation(c102380.damop)
c:RegisterEffect(e2)
--cannot normal summon
--spsummon cost
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e3:SetCode(EVENT_SPSUMMON_SUCCESS)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetCode(EFFECT_SPSUMMON_COST)
e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e3:SetOperation(c102380.op2)
e3:SetCost(c102380.spcost)
e3:SetOperation(c102380.spcop)
c:RegisterEffect(e3)
end
function c102380.spcon(e,c)
if c==nil then return true end
local p=c:GetControler()
return not Duel.CheckNormalSummonActivity(p) and Duel.IsExistingMatchingCard(Card.IsReleaseable,p,0,LOCATION_MZONE,2,nil)
return Duel.IsExistingMatchingCard(Card.IsReleaseable,c:GetControler(),0,LOCATION_MZONE,2,nil)
end
function c102380.spop(e,tp,eg,ep,ev,re,r,rp,c)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE)
Expand All @@ -53,17 +53,19 @@ end
function c102380.damop(e,tp,eg,ep,ev,re,r,rp)
Duel.Damage(e:GetHandler():GetControler(),1000,REASON_EFFECT)
end
function c102380.op2(e,tp,eg,ep,ev,re,r,rp)
function c102380.spcost(e,c,tp)
return not Duel.CheckNormalSummonActivity(tp)
end
function c102380.spcop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local sp=c:GetSummonPlayer()
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CANNOT_SUMMON)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetReset(RESET_PHASE+RESET_END)
e1:SetTargetRange(1,0)
Duel.RegisterEffect(e1,sp)
Duel.RegisterEffect(e1,tp)
local e2=e1:Clone(e1)
e2:SetCode(EFFECT_CANNOT_MSET)
Duel.RegisterEffect(e2,sp)
Duel.RegisterEffect(e2,tp)
end
33 changes: 33 additions & 0 deletions script/c11287364.lua
@@ -0,0 +1,33 @@
--クイック·スパナイト
function c11287364.initial_effect(c)
--atk change
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(11287364,0))
e1:SetCategory(CATEGORY_ATKCHANGE)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e1:SetCode(EVENT_BE_MATERIAL)
e1:SetCondition(c11287364.atkcon)
e1:SetTarget(c11287364.atktg)
e1:SetOperation(c11287364.atkop)
c:RegisterEffect(e1)
end
function c11287364.atkcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsLocation(LOCATION_GRAVE) and r==REASON_SYNCHRO
end
function c11287364.atktg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1-tp) and chkc:IsFaceup() end
if chk==0 then return true end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
Duel.SelectTarget(tp,Card.IsFaceup,tp,0,LOCATION_MZONE,1,1,nil)
end
function c11287364.atkop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc and tc:IsRelateToEffect(e) and tc:IsFaceup() then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetReset(RESET_EVENT+0x1fe0000)
e1:SetValue(-500)
tc:RegisterEffect(e1)
end
end
1 change: 1 addition & 0 deletions script/c13093792.lua
Expand Up @@ -20,6 +20,7 @@ function c13093792.operation(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetDecktopGroup(tp,1)
local tc=g:GetFirst()
if tc:GetType()==TYPE_SPELL then
Duel.DisableShuffleCheck()
Duel.SendtoGrave(g,REASON_EFFECT)
local ae=tc:GetActivateEffect()
if tc:GetLocation()==LOCATION_GRAVE and ae then
Expand Down
27 changes: 27 additions & 0 deletions script/c1371589.lua
@@ -0,0 +1,27 @@
--吸血コアラ
function c1371589.initial_effect(c)
--recover
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(1371589,0))
e1:SetCategory(CATEGORY_RECOVER)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetCode(EVENT_BATTLE_DAMAGE)
e1:SetCondition(c1371589.condition)
e1:SetTarget(c1371589.target)
e1:SetOperation(c1371589.operation)
c:RegisterEffect(e1)
end
function c1371589.condition(e,tp,eg,ep,ev,re,r,rp)
return ep~=tp
end
function c1371589.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetTargetPlayer(tp)
Duel.SetTargetParam(ev)
Duel.SetOperationInfo(0,CATEGORY_RECOVER,0,0,tp,ev)
end
function c1371589.operation(e,tp,eg,ep,ev,re,r,rp)
local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)
Duel.Recover(p,d,REASON_EFFECT)
end

0 comments on commit f05fcc2

Please sign in to comment.