Hello Snarky, first, I must thank you for all your work. It is admirable what you've done. Thank you very much. It give me a lot of fun time.
Hey, thank you very much.
I am a software developer, and is the first time I am trying this, at first is overwhelming to see the code for the different decks. I'll give it time to try something.
Great to see more and more people trying. Take your time :)
So... How I can know if "U.A. Penalty Box" effect was activated that turn? or better yet, how I can know if "U.A. Penalty Box" can activate its effect?
Unfortunately, I do not know of a way to check, if a specific effect can be activated this turn. So you have to handle that manually.
For that, I use the OPTCheck() and OPTSet() functions. You can pass an ID for a hard OPT ("You can only use this effect once per turn...", or a card for a soft OPT check ("Once per turn, you can...")
I assume, you have some sort of code already set up for chaining Penalty Box' effect in OnSelectChain() and OnSelectEffectYesNo()? If this is the case, you can set up the OPTCheck like this:
if HasID(cards,70043345,ChainPenaltyBox) then
"SelectAttackConditions" is used to check, whick conditions have to be checked for the AI to attack INTO certain monsters. You could use it to prevent your opponent from attacking into UAs with Penalty Box on the field, for example. But thats probably too specific and unneeded for now.
Have a look at the "BattleCommand" and "AttackTarget" functions instead. These are used to handle situations, when certain AI monsters should attack into the player's monsters with a custom targeting logic, ignoring the base ATK calculation. You can set them up for your deck in the initial function as usual:
deck.AttackTarget = UAAttackTarget
deck.AttackBoost = UAAttackBoost
Then, the actual functions could be handled like this:
SortByAtk(attackers) -- lowest ATK first
for i=1,#attackers do
local c = attackers[i]
A few notes, that might be helpful (didn't want to spam the code with comments):
- BattleCommand determines, if an attack order should be given at all, and which card attacks first
- SortByAtk sorts the attackers in ascending order, so the lowest ATK is checked first. Should result in the lowest UA being used to trigger Box, so higher ATKs can be used for more damage. If you return true as a 2nd parameter, order would be descending instead.
- AttackTarget selects the target of the current attacker. I use BestTarget instead of BestATtackTarget here, because BestAttackTarget uses the attack points logic. This would result in attacking a monster we could already beat in battle. BestTarget chooses the strongest target matching the filter instead, which probably makes more sense.
- Using c.setcode == 178 is not recommended. Some cards are part of multiple archetypes or sub-archetypes, in which case a simple comparison leads to wrong results. You can do a bit32.band(c.setcode,178)>0, but that can be inaccurate as well. I usually use the FilterSet() or the IsSetCode() functions.
Sorry if I do not use the tools well, its my first try.
Don't apologize. It is complex and confusing, and the tools are not always the most logical things to use. Just keep trying and keep asking, if something comes up :)
Does this help you?.
Edited by user
| Reason: Not specified