EQ2Interface

EQ2Interface (https://www.eq2interface.com/forums/index.php)
-   XML Modification Help & Info (https://www.eq2interface.com/forums/forumdisplay.php?f=22)
-   -   Need Help with Health bar modifcation (https://www.eq2interface.com/forums/showthread.php?t=12955)

oleega 06-07-2009 01:49 PM

Need Help with Health bar modifcation
 
Is there a way to change the colors of a health bar so that it turns yellow, orange red sooner than it does now? If there is an easy way to do that, can someone post an example? Thank you so much.

EQAditu 06-07-2009 02:15 PM

Assuming there's an appropriate event trigger for ProgressBars(I don't know where there is an up-to-date list). Maybe use the OnTextChanged event for a health label instead.

Anyhow, I expect you'd have to disable EQ2's option to change the color at all so that it remains red. It's an actual game option, but probably a scriptable slash command as well. I'd hope that once it stays red that EQ2's hardcoding doesn't reset it to red on every change or you'll have difficulty.

Depending on which event you handle you'll either have a progress of 0.000 to 1.000 or a text of 0 to 100. You'll have to create a script to compare the current values to the steppings that you want. If you want smoother color transitions, you'll have to add more comparisons.

Sorta like:
Code removed
At the end, you'll end up with a color of red, yellow or green as ProgColor depending on the value of Prog, which you'll have to replace with the actual ProgressBar value or whatever. If you end up using the 1-100, you'll obviously have to use integers not decimals.

So as a short answer, it's not "easy" but not "hard" either. You'd have to calculate your own color transitions and hope EQ2 doesn't override you.

oleega 06-07-2009 05:11 PM

Thank you for your reply. I am not sure how to implement this however - can variables be declared in the xml? I have not found a sample of that and I have been looking through these posts for hours lol.

EQAditu 06-07-2009 07:02 PM

Sure they can be declared. When you write something in UI scripting, it first checks to see if it was a valid variable. It also considers the XML attributes of that node as variable names. In my above example, I use Prog and ProgColor as variables. ProgColor I actually assign a value to in scripting and Prog I assume has a value. If EQ2 can't find an assigned variable(or XML attribute) of that name, it treats it as a string. It also likes to treat things as arithmetic when possible.

Conversely you can assign XML attributes values in scripting as if they were internal variables.

Lemme just throw some of the things you want to do together in a simple way instead of speaking abstractly.
Code:

<Progressbar Color="#FF0000" DynamicData="/GameData.Group.Group_1.HealthPercent" Name="HealthBar" Progress="1.000" />
<Text DynamicData="/GameData.Group.Group_1.HealthPercent" Name="Percent" OnTextChanged="
ProgColor=#FF0000
ISGREATER=Parent.HealthBar.Progress > 0.5
ProgColor=ISGREATER ? #FFFF00 : ProgColor
ISGREATER=Parent.HealthBar.Progress > 0.9
ProgColor=ISGREATER ? #00FF00 : ProgColor
Parent.HealthBar.Color=ProgColor" />

You have the health bar and the health text percentage of group member 1. Obviously they belong nested inside of some other stuff in the group window. When the text changes from say, 100% to 80%, the OnTextChanged event should be raised and the script checks the progress bar's values against my two simple checks. It starts red, evaluates as true on the next line(turning it yellow) and evaluates as false on the next line(keeping it what it was). The last line of the script set's the progress bar's color to the result obtained in the short script. If you were going to do this 5-6 times for a group window or 24 times for a raid window there are definitely more elegant ways to code it at least to the point of a smaller file size.

oleega 06-07-2009 11:24 PM

I think I understand the idea behind your example. I tried changing the health bar, that did not work, so I tried to change the color in a power bar. The following code snippet does not work. The original color of the progress bar remains. Am I missing something?
Code:

<Page DynamicData="/GameData.Self.Power"  DynamicDataFilter="0001" Location="5,5" Name="PowerBar" PackSize="absolute,fixed" ScrollExtent="200,30" Size="200,30" Visible="true">
        <Image AbsorbsInput="false" Name="Bkg" ScrollExtent="50,30" Size="50,30" SourceRect="317,275,366,296" SourceResource="/images/window_elements_hr.dds" />
        <Image AbsorbsInput="false" Location="50,0" Name="ProgressBkg" PackSize="absolute,fixed" ScrollExtent="150,30" Size="150,30" SourceRect="395,276,487,300" SourceResource="/images/window_elements_hr.dds" />
        <Progressbar AbsorbsInput="false" BackgroundColor="#000000"  Color="#FFFFFF" DynamicData="/GameData.Self.Power" Location="54,3" Name="Bar" PackSize="absolute,fixed" Progress="0.500" ScrollExtent="141,24" Size="141,24" Style="progressBar" />
        <Page AbsorbsInput="false" BackgroundOpacity="1.000" Location="54,2" Name="Frame" PackSize="absolute,fixed" ScrollExtent="141,26" Size="141,26" />
        <Text DynamicData="/GameData.Self.Power"  Name="Percent" OnTextChanged="
                ProgColor=#FF0000
                BlueColor=#0000CD
                PinkColor=#FF1493
                PurpleColor=#8A2BE2
                YellowColor=#FFFF00
                OrangeColor=#D2691E
                ProgColor=Parent.Bar.Progress > .30 ? OrangeColor : ProgColor
                ProgColor=Parent.Bar.Progress > .40 ? YellowColor : ProgColor
                ProgColor=Parent.Bar.Progress > 0.45 ? BlueColor : ProgColor
                ProgColor=Parent.Bar.Progress > 0.55 ? PinkColor : ProgColor
                ProgColor=Parent.Bar.Progress > 0.62 ? PurpleColor : ProgColor
                Parent.Bar.Color=ProgColor"/>
               
    </Page>


EQAditu 06-08-2009 12:16 AM

Apparently I wasn't thinking when I was writing out that code. You can't have the UI scripting evaluate a boolean condition in the same line that it is using it. I apologize and I'll fix my previous code.

gm9 06-08-2009 01:27 AM

In addition, depending on where you try to change the colors, you will need to change the name of the health/power bar because otherwise the game will override your color changes when it sets the color itself.

oleega 06-08-2009 08:45 AM

Oh and both of you - I am in awe of the things you have done for the EQ2 community!!

I am a fervent promoter of both ACT and ProfitUI - they have certainly made my game experience much better!!!

I thank you for your time.

oleega 06-08-2009 11:05 AM

Yay! I have gotten the power bar to work!
I have yet to get the health bar to work. Here is the current code snippet:
Code:

<Page DynamicData="/GameData.Self.Health" DynamicDataFilter="0001" Location="5,5" Name="HealthBar" PackSize="absolute,fixed" ScrollExtent="200,30" Size="200,30" Visible="true">
        <Image AbsorbsInput="false" Name="Bkg" ScrollExtent="50,30" Size="50,30" SourceRect="317,275,366,296" SourceResource="/images/window_elements_hr.dds" />
        <Image AbsorbsInput="false" Location="50,0" Name="ProgressBkg" PackSize="absolute,fixed" ScrollExtent="150,30" Size="150,30" SourceRect="395,276,487,300" SourceResource="/images/window_elements_hr.dds" />
        <Progressbar AbsorbsInput="false" Color="#8A2BE2" DynamicDataFilter="FBFF" BackgroundColor="#000000" DynamicData="/GameData.Self.Health" Location="54,3" Name="Bar" PackSize="absolute,fixed" Progress="0.500" ScrollExtent="141,24" Size="141,24" Style="progressBar" />
        <Page AbsorbsInput="false" BackgroundOpacity="1.000" Location="54,2" Name="Frame" PackSize="absolute,fixed" ScrollExtent="141,26" Size="141,26" />
                <Text DynamicData="/GameData.Self.Health" Name="Percent" DynamicDataFilter="0001" OnTextChanged="
                ProgColor=#FF0000
                GreenColor=#00FF00
                OrangeColor=#D2691E
                isGreater=Parent.Bar.Progress > 0.52
                ProgColor=isGreater ? OrangeColor : ProgColor
                isGreater=Parent.Bar.Progress > 0.55
                ProgColor=isGreater ? GreenColor : ProgColor
                isGreater=Parent.Bar.Progress > 0.85
                ProgColor=isGreater ? OrangeColor : ProgColor
                Parent.Bar.Color=ProgColor
                Parent.Parent.Health.Color=ProgColor" />
    </Page>

Where would I change the name of the progress bar?

EQAditu 06-08-2009 01:08 PM

The attribute, Name in the ProgressBar element. Changing the name will cause EQ2's hardcoding of the recoloring not able to find the element. Of course it will make your script unable to find it too, so you'll have to change the Parent.Bar.XMLAttribute from Bar to whatever you change the name to.

oleega 06-08-2009 02:15 PM

I understand what attribute to change, just not exactly where to change it lol.

gm9 06-08-2009 02:18 PM

Quote:

Originally Posted by oleega (Post 83871)
Yay! I have gotten the power bar to work!
I have yet to get the health bar to work. Here is the current code snippet:
Code:

<Page DynamicData="/GameData.Self.Health" DynamicDataFilter="0001" Location="5,5" Name="HealthBar" PackSize="absolute,fixed" ScrollExtent="200,30" Size="200,30" Visible="true">
        <Image AbsorbsInput="false" Name="Bkg" ScrollExtent="50,30" Size="50,30" SourceRect="317,275,366,296" SourceResource="/images/window_elements_hr.dds" />
        <Image AbsorbsInput="false" Location="50,0" Name="ProgressBkg" PackSize="absolute,fixed" ScrollExtent="150,30" Size="150,30" SourceRect="395,276,487,300" SourceResource="/images/window_elements_hr.dds" />
        <Progressbar AbsorbsInput="false" Color="#8A2BE2" DynamicDataFilter="FBFF" BackgroundColor="#000000" DynamicData="/GameData.Self.Health" Location="54,3" Name="Bar" PackSize="absolute,fixed" Progress="0.500" ScrollExtent="141,24" Size="141,24" Style="progressBar" />
        <Page AbsorbsInput="false" BackgroundOpacity="1.000" Location="54,2" Name="Frame" PackSize="absolute,fixed" ScrollExtent="141,26" Size="141,26" />
                <Text DynamicData="/GameData.Self.Health" Name="Percent" DynamicDataFilter="0001" OnTextChanged="
                ProgColor=#FF0000
                GreenColor=#00FF00
                OrangeColor=#D2691E
                isGreater=Parent.Bar.Progress > 0.52
                ProgColor=isGreater ? OrangeColor : ProgColor
                isGreater=Parent.Bar.Progress > 0.55
                ProgColor=isGreater ? GreenColor : ProgColor
                isGreater=Parent.Bar.Progress > 0.85
                ProgColor=isGreater ? OrangeColor : ProgColor
                Parent.Bar.Color=ProgColor
                Parent.Parent.Health.Color=ProgColor" />
    </Page>

Where would I change the name of the progress bar?

colored it red for you ;)

PS: Isn't that a renamed bar already? I don't remember it being called "Bar" in the default. Also just briefly looking at this shouldn't it be Parent.Parent.Bar ? Also this line "Parent.Parent.Health.Color=ProgColor" is referencing a non-existant object.

oleega 06-08-2009 02:53 PM

Here is my confusion. The progress bar, when created is named Bar
and so that is how we reference it to either query its Progress attribute or to
set the value of the color. So ... In order to rename the progress bar from Bar to something else, I need to first reference it as Bar - so do I query it as Bar then rename it to FooBar for instance, THEN change the color?
OR Do you mean that I should not make the name of the progress bar the default name from the start?
I am not sure what the default is but in case that is what you mean will try it with the name of FooBar in the first place and see what I can see.


The answer to the last question is no, not a typo - it is changing the text that is defined in code not showing in the snippet.

gm9 06-08-2009 02:59 PM

No, you only ever reference elements only by their name.

However, you only need to rename it if you modify an alreay existing default UI window, there is no need to rename your custom created "bar", so just ignore that for your mod. :)

Apart from that, unless I'm not looking straight: I still think you need to reference it from within that Text element as Parent.Parent.Bar, not Parent.Bar.

oleega 06-08-2009 03:17 PM

Ok - no not a modification of a default window, so no need to rename.

The Text object is a sibling of the progress bar (sorry, my indentations were not
correct)

Here is the full code for the xml file:

Code:


<?xml version="1.0" encoding="utf-8"?>
<Page eq2usescomwndcontrols="true" MaximumSize="1000,40" MinimumSize="85,40" Name="VSHealth" PackLocation="right,bottom" ScrollExtent="210,40" Size="210,40" UserMovable="true" UserResizable="true" version="1.1">
    <ProgressbarStyle Bar.Background="progressFill" Name="ProgressBar" />
    <ImageStyle Name="ProgressFill">
        <ImageFrame Name="progress_fill" Source="/images/window_elements_hr.dds" SourceRect="136,351,350,364" />
    </ImageStyle>
    <Text AbsorbsInput="false" Color="#FFFFFF" DynamicDataFilter="FBFB" DynamicData="/GameData.Self.Health" Font="/TextStyles.VeryLarge.VeryLargeStyle" Location="9,8" Name="Health" ScrollExtent="42,24" ShadowStyle="/ShadowStylesNew.Outline.style" Size="42,24" TextAlignment="Center" TextAlignmentVertical="Center" Visible="true">100</Text>
   
   
    <Page DynamicData="/GameData.Self.Health" DynamicDataFilter="0001" Location="5,5" Name="HealthBar" PackSize="absolute,fixed" ScrollExtent="200,30" Size="200,30" Visible="true">
        <Image AbsorbsInput="false" Name="Bkg" ScrollExtent="50,30" Size="50,30" SourceRect="317,275,366,296" SourceResource="/images/window_elements_hr.dds" />
        <Image AbsorbsInput="false" Location="50,0" Name="ProgressBkg" PackSize="absolute,fixed" ScrollExtent="150,30" Size="150,30" SourceRect="395,276,487,300" SourceResource="/images/window_elements_hr.dds" />
        <Progressbar AbsorbsInput="false" Color="#8A2BE2" DynamicDataFilter="FBFB" BackgroundColor="#000000" DynamicData="/GameData.Self.Health" Location="54,3" Name="FooBar" PackSize="absolute,fixed" Progress="1.0" ScrollExtent="141,24" Size="141,24" Style="progressBar" />
        <Page AbsorbsInput="false" BackgroundOpacity="1.000" Location="54,2" Name="Frame" PackSize="absolute,fixed" ScrollExtent="141,26" Size="141,26" />
        <Text DynamicData="/GameData.Self.Health" Name="Percent" DynamicDataFilter="0001" OnTextChanged="
                ProgColor=#FF0000
                GreenColor=#00FF00
                OrangeColor=#D2691E
                isGreater=Parent.FooBar.Progress > 0.52
                ProgColor=isGreater ? OrangeColor : ProgColor
                isGreater=Parent.FooBar.Progress > 0.55
                ProgColor=isGreater ? GreenColor : ProgColor
                isGreater=Parent.FooBar.Progress > 0.85
                ProgColor=isGreater ? OrangeColor : ProgColor
                Parent.FooBar.Color=ProgColor
                Parent.Parent.Health.Color=ProgColor" />
    </Page>
    <Page AbsorbsInput="false" Name="WindowFrame" PackSize="a,a" ScrollExtent="210,40" Size="210,40" Visible="true">
        <Page AbsorbsInput="false" BackgroundOpacity="1.000" Name="Frame" PackLocation="left,top" PackSize="absolute,absolute" RStyleDefault="/WindowElements.DesktopWindowFrame.data.frame.rect" ScrollExtent="210,40" Size="210,40" />
        <Page AbsorbsInput="false" BackgroundOpacity="1.000" Name="Bkg" PackLocation="left,top" PackSize="absolute,absolute" RStyleDefault="/WindowElements.DesktopWindowFrame.data.bkg.rect" ScrollExtent="210,40" Size="210,40" />
    </Page>
</Page>

Any other ideas?
And thank you again for taking the time to look at this.

gm9 06-09-2009 09:58 AM

The only thing I immediately see is that you must remove the DynamicDataFilter from the "Percent" object (or set one that lets only the text through). Otherwise your color cycle is a bit messed up (it goes red->orange->green->orange) but that's just a style question.

oleega 06-11-2009 07:41 AM

LOL yes it ends on orange just so that I can see right away if it will work, which it does not.

If the color value gets through on the text object Progress, it should not have an effect on the progress bar should it?

oleega 06-11-2009 10:02 AM

I got it to work! By making the progress bar invisible and copying the progress attribute from it to the visible progress bar. Here is the code:

Code:

<?xml version="1.0" encoding="utf-8"?>
<Page eq2usescomwndcontrols="true" MaximumSize="1000,40" MinimumSize="85,40" Name="VSHealth" PackLocation="right,bottom" ScrollExtent="210,40" Size="210,40" UserMovable="true" UserResizable="true" version="1.1">
    <ProgressbarStyle Bar.Background="progressFill" Name="ProgressBar" />
    <ImageStyle Name="ProgressFill">
        <ImageFrame Name="progress_fill" Source="/images/window_elements_hr.dds" SourceRect="136,351,350,364" />
    </ImageStyle>
    <Text AbsorbsInput="false" Color="#FFFFFF" DynamicDataFilter="FBFB" DynamicData="/GameData.Self.Health" Font="/TextStyles.VeryLarge.VeryLargeStyle" Location="9,8" Name="Health" ScrollExtent="42,24" ShadowStyle="/ShadowStylesNew.Outline.style" Size="42,24" TextAlignment="Center" TextAlignmentVertical="Center" Visible="true">100</Text>
   
   
    <Page DynamicData="/GameData.Self.Health" DynamicDataFilter="0001" Location="5,5" Name="HealthBar" PackSize="absolute,fixed" ScrollExtent="200,30" Size="200,30" Visible="true">
        <Image AbsorbsInput="false" Name="Bkg" ScrollExtent="50,30" Size="50,30" SourceRect="317,275,366,296" SourceResource="/images/window_elements_hr.dds" />
        <Image AbsorbsInput="false" Location="50,0" Name="ProgressBkg" PackSize="absolute,fixed" ScrollExtent="150,30" Size="150,30" SourceRect="395,276,487,300" SourceResource="/images/window_elements_hr.dds" />
        <Progressbar Visible="false" AbsorbsInput="false" Color="#8A2BE2" BackgroundColor="#000000" DynamicData="/GameData.Self.Health" Location="54,3" Name="FooBar" PackSize="absolute,fixed" Progress="1.0" ScrollExtent="141,24" Size="141,24" Style="progressBar" />
        <Progressbar AbsorbsInput="false" Color="#8A2BE2"  BackgroundColor="#000000"  Location="54,3" Name="Bar" PackSize="absolute,fixed" Progress="1.0" ScrollExtent="141,24" Size="141,24" Style="progressBar" />
        <Page AbsorbsInput="false" BackgroundOpacity="1.000" Location="54,2" Name="Frame" PackSize="absolute,fixed" ScrollExtent="141,26" Size="141,26" />
        <Text DynamicData="/GameData.Self.Health" Name="Percent"  OnTextChanged="
                ProgColor=#FF0000
                GreenColor=#00FF00
                OrangeColor=#D2691E
                isGreater=Parent.FooBar.Progress > 0.52
                ProgColor=isGreater ? OrangeColor : ProgColor
                isGreater=Parent.FooBar.Progress > 0.55
                ProgColor=isGreater ? GreenColor : ProgColor
                isGreater=Parent.FooBar.Progress > 0.85
                ProgColor=isGreater ? OrangeColor : ProgColor
                Parent.Bar.Color=ProgColor
                Parent.Bar.Progress=Parent.FooBar.Progress
                Parent.Parent.Health.Color=ProgColor" />
    </Page>
    <Page AbsorbsInput="false" Name="WindowFrame" PackSize="a,a" ScrollExtent="210,40" Size="210,40" Visible="true">
        <Page AbsorbsInput="false" BackgroundOpacity="1.000" Name="Frame" PackLocation="left,top" PackSize="absolute,absolute" RStyleDefault="/WindowElements.DesktopWindowFrame.data.frame.rect" ScrollExtent="210,40" Size="210,40" />
        <Page AbsorbsInput="false" BackgroundOpacity="1.000" Name="Bkg" PackLocation="left,top" PackSize="absolute,absolute" RStyleDefault="/WindowElements.DesktopWindowFrame.data.bkg.rect" ScrollExtent="210,40" Size="210,40" />
    </Page>
</Page>

Thanks to both of you for holding my hand on this one!
Now, one more question lol
Is there a way to script the sprint ability? I cannot find the command
anywhere. "sprint" does not seem to work.

mother9987 06-11-2009 11:51 AM

I believe it's /useability Sprint

But that's entirely from memory.

oleega 06-11-2009 03:47 PM

yes thanks that worked!


All times are GMT -5. The time now is 07:20 AM.

vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI