This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathspellesp.lua
162 lines (151 loc) · 4.96 KB
/
spellesp.lua
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
local function get_entities( start, stop )
local t = {}
start = start or 1
stop = stop or 2048
for index = start, stop do
local e = entities.GetByIndex( index )
if e and not e:IsDormant() then
t[index] = e
end
end
return t
end
local function dump_materials( ... )
local include = {}
local args = { ... }
if #args == 0 then
include['*'] = true
else
for pos, value in ipairs( args ) do
include[value] = true
end
end
local t = {}
materials.Enumerate( function( mat )
local group = mat:GetTextureitem_name()
if not t[group] then
t[group] = {}
end
if include[group] or include['*'] then
t[group][mat:GetName()] = mat
end
end )
return t
end
local function round( num, numDecimalPlaces )
local mult = 10 ^ (numDecimalPlaces or 0)
return math.floor( num * mult + 0.5 ) / mult
end
local translations = {
["ITEM_SPELL"] = {
["localized_string_key"] = "TF_Spellbook_Type",
["localized_fallback"] = "Spell"
},
["ITEM_SPELL_RARE"] = {
["localized_fallback"] = "Rare Spell"
}
}
for k, t in pairs( translations ) do
local localized_str = client.Localize( t["localized_string_key"] or '' )
::checkpoint::
if not localized_str or #localized_str:gsub( "%s", '' ) < 1 then
localized_str = t["localized_fallback"]
end
translations[k] = localized_str
end
local spell_e = {
[-2] = "", -- Rolling spell
[-1] = nil,
[0] = "Fireball",
"Swarm of Bats",
"Overheal",
"Pumpkin MIRV",
"Blast Jump",
"Stealth",
"Shadow Leap",
"Ball O' Lightning",
"Power Up",
"Meteor Shower",
"Summon MONOCULUS",
"Skeletons Horde",
"Boxing Rocket",
"B.A.S.E. Jump",
"Overheal",
"Bomb Head",
}
for index = 0, #spell_e do
local name = spell_e[index]
if translations[name] then
spell_e[index] = translations[name]
end
end
local esp = {}
local models_struct = {
["ITEM_SPELL"] = { "models/props_halloween/hwn_spellbook_incomplete.mdl",
"models/props_halloween/hwn_spellbook_magazine.mdl",
"models/props_halloween/hwn_spellbook_page.mdl",
"models/props_halloween/hwn_spellbook_upright.mdl", "models/items/crystal_ball_pickup.mdl",
"models/props_monster_mash/flask_vial_green.mdl" },
["ITEM_SPELL_RARE"] = { "models/props_halloween/hwn_spellbook_upright_major.mdl",
"models/items/crystal_ball_pickup_major.mdl",
"models/props_monster_mash/flask_vial_purple.mdl" }
}
local models = {}
for item_name, group in pairs( models_struct ) do
item_name = translations[item_name]
esp[item_name] = {}
for _, item in pairs( group ) do
models[item] = item_name
end
-- models_struct[item_name] = nil
end
callbacks.Register( "DrawModel", function( ctx )
local name, entity
name = ctx:GetModelName()
entity = ctx:GetEntity()
local item_name = models[name]
if item_name then
esp[item_name][entity:GetIndex()] = entity
end
end )
callbacks.Register( "Draw", function()
local screenwidth, screenheight = draw.GetScreenSize()
local widthcenter, heightcenter = screenwidth // 2, screenheight // 2
draw.SetFont( 21 )
draw.Color( 255, 255, 255, 255 )
for item_name, group in pairs( esp ) do
for networkindex, entity in pairs( group ) do
if entity:IsDormant() or not entity:IsValid() then
group[networkindex] = nil
goto done
end
local origin, w2s
origin = entity:GetAbsOrigin()
w2s = client.WorldToScreen( origin )
if w2s then
draw.Text( w2s[1], w2s[2], item_name )
end
end
::done::
end
local spellbooks = entities.FindByClass( 'CTFSpellBook' )
for networkindex, entity in pairs( spellbooks ) do
if entity:GetPropEntity( "m_hOwner" ) == entities.GetLocalPlayer() then
local spellindex, spellcharges, time_before_use_spell
spellindex = entity:GetPropInt( "m_iSelectedSpellIndex" )
spellcharges = entity:GetPropInt( "m_iSpellCharges" )
time_before_use_spell = entity:GetPropFloat( "m_flTimeNextSpell" ) - globals.CurTime()
if spellindex ~= -1 and spellcharges >= 1 then
local spellname = spell_e[spellindex]
local w, h = widthcenter - (draw.GetTextSize( spellname ) // 2), heightcenter + 50
draw.Text( w, h, spellname )
draw.Text( w, h + 20, spellcharges .. " charges left" )
if time_before_use_spell > 0 then
draw.Text( w, h + 50, "Wait " .. round( time_before_use_spell, 2 ) .. " before using spell" )
end
end
goto done
end
::done::
end
end )