Author Topic: Cannot use magic when the spell keys are changed  (Read 5995 times)

Taxxi

  • Member
  • Posts: 26
  • Karma: +0/-0
    • View Profile
Cannot use magic when the spell keys are changed
« on: August 20, 2014, 08:07:01 AM »
Running window version of AA in window 7.

Since I was playing this game in laptop, I couln't use the keypad numbers, so assigned them to non-keypad numbers. Also assigned the spell casting button to 'F' and abort casting button to 'B'. Even though I had all the corresponding runes and indeed ordered the runes corresponding to the appropriate magic I wanted to use, any magic couldn't be casted. Only leaving the message, 'YOU FEEL SOMTHING IS JUST NOT RIGHT'.

Now reinstalled the game and backed up the character files. This time I didn't do anything about key assignment. Now magic works.

This time assigned the spell casting buttons to something like 'i, o, p, k, l, ;, ,, ., /'. It didn't work either :(

Maybe I've done something wrong then forgive me and please erase this topic.
My assumption is that the default assignment of the spell casting buttons(i.e. rune selecting buttons) shouldn't be changed, which means I cannot play any further. Oh my ...



peewee_RotA

  • Sr. Member
  • Posts: 272
  • Karma: +8/-0
    • View Profile
Re: Cannot use magic when the spell keys are changed
« Reply #1 on: August 20, 2014, 09:13:44 PM »
Even if you remap the keys, I think the runes are literally hardcoded to the keypad buttons behind the scenes.  :(

peewee_RotA

  • Sr. Member
  • Posts: 272
  • Karma: +8/-0
    • View Profile
Re: Cannot use magic when the spell keys are changed
« Reply #2 on: August 21, 2014, 06:21:05 AM »
Just as I suspected, the spell list is trying to match the actual keycode to the spell, not the rune position.

I'll add more detail below. Lysle is awesome and will probably get you a fix pretty soon, if I don't send him one first :)


Here's what seems to be the the culprits:

SpellsAddRune - Spells.c
https://github.com/ExiguusEntertainment/AmuletsArmor/blob/master/Source/SPELLS.C#L222

Code: [Select]
if (StatsGetPlayerMana()>0)
{
  ColorSetColor (MANA_BACKCOLOR,30,0,30);
  G_curspell[i]=(T_byte8)p_button->scancode;   //add scancode to spell key
  SpellsDrawRuneBox();
} else ColorSetColor (MANA_BACKCOLOR,55,0,0);
break;


BannerAddSpellButton - Banner.c
https://github.com/ExiguusEntertainment/AmuletsArmor/blob/1e5ba927b929badbda808735766182bff1bf6e9e/Source/BANNER.C#L1774

Code: [Select]
if (slot == 0)
            keycode = KeyMap(KEYMAP_RUNE1);
            else if (slot==1) keycode=KeyMap(KEYMAP_RUNE2);
            else if (slot==2) keycode=KeyMap(KEYMAP_RUNE3);
            else if (slot==3) keycode=KeyMap(KEYMAP_RUNE4);
            else if (slot==4) keycode=KeyMap(KEYMAP_RUNE5);
            else if (slot==5) keycode=KeyMap(KEYMAP_RUNE6);
            else if (slot==6) keycode=KeyMap(KEYMAP_RUNE7);
            else if (slot==7) keycode=KeyMap(KEYMAP_RUNE8);
            else if (slot==8) keycode=KeyMap(KEYMAP_RUNE9);

            /* add button for slot */
        sprintf(stmp, "UI/3DUI/RUNBUT%02d", picno);

        DebugCheck(G_runeButtons[slot]==NULL);
        G_runeButtons[slot] = ButtonCreate(xloc[slot], yloc[slot], stmp, FALSE,
                keycode, SpellsAddRune, NULL);



There needs to be a tertiary mapping done. I think it can be accomplished here:

SpellsInitSpells - Spells.c
https://github.com/ExiguusEntertainment/AmuletsArmor/blob/1e5ba927b929badbda808735766182bff1bf6e9e/Source/BANNER.C#L1829
Code: [Select]
for (i=0;i<4;i++)
        {
            if (p_spell->code[i]==1) p_spell->code[i]=KEY_SCAN_CODE_KEYPAD_1;
            else if (p_spell->code[i]==2) p_spell->code[i]=KEY_SCAN_CODE_KEYPAD_2;
            else if (p_spell->code[i]==3) p_spell->code[i]=KEY_SCAN_CODE_KEYPAD_3;
            else if (p_spell->code[i]==4) p_spell->code[i]=KEY_SCAN_CODE_KEYPAD_4;
            else if (p_spell->code[i]==5) p_spell->code[i]=KEY_SCAN_CODE_KEYPAD_5;
            else if (p_spell->code[i]==6) p_spell->code[i]=KEY_SCAN_CODE_KEYPAD_6;
            else if (p_spell->code[i]==7) p_spell->code[i]=KEY_SCAN_CODE_KEYPAD_7;
            else if (p_spell->code[i]==8) p_spell->code[i]=KEY_SCAN_CODE_KEYPAD_8;
            else if (p_spell->code[i]==9) p_spell->code[i]=KEY_SCAN_CODE_KEYPAD_9;
        }

This section remaps the values in the spell's "wad" file entry in order to look for specific keycode values. Instead of using the scancodes for the keypad keys, this could be jury rigged with the new key mappings from the Keymap function... (i.e... "KeyMap(KEYMAP_RUNE1)")
« Last Edit: August 21, 2014, 06:32:09 AM by peewee_RotA »

Taxxi

  • Member
  • Posts: 26
  • Karma: +0/-0
    • View Profile
Re: Cannot use magic when the spell keys are changed
« Reply #3 on: August 22, 2014, 02:07:52 AM »
Thanks for the info! I also hope that the fix would come soon. It is weird that if I change the rune keys, even if I choose the correct runes using my mouse not the changed keys, the magic still wouldn't work.

Meanwhile, I don't have other choices but to play some other games.

LysleShields

  • Administrator
  • Full Member
  • Posts: 208
  • Karma: +6/-1
  • Is the potion half full or half empty?
    • View Profile
    • Amulets & Armor
Re: Cannot use magic when the spell keys are changed
« Reply #4 on: August 22, 2014, 09:28:33 AM »
I'll try to knock it out tonight (9:30 AM here) and put up an update.

LysleShields

  • Administrator
  • Full Member
  • Posts: 208
  • Karma: +6/-1
  • Is the potion half full or half empty?
    • View Profile
    • Amulets & Armor
Re: Cannot use magic when the spell keys are changed
« Reply #5 on: August 23, 2014, 11:45:16 AM »
Taxxi,

I created a new .exe with the fixes and put it up here:  http://amuletsandarmor.com/download/AA.exe

It is NOT an installer.  Just backup the AA.exe and replace it with the one downloaded above.  It should report as "Classic V1.04c" in the game.  (not the older v1.04b or earlier).

Your keyboard mapping should now work with other keys.  I used UIOJKLM,. and N for cast and P for cancel without problem.

Taxxi

  • Member
  • Posts: 26
  • Karma: +0/-0
    • View Profile
Re: Cannot use magic when the spell keys are changed
« Reply #6 on: August 23, 2014, 06:25:48 PM »
Oh my, you've made it much faster than I've thought!

I've tried it, and even though still numbers above the keyboards cannot be assigned to runes,

normal keys now can be assigned to runes! It works!

Thank you so much indeed :) Now I can go back and play it...

peewee_RotA

  • Sr. Member
  • Posts: 272
  • Karma: +8/-0
    • View Profile
Re: Cannot use magic when the spell keys are changed
« Reply #7 on: August 23, 2014, 10:26:54 PM »
Taxxi,

I created a new .exe with the fixes and put it up here:  http://amuletsandarmor.com/download/AA.exe

It is NOT an installer.  Just backup the AA.exe and replace it with the one downloaded above.  It should report as "Classic V1.04c" in the game.  (not the older v1.04b or earlier).

Your keyboard mapping should now work with other keys.  I used UIOJKLM,. and N for cast and P for cancel without problem.

Awesome. Was there anymore than described? Definitely curious.

LysleShields

  • Administrator
  • Full Member
  • Posts: 208
  • Karma: +6/-1
  • Is the potion half full or half empty?
    • View Profile
    • Amulets & Armor
Re: Cannot use magic when the spell keys are changed
« Reply #8 on: August 24, 2014, 12:00:34 AM »
No.  I've got the Lua changes in a branch.  For Taxxi, I just edited the last release.