Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Simucal
Beginner


Joined: 26 Sep 2005
Posts: 13

PostPosted: Sun Oct 09, 2005 12:55 am   

Converting combat shape into % health * Solved *
 
On the mud I play on, it has a thing called combat shape. When you combat shape a mob, it shows a nice little graphical "gauge" of the mobs health. The mobs remaining health changes color as the bar goes down.

There bar itself is composed of a series of (30 to be precise) colored "spaces".

Here are a few pictures of what I am talking about:

Mob has full health:



Little Less:



Even less:



Monster is about halfway dead:



More than halfway dead:



Almost there:



Barely hanging on to life:




So what I was thinking could possibly be done, is somehow count how many blue spaces there are, and conver that into some kind of numerical value for its health. As the number of blue spaces increases that means the health of the mob is decreasing.


This could very well be beyond what zmud is capable of in terms of triggers, but if it could be done.. well that would be very neat indeed. In summary, I would be interested in getting some kind of "percent" health left.


Last edited by Simucal on Mon Oct 10, 2005 1:22 am; edited 5 times in total
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun Oct 09, 2005 6:03 am   
 
Impossible for zmud scripting, but it should be doable in plugin form. ZMud doesn't have the capability to draw out the ansi codes for a specific position in the text, so while you maybe can match and then count the total number of bars there'd be no way to differentiate between red, blue, yellow, or green.
_________________
EDIT: I didn't like my old signature
Reply with quote
OmegaDeus
Apprentice


Joined: 14 Sep 2005
Posts: 121

PostPosted: Sun Oct 09, 2005 6:21 am   Ansi Trigger
 
I've got a question though. If it can't get the ansi of a specific line, what's up with the ansi trigger option that says Pattern contains ANSI color codes that must match line from MUD? I've been looking at this and wanting a little more information on it anyways.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Sun Oct 09, 2005 6:32 am   
 
Considering Matt is a Wizard and I'm still a Wanderer I hope I'm not speaking out of turn. However, if I understand the problem correctly I believe it is possible to do that with zMud. You would of course need to specify an ANSI trigger. capture the entire line and calculate the remaining spaces. More specifically you'd need your ANSI trigger to match. After that it becomes simple mathematics. Now I did notice something a little funky while matching spaces in zScript a few days ago (but I'm chalking as possible errors on my part) but I can match multiple spaces with a Perl regex in the pattern.

The following is a crude attempt at pseudo-code
Code:
Perl Pattern:  (ANSI\|Green2Ansi\|BrownANSI\|YellowANSI\|RedANSI)(\s+)(BlunANSI(\s+))?
Code:  #IF (%len(%4) > 0) { #VAR BlueSpaces %len( %4));  #VAR PercentRemaing %eval ( ( (30 - @BlueSpaces)/30)*100) }


Then all you should have to do is display @PercentRemaining. Now bear in mind I did this off the top of my head and it's not verified, but it should get you a good start.
_________________
Asati di tempari!
Reply with quote
Bremen
Novice


Joined: 26 Dec 2002
Posts: 33
Location: USA

PostPosted: Sun Oct 09, 2005 6:39 am   
 
I wouldn't say it's impossible. It shouldn't be that hard to do a trigger on receiving the blue ANSI code and then store the resulting spaces (%s) in a variable and count the length of the variable..
_________________
--Bremen, zMUD 7.21 on Windows 7 x64
Reply with quote
Simucal
Beginner


Joined: 26 Sep 2005
Posts: 13

PostPosted: Sun Oct 09, 2005 4:26 pm   
 
any chance someone could help me get some of this started?

I tried the code Tech wrote, and it didnt capture anything into the variable.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun Oct 09, 2005 5:11 pm   
 
Quote:

I've got a question though. If it can't get the ansi of a specific line, what's up with the ansi trigger option that says Pattern contains ANSI color codes that must match line from MUD? I've been looking at this and wanting a little more information on it anyways.


#trigger {ansi color code goes here([symbol for the gauge blocks])blue ansi code goes here([symbol for the gauge blocks])} {Left = %len(%1);Total = %eval(%len(%1) + %len(%2))}

where it says "ansi code goes here", you have to provide the exact color code. You can't use the %ansi() function or otherwise pass the code to the trigger pattern via some other function and I don't believe you can use wildcards. Because ZMud cannot print the escape character, you have to use %e instead.

Also, I'm expecting this trigger to not actually work rather than just giving my usual "untested" advice.
_________________
EDIT: I didn't like my old signature
Reply with quote
Simucal
Beginner


Joined: 26 Sep 2005
Posts: 13

PostPosted: Sun Oct 09, 2005 5:34 pm   
 
but what about whenever the bar is 100% green? It wouldnt have any blue to pick up then, would it? There is no way I could trigger on a group of 30 spaces, and then figure out how many are blue from there?

Also, as far as the ansi code for the blue.. I turn on ansi logging, and saved my log.



There is a picture of a combat shape and here is its corresponding log:

Ghirma   
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sun Oct 09, 2005 7:18 pm   
 
#TRIGGER "combatshape" {Doing: combat shape} {}
#COND {%e[1;32m*%e[0m (*)%e[0m} {RawBar="%1"} {within|param=1|color}

That will give you a variable Rawbar which contains just the whole bar including ansi codes.

This is what I have so far and its untested but should work, There is still alot more work to be done but it should be enough to get you started
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
Simucal
Beginner


Joined: 26 Sep 2005
Posts: 13

PostPosted: Sun Oct 09, 2005 8:51 pm   almost there
 
yes, thank you nexela!! we are almost there. Now, lets say I have a raw output of:

 

what is the easiest way to count the number of spaces after 44m?

It must be the 44m that it counts after and not anything else.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun Oct 09, 2005 10:18 pm   
 
Capture the output in its entirety, then use %match() to divide up the pieces (spaces), and from there use %len() to get the lengths?
_________________
EDIT: I didn't like my old signature
Reply with quote
Simucal
Beginner


Joined: 26 Sep 2005
Posts: 13

PostPosted: Mon Oct 10, 2005 1:21 am   
 
ok, im using:



#show %eval(100-%format(2,%eval(100*(%eval(%len(%right(@RawBar,%match(@RawBar,"44m")+2))/%float(30))))))

That is what I am currently using to display the %health left of the mob and it seems to work. Can anyone see anything wrong with it? Or perhaps a simpler way? The way I had to format the numbers I wasnt sure if that was the best method or not. Well anyway... it works!!! Thanks everyone.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net