Jump to content
CamDawg

Toss your semi-useful WeiDU macros here

Recommended Posts

@Ardanis

Could you have a look at the following piece of code? It seems there's a problem with your ADD_SPELL_HEADER/FJ_SPL_ITM_REINDEX....

Spoiler

CREATE    "SPL"    "GTPENAL"
    WRITE_LONG 0x018 (BIT14 | BIT25)  // Castable when Silenced, Ignore Dead/Wild Magic
    WRITE_SHORT 0x01c 4               // Innate ability
    WRITE_LONG 0x034 1                 // Spell level

    LPF ADD_SPELL_HEADER
    INT_VAR
        type = 1         // Melee
        location = 4      // Ability
        target = 1         // Living Actor
        range = 1
        required_level = 1
        projectile = 1       // NONE
    END

 

This is the error:

Spoiler

ERROR: cannot convert hs or %hs% to an integer
Stopping installation because of error.
Stopping installation because of error.
Stopping installation because of error.
Stopping installation because of error.
Stopping installation because of error.

ERROR Installing [Revised Items ---> BG:EE], rolling back to previous state
[Item_Tweaks/backup/0/UNSETSTR.0] SET_STRING uninstall info not found
Will uninstall   0 files for [ITEM_TWEAKS/ITEM_TWEAKS.TP2] component 0.
Uninstalled      0 files for [ITEM_TWEAKS/ITEM_TWEAKS.TP2] component 0.
Unable to Unlink [Item_Tweaks/backup/0/READLN.0]: Unix.Unix_error(Unix.ENOENT, "unlink", "Item_Tweaks/backup/0/READLN.0")
Unable to Unlink [Item_Tweaks/backup/0/READLN.0.TEXT]: Unix.Unix_error(Unix.ENOENT, "unlink", "Item_Tweaks/backup/0/READLN.0.TEXT")
ERROR: Not_found

 

 

Edited by Luke

Share this post


Link to post

The function checks file's extension to determine its type (spl or itm), and CREATE action doesn't seem to provide one.This works

CREATE    "SPL"    "GTPENAL"
    WRITE_LONG 0x018 (BIT14 | BIT25)  // Castable when Silenced, Ignore Dead/Wild Magic
    WRITE_SHORT 0x01c 4               // Innate ability
    WRITE_LONG 0x034 1                 // Spell level

COPY_EXISTING "GTPENAL.SPL" override
    LPF ADD_SPELL_HEADER
    INT_VAR
        type = 1         // Melee
        location = 4      // Ability
        target = 1         // Living Actor
        range = 1
        required_level = 1
        projectile = 1       // NONE
    END

 

Share this post


Link to post
On 1/15/2019 at 2:12 PM, Ardanis said:

The function checks file's extension to determine its type (spl or itm), and CREATE action doesn't seem to provide one.This works


CREATE    "SPL"    "GTPENAL"
    WRITE_LONG 0x018 (BIT14 | BIT25)  // Castable when Silenced, Ignore Dead/Wild Magic
    WRITE_SHORT 0x01c 4               // Innate ability
    WRITE_LONG 0x034 1                 // Spell level

COPY_EXISTING "GTPENAL.SPL" override
    LPF ADD_SPELL_HEADER
    INT_VAR
        type = 1         // Melee
        location = 4      // Ability
        target = 1         // Living Actor
        range = 1
        required_level = 1
        projectile = 1       // NONE
    END

 

Wow that's good to know.  I've had to avoid CREATE for like a year because I didn't realize why FJ_SPL_ITM_REINDEX kept throwing errors. @Aquadrizzt if you're around these parts, might want to update QDMulti v0.3 with this adjustment.

Edited by subtledoctor

Share this post


Link to post

@subtledoctor

Yep, CREATE is so handy, there's no need to create in advance your files with NearInfinity......

Thanks @Ardanis by the way

Edited by Luke

Share this post


Link to post

Strictly speaking, if you create them from scratch then you don't need FJ_SPL_ITM_REINDEX in the first place, it's just a safeguard against non-standard structuring in some files - just comment it out in your code.

Share this post


Link to post
1 hour ago, Ardanis said:

Strictly speaking, if you create them from scratch then you don't need FJ_SPL_ITM_REINDEX in the first place, it's just a safeguard against non-standard structuring in some files - just comment it out in your code.

But... that's called in the ADD_SPELL_HEADER function... no?   I always had errors when trying to add spell headers to new, headerless spells.  E.g. this code would tend to flake out on me at line 285.

Share this post


Link to post

Same issue as Luke's - it's trying to run reindex, and it fails without file extension. Frankly, those functions have been written well before CREATE (in fact, the library file they're from has its own CREATE_SPELL function), so this is a new conflict... but if you only need header additions to new files, then you can just comment the reindex out at line 84.

Edited by Ardanis

Share this post


Link to post

This function automatically updates the descriptions of the anti-defense spells (Ruby Ray, Breach et al) to reflect the actual spells that they affect (which, on a modded environment, might be very different from the vanilla list - not that the vanilla list is completely accurate anyway). The algorithm is a little heuristic but should be pretty robust. You need to supply one short string.

EDIT: this uses slightly more of SCS's function environment than I'd realized at first glance. I'll embed it in v32; if anyone wants to use it, talk to me about how to extract it.

 

Share this post


Link to post
Posted (edited)

ADD_SPELL_EX - Action function similar to WeiDU ADD_SPELL (adding a spell of type and level into spell.ids, in the first empty slot possible), but more flexible:

https://github.com/K4thos/IE-code-repository/blob/master/add_spell_ex.tpa

-----------

Also my older REPLACE_MULTILINE function now supports regexp variables in output string, which works in a similar way to REPLACE_EVALUATE (see the 200 MATCHi variables explanation in weidu documentation.)

Edited by K4thos

Share this post


Link to post
Posted (edited)

APPEND_TO_IDS - Action function for appending into IDS file at the first free index slot within given index range.
The action can return numerical reference of the appended entry or existing index if symbolic name already exists within the file.

Example usage:

LAF APPEND_TO_IDS INT_VAR min = 400 max = 65535 STR_VAR file = ~STATS.IDS~ name = ~SYMBOLIC_NAME~ RET index END

https://github.com/K4thos/IE-code-repository/blob/master/append_to_ids.tpa

Edited by K4thos

Share this post


Link to post
Posted (edited)

COMPILE_LUA - Action function that lets you compile BAF and D files containing Bubb's EEex Lua functions (EEex_Lua, EEex_LuaTrigger)
The function converts easy to read multiline Lua code into a single line syntax supported by weiduExample usage:

LAF COMPILE_LUA STR_VAR path = ~someDir/someFile.baf~ END
LAF COMPILE_LUA STR_VAR path = ~someDir~ END

https://github.com/K4thos/IE-code-repository/blob/master/compile_lua.tpa

edit: feel free to merge this post with previous one.

Edited by K4thos

Share this post


Link to post
Guest
You are commenting as a guest. If you have an account, please sign in.
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.


×