-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZSCRIPT.zs
178 lines (150 loc) · 5 KB
/
ZSCRIPT.zs
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
version "4.7.1"
/*
Shader controller base class
This allows mappers to control shaders using the GiveInventory/TakeInventory
ACS functions.
Do not use this directly! Instead, make an actor class that inherits from
ShaderControl. Set the ShaderControl.Shader property to the name of the
shader to control. The shader must be defined in GLDEFS.
To enable a shader, give 2 of the ShaderControl subclass item to the player.
For example:
GiveInventory("ShakeShaderControl", 2);
To disable a shader, take 1 of the shader control item away so that the
player only has 1 of said item. For example:
TakeInventory("ShakeShaderControl", 1);
or
SetInventory("ShakeShaderControl", 1);
Note that the latter requires you to define the SetInventory function in
your ACS code.
*/
class ShaderControl : Inventory
{
string ShaderToControl;
property Shader: ShaderToControl;
Default
{
Inventory.MaxAmount 0x7fffffff;
}
virtual ui void SetUniforms(PlayerInfo p, RenderEvent e) {}
}
class CustomShaderHandler : StaticEventHandler
{
override void RenderOverlay(RenderEvent e)
{
PlayerInfo p = players[consoleplayer];
ThinkerIterator shaderIter = ThinkerIterator.Create("ShaderControl");
ShaderControl shaderControl;
while (shaderControl = ShaderControl(shaderIter.Next()))
{
if (shaderControl.Owner && shaderControl.Owner == p.mo) {
//Console.Printf("Shader: %s", shaderControl.ShaderToControl);
if (shaderControl.amount >= 2)
{
Shader.SetUniform1f(p, shaderControl.ShaderToControl, "timer", gametic + e.FracTic);
Shader.SetUniform1f(p, shaderControl.ShaderToControl, "amount", shaderControl.amount - 1);
Shader.SetUniform1f(p, shaderControl.ShaderToControl, "alpha", shaderControl.alpha);
shaderControl.SetUniforms(p, e);
Shader.SetEnabled(p, shaderControl.ShaderToControl, true);
}
else
{
Shader.SetEnabled(p, shaderControl.ShaderToControl, false);
}
}
}
}
}
// Actor that does the bare minumum of ticking
// Use for static, non-interactive actors
//
// Derived from bits and pieces of p_mobj.cpp
class SimpleActor : Actor
{
Vector2 floorxy;
Vector3 oldpos;
override void Tick()
{
if (IsFrozen()) { return; }
Vector2 curfloorxy = (curSector.GetXOffset(sector.floor), curSector.GetYOffset(sector.floor)); // Hacky scroll check because MF8_INSCROLLSEC not externalized to ZScript?
bool dotick = (curfloorxy != floorxy) || curSector.flags & sector.SECF_PUSH || (pos != oldpos);
if (dotick) // Only run a full Tick once; or if we are on a carrying floor, pushers are enabled in the sector (wind), or if we moved by some external force
{
oldpos = pos;
Super.Tick();
floorxy = curfloorxy;
return;
}
if (vel != (0, 0, 0)) // Apply velocity as required
{
SetXYZ(Vec3Offset(vel.X, vel.Y, vel.Z)); // Vec3Offset is portal-aware; use instead of just pos + vel, which is not
}
// Tick through actor states as normal
if (tics == -1) { return; }
else if (--tics <= 0)
{
SetState(CurState.NextState);
}
}
}
//MAIN
//#include "zscript/base.zs" //core
#include "zscript/avatar.zs" //player
#include "zscript/models.zs"
//SCENERY
//#include "zscript/flora.zs"
//#include "zscript/fauna.zs"
#include "zscript/props.zs"
//SFX
#include "zscript/sfx/boids.zs"
#include "zscript/sfx/fisheye.zs"
#include "zscript/sfx/heateffect.zs"
#include "zscript/sfx/smoke.zs"
#include "zscript/sfx/splashes.zs"
#include "zscript/sfx/underwater.zs"
//INTERACTIVES
#include "zscript/interactive/crystal.zs"
#include "zscript/interactive/fountain.zs"
//INVENTORY
#include "zscript/inventory/runes.zs"
#include "zscript/inventory/sapling.zs"
#include "zscript/inventory/torches.zs"
//WEAPONS
#include "zscript/weapons/main.zs" //actions
#include "zscript/weapons/fists.zs"
#include "zscript/weapons/maces.zs"
#include "zscript/weapons/axes.zs"
#include "zscript/weapons/swords.zs"
//#include "zscript/weapons/others.zs"
//FOES
#include "zscript/critters/easters.zs"
#include "zscript/critters/bats.zs"
#include "zscript/critters/dwarves.zs"
#include "zscript/critters/ghosts.zs"
#include "zscript/critters/imps.zs"
#include "zscript/critters/females_f.zs"
#include "zscript/critters/males_f.zs"
#include "zscript/critters/skeleton.zs"
/*
#include "zscript/critters/demon.zs"
#include "zscript/critters/elementals.zs"
#include "zscript/critters/females_w.zs"
#include "zscript/critters/gazer.zs"
#include "zscript/critters/ghouls.zs"
#include "zscript/critters/golem.zs"
#include "zscript/critters/graygobs.zs"
#include "zscript/critters/grengobs.zs"
#include "zscript/critters/headless.zs"
#include "zscript/critters/lizardmen.zs"
#include "zscript/critters/lurker.zs"
#include "zscript/critters/male_w.zs"
#include "zscript/critters/rats.zs"
#include "zscript/critters/reaper.zs"
#include "zscript/critters/rotworms.zs"
#include "zscript/critters/shadows.zs"
#include "zscript/critters/slugs.zs"
#include "zscript/critters/spiders.zs"
#include "zscript/critters/staff_w.zs"
#include "zscript/critters/trolls.zs"
#include "zscript/critters/tybal.zs"
#include "zscript/critters/wisp.zs"
*/