name: 地獄の扉越し銃
card_text: ダメージを与える効果が発動した時に発動する事ができる。
  自分が受けるその効果ダメージを相手に与える。
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--reflect
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetCondition(s.condition)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	if re:IsActiveType(TYPE_SPELL + TYPE_TRAP) and not re:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		return false
  	end
  	local ex, cg, ct, cp, cv = Duel.GetOperationInfo(ev, CATEGORY_DAMAGE)
  	if ex and (cp == tp or cp == PLAYER_ALL) then
  		return true
  	end
  	ex, cg, ct, cp, cv = Duel.GetOperationInfo(ev, CATEGORY_RECOVER)
  	return ex and (cp == tp or cp == PLAYER_ALL) and Duel.IsPlayerAffectedByEffect(tp, EFFECT_REVERSE_RECOVER)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local cid = Duel.GetChainInfo(ev, CHAININFO_CHAIN_ID)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_REFLECT_DAMAGE)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	e1:SetLabel(cid)
  	e1:SetValue(s.refcon)
  	e1:SetReset(RESET_CHAIN)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.refcon(e, re, val, r, rp, rc)
  	local cc = Duel.GetCurrentChain()
  	if cc == 0 or bit.band(r, REASON_EFFECT) == 0 then
  		return
  	end
  	local cid = Duel.GetChainInfo(0, CHAININFO_CHAIN_ID)
  	return cid == e:GetLabel()
  end
  
  
source_text: 地獄の扉越し銃
  ダメージを与える効果が発動した時に発動する事ができる。
  自分が受けるその効果ダメージを相手に与える。
target_text: -- 地獄の扉越し銃
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--reflect
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetCondition(s.condition)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	if re:IsActiveType(TYPE_SPELL + TYPE_TRAP) and not re:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		return false
  	end
  	local ex, cg, ct, cp, cv = Duel.GetOperationInfo(ev, CATEGORY_DAMAGE)
  	if ex and (cp == tp or cp == PLAYER_ALL) then
  		return true
  	end
  	ex, cg, ct, cp, cv = Duel.GetOperationInfo(ev, CATEGORY_RECOVER)
  	return ex and (cp == tp or cp == PLAYER_ALL) and Duel.IsPlayerAffectedByEffect(tp, EFFECT_REVERSE_RECOVER)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local cid = Duel.GetChainInfo(ev, CHAININFO_CHAIN_ID)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_REFLECT_DAMAGE)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	e1:SetLabel(cid)
  	e1:SetValue(s.refcon)
  	e1:SetReset(RESET_CHAIN)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.refcon(e, re, val, r, rp, rc)
  	local cc = Duel.GetCurrentChain()
  	if cc == 0 or bit.band(r, REASON_EFFECT) == 0 then
  		return
  	end
  	local cid = Duel.GetChainInfo(0, CHAININFO_CHAIN_ID)
  	return cid == e:GetLabel()
  end
  
  