SHOW:
|
|
- or go back to the newest paste.
1 | local m_fOverheadNumberZSpeed = 170.0 | |
2 | local m_OverheadNumberColorShieldMin = rgb(255, 255, 255) | |
3 | local m_OverheadNumberColorShieldMax = rgb(83, 83, 255) | |
4 | local m_fOverheadNumberTotalTime = 1.70 | |
5 | local m_fOverheadNumberFadeTime = 1.30 | |
6 | local m_fOverheadNumberScaleTime = 0.450 | |
7 | local m_fOverheadNumberMaxScaleAmount = 0.650 | |
8 | local m_fOverheadNumberColorizeTimeMin = 0.250 | |
9 | local m_fOverheadNumberColorizeTimeMax = 0.50 | |
10 | ||
11 | -- Linear interpolation utility function | |
12 | function lerp(a, b, x) | |
13 | return a + (b - a) * x | |
14 | end | |
15 | ||
16 | -- Simple number creation, just add the number to the list | |
17 | function onDamageNumberCreate(dam_nums, number, loc, is_shield) | |
18 | local num = DamageNumber(number, m_fOverheadNumberTotalTime, loc, is_shield) | |
19 | num.color = damageNumbersColorMin | |
20 | dam_nums:add(num) | |
21 | end | |
22 | ||
23 | -- Numbers update, most of the code is there to match HiRez's implementation | |
24 | function onDamageNumberUpdate(dam_nums, hud, delta) | |
25 | local i = 0 | |
26 | while i < dam_nums:size() do | |
27 | local curr = dam_nums:get(i) | |
28 | curr.time = curr.time - delta | |
29 | if curr.time <= 0 then | |
30 | dam_nums:remove(i) | |
31 | i = i - 1 | |
32 | else | |
33 | local accu_time = 1.70 - curr.time | |
34 | if curr.number > damageNumbersLimit then | |
35 | curr.location.z = curr.location.z + delta * m_fOverheadNumberZSpeed | |
36 | end | |
37 | if accu_time > m_fOverheadNumberColorizeTimeMax then | |
38 | if curr.shieldDamage then | |
39 | curr.color = m_OverheadNumberColorShieldMax | |
40 | else | |
41 | curr.color = damageNumbersColorMax | |
42 | end | |
43 | else | |
44 | if accu_time > m_fOverheadNumberColorizeTimeMin and m_fOverheadNumberColorizeTimeMin < m_fOverheadNumberColorizeTimeMax then | |
45 | local alpha = (m_fOverheadNumberColorizeTimeMin - (m_fOverheadNumberColorizeTimeMax - accu_time)) / (m_fOverheadNumberColorizeTimeMax - m_fOverheadNumberColorizeTimeMin) | |
46 | local cmin, cmax | |
47 | ||
48 | if curr.shieldDamage then | |
49 | cmin = m_OverheadNumberColorShieldMin | |
50 | cmax = m_OverheadNumberColorShieldMax | |
51 | else | |
52 | cmin = damageNumbersColorMin | |
53 | cmax = damageNumbersColorMax | |
54 | end | |
55 | curr.color.r = math.floor(lerp(cmin.r, cmax.r, alpha)) | |
56 | curr.color.g = math.floor(lerp(cmin.g, cmax.g, alpha)) | |
57 | curr.color.b = math.floor(lerp(cmin.b, cmax.b, alpha)) | |
58 | end | |
59 | end | |
60 | ||
61 | if curr.time < m_fOverheadNumberFadeTime and m_fOverheadNumberFadeTime > 0 then | |
62 | curr.color.a = math.floor((curr.time / m_fOverheadNumberFadeTime) * 255.0) | |
63 | end | |
64 | ||
65 | if accu_time < m_fOverheadNumberScaleTime then | |
66 | local peak = m_fOverheadNumberScaleTime / 2.0 | |
67 | if accu_time < peak then | |
68 | curr.scale = 1.0 + ((accu_time / peak) * m_fOverheadNumberMaxScaleAmount) | |
69 | else | |
70 | curr.scale = 1.0 + ((1.0 - ((accu_time - (m_fOverheadNumberScaleTime - peak)) / (m_fOverheadNumberScaleTime - peak))) * m_fOverheadNumberMaxScaleAmount) | |
71 | end | |
72 | elseif curr.scale ~= 1.0 then | |
73 | curr.scale = 1.0 | |
74 | end | |
75 | ||
76 | local loc = Vector(curr.location.x, curr.location.y, curr.location.z) | |
77 | if isOnScreen(hud, loc) then | |
78 | loc = project(hud, loc) | |
79 | loc.z = curr.location.w | |
80 | if curr.shieldDamage then | |
81 | loc.y = loc.y - 20.0 | |
82 | end | |
83 | ||
84 | curr.scale = curr.scale * damageNumbersScale | |
85 | loc.x = loc.x + damageNumbersOffsetX | |
86 | loc.y = loc.y + damageNumbersOffsetY | |
87 | ||
88 | -- Custom part, in this case draw a dot instead of the number if it's under the threshold | |
89 | local str = "." | |
90 | if curr.number > damageNumbersLimit then | |
91 | str = tostring(curr.number) | |
92 | else | |
93 | loc.x = loc.x + 10 | |
94 | loc.y = loc.y + 10 | |
95 | end | |
96 | drawDamageNumber(hud, str, curr.color, loc, curr.scale, curr.scale) | |
97 | end | |
98 | end | |
99 | i = i + 1 | |
100 | end | |
101 | end |