Author Topic: ALTER_ITEM_HEADER  (Read 1749 times)

Offline Echon

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1944
  • Gender: Male
    • The Fields of the Dead
ALTER_ITEM_HEADER
« on: April 10, 2014, 06:19:15 AM »
I need a fresh pair of eyes to look at this code. ALTER_ITEM_HEADER may not be the problem here but I am not sure what else could be the cause. Anyway, the issue is that only spears are being patched. I added the PATCH_PRINTs to make sure the string variable was not the problem, and all three are displayed several times.

Code: [Select]
COPY_EXISTING_REGEXP GLOB ~.*\.itm~ ~override~
  READ_ASCII 0x22 "appearance"
  PATCH_IF ("%appearance%" STRING_EQUAL_CASE "MS") THEN BEGIN
    PATCH_PRINT ~Morningstar found~
LAUNCH_PATCH_FUNCTION ALTER_ITEM_HEADER
  INT_VAR
  header_type = 1
  damage_type = 6
  END
END
  PATCH_IF ("%appearance%" STRING_EQUAL_CASE "HB") THEN BEGIN
    PATCH_PRINT ~Halberd found~
LAUNCH_PATCH_FUNCTION ALTER_ITEM_HEADER
  INT_VAR
  header_type = 1
  damage_type = 7
  END
END
  PATCH_IF ("%appearance%" STRING_EQUAL_CASE "SP") THEN BEGIN
   PATCH_PRINT ~Spear found~
   WRITE_LONG 0x34 "5"
   WRITE_LONG 0x4c "8"
   LAUNCH_PATCH_FUNCTION ALTER_ITEM_HEADER
  INT_VAR
  header_type = 1
  speed = 8
  dicesize = 6
  dicenumber = 2
  END
END
  BUT_ONLY_IF_IT_CHANGES

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: ALTER_ITEM_HEADER
« Reply #1 on: April 11, 2014, 03:06:07 PM »
Bug (my bad). Has been fixed. If you want a local fix before next WeiDU, you can INCLUDE the fixed function definition before you try to use it. Bear in mind this overriding also affects any other future changes that might be made to the function, so it's a good idea to take it out when it is no longer necessary.
Code: [Select]
DEFINE_PATCH_FUNCTION ALTER_ITEM_HEADER
  INT_VAR header_type        = "-1" // -1 is all headers, otherwise use value here
          match_icon         = 0    // make icon match a qualifier, 0 = no, 1 = yes
          header             = 0    // 0 matches all headers, otherwise just modify specified header - use with type = -1
          new_header_type    = "-1" // change the type at 0x00 to this value; negative values mean no change
          identify           = "-1" // identify to use? at 0x01; negative values mean no change
          location           = "-1" // ability location at 0x02; negative values mean no change
          target             = "-1" // target at 0x0c; negative values mean no change
          range              = "-1" // range at 0x0e; negative values mean no change
          launcher           = "-1" // launcher required at 0x10; negative values mean no change
          speed              = "-1" // speed at 0x12; negative values mean no change
          thac0_bonus        = "-1" // to-hit bonus at 0x14; negative values mean no change
          dicesize           = "-1" // dice size at 0x16; negative values mean no change
          primary_type       = "-1" // primary school at 0x17; negative values mean no change
          dicenumber         = "-1" // number of dice at 0x18; negative values mean no change
          secondary_type     = "-1" // seoncdary type at 0x19; negative values mean no change
          damage_bonus       = "-1" // +damage bonus at 0x1a; negative values mean no change
          damage_type        = "-1" // damage type at 0x1c; negative values mean no change
          charges            = "-1" // number of charges at 0x22; negative values mean no change
          drained            = "-1" // when drained? at 0x24; negative values mean no change
          projectile         = "-1" // projectile at 0x2a; negative values mean no change
          animation_overhand = "-1" // % of overhand attacks at 0x2c; negative values mean no change
          animation_backhand = "-1" // % of backhand attacks at 0x2e; negative values mean no change
          animation_thrust   = "-1" // % of thrusting attacks at 0x30; negative values mean no change
          arrow              = "-1" // is arrow? at 0x32; negative values mean no change
          bolt               = "-1" // is bolt? at 0x34; negative values mean no change
          bullet             = "-1" // is bullet? at 0x36; negative values mean no change
          // flag_ vars affect flags starting at 0x26; 0 means remove flag, 1 means add flag, -1 no change
          flag_strength      = "-1" // add strength bonus, bit0
          flag_break         = "-1" // breakable, bit1
          flag_hostile       = "-1" // hostile, bit10
          flag_recharge      = "-1" // recharge after resting, bit11
          flag_bypass        = "-1" // bypass armor, bit16
          flag_keenedge      = "-1" // keen edge, bit17
          flag_backstab      = "-1" // tobex only, can backstab, bit25
          flag_noinvisible   = "-1" // tobex only, cannot target invisible, bit26
  STR_VAR icon               = "same" // ability icon at 0x04; used to match if type > 4; same means no change otherwise use this value
BEGIN
  LPF ALTER_ITMSPL_HEADER
    INT_VAR
      header_type
      match_icon
      header
      new_header_type
      identify
      location
      target
      range
      launcher_or_level = launcher
      speed
      thac0_bonus
      dicesize
      primary_type
      dicenumber
      secondary_type
      damage_bonus
      damage_type
      charges
      drained
      projectile
      animation_overhand
      animation_backhand
      animation_thrust
      arrow
      bolt
      bullet
      flag_strength
      flag_break
      flag_hostile
      flag_recharge
      flag_bypass
      flag_keenedge
      flag_backstab
      flag_noinvisible
      header_length = 0x38
    STR_VAR
      icon
  END
END

critto_unreg

  • Guest
Re: ALTER_ITEM_HEADER
« Reply #2 on: May 11, 2016, 02:53:46 AM »
I've been meaning to ask two questions:

1) any reason why alter_item_header does not allow to change the amount of abilities and the first ability's offset? Except for the obvious one that somebody might break something horribly (but that is always an option when things come to WeiDU and patching).

2) any reason why there isn't a add_item_header function? I've recently written a local version for myself and was wondering whether it could be included into WeiDU itself.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: ALTER_ITEM_HEADER
« Reply #3 on: May 19, 2016, 01:25:53 PM »
1) any reason why alter_item_header does not allow to change the amount of abilities and the first ability's offset? Except for the obvious one that somebody might break something horribly (but that is always an option when things come to WeiDU and patching).
I did not want to support this as one way of doing those things.

Quote
2) any reason why there isn't a add_item_header function? I've recently written a local version for myself and was wondering whether it could be included into WeiDU itself.
Thunderdome. Then it got ridden out into the desert of my ever-growing todo list.

 

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)?: