It is currently 29 Oct 2025, 12:28
   
Text Size

Defined AbilityHost for granted abilities

Post MTG Forge Related Programming Questions Here

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

Defined AbilityHost for granted abilities

Postby moomarc » 23 Feb 2012, 14:23

I'm trying to add the support to allow Defined to call the original card granting an ability (specifically for Rakdos Riteknife). My first attempt was a dismal failure that added the source card to a RememberedHost list on the target of an attach AF if the params contained RememberHost$True and could be called via Defined$AbHost. That bit worked but if two Riteknives were on the card it caused problems because the remembered objects weren't actually linked to the ability.

So onto attempt route 2: I now know I'm in way over my head with this but its been fun trying so far, so I just want to see if I'm pointing in the right direction before I go any further. The way I can see it working properly follows this logic:
- in StaticAbilityContinuous where abilities are granted, an additional line/block needs to be added that sets the hostCard as AbHost for the spell ability. Something along the lines of this just before the sa is actually added to the affectedCard:
Code: Select all
sa.setAbHost(hostCard);
The relevant setter and getter is added to SpellAbility.java which can then be called from AbilityFactory as a defined card if added there correctly.

It just doesn't seem to work. I don't know whether it's just completely wrong or if I've made a stupid mistake. I've attached a patch in case anyone has the time to have a look.
Attachments
alpha patch abHost.txt
Patch
(3.5 KiB) Downloaded 157 times
-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: Defined AbilityHost for granted abilities

Postby Sloth » 23 Feb 2012, 14:32

This concept should work. I will take a look.

EDIT: OK, you hijacked the sourceCard variable in SpellAbility, which gets rightfully overwritten when the ability is added to the equipped card. I simply added a new pointer for your AbHost to the SpellAbility class.

EDIT2: Renamed to OriginalHost for clarity.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Defined AbilityHost for granted abilities

Postby moomarc » 23 Feb 2012, 15:15

Sloth wrote:This concept should work. I will take a look.

EDIT: OK, you hijacked the sourceCard variable in SpellAbility, which gets rightfully overwritten when the ability is added to the equipped card. I simply added a new pointer for your AbHost to the SpellAbility class.

EDIT2: Renamed to OriginalHost for clarity.
Thanks Sloth. I was SOOO close. I'm starting to get the hang of it I think.

The source card being overwritten was just a lack of concentration at the end there, not something intentional. I was typing up the first post and as I did so I was trying some last minute insights and just forgot to rename those variables. I really appreciate your time looking at it and for the fixes. =D>
-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: Defined AbilityHost for granted abilities

Postby moomarc » 26 Feb 2012, 17:49

Sloth, wonder if you could point me in the right direction. I'm trying to make it so that cards that use OriginalHost will replace ORIGINALHOST from the spell description the same way as CARDNAME is normally read. I then want to make it append the unique id of the host card, but I can't work out how to add the ORIGINALHOST replacement though.

I want it for two reasons. The first is for general gameplay. If I have two Rakdos Riteknife on the same creature and tap it to activate the ability, a list pops up with two instances of the ability and you don't know which host card will get the counters.

The second reason is for testing. I've tried the above scenario with two copies of the knife on a creature. I activate the ability the first time then untap it and activate it again (after the first resolves). But the same card always gets the counters regardless which one I choose. It seems that the newest ability granted acts as OriginalHost for both abilities, although if that card is then removed the other works correctly (so it can't be that its being overwritten somehow). So I want to make sure that each of the abilities in the choice list is actually recognising the correct host.

I'm busy for the next week or two so not in a huge rush, just hope you can point me to the right place to start looking when I have time.
-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


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 13 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 13 users online :: 0 registered, 0 hidden and 13 guests (based on users active over the past 10 minutes)
Most users ever online was 9298 on 10 Oct 2025, 12:54

Users browsing this forum: No registered users and 13 guests

Login Form