Jump to content

Issues with CollectRandomTargets?


Recommended Posts

I've been trying to make a card that is similar to Efficient Disposal, except it applies Trauma to enemies. Here's the code for the move so far:

Spoiler

        lyra_rapid_tossing =
    {
        name = "Rapid Tossing",
        rarity = CARD_RARITY.UNCOMMON,
        anim = "taunt",
        desc = "Ability: When you {DISCARD} or {EXPEND} a card, apply 1 {TRAUMA} to a random enemy.",
        icon = "battle/right_in_the_face.tex",
        flavour = "'When you're done with something, be sure to toss it in your target's face. It's only polite!'",
        flags = CARD_FLAGS.SKILL | CARD_FLAGS.EXPEND,
        cost = 2,
        target_type = TARGET_TYPE.SELF,
        
        OnPostResolve = function( self, battle, attack)
            local con = self.owner:AddCondition( "lyra_rapid_tossing", 1, self )
                if con then
                    con.ignore_card = self
                    end
                end,
        
        condition =
        {   
            desc = "Whenever you discard or expend a card, apply {1} {TRAUMA} to a random enemy.",
            desc_fn = function( self, fmt_str )
                return loc.format(fmt_str, self.trauma_amt * self.stacks)
            end,

            trauma_amt = 1,
        
            Trigger = function( self, battle )
                local target_fighters = {}
                battle:CollectRandomTargets( target_fighters, self.owner:GetEnemyTeam().fighters, 1 )

                for i=1, #target_fighters do
                    hit.target:AddCondition("TRAUMA", self.trauma_amt, self)
                end
            end,

            event_handlers =
            {
                [ BATTLE_EVENT.CARD_DISCARDED ] = function( self, card, battle )
                    self:Trigger( battle )
                end,
                
                [ BATTLE_EVENT.CARD_EXPENDED ] = function( self, card, battle )
                if card ~= self.ignore_card then
                    self:Trigger( battle )
                    end
                end,
            },
        },
    },

However, when I try to use the card in testing, this appears: Griftlands_NRCXJACAB5.thumb.png.1e55b203bfded511e929c78a19d826e6.png

Any idea what I'm doing wrong here?

Link to comment
Share on other sites

The code I copied from the Efficient Disposal cards in sal_actions.lua uses self, card, battle for the function, however.

EDIT: Here's the code for Serial Disposal, for reference:

Spoiler

    efficient_disposal_plus =
    {
        name = "Serial Disposal",
        desc = "{ABILITY}: Whenever you <#UPGRADE>discard or {EXPEND}</> a card, deal {1} damage to a random enemy.",
        desc_fn = function( self, fmt_str )
            return loc.format(fmt_str, self.damage_amt)
        end,

        damage_amt = 2,

        condition =
        {
            desc = "Whenever you discard or {EXPEND} a card, deal <#HILITE>{1}</> damage to a random enemy.",
            desc_fn = function( self, fmt_str )
                return loc.format(fmt_str, self.stacks)
            end,

            Trigger = function( self, battle )
                local target_fighters = {}
                battle:CollectRandomTargets( target_fighters, self.owner:GetEnemyTeam().fighters, 1)

                self.owner:BroadcastEvent( BATTLE_EVENT.CUSTOM_BEGIN, self )
                self.owner:BroadcastEvent( BATTLE_EVENT.PLAY_ANIM, "targetpractice1", true )

                for i=1, #target_fighters do
                    target_fighters:ApplyDamage( self.stacks, self.owner, nil, nil, { "discard" } )
                end
                self.owner:BroadcastEvent( BATTLE_EVENT.CUSTOM_END, self )
            end,

            event_handlers =
            {
                [ BATTLE_EVENT.CARD_DISCARDED ] = function( self, card, battle )
                    self:Trigger( battle )
                end,

                [ BATTLE_EVENT.CARD_EXPENDED ] = function( self, battle, card )
                    if card ~= self.ignore_card then
                        self:Trigger( battle )
                    end
                end,
            },
        },

 

Link to comment
Share on other sites

2 hours ago, WrenchInthePlan said:

                [ BATTLE_EVENT.CARD_DISCARDED ] = function( self, card, battle )
                    self:Trigger( battle )
                end,
                
                [ BATTLE_EVENT.CARD_EXPENDED ] = function( self, card, battle )
                if card ~= self.ignore_card then

Your code

1 hour ago, WrenchInthePlan said:

                [ BATTLE_EVENT.CARD_DISCARDED ] = function( self, card, battle )
                    self:Trigger( battle )
                end,

                [ BATTLE_EVENT.CARD_EXPENDED ] = function( self, battle, card )
                    if card ~= self.ignore_card then

Serial Disposal code.

Link to comment
Share on other sites

So it turns out that I was just listing things in the wrong order. Huh.

After changing it so it matches the order in Serial Disposal (and changing the code so it behaves like Resonator when the effect is triggered, since it's a status effect and not damage) Rapid Tossing is now working properly.

Thanks for the help.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
×
  • Create New...