Jump to content


Photo

whats wrong wiht this code?


  • Please log in to reply
10 replies to this topic

#1 Nirran

Nirran
  • Member
  • 26 posts

Donator

Posted 06 April 2018 - 09:33 AM


BEGIN ~Extract File Names of Learn Spell items~ 
     
COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~ 
   PATCH_IF ("%SOURCE_SIZE%" > "0x0") BEGIN
     READ_LONG  0x64 "abil_off"
     READ_SHORT 0x68 "abil_num"
     READ_SHORT  0x1C "type"
     SET "stack" = 0
     FOR (index = 0; index < abil_num ; index = index + 1) BEGIN
        READ_BYTE ("%abil_off%" + 0x00 + ("%index%" * 0x36)) "effect_type"
        PATCH_IF ("%effect_type%" == 147) BEGIN
           PATCH_PRINT ~%SOURCE_FILE%~
        END   
     END
   END
   BUT_ONLY_IF_IT_CHANGES

I want to extract all spell scroll item names that have learn spell (147),is my method wrong?

 

 

 


Edited by Nirran, 06 April 2018 - 03:47 PM.


#2 subtledoctor

subtledoctor
  • Modder
  • 656 posts

Posted 06 April 2018 - 10:47 AM

Not sure about your specific code, but I can point you to my code that does this very thing:
https://github.com/U...b/hla_thief.tpa

It's about 2/3 down the document, search for "scroll_count" to find it. It creates an array of all scrolls that can both learn and cast spells - i.e. it should find all arcane spell scrolls.

Then in the next section with ACTION_PHP_EACH, you can do stuff like print the scroll names, or patch the items, or whatever.

#3 Nirran

Nirran
  • Member
  • 26 posts

Donator

Posted 06 April 2018 - 11:43 AM

tyvm

 

is anyway of getting  the spell lvl with wiedu?


Edited by Nirran, 06 April 2018 - 11:45 AM.


#4 The Imp

The Imp

    Not good, see EVIL is better. You'll LIVE.

  • Member
  • 5148 posts

Posted 06 April 2018 - 12:33 PM

is anyway of getting  the spell lvl with wiedu?
Erhm, in a copy just:
READ_LONG 0x34 ~spell_level~

Yep, Jarno Mikkola. my Mega Mod FAQ. Use of the BWS, and how to use it(scroll down that post a bit). 
OK, desert dweller, welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand. Ouh, actually it was still snow then.. but anyways.


#5 Nirran

Nirran
  • Member
  • 26 posts

Donator

Posted 06 April 2018 - 12:59 PM

and this is from the scroll?(what I was asking,maybe wasn't clear)



#6 The Imp

The Imp

    Not good, see EVIL is better. You'll LIVE.

  • Member
  • 5148 posts

Posted 06 April 2018 - 01:19 PM

Ahh, nope... that's for the .spl...

Yep, Jarno Mikkola. my Mega Mod FAQ. Use of the BWS, and how to use it(scroll down that post a bit). 
OK, desert dweller, welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand. Ouh, actually it was still snow then.. but anyways.


#7 Nirran

Nirran
  • Member
  • 26 posts

Donator

Posted 06 April 2018 - 02:24 PM

thnx ....



#8 subtledoctor

subtledoctor
  • Modder
  • 656 posts

Posted 06 April 2018 - 03:26 PM

Actually yes, you can READ_LONG 0x34 to put the spell level into a variable right after it says INNER_PATCH_FILE. (That bit is about the .SPL attached to the scroll.)

Edited by subtledoctor, 06 April 2018 - 08:50 PM.


#9 The Imp

The Imp

    Not good, see EVIL is better. You'll LIVE.

  • Member
  • 5148 posts

Posted 06 April 2018 - 11:48 PM

Actually yes, you can READ_LONG 0x34 to put the spell level into a variable right after it says INNER_PATCH_FILE. (That bit is about the .SPL attached to the scroll.)
Yeah... but the thing is you need to be sure the target is a .spl in the inner_patch_file... just like with the above codes:
READ_BYTE ("%abil_off%" + 0x00 + ("%index%" * 0x36)) "effect_type"

That constructs from what's read from the file before it... but to get to the .spl from the .itm is going to be a quite a road.

Yep, Jarno Mikkola. my Mega Mod FAQ. Use of the BWS, and how to use it(scroll down that post a bit). 
OK, desert dweller, welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand. Ouh, actually it was still snow then.. but anyways.


#10 Gwendolyne

Gwendolyne
  • Administrator
  • 1016 posts

Posted 07 April 2018 - 03:17 AM

did not test it, but, the following code might work

COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~
    PATCH_IF ("%SOURCE_SIZE%" > 0x71) BEGIN
        READ_LONG  0x64 "abil_off"
        READ_SHORT 0x68 "abil_num"
        READ_LONG  0x6a "fx_off"
        PATCH_IF (SHORT_AT 0x1c == 0x0B) BEGIN                                               // type = 0xB-Scroll
            FOR (i = 0 ; i < abil_num ; ++i) BEGIN                                           // looping through headers
            READ_SHORT ("%abil_off%" + 0x1e + 0x28*i) "abil_fx_num"
            READ_SHORT ("%abil_off%" + 0x20 + 0x28*i) "abil_fx_idx"
                FOR (j = 0 ; j < abil_fx_num ; ++j) BEGIN                                    // looping through effects
                    READ_SHORT (fx_off + (0x30 * (j + abil_fx_idx))) "opcode"
                    PATCH_IF (opcode = 147) BEGIN                                            // Spell: Learn Spell [147]
                        READ_ASCII (fx_off + 0x14 + (0x30 * (j + abil_fx_idx))) resource (8) NULL
                        INNER_ACTION BEGIN
                            ACTION_IF (FILE_EXISTS_IN_GAME "%resource%.spl") BEGIN
                                COPY_EXISTING - ~%resource%.spl~ ~override~
                                    READ_LONG 0x34 "spell_level"
                                BUT_ONLY
                            END ELSE BEGIN
                                spell_level = 0
                            END
                        END
                    PATCH_PRINT ~Scroll %SOURCE_FILE% --> Learn Spell %resource% (Level %spell_level%)~
                    j = abil_fx_num
                    END // of PATCH_IF (opcode = 147)
                END     // of looping through effects
            END         // of looping through headers
         END            // of reading scrolls
    END                 // of PATCH_IF ("%SOURCE_SIZE%" > 0x71)
BUT_ONLY

 


CARPE DIEM ....
 

In progress : Menace sur le Royaume de Diamant Éternel there.


#11 Nirran

Nirran
  • Member
  • 26 posts

Donator

Posted 07 April 2018 - 09:08 AM


You guys are the bomb!