It is currently 23 Aug 2019, 02:09
   
Text Size

Will Takeno and Golden-Tail ever get along?

Moderators: Xander9009, CCGHQ Admins

Will Takeno and Golden-Tail ever get along?

Postby thefiremind » 21 Feb 2013, 00:30

I wonder what you could possibly think by reading the topic title... :mrgreen: :mrgreen: :mrgreen: well, let's get serious now. :wink:

I started to think about the problem of coding the bushido mechanic so that all the involved cards can work together.
  • I can code bushido so that Takeno, Samurai General can retrieve the bushido points of each creature by adding that value to the ObjectDC through a static ability.
  • I can code bushido so that Sensei Golden-Tail can add multiple instances of bushido 1 to any creature.
  • ...But I can't code bushido so that both the conditions are met! :(
The first idea I had was to make Sensei Golden-Tail grant not only the bushido ability, but also a static ability that increments the ObjectDC register where I store the bushido points. This would require also the base bushido static abilities to work on increments otherwise they would overwrite the Int_Inc with their Set_Int, but it doesn't work anyway because a static ability that increments a register will do it once for each state-based effects check (Takeno will end up giving his army more than +100/+100 this way :lol:).
I can't increment the register using GetDataChest() from Sensei Golden-Tail either, because while ObjectDC() initialises the register if needed, GetDataChest() doesn't, and this would mean that I could increment the register only on cards where ObjectDC was already initialised.

I'm waiting for a clever idea... :idea:
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 717 times

Re: Will Takeno and Golden-Tail ever get along?

Postby RiiakShiNal » 21 Feb 2013, 04:39

I think they can get along, it will just require some ground rules to be set.

Just a thought (obviously untested), but what if you code a static ability with a low priority (meaning it runs first) to first reset the register on a card then with higher priority (meaning they run later) increment the registers with static abilities. In essence resetting then re-incrementing the register every time state-based effects are processed. It would require that anything that checks that register run at an even higher priority, but theoretically it could allow both to be coded. It is probably not the most efficient idea and it may not even work, but it is a possibility.

To account for cards that have a base Bushido ability not being overridden by an added Bushido ability from Sensei Golden-Tail, you could have a static ability that sets a "Base Bushido Ability" register on the ObjectDC, then in the added static reset abilities they read from the "Base Bushido Ability" register and use that to set the "Current Bushido Points" register which is then incremented by the added static Bushido abilities.

This way the Base (or Regular) Bushido ability will can use the "Base Bushido Ability" register (or ignore the register and hard-code how much pump) to determine how much to pump, while the added abilities just pump by a static (hard-coded) 1 (to satisfy the "multiple instances of Bushido trigger separately" condition). While static abilities increment the "Current Bushido Points" register so that Takeno, Samurai General can properly pump other Samurai based on the "Current Bushido Points" register on that card.

Of course this all assumes that static abilities with lower priorities always run first regardless of when they were added to the card.

Since we pump creatures using layer 7C, if we run the abilities using these layers it might work:
Layer 0 - [Static Ability] Set "Base Bushido Points" (if any)
Layer 1 - [Static Granted Ability] "Current Bushido Points" Reset abilities (they read from "Base Bushido Points" register to force set the "Current Bushido Points").
Layer 2 - [Static Granted Ability] Increment "Current Bushido Points" (if necessary for example Sensei Golden-Tail added abilities)
Layer 3 or higher (probably running on 7C) - [Static Ability] Takeno, Samurai General checks Current Bushido Points to check how many points to update.

This approach allows each individual Bushido pump [Triggered Abilities] to function separately yet still provide the same overall desired effect.
Problems with base game cards: DotP 2014 Core Fixes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
RiiakShiNal
Programmer
 
Posts: 2126
Joined: 16 May 2011, 21:37
Has thanked: 73 times
Been thanked: 472 times

Re: Will Takeno and Golden-Tail ever get along?

Postby thefiremind » 21 Feb 2013, 10:01

Even without thinking about resetting bushido for those who don't have base bushido points, it seems that the layers are ignored in this case: if a creature has
Code: Select all
  <STATIC_ABILITY>
    <CONTINUOUS_ACTION layer="0">
    ObjectDC():Int_Set( CHARACTERISTIC_BUSHIDO, 1 )
    </CONTINUOUS_ACTION>
  </STATIC_ABILITY>
by itself, and then Sensei Golden-Tail adds
Code: Select all
  <STATIC_ABILITY resource_id="2">
    <CONTINUOUS_ACTION layer="6">
    ObjectDC():Int_Inc( CHARACTERISTIC_BUSHIDO )
    </CONTINUOUS_ACTION>
  </STATIC_ABILITY>
Takeno still gives +1/+1 to that creature, meaning (I think) that the first ability still resolves last.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 717 times

Re: Will Takeno and Golden-Tail ever get along?

Postby RiiakShiNal » 21 Feb 2013, 15:38

I found a combination that works. Rather than write out the whole description here I have attached the 2 working cards so you can try it for yourself.

NOTE: They do make use of some of my functions (RSN_AddBothPowerAndToughness(), RSN_GrantAbility(), etc...) so be aware that you either need my mod (or at least the functions) or you need to replace them with equivalent code that does not rely on my functions.

It uses a variation on what I described before. Even better is that all the abilities are quite simple (the longest action is in Takeno, Samurai General for his second ability and half of that is checking for nils).

I wound up not using a layer for the base set, and using 7A for the reset, and 7B for the increment.

I guess there are also some notes I should add to this post for things I encountered in testing. Whether there are any important findings here I don't know because none of the items were very well tested to see if there are issues with layers and/or registers. I will leave that testing for another day.
  • Initially I tried using Layer 0 for base set, layer 1 for reset and layer 2 for increment using 20001 for base register and 20002 for current register.
    • Result: Reset did not appear to work and I had creatures that were quite large.
  • I tried changing base register to 2001 and current register to 2002.
    • Result: Takeno's ability appeared to stop working (as if it was always getting the value 0).
  • I tried changing base register to 201 and current register to 202.
    • Result: Same as above appeared to only get a value of 0.
  • I tried using layers 6A, 6B, 6C for the various abilities.
    • Result: Same as above appeared to only get a value of 0.
  • At this point I said screw it and tried making things a bit more simplistic (in an attempt to get Takeno working again). Removed layers, and decided to use those layers that seem to work for altering P/T.
    • Result: Surprise both actually worked!
Attachments
Working Bushido.zip
Contains both Sensei Golden-Tail and Takeno, Samurai General (with images)
(695.65 KiB) Downloaded 119 times
Last edited by RiiakShiNal on 21 Feb 2013, 16:11, edited 1 time in total.
Problems with base game cards: DotP 2014 Core Fixes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
RiiakShiNal
Programmer
 
Posts: 2126
Joined: 16 May 2011, 21:37
Has thanked: 73 times
Been thanked: 472 times

Re: Will Takeno and Golden-Tail ever get along?

Postby thefiremind » 21 Feb 2013, 16:06

I understood the idea much better by looking at the example. I don't even have much to edit in my cards, just the key idea of using 2 registers instead of 1. Very nice! :D
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 717 times

Re: Will Takeno and Golden-Tail ever get along?

Postby RiiakShiNal » 21 Feb 2013, 16:18

Well, I had tried to explain that initially, but I guess I didn't do a very good job of explaining it. "Base Bushido Points" was one register and "Current Bushido Points" was the second. I had figured that 2 were required so that any "Resets" would reset to a known base that existed on the card so that it didn't matter how many "Resets" there were they would all reset to the known base. Then on another layer (after any resets) we increment once for each added Bushido 1 ability which should always give us the correct result.

I did test multiple added abilities and adding Bushido to a card that has Bushido as a base and all gave correct results in my final test. 1 Ability on card without Bushido base got +1/+1, 2 Abilities on card without Bushido base got +2/+2, 6 added abilities on card without Bushido base got +6/+6, Sensei Golden-Tail without added abilities (only base) got +1/+1, with one added ability got +2/+2, and two added abilities got +3/+3.

Oh also of note is that just like the ruling on Sensei Golden-Tail, the "Training Counter" doesn't make any difference (not used for keying, and does not add Bushido). So moving the counter or removing it doesn't matter. Even though we get the blue text for granted abilities that "mark" the creature as changed, I made sure to put the counter in simply because the card says to do it.

Once we established the ground rules, Sensei Golden-Tail and Takeno, Samurai General became best buddies.
Problems with base game cards: DotP 2014 Core Fixes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
RiiakShiNal
Programmer
 
Posts: 2126
Joined: 16 May 2011, 21:37
Has thanked: 73 times
Been thanked: 472 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 2 guests


Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 10 minutes)
Most users ever online was 287 on 31 Mar 2019, 04:11

Users browsing this forum: No registered users and 2 guests

Login Form