Skip to content

-HOW TO DO STUFF IN WEIDU-

2456789

Comments

  • OlvynChuruOlvynChuru Member Posts: 3,075
    edited February 2017
    How do I modify a specific actor in an area that has multiple actors with the same name?
    Post edited by OlvynChuru on
  • argent77argent77 Member Posts: 3,431
    You have probably no other choice but to scan the ARE file manually for the actor. The ARE file structure is described there.

    You can use this template and fill in the missing pieces:
    COPY_EXISTING ~YOUR_MAP.ARE~ ~override~ READ_LONG 0x54 ofsActors READ_SHORT 0x58 numActors FOR (idx = 0; idx < numActors; ++idx) BEGIN SET offset = ofsActors + (idx * 0x110) // start offset of current actor structure READ_ASCII offset actorName (32) NULL PATCH_IF (~%actorName%~ STRING_EQUAL ~Name_of_actor~) BEGIN // you code to determine and modify the right actor... SET idx = numActors // use this to terminate the loop prematurely after you're done END END BUT_ONLY
    Grammarsalad
  • OlvynChuruOlvynChuru Member Posts: 3,075
    edited February 2017
    I'm wondering how to make a variable in a TP2 file that I can reuse without having to define it over and over again. For example, I'd like to have a variable called strength which is equal to 0x238 (or 568 in decimal), so that if I want to set a creature's Strength to 25 I could simply do WRITE_BYTE strength 25. Is it possible to do that without having to define strength with each creature?

    EDIT: Never mind, I figured it out.
  • The user and all related content has been deleted.
    Grammarsaladinethelminsterlolien
  • OlvynChuruOlvynChuru Member Posts: 3,075
    edited February 2017
    No, my solution is to use an Amulet of Offsets. The code looks like this:

    COPY_EXISTING ~amul02.itm~ ~override~
    strength=0x238
    exceptionalstrength=0x239
    intellgence=0x23a
    wisdom=0x23b
    dexterity=0x23c
    constitution=0x23d
    charisma=0x23e
    ...and so on.

    I found that if I do this I can use these variables when I'm copying other files.
    lolien
  • ArdanisArdanis Member Posts: 1,736
    edited February 2017
    You can also do

    OUTER_PATCH blah BEGIN // blah is just some random string, it's not being used in this scenario
    strength=0x238
    // ...
    END

    to set variables without typing OUTER_SET for each.
    OlvynChuruCrevsDaak
  • OlvynChuruOlvynChuru Member Posts: 3,075
    I was wondering, what's the easiest way to make a new string for the purposes of having someone say it via a script? I want to make an Imix creature in BG1 who says "Who calls Imix, Prince of Fire?!" This string is not in BG1's files; I want to know how to put it in with WeiDU and have Imix say it.
  • argent77argent77 Member Posts: 3,431
    Use RESOLVE_STR_REF(~Your string~) to receive a strref value that can be used directly within game resources.

    Example:
    <<<<<<<< .../inlined/script.baf IF True() THEN RESPONSE #100 DisplayString(Myself, %my_message%) END >>>>>>>> OUTER_SET my_message = RESOLVE_STR_REF(~Your string~) // or use a tra reference COMPILE ~.../inlined/script.baf~ EVAL // EVAL instructs WeiDU to resolve variables within the script
    OlvynChurulolien
  • BCaesarBCaesar Member Posts: 452
    edited May 2017

    @BCaesar look up APPEND

    EDIT - in fact I use it in the 2nd post in this thread. Just:

    APPEND ~stylbonu.2da~ ~string~
    Just, with .2da files, make sure you get the number of columns right.
    Hello again. Another question. Let's say I want to make a Shadowdancer able to dual-class with a Jester. Now I have no idea if this is even possible, but if it is I'd need to add a new column saying "Jester" to the top line where all the classes are listed in dualclass.2da and then make a 1 down where Shadowdancer meets that column. So my question is how does one add a column to a 2da file?

    Also on this forum recently it seems to me that anything put in code (using the option in the menu or using Codeblock and code) ends up being unreadable once posted? As long as you just use pre and /pre you're ok, but anything in code ends up looking really weird. Like this:
    IF //Aerie's script If Mazzy goes hostile.
    	Global("_bMazzyHostile","GLOBAL",4)
    	InParty("Aerie") 
    	!StateCheck("Aerie",CD_STATE_NOTVALID)
    THEN
    	RESPONSE #100
    	LeaveParty() 
    	Enemy()
    	SetGlobal("KickedOut","LOCALS",2)
    END
    
  • The user and all related content has been deleted.
  • semiticgoddesssemiticgoddess Member Posts: 14,903
    How would I apply a patch to multiple existing items? I'd like to rig all minimum HP 1 items so that they grant immunity to a certain spell.

    Also, is it possible to remove effects from items? Would it be possible to remove MINHP1.itm's immunity to poison, for example?
  • kjeronkjeron Member Posts: 2,367

    How would I apply a patch to multiple existing items? I'd like to rig all minimum HP 1 items so that they grant immunity to a certain spell.

    Also, is it possible to remove effects from items? Would it be possible to remove MINHP1.itm's immunity to poison, for example?

    Known existing items?:
    COPY_EXISTING
     ~ITEM1.itm~ override
     ~ITEM2.itm~ override
     ~ITEM3.itm~ overrride
     ~etc....itm~ override
     LPF ADD_SPELL_EFFECT
      INT_VAR
       opcode = 206 // Immunity to Spell
       target = 1
       timing = 2
      STR_VAR
       resource = ~RESREF~  // Spell filename
     END
     LPF DELETE_EFFECT
      INT_VAR
       check_headers = 0
       match_opcode = 101  // Immunity to effect
       macth_parameter2 = 25  // Poison
     END
    
    or unknown existing items?:
    COPY_EXISTING_REGEXP ~.*\.itm~ override
     LPF CLONE_EFFECT
      INT_VAR
       silent = 1
       check_headers = 0
       match_opcode = 208  // Minimum HP
       opcode = 206 // Immunity to Spell
       parameter1 = 0
      STR_VAR
       resource = ~RESREF~  // Spell filename
     END
     READ_LONG 0x6a fx_off
     READ_SHORT 0x70 glob_fx
     FOR (i = 0; i < glob_fx; ++i) BEGIN
      READ_SHORT (fx_off + i * 0x30) opcode
      PATCH_IF opcode = 208 BEGIN
       LPF DELETE_EFFECT
        INT_VAR
         check_headers = 0
         match_opcode = 101  // Immunity to effect
         macth_parameter2 = 25  // Poison
       END
       SET i = glob_fx
      END
     END
    BUT_ONLY
    tbone1semiticgoddesslolien
  • semiticgoddesssemiticgoddess Member Posts: 14,903
    @kjeron: Let's say we're patching all of the items (I was thinking of excepting trolls from the list, but decided against it).

    What I need to do is give all MINHP1 items immunity to the spell "USSD15." Would this be sufficient if I just copied and pasted it at the bottom of my TP2?

    COPY_EXISTING_REGEXP ~.*\.itm~ override
    LPF CLONE_EFFECT
    INT_VAR
    silent = 1
    check_headers = 0
    match_opcode = 208 // Minimum HP
    opcode = 206 // Immunity to Spell
    parameter1 = 0
    STR_VAR
    resource = ~USSD15~ // Spell filename
    END
    BUT_ONLY
  • kjeronkjeron Member Posts: 2,367

    @kjeron: Let's say we're patching all of the items (I was thinking of excepting trolls from the list, but decided against it).

    What I need to do is give all MINHP1 items immunity to the spell "USSD15." Would this be sufficient if I just copied and pasted it at the bottom of my TP2?[/spoiler]

    Yes, it will duplicate every MINHP1 effect it finds with an immunity to spell (USSD15) effect.
    The one MINHP1 effect I know of that it will NOT account for is that applied by Story Mode, as it is spell-based, not item-based.
    semiticgoddesslolien
  • AndreaColomboAndreaColombo Member Posts: 5,524
    I've been looking for an explanation of how INT_VAR and STR_VAR work and when they should be used, but the WeiDU documentation doesn't seem to have it. Would a kind soul enlighten me?
  • [Deleted User][Deleted User] Posts: 0
    edited May 2017
    The user and all related content has been deleted.
    AndreaColombo
  • argent77argent77 Member Posts: 3,431
    edited May 2017

    I've been looking for an explanation of how INT_VAR and STR_VAR work and when they should be used, but the WeiDU documentation doesn't seem to have it. Would a kind soul enlighten me?

    You have linked to an outdated WeiDU Readme. The current (stable) Readme can be found here: http://www.weidu.org/~thebigg/README-WeiDU.html

    INT_VAR and STR_VAR (and RET as well) are used by WeiDU functions to handle function arguments or return values. As the names suggest INT_VAR expects a list of numeric arguments (and don't ever require the EVAL keyword), STR_VAR expects string arguments and requires EVAL to evaluate content of variables. RET can be used to return values from a function call. Macros don't support argument lists, but instead share the global namespace for variables.

    Example code:
    [spoiler]// The function definition DEFINE_ACTION_FUNCTION MyFunction INT_VAR numArg1 = 0 numArg2 = 0 numArg3 = 1234 STR_VAR strArg1 = ~~ strArg2 = ~~ strArg3 = ~Hello World!~ RET result1 result2 BEGIN // your code... END // And the function call OUTER_SET myNum = 1234 OUTER_TEXT_SPRINT myString ~Hello World!~ LAF MyFunction // LAF is short for LAUNCH_ACTION_FUNCTION INT_VAR numArg1 = 1234 numArg2 = myNum // skip numArg3 if you want to use its default value 1234 STR_VAR strArg1 = ~Hello World!~ // no EVAL needed strArg2 = EVAL ~%myString%~ // EVAL needed // skip strArg3 if you want to use its default value ~Hello World!~ RET result1 result2 END
    [/spoiler]
    Edit: Correct order of INT_VAR, STR_VAR and RET sections is important.
    AndreaColomboGrammarsalad
  • semiticgoddesssemiticgoddess Member Posts: 14,903
    edited May 2017
    @kjeron: It worked! I got all MINHP1 items to grant immunity to the USSD15 spell.

    Is it possible to remove an effect by opcode from items? I'd like to remove immunity to opcode 241 (Control Creature) from MINHP1 items.
  • The user and all related content has been deleted.
  • kjeronkjeron Member Posts: 2,367
    edited May 2017

    Is it possible to remove an effect by opcode from items? I'd like to remove immunity to opcode 241 (Control Creature) from MINHP1 items.

    COPY_EXISTING_REGEXP ~.*\.itm~ override
     READ_LONG 0x6a fx_off
     READ_SHORT 0x70 glob_fx
     FOR (i = 0; i < glob_fx; ++i) BEGIN
      READ_SHORT (fx_off + i * 0x30) opcode
      PATCH_IF opcode = 208 BEGIN	// Item has MINHP effect
       LPF DELETE_EFFECT
        INT_VAR
         check_headers = 0	// Ignore abilities / Only remove global/equipped effects
         match_opcode = 101  // Immunity to effect
         match_parameter2 = 241  // Control Creature
       END
       SET i = glob_fx
      END
     END
    BUT_ONLY
    semiticgoddess
  • OlvynChuruOlvynChuru Member Posts: 3,075
    What is the easiest way to add a header to an item or spell in WeiDU? Looking through the WeiDU documentation, I was unable to find a function like ADD_ITEM_HEADER or ADD_SPELL_HEADER.
  • The user and all related content has been deleted.
  • OlvynChuruOlvynChuru Member Posts: 3,075
    That link mentioned how to add a spell header, but it didn't say how to add an item header.

    Does anyone have a function for adding a header to an item?
  • GwendolyneGwendolyne Member Posts: 461

    What is the easiest way to add a header to an item or spell in WeiDU? Looking through the WeiDU documentation, I was unable to find a function like ADD_ITEM_HEADER or ADD_SPELL_HEADER.

    I don't understand: you can do it with the ADD_ITEM_HEADER function.
  • badungubadungu Member Posts: 53

    I don't understand: you can do it with the ADD_ITEM_HEADER function.

    I think there's currently no ADD_ITEM_HEADER function inside weidu (can't find it in the source code... :p )

    I did a quick google search and GeN1e did a function some years ago:

    http://forums.pocketplane.net/index.php/topic,27532.msg329089.html#msg329089

    I think this can be used like this:
    LPF ~ADD_ITEM_HEADER~ INT_VAR type=3 required_id=0 location=3 alt_dicesize=0 target=1 target_count=0 range=0 projectile_type=0 alt_dicenumber=0 speed=0 alt_damage=0 thaco=0 dicesize=0 school=0 dicenumber=0 sectype=0 damage=0 damage_type=0 charges=0 depletion=0 flags=0 projectile=1 overhand=0 backhand=0 thrust=0 is_bow=0 is_xbow=0 is_sling=0 copy_header=0 insert_point=~-1~ STR_VAR icon=~~ END
  • GwendolyneGwendolyne Member Posts: 461
    edited June 2017
    My mistake. I created one for my own use so long ago I was sure it was WeiDU content. ;)
  • NicolBluetoothNicolBluetooth Member Posts: 48
    I'm new to WeiDU, and I've been trying to make a simple PST:EE mod that adds an || (OR) condition to the ends of a few store item sale triggers and the ends of some of the lines of a few dialog response triggers. I know the numbers of all the StringRefs of the sale triggers I want to append the OR statements to, I know all the response trigger numbers in the dlg file that I want to edit, and I know what OR statements I want to add to the ends of each of them. I just don't know how.
    Unlike other PLs I've learned, there aren't too many extensive tutorials on WeiDU. Most of the examples of WeiDU online mainly explain how to add stuff, not how to edit them, so I'm not sure what functions I could use to easily achieve my goals. Does anyone know the best way to edit these triggers in WeiDU?
  • OlvynChuruOlvynChuru Member Posts: 3,075
    What is the safest way to add an animation to the game? How do I make sure that no other mod has made an animation with the same number as mine?
  • GwendolyneGwendolyne Member Posts: 461
    edited July 2017
    The best way is to use the function created by @Argent77 in its Golem Construction for Spellcasters mod.
  • argent77argent77 Member Posts: 3,431
    I have published the animation slot function in this post, so that it can be added to other projects more easily. Description of function and required parameters (as well as example code) can be found there as well.
    AndreaColomboGrammarsaladlolien
Sign In or Register to comment.