Sign in to follow this  
CapOfWeird

Engine/Minigame definitions?

Recommended Posts

CapOfWeird    0

I'm trying to make a negotiation card that destroys two cards in hand, and then itself. However, I'm having trouble with the actual card function. I've tried slapping other card functions from the base game onto it but it hasn't worked yet. So, I need to try and build the function from scratch but I don't know where to find the base functions, like where the minigame types are defined.

Apologies if this is a noob question, but anyone know where I can find this stuff?

Share this post


Link to post
Share on other sites
RageLeague    1485

Best you can do is decompress the game code and search through the code base for your desired function.

One of the best ways you can start learning about modding custom cards is by looking at your desired effect, search through the codebase for existing card with similar effects, and modify the effect to suit your purpose.

For example, for your card effect in mind, it is made up of 3 different sub-effects: Selecting 2 card from hand, destroying them, and destroying itself. The "destroy self" is easy, many other cards have it, and it's basically a card flag. The other two effect is similar to "back pedal", but instead of expending cards, you are destroying them. It calls "minigame:ExpendCards", so you should search your code base for something with ":ExpendCards". Searching through with it, you find this:

Spoiler

function CardEngine:ExpendCards( min_count, max_count, source )
    local cards = self:ChooseCardsFromTable( self.hand_deck, min_count, max_count, nil, EXPEND_STRINGS, source )
    for i, card in ipairs( cards ) do
        self:ExpendCard( card )
    end

    return cards
end

 

For your card, since this effect is very rare, you don't need to write a new function, so you just copy the code and substitute the function parameter with your things. Remember in lua, using ":" to call methods changes its first argument to the thing before ":". "EXPEND_STRINGS" is not necessary here, so you can remove it for now.

For destroying cards mid-battle, a lot of hatch cards does that. They are self destruction, but you can easily change them into destroying other cards of your choosing.

In this end, you should get something like this:

OnPostResolve = function( self, minigame, targets )
  local cards = minigame:ChooseCardsFromTable( minigame.hand_deck, 0 --[[or 2 if it's not "up to"]], 2, nil, nil, self )
  for i, card in ipairs( cards ) do
    card:Consume()
  end
end,

 

Share this post


Link to post
Share on other sites
CapOfWeird    0

Gotcha, thanks for the tips!

It's definitely working much better than before, but it still isn't destroying the cards I select. It just... puts them back into my hand like nothing happened. I'll keep fiddling with it and see what happens. Thanks a lot!

Share this post


Link to post
Share on other sites
RageLeague    1485

I see the problem.

Apparently you need to call card:TransferCard( minigame.trash_deck ), because Consume only removes it from your negotiator, and if you want it to go away for the negotiation, you need to use this to transfer that card to the trash deck.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this