Advertisement
Guest User

Health HUD

a guest
Jun 30th, 2017
565
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define init
  2. global.offset = 100;
  3. global.lasthitenemy = 0;
  4. global.hoverId = 0;
  5. #define draw
  6. with(Player){
  7.     var _things = [prop, enemy];
  8.     for(var i = 0; i < array_length_1d(_things); i += 1) {
  9.         with(instances_matching(_things[i],"id",global.hoverId)) {
  10.             if (my_health > 0) {
  11.                 if(maxhealth/2 > 100){
  12.                     var dx = 100;
  13.                 }else dx = maxhealth/2;
  14.                 draw_healthbar(x-dx, y-1, x+dx, y+2, (my_health / maxhealth) * 100, c_black, c_red, c_lime, 0, true, true)
  15.                 draw_text(x,y,string(my_health)+"/"+string(maxhealth));
  16.             }
  17.         }
  18.     }
  19. }
  20. #define draw_gui
  21. with(Player){
  22.     var _things = [prop, enemy];
  23.     for(var i = 0; i < array_length_1d(_things); i += 1) {
  24.         with(instances_matching(_things[i],"id",global.hoverId)) {
  25.             if (my_health > 0 && "_name" in self) {
  26.                 draw_set_colour(c_black);
  27.                 draw_roundrect(250, -1+global.offset, 319, 70+global.offset, 0);
  28.                 draw_set_colour(c_white);
  29.                 draw_roundrect(252, 1+global.offset, 317, 68+global.offset, 0);
  30.                 draw_healthbar(253, 50+global.offset, 317, 68+global.offset, (my_health / maxhealth) * global.offset, c_black, c_red, c_lime, 0, true, false);
  31.                 //draw_set_font(-1);
  32.                 draw_text_transformed(286,6+global.offset,string_upper(_name),0.75,0.75,0);
  33.                 draw_set_colour(c_black);
  34.                 draw_text(286,56+global.offset,string(my_health)+"/"+string(maxhealth));
  35.                 draw_text_transformed(285,5+global.offset,string_upper(_name),0.75,0.75,0);
  36.                 draw_set_colour(c_white);
  37.  
  38.                 draw_text(285,55+global.offset,string(my_health)+"/"+string(maxhealth));
  39.                 draw_sprite_stretched(sprite_index, -1, 270, 15+global.offset, sprite_width / (sprite_width/30), sprite_height / (sprite_height/30));
  40.                 draw_set_colour(c_black);
  41.                 draw_rectangle(270,15+global.offset,300,45+global.offset,1);
  42.             }
  43.         }
  44.     }
  45. }
  46. #define step
  47.     with(enemy){
  48.         if (x > view_xview && x < view_xview + game_width) && (y > view_yview && y < view_yview + game_height){
  49.             drawme = 1
  50.         }else drawme = 0;
  51.     }
  52.     with(prop){
  53.         if (x > view_xview && x < view_xview + game_width) && (y > view_yview && y < view_yview + game_height){
  54.             drawme = 1
  55.         }else drawme = 0;
  56.     }
  57.     with(enemy){
  58.         if "_name" not in self{
  59.             var _nombre = object_get_name(object_index);
  60.             // Specific aliases for enemies.
  61.             // Read through the list and you'll understand why they're needed
  62.             switch(_nombre){
  63.                 case "EnemyHorror": _name = "Horror";break;
  64.                 case "BanditBoss": _name = "Big Bandit";break;
  65.                 case "Nothing": _name = "Throne"; break;
  66.                 case "Nothing2": _name = "Throne 2"; break;
  67.                 case "MeleeBandit": _name = "Assassin"; break;
  68.                 case "Exploder": _name = "Frog"; break;
  69.                 case "SuperFrog": _name = "Fetid Frog"; break;
  70.                 case "FastRat": _name = "Fetid Rat"; break;
  71.                 case "Ratking": _name = "King Rat"; break;
  72.                 case "BuffGator": _name = "Buff Gator"; break;
  73.                 case "FrogQueen": _name = "Ballmum"; break;
  74.                 case "SnowBotCar": _name = "SnowBot"; break;
  75.                 case "Last": _name = "IDPD Captain"; break;
  76.                 default: _name = _nombre; break;
  77.             }
  78.             // Streamlined replacement of parts of an enemy's name
  79.             // This mostly applies to things later in the game (Elites, Crystals, etc)
  80.             _name = string_replace_all(_name,"Inv","Cursed ");
  81.             _name = string_replace_all(_name,"Gold","Golden ");
  82.             _name = string_replace_all(_name,"Elite","Elite ");
  83.             _name = string_replace_all(_name,"Crystal"," Crystal");
  84.             _name = string_replace_all(_name,"ScrapBoss","Big Dog ");
  85.             _name = string_replace_all(_name,"Jungle","Jungle ");
  86.             _name = string_replace_all(_name,"Maggot"," Maggot");
  87.            
  88.             // Cleanup. Deletes spaces at the beginning and end of the names.
  89.             if string_char_at(_name,1) = " "{
  90.                 _name = string_delete(_name,1,1);
  91.             }
  92.             if string_char_at(_name,string_length(_name)) = " "{
  93.                 _name = string_delete(_name,string_length(_name),1);
  94.             }
  95.            
  96.             // For debugging purposes, we display their object names and aliases in chat
  97.             //trace(_nombre,'==>','"' + _name + '"',);
  98.         }
  99.     }
  100.     with(prop){
  101.        
  102.         if "_name" not in self{
  103.             var _nombre = object_get_name(object_index);
  104.             // Specific aliases for props.
  105.             // Read through the list and you'll understand why they're needed
  106.             switch(_nombre){
  107.                 case "CarVenus2": _name = "YV's Car";break;
  108.                case "RadMaggotChest": _name = "Rad MaggotChest";break;
  109.                case "MeleeFake": _name = "Faking Assassin";break;
  110.                case "CarVenus": _name = "YV's Car";break;
  111.                 case "CarVenusFixed": _name = "YV's Car";break;
  112.                case "GeneratorInactive": _name = "IdleGenerator";break;
  113.                case "NothingInactive": _name = "Throne";break;
  114.                case "BecomeScrapBoss": _name = "Big Dog";break;
  115.                case "NothingIntroMask": _name = "Throne"; break;
  116.                default: _name = _nombre; break;
  117.            }
  118.            // Streamlined replacement of parts of an enemy's name
  119.             // This mostly applies to things later in the game (Elites, Crystals, etc)
  120.             _name = string_replace_all(_name,"Barrel"," Barrel");
  121.             _name = string_replace_all(_name,"Generator"," Generator");
  122.             _name = string_replace_all(_name,"Statue"," Statue");
  123.             _name = string_replace_all(_name,"Mine"," Mine");
  124.             _name = string_replace_all(_name,"Flower"," Flower");
  125.             _name = string_replace_all(_name,"Plant"," Plant");
  126.             _name = string_replace_all(_name,"Pot"," Pot");
  127.             _name = string_replace_all(_name,"Pile"," Pile");
  128.             _name = string_replace_all(_name,"Night","");
  129.             _name = string_replace_all(_name,"TV"," TV");
  130.             _name = string_replace_all(_name,"Crystal"," Crystal");
  131.             _name = string_replace_all(_name,"Tube"," Tube");
  132.             _name = string_replace_all(_name,"Box"," Box");
  133.             _name = string_replace_all(_name,"Skull"," Skull");
  134.             _name = string_replace_all(_name,"Machine"," Machine");
  135.             _name = string_replace_all(_name,"Light"," Light");
  136.             _name = string_replace_all(_name,"Egg"," Egg");
  137.             _name = string_replace_all(_name,"Couch"," Couch");
  138.             _name = string_replace_all(_name,"Chest"," Chest");
  139.            
  140.             // Cleanup. Deletes spaces at the beginning and end of the names.
  141.             if string_char_at(_name,1) = " "{
  142.                 _name = string_delete(_name,1,1);
  143.             }
  144.             if string_char_at(_name,string_length(_name)) = " "{
  145.                 _name = string_delete(_name,string_length(_name),1);
  146.             }
  147.            
  148.             // For debugging purposes, we display their object names and aliases in chat
  149.             //trace("P: ",_nombre,'==>','"' + _name + '"',);
  150.         }
  151.     }
  152.    
  153. with instances_matching(projectile,"team",2){
  154.     script_bind_step(trackenemy,1,self,x,y)
  155. }
  156. with (enemy){
  157.     if id = global.hoverId{
  158.         image_blend = c_red
  159.     }
  160.     else image_blend = c_white
  161. }
  162. with (prop){
  163.     if id = global.hoverId{
  164.         image_blend = c_red
  165.     }
  166.     else image_blend = c_white
  167. }
  168. #define trackenemy
  169. ed = 100000;
  170. pd = 100000;
  171. with instance_nearest(argument1,argument2,enemy) if distance_to_point(argument1,argument2) < game_height{
  172.     var ed = point_distance(argument1, argument2, x, y);
  173.     var ei = id;
  174. }
  175. with instance_nearest(argument1,argument2,prop) if distance_to_point(argument1,argument2) < game_height {
  176.     pd = game_height;
  177.     var pi = id;
  178.     if(maxhealth > 2){
  179.         var pd = point_distance(argument1, argument2, x, y);
  180.         var pi = id;
  181.     }
  182. }
  183. if(pi > 0 || ei> 0){
  184.     if(pd < ed){
  185.         global.hoverId = pi;
  186.     }else global.hoverId = ei;
  187. }
  188. instance_destroy()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement