name: Ojama
card_text: Special Summon 3 "Ojama Tokens" (Beast/LIGHT/Level 2/ATK 0/DEF 1000) to your opponent's field in Defense Position. They cannot be Tributed for a Tribute Summon, and each time 1 is destroyed, its controller takes 300 damage.
external_ids: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_1 = 29843092 --Ojama Token
  local SETCARD_ID_0 = 0xf --Ojama
  
lua: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_1 = 29843092 --Ojama Token
  local SETCARD_ID_0 = 0xf --Ojama
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0)
  			and Duel.GetLocationCount(1 - tp, LOCATION_MZONE, tp) > 2
  			and Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 1000, 2, RACE_BEAST, ATTRIBUTE_LIGHT, POS_FACEUP_DEFENSE, 1 - tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 3, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 3, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		return
  	end
  	if Duel.GetLocationCount(1 - tp, LOCATION_MZONE, tp) < 3 then
  		return
  	end
  	if not Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 1000, 2, RACE_BEAST, ATTRIBUTE_LIGHT, POS_FACEUP_DEFENSE, 1 - tp) then
  		return
  	end
  	for i = 1, 3 do
  		local token = Duel.CreateToken(tp, id + i)
  		if Duel.SpecialSummonStep(token, 0, tp, 1 - tp, false, false, POS_FACEUP_DEFENSE) then
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_UNRELEASABLE_SUM)
  			e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			e1:SetValue(1)
  			token:RegisterEffect(e1, true)
  			local e2 = Effect.CreateEffect(e:GetHandler())
  			e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  			e2:SetCode(EVENT_LEAVE_FIELD)
  			e2:SetOperation(s.damop)
  			token:RegisterEffect(e2, true)
  		end
  	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(), 300, REASON_EFFECT)
  	end
  	e:Reset()
  end
  
  
source_text: Ojama
  Special Summon 3 "Ojama Tokens" (Beast/LIGHT/Level 2/ATK 0/DEF 1000) to your opponent's field in Defense Position. They cannot be Tributed for a Tribute Summon, and each time 1 is destroyed, its controller takes 300 damage.
target_text: -- Ojama
  local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_1 = 29843092 --Ojama Token
  local SETCARD_ID_0 = 0xf --Ojama
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0)
  			and Duel.GetLocationCount(1 - tp, LOCATION_MZONE, tp) > 2
  			and Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 1000, 2, RACE_BEAST, ATTRIBUTE_LIGHT, POS_FACEUP_DEFENSE, 1 - tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 3, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 3, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		return
  	end
  	if Duel.GetLocationCount(1 - tp, LOCATION_MZONE, tp) < 3 then
  		return
  	end
  	if not Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 1000, 2, RACE_BEAST, ATTRIBUTE_LIGHT, POS_FACEUP_DEFENSE, 1 - tp) then
  		return
  	end
  	for i = 1, 3 do
  		local token = Duel.CreateToken(tp, id + i)
  		if Duel.SpecialSummonStep(token, 0, tp, 1 - tp, false, false, POS_FACEUP_DEFENSE) then
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_UNRELEASABLE_SUM)
  			e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			e1:SetValue(1)
  			token:RegisterEffect(e1, true)
  			local e2 = Effect.CreateEffect(e:GetHandler())
  			e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  			e2:SetCode(EVENT_LEAVE_FIELD)
  			e2:SetOperation(s.damop)
  			token:RegisterEffect(e2, true)
  		end
  	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(), 300, REASON_EFFECT)
  	end
  	e:Reset()
  end
  
  