name: Seismic
card_text: Destroy this card during your 3rd Standby Phase after activation. Activate this card when a face-up Dinosaur-Type monster you control is destroyed and sent to the Graveyard (except during the Damage Step): Choose 3 of your opponent's unused Spell & Trap Zones. Those Zones cannot be used. If this card destroys itself: You can target 1 Dinosaur-Type monster in your Graveyard; add that target to your hand.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--salvage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOHAND)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_CUSTOM + id)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c, tp)
  	return c:IsPreviousLocation(LOCATION_ONFIELD) and c:IsPreviousControler(tp) and c:IsReason(REASON_DESTROY) and c:IsRace(RACE_DINOSAUR)
  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.GetLocationCount(1 - tp, LOCATION_SZONE, PLAYER_NONE, 0) > 2
  	end
  	local c = e:GetHandler()
  	c:SetTurnCounter(0)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetCode(EVENT_PHASE + PHASE_STANDBY)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_SZONE)
  	e1:SetCondition(s.descon)
  	e1:SetOperation(s.desop)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	c:RegisterEffect(e1)
  	local dis = Duel.SelectDisableField(tp, 3, 0, LOCATION_SZONE, 0)
  	e:SetLabel(dis)
  	Duel.Hint(HINT_ZONE, tp, dis)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(1 - tp, LOCATION_SZONE, PLAYER_NONE, 0) < 3 then
  		return
  	end
  	local zone = e:GetLabel()
  	if tp == 1 then
  		zone = ((zone & 0xffff) << 16) | ((zone >> 16) & 0xffff)
  	end
  	--disable field
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetRange(LOCATION_SZONE)
  	e1:SetCode(EFFECT_DISABLE_FIELD)
  	e1:SetValue(zone)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	e:GetHandler():RegisterEffect(e1)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return tp == Duel.GetTurnPlayer()
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local ct = c:GetTurnCounter()
  	ct = ct + 1
  	c:SetTurnCounter(ct)
  	if ct == 3 and Duel.Destroy(c, REASON_EFFECT) > 0 then
  		Duel.RaiseSingleEvent(e:GetHandler(), EVENT_CUSTOM + id, e, 0, tp, tp, 0)
  	end
  end
  function s.thfilter(c)
  	return c:IsRace(RACE_DINOSAUR) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.thfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.thfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RTOHAND)
  	local g = Duel.SelectTarget(tp, s.thfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, g:GetCount(), 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc and tc:IsRelateToEffect(e) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, tc)
  	end
  end
  
  
source_text: Seismic
  Destroy this card during your 3rd Standby Phase after activation. Activate this card when a face-up Dinosaur-Type monster you control is destroyed and sent to the Graveyard (except during the Damage Step): Choose 3 of your opponent's unused Spell & Trap Zones. Those Zones cannot be used. If this card destroys itself: You can target 1 Dinosaur-Type monster in your Graveyard; add that target to your hand.
target_text: -- Seismic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--salvage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOHAND)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_CUSTOM + id)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c, tp)
  	return c:IsPreviousLocation(LOCATION_ONFIELD) and c:IsPreviousControler(tp) and c:IsReason(REASON_DESTROY) and c:IsRace(RACE_DINOSAUR)
  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.GetLocationCount(1 - tp, LOCATION_SZONE, PLAYER_NONE, 0) > 2
  	end
  	local c = e:GetHandler()
  	c:SetTurnCounter(0)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetCode(EVENT_PHASE + PHASE_STANDBY)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_SZONE)
  	e1:SetCondition(s.descon)
  	e1:SetOperation(s.desop)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	c:RegisterEffect(e1)
  	local dis = Duel.SelectDisableField(tp, 3, 0, LOCATION_SZONE, 0)
  	e:SetLabel(dis)
  	Duel.Hint(HINT_ZONE, tp, dis)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(1 - tp, LOCATION_SZONE, PLAYER_NONE, 0) < 3 then
  		return
  	end
  	local zone = e:GetLabel()
  	if tp == 1 then
  		zone = ((zone & 0xffff) << 16) | ((zone >> 16) & 0xffff)
  	end
  	--disable field
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetRange(LOCATION_SZONE)
  	e1:SetCode(EFFECT_DISABLE_FIELD)
  	e1:SetValue(zone)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	e:GetHandler():RegisterEffect(e1)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return tp == Duel.GetTurnPlayer()
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local ct = c:GetTurnCounter()
  	ct = ct + 1
  	c:SetTurnCounter(ct)
  	if ct == 3 and Duel.Destroy(c, REASON_EFFECT) > 0 then
  		Duel.RaiseSingleEvent(e:GetHandler(), EVENT_CUSTOM + id, e, 0, tp, tp, 0)
  	end
  end
  function s.thfilter(c)
  	return c:IsRace(RACE_DINOSAUR) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.thfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.thfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RTOHAND)
  	local g = Duel.SelectTarget(tp, s.thfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, g:GetCount(), 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc and tc:IsRelateToEffect(e) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, tc)
  	end
  end
  
  