forked from muspellsson/omega-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
itemf2.c
522 lines (454 loc) · 11.8 KB
/
itemf2.c
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
/* omega copyright (C) 1987,1988,1989 by Laurence Raphael Brothers */
/* itemf2.c */
/* mostly ring, armor, and weapon functions */
#include "glob.h"
/* ring functions */
void i_perm_knowledge(pob o)
{
if (o->known < 1)
o->known = 1;
if (o->blessing > -1)
Objects[o->id].known = 1;
/* DAG hack for mirror of self-knowledge
if (o->used)
knowledge(o->blessing);
*/
knowledge(o->blessing);
}
void i_perm_strength(pob o)
{
if (o->known < 1) o->known = 1;
Objects[o->id].known = 1;
if (o->used){
if (o->blessing > -1)
Player.str += abs(o->plus)+1;
else
Player.str -= abs(o->plus)+1;
}
else {
if (o->blessing > -1)
Player.str -= abs(o->plus)+1;
else
Player.str += abs(o->plus)+1;
}
calc_melee();
}
void i_perm_burden(pob o)
{
int i;
if (o->used) {
o->weight = 1000;
mprint("You feel heavier.");
}
else {
o->weight = 1;
mprint("Phew. What a relief.");
}
Player.itemweight = 0;
for (i=0;i<MAXITEMS;i++) {
if (Player.possessions[i] != NULL)
Player.itemweight +=
(Player.possessions[i]->weight*Player.possessions[i]->number);
}
}
void i_perm_gaze_immune(pob o)
{
if (o->used) Player.immunity[GAZE]++;
else Player.immunity[GAZE]--;
}
void i_perm_fire_resist(pob o)
{
if (o->used) Player.immunity[FLAME]++;
else Player.immunity[FLAME]--;
}
void i_perm_poison_resist(pob o)
{
if (o->used) {
if (o->blessing < 0) {
Player.immunity[POISON] = 0;
p_poison(100);
}
else {
Player.immunity[POISON]++;
if (Player.status[POISONED] > 0) {
mprint("You feel much better now.");
Player.status[POISONED] = 0;
}
}
}
else {
Player.status[POISONED] = 0;
Player.immunity[POISON]--;
}
}
void i_perm_regenerate(pob o)
{
if (o->known < 1) o->known = 1;
if (o->blessing > -1)
Objects[o->id].known = 1;
if (o->used) {
mprint("You seem abnormally healthy.");
Player.status[REGENERATING] += 1500;
}
else {
Player.status[REGENERATING] -= 1500;
if (Player.status[REGENERATING] < 1) {
mprint("Your vitality is back to normal");
Player.status[REGENERATING] = 0;
}
}
}
/* armor functions */
void i_normal_armor(pob o)
{
if (o->used) mprint("You put on your suit of armor.");
}
void i_perm_energy_resist(pob o)
{
if (o->used){
Player.immunity[FLAME]++;
Player.immunity[COLD]++;
Player.immunity[ELECTRICITY]++;
}
else {
Player.immunity[FLAME]--;
Player.immunity[COLD]--;
Player.immunity[ELECTRICITY]--;
}
}
void i_perm_fear_resist(pob o)
{
if (o->used){
Player.immunity[FEAR]++;
if (o->blessing < 0) {
Player.status[BERSERK] += 1500;
mprint("You feel blood-simple!");
}
}
else {
Player.immunity[FEAR]--;
if (o->blessing < 0) {
Player.status[BERSERK] -= 1500;
if (Player.status[BERSERK] < 1) {
mprint("You feel less rabid now.");
Player.status[BERSERK] = 0;
}
}
}
}
void i_perm_breathing(pob o)
{
if (o->known < 1) o->known = 1;
if (o->blessing > -1)
Objects[o->id].known = 1;
if (o->blessing > -1) {
if (o->used) {
mprint("Your breath is energized!");
Player.status[BREATHING] += 1500;
}
else {
Player.status[BREATHING] -= 1500;
if (Player.status[BREATHING] < 1) {
mprint("Your breathing is back to normal.");
Player.status[BREATHING] = 0;
}
}
}
else if (o->used) {
Player.status[BREATHING] = 0;
p_drown();
print1("Water pours from the broken suit.");
}
}
/* weapons functions */
void weapon_acidwhip(int dmgmod, pob o, pmt m)
{
if ((random_range(2) == 1) && (! m_immunityp(m,NORMAL_DAMAGE))) {
mprint("You entangle the monster!");
m_status_reset(m,MOBILE);
}
p_hit(m,Player.dmg+dmgmod,ACID);
}
void weapon_scythe(int dmgmod, pob o, pmt m)
{
mprint("Slice!");
m_death(m);
if (! Player.rank[ADEPT]) {
mprint("Ooops!");
mprint("You accidentally touch yourself on the backswing....");
p_death("the Scythe of Death");
}
}
void weapon_demonblade(int dmgmod, pob o, pmt m)
{
if (o->blessing > -1) {
mprint("Demonblade disintegrates with a soft sigh.");
mprint("You stop foaming at the mouth.");
Player.status[BERSERK] = 0;
conform_lost_object(o);
}
else if (m->specialf == M_SP_DEMON) {
mprint("The demon flees in terror before your weapon!");
m_vanish(m);
}
else if (m->meleef != M_MELEE_SPIRIT) {
if (m->level > random_range(10)) {
if( Player.hp < Player.maxhp )
Player.hp = min(Player.maxhp,Player.hp+m->hp);
Player.str++;
if( Player.pow < Player.maxpow )
Player.pow = min(Player.maxpow,Player.pow+m->level);
m_death(m);
mprint("You feel a surge of raw power from Demonblade!");
}
else p_hit(m,Player.dmg+dmgmod,NORMAL_DAMAGE);
}
else {
mprint("Demonblade howls as it strikes the spirit!");
if (random_range(10) == 1) {
mprint("... and shatters into a thousand lost fragments!");
morewait();
p_damage(50,UNSTOPPABLE,"Demonblade exploding");
conform_lost_object(o);
}
else {
mprint("You feel your lifeforce draining....");
p_damage(25,UNSTOPPABLE,"a backlash of negative energies");
Player.str -= 3;
Player.con -= 3;
if (Player.str < 1 || Player.con < 1)
p_death("a backlash of negative energies");
}
}
}
void weapon_lightsabre(int dmgmod, pob o, pmt m)
{
if (! o->known) {
mprint("Fumbling with the cylinder, you press the wrong stud....");
p_damage(100,UNSTOPPABLE,"fumbling with a lightsabre");
o->known = 1;
}
else {
/* test prevents confusing immunity messages.... */
if (! m_immunityp(m,NORMAL_DAMAGE)) {
mprint("Vzzzzmmm!");
m_damage(m,20,NORMAL_DAMAGE);
}
if ((m->hp>0) && (! m_immunityp(m,FLAME))) {
mprint("Zzzzap!");
m_damage(m,20,FLAME);
}
}
}
void weapon_tangle(int dmgmod, pob o, pmt m)
{
if ((random_range(2) == 1) && (! m_immunityp(m,NORMAL_DAMAGE))) {
mprint("You entangle the monster!");
m_status_reset(m,MOBILE);
}
p_hit(m,Player.dmg+dmgmod,NORMAL_DAMAGE);
}
/* if wielding a bow, add bow damage to arrow damage */
void weapon_arrow(int dmgmod, pob o, pmt m)
{
if ((Player.possessions[O_WEAPON_HAND] != NULL) &&
(Player.possessions[O_WEAPON_HAND]->id == OB_LONGBOW)) /* ie, using a bow */
p_hit(m,Player.dmg+o->plus+o->dmg+dmgmod,NORMAL_DAMAGE);
else p_hit(m,o->plus+o->dmg+dmgmod,NORMAL_DAMAGE);
}
/* if wielding a crossbow, add bow damage to arrow damage */
void weapon_bolt(int dmgmod, pob o, pmt m)
{
if ((Player.possessions[O_WEAPON_HAND] != NULL) &&
(Player.possessions[O_WEAPON_HAND]->id == OB_CROSSBOW) && /*ie using a crossbow */
(Player.possessions[O_WEAPON_HAND]->aux==LOADED)) {
p_hit(m,Player.dmg+o->plus+o->dmg+dmgmod,NORMAL_DAMAGE);
Player.possessions[O_WEAPON_HAND]->aux = UNLOADED;
}
else p_hit(m,o->plus+o->dmg,NORMAL_DAMAGE);
}
void weapon_mace_disrupt(int dmgmod, pob o, pmt m)
{
if (m->meleef == M_MELEE_SPIRIT) {
mprint("The monster crumbles away to dust!");
m_death(m);
}
else p_hit(m,Player.dmg+dmgmod,UNSTOPPABLE);
}
void weapon_normal_hit(int dmgmod, pob o, pmt m)
{
p_hit(m,Player.dmg+dmgmod,NORMAL_DAMAGE);
}
/* will be updated eventually */
void weapon_bare_hands(int dmgmod, pmt m)
{
p_hit(m,Player.dmg+dmgmod,NORMAL_DAMAGE);
}
void i_demonblade(pob o)
{
if (o->used) {
o->known = 2;
mprint("Demonblade's fangs open and bury themselves in your wrist!");
mprint("You hear evil laughter in the distance....");
mprint("You begin to foam at the mouth!");
Player.status[BERSERK] = 1500;
}
else {
mprint("You hear a sound like a demon cursing.");
mprint("You feel less like biting your shield.");
Player.status[BERSERK] = 0;
}
}
void i_normal_weapon(pob o)
{
if (o->used) mprint("You ready your weapon for battle.");
}
void i_lightsabre(pob o)
{
if (o->used) mprint("You feel one with the Force.");
else mprint("You feel out of touch with the Force.");
}
void i_mace_disrupt(pob o)
{
mprint("That's a damned heavy mace!");
}
void weapon_vorpal(int dmgmod, pob o, pmt m)
{
if ((random_range(10) < 3) && (! m_immunityp(m,NORMAL_DAMAGE))) {
o->known = 2;
if (random_range(2) == 1)
mprint("One Two! One Two! And through and through!");
else mprint("Your vorpal blade goes snicker-snack!");
m_death(m);
}
else weapon_normal_hit(dmgmod,o,m);
}
void weapon_desecrate(int dmgmod, pob o, pmt m)
{
o->known = 2;
if (Player.alignment < 0) {
mprint("Your opponent screams in agony!");
p_hit(m,Player.dmg+dmgmod,UNSTOPPABLE);
Player.alignment--;
if (Player.hp < Player.maxhp) {
mprint("You feel a thrill of power surging up your blade!");
Player.hp = min(Player.maxhp,Player.hp+Player.dmg+dmgmod);
}
}
else {
mprint("Your blade turns in your hands and hits you!");
mprint("You hear evil laughter....");
level_drain(Player.dmg,"the sword Desecrator");
Player.alignment-=10;
mprint("A strange force spreads from the wound throughout your body...");
mprint("You feel much more chaotic now.");
}
}
void weapon_firestar(int dmgmod, pob o, pmt m)
{
if (random_range(3) == 1) {
o->known = 2;
fball(Player.x,Player.y,Player.x,Player.y,max(Player.dmg,25));
}
if (m->hp > 0) weapon_normal_hit(dmgmod,o,m);
}
void weapon_defend(int dmgmod, pob o, pmt m)
{
if ((Player.alignment < 0) && (o->blessing > 0)) {
mprint("The Holy Defender screams in your hands....");
mprint("You stagger before the sound of its rage....");
p_damage(50,UNSTOPPABLE,"a pissed-off Holy Defender");
mprint("The weapon finally quiets. It seems less holy now.");
o->truename = o->cursestr;
Player.status[PROTECTION] -= (o->hit);
o->plus = 0-abs(o->plus);
o->blessing = -1;
}
if ((o->blessing > 0) &&
((m->specialf == M_SP_DEMON) ||
(m->meleef == M_MELEE_SPIRIT))) {
mprint("Your opponent shies back before your holy weapon!");
m->hit = 0;
m->speed *=2;
}
weapon_normal_hit(dmgmod,o,m);
}
void weapon_victrix(int dmgmod, pob o, pmt m)
{
if (m->meleef == M_MELEE_SPIRIT) {
mprint("Your opponent dissipates in a harmless cloud of vapors...");
m_death(m);
}
else weapon_normal_hit(dmgmod,o,m);
}
void i_defend(pob o)
{
o->known = 2;
if (o->used) {
mprint("You feel under an aegis!");
Player.status[PROTECTION] += o->hit;
}
else Player.status[PROTECTION] -= o->hit;
}
void i_victrix(pob o)
{
o->known = 2;
o->blessing = abs(o->blessing);
if (o->used) {
Player.immunity[POISON]++;
Player.immunity[FEAR]++;
Player.immunity[INFECTION]++;
}
else {
Player.immunity[POISON]--;
Player.immunity[FEAR]--;
Player.immunity[INFECTION]--;
}
}
void i_desecrate(pob o)
{
if (o->known < 1) o->known = 2;
if (o->blessing > 0) {
mprint("How weird, a blessed desecrator... ");
mprint("The structure of reality cannot permit such a thing....");
dispose_lost_objects(1,o);
}
else if (Level->site[Player.x][Player.y].locchar == ALTAR)
sanctify(-1);
}
/* shield functions */
void i_normal_shield(pob o)
{
if (o->used) mprint("You sling your shield across a forearm.");
}
void i_perm_deflect(pob o)
{
if (o->known < 1) o->known = 2;
if (o->blessing > -1) {
if (o->used) {
mprint("You feel buffered.");
Player.status[DEFLECTION] += 1500;
}
else {
Player.status[DEFLECTION] -= 1500;
if (Player.status[DEFLECTION] < 1) {
mprint("You feel less defended");
Player.status[DEFLECTION] = 0;
}
}
}
else {
if (o->used) {
mprint("You feel naked.");
Player.status[VULNERABLE] += 1500;
Player.status[DEFLECTION] = 0;
}
else {
Player.status[VULNERABLE] -= 1500;
if (Player.status[VULNERABLE] < 1) {
mprint("You feel less vulnerable");
Player.status[VULNERABLE] = 0;
}
}
}
}