Jump to content


Photo

Toss your semi-useful WeiDU macros here


51 replies to this topic

#16 argent77

argent77
  • Modders
  • 711 posts
  • Gender:Male

Posted 20 July 2017 - 01:44 AM

The majority of my own functions and macros are too specific to be of (general) use. But there is a small number of functions that might be helpful.

TO_HEX_NUMBER:
A decimal to hexadecimal number converter. May be useful when dealing with IDS or INI files.
Spoiler

FIND_FREE_ANIM_SLOT:
This function attempts to find a free creature animation slot in a given range, so that it can be used to install custom creature animations. I'm using it quite extensively in my Golem Construction mod (example code). This function requires EE games patched to v1.4 or higher. It also makes use of the function TO_HEX_NUMBER mentioned above.
Spoiler


#17 K4thos

K4thos
  • Modders
  • 1057 posts
  • Gender:Male

Posted 20 July 2017 - 04:23 AM

TO_HEX_NUMBER:
A decimal to hexadecimal number converter. May be useful when dealing with IDS or INI files.

there is actually a hidden SPRINTF command in weidu that can do it. Example:

SET dec_value = 3
SPRINTF hex_value ~%x~ (dec_value)
PATCH_PRINT ~%hex_value%~

Edited by K4thos, 20 July 2017 - 04:23 AM.


#18 argent77

argent77
  • Modders
  • 711 posts
  • Gender:Male

Posted 20 July 2017 - 05:14 AM

You're right. There is a (patch-only) SPRINTF command available which supports %s, %d and %x format specifiers. However, the command doesn't properly convert negative values into hexadecimal format, always prefixes the result with "0x" and you can't specify minimum number of digits, which forces me to do a lot of editing either way for my purposes.



#19 Angel

Angel
  • Members
  • 114 posts
  • Gender:Not Telling
  • Location:Netherlands

Posted 20 July 2017 - 06:06 AM

FIND_FREE_ANIM_SLOT:
This function attempts to find a free creature animation slot in a given range, so that it can be used to install custom creature animations. I'm using it quite extensively in my Golem Construction mod (example code). This function requires EE games patched to v1.4 or higher. It also makes use of the function TO_HEX_NUMBER mentioned above.
 
Ah, if only I knew how to create new animations and add them to the game.  It's been a long-time wish of mine to add griffins, (black) unicorns and nightmares, to name but a few. :-)


#20 Gwendolyne

Gwendolyne
  • Members
  • 151 posts
  • Gender:Male
  • Location:France

Posted 20 July 2017 - 08:35 AM

 

FIND_FREE_ANIM_SLOT:
This function attempts to find a free creature animation slot in a given range, so that it can be used to install custom creature animations. I'm using it quite extensively in my Golem Construction mod (example code). This function requires EE games patched to v1.4 or higher. It also makes use of the function TO_HEX_NUMBER mentioned above.
 
Ah, if only I knew how to create new animations and add them to the game.  It's been a long-time wish of mine to add griffins, (black) unicorns and nightmares, to name but a few. :-)

 

 

Sorry for the off-topic, but you won't have to wait too long, at least for unicorns (regular and black ones) and nightmares. ;)


Edited by Gwendolyne, 20 July 2017 - 08:36 AM.

CARPE DIEM...



In progress : Menace sur le Royaume de Diamant Éternel

#21 Angel

Angel
  • Members
  • 114 posts
  • Gender:Not Telling
  • Location:Netherlands

Posted 21 July 2017 - 12:03 AM

 

 

FIND_FREE_ANIM_SLOT:
This function attempts to find a free creature animation slot in a given range, so that it can be used to install custom creature animations. I'm using it quite extensively in my Golem Construction mod (example code). This function requires EE games patched to v1.4 or higher. It also makes use of the function TO_HEX_NUMBER mentioned above.
 
Ah, if only I knew how to create new animations and add them to the game.  It's been a long-time wish of mine to add griffins, (black) unicorns and nightmares, to name but a few. :-)

 

 

Sorry for the off-topic, but you won't have to wait too long, at least for unicorns (regular and black ones) and nightmares. ;)

 

 

Interesting, I will certainly keep an eye on that.  Please tell me they will work with non-EE games as well! And I'd pay you to make a griffin animation.  (Seriously, I would.)



#22 Gwendolyne

Gwendolyne
  • Members
  • 151 posts
  • Gender:Male
  • Location:France

Posted 21 July 2017 - 03:44 AM

End of the off-topic : my mod is written for BG2 and BGT and will be EE compatible. ;)

The ironic point is that I can use huge tarasque animations (640x640 px) with IA but not in BG2:EE because the enhanced dragon animation format seems to be buggy and does not allow to add new effective slots to ANIMATE.IDS.


CARPE DIEM...



In progress : Menace sur le Royaume de Diamant Éternel

#23 jastey

jastey
  • Gibberlings
  • 6893 posts
  • Gender:Female

Posted 25 July 2017 - 07:57 AM

argent77 just posted a WeiDU function to to fetch a journal strref here. Thinking about all the instances where original game journal entries need to be erased by a mod which only works for exact matching strings but BGT / EET not having them at specified reference numbers, this is very cool to use especially across game platforms.


Edited by jastey, 25 July 2017 - 08:20 AM.


#24 K4thos

K4thos
  • Modders
  • 1057 posts
  • Gender:Male

Posted 25 July 2017 - 08:17 AM

but BGT / EET not having them at specified reference numbers

 

actually EET handles BG1 strrefs in a static way. SAY is not used at all during installation. You can reference correct journal number by simply adding 200000 to the original strrefs. For example BG1 strrefs 27091 is 227091 in EET and that's always true regardless of mods you install before/after it.



#25 jastey

jastey
  • Gibberlings
  • 6893 posts
  • Gender:Female

Posted 25 July 2017 - 08:20 AM

Ah, yes, I recall now that I knew this. That is a very good thing. Still, since my mods are compatible with BGT, as well, I'll always have the problem with floating strrefs.



#26 K4thos

K4thos
  • Modders
  • 1057 posts
  • Gender:Male

Posted 25 July 2017 - 08:36 AM

the function is extremely useful, indeed. Even BG2 Fixpack 'Game Text Update'  can brake journal erasing in mods that use exact match approach (and there are 2 versions of this component if I remember correctly). Then there is a problem with translation of strings (I remember tons of issues with erasing journal in Polish version of some older mods - most likely because translator didn't even know that the text was meant to be copied directly from TLK file rather than translated from scratch).

 

Now I feel silly since I never thought about looking what IESDP has to say about DLG format (which turns out can be looped through like any other BG file format). For some reason I always considered it as a text file while decompiled and unreadable gibberlish after compiling :p
 


Edited by K4thos, 25 July 2017 - 08:42 AM.


#27 Gwendolyne

Gwendolyne
  • Members
  • 151 posts
  • Gender:Male
  • Location:France

Posted 25 July 2017 - 09:13 AM

Now I feel silly since I never thought about looking what IESDP has to say about DLG format (which turns out can be looped through like any other BG file format). For some reason I always considered it as a text file while decompiled and unreadable gibberlish after compiling :p
 

 

You can loop through states and transitions. Here is a homemade function used to extend existing dlg:

 

Spoiler

 

Then:

COPY_EXISTING - ~UHOGRE01.dlg~ ~override~
    PATCH_IF (SOURCE_SIZE > 0x2f) THEN BEGIN    // protects against invalid files

    // #33324 ~J'ai surtout décidé de mettre un terme à ton ignoble existence, sale monstre !~
    // EN = ~I've actually decided to end your monstrous existence, creature!~
        LPF ~GW_FIND_DLG_RESPONSE_STRING~ INT_VAR GW_string_dlg = 33324 RET GW_transition_found GW_state_number GW_transition_number END
        PATCH_IF ("%GW_transition_found%" STRING_EQUAL "Y") AND (GW_transition_number != "-99") BEGIN
            SET UHOGRE01_Transition16 = GW_transition_number
            SET UHOGRE01_State16 = GW_state_number
        END

    END    // of PATCH_IF (SOURCE_SIZE > 0x2f)
BUT_ONLY

And actually in the d file:

EXTEND_TOP UHOGRE01 %UHOGRE01_State16% #%UHOGRE01_Transition16%
    + ~Global("GWChevaucheuseKit","GLOBAL",2) Global("GWLyrielUmar","LOCALS",0)~ + @11100501 GOTO UhOgre01_Question    // ~D'abord, j'aimerais que tu répondes à une question, Madulf.~
END





 


CARPE DIEM...



In progress : Menace sur le Royaume de Diamant Éternel

#28 Jarno Mikkola

Jarno Mikkola

    The Imp

  • Modders
  • 6201 posts
  • Gender:Male
  • Location:The town where the dead haven't keeled over, yet. In Finland.

Posted 25 July 2017 - 09:19 AM

Off topic, but have to ask, what's the difference ?

PATCH_IF plah THEN BEGIN 
...
PATCH_IF plah BEGIN


Edit: thanks for the conformation ... I write it too... but most of he time it's there cause of a copy-paste had it.

Edited by Jarno Mikkola, 25 July 2017 - 11:23 AM.

Welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand.
Here's how to install all the ... mods you ever really could want to Infinity Engine games. I removed the stable word from there as Roxanne began to add BS mods that are likely to break compatibility from the BWS.

#29 Gwendolyne

Gwendolyne
  • Members
  • 151 posts
  • Gender:Male
  • Location:France

Posted 25 July 2017 - 10:56 AM

In WeiDU it seems: none!

 

But as I am far away from being a programmer, I learned the IF THEN condition way of codding at my beginnings, a long time ago. After many years of modding, I know  that THEN is not mandatory in WeiDU code but... the force of habit: sometimes I write it, sometimes not... ;)


CARPE DIEM...



In progress : Menace sur le Royaume de Diamant Éternel

#30 jastey

jastey
  • Gibberlings
  • 6893 posts
  • Gender:Female

Posted 26 July 2017 - 12:12 AM

Question to cd_extend_bg_area_script: If I have a script that uses tra strings, but from another file (with different name). Is that possible? Where would I put the USING ~path/blah.tra~?





Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users