name: Hero
card_text: When an "Elemental HERO" monster you control is destroyed by battle: Your opponent chooses and reveals 1 random card from your hand, then, if it is an "Elemental HERO" monster, you destroy 1 monster your opponent controls and Special Summon the chosen monster.
external_ids: local SETCARD_ID_0 = 0x3008 --Elemental
  
lua: local SETCARD_ID_0 = 0x3008 --Elemental
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_BATTLE_DESTROYED)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsPreviousControler(tp)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.cfilter, 1, nil, tp)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsSetCard, tp, LOCATION_HAND, 0, 1, nil, 0x3008)
  	end
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, LOCATION_HAND, 0)
  	local sg = g:RandomSelect(1 - tp, 1)
  	local tc = sg:GetFirst()
  	if tc then
  		Duel.ConfirmCards(1 - tp, tc)
  		if tc:IsSetCard(SETCARD_ID_0) and tc:IsType(TYPE_MONSTER) then
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  			local dg = Duel.SelectMatchingCard(tp, aux.TRUE, tp, 0, LOCATION_MZONE, 1, 1, nil)
  			Duel.Destroy(dg, REASON_EFFECT)
  			if Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP) == 0 then
  				Duel.ShuffleHand(tp)
  			end
  		else
  			Duel.ShuffleHand(tp)
  		end
  	end
  end
  
  
source_text: Hero
  When an "Elemental HERO" monster you control is destroyed by battle: Your opponent chooses and reveals 1 random card from your hand, then, if it is an "Elemental HERO" monster, you destroy 1 monster your opponent controls and Special Summon the chosen monster.
target_text: -- Hero
  local SETCARD_ID_0 = 0x3008 --Elemental
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_BATTLE_DESTROYED)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsPreviousControler(tp)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.cfilter, 1, nil, tp)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsSetCard, tp, LOCATION_HAND, 0, 1, nil, 0x3008)
  	end
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, LOCATION_HAND, 0)
  	local sg = g:RandomSelect(1 - tp, 1)
  	local tc = sg:GetFirst()
  	if tc then
  		Duel.ConfirmCards(1 - tp, tc)
  		if tc:IsSetCard(SETCARD_ID_0) and tc:IsType(TYPE_MONSTER) then
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  			local dg = Duel.SelectMatchingCard(tp, aux.TRUE, tp, 0, LOCATION_MZONE, 1, 1, nil)
  			Duel.Destroy(dg, REASON_EFFECT)
  			if Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP) == 0 then
  				Duel.ShuffleHand(tp)
  			end
  		else
  			Duel.ShuffleHand(tp)
  		end
  	end
  end
  
  