SHOW:
|
|
- or go back to the newest paste.
1 | //----------------------------------------- | |
2 | //gunplay.acs | |
3 | //----------------------------------------- | |
4 | #library "GUNS" | |
5 | #include "zcommon.acs" | |
6 | ||
7 | str numberActors[10] = {"num0","num1","num2","num3","num4","num5","num6","num7","num8","num9"}; | |
8 | ||
9 | script "DealHitscanDamage" (int maxrange, int maxDamage, int minDamage) | |
10 | { | |
11 | int dist = fdistance(0, 1000); | |
12 | ||
13 | //add a little padding so you can actually do max damage | |
14 | dist -= 32.0; | |
15 | if (dist < 0) | |
16 | { | |
17 | dist = 0; | |
18 | } | |
19 | ||
20 | //make it a fixed | |
21 | maxrange = maxrange << 16; | |
22 | int damage = 0; | |
23 | ||
24 | //linear damage falloff, based on dist from monster to player | |
25 | damage = fixeddiv (dist, maxrange); | |
26 | if (damage > 1.0) | |
27 | { | |
28 | damage = 1.0; | |
29 | } | |
30 | damage = 1.0 - damage; | |
31 | ||
32 | //ensure that the damage doesn't go above maxDamage | |
33 | damage *= (maxDamage - minDamage); | |
34 | ||
35 | //add spread | |
36 | damage += random(0, 10); | |
37 | ||
38 | //add mindamage to the mix | |
39 | damage = damage >> 16; | |
40 | damage += minDamage; | |
41 | ||
42 | //deal the damage | |
43 | DamageThing(damage); | |
44 | ||
45 | //increment the damage var | |
46 | SetUserVariable(0, "user_lastdamage", GetUserVariable(0, "user_lastdamage") + damage); | |
47 | } | |
48 | ||
49 | script "SetupPlayerTid" ENTER | |
50 | { | |
51 | Thing_ChangeTid(0, 1000); | |
52 | } | |
53 | ||
54 | script "DamageDropoff" (void) | |
55 | { | |
56 | SetResultValue(GetUserVariable(0, "user_damage")); | |
57 | } | |
58 | ||
59 | script "GenericActorTick" (void) | |
60 | { | |
61 | - | if (GetUserVariable(0, "user_lastdamage") > 0) |
61 | + | if (GetUserVariable(0, "user_lasthealth") - GetActorProperty(0, APROP_HEALTH) > 0) |
62 | { | |
63 | Spawn("MagicDamageNumberGuy", getActorX(0), getActorY(0), GetActorZ(0) + 64.0, 32000); | |
64 | - | SetUserVariable(32000, "user_damage", GetUserVariable(0, "user_lastdamage")); |
64 | + | SetUserVariable(32000, "user_damage", GetUserVariable(0, "user_lasthealth") - GetActorProperty(0, APROP_HEALTH)); |
65 | Thing_ChangeTid(32000, 0); | |
66 | SetUserVariable(0, "user_lastdamage", 0); | |
67 | } | |
68 | if (GetActorProperty(0, APROP_HEALTH) > 0) | |
69 | { | |
70 | SetUserVariable(0, "user_lasthealth", GetActorProperty(0, APROP_HEALTH)); | |
71 | if (GetUserVariable(0, "user_afterburn") > 0) | |
72 | { | |
73 | if (GetUserVariable(0, "user_afterburn") % 10 == 0) | |
74 | - | Thing_Damage2(0, 2, "Afterburn"); |
74 | + | |
75 | Thing_Damage2(0, 4, "Afterburn"); | |
76 | } | |
77 | SetUserVariable(0, "user_afterburn", GetUserVariable(0, "user_afterburn") - 1); | |
78 | } | |
79 | Delay(1); | |
80 | restart; | |
81 | } | |
82 | } | |
83 | ||
84 | int damagenum[3]; | |
85 | script "NumberMagic" (void) | |
86 | { | |
87 | if (GetUserVariable(0, "user_ticks") < 30) | |
88 | { | |
89 | int damage = GetUserVariable(0, "user_damage"); | |
90 | int numbers = 2; | |
91 | damagenum[0] = (damage / 100) % 10; | |
92 | damagenum[1] = (damage / 10) % 10; | |
93 | damagenum[2] = (damage / 1) % 10; | |
94 | if (damagenum[0] == 0) | |
95 | { | |
96 | numbers--; | |
97 | if (damagenum[1] == 0) | |
98 | numbers--; | |
99 | } | |
100 | ||
101 | int angle = 1.0 - VectorAngle(GetActorX(0) - GetActorX(1000), GetActorY(0) - GetActorY(1000)); | |
102 | int startOffset = 14.0; | |
103 | //startOffset += (7.0 * (numbers - 1)); | |
104 | ||
105 | int offset = startOffset; | |
106 | for (int x = 0; x <= numbers; x++) | |
107 | { | |
108 | int posX = sin(angle); | |
109 | int posY = cos(angle); | |
110 | ||
111 | Spawn(numberActors[damagenum[x + (2-numbers)]], GetActorX(0) + FixedMul(posX, offset), GetActorY(0) + FixedMul(posY, offset), getActorZ(0), 0, 0); | |
112 | offset -= 14.0; | |
113 | } | |
114 | ||
115 | SetUserVariable(0, "user_ticks", GetUserVariable(0, "user_ticks") + 1); | |
116 | delay(1); | |
117 | restart; | |
118 | } | |
119 | } | |
120 | ||
121 | function int abs(int input) | |
122 | { | |
123 | if (input < 0) | |
124 | { | |
125 | return -input; | |
126 | } | |
127 | return input; | |
128 | } | |
129 | ||
130 | function int fdistance (int tid1, int tid2) | |
131 | { | |
132 | int len; | |
133 | int y = getactory(tid1) - getactory(tid2); | |
134 | int x = getactorx(tid1) - getactorx(tid2); | |
135 | int z = getactorz(tid1) - getactorz(tid2); | |
136 | ||
137 | int ang = vectorangle(x,y); | |
138 | if(((ang+0.125)%0.5) > 0.25) len = fixeddiv(y, sin(ang)); | |
139 | else len = fixeddiv(x, cos(ang)); | |
140 | ||
141 | ang = vectorangle(len, z); | |
142 | if(((ang+0.125)%0.5) > 0.25) len = fixeddiv(z, sin(ang)); | |
143 | else len = fixeddiv(len, cos(ang)); | |
144 | ||
145 | return len; | |
146 | } | |
147 | ||
148 | //----------------------------------------- | |
149 | //decorate | |
150 | //----------------------------------------- | |
151 | ACTOR MagicDamageNumberGuy | |
152 | { | |
153 | +NOBLOCKMAP | |
154 | +NOGRAVITY | |
155 | VSpeed 1 | |
156 | var int user_damage; | |
157 | var int user_ticks; | |
158 | States | |
159 | { | |
160 | Spawn: | |
161 | TNT1 AA 0 ACS_NamedExecuteAlways("NumberMagic", 0, 0, 0, 0) | |
162 | TNT1 A 300 | |
163 | Stop | |
164 | } | |
165 | } | |
166 | ||
167 | Actor num0 | |
168 | { | |
169 | +NOBLOCKMAP | |
170 | +NOGRAVITY | |
171 | States | |
172 | { | |
173 | Spawn: | |
174 | NUM0 A 2 bright | |
175 | stop | |
176 | } | |
177 | } | |
178 | ||
179 | Actor num1 | |
180 | { | |
181 | +NOBLOCKMAP | |
182 | +NOGRAVITY | |
183 | States | |
184 | { | |
185 | Spawn: | |
186 | NUM1 A 2 bright | |
187 | stop | |
188 | } | |
189 | } | |
190 | ||
191 | Actor num2 | |
192 | { | |
193 | +NOBLOCKMAP | |
194 | +NOGRAVITY | |
195 | States | |
196 | { | |
197 | Spawn: | |
198 | NUM2 A 2 bright | |
199 | stop | |
200 | } | |
201 | } | |
202 | ||
203 | Actor num3 | |
204 | { | |
205 | +NOBLOCKMAP | |
206 | +NOGRAVITY | |
207 | States | |
208 | { | |
209 | Spawn: | |
210 | NUM3 A 2 bright | |
211 | stop | |
212 | } | |
213 | } | |
214 | ||
215 | Actor num4 | |
216 | { | |
217 | +NOBLOCKMAP | |
218 | +NOGRAVITY | |
219 | States | |
220 | { | |
221 | Spawn: | |
222 | NUM4 A 2 bright | |
223 | stop | |
224 | } | |
225 | } | |
226 | ||
227 | Actor num5 | |
228 | { | |
229 | +NOBLOCKMAP | |
230 | +NOGRAVITY | |
231 | States | |
232 | { | |
233 | Spawn: | |
234 | NUM5 A 2 bright | |
235 | stop | |
236 | } | |
237 | } | |
238 | ||
239 | Actor num6 | |
240 | { | |
241 | +NOBLOCKMAP | |
242 | +NOGRAVITY | |
243 | States | |
244 | { | |
245 | Spawn: | |
246 | NUM6 A 2 bright | |
247 | stop | |
248 | } | |
249 | } | |
250 | ||
251 | Actor num7 | |
252 | { | |
253 | +NOBLOCKMAP | |
254 | +NOGRAVITY | |
255 | States | |
256 | { | |
257 | Spawn: | |
258 | NUM7 A 2 bright | |
259 | stop | |
260 | } | |
261 | } | |
262 | ||
263 | Actor num8 | |
264 | { | |
265 | +NOBLOCKMAP | |
266 | +NOGRAVITY | |
267 | States | |
268 | { | |
269 | Spawn: | |
270 | NUM8 A 2 bright | |
271 | stop | |
272 | } | |
273 | } | |
274 | ||
275 | Actor num9 | |
276 | { | |
277 | +NOBLOCKMAP | |
278 | +NOGRAVITY | |
279 | States | |
280 | { | |
281 | Spawn: | |
282 | NUM9 A 2 bright | |
283 | stop | |
284 | } | |
285 | } | |
286 | ||
287 | ACTOR ZombieManII : Zombieman replaces Zombieman | |
288 | { | |
289 | PainChance 256 | |
290 | PainChance "Afterburn", 128 | |
291 | Health 100 | |
292 | var int user_afterburn; | |
293 | var int user_lastdamage; | |
294 | var int user_lasthealth; | |
295 | States | |
296 | - | POSS AA 0 ACS_NamedExecuteAlways("GenericActorTick") |
296 | + | |
297 | Spawn: | |
298 | POSS AA 0 A_SetUserVar("user_lasthealth", health) | |
299 | POSS A 0 ACS_NamedExecuteAlways("GenericActorTick") | |
300 | Goto Super::Spawn | |
301 | Missile: | |
302 | POSS E 10 A_FaceTarget | |
303 | POSS F 8 A_CustomBulletAttack(22.9,0,1,5) | |
304 | POSS E 8 | |
305 | Goto See | |
306 | Pain.Gun: | |
307 | POSS G 0 ACS_NamedExecuteAlways("DealHitscanDamage",0,512,150,50) | |
308 | goto Super::Pain | |
309 | Pain.Sniper: | |
310 | POSS G 0 ACS_NamedExecuteAlways("DealHitscanDamage",0,3000,300,50) | |
311 | goto Super::Pain | |
312 | Pain.MGun: | |
313 | POSS G 0 ACS_NamedExecuteAlways("DealHitscanDamage",0,512,80,30) | |
314 | goto Super::Pain | |
315 | Pain.Shotgun: | |
316 | POSS G 0 ACS_NamedExecuteAlways("DealHitscanDamage",0,512,60,10) | |
317 | goto Super::Pain | |
318 | Pain.Fire: | |
319 | POSS G 0 A_SetUserVar("user_afterburn", 400) | |
320 | goto Super::Pain | |
321 | } | |
322 | } |