Temple+ Modding Question

Discussion in 'General Modification' started by _doug_, Feb 21, 2018.

Remove all ads!
  1. _doug_

    _doug_ Member

    Joined:
    Jul 9, 2009
    Messages:
    86
    Likes Received:
    2
    That makes sense but I still can't seem to get it to override. I am replacing the function as below but there seems to be no effect. No errors from miniHook and no crashes. The old function gets called the same as before. Any ideas?

    int __cdecl _checkSpellResistance(SpellPacketBody *spellPkt, objHndl objHnd)

    {
    if (!spellPkt || !objHnd) return 0;
    return spellSys.CheckSpellResistance(spellPkt, objHnd);

    }


    int __declspec(naked) _CheckSpellResistanceWrapper(objHndl objHnd)

    {
    __asm { // esi is SpellPacketBody *

    push ebx
    push ebp
    push edi

    mov eax, [ebp + 12];
    push eax;
    mov eax, [ebp + 8];
    push eax;
    push esi;
    mov eax, _checkSpellResistance;
    call eax;
    pop esi;
    add esp, 8;

    pop edi
    pop ebp
    pop ebx
    retn;
    }
    }

    //..............

    auto pFn = replaceFunction (0x100C3810, _CheckSpellResistanceWrapper);
     
  2. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    2,725
    Likes Received:
    85
    Are you saying you don't even hit the breakpoint inside the _CheckSpellResistanceWrapper function? If so that's weird...

    Not sure if related but you need to add mov ebp,esp if you want to use ebp as a stack pointer. (I like doing this because that way the register doesn't change when you do a push)

    Anyway I implemented and tested it myself and it worked fine, so I'll just push the code and you can compare. It's probably something subtle which I'm not seeing at the moment...
     
  3. _doug_

    _doug_ Member

    Joined:
    Jul 9, 2009
    Messages:
    86
    Likes Received:
    2
    Thanks for the help!

    I originally had a more orthodox function with a move ebp,esp instruction. The version I posted was more of a "trying everything" version.:)

    Unfortunately, it is still not working for me. It will not break in that code even after I reverted my changes. I am testing against a vrock and I am seeing the spell resistance message but it is not going into the new code. Any thoughts on what is going wrong? Is there any way I can verify that mini hook is getting its job done? I assume I should see a change in the disassembly at the function's address.
     
  4. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    2,725
    Likes Received:
    85
    How exactly are you testing?

    Note that if you are testing with magic missile, it doesn't go through that function at all. The relevant code is the one that goes through the target list, it's essentially a duplicate of that function (might have been inlined by the original compiler). You can find it via searching for "spell resistance".
     
    Last edited: May 14, 2019
  5. _doug_

    _doug_ Member

    Joined:
    Jul 9, 2009
    Messages:
    86
    Likes Received:
    2
    I see... Looks like that was my problem the whole time. I was testing with color spray, magic missile and ray of frost. I bet all of those get processed in PerformCastSpellProcessTargets(). I may take a shot at replacing that with my own function. It shouldn't be that bad since a lot of that function seems to be checking spell resistance. I assume al as the return value means the first 8 bits of the eax register? I would also need to make a update to spell immunity it seems since the spell resistance spell gets processed there also but it should not be that bad.
     
  6. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    2,725
    Likes Received:
    85
    Eh? It's already effectively replaced, since it only appears in the Perform callback of cast spell and I rewrote that one completely. Look for CastSpellProcessTargets.

    Pretty sure I've also hooked spell immunity.
     
  7. _doug_

    _doug_ Member

    Joined:
    Jul 9, 2009
    Messages:
    86
    Likes Received:
    2
    I hadn't looked through the code thoroughly before my previous comment. Looks like I need to make my change in CastSpellProcessTargets and the spell immunity hook and I will be good to go! Thanks for the help.
     
  8. _doug_

    _doug_ Member

    Joined:
    Jul 9, 2009
    Messages:
    86
    Likes Received:
    2
    It's been a while since my last question... Is there a way from python to have a character cast a spell with a specified level and class without having to have it on their spell list? I am trying to add a spell like ability from a class and it seems like I would need something like that. I suppose I could add a modified version of cast_spell if there is not already a way to do that.
     
  9. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    2,725
    Likes Received:
    85
    I did something similar with racial spell-like abilities, is that what you're after?
     
  10. Pygmy

    Pygmy Established Member Supporter

    Joined:
    Oct 8, 2010
    Messages:
    374
    Likes Received:
    3
    Hi Doug,

    Are your Sudden Metamagic feats supposed to be linked to the Rapid Metamagic Feat? I ask this because casting a Sudden Metamagic spell is a Full Round action for a War Mage even when the character has the Rapid Metamagic feat. A wizard with Quicken Metamagic selected gets 2 spells in that round whilst a war mage with Quicken Metamagic and Rapid Metamagic only gets one.
     
  11. _doug_

    _doug_ Member

    Joined:
    Jul 9, 2009
    Messages:
    86
    Likes Received:
    2
    That was my first thought but after looking over your code I don't think it would work. The racial spell-like abilities are implemented as domain spells. I need to allow the class to cast one of five spells 3 + Int mod times per day. I don't think I could pull it off using domain spells.
     
  12. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    2,725
    Likes Received:
    85
    I'm not sure I understand what exactly youre after.
     
  13. WinstonShnozwick

    WinstonShnozwick Established Member

    Joined:
    Mar 2, 2011
    Messages:
    570
    Likes Received:
    10
    Modifier args can certainly hold daily count of "spell" casts. You simply allow the player to utilize the action while the count is under daily max, disable the radial option or have it return the attachee invalid floating text, and refresh the daily count arg when you get the on new day event key.
     
  14. _doug_

    _doug_ Member

    Joined:
    Jul 9, 2009
    Messages:
    86
    Likes Received:
    2
    This is what I was planning to do. I was wondering if there was already a way to actually cast the spell from python or if this was something I would need to add myself. I think the cast_spell method requires the character be able to cast the spell.
     
  15. _doug_

    _doug_ Member

    Joined:
    Jul 9, 2009
    Messages:
    86
    Likes Received:
    2
    I thought the sudden feats would not increase the casting time. I may not be correct on this though. Is there an official ruling that says the casting time increases?
     
Our Host!