name: Volcanic
card_text: If this card is Normal or Special Summoned: You can add 1 "Volcanic" card from your Deck to your hand, except "Volcanic Trooper". You can discard 1 card; Special Summon 1 "Bomb Token" (Pyro/FIRE/Level 1/ATK 1000/DEF 1000) to your opponent's field. Each time 1 is destroyed, its controller takes 500 damage. You can only use each effect of "Volcanic Trooper" once per turn.
external_ids: local CARD_ID_0 = 22411610 --Bomb Token
  local SETCARD_ID_0 = 0x32 --Volcanic
  
lua: local CARD_ID_0 = 22411610 --Bomb Token
  local SETCARD_ID_0 = 0x32 --Volcanic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--to hand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	--token
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCost(s.tkcost)
  	e3:SetTarget(s.tktg)
  	e3:SetOperation(s.tkop)
  	c:RegisterEffect(e3)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and not c:IsCode(id) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.tkcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD)
  end
  function s.tktg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(1 - tp, LOCATION_MZONE, tp) > 0 and Duel.IsPlayerCanSpecialSummonMonster(
  			tp,
  			id + 1,
  			0,
  			TYPES_TOKEN_MONSTER,
  			1000,
  			1000,
  			1,
  			RACE_PYRO,
  			ATTRIBUTE_FIRE,
  			POS_FACEUP,
  			1 - tp
  		)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, 0, 0)
  end
  function s.tkop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(1 - tp, LOCATION_MZONE, tp) <= 0 then
  		return
  	end
  	if not Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, 0, TYPES_TOKEN_MONSTER, 1000, 1000, 1, RACE_PYRO, ATTRIBUTE_FIRE, POS_FACEUP, 1 - tp) then
  		return
  	end
  	local token = Duel.CreateToken(tp, id + 1)
  	if Duel.SpecialSummonStep(token, 0, tp, 1 - tp, false, false, POS_FACEUP) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  		e1:SetCode(EVENT_LEAVE_FIELD)
  		e1:SetOperation(s.damop)
  		token:RegisterEffect(e1, true)
  	end
  	Duel.SpecialSummonComplete()
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsReason(REASON_DESTROY) then
  		Duel.Damage(c:GetPreviousControler(), 500, REASON_EFFECT)
  	end
  	e:Reset()
  end
  
  
source_text: Volcanic
  If this card is Normal or Special Summoned: You can add 1 "Volcanic" card from your Deck to your hand, except "Volcanic Trooper". You can discard 1 card; Special Summon 1 "Bomb Token" (Pyro/FIRE/Level 1/ATK 1000/DEF 1000) to your opponent's field. Each time 1 is destroyed, its controller takes 500 damage. You can only use each effect of "Volcanic Trooper" once per turn.
target_text: -- Volcanic
  local CARD_ID_0 = 22411610 --Bomb Token
  local SETCARD_ID_0 = 0x32 --Volcanic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--to hand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	--token
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCost(s.tkcost)
  	e3:SetTarget(s.tktg)
  	e3:SetOperation(s.tkop)
  	c:RegisterEffect(e3)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and not c:IsCode(id) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.tkcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD)
  end
  function s.tktg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(1 - tp, LOCATION_MZONE, tp) > 0 and Duel.IsPlayerCanSpecialSummonMonster(
  			tp,
  			id + 1,
  			0,
  			TYPES_TOKEN_MONSTER,
  			1000,
  			1000,
  			1,
  			RACE_PYRO,
  			ATTRIBUTE_FIRE,
  			POS_FACEUP,
  			1 - tp
  		)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, 0, 0)
  end
  function s.tkop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(1 - tp, LOCATION_MZONE, tp) <= 0 then
  		return
  	end
  	if not Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, 0, TYPES_TOKEN_MONSTER, 1000, 1000, 1, RACE_PYRO, ATTRIBUTE_FIRE, POS_FACEUP, 1 - tp) then
  		return
  	end
  	local token = Duel.CreateToken(tp, id + 1)
  	if Duel.SpecialSummonStep(token, 0, tp, 1 - tp, false, false, POS_FACEUP) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  		e1:SetCode(EVENT_LEAVE_FIELD)
  		e1:SetOperation(s.damop)
  		token:RegisterEffect(e1, true)
  	end
  	Duel.SpecialSummonComplete()
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsReason(REASON_DESTROY) then
  		Duel.Damage(c:GetPreviousControler(), 500, REASON_EFFECT)
  	end
  	e:Reset()
  end
  
  