Jump to content

WEIDU - items basic coding problems


ptifab

Recommended Posts

Here is a piece of code I use to make an op#12 (half damage) written for classic game compatible with EE:

COPY ~%MOD_FOLDER%/kits/Objets/GWFlePu.itm~    ~override/GWFlePu.itm~    SAY NAME1 @7729309    SAY NAME2 @7729309
    LPF ALTER_ITEM_HEADER INT_VAR projectile = (IDS_OF_SYMBOL (projectl GWFlePu) + 1) END    // 3-Arrow Exploding (ARROWEX) : Only Enemy
    PATCH_IF (GW_EE) BEGIN
        LPF DELETE_EFFECT INT_VAR multi_match = 1 match_opcode = 12 match_savingthrow = 0 END
        LPF ALTER_EFFECT INT_VAR match_opcode = 12 dicenumber = 4 special = 256 END
    END
BUT_ONLY

In classic games, you have 2 op#12 effects (one for each half damage).  LPF DELETE_EFFECT deletes op#12 dealing with save for half and LPF ALTER_EFFECT modifies the remaining op#12 to suit EE save for half coding: it doubles dicenumber parameter and adds BIT8 value at special offset (256).

 

Edited by Gwendolyne
Link to comment

Thanks @Gwendolyne ! i've already tried this parameter (special = 256) but it's for a cast spell opcode (146), and weidu juste write a 256 number instead of checking the flag at bit8.. i don't understand why. Is that a bug ?

here's my code

LPF ALTER_EFFECT INT_VAR match_opcode = 215 opcode = 146 target = 2 power = 3 timing = 1 duration = 0 savingthrow = 2 special = 256 STR_VAR resource = ~IUBURN2~ END

 

Edited by ptifab
Link to comment

Hi again.

 

I'm actually trying to replace some text into a dialogue. In 1 state (109), i want to change both the trigger and the action, but only some of the text not everything.

(here it is the dagg03 that i want to replace for a dagg15)

While this code works (in a .d file)


ALTER_TRANS ~THALAN~
BEGIN 109 END
BEGIN 1 END
BEGIN "ACTION" ~TakePartyGold(4000) DestroyGold(4000)
TakePartyItemNum("MISC75",1)  // Dagger of Venom +2
DestroyItem("MISC75")  // Dagger of Venom +2
TakePartyItemNum("dagg15",1)  // Heart of the Golem +2
DestroyItem("dagg15")  // Heart of the Golem +2
TakePartyItemNum("potn14",1)  // Potion of Speed
DestroyItem("potn14")  // Potion of Speed
TakePartyItemNum("potn32",1)  // Strange Potion of Antidote
DestroyItem("potn32")  // Strange Potion of Antidote
GiveItemCreate("thdagg01",Player1,1,1,1)  // Dagger of Venom +3
CreateVisualEffect("spcrtwpn",[330.230])~
END

ALTER_TRANS ~THALAN~
BEGIN 109 END
BEGIN 1 END
BEGIN "TRIGGER" ~PartyHasItem("MISC75")  // Dagger of Venom +2
PartyHasItem("dagg15")  // Heart of the Golem +2
PartyHasItem("potn14")  // Potion of Speed
PartyHasItem("potn32")  // Strange Potion of Antidote
PartyGoldGT(3999)~
END

but it changes everything, while i just want to edit the item (here it is the dagg03 for a dagg15)

But that code (in my .tpa) doesn't work at all

ACTION_IF (FILE_EXISTS_IN_GAME ~THALAN.DLG~) THEN BEGIN

<<<<<<<< items_rev_ultimate/inlined/thalan_ir_compatibility.d
REPLACE_TRANS_ACTION ~THALAN~ BEGIN 109 END BEGIN 1 END 
~TakePartyItemNum("dagg03",1)  // Heart of the Golem +2
DestroyItem("dagg03")  // Heart of the Golem +2~

~TakePartyItemNum("dagg15",1)  // Dagger +2
DestroyItem("dagg15")  // Dagger +2~

REPLACE_TRANS_TRIGGER ~THALAN~ BEGIN 109 END BEGIN 1 END
~PartyHasItem("dagg03")  // Heart of the Golem +2~ ~PartyHasItem("dagg15")  // Dagger +2)~
>>>>>>>>
COMPILE ~items_rev_ultimate/inlined/thalan_ir_compatibility.d~

END // END ACTION_IF

There is no error during the weidu installation. Did i missed something ?

Edited by ptifab
Link to comment

One of the things to be careful of in these situations is that editors like NI will show helpful comments which actually are not in the code, e.g.

TakePartyItemNum("dagg15",1)  // Dagger +2

likely isn't matching because it's actually just

TakePartyItemNum("dagg15",1)

in the code. If you find yourself struggling with text replacements in scripts or dialogues, it can sometimes be very useful to decompile the bcs/dlg at the command-line with WeiDU and check the output.

Link to comment

I'm trying to patch items by looking at a specific effect here it's opcode #101 with parameter 78 (disease)

i've tried this code :

COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ override PATCH_IF SOURCE_SIZE>0x71 BEGIN
READ_LONG  0x6a ef_off
READ_SHORT 0x70 ef_num
FOR (i=0;i<ef_num;++i) BEGIN
READ_SHORT ef_off+i*0x30 opcode
PATCH_IF opcode = 101 BEGIN // immunity to effect
READ_LONG ef_off+i*0x30+8 effect
PATCH_IF effect = 78 BEGIN // disease
LPF ADD_ITEM_EQEFFECT INT_VAR opcode = 142 target = 1 parameter2 = (icon_index - 3) timing = 2 END // add portrait icon
END
END
END
END // END REGEXP

It adds correctly the #opcode 142  but it's duplicated multiple times. i must have forget to limit the array but i don't know where to put that. If someone can help me on this one ?

Link to comment

Imagine this:

  • You look at effect 0. It's not a match, so the loop goes to the next effect.
  • You look at effect 1. It's a match, so you insert your new effect which, by default, gets added as effect 0. The loop moves on.
  • You look at effect 2, which thanks to the effect you just added, is actually effect 1 again. Since it's still a match, another effect gets added as effect 0.
  • You look at effect 3, which was previously effect 2, which was previously effect 1...

So, two suggestions: either add insert_point = 999 as an option, or simply use:

COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ override 
  CLONE_EFFECT INT_VAR silent = 1 match_opcode = 101 match_parameter2 = 108 opcode = 142 parameter2 = (icon_index - 3) END // add whatever else you need
  BUT_ONLY
Link to comment

Hi everyone,

 

i'd like to know the importance of the "Power" parameter in the EE engine ? i see that spells do have actually this parameter set (the level of the spell in general), but on some items some have and others don't, especially in mods. Is it important to set a level on this, and if yes how the game process it . Is it for resistances ?

Link to comment

When you see a spell say it makes you immune/blocks/absorbs spells of level X, what the engine is actually checking is the power field on an effect. A power level of 0 will bypass any such spell protections.

Generally, effects from weapons should use 0 and spells should use their level as their power level. Anti-magic spells will sometimes use 0 if they're supposed to bypass spell protections (e.g. Dispel Magic) and summoning spells generally use 0 so they don't fail if you target someone with the spell.

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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

×
×
  • Create New...