1
+ extend class MyCustomHUD {
2
+
3
+ void DrawCurrentTargetHPBar() {
4
+ let handler = CurrentTargetHandler(EventHandler . Find(' CurrentTargetHandler' ));
5
+ if (handler . currentTargetMonster == null || handler . currentTargetMonster. Health <= 0 ) {
6
+ return ;
7
+ }
8
+
9
+ let plr = RwPlayer(CPlayer . mo);
10
+ if (!plr) return ;
11
+
12
+ DrawHpBarRect(handler . currentTargetMonster, handler . currentMonsterAffixator);
13
+ }
14
+
15
+ void DrawHpBarRect(Actor currentTargetMonster, RwMonsterAffixator currAffixator) {
16
+ let borderThickness2 = rwhud_hpbar_border_thickness * 2 ;
17
+ let str = currentTargetMonster . GetTag()..String . Format(" (%d/%d)" , (currentTargetMonster . health, currentTargetMonster . GetMaxHealth()));
18
+ let HPBarWidth = max(rwhud_hpbar_min_width, monsterNameFont . mFont. StringWidth(str) + 2 * borderThickness2);
19
+
20
+ // The background rectangle
21
+ let w = HPBarWidth * CleanXFac_1;
22
+ let h = rwhud_hpbar_height * CleanYFac_1;
23
+ let x = Screen . GetWidth()/2 - w/ 2 ;
24
+ let y = rwhud_hpbar_y_position * CleanYFac_1;
25
+ Screen . Dim(rwhud_monster_hpbar_border_color, 0.65 , x, y, w, h, STYLE_Translucent);
26
+
27
+ // The HP rectangle
28
+ w = math . remapIntRange(currentTargetMonster . health, 0 , currentTargetMonster . GetMaxHealth(), 0 , (HPBarWidth - borderThickness2)) * CleanXFac_1;
29
+ x += rwhud_hpbar_border_thickness * CleanXFac_1;
30
+ h = (rwhud_hpbar_height - borderThickness2) * CleanYFac_1;
31
+ y += rwhud_hpbar_border_thickness * CleanYFac_1;
32
+ Screen . Dim(rwhud_monster_hpbar_color, 0.3 , x, y, w, h, STYLE_Translucent);
33
+
34
+ let clr = Font . CR_WHITE;
35
+ if (currAffixator) {
36
+ clr = PickColorForAffixableItem(currAffixator);
37
+ }
38
+
39
+ // Text
40
+ let fontHeight = monsterNameFont . mFont. GetHeight();
41
+ let textYPos = y+(h/ 2 )-(fontHeight/ 2 )-rwhud_hpbar_border_thickness;
42
+ // DrawString(monsterNameFont, str, (0, rwhud_hpbar_y_position * CleanYFac_1), DI_SCREEN_CENTER_TOP|DI_TEXT_ALIGN_CENTER, clr);
43
+ Screen . DrawText(monsterNameFont . mFont, clr,
44
+ Screen . GetWidth()/2 - monsterNameFont . mFont. StringWidth(str), textYPos+ rwhud_monster_name_y_offset,
45
+ str, DTA_SCALEX, CleanXFac_1, DTA_SCALEY, CleanYFac_1);
46
+
47
+ // Affixes
48
+ if (currAffixator) {
49
+ let text = currAffixator . getDescriptionString();
50
+ Screen . DrawText(monsterNameFont . mFont, Font . CR_GRAY,
51
+ Screen . GetWidth()/2 - monsterNameFont . mFont. StringWidth(text), textYPos+ rwhud_monster_affixes_y_offset,
52
+ text, DTA_SCALEX, CleanXFac_1, DTA_SCALEY, CleanYFac_1, DTA_COLOR, 0xFF000000 | rwhud_monster_affixes_text_color);
53
+ }
54
+ }
55
+ }
0 commit comments