Jump to content

YGOPro Scripting Help Thread


Flash Flyer - Sakura

Recommended Posts

Equip only to a Level 8 or higher "Voidslayer" Warrior-Type monster. This card and the equipped monster cannot be targeted or destroyed by your opponent's card effects. If the equipped monster destroys an opponent's monster by battle: You can inflict damage to your opponent equal to the ATK of the destroyed monster. If the equipped monster is destroyed by battle: Inflict damage to your opponent equal to the ATK of the equipped monster. You cannot Normal or Special Summon monsters. You can only activate 1 "Sword of the Ultimate Voidslayer" once per duel. 

(i dont have all the effects coded)

 

--Sword of the Ultimate Voidslayer
function c22023901.initial_effect©
--Activate
local e1=Effect.CreateEffect©
e1:SetCategory(CATEGORY_EQUIP)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetTarget(c22023901.target)
e1:SetOperation(c22023901.operation)
c:RegisterEffect(e1)
--Equip limit
local e2=Effect.CreateEffect©
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_EQUIP_LIMIT)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetValue(c22023901.eqlimit)
c:RegisterEffect(e2)
--damage1
local e3=Effect.CreateEffect©
e3:SetDescription(aux.Stringid(22023901,0))
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e3:SetCategory(CATEGORY_DAMAGE)
e3:SetCode(EVENT_LEAVE_FIELD)
e3:SetCondition(c22023901.damcon)
e3:SetTarget(c22023901.damtg)
e3:SetOperation(c22023901.damop)
c:RegisterEffect(e3)
--damage2
local e4=Effect.CreateEffect©
e4:SetDescription(aux.Stringid(22023901,0))
e4:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e4:SetCode(EVENT_BATTLE_DESTROYING)
e4:SetRange(LOCATION_SZONE)
e4:SetCondition(c22023901.damcon2)
e4:SetTarget(c22023901.damtg2)
e4:SetOperation(c22023901.damop2)
c:RegisterEffect(e4)
end
function c22023901.eqlimit(e,c)
return c:IsLevelAbove(8) and c:IsSetCard(0x378) and c:IsRace(RACE_WARRIOR)
end
function c22023901.filter©
return c:IsFaceup() and c:IsLevelAbove(8) and c:IsSetCard(0x378) and c:IsRace(RACE_WARRIOR)
end
function c22023901.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and c22023901.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c22023901.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
Duel.SelectTarget(tp,c22023901.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0)
end
function c22023901.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) and tc:IsFaceup() then
Duel.Equip(tp,c,tc)
end
end
function c22023901.damcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local ec=c:GetPreviousEquipTarget()
return c:IsReason(REASON_LOST_TARGET) and ec:IsLocation(LOCATION_GRAVE)
end
function c22023901.damtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
local dam=e:GetHandler():GetPreviousEquipTarget():GetAttack()
Duel.SetTargetPlayer(1-tp)
Duel.SetTargetParam(dam)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,dam)
end
function c22023901.damop(e,tp,eg,ep,ev,re,r,rp)
local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)
Duel.Damage(p,d,REASON_EFFECT)
end
function c22023901.damcon2(e,tp,eg,ep,ev,re,r,rp)
local ec=eg:GetFirst()
local bc=ec:GetBattleTarget()
return e:GetHandler():GetEquipTarget()==eg:GetFirst() and bc:IsReason(REASON_BATTLE)
end
function c22023901.damtg2(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
local tc=e:GetHandler():GetBattleTarget()
Duel.SetTargetGroup(tc)
local dam=bc:GetAttack()
if dam<0 then dam=0 end
Duel.SetTargetPlayer(1-tp)
Duel.SetTargetParam(dam)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,dam)
end
function c22023901.damop2(e,tp,eg,ep,ev,re,r,rp)
local ec=eg:GetFirst()
local bc=ec:GetBattleTarget()
if tc:IsRelateToEffect(e) then
local p=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER)
local dam=tc:GetAttack()
if dam<0 then dam=0 end
Duel.Damage(p,dam,REASON_EFFECT)
end
end
Link to comment
Share on other sites

  • 4 weeks later...

I've never done any coding before, but I've managed to get most of my card working. It's effect is

 

Once per turn, you may discard a "Danmaku" card: Special Summon 1 "Kaleidoscope" monster from your deck and then shuffle this monster into your deck.

I got the summon part done by taking Summoner Monk and just changing its criteria, but I'm struggling to find a way to put it back into the deck after it summons the monster. At first I tried looking at effects that move the monster that was summoned to see if I could just retarget its effect, but I couldn't quite figure out how. Not to mention most of the time I couldn't get the card to go into the deck, anyway.

 

Here's the code:

--Kaleidoscope Aya
function c52156884.initial_effect(c)
	--special summon
	local e1=Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(52156884,1))
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e1:SetType(EFFECT_TYPE_IGNITION)
	e1:SetCountLimit(1)
	e1:SetRange(LOCATION_MZONE)
	e1:SetCost(c52156884.spcost)
	e1:SetTarget(c52156884.sptg)
	e1:SetOperation(c52156884.spop)
	c:RegisterEffect(e1)
end
function c52156884.costfilter(c)
	return c:IsSetCard(0x515) and c:IsDiscardable()
end
function c52156884.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
	if chk==0 then return Duel.IsExistingMatchingCard(c52156884.costfilter,tp,LOCATION_HAND,0,1,e:GetHandler()) end
	Duel.DiscardHand(tp,c52156884.costfilter,1,1,REASON_COST+REASON_DISCARD)
end
function c52156884.filter(c,e,tp)
	return c:IsSetCard(0x514) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c52156884.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
	if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
		and Duel.IsExistingMatchingCard(c52156884.filter,tp,LOCATION_DECK,0,1,nil,e,tp) end
	Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)
end
function c52156884.spop(e,tp,eg,ep,ev,re,r,rp)
	if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
	local g=Duel.SelectMatchingCard(tp,c52156884.filter,tp,LOCATION_DECK,0,1,1,nil,e,tp)
	local tc=g:GetFirst()
	if tc then
		Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
	end
end

Link to comment
Share on other sites

 

I've never done any coding before, but I've managed to get most of my card working. It's effect is

I got the summon part done by taking Summoner Monk and just changing its criteria, but I'm struggling to find a way to put it back into the deck after it summons the monster. At first I tried looking at effects that move the monster that was summoned to see if I could just retarget its effect, but I couldn't quite figure out how. Not to mention most of the time I couldn't get the card to go into the deck, anyway.

 

Here's the code:

--Kaleidoscope Aya
function c52156884.initial_effect(c)
	--special summon
	local e1=Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(52156884,1))
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e1:SetType(EFFECT_TYPE_IGNITION)
	e1:SetCountLimit(1)
	e1:SetRange(LOCATION_MZONE)
	e1:SetCost(c52156884.spcost)
	e1:SetTarget(c52156884.sptg)
	e1:SetOperation(c52156884.spop)
	c:RegisterEffect(e1)
end
function c52156884.costfilter(c)
	return c:IsSetCard(0x515) and c:IsDiscardable()
end
function c52156884.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
	if chk==0 then return Duel.IsExistingMatchingCard(c52156884.costfilter,tp,LOCATION_HAND,0,1,e:GetHandler()) end
	Duel.DiscardHand(tp,c52156884.costfilter,1,1,REASON_COST+REASON_DISCARD)
end
function c52156884.filter(c,e,tp)
	return c:IsSetCard(0x514) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c52156884.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
	if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
		and Duel.IsExistingMatchingCard(c52156884.filter,tp,LOCATION_DECK,0,1,nil,e,tp) end
	Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)
end
function c52156884.spop(e,tp,eg,ep,ev,re,r,rp)
	if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
	local g=Duel.SelectMatchingCard(tp,c52156884.filter,tp,LOCATION_DECK,0,1,1,nil,e,tp)
	local tc=g:GetFirst()
	if tc then
		Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
	end
end

function c52156884.sptg(e,tp,eg,ep,ev,re,r,rp,chk)

    if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0

        and Duel.IsExistingMatchingCard(c52156884.filter,tp,LOCATION_DECK,0,1,nil,e,tp)

  and e:GetHandler():IsAbleToDeck() end

    Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)

end

 

function c52156884.spop(e,tp,eg,ep,ev,re,r,rp)

  local c=e:GetHandler()

   if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end

    Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)

    local g=Duel.SelectMatchingCard(tp,c52156884.filter,tp,LOCATION_DECK,0,1,1,nil,e,tp)

    local tc=g:GetFirst()

    if tc then

        Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)

    end

    Duel.SendtoDeck(c,nil,2,REASON_EFFECT)

end

 

Changes are in bold. See if this works for you.

Link to comment
Share on other sites

function c52156884.sptg(e,tp,eg,ep,ev,re,r,rp,chk)

    if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0

        and Duel.IsExistingMatchingCard(c52156884.filter,tp,LOCATION_DECK,0,1,nil,e,tp)

  and e:GetHandler():IsAbleToDeck() end

    Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)

end

 

function c52156884.spop(e,tp,eg,ep,ev,re,r,rp)

  local c=e:GetHandler()

   if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end

    Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)

    local g=Duel.SelectMatchingCard(tp,c52156884.filter,tp,LOCATION_DECK,0,1,1,nil,e,tp)

    local tc=g:GetFirst()

    if tc then

        Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)

    end

    Duel.SendtoDeck(c,nil,2,REASON_EFFECT)

end

 

Changes are in bold. See if this works for you.

Yes! Works perfectly, thank you!

 

Just for future reference, I'm guessing that the first bolded part checks if the monster can be shuffled and the second bolded part designates the monster to be shuffled at the third bolded part?

Link to comment
Share on other sites

Ok, here's another one.

 

Activate this card only if you control "Kaleidoscope Marisa": Target 1 on the field; destroy it, then if you do, banish 1 "Danmaku" card not named "Danmaku: Master Spark" from your Graveyard. On your End Phase, add the banished card to your hand.

At first I couldn't figure out how to run the two effects in parallel, but eventually I found Number 39: Utopia Beyond. In the end, I was able to get the card to both destroy 1 card and banish another from my graveyard, but even after playing around with code from Gold Sarcophagus and Ehther the Heavenly Monarch I couldn't quite get the local effect created that would send the banished card to my hand on the End Phase - more accurately, I couldn't tack on any delayed effects without breaking the card (disabling its activation).

--Danmaku: Master Spark
function c53491957.initial_effect(c)
--Destruction
	local e1=Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(53491957,0))
	e1:SetCategory(CATEGORY_DESTROY+CATEGORY_REMOVE)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e1:SetCondition(c53491957.con)
	e1:SetTarget(c53491957.destg)
	e1:SetOperation(c53491957.desop)
	c:RegisterEffect(e1)
	end
function c53491957.fil1(c)
	return c:IsFaceup() and c:IsCode(89259097)
	end
function c53491957.con(e,tp,eg,ep,ev,re,r,rp)
	return Duel.IsExistingMatchingCard(c53491957.fil1,tp,LOCATION_ONFIELD,0,1,nil)
	end
function c53491957.fil2(c)
	return c:IsOnField() and c:IsDestructable()
	end
function c53491957.fil3(c)
	return c:IsLocation(LOCATION_GRAVE) and c:IsControler(tp) and c:IsAbleToRemove() and c:IsSetCard(0x515)
	end
function c53491957.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
	if chkc then return false end
	if chk==0 then return Duel.IsExistingTarget(c53491957.fil2,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil)
	and Duel.IsExistingTarget(c53491957.fil3,tp,LOCATION_GRAVE,0,1,e:GetHandler()) end
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
	local g1=Duel.SelectTarget(tp,c53491957.fil2,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,nil)
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
	local g2=Duel.SelectTarget(tp,c53491957.fil3,tp,LOCATION_GRAVE,0,1,1,nil,tp)
	Duel.SetOperationInfo(0,CATEGORY_DESTROY,g1,1,0,0)
	Duel.SetOperationInfo(0,CATEGORY_REMOVE,g2,1,0,0)
end
function c53491957.desop(e,tp,eg,ep,ev,re,r,rp)
	local ex,g1=Duel.GetOperationInfo(0,CATEGORY_DESTROY)
	local ex,g2=Duel.GetOperationInfo(0,CATEGORY_REMOVE)
	local tc1=g1:GetFirst()
	if not tc1:IsRelateToEffect(e) or Duel.Destroy(tc1,REASON_EFFECT)==0 then return end
	local tc2=g2:GetFirst()
	if tc2:IsRelateToEffect(e) then Duel.Remove(tc2,tp,POS_FACEUP)==0 then return end
	end
Link to comment
Share on other sites

So., fairly new to this and only really frankensteining stuff together right now, so I can't quite figure out how to do 2 things here. Firstly, the Ignition effects both can't activate, and I'm not entirely sure where my error is. Secondly I have no idea how how to make it so that the cards banished from the deck have to specifically be sent by Chain cards (I've given Chain cards the setcode of 203 (CB), not entirely sure how to mesh both archetypes of Iron Chain and Chain)

 

When a card(s) would be sent from the Deck to the Graveyard by the effect of a "Chain" card, remove it from play instead. Once per turn: You can return 2 banished "Iron Chain" monsters to your Graveyard; add 1 "Chain" card from your Deck to your hand. Once per turn: You can target 1 "Iron Chain" monster whose current ATK is higher than its original ATK; it gains 1000 ATK until the End Phase.

 

 

--Gaol Forge
function c77230003.initial_effect©
--Activate
local e1=Effect.CreateEffect©
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e1)
--remove
local e2=Effect.CreateEffect©
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetProperty(EFFECT_FLAG_SET_AVAILABLE)
e2:SetCode(EFFECT_TO_GRAVE_REDIRECT)
e2:SetRange(LOCATION_FZONE)
e2:SetTarget(c77230003.rmtarget)
e2:SetTargetRange(LOCATION_DECK,LOCATION_DECK)
e2:SetValue(LOCATION_REMOVED)
c:RegisterEffect(e2)
--atkchange
local e3=Effect.CreateEffect©
e3:SetDescription(aux.Stringid(77230003,0))
e3:SetCategory(CATEGORY_ATKCHANGE)
e3:SetType(EFFECT_TYPE_IGNITION)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
e3:SetRange(LOCATION_FZONE)
e3:SetCountLimit(1,77230003)
e3:SetOperation(c77230003.operation)
c:RegisterEffect(e3)
-- search
local e4=Effect.CreateEffect©
e4:SetDescription(aux.Stringid(77230003,0))
e4:SetCategory(CATEGORY_TOGRAVE+CATEGORY_SEARCH)
e4:SetType(EFFECT_TYPE_IGNITION)
e4:SetProperty(EFFECT_FLAG_CARD_TARGET)
e4:SetRange(LOCATION_FZONE)
e4:SetCountLimit(1)
e4:SetTarget(c77230003.thtg)
e4:SetOperation(c77230003.thop)
c:RegisterEffect(e4)
end
function c77230003.filter©
return c:IsFaceup() and c:GetAttack()~=c:GetBaseAttack() and c:IsSetCard(0x25)
end
function c77230003.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and c77230003.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c77230003.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
Duel.SelectTarget(tp,c77230003.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
end
function c77230003.operation(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and tc:IsFaceup() then
local atk=tc:GetAttack()
local batk=tc:GetBaseAttack()
if atk==batk then return end
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
if atk>batk then
e1:SetValue(1000)
else
e1:SetValue(-1000)
end
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e1)
end
end
function c77230003.tgfilter©
return c:IsFaceup() and c:IsSetCard(0x25)
end
function c77230003.thfilter©
return c:IsSetCard(0x25) and c:IsSetCard(0xCB) and c:IsAbleToHand()
end
function c77230003.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_REMOVED) and chkc:IsControler(tp) and c77230003.tgfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c77230003.tgfilter,tp,LOCATION_REMOVED,0,2,nil)
and Duel.IsExistingMatchingCard(c77230003.thfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectTarget(tp,c77230003.tgfilter,tp,LOCATION_REMOVED,0,2,2,nil)
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,g,2,0,0)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c77230003.thop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect,nil,e)
if g:GetCount()>0 then
Duel.SendtoGrave(g,REASON_EFFECT+REASON_RETURN)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local sg=Duel.SelectMatchingCard(tp,c77230003.thfilter,tp,LOCATION_DECK,0,1,1,nil)
if sg:GetCount()>0 then
Duel.SendtoHand(sg,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,sg)
end
end
end
 

 

 
Link to comment
Share on other sites

  • 1 year later...

Thanks FF - Sakura for informing me about this page. :)

I'm having a problem on an effect that triggers on Summon. It won't activate no matter what I do to the coding. I must be oblivious to this if it's something so simple. I've copied and pasted the coding from Union Hangar, and changed some things. I'm clueless to what is preventing the effect from triggering.

If a "Weapon Star" monster(s) is Normal or Special Summoned to your field (except during the Damage Step): You can target 1 of those monsters; equip 1 appropriate Equip Spell card from your Deck to that monster. 

--function c1003.initial_effect(c)
	--Activate
	local e1=Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	c:RegisterEffect(e1)
	--equip
	local e2=Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(1003,1))
	e2:SetCategory(CATEGORY_EQUIP)
	e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
	e2:SetCode(EVENT_SUMMON_SUCCESS)
	e2:SetRange(LOCATION_SZONE)
	e2:SetCountLimit(1)
	e2:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
	e2:SetTarget(c1003.eqtg)
	e2:SetOperation(c1003.eqop)
	c:RegisterEffect(e2)
	local e3=e2:Clone()
	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
	c:RegisterEffect(e3)
end

function c1003.eqtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
		if chkc then return eg:IsContains(chkc) and c1003.tgfilter(chkc,e,tp,true) end
	local g=eg:Filter(c1003.tgfilter,nil,e,tp,false)
	if chk==0 then return g:GetCount()>0 and Duel.GetLocationCount(tp,LOCATION_SZONE)>0 end
	if g:GetCount()==1 then
		Duel.SetTargetCard(g:GetFirst())
	else
		Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
		local tc=g:Select(tp,1,1,nil)
		Duel.SetTargetCard(tc)
	end
end
function C1003.eqop(e,tp,eg,ep,ev,re,r,rp)
	if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 then return end
	local c=e:GetHandler()
	local ec=c:GetEquipTarget()
	if c:IsRelateToEffect(e) and ec:IsFaceup() then
		Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
		local g=Duel.SelectMatchingCard(tp,c1003.cfilter,tp,LOCATION_DECK,0,1,1,nil)
		local tc=g:GetFirst()
		if not tc or not Duel.Equip(tp,tc,ec,true) then return end
	end
end

function c1003.tgfilter(c,e,tp,chk)
	return c:IsSetCard(0xD80) and c:IsLocation(LOCATION_MZONE) and c:IsFaceup() and c:IsControler(tp) and c:IsCanBeEffectTarget(e)
		and (chk or Duel.IsExistingMatchingCard(c1003.cfilter,tp,LOCATION_DECK,0,1,nil,c))
end

function c1003.cfilter(c)
	return c:IsSetCard(0x80) and c:IsType(TYPE_EQUIP) and not c:IsForbidden()
end
Link to comment
Share on other sites

I can't for the life of me figure out how to limit the summoning conditions of fusion monsters. I'm creating some new U.A. cards, a fusion that works by contact fusion, but can't be summoned by other ways. It was easy enough to get the fusion summoning to work, just stole it from Gladiator Beasts. But I can't figure out what makes it so that a monster can't be summoned by other ways. I've looked at and compared with other monsters that have that condition, but they all have the  c:EnableReviveLimit(), and I can't figure out the difference between aux.AddFusionProcCode2 and aux.AddFusionProcCodeFun.

Link to comment
Share on other sites

I think the difference between FusionProcCode2 and Func is that one just requires certain monsters, but substitutions are permitted, and the other is strict. Have you compared those two from the cards whose scripts you got them from?

 

You may want to borrow from either A-to-Z Dragon Buster Cannon or that Magnet Warrior Fusion; those two are Contact Fusion and have a Nomi clause. For the latter clause in general, did you look at stuff such as HERO Fusions (because most of them, for whatever reason, are Nomi).

Link to comment
Share on other sites

  • 2 months later...

I'm needing some help with a custom script I just finished. The effect I'm going for, and I know this is overpowered, is that the card can attack all opponent monster's once and if the monster is destroyed, I get to draw 1 card. The attack all script works but the drawing effect doesn't trigger at all. Here's the script for the drawing effect and the functions:

 

-- Destroy monster, draw 1 card
local e3=Effect.CreateEffect©
e3:SetDescription(aux.Stringid(53978178,1))
e3:SetCategory(CATEGORY_DRAW)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e3:SetCode(EVENT_BATTLE_DESTROYING)
e3:SetCondition(c53978178.condition)
e3:SetTarget(c53978178.target)
e3:SetOperation(c53978178.operation)
c:RegisterEffect(e3)
 
function c53978178.condition(e,tp,eg,ep,ev,re,r,rp)
return ep~=tp
end
 
function c53978178.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetTargetPlayer(tp)
Duel.SetTargetParam(1)
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1)
end
 
function c53978178.operation(e,tp,eg,ep,ev,re,r,rp)
local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)
Duel.Draw(p,d,REASON_EFFECT)
end

 

Any help given is appreciated!

Link to comment
Share on other sites

Does the card draw happen when your monster dies, or when the opponent's one does? I have access to my codes right now, but that one draws on its own destruction.

 

Though, looking at the YGOPro database, try ripping the code from Digital Bug LEDybug [minus the Xyz portion]. That one should already be coded. That is, if the opponent's monster is the trigger.

 

[spoiler=sample]

--Senkōkūra the High Savior Dragon
function c90000907.initial_effect(c)
	--synchro summon
	aux.AddSynchroProcedure(c,nil,aux.NonTuner,1)
	c:EnableReviveLimit()
	--targeting protection
	local e1=Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_SINGLE)
	e1:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
	e1:SetRange(LOCATION_MZONE)
	e1:SetCondition(c90000907.con)
	e1:SetValue(aux.tgoval)
	c:RegisterEffect(e1)
	--multiple shots
	local e2=Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_SINGLE)
	e2:SetCode(EFFECT_ATTACK_ALL)
	e2:SetValue(1)
	c:RegisterEffect(e2)
	--parting gift
	local e3=Effect.CreateEffect(c)
	e3:SetDescription(aux.Stringid(90000907,1))
	e3:SetCategory(CATEGORY_DRAW)
	e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
	e3:SetCode(EVENT_DESTROYED)
	e3:SetCondition(c90000907.drcon)
	e3:SetTarget(c90000907.drtg)
	e3:SetCountLimit(1,90000907)
	e3:SetOperation(c90000907.drop)
	c:RegisterEffect(e3)
end

--targeting immunity
function c90000907.con(e)
	return e:GetHandler():IsFaceup() and e:GetHandler():IsLocation(LOCATION_MZONE)
end
function c90000907.indval(e,re,tp)
	return e:GetHandler():GetControler()~=tp
end

--parting gift
function c90000907.drcon(e,tp,eg,ep,ev,re,r,rp)
	local c=e:GetHandler()
	return c:IsReason(REASON_BATTLE) or c:IsReason(REASON_EFFECT)
end

function c90000907.drtg(e,tp,eg,ep,ev,re,r,rp,chk)
	if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end
	Duel.SetTargetPlayer(tp)
	Duel.SetTargetParam(1)
	Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1)
end
function c90000907.drop(e,tp,eg,ep,ev,re,r,rp)
	local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)
	Duel.Draw(p,d,REASON_EFFECT)
end

 

 

Link to comment
Share on other sites

I tried using Digital Bug LEDybug's material effect and I've got most of the initial errors fixed, but the draw card part is still not working. When I attacked a monster and destroyed it, it gave me a script error: "38: Parameter 1 should be "Card"" The code I have so far is posted below with the error line marked.

 

-- Destroy monster, draw 1 card

local e3=Effect.CreateEffect©
e3:SetDescription(aux.Stringid(53978178,1))
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e3:SetCode(EVENT_BATTLE_DESTROYING)
e3:SetOperation(c53978178.efop)
c:RegisterEffect(e3)
end
 
function c53978178.efop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local rc=c:GetReasonCard()
local e1=Effect.CreateEffect(rc)           <------------------------------------------- Here's the problem area
e1:SetDescription(aux.Stringid(53978178,1))
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_BATTLE_DESTROYING)
e1:SetProperty(EFFECT_FLAG_CLIENT_HINT)
e1:SetOperation(c53978178.drop)
e1:SetReset(RESET_EVENT+0x1fe0000)
rc:RegisterEffect(e1,true)
if not rc:IsType(TYPE_EFFECT) then
     local e2=Effect.CreateEffect©
     e2:SetType(EFFECT_TYPE_SINGLE)
     e2:SetCode(EFFECT_ADD_TYPE)
    e2:SetValue(TYPE_EFFECT)
    e2:SetReset(RESET_EVENT+0x1fe0000)
    rc:RegisterEffect(e2,true)
   end
end
 
function c53978178.drop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_CARD,0,83048208)
Duel.Draw(tp,1,REASON_EFFECT)
end
Link to comment
Share on other sites

I should probably redirect you to the Discord channel that offers coding help for this, but one thing you can do is try looking at the other cards that have a "If this card destroys an opponent's monster" trigger.

 

(Will assume that you have updated your scripts and YGOPro to their latest version; older versions may render errors like this. If other cards are formatted similar to yours, but they work, then likely compatibility.)

 

====

I haven't checked this lately, but here's the code for a card I made that restores LP; should have the same trigger as yours (though as mentioned above, my code may be outdated for the newer versions of YGOPro OR it doesn't use the same functions that are giving you a problem). Might be the issue is because this isn't an internal effect on the monster, but rather that LED is giving it to the monster using it as material.

 

[spoiler=code]

--healing
	local e4=Effect.CreateEffect(c)
	e4:SetDescription(aux.Stringid(90000905,0))
	e4:SetCategory(CATEGORY_RECOVER)
	e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
	e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
	e4:SetCode(EVENT_BATTLE_DESTROYING)
	e4:SetCondition(c90000905.reccon)
	e4:SetTarget(c90000905.rectg)
	e4:SetOperation(c90000905.recop)
	c:RegisterEffect(e4)
--lp restoration
function c90000905.reccon(e,tp,eg,ep,ev,re,r,rp)
	local c=e:GetHandler()
	local bc=c:GetBattleTarget()
	return c:IsRelateToBattle()
end
function c90000905.rectg(e,tp,eg,ep,ev,re,r,rp,chk)
	if chk==0 then return true end
	local c=e:GetHandler()
	local bc=c:GetBattleTarget()
	local rec=bc:GetAttack()
	if bc:GetAttack() < bc:GetDefence() then rec=bc:GetDefence() end
	if rec<0 then rec=0 end
	Duel.SetTargetPlayer(tp)
	Duel.SetTargetParam(rec)
	Duel.SetOperationInfo(0,CATEGORY_RECOVER,nil,0,tp,rec)
end

function c90000905.recop(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

 

 

Link to comment
Share on other sites

  • 2 weeks later...

I need some help with this card I've been scripting. I'm new (started only a week ago) at scripting and have been having limited success, but this problem is beyond my abilities at the moment. Here's the card's flavor text, and its code in lua:

 

[spoiler=Flavor Text]76980807

1 "0x122" monster + 1 Fairy-Type monster

You can only control 1 "76980807". All "0x122" monsters you control gain 200 ATK and DEF for each Fairy-Type monster you control. If another Fairy-Type monster(s) is Normal or Special Summoned to your field, while you control this face-up card (except during the Damage Step): You can Special Summon 1 Level 4 or lower "0x122" monster from your Graveyard, but it cannot be used as a Fusion Material. You can only use this effect of "76980807" once per turn.

 

[spoiler=Code]function c76980807.initial_effect©

c:SetUniqueOnField(1,0,76980807)

--Fusion Material

c:EnableReviveLimit()

aux.AddFusionProcFun2(c,aux.FilterBoolFunction(Card.IsFusionSetCard,0x122),aux.FilterBoolFunction(Card.IsRace,RACE_FAIRY),true)

--Stat Boost

local e1=Effect.CreateEffect©

e1:SetType(EFFECT_TYPE_FIELD)

e1:SetCode(EFFECT_UPDATE_ATTACK)

e1:SetCondition(c76980807.efcon)

e1:SetRange(LOCATION_MZONE)

e1:SetTargetRange(LOCATION_MZONE,0)

e1:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x122))

e1:SetValue(c76980807.atkval)

c:RegisterEffect(e1)

local e2=e1:Clone()

e2:SetCode(EFFECT_UPDATE_DEFENSE)

c:RegisterEffect(e2)

--Special Summon

local e3=Effect.CreateEffect©

e3:SetCategory(CATEGORY_SPECIAL_SUMMON)

e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)

e3:SetCode(EVENT_SUMMON_SUCCESS)

e3:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)

e3:SetRange(LOCATION_MZONE)

e3:SetCountLimit(1,76980807)

e3:SetCondition(c76980807.spcon)

e3:SetTarget(c76980807.sptg)

e3:SetOperation(c76980807.spop)

c:RegisterEffect(e3)

local e4=e3:Clone()

e4:SetCode(EVENT_SPSUMMON_SUCCESS)

c:RegisterEffect(e4)

end

function c76980807.atkfilter©

return c:IsFaceup() and c:IsRace(RACE_FAIRY)

end

function c76980807.atkval(e,c)

return Duel.GetMatchingGroupCount(c76980807.atkfilter,c:GetControler(),LOCATION_MZONE,0,nil)*200

end

function c76980807.cfilter©

return c:IsFaceup() and c:IsSetCard(0x122)

end

function c76980807.efcon(e)

return Duel.IsExistingMatchingCard(c76980807.cfilter,e:GetHandlerPlayer(),LOCATION_MZONE,0,1,e:GetHandler())

end

function c76980807.cfilter(c,tp)

return c:IsFaceup() and c:IsRace(RACE_FAIRY) and c:IsControler(tp)

end

function c76980807.spcon(e,tp,eg,ep,ev,re,r,rp)

return not eg:IsContains(e:GetHandler()) and eg:IsExists(c76980807.cfilter,1,nil,tp)

end

function c76980807.spfilter(c,e,tp)

return c:IsLevelBelow(4) and c:IsSetCard(0x122) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)

end

function c76980807.sptg(e,tp,eg,ep,ev,re,r,rp,chk)

if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0

and Duel.IsExistingMatchingCard(c76980807.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end

Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_GRAVE)

end

function c76980807.spop(e,tp,eg,ep,ev,re,r,rp)

if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end

Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)

local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(c76980807.spfilter),tp, LOCATION_GRAVE,0,1,1,nil,e,tp)

local tc=g:GetFirst()

if tc then

Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)

local e1=Effect.CreateEffect(e:GetHandler())

e1:SetType(EFFECT_TYPE_SINGLE)

e1:SetCode(EFFECT_CANNOT_BE_FUSION_MATERIAL)

e1:SetValue(1)

e1:SetReset(RESET_EVENT+0x1fe0000)

tc:RegisterEffect(e1)

end

end

 

 

I'm using YGOPro-Percy to test my scripts (not sure if this might've been a factor, so I'm mentioning it). I've been incrementally testing each of cards with some success (basically adding each effect on one at a time and testing the card to see if it works). For this card, I did 3 different revisions (one to Fusion Summon the card, another to test the stat boost, and yet another to test the Summoning effect). I encountered the problem on the third revision, after I added in the Summoning effect. The previous effects worked more or less as they should have.

 

To add to this, I only discovered this problem because I have both myself and the devbot using the same "deck" which I'm using to test the cards ("Don't check Deck" and "Do not shuffle Deck" are enabled so we both started with the same predetermined hand). Had I not done this, I probablt wouldn't have found the problem.

 

So devbot ended up going first in the third test. It sets a single card. Come my turn, I draw Poly and immediately Fusion Summon this card, then Summon a Fairy to trigger both its effects. The Summoning effect activates, but the stat boost doesn't, much to my confusion. So I end my turn to see what devbot does, and sure enough, it Polys the card out and uses the Summoning effect, same as I did. However, the stat boost is working for it (cue further confusion). After that, I check the code, and find nothing noticiably wrong. So I test it again. This time I go first, Fusion Summon the card, and find the stat boost applying for me. Devbot repeats my move, only its copy isn't appling its effect anymore.

 

After a few more duels, I manage to figured out that the player who goes first in the Duel, not necessarily the first player to Fusion Summon the card, is the one gets the ATK boost applied to them. And that none of my other cards seem to influence this. So now my question is how and why is this happening?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...