Jump to content

How to change name of Item's abilities?


Recommended Posts

Making some new weapons in IW:EE, some having their own abilities which can be accessed from the "Use Item" menu. The abilities are designed as spells using NearInfinity but in-game, the name of the ability is the same as the name of the weapon. And right-clicking on the ability just gives the description of the weapon and not of the spell (IIRC this was also the case in BG:EE).

Is there a way to change this?

Link to comment

If it's like the original games then there's a 2da file called TOOLTIP.2DA which contains the string references to the names of items' special abilities. Right-clicking gives the item description because as per traditional design the special abilities are just a bunch of direct effects, and not linked to any actual spells. Just put the entire spell description in with the item description, if you want.

Edited by ABlake
Link to comment

You can drop these functions (TRA2STR and ADD_ITEM_TOOLIPS) into your code, or in the ALWAYS block. Then use it on an item with something like:

LAF ~ADD_ITEM_TOOLTIPS~ STR_VAR item = EVAL ~%itm_name%~ tooltips = ~@301~ END

I didn't make that. Honestly I don't remember who did. I did a search and it is in a number of mods floating around.

Ardanis also made a tooltip function, but I don't have experience using that one.

Link to comment

Thank you both @ABlake@subtledoctor ,

I'm attempting on using the WEIDU code with the TRA2STR and ADD_ITEM_TOOLIPS functions but for some reason, the latter function isn't being recognised. I basically copied/pasted the code into the .tp2 file:

DEFINE_PATCH_FUNCTION ~TRA2STR~ // given tra reference, returns string
  STR_VAR tra = ~~ // e.g. ~@123~
  RET str
BEGIN
  PATCH_IF ((~%tra%~ STRING_MATCHES_REGEXP ~@-?[0-9]+~) == 0) BEGIN
    INNER_ACTION BEGIN
      <<<<<<<< .../inlined/mi_tra2str.tph
        OUTER_SPRINT str %tra%
      >>>>>>>>
      COPY - ~.../inlined/mi_tra2str.tph~ ~.../inlined/mi_tra2str.tph~
        EVALUATE_BUFFER
      REINCLUDE ~.../inlined/mi_tra2str.tph~
    END
  END
  ELSE BEGIN
    TEXT_SPRINT str ~%tra%~
  END
END


DEFINE_ACTION_FUNCTION ~ADD_ITEM_TOOLTIPS~
  STR_VAR item = ~~     // e.g. ~sw1h01~
  tooltips = ~~ // e.g. ~@123 @124 6620~, takes combination of tra refs and strrefs for as many abilities as you need to specify
BEGIN
  ACTION_IF (STRING_LENGTH ~%item%~ > 0) BEGIN
    // generate our row to add to tooltip.2da
    OUTER_TEXT_SPRINT row ~%item%~
    OUTER_PATCH ~ %tooltips%~ BEGIN // extract our tooltips from the tooltips string
      REPLACE_EVALUATE ~[ %tab%]+\(@?-?[0-9]+\)~ BEGIN
        PATCH_IF ((~%MATCH1%~ STRING_MATCHES_REGEXP ~@-?[0-9]+~) == 0) BEGIN // tra ref
          // look up string for given tra reference
          LAUNCH_PATCH_FUNCTION ~TRA2STR~ STR_VAR tra = EVALUATE_BUFFER ~%MATCH1%~ RET str = str END
          // use REPLACE to get a strref for our new string
          INNER_PATCH ~0~ BEGIN
            REPLACE ~0~ ~%str%~
            READ_2DA_ENTRY 0 0 1 strref
          END
          TEXT_SPRINT row ~%row% %strref%~ // add to our row
        END
        ELSE BEGIN // strref
          TEXT_SPRINT row ~%row% %MATCH1%~ // add to our row
        END
      END ~~
    END
    
    COPY_EXISTING ~tooltip.2da~ ~override~
      REPLACE_TEXTUALLY ~^[ %tab%]*%item%[ %tab%].*~ ~~ // remove previous row for this item if it exists
      COUNT_2DA_ROWS 1 num_rows
      INSERT_2DA_ROW num_rows 1 ~%row%~ // insert our row at the end
      
      // ensure all rows have -1 entries in unused columns
      REPLACE_TEXTUALLY ~^[ %tab%]*0?[ %tab%]*1[ %tab%]+2[ %tab%]+3.*~ ~~ // remove column labels for now
      COUNT_2DA_COLS num_cols
      TEXT_SPRINT entries ~~
      TEXT_SPRINT col_labels ~~
      FOR (i = 1; i < (num_cols - 1); i += 1) BEGIN // for each number of columns less than there should be
        TEXT_SPRINT entries ~%entries%[ %tab%]+[0-9-]+~ // generate regexp to detect this many columns
        TEXT_SPRINT empties ~~
        FOR (j = (num_cols - 1); j > i; j -= 1) BEGIN // generate -1 entries for the number of missing columns
          TEXT_SPRINT empties ~%empties% -1~
        END
        REPLACE_TEXTUALLY ~^\([ %tab%]*[^ %tab%]+%entries%\)[ %tab%]*[%mnl%]?$~ ~\1%empties%~ // add -1 entries to all rows with this many missing columns
        TEXT_SPRINT col_labels ~%col_labels% %i%~ // generate fresh column labels
      END
      INSERT_2DA_ROW 2 1 ~%col_labels% %i%~ // re-add column labels, with last entry where i == (num_cols - 1)
      PRETTY_PRINT_2DA
      REPLACE_TEXTUALLY ~2DA +~ ~2DA ~
    
  END
END


BEGIN ~Add ABILITY tooltips~
LAF ~ADD_ITEM_TOOLTIPS~ STR_VAR item = EVAL ~%RB_STF02%~ tooltips = ~41300~ END

This is the error:

Installing [Add ABILITY tooltips] [1]
Stopping installation because of error.

ERROR Installing [Add ABILITY tooltips], rolling back to previous state
Will uninstall   0 files for [MOONBOY_MOD/MOONBOY_MOD.TP2] component 2.
Uninstalled      0 files for [MOONBOY_MOD/MOONBOY_MOD.TP2] component 2.
ERROR: Failure("Unknown function: ADD_ITEM_TOOLTIPS")
Please make a backup of the file: SETUP-MOONBOY_MOD.DEBUG and look for support at: SubtleD

 

Link to comment

I've manually edited the "/overide/tooltip.2da" file and added extra columns along with the correct string values so now the tooltips for each ability shows the correct names. Unfortunately, the charges for each item ability gets messed up if there's more than 3 abilities. I've added 6 item abilities and if I use any of the 3rd/4th/5th/6th ability, all charges get depleted.

It is mentioned here and here that adding new headers would result in using the same charge as the first "extended header" (or column). Is there a way of getting round this when playing with more than 3 item abilities?

Edited by pete_smith1229
Link to comment
2 hours ago, pete_smith1229 said:

attempting on using the WEIDU code with the TRA2STR and ADD_ITEM_TOOLIPS functions but for some reason, the latter function isn't being recognised.

Just move your BEGIN line

BEGIN ~Add ABILITY tooltips~

above the DEFINE_FUNCTION stuff.

BEGIN tells weidu when to start paying attention to when it coded; so you have to put  stuff like that after the BEGIN.

An alternative: write  ALWAYS above the function definitions, and END after them. The ALWAYS means that every time Weidu sees a BEGIN line starting a mod component, it will go back and run through the ALWAYS  code. So this would be convenient if, for instance, you end up having multiple components and they all use the tooltips function.)

What I do, is put stuff like function definitions into a separate file in my mod  folder - like "misc_functions.tpa." Then I structure my .tp2 file like this:

ALWAYS

  INCLUDE ~%MOD_FOLDER%/misc_functions.tpa~

END

BEGIN ~my mod component #1~

[do stuff]

BEGIN ~my mod component #2~

[do stuff]

Now, I can put any useful functions I find into that misc_functions.tpa file, and all those functions willbe available for use by any components in the mod.

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...