ygo吧 关注:3,641贴子:15,240
  • 2回复贴,共1

关于自定义卡片脚本的一些疑问。

只看楼主收藏回复

本人是YGO新手,想在自己搭的服务器上用自己写的卡玩一玩,但是卡的脚本编写一直存在问题,所以想在此请教一下各位大佬,看能否有办法实现。

该自定义系列的卡2效果都相同,就是模仿的珠泪的送墓融合(虽然这个没有必须有这张卡作为素材的要求,要强不少,不过可以改的)进行送墓同调。
目前代码主要是2效果无法实现。送去墓地之后可以选同调怪兽,但是在选择同调素材时却会将无法同调的素材也选进来。例子:
场上:自定义的等级2、螺丝刺猬、IP莱娜、宇宙耀变龙
墓地中的卡:神树之圣像骑士、虹光之宣告者、武力军奏、花园蔷薇少女、自定义的等级1(送墓发效果)
手卡:死者苏生、自定义的等级1
同调召唤的怪兽:流天类星龙
期望的行为:选择素材时只会有虹光之宣告者、武力军奏、花园蔷薇少女
实际上的行为:以下怪兽都成为了可选择素材:场上的自定义的等级2;手卡的自定义的等级1;墓地的神树之圣像骑士、虹光之宣告者、武力军奏、花园蔷薇少女、自定义的等级1。并且是确实可以选择的。
望各位大佬不吝赐教,感激不尽。


IP属地:四川1楼2023-04-22 16:30回复
    这里贴一下相关代码:
    function this.initial_effect(c)
    ...
    local e2=Effect.CreateEffect(c)
    e2:SetDescription(aux.Stringid(id,1))
    e2:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_GRAVE_ACTION)
    e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
    e2:SetCode(EVENT_TO_GRAVE) e2:SetCountLimit(1,id+offset)
    e2:SetProperty(EFFECT_FLAG_DELAY)
    e2:SetCondition(this.condition)
    e2:SetTarget(this.target)
    e2:SetOperation(this.operation)
    c:RegisterEffect(e2)
    end
    --2效果的发动时段,不能是伤害计算阶段
    function this.condition(e,tp,eg,ep,ev,re,r,rp)
    local ph=Duel.GetCurrentPhase()
    return ph~=PHASE_DAMAGE and ph~=PHASE_DAMAGE_CAL
    end
    --2效果场上·墓地卡片筛选,要求表侧表示、有等级且能够返回卡组
    function this.synfilter1(c)
    return c:IsFaceup() and c:IsType(TYPE_MONSTER) and not (c:IsType(TYPE_LINK) or c:IsType(TYPE_XYZ)) and c:IsAbleToDeck() and c:IsCanBeSynchroMaterial()
    end
    --2效果手卡筛选,要求怪兽卡且能够返回卡组(没有等级的怪兽不会出现在手卡中)
    function this.synfilter2(c)
    return c:IsType(TYPE_MONSTER) and c:IsAbleToDeck() and c:IsCanBeSynchroMaterial()
    end
    --2效果手卡素材筛选,用于展示手卡素材
    function this.handfilter(c)
    return c:IsLocation(LOCATION_HAND)
    end
    function this.synmfilter(c,tp,syncard,mg)
    local ret=Duel.CheckSynchroMaterial(syncard,nil,this.synfilter2,1,mg:GetCount(),nil,mg)
    return ret
    end
    --2效果的效果目标,被同调召唤的怪兽
    function this.target(e,tp,eg,ep,ev,re,r,rp,chk)
    if chk==0 then
    local mg=Duel.GetMatchingGroup(this.synfilter1,tp,LOCATION_MZONE+LOCATION_GRAVE,LOCATION_MZONE,nil)
    local handmg=Duel.GetMatchingGroup(this.synfilter2,tp,LOCATION_HAND,0,nil)
    mg:Merge(handmg)
    return Duel.IsExistingMatchingCard(Card.IsSynchroSummonable,tp,LOCATION_EXTRA,0,1,nil,nil,mg)
    end
    Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
    end
    --2效果的效果操作,选素材进行同调召唤
    function this.operation(e,tp,eg,ep,ev,re,r,rp)
    local mg=Duel.GetMatchingGroup(this.synfilter1,tp,LOCATION_MZONE+LOCATION_GRAVE,LOCATION_MZONE,nil)
    local handmg=Duel.GetMatchingGroup(this.synfilter2,tp,LOCATION_HAND,0,nil)
    mg:Merge(handmg)
    local g2=Duel.GetMatchingGroup(Card.IsSynchroSummonable,tp,LOCATION_EXTRA,0,nil,nil,mg)
    if g2:GetCount()>0 then
    Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
    local sg=g2:Select(tp,1,1,nil)
    local syncard=sg:GetFirst() --要同调召唤的同调怪兽
    if syncard ~= nil then
    Debug.Message(syncard:IsHasEffect(EFFECT_SPSUMMON_PROC))
    Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SMATERIAL)
    local copymg=mg:Clone()
    local mg2=mg:Filter(this.synmfilter,nil,tp,syncard,copymg)
    local mat1=Duel.SelectSynchroMaterial(tp,syncard,this.synfilter2,nil,1,99,e:GetHandler(),mg2) --让玩家选择同调素材
    if mat1 ~= nil then
    --展示手卡中的同调素材
    if mat1:IsExists(this.handfilter,1,nil) then
    local showHandmg=mat1:Filter(this.handfilter,nil)
    Duel.ConfirmCards(1-tp,showHandmg)
    end
    syncard:SetMaterial(mat1) --设置同调素材
    aux.PlaceCardsOnDeckBottom(tp,mat1,REASON_EFFECT+REASON_MATERIAL+REASON_SYNCHRO)
    Duel.BreakEffect()
    Duel.SpecialSummon(syncard,SUMMON_TYPE_SYNCHRO,tp,tp,false,false,POS_FACEUP)
    syncard:CompleteProcedure()
    end
    end
    end
    --添加自肃
    local e2=Effect.CreateEffect(e:GetHandler())
    e2:SetType(EFFECT_TYPE_FIELD)
    e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
    e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
    e2:SetTargetRange(1,0) e2:SetTarget(this.synsplimit)
    e2:SetReset(RESET_PHASE+PHASE_END)
    Duel.RegisterEffect(e2,tp)
    end
    --2效果的自肃筛选,不是同调怪兽不能从额外卡组特殊召唤
    function this.synsplimit(e,c)
    return not c:IsType(TYPE_SYNCHRO) and c:IsLocation(LOCATION_EXTRA)
    end


    IP属地:四川2楼2023-04-22 16:37
    回复
      太难了,我只会抄现成的


      IP属地:上海来自Android客户端3楼2023-11-04 21:43
      回复