Jump to content

YGOPRO custom card scripting help wanted


Blace

Recommended Posts

Card effect:
You can activate "Star Resonance Weapon" Spells/Traps from your hand during either player's turn. If a "Star Resonance Weapon" Spell/Trap is activated: You can add 1 "Star Resonance Weapon" card with a different name from that activated card from your Deck to your hand. You can only use this effect of "Weapon Star Black Rock Shooter" once per turn.

Apparently, there is no card effect in the game that allows you to activate Spells from the hand during the opponent's turn, so I have no idea how to get that work. And another problem I'm having is on the second effect unable to resolve. It activates, but it won't let me to search. No idea why.

 

--
function c1001.initial_effect(c)
	--activate from hand
	local e1=Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_FIELD)
	e1:SetCode(EFFECT_ACT_IN_HAND)
	e1:SetRange(LOCATION_MZONE)
	e1:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x80))
	e1:SetTargetRange(LOCATION_HAND,0)
	c:RegisterEffect(e1)
	local e2=e1:Clone()
	e2:SetCode(EFFECT_TRAP_ACT_IN_HAND)
	c:RegisterEffect(e2)
	--search
	local e0=Effect.CreateEffect(c)
	e0:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
	e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
	e0:SetCode(EVENT_CHAINING)
	e0:SetRange(LOCATION_MZONE)
	e0:SetOperation(aux.chainreg)
	c:RegisterEffect(e0)
	local e3=Effect.CreateEffect(c)
	e3:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
	e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
	e3:SetCode(EVENT_CHAIN_SOLVED)
	e3:SetProperty(EFFECT_FLAG_DELAY)
	e3:SetRange(LOCATION_MZONE)
	e3:SetCountLimit(1,1001)
	e3:SetCondition(c1001.condition)
	e3:SetTarget(c1001.target)
	e3:SetOperation(c1001.operation)
	c:RegisterEffect(e3)
end

function c1001.condition(e,tp,eg,ep,ev,re,r,rp)
	return re:IsHasType(EFFECT_TYPE_ACTIVATE) and re:IsActiveType(TYPE_SPELL+TYPE_TRAP) and re:GetHandler():IsSetCard(0x80)
end
function c1001.thfilter(c,rc)
	return c:IsSetCard(0x80) and not c:IsCode(rc:GetCode()) and c:IsAbleToHand()
end
function c1001.target(e,tp,eg,ep,ev,re,r,rp,chk)
	local rc=re:GetHandler()
	if chk==0 then return rc and Duel.IsExistingMatchingCard(c1001.thfilter,tp,LOCATION_DECK,0,1,nil,rc) end
	Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c1001.operation(e,tp,eg,ep,ev,re,r,rp)
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
	local g=Duel.SelectMatchingCard(tp,c1001.thfilter,tp,LOCATION_DECK,0,1,1,nil)
	if g:GetCount()>0 then
		Duel.SendtoHand(g,nil,REASON_EFFECT)
		Duel.ConfirmCards(1-tp,g)
	end
end

Link to comment
Share on other sites

  • 2 weeks later...

Dude, here's the script I made:

--Weapon Star Black Rock Shooter
--Original Card Idea by "Łîe"
--Script by TonyTony30
function c12345678.initial_effect(c)
	--activate from hand
	--WORKS ONLY FOR QUICK-PLAYS 
	local e1=Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_FIELD)
	e1:SetCode(EFFECT_QP_ACT_IN_NTPHAND)
	e1:SetRange(LOCATION_MZONE)
	e1:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x80))
	e1:SetTargetRange(LOCATION_HAND,0)
	c:RegisterEffect(e1)
	--WORKS FOR ALL TRAPS
	local e2=e1:Clone()
	e2:SetCode(EFFECT_TRAP_ACT_IN_HAND)
	c:RegisterEffect(e2)
	--search
	local e0=Effect.CreateEffect(c)
	e0:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
	e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
	e0:SetCode(EVENT_CHAINING)
	e0:SetRange(LOCATION_MZONE)
	e0:SetOperation(aux.chainreg)
	c:RegisterEffect(e0)
	local e3=Effect.CreateEffect(c)
	e3:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
	e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
	e3:SetCode(EVENT_CHAIN_SOLVING)
	e3:SetProperty(EFFECT_FLAG_DELAY)
	e3:SetRange(LOCATION_MZONE)
	e3:SetCountLimit(1,12345678)
	e3:SetTarget(c12345678.thtg)
	e3:SetOperation(c12345678.thop)
	c:RegisterEffect(e3)
end
function c12345678.thfilter(c,rc)
	return c:IsSetCard(0x80) and not c:IsCode(rc:GetCode()) and c:IsAbleToHand()
end
function c12345678.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
	local rc=re:GetHandler()
	if chk==0 then return rc and Duel.IsExistingMatchingCard(c12345678.thfilter,tp,LOCATION_DECK,0,1,nil,rc) end
	Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c12345678.thop(e,tp,eg,ep,ev,re,r,rp)
    local rc=re:GetHandler()
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
	local g=Duel.SelectMatchingCard(tp,c12345678.thfilter,tp,LOCATION_DECK,0,1,1,nil,rc)
	if g:GetCount()>0 then
		Duel.SendtoHand(g,nil,REASON_EFFECT)
		Duel.ConfirmCards(1-tp,g)
	end
end

Here's a few notes:

0) Change all the "12345678" with the ID you chose for the card you made

1) Regarding the "Activate Spell/Traps from hand": This effects works only with QUICK-PLAY SPELLS but there shouldn't be any problems with Traps.

2) The second effect works perfectly.

3) I don't know if you noticed but the Setcode of your Archetype (0x80) is the same of the Duston's one. (I don't know if you did that on purpose)

 

I hope you will find this helpful!

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...