Undead Corpse Sorter

This script will look at the corpses held by your undead and those on the ground in the room that the undead is standing in. It will then swap smaller corpses in its inventory for the largest ones on the ground, and then attempt to pick up what is left on the ground afterwards.

#CLASS 0
#ALIAS csortminion {
  #ECHO ===== Sorting Minion Corpses =====
  #t+ CorpseSortMinion
  #var aCorpsesMinion {} {} CorpseSortMinion
  #var aCorpsesGround {} {} CorpseSortMinion
  #t+ CorpseSortMinion|CorpsesMinion
  #send {!iu c}
  #send {!=i}
  #send {!=look}
  }
#CLASS {CorpseSortMinion}
#TRIGGER {You see nothing more.} {
  #t- CorpseSortMinion|CorpsesGround
  #LOOP 1,%numitems( @aCorpsesGround) {
    #LOOP 0,%eval( %item( @aCorpsesGround, %i)-1) {
      #VA vLowCorpseMinion %ismember( %j, @aCorpsesMinion) %null CorpseSortMinion
      #if (@vLowCorpseMinion > 0) {
        #SEND {=drop preservation @vLowCorpseMinion}
        #SEND {=get preservation %eval( %i+1)}
        #VA aCorpsesGround %push( %item( @aCorpsesMinion, @vLowCorpseMinion), @aCorpsesGround) %null CorpseSortMinion
        #VA aCorpsesMinion %push( %item( @aCorpsesGround, %eval( %i+1)), @aCorpsesMinion) %null CorpseSortMinion
        #DELNITEM aCorpsesGround %eval( %i+1)
        #DELNITEM aCorpsesMinion %eval( @vLowCorpseMinion+1)
        }
      }
    }
  #LOOP 9,0 {
    #VA vHighCorpseGround %ismember( %i, @aCorpsesGround) %null CorpseSortMinion
    #WHILE (@vHighCorpseGround > 0) {
      #SEND {=get preservation @vHighCorpseGround}
      #DELNITEM aCorpsesGround @vHighCorpseGround
      #VA vHighCorpseGround %ismember( %i, @aCorpsesGround) %null CorpseSortMinion
      }
    }
  #T- CorpseSortMinion
  }
#CLASS 0
#CLASS {CorpseSortMinion|CorpsesMinion}
#REGEX {^[ ]+\(([-|*])([-|*])([-|*])([-|*])([-|*])\) .*} {#if ("%1" = "|") {#VAR aCorpsesMinion %additem( "0", @aCorpsesMinion)} {#if ("%2" = "|") {#VAR aCorpsesMinion %additem( "1", @aCorpsesMinion)} {#if ("%3" = "|") {#VAR aCorpsesMinion %additem( "2", @aCorpsesMinion)} {#if ("%4" = "|") {#VAR aCorpsesMinion %additem( "3", @aCorpsesMinion)} {#if ("%5" = "|") {#VAR aCorpsesMinion %additem( "4", @aCorpsesMinion)} {#if ("%1" = "*") {#VAR aCorpsesMinion %additem( "9", @aCorpsesMinion)} {#if ("%2" = "*") {#VAR aCorpsesMinion %additem( "8", @aCorpsesMinion)} {#if ("%3" = "*") {#VAR aCorpsesMinion %additem( "7", @aCorpsesMinion)} {#if ("%4" = "*") {#VAR aCorpsesMinion %additem( "6", @aCorpsesMinion)} {#if ("%5" = "*") {#VAR aCorpsesMinion %additem( "5", @aCorpsesMinion)}}}}}}}}}}}
#REGEX {(?:--> (\d+) preserved corpse|The grimare is not carrying anything.)} {
  #t- CorpseSortMinion|CorpsesMinion
  #t+ CorpseSortMinion|CorpsesGround
  }
#CLASS 0
#CLASS {CorpseSortMinion|CorpsesGround}
#REGEX {^\(([-|*])([-|*])([-|*])([-|*])([-|*])\) .*} {#if ("%1" = "|") {#VAR aCorpsesGround %additem( "0", @aCorpsesGround)} {#if ("%2" = "|") {#VAR aCorpsesGround %additem( "1", @aCorpsesGround)} {#if ("%3" = "|") {#VAR aCorpsesGround %additem( "2", @aCorpsesGround)} {#if ("%4" = "|") {#VAR aCorpsesGround %additem( "3", @aCorpsesGround)} {#if ("%5" = "|") {#VAR aCorpsesGround %additem( "4", @aCorpsesGround)} {#if ("%1" = "*") {#VAR aCorpsesGround %additem( "9", @aCorpsesGround)} {#if ("%2" = "*") {#VAR aCorpsesGround %additem( "8", @aCorpsesGround)} {#if ("%3" = "*") {#VAR aCorpsesGround %additem( "7", @aCorpsesGround)} {#if ("%4" = "*") {#VAR aCorpsesGround %additem( "6", @aCorpsesGround)} {#if ("%5" = "*") {#VAR aCorpsesGround %additem( "5", @aCorpsesGround)}}}}}}}}}}}
#CLASS 0
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License