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
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?
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.
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
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
@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?
@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.
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 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?
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.
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
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.
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.
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?
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.
Comments
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
EDIT: Never mind, I figured it out.
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.
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.
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
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:
Also, is it possible to remove effects from items? Would it be possible to remove MINHP1.itm's immunity to poison, for example?
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
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.
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.
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.
Does anyone have a function for adding a header to an item?
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
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?