-
Notifications
You must be signed in to change notification settings - Fork 0
/
hp-warn.js
33 lines (33 loc) · 949 Bytes
/
hp-warn.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
addons.register({
init: function(events)
{
events.on('onGetStats', this.onLowHP.bind(this));
},
onLowHP: function(stats)
{
var uiContainer = $('.ui-container');
if( ! this.hpWarning)
{
this.hpWarning = $('<div class="HP-Warning"></div>').appendTo(uiContainer);
}
var hpMax = stats.hpMax;
var hpCur = stats.hp;
var hpMin = (hpMax / 100) * 30;
if(hpCur <= hpMin)
{
$('.ui-container').addClass('HP-warning-splash');
if($('.HP-Warning').html().length <= 1)
{
$('.HP-Warning').html('You have LOW HP!');
}
}
else
{
$('.ui-container').removeClass('HP-warning-splash');
if($('.HP-Warning').html().length > 0)
{
$('.HP-Warning').html(' ');
}
}
},
});