Advertisement
ywkls

Boss Health Bar

Aug 26th, 2019
95
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ffc script BossHealthBar{
  2. void run(int enemyid, int message, int delay){
  3. npc n;
  4. int InitHP;
  5. int OldHP;
  6. int strname[256];
  7. Waitframes(delay+4);
  8. n = LoadNPCOf(enemyid);
  9. if(!message)
  10. n->GetName(strname);
  11. else
  12. GetMessage(message, strname);
  13. InitHP = n->HP;
  14. OldHP = n->HP;
  15. int Damage;
  16. int DamageCounter;
  17. while(n->isValid()){
  18. if(n->HP!=OldHP){
  19. if(n->HP<OldHP){
  20. Damage = OldHP-Max(n->HP, 0);
  21. DamageCounter = 32;
  22. }
  23. OldHP = n->HP;
  24. }
  25. Screen->Rectangle(6, 8, 16, 248, 19, 0x0F, 1, 0, 0, 0, true, 128);
  26. if(n->HP>0)
  27. Screen->Rectangle(6, 9, 17, 9+Clamp(238*(n->HP/InitHP), 1, 238), 18, 0x82, 1, 0, 0, 0, true, 128);
  28. Screen->DrawString(6, 9, 11, FONT_Z3SMALL, 0x0F, -1, TF_NORMAL, strname, 128);
  29. Screen->DrawString(6, 8, 10, FONT_Z3SMALL, 0x01, -1, TF_NORMAL, strname, 128);
  30. if(DamageCounter>0){
  31. int Offset = -4;
  32. if(Damage>999)
  33. Offset = -16;
  34. else if(Damage>99)
  35. Offset = -12;
  36. else if(Damage>9)
  37. Offset = -8;
  38. if(n->HP>0)
  39. Screen->Rectangle(6, 9+Clamp(238*(n->HP/InitHP), 1, 238), 17,
  40. 9+Clamp(238*(n->HP/InitHP), 1, 238)+Clamp(238*(Damage/InitHP)*(DamageCounter/32),
  41. 1, 238), 18, 0x83, 1, 0, 0, 0, true, 128);
  42. Screen->DrawInteger(6, 249+Offset, 11, FONT_Z3SMALL, 0x0F, -1, -1, -1, Damage, 0, 128);
  43. Screen->DrawInteger(6, 248+Offset, 10, FONT_Z3SMALL, 0x01, -1, -1, -1, Damage, 0, 128);
  44. DamageCounter--;
  45. }
  46. Waitframe();
  47. }
  48. }
  49. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement