name: Thorn
card_text: Equip only to "Black Rose Dragon" or a Plant monster. It gains 600 ATK. If the equipped monster attacks a Defense Position monster, inflict piercing battle damage to your opponent. If the equipped monster attacks a monster, after damage calculation: The attacked monster loses 600 ATK/DEF. An opponent's monster that battles with the equipped monster cannot be destroyed by that battle.
external_ids: local CARD_ID_0 = 73580471 --Black Rose Dragon
  
lua: local CARD_ID_0 = 73580471 --Black Rose Dragon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_EQUIP)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_CONTINUOUS_TARGET)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--Atk
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_EQUIP)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetValue(600)
  	c:RegisterEffect(e2)
  	--Pierce
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_EQUIP)
  	e3:SetCode(EFFECT_PIERCE)
  	c:RegisterEffect(e3)
  	--Equip limit
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetCode(EFFECT_EQUIP_LIMIT)
  	e4:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e4:SetValue(s.eqlimit)
  	c:RegisterEffect(e4)
  	--indes
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_FIELD)
  	e5:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e5:SetRange(LOCATION_SZONE)
  	e5:SetTargetRange(0, LOCATION_MZONE)
  	e5:SetTarget(s.indestg)
  	e5:SetValue(1)
  	c:RegisterEffect(e5)
  	--battle
  	local e6 = Effect.CreateEffect(c)
  	e6:SetDescription(aux.Stringid(id, 0))
  	e6:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e6:SetRange(LOCATION_SZONE)
  	e6:SetCode(EVENT_BATTLED)
  	e6:SetCondition(s.adcon)
  	e6:SetOperation(s.adop)
  	c:RegisterEffect(e6)
  end
  function s.eqlimit(e, c)
  	return c:IsCode(CARD_ID_0) or c:IsRace(RACE_PLANT)
  end
  function s.filter(c)
  	return c:IsFaceup() and (c:IsCode(CARD_ID_0) or c:IsRace(RACE_PLANT))
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_EQUIP, e:GetHandler(), 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		Duel.Equip(tp, c, tc)
  	end
  end
  function s.indestg(e, c)
  	return c == e:GetHandler():GetEquipTarget():GetBattleTarget()
  end
  function s.adcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetAttacker() == e:GetHandler():GetEquipTarget() and Duel.GetAttackTarget() ~= nil
  end
  function s.adop(e, tp, eg, ep, ev, re, r, rp)
  	local bc = Duel.GetAttackTarget()
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetValue(-600)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	bc:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_UPDATE_DEFENSE)
  	bc:RegisterEffect(e2)
  end
  
  
source_text: Thorn
  Equip only to "Black Rose Dragon" or a Plant monster. It gains 600 ATK. If the equipped monster attacks a Defense Position monster, inflict piercing battle damage to your opponent. If the equipped monster attacks a monster, after damage calculation: The attacked monster loses 600 ATK/DEF. An opponent's monster that battles with the equipped monster cannot be destroyed by that battle.
target_text: -- Thorn
  local CARD_ID_0 = 73580471 --Black Rose Dragon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_EQUIP)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_CONTINUOUS_TARGET)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--Atk
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_EQUIP)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetValue(600)
  	c:RegisterEffect(e2)
  	--Pierce
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_EQUIP)
  	e3:SetCode(EFFECT_PIERCE)
  	c:RegisterEffect(e3)
  	--Equip limit
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetCode(EFFECT_EQUIP_LIMIT)
  	e4:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e4:SetValue(s.eqlimit)
  	c:RegisterEffect(e4)
  	--indes
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_FIELD)
  	e5:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e5:SetRange(LOCATION_SZONE)
  	e5:SetTargetRange(0, LOCATION_MZONE)
  	e5:SetTarget(s.indestg)
  	e5:SetValue(1)
  	c:RegisterEffect(e5)
  	--battle
  	local e6 = Effect.CreateEffect(c)
  	e6:SetDescription(aux.Stringid(id, 0))
  	e6:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e6:SetRange(LOCATION_SZONE)
  	e6:SetCode(EVENT_BATTLED)
  	e6:SetCondition(s.adcon)
  	e6:SetOperation(s.adop)
  	c:RegisterEffect(e6)
  end
  function s.eqlimit(e, c)
  	return c:IsCode(CARD_ID_0) or c:IsRace(RACE_PLANT)
  end
  function s.filter(c)
  	return c:IsFaceup() and (c:IsCode(CARD_ID_0) or c:IsRace(RACE_PLANT))
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_EQUIP, e:GetHandler(), 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		Duel.Equip(tp, c, tc)
  	end
  end
  function s.indestg(e, c)
  	return c == e:GetHandler():GetEquipTarget():GetBattleTarget()
  end
  function s.adcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetAttacker() == e:GetHandler():GetEquipTarget() and Duel.GetAttackTarget() ~= nil
  end
  function s.adop(e, tp, eg, ep, ev, re, r, rp)
  	local bc = Duel.GetAttackTarget()
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetValue(-600)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	bc:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_UPDATE_DEFENSE)
  	bc:RegisterEffect(e2)
  end
  
  