Skip to content

Appending to IDS files (or replacing them?)

chimericchimeric Member Posts: 1,163
I'm at the point where I can release a spell for testing, but I have made some new entries in my MISSILE.IDS, PROJECTL.IDS and SPECIFIC.IDS. What do I do with these files, when I assemble my Weidu installation? Do I just include them in the mod whole-cloth so they go in the players' Override folder, or do I append to players' files? Then how do I do that? All entries have position numbers. For example, the default SPECIFIC.IDS has Normal, Magic, Non-Magic, Spirit, and those are not 1,2,3,4. Spirit is 50, I think. The state I added there also has its own number, and it is by this number that the Specific trigger calls on the IDS. The positions are important for the other IDS files, too.

Have you appended to IDS files? How does it work?

Comments

  • GrimLefourbeGrimLefourbe Member Posts: 637
    I think there are weidu functions for those, there is one for PROJECTL.IDS (http://www.weidu.org/~thebigg/beta/README-WeiDU.html#hevea_default278). You don't modify the .IDS file, you just call the weidu function with the proper arguments.

    I'm not sure there are weidu functions for the others.
  • chimericchimeric Member Posts: 1,163
    Thanks, that's something. MISSILE.IDS and PROJECTL.ids repeat each other, though, except the numbering is off by one position. So if there is code for one, there has got to be something for the other. Now SPECIFIC, hmm...
  • kjeronkjeron Member Posts: 2,368
    edited August 2016
    In general: Read each entry in the relevant file, start from 0 and check each value going up until you reach one that is not being used, add an entry using that value, then patch your files to use that value.

    Projectiles require another step: Take (value - 1) and add an entry to Missile.IDS using that new value, that is the value you will use for the Projectile. Missile.IDS is not used by the game, has missing entries, and so cannot be used to find available values, however, it is used by Near Infinity and DLTCEP to give meaningful names to projectiles other than their filename, so it is generally worth updating.
  • chimericchimeric Member Posts: 1,163
    And how do I patch my files, or rather the files of the players who download and run the Weidu installer, for this? If the answer were obvious to me, I wouldn't have asked, you know.
  • kjeronkjeron Member Posts: 2,368
    If its basics that you need, the best way to learn is to download another mod and see how it does things. Preferably one with decent commenting that explains what its doing.
  • chimericchimeric Member Posts: 1,163
    Well... there are two considerations. One is that I don't know which mod patches the right files in the right way. I don't want to learn the whole of patching by trial and error, I only need this narrow application, so I'd rather ask. SPECIFIC.IDS in particular cannot be patched the way described above, by letting Weidu assign its own numbers to custom positions, because lines in that file are called on by their numbers in the trigger. You can't trigger to a Specific with the name of the position, you need to ask for the integer. Two, if asking for advice is begging for help, as I sometimes think, then one ought to resort to it as little as possible. If, on the other hand, you look at dispensing advice as a pleasant activity we engage in in our free time, no strings attached, then I'm not a moocher for inviting others to that interaction easily and often.
  • kjeronkjeron Member Posts: 2,368
    edited August 2016
    chimeric said:

    If, on the other hand, you look at dispensing advice as a pleasant activity we engage in in our free time, no strings attached, then I'm not a moocher for inviting others to that interaction easily and often.

    I have only one string: I am knowledgeable of and am confident in what I'm trying to explain. I can give you the code, but explaining it is not something I can do very well. I generally don't use any commenting, and would be a terrible source to learn from my mods.
    Here is something for Specifics. It would go as early in your installation as possible.
     DEFINE_ACTION_FUNCTION ADD_SPECIFIC STR_VAR label = ~~ RET index  BEGIN
      OUTER_SET index = ~-1~
      ACTION_IF FILE_CONTAINS_EVALUATED (~SPECIFIC.IDS~ ~^.+[ %TAB%]%label%\b~) BEGIN
       COPY_EXISTING ~SPECIFIC.IDS~ override
        COUNT_2DA_ROWS 2 rows
        FOR (i = 0; i < rows; ++i) BEGIN
         READ_2DA_ENTRY i 1 2 state_label
         PATCH_IF ~%state_label%~ STRING_EQUAL_CASE ~%label%~ BEGIN
          READ_2DA_ENTRY i 0 2 state_id
          SET index = state_id
         END
        END
       BUT_ONLY
      END ELSE BEGIN
       ACTION_IF (~%label%~ STRING_EQUAL ~~) BEGIN FAIL ~Missing Specific's label~ END ELSE BEGIN
        ACTION_IF ((~%label%~ STRING_CONTAINS_REGEXP ~ ~) = 0) BEGIN FAIL ~Specific's lable cannot have spaces~ END ELSE BEGIN
         COPY_EXISTING ~SPECIFIC.IDS~ override
          COUNT_2DA_ROWS 2 rows
          FOR (i = 1; i < rows; ++i) BEGIN
           READ_2DA_ENTRY i 0 2 state_id
           SET $occupied_slot(~%state_id%~) = 1
          END
           FOR (i = 0; i < 256; ++i) BEGIN
            PATCH_IF (!VARIABLE_IS_SET $occupied_slot(~%i%~)) BEGIN
             SET index = i
             SET i = 256
             PATCH_IF index <= rows BEGIN
              INSERT_2DA_ROW index 2 ~%index% %label%~
             END ELSE BEGIN
              INSERT_2DA_ROW rows 2 ~%index% %label%~
             END
            END
           END
         PATCH_IF (index = ~-1~) BEGIN PATCH_FAIL ~No available slots in SPECIFIC.IDS~ END
         BUT_ONLY
        END
       END
      END
     END
    LAF ADD_SPECIFIC STR_VAR string = ~custom_label~ RET specific_1 = index END
    The first part is a function that will do what I described: read every entry and find a vacant slot.
    The last line can be reused with different labels and a different "specific_#" for additional entries.
    custom_label is the arbitrary string you want to identify your specifics as, it needs the ~'s on both sides of it, cannot have spaces, probably not special characters(at least not other ~'s).
    The variable "specific_1" will store the value you need to use in effects like Opcode 177.

    And here is the code to alter your spells/items at installation:
    ADD_PROJECTILE ~%file_path%\MYPROJ.PRO~
    
    COPY ~%file_path%\MYSPELL.SPL~ override	// or COPY ~%file_path%\MYITEM.ITM~ override
    // Projectile:
     LPF ALTER_SPELL_HEADER // or ALTER_ITEM_HEADER it its an item
      INT_VAR
       projectile = MYPROJ  //  the filename without extension
     END
    // Specifics:
     LPF ALTER_EFFECT
      INT_VAR
       match_opcode = 177  // Use Eff file, or the number of the opcode your using to target a specifics)
       match_parameter1 = ~value~ // (whatever placeholder value you have in the effect already)
       match_parameter2 = 6  // specifics
       parameter1 = specific_1
     END
    The LPF's, ALTER_SPELL_HEADER and ALTER_EFFECT, are functions built-in to Weidu, unlike the "ADD_SPECIFIC" which I had to define myself. These two can alter most fields in item and spell files for existing headers/effects, but I've only included the parts you will need. They will(by default) return warnings if they do not alter the file.
    file_path will need to be written out starting from(but not including) the folder containing Chitin.key for that game, the same one the Setup-MYMOD.exe file will be located.

    edit:typo, edit2: sorry, another typo in the code
    Post edited by kjeron on
  • chimericchimeric Member Posts: 1,163
    kjeron said:

    chimeric said:

    code

    I just noticed this reply. This all looks just fantastic. It's too bad I would have to learn the whole coding for Weidu business to understand this, be able to use this, adapt this and find errors, if any, in my implementation of it. As it is, I'm like a blind man with an elephant - you can help him ride, but he still won't know what. I should stop asking people for code, it's no good to me.

    I guess I'll just include some instructions for manual changes in the IDS files when the mod is ready. It's not difficult to open up a few files in Notepad and insert some entries there.
Sign In or Register to comment.