name: Triamid
card_text: All Rock-Type monsters on the field gain 500 ATK. If a "Triamid" monster you control battles, your opponent's cards and effects cannot be activated until the end of the Damage Step. If this face-up card in the Field Zone is sent to the Graveyard: You can Special Summon 1 "Triamid" monster from your hand. You can only use this effect of "Triamid Kingolem" once per turn.
external_ids: local SETCARD_ID_0 = 0xe2 --Triamid
  
lua: local SETCARD_ID_0 = 0xe2 --Triamid
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--atk
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e2:SetTarget(aux.TargetBoolFunction(Card.IsRace, RACE_ROCK))
  	e2:SetValue(500)
  	c:RegisterEffect(e2)
  	--actlimit
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e3:SetRange(LOCATION_FZONE)
  	e3:SetTargetRange(0, 1)
  	e3:SetValue(1)
  	e3:SetCondition(s.actcon)
  	c:RegisterEffect(e3)
  	--spsummon
  	local e4 = Effect.CreateEffect(c)
  	e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e4:SetCode(EVENT_TO_GRAVE)
  	e4:SetProperty(EFFECT_FLAG_DELAY)
  	e4:SetCountLimit(1, id)
  	e4:SetCondition(s.spcon)
  	e4:SetTarget(s.sptg)
  	e4:SetOperation(s.spop)
  	c:RegisterEffect(e4)
  end
  function s.actfilter(c, tp)
  	return c and c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsControler(tp)
  end
  function s.actcon(e)
  	local tp = e:GetHandlerPlayer()
  	return s.actfilter(Duel.GetAttacker(), tp) or s.actfilter(Duel.GetAttackTarget(), tp)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsPreviousLocation(LOCATION_FZONE) and c:IsPreviousPosition(POS_FACEUP)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, aux.TriamidSpSummonType(c))
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		local sc = g:GetFirst()
  		if Duel.SpecialSummon(g, 0, tp, tp, false, aux.TriamidSpSummonType(sc), POS_FACEUP) and aux.TriamidSpSummonType(sc) then
  			sc:CompleteProcedure()
  		end
  	end
  end
  
  
source_text: Triamid
  All Rock-Type monsters on the field gain 500 ATK. If a "Triamid" monster you control battles, your opponent's cards and effects cannot be activated until the end of the Damage Step. If this face-up card in the Field Zone is sent to the Graveyard: You can Special Summon 1 "Triamid" monster from your hand. You can only use this effect of "Triamid Kingolem" once per turn.
target_text: -- Triamid
  local SETCARD_ID_0 = 0xe2 --Triamid
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--atk
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e2:SetTarget(aux.TargetBoolFunction(Card.IsRace, RACE_ROCK))
  	e2:SetValue(500)
  	c:RegisterEffect(e2)
  	--actlimit
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e3:SetRange(LOCATION_FZONE)
  	e3:SetTargetRange(0, 1)
  	e3:SetValue(1)
  	e3:SetCondition(s.actcon)
  	c:RegisterEffect(e3)
  	--spsummon
  	local e4 = Effect.CreateEffect(c)
  	e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e4:SetCode(EVENT_TO_GRAVE)
  	e4:SetProperty(EFFECT_FLAG_DELAY)
  	e4:SetCountLimit(1, id)
  	e4:SetCondition(s.spcon)
  	e4:SetTarget(s.sptg)
  	e4:SetOperation(s.spop)
  	c:RegisterEffect(e4)
  end
  function s.actfilter(c, tp)
  	return c and c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsControler(tp)
  end
  function s.actcon(e)
  	local tp = e:GetHandlerPlayer()
  	return s.actfilter(Duel.GetAttacker(), tp) or s.actfilter(Duel.GetAttackTarget(), tp)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsPreviousLocation(LOCATION_FZONE) and c:IsPreviousPosition(POS_FACEUP)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, aux.TriamidSpSummonType(c))
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		local sc = g:GetFirst()
  		if Duel.SpecialSummon(g, 0, tp, tp, false, aux.TriamidSpSummonType(sc), POS_FACEUP) and aux.TriamidSpSummonType(sc) then
  			sc:CompleteProcedure()
  		end
  	end
  end
  
  