-
Notifications
You must be signed in to change notification settings - Fork 10
/
hologramanticringelib.txt
114 lines (101 loc) · 3.93 KB
/
hologramanticringelib.txt
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
@name hologramanticringelib
@model models/bull/gates/microcontroller1.mdl
#[ ]#
## E2 Library: hologramAntiCringeLib ##
## ##
## Take back control of your holoModelAny holos ##
## with weird and nonsensical coordinate centers! ##
## ##
## WARNING: ##
## Extended holograms will break if moved without ##
## the library's knowledge! Don't parent them! ##
#[ ]#
if( first() ){
###############
##
# antiCringeExtend( HoloID ) OR <BetterHolo>:antiCringeExtend( )
# Extends the provided hologram to work with the anticringe functions.
# Call one of these on your hologram BEFORE you use the other functions in this library.
#
function number:antiCringeExtend(){
local Ent = holoEntity(This)
Ent["ang",angle] = Ent:angles()
Ent["pos",vector] = Ent:pos()
Ent["scl",vector] = holoScale(This)
Ent["c",vector] = -Ent:boxCenter()
Ent["o",angle] = ang(0)
Ent["model_scl",vector] = holoScaleUnits(This)
}
function antiCringeExtend(This){
This:antiCringeExtend()
}
###############
##
# holoSetCenter( Id, Center:vector )
# Use this to set the "true center" of an antiCringeExtended hologram
# NOTE: Center is local to the hologram, and not to the world
#
function holoSetCenter( Id, Center:vector ){
local Ent = holoEntity(Id)
Ent["c",vector] = -Center
}
###############
##
# holoOrient( Id, Default:angle )
# Use this to set the "default angles" of an antiCringeExtended hologram
# NOTE: Center is local to the hologram, and not to the world
#
function holoOrient( Id, Default:angle ){
local Ent = holoEntity(Id)
Ent["o",angle] = Default
}
###############
##
# holoAngExt( Id, A:angle )
# Use this where you would normally use holoAng on a normal hologram.
#
function holoAngExt( Id, A:angle ){
local Ent = holoEntity(Id)
Ent["ang",angle] = toWorldAng(vec(),Ent["o",angle],vec(),A)
holoAng(Id, Ent["ang",angle])
holoPos(Id, Ent["pos",vector] + (Ent["c",vector]*Ent["scl",vector]):rotate(Ent["ang",angle]) )
}
###############
##
# holoPosExt( Id, A:vector )
# Use this where you would normally use holoPos on a normal hologram.
#
function holoPosExt( Id, P:vector ){
local Ent = holoEntity(Id)
Ent["pos",vector] = P
holoPos(Id, P + (Ent["c",vector]*Ent["scl",vector]):rotate(Ent["ang",angle]) )
}
###############
##
# holoScaleExt( Id, S:vector )
# Use this where you would normally use holoScale on a normal hologram.
#
function holoScaleExt( Id, S:vector ){
local Ent = holoEntity(Id)
Ent["scl",vector] = S
holoPos(Id, Ent["pos",vector] + (Ent["c",vector]*S):rotate(Ent["ang",angle]) )
holoScale(Id, S)
}
###############
##
# holoScaleUnitsExt( Id, S:vector )
# Use this where you would normally use holoScaleUnits on a normal hologram.
#
function holoScaleUnitsExt( Id, S:vector ){
local Ent = holoEntity(Id)
S = S / Ent["model_scl",vector]
Ent["scl",vector] = S
holoPos(Id, Ent["pos",vector] + (Ent["c",vector]*S):rotate(Ent["ang",angle]) )
holoScale(Id, S)
}
if(entity():model() == "models/bull/gates/microcontroller1.mdl"){
selfDestruct()
error("This is a library; #include it in something.")
}
# see hologramanticringelib_demo.txt for a demo of what this library does and how to use it
}