LDONUtil.mac - Cause I hate math? Group Level and Range find

A forum for you to dump all the macros you create, allowing users to use, modify, and comment on your work.

Moderator: MacroQuest Developers

Preocts
a snow griffon
a snow griffon
Posts: 312
Joined: Thu Jan 29, 2004 1:02 pm

LDONUtil.mac - Cause I hate math? Group Level and Range find

Post by Preocts » Sat Feb 28, 2004 6:30 am

Since I am bored, and eq isn't with me tonight I'll just post some code that I use while throwing ldon groups together. Simple echos out a report of your current group including Name, Level, Class and the level range you can recuit people in. Try it, it's fun, usuful, and saves you from thinking too much. :roll:

Code: Select all

#turbo 10

Sub Main
  /zapvars
  /declare GroupNumber global
  /declare GroupNames array
  /declare GroupLevels array
  /declare GroupClass array
  /declare GroupMax global
  /declare GroupMin global
  /declare LoopVar global

  /call ScanGroup
  /call Report
/return

Sub ScanGroup
  /varset GroupNumber $calc($group(count)-1)  | group count minus one. Alone==0 Full==5
  /for LoopVar 0 to @GroupNumber
    /if "@GroupNames(@LoopVar)"!="$spawn($group(@LoopVar),name)" { |Assume new member
|      /echo <<New Member Joined>> $spawn($group(@LoopVar),name) is a level $spawn($group(@LoopVar),level) $spawn($group(@LoopVar),class)
    }
    /varset GroupNames(@LoopVar) "$spawn($group(@LoopVar),name)"
    /varset GroupLevels(@LoopVar) $spawn($group(@LoopVar),level)
    /varset GroupClass(@LoopVar) "$spawn($group(@LoopVar),class)"
  /next LoopVar
  /call EchoRange
/return

Sub EchoRange
  /declare Min local
  /declare Max local
  /varset Min $char(level)
  /varset Max $char(level)
  /if n $group(count)==1 /goto :SkipMath
  /for LoopVar 0 to @GroupNumber
    | Find the highest and lowest level in group
    /if n $spawn($group(@LoopVar),level)<@Min /varset Min $spawn($group(@LoopVar),level)
    /if n $spawn($group(@LoopVar),level)>@Max /varset Max $spawn($group(@LoopVar),level)
  /next LoopVar
  :SkipMath
  |Find the min and max level with a span of 7 from the previous levels.
  /varset GroupMin $calc(@Max-7)
  /varset GroupMax $calc(@Min+7)
  /if n @GroupMax>65 /varset GroupMax 65
  /if n $calc(@Min+7)<@Max {
    |Assume that the lowest level MUST be within seven levels of the highest
    /echo ***************WARNING*****************
    /echo Lowest Level in group is: Level @GroupMin
    /echo Highest Level in group is: Level @GroupMax
    /echo This is larger than the 7 level span limit.
    /echo ****************************************
    /return
  }
  /echo Level span Avalible is @GroupMin to @GroupMax
/return

Sub Report
  /echo -- GROUP REPORT --
  /for LoopVar 0 to @GroupNumber
    /echo <<Group Member>> $spawn($group(@LoopVar),name) is a level $spawn($group(@LoopVar),level) $spawn($group(@LoopVar),class)
  /next LoopVar
  /echo -- END REPORT --
/return