this code i made for a edopro card script is not working as intended, it was not…
- User
this code i made for a edopro card script is not working as intended, it was not supposed to do this "All your monsters currently on the field are immune to opponent card effects until the end of this turn." , my code: --Black ops 3 - In Plain Sight --card effect description: All your monsters currently on the field are immune to opponent card effects until the end of this turn. local s,id = GetID() function s.initial_effect(c) local e1 = Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetTarget(s.target) e1:SetOperation(s.activate) c:RegisterEffect(e1) end -- Make all the player's monsters immune to all opponent card effects until the end of this turn. function s.target(e, tp, eg, ep, ev, re, r, rp, chk) if chk == 0 then return Duel.IsExistingMatchingCard(Card.IsMonster, tp, LOCATION_ONFIELD, 0, 1, nil) and Duel.IsExistingMatchingCard(Card.IsMonster, tp, LOCATION_ONFIELD, 0, 1, nil) end end function s.activate(e, tp, eg, ep, ev, re, r, rp) local c=e:GetHandler() local g = Duel.GetMatchingGroup(Card.IsMonster,tp,LOCATION_ONFIELD,0,nil) -- Loop through all cards in the group g and apply the immune effect using a for loop for tc in aux.Next(g) do local e1 = Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_IMMUNE_EFFECT) e1:SetRange(LOCATION_MZONE) e1:SetValue(s.efilter) e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END) tc:RegisterEffect(e1) end end function s.efilter(e,te) return te:GetOwner()~=e:GetOwner() end
Assistant
The problem with your code is that you are using the
forloop to apply the immune effect to all monsters on the field. However, theforloop only iterates over the monsters in theggroup, which is the group of monsters that match the conditionCard.IsMonster. This means that the immune effect will only be applied to the monsters in theggroup, and not to all monsters on the field.To fix this, you need to use the
forloop to iterate over all monsters on the field, and then apply the immune effect to each monster. You can do this by changing theforloop to the following:for tc in aux.Next(Duel.GetMatchingGroup(Card.IsMonster,tp,LOCATION_ONFIELD,0,nil)) doThis will iterate over all monsters on the field, and then you can apply the immune effect to each monster using the following code:
local e1 = Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_IMMUNE_EFFECT) e1:SetRange(LOCATION_MZONE) e1:SetValue(s.efilter) e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END) tc:RegisterEffect(e1)This will create a new effect that makes the monster immune to opponent card effects, and then register it with the monster.
Once you have made these changes, your code should work as intended.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.