Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release Animated Health Bar from Minecraft
#1
I created this health bar for my Minecraft mod, but i never finished him, so i prefer share the code that keep it for myself.

[Image: 3890AC754F32C9D214876684DC8C1554E10FFF4F]


PS: When you have only three hearts, the bar is animated as in Minecraft.
___________________________________________________________________________________________________________________________________

Put this line in init()
Code:
level thread precacheAll()

If you are a beginner modder, place it in onPlayerSpawned() under self waittill("spawned_player");
Code:
self.health = 100;
self.maxhealth = self.health;
self thread Health();

Place this code where you want
Code:
precacheAll()
{
    // Shaders
    precacheShader("health10");
    precacheShader("health9");
    precacheShader("health8");
    precacheShader("health7");
    precacheShader("health6");
    precacheShader("health5");
    precacheShader("health4");
    precacheShader("health3");
    precacheShader("health2_1");
    precacheShader("health2_2");
    precacheShader("health2_3");
    precacheShader("health1_1");
    precacheShader("health1_2");
    precacheShader("health1_3");
    precacheShader("health1_3");
}

Health()
{
    self endon("death");
    self endon("disconnect");

        Health = createIcon( "health10", 192, 48 );
        Health setPoint( "CENTER", "BOTTOM", 0, -20 );
        self thread Destroy( Health );

    for(;;)
    {
        if(self.health <= 100 && self.health >= 95)
        {
            Health setShader( "health10", 192, 48 );
        }

        else if(self.health < 95 && self.health >= 85)
        {
            Health setShader( "health9", 192, 48 );
        }

        else if(self.health < 85 && self.health >= 75)
        {
            Health setShader( "health8", 192, 48 );
        }

        else if(self.health < 75 && self.health >= 65)
        {
            Health setShader( "health7", 192, 48 );
        }

        else if(self.health < 65 && self.health >= 55)
        {
            Health setShader( "health6", 192, 48 );
        }

        else if(self.health < 55 && self.health >= 45)
        {
            Health setShader( "health5", 192, 48 );
        }

        else if(self.health < 45 && self.health >= 35)
        {
            Health setShader( "health4", 192, 48 );
        }

        else if(self.health < 35 && self.health >= 25)
        {
            Health setShader( "health3", 192, 48 );
        }

        else if(self.health < 25 && self.health >= 15)
        {
            Health setShader( "health2_1", 192, 48 );
            wait 0.1;
            Health setShader( "health2_2", 192, 48 );
            wait 0.1;
            Health setShader( "health2_3", 192, 48 );
            wait 0.1;
        }

        else if(self.health < 15 && self.health >= 1)
        {
            Health setShader( "health1_1", 192, 48 );
            wait 0.1;
            Health setShader( "health1_2", 192, 48 );
            wait 0.1;
            Health setShader( "health1_3", 192, 48 );
            wait 0.1;
        }

    wait .1;
    }
}

Destroy( hudElem )
{
    self waittill ( "death" );
    hudElem destroy();
}

Put these lines in mod.csv
Code:
material,health1_1
material,health1_2
material,health1_3
material,health2_1
material,health2_2
material,health2_3
material,health3
material,health4
material,health5
material,health6
material,health7
material,health8
material,health9
material,health10

And for finish, download images.zip, then unzip it into mp_yourmod and rebuild your mod.


Attached Files
.zip   images.zip (Size: 60.5 KB / Downloads: 14)
Reply

#2
cool, but takes many materials Sad
(For Black Ops obv)
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#3
(07-22-2012, 17:24)JayDi Wrote: cool, but takes many materials Sad
(For Black Ops obv)

Yes, but i'm noob modder, so i have many files, but the code is very simple. Tongue
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  [Request] Health and Points on hud source robinvm 7 5,589 10-27-2013, 08:23
Last Post: robinvm
  Making an apocalyptic themed Minecraft map AZUMIKKEL 54 29,068 08-31-2013, 02:54
Last Post: AZUMIKKEL
  FREE HELP SERVICE Minecraft Plugins Help Support KrypTiK 14 20,960 07-23-2013, 22:21
Last Post: KrypTiK
Sad Help Minecraft-Mojang Loading Screen, Than Black Screen mans123 6 6,804 06-01-2013, 19:40
Last Post: Shreddie
Brick [Release] Health on HUD (no crash :D) xtreme2010 3 6,217 04-21-2013, 00:20
Last Post: CHRISLUVMSR
Wink GSA Minecraft BillTurbineGR 10 6,453 02-15-2013, 14:14
Last Post: BillTurbineGR
  [Release] Show player health on HUD [Z00MBY] Alex 18 13,388 02-03-2013, 00:48
Last Post: JariZ
  Minecraft server Stocker 9 5,596 01-19-2013, 23:13
Last Post: Stocker
Rainbow [News] Minecraft mod Nekochan 15 7,684 01-17-2013, 10:15
Last Post: narkos
Rainbow [News] Minecraft PE server. Nekochan 3 17,292 01-16-2013, 16:14
Last Post: 99IRock

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.