Author Topic: Expanded ALTER_AREA_foo functions  (Read 1233 times)

Offline CamDawg

  • Infidel
  • Planewalker
  • *****
  • Posts: 859
  • Dreaming of a red Xmas
    • The Gibberlings Three
Expanded ALTER_AREA_foo functions
« on: December 14, 2015, 12:27:32 PM »
Another request is to broaden the scope of the ALTER_AREA_foo functions. The functions, along with additional documentation, follow. Any parameter defined with a non-default value will get updated to the specified value like the previous parameters. All parameters are INT_VARs unless otherwise specified.

ALTER_AREA_ENTRANCE - No changes.

ALTER_AREA_REGION now accepts the following parameters with these defaults:

  • bounding_left (-1), bounding_top (-1), bounding_right (-1), bounding_bottom (-1) - The bounding_ series affect the bounding box (0x22 through 0x29 in the trigger structure). Changes to actual vertices are not possible through this function.
  • info_point (99999999) - allows for the alteration of a string for info triggers (0x64)
  • launch_x (-1), launch_y (-1) - Allows for changing the launch point (0x70)
  • activate_x (-1), activate_y (-1) - Allows for changing the activation point (0x84)
Code: [Select]
DEFINE_PATCH_FUNCTION ALTER_AREA_REGION
  INT_VAR type        = "-1" // region type at 0x20; negative values mean no change
          cursor      = "-1" // cursor type at 0x34; negative values mean no change
          trap_detect = "-1" // difficulty of trap detection at 0x68; negative values mean no change
          trap_remove = "-1" // difficulty of trap removal at 0x6a; negative values mean no change
          trapped     = "-1" // is trapped? at 0x6c; negative values mean no change
          detected    = "-1" // is detected? at 0x6e; negative values mean no change
          // flag_ vars affect flags starting at 0x60; 0 means remove flag, 1 means add flag, -1 no change
          flag_locked           = "-1" // locked, bit0
          flag_resets           = "-1" // trap resets, bit1
          flag_party_required   = "-1" // party required, bit2
          flag_trap_detectable  = "-1" // trap can be detected, bit3
          flag_trap_enemies     = "-1" // trap can be set off by enemies, bit4
          flag_tutorial         = "-1" // tutorial trigger, bit5
          flag_trap_npcs        = "-1" // trap can be set off by npcs, bit6
          flag_silent           = "-1" // silent trigger, bit7
          flag_deactivated      = "-1" // deactivated, bit8
          flag_impassable_npc   = "-1" // can not be passed by npcs, bit9
          flag_activation_point = "-1" // use activation point, bit10
          flag_connect_to_door  = "-1" // connected to door, bit11
          // added
          bounding_left         = "-1"
          bounding_top          = "-1"
          bounding_right        = "-1"
          bounding_bottom       = "-1"
          info_point            = 99999999
          launch_x              = "-1"
          launch_y              = "-1"
          activate_x            = "-1"
          activate_y            = "-1"
  STR_VAR region_name = ""     // required, at 0x00, used to match region
          destination_area    = "same" // changes destination area at 0x38; "same" means no change
          entrance_name     = "same" // changes entrance name at 0x40; "same" means no change
          door_key     = "same" // resref of key to unlock at 0x74; "same" means no change
          door_script  = "same" // resref of region script at 0x7c; "same" means no change
BEGIN

  READ_SHORT 0x5a trig_num
  READ_LONG  0x5c trig_off
  FOR (index = 0 ; index < trig_num ; ++index) BEGIN
    READ_ASCII (trig_off + (index * 0xc4)) trig_name_file (32) NULL
    PATCH_IF ("%region_name%" STRING_COMPARE_CASE  "%trig_name_file%" = 0) BEGIN
      PATCH_IF (type >= 0)                 BEGIN WRITE_SHORT (trig_off + 0x20 + (index * 0xc4)) type        END
      PATCH_IF (cursor >= 0)               BEGIN WRITE_LONG  (trig_off + 0x34 + (index * 0xc4)) cursor      END
      PATCH_IF (trap_detect >= 0)          BEGIN WRITE_SHORT (trig_off + 0x68 + (index * 0xc4)) trap_detect END
      PATCH_IF (trap_remove >= 0)          BEGIN WRITE_SHORT (trig_off + 0x6a + (index * 0xc4)) trap_remove END
      PATCH_IF (trapped >= 0)              BEGIN WRITE_SHORT (trig_off + 0x6c + (index * 0xc4)) trapped     END
      PATCH_IF (detected >= 0)             BEGIN WRITE_SHORT (trig_off + 0x6e + (index * 0xc4)) detected    END
      PATCH_IF (flag_locked = 0)           BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BAND 0b11111110) END
      PATCH_IF (flag_resets = 0)           BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BAND 0b11111101) END
      PATCH_IF (flag_party_required = 0)   BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BAND 0b11111011) END
      PATCH_IF (flag_trap_detectable = 0)  BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BAND 0b11110111) END
      PATCH_IF (flag_trap_enemies = 0)     BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BAND 0b11101111) END
      PATCH_IF (flag_tutorial = 0)         BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BAND 0b11011111) END
      PATCH_IF (flag_trap_npcs = 0)        BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BAND 0b10111111) END
      PATCH_IF (flag_silent = 0)           BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BAND 0b01111111) END
      PATCH_IF (flag_deactivated = 0)      BEGIN WRITE_BYTE  (trig_off + 0x61 + (index * 0xc4)) (THIS BAND 0b11111110) END
      PATCH_IF (flag_impassable_npc = 0)   BEGIN WRITE_BYTE  (trig_off + 0x61 + (index * 0xc4)) (THIS BAND 0b11111101) END
      PATCH_IF (flag_activation_point = 0) BEGIN WRITE_BYTE  (trig_off + 0x61 + (index * 0xc4)) (THIS BAND 0b11111011) END
      PATCH_IF (flag_connect_to_door = 0)  BEGIN WRITE_BYTE  (trig_off + 0x61 + (index * 0xc4)) (THIS BAND 0b11110111) END
      PATCH_IF (flag_locked = 1)           BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BOR BIT0) END
      PATCH_IF (flag_resets = 1)           BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BOR BIT1) END
      PATCH_IF (flag_party_required = 1)   BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BOR BIT2) END
      PATCH_IF (flag_trap_detectable = 1)  BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BOR BIT3) END
      PATCH_IF (flag_trap_enemies = 1)     BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BOR BIT4) END
      PATCH_IF (flag_tutorial = 1)         BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BOR BIT5) END
      PATCH_IF (flag_trap_npcs = 1)        BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BOR BIT6) END
      PATCH_IF (flag_silent = 1)           BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BOR BIT7) END
      PATCH_IF (flag_deactivated = 1)      BEGIN WRITE_BYTE  (trig_off + 0x61 + (index * 0xc4)) (THIS BOR BIT0) END
      PATCH_IF (flag_impassable_npc = 1)   BEGIN WRITE_BYTE  (trig_off + 0x61 + (index * 0xc4)) (THIS BOR BIT1) END
      PATCH_IF (flag_activation_point = 1) BEGIN WRITE_BYTE  (trig_off + 0x61 + (index * 0xc4)) (THIS BOR BIT2) END
      PATCH_IF (flag_connect_to_door = 1)  BEGIN WRITE_BYTE  (trig_off + 0x61 + (index * 0xc4)) (THIS BOR BIT3) END
      PATCH_IF ("%destination_area%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (trig_off + 0x38 + (index * 0xc4)) "%destination_area%" #8
      END
      PATCH_IF ("%entrance_name%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (trig_off + 0x40 + (index * 0xc4)) "%entrance_name%" #32
      END
      PATCH_IF ("%door_key%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (trig_off + 0x74 + (index * 0xc4)) "%door_key%" #8
      END
      PATCH_IF ("%door_script%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (trig_off + 0x7c + (index * 0xc4)) "%door_script%" #8
      END
      // added
      PATCH_IF (bounding_left >= 0)     BEGIN WRITE_SHORT (trig_off + 0x22 + (index * 0xc4)) bounding_left   END
      PATCH_IF (bounding_top >= 0)      BEGIN WRITE_SHORT (trig_off + 0x24 + (index * 0xc4)) bounding_top    END
      PATCH_IF (bounding_right >= 0)    BEGIN WRITE_SHORT (trig_off + 0x26 + (index * 0xc4)) bounding_right  END
      PATCH_IF (bounding_bottom >= 0)   BEGIN WRITE_SHORT (trig_off + 0x28 + (index * 0xc4)) bounding_bottom END
      PATCH_IF (info_point != 99999999) BEGIN WRITE_LONG  (trig_off + 0x64 + (index * 0xc4)) info_point      END
      PATCH_IF (launch_x >= 0)          BEGIN WRITE_SHORT (trig_off + 0x70 + (index * 0xc4)) launch_x        END
      PATCH_IF (launch_y >= 0)          BEGIN WRITE_SHORT (trig_off + 0x72 + (index * 0xc4)) launch_y        END
      PATCH_IF (activate_x >= 0)        BEGIN WRITE_SHORT (trig_off + 0x84 + (index * 0xc4)) activate_x      END
      PATCH_IF (activate_y >= 0)        BEGIN WRITE_SHORT (trig_off + 0x86 + (index * 0xc4)) activate_y      END
    END
  END

END

ALTER_AREA_ACTOR now accepts the following parameters with these defaults:
  • dest_x (-1), dest_y (-1) - Allows for setting destination coordinates (0x24). The existing x_coord and y_coord parameters originally changed both the current and destination coordinates of an actor. For backwards compatibility, these will continue to do so unless separate destination coordinates are supplied with dest_x and dest_y.
  • spawned (-1) - Used to change the spawned field (0x2c)
  • animation (-1) - Used to change the defined animation (0x30)
  • expiry (-2) - Used to change the expiry time (0x38). Since -1 is a valid value, default here is -2.
  • wander (-1) - Used to change the wander field (0x3c)
  • follow (-1) - Used to change the follow field (0x3e)
  • times_talked (-1) - Used to change the number of times talked to field (0x44)
  • flag_cre_unattached (-1), flag_seen_party (-1), flag_invuln (-1), flag_override_dv (-1) - Controls the unattached, seen party, invulnerable, and override script name  flags at 0x28. Values of zero clear the flag and one set it. Other values are ignored.
  • flag_time_0 (-1), flag_time_1 (-1), ... flag_time_23 (-1) - Controls the actor's appearance time flags at 0x40. Each flag can be cleared with a zero value or set with a one value. Other values are ignored.
Code: [Select]
DEFINE_PATCH_FUNCTION ALTER_AREA_ACTOR
  INT_VAR x_coord = "-1" // new x coordinate at 0x20 and 0x24; negative values mean no change
          y_coord = "-1" // new y coordinate at 0x22 and 0x26; negative values mean no change
          orient  = "-1" // facing direction for actor at 0x34; negative values mean no change
          //added
          dest_x       = "-1"
          dest_y       = "-1"
          spawned      = "-1"
          animation    = "-1"
          expiry       = "-2"
          wander       = "-1"
          follow       = "-1"
          times_talked = "-1"
          // added flags
          flag_cre_unattached = "-1"
          flag_seen_party     = "-1"
          flag_invuln         = "-1"
          flag_override_dv    = "-1"
          flag_time_0         = "-1"
          flag_time_1         = "-1"
          flag_time_2         = "-1"
          flag_time_3         = "-1"
          flag_time_4         = "-1"
          flag_time_5         = "-1"
          flag_time_6         = "-1"
          flag_time_7         = "-1"
          flag_time_8         = "-1"
          flag_time_9         = "-1"
          flag_time_10        = "-1"
          flag_time_11        = "-1"
          flag_time_12        = "-1"
          flag_time_13        = "-1"
          flag_time_14        = "-1"
          flag_time_15        = "-1"
          flag_time_16        = "-1"
          flag_time_17        = "-1"
          flag_time_18        = "-1"
          flag_time_19        = "-1"
          flag_time_20        = "-1"
          flag_time_21        = "-1"
          flag_time_22        = "-1"
          flag_time_23        = "-1"

  STR_VAR actor_name       = ""     // required, at 0x00, used to match actor
          dlg_file         = "same" // changes dialog file at 0x48; "same" means no change
          script_override  = "same" // changes override script at 0x50; "same" means no change
          script_general   = "same" // changes general script at 0x58; "same" means no change
          script_class     = "same" // changes class script at 0x60; "same" means no change
          script_race      = "same" // changes race script at 0x68; "same" means no change
          script_default   = "same" // changes default script at 0x70; "same" means no change
          script_specifics = "same" // changes specifics script at 0x78; "same" means no change
          cre_file         = "same" // changes creature file at 0x80; "same" means no change
BEGIN

  READ_LONG  0x54 cre_off
  READ_SHORT 0x58 cre_num
  FOR (index = 0 ; index < cre_num ; ++index) BEGIN
    READ_ASCII (cre_off + (index * 0x110)) actor_name_file (32) NULL
    PATCH_IF ("%actor_name%" STRING_COMPARE_CASE "%actor_name_file%" = 0) BEGIN
      PATCH_IF (x_coord >= 0) BEGIN
        WRITE_SHORT (cre_off + 0x20 + (index * 0x110)) x_coord
        PATCH_IF (dest_x < 0) BEGIN
          WRITE_SHORT (cre_off + 0x24 + (index * 0x110)) x_coord
        END
      END
      PATCH_IF (y_coord >= 0) BEGIN
        WRITE_SHORT (cre_off + 0x22 + (index * 0x110)) y_coord
        PATCH_IF (dest_y < 0) BEGIN
          WRITE_SHORT (cre_off + 0x26 + (index * 0x110)) y_coord
        END
      END
      PATCH_IF (orient >= 0)  BEGIN WRITE_SHORT (cre_off + 0x34 + (index * 0x110)) orient END
      PATCH_IF ("%dlg_file%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (cre_off + 0x48 + (index * 0x110)) "%dlg_file%" #8
      END
      PATCH_IF ("%script_override%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (cre_off + 0x50 + (index * 0x110)) "%script_override%" #8
      END
      PATCH_IF ("%script_general%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (cre_off + 0x58 + (index * 0x110)) "%script_general%" #8
      END
      PATCH_IF ("%script_race%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (cre_off + 0x68 + (index * 0x110)) "%script_race%" #8
      END
      PATCH_IF ("%script_default%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (cre_off + 0x70 + (index * 0x110)) "%script_default%" #8
      END
      PATCH_IF ("%script_class%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (cre_off + 0x60 + (index * 0x110)) "%script_class%" #8
      END
      PATCH_IF ("%script_specifics%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (cre_off + 0x78 + (index * 0x110)) "%script_specifics%" #8
      END
      PATCH_IF ("%cre_file%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (cre_off + 0x80 + (index * 0x110)) "%cre_file%" #8
      END
      // added
      PATCH_IF (dest_x >= 0)       BEGIN WRITE_SHORT (cre_off + 0x24 + (index * 0x110)) dest_x       END
      PATCH_IF (dest_y >= 0)       BEGIN WRITE_SHORT (cre_off + 0x26 + (index * 0x110)) dest_y       END
      PATCH_IF (spawned >= 0)      BEGIN WRITE_SHORT (cre_off + 0x2c + (index * 0x110)) spawned      END
      PATCH_IF (animation >= 0)    BEGIN WRITE_LONG  (cre_off + 0x30 + (index * 0x110)) animation    END
      PATCH_IF (expiry >= "-1")    BEGIN WRITE_LONG  (cre_off + 0x38 + (index * 0x110)) expiry       END
      PATCH_IF (wander >= 0)       BEGIN WRITE_SHORT (cre_off + 0x3c + (index * 0x110)) wander       END
      PATCH_IF (follow >= 0)       BEGIN WRITE_SHORT (cre_off + 0x3e + (index * 0x110)) follow       END
      PATCH_IF (times_talked >= 0) BEGIN WRITE_LONG  (cre_off + 0x44 + (index * 0x110)) times_talked END
      // added flags
      PATCH_IF (flag_cre_unattached = 0) BEGIN WRITE_BYTE  (cre_off + 0x28 + (index * 0x110)) (THIS & `BIT0) END
      PATCH_IF (flag_cre_unattached = 1) BEGIN WRITE_BYTE  (cre_off + 0x28 + (index * 0x110)) (THIS BOR BIT0) END
      PATCH_IF (flag_seen_party = 0)     BEGIN WRITE_BYTE  (cre_off + 0x28 + (index * 0x110)) (THIS & `BIT1) END
      PATCH_IF (flag_seen_party = 1)     BEGIN WRITE_BYTE  (cre_off + 0x28 + (index * 0x110)) (THIS BOR BIT1) END
      PATCH_IF (flag_invuln = 0)         BEGIN WRITE_BYTE  (cre_off + 0x28 + (index * 0x110)) (THIS & `BIT2) END
      PATCH_IF (flag_invuln = 1)         BEGIN WRITE_BYTE  (cre_off + 0x28 + (index * 0x110)) (THIS BOR BIT2) END
      PATCH_IF (flag_override_dv = 0)    BEGIN WRITE_BYTE  (cre_off + 0x28 + (index * 0x110)) (THIS & `BIT3) END
      PATCH_IF (flag_override_dv = 1)    BEGIN WRITE_BYTE  (cre_off + 0x28 + (index * 0x110)) (THIS BOR BIT3) END
      PATCH_IF (flag_time_0 = 0)  BEGIN WRITE_BYTE  (cre_off + 0x40 + (index * 0x110)) (THIS & `BIT0) END
      PATCH_IF (flag_time_0 = 1)  BEGIN WRITE_BYTE  (cre_off + 0x40 + (index * 0x110)) (THIS BOR BIT0) END
      PATCH_IF (flag_time_1 = 0)  BEGIN WRITE_BYTE  (cre_off + 0x40 + (index * 0x110)) (THIS & `BIT1) END
      PATCH_IF (flag_time_1 = 1)  BEGIN WRITE_BYTE  (cre_off + 0x40 + (index * 0x110)) (THIS BOR BIT1) END
      PATCH_IF (flag_time_2 = 0)  BEGIN WRITE_BYTE  (cre_off + 0x40 + (index * 0x110)) (THIS & `BIT2) END
      PATCH_IF (flag_time_2 = 1)  BEGIN WRITE_BYTE  (cre_off + 0x40 + (index * 0x110)) (THIS BOR BIT2) END
      PATCH_IF (flag_time_3 = 0)  BEGIN WRITE_BYTE  (cre_off + 0x40 + (index * 0x110)) (THIS & `BIT3) END
      PATCH_IF (flag_time_3 = 1)  BEGIN WRITE_BYTE  (cre_off + 0x40 + (index * 0x110)) (THIS BOR BIT3) END
      PATCH_IF (flag_time_4 = 0)  BEGIN WRITE_BYTE  (cre_off + 0x40 + (index * 0x110)) (THIS & `BIT4) END
      PATCH_IF (flag_time_4 = 1)  BEGIN WRITE_BYTE  (cre_off + 0x40 + (index * 0x110)) (THIS BOR BIT4) END
      PATCH_IF (flag_time_5 = 0)  BEGIN WRITE_BYTE  (cre_off + 0x40 + (index * 0x110)) (THIS & `BIT5) END
      PATCH_IF (flag_time_5 = 1)  BEGIN WRITE_BYTE  (cre_off + 0x40 + (index * 0x110)) (THIS BOR BIT5) END
      PATCH_IF (flag_time_6 = 0)  BEGIN WRITE_BYTE  (cre_off + 0x40 + (index * 0x110)) (THIS & `BIT6) END
      PATCH_IF (flag_time_6 = 1)  BEGIN WRITE_BYTE  (cre_off + 0x40 + (index * 0x110)) (THIS BOR BIT6) END
      PATCH_IF (flag_time_7 = 0)  BEGIN WRITE_BYTE  (cre_off + 0x40 + (index * 0x110)) (THIS & `BIT7) END
      PATCH_IF (flag_time_7 = 1)  BEGIN WRITE_BYTE  (cre_off + 0x40 + (index * 0x110)) (THIS BOR BIT7) END
      PATCH_IF (flag_time_8 = 0)  BEGIN WRITE_BYTE  (cre_off + 0x41 + (index * 0x110)) (THIS & `BIT0) END
      PATCH_IF (flag_time_8 = 1)  BEGIN WRITE_BYTE  (cre_off + 0x41 + (index * 0x110)) (THIS BOR BIT0) END
      PATCH_IF (flag_time_9 = 0)  BEGIN WRITE_BYTE  (cre_off + 0x41 + (index * 0x110)) (THIS & `BIT1) END
      PATCH_IF (flag_time_9 = 1)  BEGIN WRITE_BYTE  (cre_off + 0x41 + (index * 0x110)) (THIS BOR BIT1) END
      PATCH_IF (flag_time_10 = 0) BEGIN WRITE_BYTE  (cre_off + 0x41 + (index * 0x110)) (THIS & `BIT2) END
      PATCH_IF (flag_time_10 = 1) BEGIN WRITE_BYTE  (cre_off + 0x41 + (index * 0x110)) (THIS BOR BIT2) END
      PATCH_IF (flag_time_11 = 0) BEGIN WRITE_BYTE  (cre_off + 0x41 + (index * 0x110)) (THIS & `BIT3) END
      PATCH_IF (flag_time_11 = 1) BEGIN WRITE_BYTE  (cre_off + 0x41 + (index * 0x110)) (THIS BOR BIT3) END
      PATCH_IF (flag_time_12 = 0) BEGIN WRITE_BYTE  (cre_off + 0x41 + (index * 0x110)) (THIS & `BIT4) END
      PATCH_IF (flag_time_12 = 1) BEGIN WRITE_BYTE  (cre_off + 0x41 + (index * 0x110)) (THIS BOR BIT4) END
      PATCH_IF (flag_time_13 = 0) BEGIN WRITE_BYTE  (cre_off + 0x41 + (index * 0x110)) (THIS & `BIT5) END
      PATCH_IF (flag_time_13 = 1) BEGIN WRITE_BYTE  (cre_off + 0x41 + (index * 0x110)) (THIS BOR BIT5) END
      PATCH_IF (flag_time_14 = 0) BEGIN WRITE_BYTE  (cre_off + 0x41 + (index * 0x110)) (THIS & `BIT6) END
      PATCH_IF (flag_time_14 = 1) BEGIN WRITE_BYTE  (cre_off + 0x41 + (index * 0x110)) (THIS BOR BIT6) END
      PATCH_IF (flag_time_15 = 0) BEGIN WRITE_BYTE  (cre_off + 0x41 + (index * 0x110)) (THIS & `BIT7) END
      PATCH_IF (flag_time_15 = 1) BEGIN WRITE_BYTE  (cre_off + 0x41 + (index * 0x110)) (THIS BOR BIT7) END
      PATCH_IF (flag_time_16 = 0) BEGIN WRITE_BYTE  (cre_off + 0x42 + (index * 0x110)) (THIS & `BIT0) END
      PATCH_IF (flag_time_16 = 1) BEGIN WRITE_BYTE  (cre_off + 0x42 + (index * 0x110)) (THIS BOR BIT0) END
      PATCH_IF (flag_time_17 = 0) BEGIN WRITE_BYTE  (cre_off + 0x42 + (index * 0x110)) (THIS & `BIT1) END
      PATCH_IF (flag_time_17 = 1) BEGIN WRITE_BYTE  (cre_off + 0x42 + (index * 0x110)) (THIS BOR BIT1) END
      PATCH_IF (flag_time_18 = 0) BEGIN WRITE_BYTE  (cre_off + 0x42 + (index * 0x110)) (THIS & `BIT2) END
      PATCH_IF (flag_time_18 = 1) BEGIN WRITE_BYTE  (cre_off + 0x42 + (index * 0x110)) (THIS BOR BIT2) END
      PATCH_IF (flag_time_19 = 0) BEGIN WRITE_BYTE  (cre_off + 0x42 + (index * 0x110)) (THIS & `BIT3) END
      PATCH_IF (flag_time_19 = 1) BEGIN WRITE_BYTE  (cre_off + 0x42 + (index * 0x110)) (THIS BOR BIT3) END
      PATCH_IF (flag_time_20 = 0) BEGIN WRITE_BYTE  (cre_off + 0x42 + (index * 0x110)) (THIS & `BIT4) END
      PATCH_IF (flag_time_20 = 1) BEGIN WRITE_BYTE  (cre_off + 0x42 + (index * 0x110)) (THIS BOR BIT4) END
      PATCH_IF (flag_time_21 = 0) BEGIN WRITE_BYTE  (cre_off + 0x42 + (index * 0x110)) (THIS & `BIT5) END
      PATCH_IF (flag_time_21 = 1) BEGIN WRITE_BYTE  (cre_off + 0x42 + (index * 0x110)) (THIS BOR BIT5) END
      PATCH_IF (flag_time_22 = 0) BEGIN WRITE_BYTE  (cre_off + 0x42 + (index * 0x110)) (THIS & `BIT6) END
      PATCH_IF (flag_time_22 = 1) BEGIN WRITE_BYTE  (cre_off + 0x42 + (index * 0x110)) (THIS BOR BIT6) END
      PATCH_IF (flag_time_23 = 0) BEGIN WRITE_BYTE  (cre_off + 0x42 + (index * 0x110)) (THIS & `BIT7) END
      PATCH_IF (flag_time_23 = 1) BEGIN WRITE_BYTE  (cre_off + 0x42 + (index * 0x110)) (THIS BOR BIT7) END
    END
  END

END

ALTER_AREA_CONTAINER now accepts the following parameters with these defaults:

  • coord_x (-1), coord_y (-1) - Sets new coordinates for the container (0x20).
  • launch_x (-1), launch_y (-1) - Sets new launch point coordinates (0x34).
  • bounding_left (-1), bounding_top (-1), bounding_right (-1), bounding_bottom (-1) - Can be used to adjust the bounding box (0x38)
  • range (-1) - Adjusts the range (0x56)
  • lockpick_string (99999999) - Allows custom failed lockpick string.
Code: [Select]
DEFINE_PATCH_FUNCTION ALTER_AREA_CONTAINER
  INT_VAR container_type  = "-1" // container type; icon displayed when opened at 0x24; negative values mean no change
          trapped         = "-1" // is trapped? at 0x30; negative values mean no change
          detected        = "-1" // is detected? at 0x32; negative values mean no change
          lockpick_strref = "-1" // lockpick string at 0x84; negative values mean no change
          lock_difficulty = "-1" // difficulty to pick lock at 0x26; negative values mean no change
          trap_detect     = "-1" // difficulty to detect trap at 0x2c; negative values mean no change
          trap_remove     = "-1" // difficulty to remove tap at 0x2e; negative values mean no change
          // flag_ vars affect flags starting at 0x28; 0 means remove flag, 1 means add flag, -1 no change
          flag_locked     = "-1" // locked, bit0
          flag_mlocked    = "-1" // magical lock, bit2
          flag_resets     = "-1" // trap resets, bit3
          flag_disabled   = "-1" // disabled, bit5
          // added
          coord_x         = "-1"
          coord_y         = "-1"
          launch_x        = "-1"
          launch_y        = "-1"
          bounding_left   = "-1"
          bounding_top    = "-1"
          bounding_right  = "-1"
          bounding_bottom = "-1"
          range           = "-1"
          lockpick_string = 99999999
  STR_VAR container_name  = ""   // required, at 0x00, used to match container
          container_script = "same" // changes container script at 0x48; "same" means no change
          container_key    = "same" // changes container key 0x78; "same" means no change
BEGIN

  READ_LONG  0x70 cont_off
  READ_SHORT 0x74 cont_num
  FOR (index = 0 ; index < cont_num ; ++index) BEGIN
    READ_ASCII (cont_off + (index * 0xc0)) cont_name_file (32) NULL
    PATCH_IF ("%container_name%" STRING_COMPARE_CASE "%cont_name_file%" = 0) BEGIN
      PATCH_IF (container_type  >= 0) BEGIN WRITE_SHORT (cont_off + 0x24 + (index * 0xc0)) container_type  END
      PATCH_IF (lock_difficulty >= 0) BEGIN WRITE_SHORT (cont_off + 0x26 + (index * 0xc0)) lock_difficulty END
      PATCH_IF (trap_detect     >= 0) BEGIN WRITE_SHORT (cont_off + 0x2c + (index * 0xc0)) trap_detect     END
      PATCH_IF (trap_remove     >= 0) BEGIN WRITE_SHORT (cont_off + 0x2e + (index * 0xc0)) trap_remove     END
      PATCH_IF (trapped         >= 0) BEGIN WRITE_SHORT (cont_off + 0x30 + (index * 0xc0)) trapped         END
      PATCH_IF (detected        >= 0) BEGIN WRITE_SHORT (cont_off + 0x32 + (index * 0xc0)) detected        END
      PATCH_IF (lockpick_strref >= 0) BEGIN WRITE_LONG  (cont_off + 0x84 + (index * 0xc0)) lockpick_strref END

      PATCH_IF (flag_locked   = 0) BEGIN WRITE_BYTE  (cont_off + 0x28 + (index * 0xc0)) THIS & `BIT0 END
      PATCH_IF (flag_mlocked  = 0) BEGIN WRITE_BYTE  (cont_off + 0x28 + (index * 0xc0)) THIS & `BIT2 END
      PATCH_IF (flag_resets   = 0) BEGIN WRITE_BYTE  (cont_off + 0x28 + (index * 0xc0)) THIS & `BIT3 END
      PATCH_IF (flag_disabled = 0) BEGIN WRITE_BYTE  (cont_off + 0x28 + (index * 0xc0)) THIS & `BIT5 END
      PATCH_IF (flag_locked   = 1) BEGIN WRITE_BYTE  (cont_off + 0x28 + (index * 0xc0)) THIS | BIT0  END
      PATCH_IF (flag_mlocked  = 1) BEGIN WRITE_BYTE  (cont_off + 0x28 + (index * 0xc0)) THIS | BIT2  END
      PATCH_IF (flag_resets   = 1) BEGIN WRITE_BYTE  (cont_off + 0x28 + (index * 0xc0)) THIS | BIT3  END
      PATCH_IF (flag_disabled = 1) BEGIN WRITE_BYTE  (cont_off + 0x28 + (index * 0xc0)) THIS | BIT5  END

      PATCH_IF ("%container_script%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (cont_off + 0x48 + (index * 0xc0)) "%container_script%" #8
      END
      PATCH_IF ("%container_key%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (cont_off + 0x78 + (index * 0xc0)) "%container_key%" #8
      END

      // added
      PATCH_IF (coord_x  >= 0)                BEGIN WRITE_SHORT (cont_off + 0x20 + (index * 0xc0)) coord_x         END
      PATCH_IF (coord_y  >= 0)                BEGIN WRITE_SHORT (cont_off + 0x22 + (index * 0xc0)) coord_y         END
      PATCH_IF (launch_x  >= 0)               BEGIN WRITE_SHORT (cont_off + 0x34 + (index * 0xc0)) launch_x        END
      PATCH_IF (launch_y  >= 0)               BEGIN WRITE_SHORT (cont_off + 0x36 + (index * 0xc0)) launch_y        END
      PATCH_IF (bounding_left  >= 0)          BEGIN WRITE_SHORT (cont_off + 0x38 + (index * 0xc0)) bounding_left   END
      PATCH_IF (bounding_top  >= 0)           BEGIN WRITE_SHORT (cont_off + 0x3a + (index * 0xc0)) bounding_top    END
      PATCH_IF (bounding_right  >= 0)         BEGIN WRITE_SHORT (cont_off + 0x3c + (index * 0xc0)) bounding_right  END
      PATCH_IF (bounding_bottom  >= 0)        BEGIN WRITE_SHORT (cont_off + 0x3e + (index * 0xc0)) bounding_bottom END
      PATCH_IF (range  >= 0)                  BEGIN WRITE_SHORT (cont_off + 0x56 + (index * 0xc0)) range           END
      PATCH_IF (lockpick_string  != 99999999) BEGIN WRITE_LONG  (cont_off + 0x84 + (index * 0xc0)) lockpick_string END
    END
  END

END

ALTER_AREA_DOOR now accepts the following parameters with these defaults:

  • flag_open (-1), flag_locked (-1), flag_resets (-1), flag_detectable (-1), flag_forced (-1), flag_no_close (-1), flag_located (-1), flag_secret (-1), flag_detected (-1), flag_no_look (-1), flag_uses_key (-1), flag_sliding (-1) - Controls the door flags (0x28). Values of zero clear the flag, one set the flag, and other values are ignored.
  • bounding_o_left (-1), bounding_o_top (-1), bounding_o_right (-1), bounding_o_bottom (-1), bounding_c_left (-1), bounding_c_top (-1), bounding_c_right (-1), bounding_c_bottom (-1) - The bounding_o series controls the bounding box of the open door and bounding_c the closed door (0x38). 
  • door_hp (-1) - Sets the door's hit points (0x54).
  • door_ac (-1) - Sets the door's armor class (0x56).
  • launch_x (-1), launch_y (-1) - Adjusts the launch point (0x74)
  • open_x (-1), open_y (-1), close_x (-1), close_y (-1) - Adjusts the open and closed coordinates (0x90)
  • string_unlock (99999999) - Sets a custom unlock string (0x98).
  • string_speaker (99999999) - Sets a custom speaker name (0xb4)
  • STR_VAR door_open_snd (same), door_close_snd (same) - Changes the door opening and closing sounds (0x58).
  • STR_VAR travel_trigger (same) - Changes the travel trigger name. This ASCII field is 24 bytes in length, not the usual 8. (0x9c)
  • STR_VAR dialogue (same) - Changes the dialogue file (0xb8)
Code: [Select]
DEFINE_PATCH_FUNCTION ALTER_AREA_DOOR
  INT_VAR cursor          = "-1" // changes cursor at 0x68; negative values mean no change
          trap_detect     = "-1" // difficulty of trap detection at 0x6c; negative values mean no change
          trap_remove     = "-1" // difficulty of trap removal at 0x6e; negative values mean no change
          trapped         = "-1" // is trapped? at 0x70; negative values mean no change
          detected        = "-1" // is detected? at 0x72; negative values mean no change
          door_detect     = "-1" // difficulty of detection at 0x88; negative values mean no change
          lock_difficulty = "-1" // difficulty of lock at 0x8c; negative values mean no change
          // added
          flag_open         = "-1"
          flag_locked       = "-1"
          flag_resets       = "-1"
          flag_detectable   = "-1"
          flag_forced       = "-1"
          flag_no_close     = "-1"
          flag_located      = "-1"
          flag_secret       = "-1"
          flag_detected     = "-1"
          flag_no_look      = "-1"
          flag_uses_key     = "-1"
          flag_sliding      = "-1"
          bounding_o_left   = "-1"
          bounding_o_top    = "-1"
          bounding_o_right  = "-1"
          bounding_o_bottom = "-1"
          bounding_c_left   = "-1"
          bounding_c_top    = "-1"
          bounding_c_right  = "-1"
          bounding_c_bottom = "-1"
          door_hp           = "-1"
          door_ac           = "-1"
          launch_x          = "-1"
          launch_y          = "-1"
          open_x            = "-1"
          open_y            = "-1"
          close_x           = "-1"
          close_y           = "-1"
          string_unlock     = 99999999
          string_speaker    = 99999999

  STR_VAR door_name   = ""     // required, at 0x00, used to match door
          door_key    = "same" // changes door key at 0x78; "same" means no change
          door_script = "same" // changes door script at 0x80; "same" means no change; "same" means no change
          // added
          door_open_snd  = "same"
          door_close_snd = "same"
          travel_trigger = "same"
          dialogue       = "same"
BEGIN

  READ_LONG 0xa4 door_num
  READ_LONG 0xa8 door_off
  FOR (index = 0 ; index < door_num ; ++index) BEGIN
    READ_ASCII (door_off + (index * 0xc8)) door_name_file (32) NULL
    PATCH_IF ("%door_name%" STRING_COMPARE_CASE "%door_name_file%" = 0) BEGIN
      PATCH_IF (cursor          >= 0) BEGIN WRITE_LONG  (door_off + 0x68 + (index * 0xc8)) cursor          END
      PATCH_IF (trap_detect     >= 0) BEGIN WRITE_SHORT (door_off + 0x6c + (index * 0xc8)) trap_detect     END
      PATCH_IF (trap_remove     >= 0) BEGIN WRITE_SHORT (door_off + 0x6e + (index * 0xc8)) trap_remove     END
      PATCH_IF (trapped         >= 0) BEGIN WRITE_SHORT (door_off + 0x70 + (index * 0xc8)) trapped         END
      PATCH_IF (detected        >= 0) BEGIN WRITE_SHORT (door_off + 0x72 + (index * 0xc8)) detected        END
      PATCH_IF (door_detect     >= 0) BEGIN WRITE_LONG  (door_off + 0x88 + (index * 0xc8)) door_detect     END
      PATCH_IF (lock_difficulty >= 0) BEGIN WRITE_LONG  (door_off + 0x8c + (index * 0xc8)) lock_difficulty END

      PATCH_IF ("%door_key%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (door_off + 0x78 + (index * 0xc8)) "%door_key%" #8
      END
      PATCH_IF ("%door_script%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (door_off + 0x80 + (index * 0xc8)) "%door_script%" #8
      END
     
      // added
      PATCH_IF (flag_open       = 0) BEGIN WRITE_BYTE  (door_off + 0x28 + (index * 0xc8)) THIS & `BIT0 END
      PATCH_IF (flag_open       = 1) BEGIN WRITE_BYTE  (door_off + 0x28 + (index * 0xc8)) THIS |  BIT0 END
      PATCH_IF (flag_locked     = 0) BEGIN WRITE_BYTE  (door_off + 0x28 + (index * 0xc8)) THIS & `BIT1 END
      PATCH_IF (flag_locked     = 1) BEGIN WRITE_BYTE  (door_off + 0x28 + (index * 0xc8)) THIS |  BIT1 END
      PATCH_IF (flag_resets     = 0) BEGIN WRITE_BYTE  (door_off + 0x28 + (index * 0xc8)) THIS & `BIT2 END
      PATCH_IF (flag_resets     = 1) BEGIN WRITE_BYTE  (door_off + 0x28 + (index * 0xc8)) THIS |  BIT2 END
      PATCH_IF (flag_detectable = 0) BEGIN WRITE_BYTE  (door_off + 0x28 + (index * 0xc8)) THIS & `BIT3 END
      PATCH_IF (flag_detectable = 1) BEGIN WRITE_BYTE  (door_off + 0x28 + (index * 0xc8)) THIS |  BIT3 END
      PATCH_IF (flag_forced     = 0) BEGIN WRITE_BYTE  (door_off + 0x28 + (index * 0xc8)) THIS & `BIT4 END
      PATCH_IF (flag_forced     = 1) BEGIN WRITE_BYTE  (door_off + 0x28 + (index * 0xc8)) THIS |  BIT4 END
      PATCH_IF (flag_no_close   = 0) BEGIN WRITE_BYTE  (door_off + 0x28 + (index * 0xc8)) THIS & `BIT5 END
      PATCH_IF (flag_no_close   = 1) BEGIN WRITE_BYTE  (door_off + 0x28 + (index * 0xc8)) THIS |  BIT5 END
      PATCH_IF (flag_located    = 0) BEGIN WRITE_BYTE  (door_off + 0x28 + (index * 0xc8)) THIS & `BIT6 END
      PATCH_IF (flag_located    = 1) BEGIN WRITE_BYTE  (door_off + 0x28 + (index * 0xc8)) THIS |  BIT6 END
      PATCH_IF (flag_secret     = 0) BEGIN WRITE_BYTE  (door_off + 0x28 + (index * 0xc8)) THIS & `BIT7 END
      PATCH_IF (flag_secret     = 1) BEGIN WRITE_BYTE  (door_off + 0x28 + (index * 0xc8)) THIS |  BIT7 END
      PATCH_IF (flag_detected   = 0) BEGIN WRITE_BYTE  (door_off + 0x29 + (index * 0xc8)) THIS & `BIT0 END
      PATCH_IF (flag_detected   = 1) BEGIN WRITE_BYTE  (door_off + 0x29 + (index * 0xc8)) THIS |  BIT0 END
      PATCH_IF (flag_no_look    = 0) BEGIN WRITE_BYTE  (door_off + 0x29 + (index * 0xc8)) THIS & `BIT1 END
      PATCH_IF (flag_no_look    = 1) BEGIN WRITE_BYTE  (door_off + 0x29 + (index * 0xc8)) THIS |  BIT1 END
      PATCH_IF (flag_uses_key   = 0) BEGIN WRITE_BYTE  (door_off + 0x29 + (index * 0xc8)) THIS & `BIT2 END
      PATCH_IF (flag_uses_key   = 1) BEGIN WRITE_BYTE  (door_off + 0x29 + (index * 0xc8)) THIS |  BIT2 END
      PATCH_IF (flag_sliding    = 0) BEGIN WRITE_BYTE  (door_off + 0x29 + (index * 0xc8)) THIS & `BIT3 END
      PATCH_IF (flag_sliding    = 1) BEGIN WRITE_BYTE  (door_off + 0x29 + (index * 0xc8)) THIS |  BIT3 END

      PATCH_IF (bounding_o_left       >= 0) BEGIN WRITE_SHORT (door_off + 0x38 + (index * 0xc8)) bounding_o_left   END
      PATCH_IF (bounding_o_top        >= 0) BEGIN WRITE_SHORT (door_off + 0x3a + (index * 0xc8)) bounding_o_top    END
      PATCH_IF (bounding_o_right      >= 0) BEGIN WRITE_SHORT (door_off + 0x3c + (index * 0xc8)) bounding_o_right  END
      PATCH_IF (bounding_o_bottom     >= 0) BEGIN WRITE_SHORT (door_off + 0x3e + (index * 0xc8)) bounding_o_bottom END
      PATCH_IF (bounding_c_left       >= 0) BEGIN WRITE_SHORT (door_off + 0x40 + (index * 0xc8)) bounding_c_left   END
      PATCH_IF (bounding_c_top        >= 0) BEGIN WRITE_SHORT (door_off + 0x42 + (index * 0xc8)) bounding_c_top    END
      PATCH_IF (bounding_c_right      >= 0) BEGIN WRITE_SHORT (door_off + 0x44 + (index * 0xc8)) bounding_c_right  END
      PATCH_IF (bounding_c_bottom     >= 0) BEGIN WRITE_SHORT (door_off + 0x46 + (index * 0xc8)) bounding_c_bottom END
      PATCH_IF (door_hp               >= 0) BEGIN WRITE_SHORT (door_off + 0x54 + (index * 0xc8)) door_hp           END
      PATCH_IF (door_ac               >= 0) BEGIN WRITE_SHORT (door_off + 0x56 + (index * 0xc8)) door_ac           END
      PATCH_IF (launch_x              >= 0) BEGIN WRITE_SHORT (door_off + 0x74 + (index * 0xc8)) launch_x          END
      PATCH_IF (launch_y              >= 0) BEGIN WRITE_SHORT (door_off + 0x76 + (index * 0xc8)) launch_y          END
      PATCH_IF (open_x                >= 0) BEGIN WRITE_SHORT (door_off + 0x90 + (index * 0xc8)) open_x            END
      PATCH_IF (open_y                >= 0) BEGIN WRITE_SHORT (door_off + 0x92 + (index * 0xc8)) open_y            END
      PATCH_IF (close_x               >= 0) BEGIN WRITE_SHORT (door_off + 0x94 + (index * 0xc8)) close_x           END
      PATCH_IF (close_y               >= 0) BEGIN WRITE_SHORT (door_off + 0x96 + (index * 0xc8)) close_y           END
      PATCH_IF (string_unlock  != 99999999) BEGIN WRITE_LONG  (door_off + 0x98 + (index * 0xc8)) string_unlock     END
      PATCH_IF (string_speaker != 99999999) BEGIN WRITE_LONG  (door_off + 0xb4 + (index * 0xc8)) string_speaker    END

      PATCH_IF ("%door_open_snd%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (door_off + 0x58 + (index * 0xc8)) "%door_open_snd%" #8
      END
      PATCH_IF ("%door_close_snd%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (door_off + 0x60 + (index * 0xc8)) "%door_close_snd%" #8
      END
      PATCH_IF ("%travel_trigger%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (door_off + 0x9c + (index * 0xc8)) "%travel_trigger%" #24
      END
      PATCH_IF ("%dialogue%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (door_off + 0xb8 + (index * 0xc8)) "%dialogue%" #8
      END
    END
  END

END
The Gibberlings Three - Home of IE Mods

The BG2 Fixpack - All the fixes of Baldurdash, plus a few hundred more. Now available, with more fixes being added in every release.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: Expanded ALTER_AREA_foo functions
« Reply #1 on: December 31, 2015, 03:56:47 AM »
Done.
flag_invuln was changed into flag_invulnerable.
flag_override_dv was changed into flag_override_script_name.
lockpick_string was omitted because lockpick_strref already exists.
bounding_o_* were changed into bounding_open_*.
bounding_c_* were changed into bounding_closed_*.
door_*_snd were changed into door_*_sound.

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: