name: Generaider
card_text: While you control a Token, your opponent's monsters cannot target "Generaider" Effect Monsters for attacks. If a "Generaider" Effect Monster is destroyed by battle: Your opponent draws 1 card. You can only use this effect of "Generaider Boss Loot" once per turn.
external_ids: local SETCARD_ID_0 = 0x134 --Generaider
  
lua: local SETCARD_ID_0 = 0x134 --Generaider
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--atklimit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(0, LOCATION_MZONE)
  	e2:SetCondition(aux.tkfcon)
  	e2:SetValue(s.atkval)
  	c:RegisterEffect(e2)
  	--draw
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_DRAW)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e3:SetCode(EVENT_BATTLE_DESTROYED)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.drcon)
  	e3:SetTarget(s.drtg)
  	e3:SetOperation(s.drop)
  	c:RegisterEffect(e3)
  end
  function s.atkval(e, c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_EFFECT)
  end
  function s.cfilter(c)
  	return bit.band(c:GetPreviousTypeOnField(), TYPE_EFFECT) ~= 0 and c:IsPreviousSetCard(SETCARD_ID_0)
  end
  function s.drcon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.cfilter, 1, nil)
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(1)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, 1 - tp, 1)
  end
  function s.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
  
  
source_text: Generaider
  While you control a Token, your opponent's monsters cannot target "Generaider" Effect Monsters for attacks. If a "Generaider" Effect Monster is destroyed by battle: Your opponent draws 1 card. You can only use this effect of "Generaider Boss Loot" once per turn.
target_text: -- Generaider
  local SETCARD_ID_0 = 0x134 --Generaider
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--atklimit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(0, LOCATION_MZONE)
  	e2:SetCondition(aux.tkfcon)
  	e2:SetValue(s.atkval)
  	c:RegisterEffect(e2)
  	--draw
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_DRAW)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e3:SetCode(EVENT_BATTLE_DESTROYED)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.drcon)
  	e3:SetTarget(s.drtg)
  	e3:SetOperation(s.drop)
  	c:RegisterEffect(e3)
  end
  function s.atkval(e, c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_EFFECT)
  end
  function s.cfilter(c)
  	return bit.band(c:GetPreviousTypeOnField(), TYPE_EFFECT) ~= 0 and c:IsPreviousSetCard(SETCARD_ID_0)
  end
  function s.drcon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.cfilter, 1, nil)
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(1)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, 1 - tp, 1)
  end
  function s.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
  
  