Manalink TODO list
Discuss Upcoming Releases, Coding New Cards, Etc.
PLEASE DO NOT REPORT BUGS HERE!
PLEASE DO NOT REPORT BUGS HERE!
Moderators: BAgate, drool66, Aswan jaguar, gmzombie, stassy, CCGHQ Admins
23 posts
• Page 2 of 2 • 1, 2
Re: Manalink TODO list
by Gargaroz » 13 Aug 2013, 12:51
@Xenias : Null Rod is already done, but needs the recoding of the old mana-artifacts in order to work. When we'll have a correct decompilation of Black Lotus, we'll do that.
----
- Current / medium term task: adjusting the code for making Misdirection and such usable
- Long term task: inserting all the good stuff I left out from the "Golden Years" mod
- Current / medium term task: adjusting the code for making Misdirection and such usable
- Long term task: inserting all the good stuff I left out from the "Golden Years" mod
- Gargaroz
- Programmer
- Posts: 7097
- Joined: 06 Nov 2009, 11:11
- Has thanked: 82 times
- Been thanked: 595 times
Re: Manalink TODO list
by Korath » 14 Aug 2013, 19:17
It's actually only available mana that's been declared through declare_mana_available(). declare_mana_available_hex() instead stores its values starting at 0x4ef21c (it can deal with up to 50 declarations for each player); has_mana() and related functions check both, as well as mana_pool[]. This bit of Counterspell will affect the ai if two Islands or Mox Sapphires are untapped, but not if two Underground Seas are, or if you're floatingXenias wrote:Second one.
DWORD AVAILABLE_MANA[2][8] 0x4EF3C0
AVAILABLE_MANA[player][color_t]
[...]It says,
- Code: Select all
if(event == EVENT_CAN_COUNTER){
if(AVAILABLE_MANA[player][COLOR_BLUE]>=2){
ai_modifier += 24;
}
}
"Wow, 2 blue mana remains. Pay attention!! Counterspell Sucks!"
or
"I keep 2 blue mana, time for counter! Just do it!!"


An interesting side note here, perhaps of use implementing Celestial Dawn and similar effects (are there similar effects?) - dword_60A4B4[11*player] can store up to ten separate "You may spend [from_color] as if it were [to_color]" effects per player. sunglasses_of_urza_effect() at 0x49d380 is a handy front end:
- Code: Select all
void sunglasses_of_urza_effect(int player, color_t from_color, color_t to_color)
{
int i;
if (from_color > 0 && to_color > 0)
for (i = 0; i < 10; ++i)
if (dword_60A4B4[11 * player + i] == -1)
{
dword_60A4B4[11 * player + i] = (unsigned __int16)from_color | (unsigned int)(to_color << 16);
dword_60A4B4[11 * player + i + 1] = -1;
break;
}
}
No help in building a proper EVENT_COUNT_MANA handler for Graven Cairns or Shadowblood Ridge, though. Maybe experiment some with calling all three of declare_mana_available(player, COLOR_BLACK, 1), declare_mana_available(player, COLOR_RED, 1), and declare_mana_available(player, COLOR_COLORLESS, -1); but I suspect that the current data won't be able to handle color filtering no matter what, and we'll have to rewrite has_mana() eventually. I just hope there aren't too many other places that inspect the raw data directly instead of going through has_mana() like they should.
-
Korath - DEVELOPER
- Posts: 3708
- Joined: 02 Jun 2013, 05:57
- Has thanked: 496 times
- Been thanked: 1108 times
Re: Manalink TODO list
by Gargaroz » 15 Aug 2013, 12:38
Korath, given the things you already know, do you think a proper implementation of Cavern of Souls or Food Chain is possible ?
----
- Current / medium term task: adjusting the code for making Misdirection and such usable
- Long term task: inserting all the good stuff I left out from the "Golden Years" mod
- Current / medium term task: adjusting the code for making Misdirection and such usable
- Long term task: inserting all the good stuff I left out from the "Golden Years" mod
- Gargaroz
- Programmer
- Posts: 7097
- Joined: 06 Nov 2009, 11:11
- Has thanked: 82 times
- Been thanked: 595 times
Re: Manalink TODO list
by Korath » 15 Aug 2013, 13:04
Not yet. charge_mana() is very complex, and I haven't yet investigated how the AI decides which spells or abilities it attempts to cast or activate.
A first approximation would be making them activateable only while paying for a mana cost (which I can do currently, with the injection I've made for Mana Flare) and only when trying to cast or activate a spell or permanent of the appropriate type (which I don't yet know how to get at). That would be almost enough for player (non-AI) use, except
A first approximation would be making them activateable only while paying for a mana cost (which I can do currently, with the injection I've made for Mana Flare) and only when trying to cast or activate a spell or permanent of the appropriate type (which I don't yet know how to get at). That would be almost enough for player (non-AI) use, except
- you'd have to be able to pay for the spell or ability without using restricted mana to even be able to get into charge_mana() (we could work around this by having EVENT_COUNT_MANA always consider them activateable, no matter what the spell is); and
- if you cancelled, the mana would just go back into your mana pool.
-
Korath - DEVELOPER
- Posts: 3708
- Joined: 02 Jun 2013, 05:57
- Has thanked: 496 times
- Been thanked: 1108 times
Re: Manalink TODO list
by Xenias » 16 Aug 2013, 12:30
Thanks Gargaroz, and thanks Korath.
I greatly appreciate your interesting information. Mycosynth Lattice is a similar to Celestial Dawn.(I think one of the hardest card to code.)
A routine for producing mana are so complicated. But you almost make it clear. Awesome!!
By the way, do you think code hooking is not a smart solution? (is a bad coding?)
I think that's a good solution for 'can't be activated' or 'split second'.
I greatly appreciate your interesting information. Mycosynth Lattice is a similar to Celestial Dawn.(I think one of the hardest card to code.)
A routine for producing mana are so complicated. But you almost make it clear. Awesome!!

By the way, do you think code hooking is not a smart solution? (is a bad coding?)
I think that's a good solution for 'can't be activated' or 'split second'.
- Attachments
-
hooking_event_test.rar
- (3.19 KiB) Downloaded 509 times
Re: Manalink TODO list
by Korath » 16 Aug 2013, 16:49
I prefer to edit the exe directly, instead of writing to it at runtime like you've done, for two reasons:
- Analyzing the exe becomes impossible if the code in the file isn't what's actually being run, and
- we don't currently have a function that's guaranteed to be run before any gameplay - pregame() gets run multiple times when starting a new game, and not at all if you load a game instead of starting one (which is why you can't use the debug commands after loading)
-
Korath - DEVELOPER
- Posts: 3708
- Joined: 02 Jun 2013, 05:57
- Has thanked: 496 times
- Been thanked: 1108 times
Re: Manalink TODO list
by Gargaroz » 17 Aug 2013, 15:25
Well, here's a preliminar version of Celestial Dawn.
I foresee A LOT of problems with Hybrid card, cards with Phyrexian mana and so on.
I foresee A LOT of problems with Hybrid card, cards with Phyrexian mana and so on.
- Code: Select all
int card_celestial_dawn(int player, int card, event_t event){
card_instance_t *instance = get_card_instance( player, card );
if( event == EVENT_RESOLVE_SPELL ){
instance->targets[1].card = get_internal_card_id_from_csv_id(CARD_ID_PLAINS);
}
if( event == EVENT_CHANGE_TYPE && instance->targets[1].card > -1 ){
if( affected_card_controller == player && is_what(affected_card_controller, affected_card, TYPE_LAND) ){
event_result = instance->targets[1].card;
}
}
if( event == EVENT_MODIFY_COST_GLOBAL && affected_card_controller == player ){
card_ptr_t* c = cards_ptr[ get_id(affected_card_controller, affected_card) ];
int amount = 0;
if( c->req_black < 16 ){
amount+=c->req_black;
COST_BLACK-=c->req_black;
}
if( c->req_blue < 16 ){
amount+=c->req_blue;
COST_BLUE-=c->req_blue;
}
if( c->req_green < 16 ){
amount+=c->req_green;
COST_GREEN-=c->req_green;
}
if( c->req_red < 16 ){
amount+=c->req_red;
COST_RED-=c->req_red;
}
COST_WHITE+=amount;
}
if( event == EVENT_SET_COLOR && affected_card_controller == player ){
event_result = COLOR_TEST_WHITE;
}
return global_enchantment(player, card, event);
}
----
- Current / medium term task: adjusting the code for making Misdirection and such usable
- Long term task: inserting all the good stuff I left out from the "Golden Years" mod
- Current / medium term task: adjusting the code for making Misdirection and such usable
- Long term task: inserting all the good stuff I left out from the "Golden Years" mod
- Gargaroz
- Programmer
- Posts: 7097
- Joined: 06 Nov 2009, 11:11
- Has thanked: 82 times
- Been thanked: 595 times
Re: Manalink TODO list
by Korath » 25 Aug 2013, 17:45
Looks like card_instance_t::damage_target_player and damage_target_card are really the player/card this card is enchanting, and its use for damage cards is a special case.Gargaroz wrote:3) How exactly works the function that "attach" an enchantment / effect to another card ? Cards like Aura Graft are doable ?
There's no way in general, though, to find out if an aura could legally enchant an arbitrary card, for much the same reason Deflection can't be coded: target validation is handled as part of EVENT_CAST_SPELL or EVENT_ACTIVATE, rather than something a card can be asked to do separately.
-
Korath - DEVELOPER
- Posts: 3708
- Joined: 02 Jun 2013, 05:57
- Has thanked: 496 times
- Been thanked: 1108 times
23 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 8 guests