• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Turn Based Battle System Speed Bar

Status
Not open for further replies.
Level 2
Joined
Dec 19, 2012
Messages
11
Hello everybody! I'm here again searching for some help to do something I think it's possible but i don't know how to. Well, here's my situation.

First of all: Have you ever played a custom campaign called HeroRPG? If so, things will be easier to understand. If not, you should play, its an awesome Final Fantasy like campaign.

I played the campaign and I liked the idea so much that I wanted to make a Turn Based Battle System for a four players RPG map. Everything was going quite well when I came into one easy but laborious situation: the speed bars.

An example of how one speed bar may work:
  • Speed Bar
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set S_Player_Speed_Maximum[1] = (S_Player_Speed_Maximum[1] + S_Player_Speed[1])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • S_Player_Speed_Maximum[1] Greater than or equal to 10.00
          • S_Player_Speed_Maximum[1] Less than 20.00
        • Then - Actions
          • Set S_Player_Speed_Bar[1] = |cAB2A2A||r|||||||||
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • S_Player_Speed_Maximum[1] Greater than or equal to 20.00
          • S_Player_Speed_Maximum[1] Less than 30.00
        • Then - Actions
          • Set S_Player_Speed_Bar[1] = |cAB2A2A|||r||||||||
        • Else - Actions
      • -------- Continues... --------
The problem comes with the "Set S_Player_Speed_Bar[1] = ||||||||||" I want to colorize some part of the text that represents the speed bar's completion. I can just imagine using a lot of IF/THEN/ELSE to verify if the "Speed Bar's Maximum" is between 2 numbers and then colorizing the right part of the text (Like I did in the example).

To be precise, i just want to know if there is a way to insert a string (the hex color code) between 2 specific string spaces (that will be calculated using the current Speed Bar Maximum's value) and after, using the |r to stop the colorizing.

Thanks for the assistance and sorry for any English mistakes. I'm not a native English speaker :p
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
This is how I colour an HP bar:
  • SQDSYS Loop Health Bar
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in SQDSYS_LeadersGroup and do (Actions)
        • Loop - Actions
          • Set tempSquadId = SQDSYS_LeaderIsInSquadId[(Custom value of (Picked unit))]
          • Floating Text - Change the position of SQDSYS_Floater[tempSquadId] to (Picked unit) with Z offset 64.00
          • Set tempCurrentHealth = 0.00
          • Set tempTotalHealth = 0.00
          • Set tempCurrentHealth = (tempCurrentHealth + (Life of (Picked unit)))
          • Set tempTotalHealth = (tempTotalHealth + (Max life of (Picked unit)))
          • Unit Group - Pick every unit in SQDSYS_SquadGroup[tempSquadId] and do (Actions)
            • Loop - Actions
              • Set tempCurrentHealth = (tempCurrentHealth + (Life of (Picked unit)))
              • Set tempTotalHealth = (tempTotalHealth + (Max life of (Picked unit)))
          • Set tempString = PlayerColour[PlayerColourChosen[(Player number of (Owner of (Picked unit)))]]
          • For each (Integer A) from 0 to (Number of units in SQDSYS_SquadGroup[tempSquadId]), do (Actions)
            • Loop - Actions
              • Set tempString = (tempString + lllllll )
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in SQDSYS_SquadGroup[tempSquadId]) Not equal to 6
            • Then - Actions
              • Set tempString = (tempString + |cff000000)
              • For each (Integer A) from 1 to (6 - (Number of units in SQDSYS_SquadGroup[tempSquadId])), do (Actions)
                • Loop - Actions
                  • Set tempString = (tempString + lllllll )
            • Else - Actions
          • Floating Text - Change text of SQDSYS_Floater[tempSquadId] to tempString using font size 5.00
The idea is that you concatenate many small strings, e.g.
|cffff0000
+ l
+ l
+ l
+ |r|cff00ff00
+ l
+ l

I used a for loop to get the right number of characters for the string in my health bar.
 
Status
Not open for further replies.
Top