Jump to content

I Need a code patch please


deratiseur

Recommended Posts

Hello :) I need you again. Some scripts are too complex for me :/

 

I need a code to patch multiples files. it must include a settable ascii variable.

The code must add an #146 effect at the top of the effects (there is only on abilitie), with target "pre target", duration "permanent", non magical, no save.

The ascii varible is the spell to cast.

 

For exemple, i will use it in the tp2 like this :

Copy ~Derats_kits/spells/test.spl~ ~override~

SET PXW_NAME = "the variable" (name of spell to cast) PATCH_INCLUDE ~Derats_kits/Codes/"the code" (in an external file)~

 

 

Link to comment

There's a built-in WeiDU function to do this. ADD_SPELL_EFFECT.

 

COPY ~Derats_kits/spells/test.spl~ ~override~
  LPF ADD_SPELL_EFFECT
    INT_VAR
      opcode = 146          // cast spell at creature
      target = 2            // pre-target
      timing = 1            // permanent
      resist_dispel = 0     // non-magical
      parameter1 = 0        // casting level = level of creature
      parameter2 = 0        // type = non-instant casting
      insert_point = 0      // insert as the first effect
    STR_VAR
      resource = ~spellres~ // the spell to cast
  END
Link to comment

Thanks, that's work :)

I use it like this (your code is in an external file named Mkcode.cod) :

COPY_EXISTING    ~pxw1poix.spl~                ~override/pxw1poiv.spl~    SAY UNIDENTIFIED_DESC @71821    PATCH_INCLUDE ~Derats_kits/Codes/Mkcode.cod~    WRITE_ASCII 0xae ~pxw1poig~ #8

Thanks a lot :)

Link to comment

You don't want to be writing the name of your resource to a hardcoded position (0xae) after all that.

If you are going to be using this code in multiple places and you want to hide it away in a separate file, use this instead.

DEFINE_PATCH_FUNCTION ADD_SPELL_EFFECT_146
  STR_VAR resource = ~~
BEGIN
  LPF ADD_SPELL_EFFECT
    INT_VAR
      opcode = 146          // cast spell at creature
      target = 2            // pre-target
      timing = 1            // permanent
      resist_dispel = 0     // non-magical
      parameter1 = 0        // casting level = level of creature
      parameter2 = 0        // type = non-instant casting
      insert_point = 0      // insert as the first effect
    STR_VAR
      resource = EVAL ~%resource%~ // the spell to cast
  END
END


Then just INCLUDE that file once at the start of your component, and you can call the function wrapper wherever you want like so:

COPY_EXISTING ~pxw1poix.spl~ ~override~
  LPF ADD_SPELL_EFFECT_146 STR_VAR resource = ~pxw1poig~ END
Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...