It is currently 13 Sep 2025, 12:23
   
Text Size

Where does equipping logic happen?

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Where does equipping logic happen?

Postby mcrawford620 » 07 Aug 2012, 22:07

For an Equipment like Ring of Thune, where is the logic that determines what creature the AI attaches it to?
I looked everywhere I could think of but couldn't find what code was actually doing it.
mcrawford620
 
Posts: 112
Joined: 25 Jun 2012, 16:59
Has thanked: 55 times
Been thanked: 25 times

Re: Where does equipping logic happen?

Postby moomarc » 08 Aug 2012, 05:52

mcrawford620 wrote:For an Equipment like Ring of Thune, where is the logic that determines what creature the AI attaches it to?
I looked everywhere I could think of but couldn't find what code was actually doing it.
The Equip macro is handled in CardFactoryUtil, from line 4652. You probably just need to add a split so that you can specify a preferred AI target in the form of AITgts$ Card.valid, then just append that to the ability string.
-Marc
User avatar
moomarc
Pixel Commander
 
Posts: 2091
Joined: 04 Jun 2010, 15:22
Location: Johannesburg, South Africa
Has thanked: 371 times
Been thanked: 372 times

Re: Where does equipping logic happen?

Postby moomarc » 08 Aug 2012, 07:28

moomarc wrote:
mcrawford620 wrote:For an Equipment like Ring of Thune, where is the logic that determines what creature the AI attaches it to?
I looked everywhere I could think of but couldn't find what code was actually doing it.
The Equip macro is handled in CardFactoryUtil, from line 4652. You probably just need to add a split so that you can specify a preferred AI target in the form of AITgts$ Card.valid, then just append that to the ability string.
I decided to go ahead and do it myself. The M13 rings are done, but if you come across any other equipment that needs preferred targeting for the AI (or any other additional params, just add the new params after the equip cost. It'll take everything after the first "|" and add it to the generated Attach script. Eg: Ring of Thune now has this:
Code: Select all
K:Equip 1 | AITgts$ Creature.White
and the generated script is
Code: Select all
AB$ Attach | Cost$ 1 | AITgts$ Creature.White | ValidTgts$ Creature.YouCtrl | TgtPrompt$ Select target creature you control | SorcerySpeed$ True | Equip$ True | AILogic$ Pump | IsPresent$ Card.Self+nonCreature | PrecostDesc$ Equip | SpellDescription$ (Attach to target creature you control. Equip only as a sorcery.)
-Marc
User avatar
moomarc
Pixel Commander
 
Posts: 2091
Joined: 04 Jun 2010, 15:22
Location: Johannesburg, South Africa
Has thanked: 371 times
Been thanked: 372 times

Re: Where does equipping logic happen?

Postby mcrawford620 » 08 Aug 2012, 16:25

I see now, thanks. I didn't understand anything about the CardFactoryUtil and how it generates that script, so it took me forever to figure out that the logic ends up in AbilityFactoryAttach.

Now the AI will never attach the Rings to a different-colored creature. I think that's OK here since the other abilities are pretty tricky to use correctly (Hexproof, Haste). I think the +1/+1 counters are what will actually be useful to the AI.
mcrawford620
 
Posts: 112
Joined: 25 Jun 2012, 16:59
Has thanked: 55 times
Been thanked: 25 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 46 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 46 users online :: 0 registered, 0 hidden and 46 guests (based on users active over the past 10 minutes)
Most users ever online was 7967 on 09 Sep 2025, 23:08

Users browsing this forum: No registered users and 46 guests

Login Form