Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Axis & Allies 1942 Online is now available in Early Access! Buy it on Steam. The FAQ is available.
New Premium Module: Tyrants of the Moonsea! Read More
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

-HOW TO DO STUFF IN WEIDU-

24567

Comments

  • OlvynChuruOlvynChuru Member Posts: 2,246
    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: 2,736
    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: 2,246
    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.

  • subtledoctorsubtledoctor Member Posts: 11,176

    EDIT: Never mind, I figured it out.

    People saying "figured it out" is a pet peeve of mine since when I have the same issue three years later and find this thread, and I see the issue was solved but not how. :lol:

    @OlvynChuru I assume your solution is OUTER_SET...?

    Grammarsaladinethelminsterlolien
  • OlvynChuruOlvynChuru Member Posts: 2,246
    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,617
    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: 2,246
    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: 2,736
    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: 182
    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
    

  • subtledoctorsubtledoctor Member Posts: 11,176
    BCaesar said:


    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,

    Not possible, sorry.

    As for posting code, I'm on my phone so I can't use the shortcuts in the forum software. I just use < pre > < /pre > and type it out longhand.

  • semiticgodsemiticgod Member, Moderator Posts: 13,381
    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,003

    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

    tbone1semiticgodlolien
  • semiticgodsemiticgod Member, Moderator Posts: 13,381
    @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,003

    @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.

    semiticgodlolien
  • AndreaColomboAndreaColombo Member Posts: 5,320
    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?

  • subtledoctorsubtledoctor Member Posts: 11,176
    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?

    I've only seen them used in the context of functions or macros, such as ALTER_EFFECT or ADD_ITEM_EQEFFECT, etc. Put simply, INT_VAR calls for an integer value to fill a variable in the function, and STR_VAR calls for a string (which goes inside ~...~ delimiters). Most of these functions have default values for each variable (check the Weidu readme for details) so you only need to specify variables which differ from the defaults.

    Occasionally you might want to include an existing variable from some other part of your .tp2 in these fields. The integer fields can generally take variables directly, while string fields generally want to specify that you are using a variable. So you might have something like
    LPF ALTER_EFFECT INT_VAR parameter1 = %an_integer% STR_VAR resource = EVAL ~%a_string%~ END
    I'm not sure that EVAL is universally needed though; it may differ by function, or some other context. I generally use trial-and-error to figure it out; if I use a function like this and it seems correct, but isn't working, I try it with and without the EVAL.

    AndreaColombo
  • argent77argent77 Member Posts: 2,736
    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:
    // 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

    Edit: Correct order of INT_VAR, STR_VAR and RET sections is important.

    AndreaColomboGrammarsalad
  • semiticgodsemiticgod Member, Moderator Posts: 13,381
    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.

  • subtledoctorsubtledoctor Member Posts: 11,176

    @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.

    DELETE_EFFECT works largely the same way as CLONE_EFFECT.

    I would be careful about which items you want to edit, however... probably calls for some judicious use of PATCH_IF to filter what items get changed. (I sorely wish there was an IDENTIFY_EFFECT function so that we wouldn't need to resort to stuff like
    READ_SHORT (fx_off + i * 0x30)

  • kjeronkjeron Member Posts: 2,003
    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

    semiticgod
  • OlvynChuruOlvynChuru Member Posts: 2,246
    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.

  • subtledoctorsubtledoctor Member Posts: 11,176

    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.

    https://forums.beamdog.com/discussion/comment/855358/#Comment_855358

    (The linked post is unhelpful, just me asking the same question. But check the responses.)

  • OlvynChuruOlvynChuru Member Posts: 2,246
    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: 246

    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: 246
    edited June 2017
    My mistake. I created one for my own use so long ago I was sure it was WeiDU content. ;)

  • NickBluetoothNickBluetooth Member Posts: 43
    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: 2,246
    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: 246
    edited July 2017
    The best way is to use the function created by @Argent77 in its Golem Construction for Spellcasters mod.

  • argent77argent77 Member Posts: 2,736
    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.