name: Penguin
card_text: This card can attack directly. When this card inflicts battle damage to your opponent: You can target 1 Level 6 or lower monster your opponent controls; take control of it until the End Phase, but its effects are negated, also it cannot declare an attack, while you control it. You can only use this effect of "Penguin Torpedo" once per turn. At the end of the Damage Step, if this card attacked: Destroy this card.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--direct attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_DIRECT_ATTACK)
  	c:RegisterEffect(e1)
  	--control
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_CONTROL)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCode(EVENT_BATTLE_DAMAGE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.ctrcon)
  	e2:SetTarget(s.ctrtg)
  	e2:SetOperation(s.ctrop)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e3:SetCode(EVENT_DAMAGE_STEP_END)
  	e3:SetCondition(s.descon)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.ctrcon(e, tp, eg, ep, ev, re, r, rp)
  	return ep ~= tp
  end
  function s.ctrfilter(c)
  	return c:IsFaceup() and c:IsLevelBelow(6) and c:IsControlerCanBeChanged()
  end
  function s.ctrtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(1 - tp) and chkc:IsLocation(LOCATION_MZONE) and s.ctrfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.ctrfilter, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
  	local g = Duel.SelectTarget(tp, s.ctrfilter, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, g, 1, 0, 0)
  end
  function s.ctrop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.GetControl(tc, tp, PHASE_END, 1) ~= 0 then
  		if tc:IsFaceup() then
  			Duel.NegateRelatedChain(tc, RESET_TURN_SET)
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_DISABLE)
  			e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e1)
  			local e2 = Effect.CreateEffect(c)
  			e2:SetType(EFFECT_TYPE_SINGLE)
  			e2:SetCode(EFFECT_DISABLE_EFFECT)
  			e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e2:SetValue(RESET_TURN_SET)
  			e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e2)
  		end
  		local e3 = Effect.CreateEffect(c)
  		e3:SetType(EFFECT_TYPE_SINGLE)
  		e3:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE)
  		e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e3:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e3)
  	end
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetAttacker() == e:GetHandler() and e:GetHandler():IsRelateToBattle()
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, e:GetHandler(), 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToBattle() then
  		Duel.Destroy(c, REASON_EFFECT)
  	end
  end
  
  
source_text: Penguin
  This card can attack directly. When this card inflicts battle damage to your opponent: You can target 1 Level 6 or lower monster your opponent controls; take control of it until the End Phase, but its effects are negated, also it cannot declare an attack, while you control it. You can only use this effect of "Penguin Torpedo" once per turn. At the end of the Damage Step, if this card attacked: Destroy this card.
target_text: -- Penguin
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--direct attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_DIRECT_ATTACK)
  	c:RegisterEffect(e1)
  	--control
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_CONTROL)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCode(EVENT_BATTLE_DAMAGE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.ctrcon)
  	e2:SetTarget(s.ctrtg)
  	e2:SetOperation(s.ctrop)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e3:SetCode(EVENT_DAMAGE_STEP_END)
  	e3:SetCondition(s.descon)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.ctrcon(e, tp, eg, ep, ev, re, r, rp)
  	return ep ~= tp
  end
  function s.ctrfilter(c)
  	return c:IsFaceup() and c:IsLevelBelow(6) and c:IsControlerCanBeChanged()
  end
  function s.ctrtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(1 - tp) and chkc:IsLocation(LOCATION_MZONE) and s.ctrfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.ctrfilter, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
  	local g = Duel.SelectTarget(tp, s.ctrfilter, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, g, 1, 0, 0)
  end
  function s.ctrop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.GetControl(tc, tp, PHASE_END, 1) ~= 0 then
  		if tc:IsFaceup() then
  			Duel.NegateRelatedChain(tc, RESET_TURN_SET)
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_DISABLE)
  			e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e1)
  			local e2 = Effect.CreateEffect(c)
  			e2:SetType(EFFECT_TYPE_SINGLE)
  			e2:SetCode(EFFECT_DISABLE_EFFECT)
  			e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e2:SetValue(RESET_TURN_SET)
  			e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e2)
  		end
  		local e3 = Effect.CreateEffect(c)
  		e3:SetType(EFFECT_TYPE_SINGLE)
  		e3:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE)
  		e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e3:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e3)
  	end
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetAttacker() == e:GetHandler() and e:GetHandler():IsRelateToBattle()
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, e:GetHandler(), 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToBattle() then
  		Duel.Destroy(c, REASON_EFFECT)
  	end
  end
  
  