// *** Test: get kit attributes ***

INCLUDE ~%MOD_FOLDER%/lib/a7#add_kit_ex.tpa~

OUTER_TEXT_SPRINT kit_name ~BOUNTY_HUNTER~

LAF GET_KIT_EX
INT_VAR
  use_parent = 1  // whether to retrieve unavailable attributes from the kit's parent class
STR_VAR
  kit_name
RET
  // numeric return values
  kit_id
  kit_class
  mixed
  lower
  help
  // EE-specific
  biography
  briefdesc
  fallen
  fallen_notice
  // textual return values
  unusable
  clasweap
  weapprof
  abclasrq
  abclsmod
  abdcdsrq
  abdcscrq
  alignmnt
  dualclas
  luabbr
  stweap
  clab_res
  kittable
  // EE-specific
  clsrcreq
  clswpbon
  hpclass
  numwslot
  clascolr
  clasiskl
  clasthac
  thiefscl
  backstab
  sneakatt
  crippstr
  thiefskl
  traplimt
  bdstweap
END

ACTION_IF (kit_id != "-1") BEGIN
  PRINT ~Getting attributes of %kit_name%:~
  ACTION_FOR_EACH var IN ~kit_id~ ~kit_class~ ~mixed~ ~lower~ ~help~ ~biography~ ~briefdesc~ ~fallen~ ~fallen_notice~
                         ~unusable~ ~clasweap~ ~weapprof~ ~abclasrq~ ~abclsmod~ ~abdcdsrq~ ~abdcscrq~ ~alignmnt~ ~dualclas~
                         ~luabbr~ ~stweap~ ~clab_res~ ~kittable~ ~clsrcreq~ ~clswpbon~ ~hpclass~ ~numwslot~ ~clascolr~
                         ~clasiskl~ ~clasthac~ ~thiefscl~ ~backstab~ ~sneakatt~ ~crippstr~ ~thiefskl~ ~traplimt~ ~bdstweap~
  BEGIN
    OUTER_TEXT_SPRINT content EVAL ~%%var%%~
    ACTION_IF (IS_AN_INT ~content~ &&
               content >= 0 &&
               (~%var%~ STR_EQ ~mixed~ ||
                ~%var%~ STR_EQ ~lower~ ||
                ~%var%~ STR_EQ ~help~ ||
                ~%var%~ STR_EQ ~biography~ ||
                ~%var%~ STR_EQ ~briefdesc~ ||
                ~%var%~ STR_EQ ~fallen_notice~)) BEGIN
      ACTION_GET_STRREF content text
      OUTER_PATCH_SAVE text ~%text%~ BEGIN
        PATCH_IF (BUFFER_LENGTH > 45) BEGIN
          DELETE_BYTES 45 (BUFFER_LENGTH - 45)
          INSERT_BYTES 45 3
          WRITE_ASCII 45 ~...~ (3)
        END
        REPLACE_TEXTUALLY ~%MNL%?%LNL%~ ~ ~
      END
      PRINT ~Content of %var%: %content% (%text%)~
    END ELSE BEGIN
      PRINT ~Content of %var%: %content%~
    END
  END
END ELSE BEGIN
  ABORT ~Kit not found: %kit_name%.~
END
