cMUD: Prompt Data Harvesting

MUD Client Links and Help
Post Reply
Inames
Bilge Rat
Posts: 5
Joined: Mon Jul 17, 2023 4:02 pm

cMUD: Prompt Data Harvesting

Post by Inames »

This code works with Classic-Powerbar and Classic-Powerbar-Top, Optional Nameplates (semi functional, doesn't work if either target is not standing, because the text appears and disappears, thus is inconsistent for pattern matching. If anyone actually likes to use nameplates I can definitely get it running by making more pattern matching cases, just didn't feel like it.

Pulls All Combat-related prompt data into the variable @MyStatus
Pulls All Powers-related prompt data into the variable @PowersRecord (except sorc points/combo points, those are in @MyStatus)

The BIGGEST functionality of this script is how it pulls the data of your powerbar into a record variable allowing you to easily check if the power is available for your aliases/scripts.

For Example: as a Sorc, if the power Torrent of Power is on your powerbar, you can check the availability of it by calling @PowersRecord.top, which returns 0 if its usable (you have enough combo points[sorc points]) or x if you haven't yet accrued enough combo points.

Powers with a Cooldown will return the number of rounds remaining on the cooldown as last seen by the prompt.

Using these to check the current state of availability can be good for creating a 1 button macro/alias for using the best power available to you each round.

OR

You could add an alarm that goes off every 2-4 seconds that spams you with a few warning lines when you are low on HP based on the @MyStatus.MissHP or @MyStatus.CurHP variables IF your Arcane Restoration is available.

Like

Code: Select all

#alarm -4 {
	#if (@MyStatus.MissHP > 350 & @PowersRecord.ar = 0) {
		#3 {#Echo HP LOW Arcane Restoration is READY!}} {
			#if (@MyStatus.MissHP > 350 & @PowersRecord.ar <= 2) {
				#3 {#Echo HP LOW Arcane Restoration is ALMOST Ready! ~(@PowersRecord.ar Rounds~)}} {}}
Full Script:

Code: Select all

<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <class name="PromptData">
    <var name="MyStatus" type="Record">
      <value>CurHP=791|MaxHP=791|MissHP=0|CurMV=170|MaxMV=170|MissMV=0|MissPSP=0|ComboPoints=2|MyPos=std|Combat=0</value>
      <json>{"MissMV":0,"MissHP":0,"MyPos":"std","MaxMV":170,"MaxHP":791,"MissPSP":0,"Combat":0,"CurMV":170,"CurHP":791,"ComboPoints":2}</json>
    </var>
    <class name="MyStatusCaptures">
      <trigger priority="6450">
        <pattern>is dead! R.I.P.</pattern>
        <value>MyStatus.Combat = 0</value>
      </trigger>
      <trigger name="PowerRecordReset" priority="6820" prompt="true">
        <pattern>< |*</pattern>
        <value>PowersRecord = %null</value>
        <trigger type="Skip Lines" param="1" prompt="true">
          <value>#noop</value>
        </trigger>
      </trigger>
    </class>
    <var name="PowersRecord" type="Record" usedef="true">
      <value>pe=0|cs=x|top=x|wms=0|cn=0|ar=0|psh=0|pls=0|cb=0|ps=0|eb=0|ts=0|qs=0|et=0|ec=0</value>
      <json>{"wms":0,"top":"x","psh":0,"pls":0,"ts":0,"qs":0,"ps":0,"pe":0,"et":0,"ec":0,"eb":0,"cs":"x","cn":0,"cb":0,"ar":0}</json>
    </var>
    <trigger param="2" priority="6830" prompt="true">
      <pattern>^<(*)>$</pattern>
      <value>//Loads and Trims whitespace from the end of the prompt, do not evaluate prompt
//patterns using <> as they are not included in the prompt string and cannot be
//matched as part of a pattern.
$prompt = %trim(%1)

//OPTIONAL this line will clear your MyStatus variable and load new data on each prompt, this makes it look cleaner, if you attempt to check the value of a non-existent key, it will return a value of %null (gives a comparison result of false for things like "#if (@MyStatus.TankCond) {#show Has a Value} {#show Is Null}"
//You do not NEED to reset this, if you want to check for old data for some reason, you can comment out or delete this line.
MyStatus = %null

//Loads PowersRecord with power cooldown timers
$powerName = %null
$powerTimer = %null
#if %match($prompt,"|(*)|") {#forall ($prompt) {
  #if (%trim(%i) != %null) {
    $powerName = %left( %i,(%match( %i, " ")-1));
    $powerTimer = %trim(%right( %i, (%match( %i, " "))));
    #if ($powerTimer = "+") {
      PowersRecord.$powerName = 0
      } {
      PowersRecord.$powerName = $powerTimer
      }
    } {}
  }
}

//Loads Combat and Status bar information into @MyStatus record variable
#if (%left($prompt,1) != "|") {
  #state PowerRecordReset 0
  #call %match($prompt,"(%d)h/(%d)H",MyStatus.CurHP,MyStatus.MaxHP);
    MyStatus.MissHP = %eval((@MyStatus.MaxHP)-(@MyStatus.CurHP))
  #call %match($prompt,"(%d)v/(%d)V",MyStatus.CurMV,MyStatus.MaxMV);
    MyStatus.MissMV = %eval((@MyStatus.MaxMV)-(@MyStatus.CurMV))
  #call %match($prompt,"(%d)p/(%d)P",MyStatus.CurPSP,MyStatus.MaxPSP);
    MyStatus.MissPSP = %eval((@MyStatus.MaxPSP)-(@MyStatus.CurPSP))
  #call %match($prompt,"~((%n)~)",MyStatus.ComboPoints)
  
  //Collects Data from Non-Nameplate Prompt about Tank and Enemy
  #call %match($prompt,"T:%s(*)%sTC:%s(*)%sE:%s(*)%sEC:%s(*)%sEP:",MyStatus.Tank,MyStatus.TankCond,MyStatus.Enemy,MyStatus.EnemyCond)

  //Collects Data from Nameplate Prompt about Tank and Enemy
  #call %match($prompt,"~[Tank:%s(%w)%s(%d)~%~]%s~[Target:%s(%w)%s(%d)~%~]",MyStatus.Tank,MyStatus.TankPercent,MyStatus.Enemy,MyStatus.EnemyPercent)

  //Collects Body Position Data from Prompt
  #call %match($prompt,"P: (%w)",MyStatus.MyPos)
  #call %match($prompt,"EP:%s(%w)%sP:",MyStatus.EnemyPos)
  //Evaluates if currently in combat or not
  #if (%match($prompt,"*E*P:") > 0) {MyStatus.Combat = 1} {MyStatus.Combat = 0}
  } {}</value>
    </trigger>
  </class>
</cmud>
Post Reply