It is currently 19 Apr 2024, 06:19
   
Text Size

Manalink TODO list

Discuss Upcoming Releases, Coding New Cards, Etc.
PLEASE DO NOT REPORT BUGS HERE!

Moderators: BAgate, drool66, Aswan jaguar, gmzombie, stassy, CCGHQ Admins

Re: Manalink TODO list

Postby 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
Gargaroz
Programmer
 
Posts: 7097
Joined: 06 Nov 2009, 11:11
Has thanked: 82 times
Been thanked: 595 times

Re: Manalink TODO list

Postby Korath » 14 Aug 2013, 19:17

Xenias wrote:Second one.
DWORD AVAILABLE_MANA[2][8] 0x4EF3C0
AVAILABLE_MANA[player][color_t]
[...]
Code: Select all
    if(event == EVENT_CAN_COUNTER){
        if(AVAILABLE_MANA[player][COLOR_BLUE]>=2){
            ai_modifier += 24;
        }
    }
It says,
"Wow, 2 blue mana remains. Pay attention!! Counterspell Sucks!"
or
"I keep 2 blue mana, time for counter! Just do it!!"
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 floating {U} {U} in your mana pool.

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;
        }
}
The only place that writes to this array is Sunglasses of Urza, which doesn't do anything except call sunglasses_of_urza_effect(player, COLOR_WHITE, COLOR_RED) in its EVENT_COUNT_MANA handler.

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.
User avatar
Korath
DEVELOPER
 
Posts: 3707
Joined: 02 Jun 2013, 05:57
Has thanked: 496 times
Been thanked: 1106 times

Re: Manalink TODO list

Postby 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
Gargaroz
Programmer
 
Posts: 7097
Joined: 06 Nov 2009, 11:11
Has thanked: 82 times
Been thanked: 595 times

Re: Manalink TODO list

Postby 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
  1. 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
  2. if you cancelled, the mana would just go back into your mana pool.
Probably the only feasible way to get them fully working is to copy the machinery that makes COLOR_ARTIFACT work. Which, among many other things, will mean tracking down and changing all the direct accesses to mana_pool[], AVAILABLE_MANA[], the version of that for declare_mana_available_hex(), etc., which'll be no fun at all.
User avatar
Korath
DEVELOPER
 
Posts: 3707
Joined: 02 Jun 2013, 05:57
Has thanked: 496 times
Been thanked: 1106 times

Re: Manalink TODO list

Postby 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!! :D

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 371 times
Xenias
 
Posts: 8
Joined: 13 Jul 2013, 16:41
Has thanked: 0 time
Been thanked: 3 times

Re: Manalink TODO list

Postby 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)
I also prefer to edit call_cards_function() (what I'd labelled 0x4018C0, the function you're hooking) directly instead of tracking down all the calls to it. More reliable, less effort, and less error-prone. It's also not the only place cards' functions are called from (though most calls do go through that).
User avatar
Korath
DEVELOPER
 
Posts: 3707
Joined: 02 Jun 2013, 05:57
Has thanked: 496 times
Been thanked: 1106 times

Re: Manalink TODO list

Postby 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.

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
Gargaroz
Programmer
 
Posts: 7097
Joined: 06 Nov 2009, 11:11
Has thanked: 82 times
Been thanked: 595 times

Re: Manalink TODO list

Postby Korath » 25 Aug 2013, 17:45

Gargaroz wrote:3) How exactly works the function that "attach" an enchantment / effect to another card ? Cards like Aura Graft are doable ?
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.

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.
User avatar
Korath
DEVELOPER
 
Posts: 3707
Joined: 02 Jun 2013, 05:57
Has thanked: 496 times
Been thanked: 1106 times

Previous

Return to Development

Who is online

Users browsing this forum: No registered users and 26 guests


Who is online

In total there are 26 users online :: 0 registered, 0 hidden and 26 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 26 guests

Login Form