Jump to content

Patching actors with identical names


Recommended Posts

The ALTER_AREA_ACTOR function requires the name of the actor to be patched. Yet many areas in the first BG use the same names for all actors of a type, only the coordinates are different. Now I would like to edit one of the "Performer" actors on the Nashkel carnival map, but there are two of them that link to the same CRE file and a third that connects to a different CRE. Plus "Farmer" actors all around. I would never add an actor to an area without giving him a unique name, but Bioware didn't build the game with Weidu. Can anybody suggest a way to zero in on these actors? GET_OFFSET_ARRAY comes to mind, to sort through the properties that set them apart, like coordinates, and editing the ones that match, but this would be complicated and really dull.

Link to comment

You pretty much have to go low-level, unless you're willing to go to the effort of writing a new function. One component I wrote had to do this (one of the guards in Athkatla's government district is standing in a wall), and I searched based on location:

	COPY_EXISTING ~AR1000.ARE~ ~override~ // Government District, Amnish Soldier
		READ_LONG 0x54 ofsActors
		READ_SHORT 0x58 numActors
		FOR (idx = 0; idx < numActors; ++idx) BEGIN
			SET offsetx = ofsActors + (idx * 0x110) + 0x20
			SET offsety = ofsActors + (idx * 0x110) + 0x22
			READ_SHORT offsetx xpos
			READ_SHORT offsety ypos
			PATCH_IF ((xpos = 2796) AND (ypos = 538)) BEGIN
				WRITE_SHORT offsety 558
			END
		END // Multiple actors with same name, long version needed
	BUT_ONLY

Now that I think about it, there's definitely an opening here for an improved version of ALTER_AREA_ACTOR. Instead of actor_name as the only match variable, do it like most other ALTER functions and have match variables for all of the fields that you can set.

Link to comment

After posting that, I went to the trouble of writing that extended version of ALTER_AREA_ACTOR. This code is not tested; if it doesn't work, it may need repairs. Also, I'm not an expert and there are probably better ways to do things.

Spoiler

/* alter_area_actor_ex : an extension of ALTER_AREA_ACTOR from base WeiDU to allow match-checking of all fields and alteration of the actor's name. All variables present in the original ALTER_AREA_ACTOR function are present here with the same meaning, with the exception of the string variable actor_name. The old actor_name is now match_actor_name and is no longer required, and the new actor_name is the value to change the actor's name to. In addition, each variable #### has a corresponding variable match_#### to help determine which actors to patch.

This function patches actors in the current area. Each field has a match_#### and #### variable pair. If all match_#### values match the actor's values, the fields for that actor will be updated with the #### values. All match_#### variables default to a value that results in all actors being considered matches and all #### variables default to a value that results in no changes being made; if no variables are set, the function will consider all actors matches but then make no changes to them.

All integer variables other than match_expiry and expiry default to -1, and all negative values result in the default behavior of all match/no change. For match_expiry and expiry, the default is -2 and only that value has the default behavior. For the flag variables, all values other than 0 and 1 result in the default behavior. These default conventions are the same as in the original ALTER_AREA_ACTOR.

All string variables default to "This string is too long to be valid", and strings longer than the field's size result in the default behavior of all match/no change. This size is 32 characters for actor_name/match_actor_name and 8 characters for the other string fields. Note that this default convention is different from the original ALTER_AREA_ACTOR, which used "same" as its defaults.

As a special note, if x_coord is defined and dest_x is not, then x_coord will be used as the x_value of the destination. The same is true for y_coord, dest_y, and the y-value of the destination.

See also the information on the original ALTER_AREA_ACTOR in the WeiDU documentation for details on each field. */

DEFINE_PATCH_FUNCTION alter_area_actor_ex
INT_VAR
  match_x_coord = -1
  match_y_coord = -1
  match_dest_x = -1
  match_dest_y = -1
  match_spawned = -1
  match_animation = -1
  match_orient = -1
  match_expiry = -2
  match_wander = -1
  match_follow = -1
  match_times_talked = -1
  match_flag_cre_unattached = -1
  match_flag_seen_party = -1
  match_flag_invulnerable = -1
  match_flag_override_script = -1
  match_flag_time_0 = -1
  match_flag_time_1 = -1
  match_flag_time_2 = -1
  match_flag_time_3 = -1
  match_flag_time_4 = -1
  match_flag_time_5 = -1
  match_flag_time_6 = -1
  match_flag_time_7 = -1
  match_flag_time_8 = -1
  match_flag_time_9 = -1
  match_flag_time_10 = -1
  match_flag_time_11 = -1
  match_flag_time_12 = -1
  match_flag_time_13 = -1
  match_flag_time_14 = -1
  match_flag_time_15 = -1
  match_flag_time_16 = -1
  match_flag_time_17 = -1
  match_flag_time_18 = -1
  match_flag_time_19 = -1
  match_flag_time_20 = -1
  match_flag_time_21 = -1
  match_flag_time_22 = -1
  match_flag_time_23 = -1
  x_coord = -1
  y_coord = -1
  dest_x = -1
  dest_y = -1
  spawned = -1
  animation = -1
  orient = -1
  expiry = -2
  wander = -1
  follow = -1
  times_talked = -1
  flag_cre_unattached = -1
  flag_seen_party = -1
  flag_invulnerable = -1
  flag_override_script = -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
  match_actor_name = ~This string is too long to be valid~
  match_dlg_file = ~This string is too long to be valid~
  match_script_override = ~This string is too long to be valid~
  match_script_general = ~This string is too long to be valid~
  match_script_class = ~This string is too long to be valid~
  match_script_race = ~This string is too long to be valid~
  match_script_default = ~This string is too long to be valid~
  match_script_specifics = ~This string is too long to be valid~
  match_cre_file = ~This string is too long to be valid~
  actor_name = ~This string is too long to be valid~
  dlg_file = ~This string is too long to be valid~
  script_override = ~This string is too long to be valid~
  script_general = ~This string is too long to be valid~
  script_class = ~This string is too long to be valid~
  script_race = ~This string is too long to be valid~
  script_default = ~This string is too long to be valid~
  script_specifics = ~This string is too long to be valid~
  cre_file = ~This string is too long to be valid~
BEGIN
  READ_LONG 0x54 offset_actors
  READ_SHORT 0x58 num_actors
  FOR (idx = 0; idx < num_actors; ++idx) BEGIN // Loop through actors in area
    SET test_match = 1 // Actor is match until proven otherwise
    SET offset_x_coord = offset_actors + (idx * 0x110) + 0x20
    READ_SHORT offset_x_coord read_x_coord
    PATCH_IF (match_x_coord >= 0 AND match_x_coord != read_x_coord) BEGIN
      SET test_match = 0
    END
    SET offset_y_coord = offset_actors + (idx * 0x110) + 0x22
    READ_SHORT offset_y_coord read_y_coord
    PATCH_IF (match_y_coord >= 0 AND match_y_coord != read_y_coord) BEGIN
      SET test_match = 0
    END
    SET offset_dest_x = offset_actors + (idx * 0x110) + 0x24
    READ_SHORT offset_dest_x read_dest_x
    PATCH_IF (match_dest_x >= 0 AND match_dest_x != read_dest_x) BEGIN
      SET test_match = 0
    END
    SET offset_dest_y = offset_actors + (idx * 0x110) + 0x26
    READ_SHORT offset_dest_y read_dest_y
    PATCH_IF (match_dest_y >= 0 AND match_dest_y != read_dest_y) BEGIN
      SET test_match = 0
    END
    SET offset_spawned = offset_actors + (idx * 0x110) + 0x2c
    READ_SHORT offset_spawned read_spawned
    PATCH_IF (match_spawned >= 0 AND match_spawned != read_spawned) BEGIN
      SET test_match = 0
    END
    SET offset_animation = offset_actors + (idx * 0x110) + 0x30
    READ_LONG offset_animation read_animation
    PATCH_IF (match_animation >= 0 AND match_animation != read_animation) BEGIN
      SET test_match = 0
    END
    SET offset_orient = offset_actors + (idx * 0x110) + 0x34
    READ_SHORT offset_orient read_orient
    PATCH_IF (match_orient >= 0 AND match_orient != read_orient) BEGIN
      SET test_match = 0
    END
    SET offset_expiry = offset_actors + (idx * 0x110) + 0x38
    READ_LONG offset_expiry read_expiry
    PATCH_IF (match_expiry != -2 AND match_expiry != read_expiry) BEGIN
      SET test_match = 0
    END
    SET offset_wander = offset_actors + (idx * 0x110) + 0x3c
    READ_SHORT offset_wander read_wander
    PATCH_IF (match_wander >= 0 AND match_wander != read_wander) BEGIN
      SET test_match = 0
    END
    SET offset_follow = offset_actors + (idx * 0x110) + 0x3e
    READ_SHORT offset_follow read_follow
    PATCH_IF (match_follow >= 0 AND match_follow != read_follow) BEGIN
      SET test_match = 0
    END
    SET offset_times_talked = offset_actors + (idx * 0x110) + 0x44
    READ_SHORT offset_times_talked read_times_talked
    PATCH_IF (match_times_talked >= 0 AND match_times_talked != read_times_talked) BEGIN
      SET test_match = 0
    END
    SET offset_flags = offset_actors + (idx * 0x110) + 0x28
    READ_LONG offset_flags read_flags
    PATCH_IF (match_flag_cre_unattached = 0 AND (read_flags BAND BIT0) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_cre_unattached = 1 AND (read_flags BAND BIT0) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_seen_party = 0 AND (read_flags BAND BIT1) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_seen_party = 1 AND (read_flags BAND BIT1) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_invulnerable = 0 AND (read_flags BAND BIT2) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_invulnerable = 1 AND (read_flags BAND BIT2) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_override_script = 0 AND (read_flags BAND BIT3) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_override_script = 1 AND (read_flags BAND BIT3) = 0)
      SET test_match = 0
    END
    SET offset_times = offset_actors + (idx * 0x110) + 0x40
    READ_LONG offset_times read_times
    PATCH_IF (match_flag_time_0 = 0 AND (read_times BAND BIT0) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_0 = 1 AND (read_times BAND BIT0) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_1 = 0 AND (read_times BAND BIT1) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_1 = 1 AND (read_times BAND BIT1) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_2 = 0 AND (read_times BAND BIT2) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_2 = 1 AND (read_times BAND BIT2) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_3 = 0 AND (read_times BAND BIT3) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_3 = 1 AND (read_times BAND BIT3) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_4 = 0 AND (read_times BAND BIT4) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_4 = 1 AND (read_times BAND BIT4) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_5 = 0 AND (read_times BAND BIT5) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_5 = 1 AND (read_times BAND BIT5) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_6 = 0 AND (read_times BAND BIT6) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_6 = 1 AND (read_times BAND BIT6) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_7 = 0 AND (read_times BAND BIT7) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_7 = 1 AND (read_times BAND BIT7) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_8 = 0 AND (read_times BAND BIT8) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_8 = 1 AND (read_times BAND BIT8) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_9 = 0 AND (read_times BAND BIT9) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_9 = 1 AND (read_times BAND BIT9) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_10 = 0 AND (read_times BAND BIT10) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_10 = 1 AND (read_times BAND BIT10) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_11 = 0 AND (read_times BAND BIT11) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_11 = 1 AND (read_times BAND BIT11) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_12 = 0 AND (read_times BAND BIT12) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_12 = 1 AND (read_times BAND BIT12) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_13 = 0 AND (read_times BAND BIT13) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_13 = 1 AND (read_times BAND BIT13) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_14 = 0 AND (read_times BAND BIT14) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_14 = 1 AND (read_times BAND BIT14) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_15 = 0 AND (read_times BAND BIT15) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_15 = 1 AND (read_times BAND BIT15) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_16 = 0 AND (read_times BAND BIT16) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_16 = 1 AND (read_times BAND BIT16) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_17 = 0 AND (read_times BAND BIT17) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_17 = 1 AND (read_times BAND BIT17) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_18 = 0 AND (read_times BAND BIT18) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_18 = 1 AND (read_times BAND BIT18) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_19 = 0 AND (read_times BAND BIT19) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_19 = 1 AND (read_times BAND BIT19) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_20 = 0 AND (read_times BAND BIT20) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_20 = 1 AND (read_times BAND BIT20) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_21 = 0 AND (read_times BAND BIT21) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_21 = 1 AND (read_times BAND BIT21) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_22 = 0 AND (read_times BAND BIT22) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_22 = 1 AND (read_times BAND BIT22) = 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_23 = 0 AND (read_times BAND BIT23) != 0)
      SET test_match = 0
    END
    PATCH_IF (match_flag_time_23 = 1 AND (read_times BAND BIT23) = 0)
      SET test_match = 0
    END
    SET offset_actor_name = offset_actors + (idx * 0x110) + 0
    READ_ASCII offset_actor_name read_actor_name (32)
    PATCH_IF ((STRING_LENGTH match_actor_name) < 33 AND NOT (match_actor_name STR_EQ read_actor_name)) BEGIN
      SET test_match = 0
    END
    SET offset_dlg_file = offset_actors + (idx * 0x110) + 0x48
    READ_ASCII offset_dlg_file read_dlg_file
    PATCH_IF ((STRING_LENGTH match_dlg_file) < 9 AND NOT (match_dlg_file STR_EQ read_dlg_file)) BEGIN
      SET test_match = 0
    END
    SET offset_script_override = offset_actors + (idx * 0x110) + 0x50
    READ_ASCII offset_script_override read_script_override
    PATCH_IF ((STRING_LENGTH match_script_override) < 9 AND NOT (match_script_override STR_EQ read_script_override)) BEGIN
      SET test_match = 0
    END
    SET offset_script_general = offset_actors + (idx * 0x110) + 0x58
    READ_ASCII offset_script_general read_script_general
    PATCH_IF ((STRING_LENGTH match_script_general) < 9 AND NOT (match_script_general STR_EQ read_script_general)) BEGIN
      SET test_match = 0
    END
    SET offset_script_class = offset_actors + (idx * 0x110) + 0x60
    READ_ASCII offset_script_class read_script_class
    PATCH_IF ((STRING_LENGTH match_script_class) < 9 AND NOT (match_script_class STR_EQ read_script_class)) BEGIN
      SET test_match = 0
    END
    SET offset_script_race = offset_actors + (idx * 0x110) + 0x68
    READ_ASCII offset_script_race read_script_race
    PATCH_IF ((STRING_LENGTH match_script_race) < 9 AND NOT (match_script_race STR_EQ read_script_race)) BEGIN
      SET test_match = 0
    END
    SET offset_script_default = offset_actors + (idx * 0x110) + 0x70
    READ_ASCII offset_script_default read_script_default
    PATCH_IF ((STRING_LENGTH match_script_default) < 9 AND NOT (match_script_default STR_EQ read_script_default)) BEGIN
      SET test_match = 0
    END
    SET offset_script_specifics = offset_actors + (idx * 0x110) + 0x78
    READ_ASCII offset_script_specifics read_script_specifics
    PATCH_IF ((STRING_LENGTH match_script_specifics) < 9 AND NOT (match_script_specifics STR_EQ read_script_specifics)) BEGIN
      SET test_match = 0
    END
    SET offset_cre_file = offset_actors + (idx * 0x110) + 0x80
    READ_ASCII offset_cre_file read_cre_file
    PATCH_IF ((STRING_LENGTH match_cre_file) < 9 AND NOT (match_cre_file STR_EQ read_cre_file)) BEGIN
      SET test_match = 0
    END
    /* All match variables checked. Making changes now. */
    PATCH_IF (test_match = 1) BEGIN
      PATCH_IF (x_coord >= 0) BEGIN
        WRITE_SHORT offset_x_coord x_coord
      END
      PATCH_IF (y_coord >= 0) BEGIN
        WRITE_SHORT offset_y_coord y_coord
      END
      PATCH_IF (dest_x < 0 AND x_coord >= 0) BEGIN
        SET dest_x = x_coord
      END
      PATCH_IF (dest_x >= 0) BEGIN
        WRITE_SHORT offset_dest_x dest_x
      END
      PATCH_IF (dest_y < 0 AND y_coord >= 0) BEGIN
        SET dest_y = y_coord
      END
      PATCH_IF (dest_y >= 0) BEGIN
        WRITE_SHORT offset_dest_y dest_y
      END
      PATCH_IF (spawned >= 0) BEGIN
        WRITE_SHORT offset_spawned spawned
      END
      PATCH_IF (animation >= 0) BEGIN
        WRITE_LONG offset_animation animation
      END
      PATCH_IF (orient >= 0) BEGIN
        WRITE_SHORT offset_orient orient
      END
      PATCH_IF (expiry != -2) BEGIN
        WRITE_LONG offset_expiry expiry
      END
      PATCH_IF (wander >= 0) BEGIN
        WRITE_SHORT offset_wander wander
      END
      PATCH_IF (follow >= 0) BEGIN
        WRITE_SHORT offset_follow follow
      END
      PATCH_IF (times_talked >= 0) BEGIN
        WRITE_SHORT offset_times_talked times_talked
      END
      PATCH_IF (flag_cre_unattached = 0) BEGIN
        WRITE_LONG offset_flags (THIS BAND (BNOT BIT0))
      END
      PATCH_IF (flag_cre_unattached = 1) BEGIN
        WRITE_LONG offset_flags (THIS BOR BIT0)
      END
      PATCH_IF (flag_seen_party = 0) BEGIN
        WRITE_LONG offset_flags (THIS BAND (BNOT BIT1))
      END
      PATCH_IF (flag_seen_party = 1) BEGIN
        WRITE_LONG offset_flags (THIS BOR BIT1)
      END
      PATCH_IF (flag_invulnerable = 0) BEGIN
        WRITE_LONG offset_flags (THIS BAND (BNOT BIT2))
      END
      PATCH_IF (flag_invulnerable = 1) BEGIN
        WRITE_LONG offset_flags (THIS BOR BIT2)
      END
      PATCH_IF (flag_override_script = 0) BEGIN
        WRITE_LONG offset_flags (THIS BAND (BNOT BIT3))
      END
      PATCH_IF (flag_override_script = 1) BEGIN
        WRITE_LONG offset_flags (THIS BOR BIT3)
      END
      PATCH_IF (flag_time_0 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT0))
      END
      PATCH_IF (flag_time_0 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT0)
      END
      PATCH_IF (flag_time_1 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT1))
      END
      PATCH_IF (flag_time_1 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT1)
      END
      PATCH_IF (flag_time_2 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT2))
      END
      PATCH_IF (flag_time_2 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT2)
      END
      PATCH_IF (flag_time_3 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT3))
      END
      PATCH_IF (flag_time_3 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT3)
      END
      PATCH_IF (flag_time_4 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT4))
      END
      PATCH_IF (flag_time_4 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT4)
      END
      PATCH_IF (flag_time_5 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT5))
      END
      PATCH_IF (flag_time_5 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT5)
      END
      PATCH_IF (flag_time_6 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT6))
      END
      PATCH_IF (flag_time_6 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT6)
      END
      PATCH_IF (flag_time_7 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT7))
      END
      PATCH_IF (flag_time_7 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT7)
      END
      PATCH_IF (flag_time_8 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT8))
      END
      PATCH_IF (flag_time_8 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT8)
      END
      PATCH_IF (flag_time_9 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT9))
      END
      PATCH_IF (flag_time_9 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT9)
      END
      PATCH_IF (flag_time_10 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT10))
      END
      PATCH_IF (flag_time_10 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT10)
      END
      PATCH_IF (flag_time_11 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT11))
      END
      PATCH_IF (flag_time_11 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT11)
      END
      PATCH_IF (flag_time_12 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT12))
      END
      PATCH_IF (flag_time_12 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT12)
      END
      PATCH_IF (flag_time_13 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT13))
      END
      PATCH_IF (flag_time_13 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT13)
      END
      PATCH_IF (flag_time_14 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT14))
      END
      PATCH_IF (flag_time_14 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT14)
      END
      PATCH_IF (flag_time_15 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT15))
      END
      PATCH_IF (flag_time_15 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT15)
      END
      PATCH_IF (flag_time_16 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT16))
      END
      PATCH_IF (flag_time_16 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT16)
      END
      PATCH_IF (flag_time_17 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT17))
      END
      PATCH_IF (flag_time_17 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT17)
      END
      PATCH_IF (flag_time_18 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT18))
      END
      PATCH_IF (flag_time_18 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT18)
      END
      PATCH_IF (flag_time_19 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT19))
      END
      PATCH_IF (flag_time_19 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT19)
      END
      PATCH_IF (flag_time_20 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT20))
      END
      PATCH_IF (flag_time_20 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT20)
      END
      PATCH_IF (flag_time_21 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT21))
      END
      PATCH_IF (flag_time_21 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT21)
      END
      PATCH_IF (flag_time_22 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT22))
      END
      PATCH_IF (flag_time_22 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT22)
      END
      PATCH_IF (flag_time_23 = 0) BEGIN
        WRITE_LONG offset_times (THIS BAND (BNOT BIT23))
      END
      PATCH_IF (flag_time_23 = 1) BEGIN
        WRITE_LONG offset_times (THIS BOR BIT23)
      END
      PATCH_IF ((STRING_LENGTH actor_name) < 33) BEGIN
        WRITE_ASCII offset_actor_name actor_name 32
      END
      PATCH_IF ((STRING_LENGTH dlg_file) < 9) BEGIN
        WRITE_ASCII offset_dlg_file dlg_file 8
      END
      PATCH_IF ((STRING_LENGTH script_override) < 9) BEGIN
        WRITE_ASCII offset_script_override script_override 8
      END
      PATCH_IF ((STRING_LENGTH script_general) < 9) BEGIN
        WRITE_ASCII offset_script_general script_general 8
      END
      PATCH_IF ((STRING_LENGTH script_class) < 9) BEGIN
        WRITE_ASCII offset_script_class script_class 8
      END
      PATCH_IF ((STRING_LENGTH script_race) < 9) BEGIN
        WRITE_ASCII offset_script_race script_race 8
      END
      PATCH_IF ((STRING_LENGTH script_default) < 9) BEGIN
        WRITE_ASCII offset_script_default script_default 8
      END
      PATCH_IF ((STRING_LENGTH script_specifics) < 9) BEGIN
        WRITE_ASCII offset_script_specifics script_specifics 8
      END
      PATCH_IF ((STRING_LENGTH cre_file) < 9) BEGIN
        WRITE_ASCII offset_cre_file cre_file 8
      END
    END // Edits complete
  END // Actor loop closed
END

Thoughts? Repairs? Improvements? Worthy of inclusion in the "semi-useful WeiDU macros" thread?

Edited by jmerry
Link to comment
2 hours ago, jmerry said:

Also, I'm not an expert and there are probably better ways to do things.

Why so self-deprecating? You wrote a useful function, cheers to you! I'll use the old code this time, though. What would be really great for these ALTER functions is a way to increase and decrease parameters instead of setting them. For instance, I know I want to move Zeke at the fair about 200 points to the north from where he's standing, closer to the petrified Branwen, but I don't know his current coordinate. I have to load the area - or look at it in Near Infinity - and search for the Y coordinate at mouse point. Or let's say I want to lower the upper probability threshold in an effect by some number of points. I have to either assume it's 100 or go the PHP_EACH way, read, adjust and reenter the value. And at that I'm not an expert. 🤖

Edited by temnix
Link to comment

You call it self-deprecating, I call it honesty. I've only been working with WeiDU for a few months, and there's definitely code I've seen around here from those with more experience that goes over my head. Programming in general for me ... a couple iterations of an introductory class, years apart and in different languages. Aside from that, it's all self-taught hobbyist stuff.

As for Zeke, just look him up. He's one creature, and you wouldn't want to move him 200 points north if he wasn't standing in his current spot. Messing with probabilities? That gives me the willies if you don't absolutely know what the current probabilities are. For example, I had to work with Sphere of Chaos with my polymorph immunity component. That does ten different things, with probabilities indicating which is which. I wanted to separate the polymorph effect out as a subspell so I could grant immunity to it and not the whole spell. So... clone the spell to a new subspell code. Run nine instances of DELETE_EFFECT with match_probability1 equal to 20, 30, ..., 100. Run an ALTER_SPELL_EFFECT to change probability1 to 100 on all remaining effects (the polymorph, with probability1 equal to 10 before the change). Edit a few other things. Then, go back to the original spell. Run a DELETE_EFFECT with match_probability1 equal to 10. Run an ADD_SPELL_EFFECT to create a new "cast spell" effect at probabilities 10/0, casting the just-created subspell. Sure, it feels convoluted, but that's because the spell is convoluted. And more flexible functions that allow for increment changes wouldn't have helped at all.

Link to comment

Let's say I want to make a spell that makes damage resistance boosts less effective. I want to lower them all by 30%. How would I do that now? How would I move EVERYBODY in an area 200 points north, because I'm planning a big explosion in the south? The usefulness in adjusting values is quite clear. But you already wrote that useful code, good on you.

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