name: Worm
card_text: FLIP: If this card is flipped face-up by an opponent's monster's attack, inflict damage equal to half the ATK of the attacking monster.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--flip
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FLIP + EFFECT_TYPE_SINGLE)
  	e1:SetCategory(CATEGORY_DAMAGE)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTarget(s.damtg)
  	e1:SetOperation(s.damop)
  	c:RegisterEffect(e1)
  end
  function s.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	if Duel.GetCurrentPhase() == PHASE_DAMAGE and e:GetHandler() == Duel.GetAttackTarget() then
  		Duel.SetTargetPlayer(1 - tp)
  		Duel.SetTargetParam(math.floor(Duel.GetAttacker():GetAttack() / 2))
  		Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, math.floor(Duel.GetAttacker():GetAttack() / 2))
  	end
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetCurrentPhase() == PHASE_DAMAGE and e:GetHandler() == Duel.GetAttackTarget() then
  		local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  		Duel.Damage(p, d, REASON_EFFECT)
  	end
  end
  
  
source_text: Worm
  FLIP: If this card is flipped face-up by an opponent's monster's attack, inflict damage equal to half the ATK of the attacking monster.
target_text: -- Worm
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--flip
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FLIP + EFFECT_TYPE_SINGLE)
  	e1:SetCategory(CATEGORY_DAMAGE)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTarget(s.damtg)
  	e1:SetOperation(s.damop)
  	c:RegisterEffect(e1)
  end
  function s.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	if Duel.GetCurrentPhase() == PHASE_DAMAGE and e:GetHandler() == Duel.GetAttackTarget() then
  		Duel.SetTargetPlayer(1 - tp)
  		Duel.SetTargetParam(math.floor(Duel.GetAttacker():GetAttack() / 2))
  		Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, math.floor(Duel.GetAttacker():GetAttack() / 2))
  	end
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetCurrentPhase() == PHASE_DAMAGE and e:GetHandler() == Duel.GetAttackTarget() then
  		local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  		Duel.Damage(p, d, REASON_EFFECT)
  	end
  end
  
  