1 /* omega copyright (C) 1987,1988,1989 by Laurence Raphael Brothers */
2 /* itemf2.c */
3 
4 /* mostly ring, armor, and weapon functions */
5 
6 #include "glob.h"
7 
8 
9 
10 
11 /* ring functions */
i_perm_knowledge(o)12 void i_perm_knowledge(o)
13 pob o;
14 {
15   if (o->known < 1)
16     o->known = 1;
17   if (o->blessing > -1)
18     Objects[o->id].known = 1;
19   if (o->used)
20     knowledge(o->blessing);
21 }
22 
i_perm_strength(o)23 void i_perm_strength(o)
24 pob o;
25 {
26   if (o->known < 1) o->known = 1;
27   Objects[o->id].known = 1;
28   if (o->used){
29     if (o->blessing > -1)
30       Player.str += abs(o->plus)+1;
31     else
32       Player.str -= abs(o->plus)+1;
33   }
34   else {
35     if (o->blessing > -1)
36       Player.str -= abs(o->plus)+1;
37     else
38       Player.str += abs(o->plus)+1;
39   }
40   calc_melee();
41 }
42 
43 
44 
i_perm_burden(o)45 void i_perm_burden(o)
46 pob o;
47 {
48   int i;
49 
50   if (o->used) {
51     o->weight = 1000;
52     mprint("You feel heavier.");
53   }
54   else {
55     o->weight = 1;
56     mprint("Phew. What a relief.");
57   }
58   Player.itemweight = 0;
59   for (i=0;i<MAXITEMS;i++) {
60     if (Player.possessions[i] != NULL)
61       Player.itemweight +=
62 	(Player.possessions[i]->weight*Player.possessions[i]->number);
63   }
64 }
65 
i_perm_gaze_immune(o)66 void i_perm_gaze_immune(o)
67 pob o;
68 {
69   if (o->used) Player.immunity[GAZE]++;
70   else Player.immunity[GAZE]--;
71 }
72 
i_perm_fire_resist(o)73 void i_perm_fire_resist(o)
74 pob o;
75 {
76   if (o->used) Player.immunity[FLAME]++;
77   else Player.immunity[FLAME]--;
78 }
79 
i_perm_poison_resist(o)80 void i_perm_poison_resist(o)
81 pob o;
82 {
83   if (o->used) {
84     if (o->blessing < 0) {
85       Player.immunity[POISON] = 0;
86       p_poison(100);
87     }
88     else {
89       Player.immunity[POISON]++;
90       if (Player.status[POISONED] > 0) {
91 	mprint("You feel much better now.");
92 	Player.status[POISONED] = 0;
93       }
94     }
95   }
96   else {
97     Player.status[POISONED] = 0;
98     Player.immunity[POISON]--;
99   }
100 }
101 
102 
103 
104 
105 
106 
i_perm_regenerate(o)107 void i_perm_regenerate(o)
108 pob o;
109 {
110   if (o->known < 1)  o->known = 1;
111   if (o->blessing > -1)
112     Objects[o->id].known = 1;
113   if (o->used) {
114     mprint("You seem abnormally healthy.");
115     Player.status[REGENERATING] += 1500;
116   }
117   else {
118     Player.status[REGENERATING] -= 1500;
119     if (Player.status[REGENERATING] < 1) {
120       mprint("Your vitality is back to normal");
121       Player.status[REGENERATING] = 0;
122     }
123   }
124 }
125 
126 
127 
128 
129 /* armor functions */
130 
131 
i_normal_armor(o)132 void i_normal_armor(o)
133 pob o;
134 {
135   if (o->used) mprint("You put on your suit of armor.");
136 }
137 
i_perm_energy_resist(o)138 void i_perm_energy_resist(o)
139 pob o;
140 {
141   if (o->used){
142     Player.immunity[FLAME]++;
143     Player.immunity[COLD]++;
144     Player.immunity[ELECTRICITY]++;
145   }
146   else {
147     Player.immunity[FLAME]--;
148     Player.immunity[COLD]--;
149     Player.immunity[ELECTRICITY]--;
150   }
151 }
152 
153 
154 
i_perm_fear_resist(o)155 void i_perm_fear_resist(o)
156 pob o;
157 {
158   if (o->used){
159     Player.immunity[FEAR]++;
160     if (o->blessing < 0) {
161       Player.status[BERSERK] += 1500;
162       mprint("You feel blood-simple!");
163     }
164   }
165   else {
166     Player.immunity[FEAR]--;
167     if (o->blessing < 0) {
168       Player.status[BERSERK] -= 1500;
169       if (Player.status[BERSERK] < 1) {
170 	mprint("You feel less rabid now.");
171       Player.status[BERSERK] = 0;
172       }
173     }
174   }
175 }
176 
177 
178 
i_perm_breathing(o)179 void i_perm_breathing(o)
180 pob o;
181 {
182   if (o->known < 1)  o->known = 1;
183   if (o->blessing > -1)
184     Objects[o->id].known = 1;
185 
186   if (o->blessing > -1) {
187     if (o->used) {
188       mprint("Your breath is energized!");
189       Player.status[BREATHING] += 1500;
190     }
191     else  {
192       Player.status[BREATHING] -= 1500;
193       if (Player.status[BREATHING] < 1) {
194 	mprint("Your breathing is back to normal.");
195 	Player.status[BREATHING] = 0;
196       }
197     }
198   }
199   else if (o->used) {
200     Player.status[BREATHING] = 0;
201     p_drown();
202     print1("Water pours from the broken suit.");
203   }
204 }
205 
206 
207 
208 /* weapons functions */
209 
weapon_acidwhip(dmgmod,o,m)210 void weapon_acidwhip(dmgmod,o,m)
211 int dmgmod;
212 pob o;
213 struct monster *m;
214 {
215   if ((random_range(2) == 1) && (! m_immunityp(m,NORMAL_DAMAGE))) {
216     mprint("You entangle the monster!");
217     m_status_reset(m,MOBILE);
218   }
219   p_hit(m,Player.dmg+dmgmod,ACID);
220 
221 }
222 
weapon_scythe(dmgmod,o,m)223 void weapon_scythe(dmgmod,o,m)
224 int dmgmod;
225 pob o;
226 struct monster *m;
227 {
228   mprint("Slice!");
229   m_death(m);
230   if (! Player.rank[ADEPT]) {
231     mprint("Ooops!");
232     mprint("You accidentally touch yourself on the backswing....");
233     p_death("the Scythe of Death");
234   }
235 }
236 
weapon_demonblade(dmgmod,o,m)237 void weapon_demonblade(dmgmod,o,m)
238 int dmgmod;
239 pob o;
240 struct monster *m;
241 {
242   if (o->blessing > -1) {
243     mprint("Demonblade disintegrates with a soft sigh.");
244     mprint("You stop foaming at the mouth.");
245     Player.status[BERSERK] = 0;
246     conform_lost_object(o);
247   }
248   else if (m->specialf == M_SP_DEMON) {
249     mprint("The demon flees in terror before your weapon!");
250     m_vanish(m);
251   }
252   else if (m->meleef != M_MELEE_SPIRIT) {
253     if (m->level > random_range(10)) {
254       if( Player.hp < Player.maxhp )
255         Player.hp = min(Player.maxhp,Player.hp+m->hp);
256       Player.str++;
257       if( Player.pow < Player.maxpow )
258         Player.pow = min(Player.maxpow,Player.pow+m->level);
259       m_death(m);
260       mprint("You feel a surge of raw power from Demonblade!");
261     }
262     else p_hit(m,Player.dmg+dmgmod,NORMAL_DAMAGE);
263 
264   }
265   else {
266     mprint("Demonblade howls as it strikes the spirit!");
267     if (random_range(10) == 1) {
268       mprint("... and shatters into a thousand lost fragments!");
269       morewait();
270       p_damage(50,UNSTOPPABLE,"Demonblade exploding");
271       conform_lost_object(o);
272     }
273     else {
274       mprint("You feel your lifeforce draining....");
275       p_damage(25,UNSTOPPABLE,"a backlash of negative energies");
276       Player.str -= 3;
277       Player.con -= 3;
278       if (Player.str < 1 || Player.con < 1)
279 	p_death("a backlash of negative energies");
280     }
281   }
282 }
283 
weapon_lightsabre(dmgmod,o,m)284 void weapon_lightsabre(dmgmod,o,m)
285 int dmgmod;
286 pob o;
287 struct monster *m;
288 {
289   if (! o->known) {
290     mprint("Fumbling with the cylinder, you press the wrong stud....");
291     p_damage(100,UNSTOPPABLE,"fumbling with a lightsabre");
292     o->known = 1;
293   }
294   else {
295     /* test prevents confusing immunity messages.... */
296     if (! m_immunityp(m,NORMAL_DAMAGE)) {
297       mprint("Vzzzzmmm!");
298       m_damage(m,20,NORMAL_DAMAGE);
299     }
300     if ((m->hp>0) && (! m_immunityp(m,FLAME))) {
301       mprint("Zzzzap!");
302       m_damage(m,20,FLAME);
303     }
304   }
305 }
306 
weapon_tangle(dmgmod,o,m)307 void weapon_tangle(dmgmod,o,m)
308 int dmgmod;
309 pob o;
310 struct monster *m;
311 {
312   if ((random_range(2) == 1) && (! m_immunityp(m,NORMAL_DAMAGE))) {
313     mprint("You entangle the monster!");
314     m_status_reset(m,MOBILE);
315   }
316   p_hit(m,Player.dmg+dmgmod,NORMAL_DAMAGE);
317 }
318 
319 /* if wielding a bow, add bow damage to arrow damage */
weapon_arrow(dmgmod,o,m)320 void weapon_arrow(dmgmod,o,m)
321 int dmgmod;
322 pob o;
323 struct monster *m;
324 {
325   if ((Player.possessions[O_WEAPON_HAND] != NULL) &&
326       (Player.possessions[O_WEAPON_HAND]->id == WEAPONID+26)) /* ie, using a bow */
327     p_hit(m,Player.dmg+o->plus+o->dmg+dmgmod,NORMAL_DAMAGE);
328   else p_hit(m,o->plus+o->dmg+dmgmod,NORMAL_DAMAGE);
329 }
330 
331 /* if wielding a crossbow, add bow damage to arrow damage */
weapon_bolt(dmgmod,o,m)332 void weapon_bolt(dmgmod,o,m)
333 int dmgmod;
334 pob o;
335 struct monster *m;
336 {
337   if ((Player.possessions[O_WEAPON_HAND] != NULL) &&
338       (Player.possessions[O_WEAPON_HAND]->id == WEAPONID+27) && /*ie using a crossbow */
339       (Player.possessions[O_WEAPON_HAND]->aux==LOADED)) {
340 	p_hit(m,Player.dmg+o->plus+o->dmg+dmgmod,NORMAL_DAMAGE);
341 	Player.possessions[O_WEAPON_HAND]->aux = UNLOADED;
342       }
343   else p_hit(m,o->plus+o->dmg,NORMAL_DAMAGE);
344 }
345 
346 
weapon_mace_disrupt(dmgmod,o,m)347 void weapon_mace_disrupt(dmgmod,o,m)
348 int dmgmod;
349 pob o;
350 struct monster *m;
351 {
352   if (m->meleef == M_MELEE_SPIRIT) {
353     mprint("The monster crumbles away to dust!");
354     m_death(m);
355   }
356   else p_hit(m,Player.dmg+dmgmod,UNSTOPPABLE);
357 }
358 
weapon_normal_hit(dmgmod,o,m)359 void weapon_normal_hit(dmgmod,o,m)
360 int dmgmod;
361 pob o;
362 struct monster *m;
363 {
364   p_hit(m,Player.dmg+dmgmod,NORMAL_DAMAGE);
365 }
366 
367 
368 /* will be updated eventually */
weapon_bare_hands(dmgmod,m)369 void weapon_bare_hands(dmgmod,m)
370 int dmgmod;
371 struct monster *m;
372 {
373   p_hit(m,Player.dmg+dmgmod,NORMAL_DAMAGE);
374 }
375 
376 
i_demonblade(o)377 void i_demonblade(o)
378 pob o;
379 {
380   if (o->used) {
381     o->known = 2;
382     mprint("Demonblade's fangs open and bury themselves in your wrist!");
383     mprint("You hear evil laughter in the distance....");
384     mprint("You begin to foam at the mouth!");
385     Player.status[BERSERK] = 1500;
386   }
387   else {
388     mprint("You hear a sound like a demon cursing.");
389     mprint("You feel less like biting your shield.");
390     Player.status[BERSERK] = 0;
391   }
392 }
393 
i_normal_weapon(o)394 void i_normal_weapon(o)
395 pob o;
396 {
397   if (o->used) mprint("You ready your weapon for battle.");
398 }
399 
i_lightsabre(o)400 void i_lightsabre(o)
401 pob o;
402 {
403   if (o->used) mprint("You feel one with the Force.");
404   else mprint("You feel out of touch with the Force.");
405 }
406 
i_mace_disrupt(o)407 void i_mace_disrupt(o)
408 pob o;
409 {
410   mprint("That's a damned heavy mace!");
411 }
412 
413 
414 
weapon_vorpal(dmgmod,o,m)415 void weapon_vorpal(dmgmod,o,m)
416 int dmgmod;
417 pob o;
418 struct monster *m;
419 {
420   if ((random_range(10) < 3) && (! m_immunityp(m,NORMAL_DAMAGE))) {
421     o->known = 2;
422     if (random_range(2) == 1)
423       mprint("One Two! One Two! And through and through!");
424     else mprint("Your vorpal blade goes snicker-snack!");
425     m_death(m);
426   }
427   else weapon_normal_hit(dmgmod,o,m);
428 }
429 
weapon_desecrate(dmgmod,o,m)430 void weapon_desecrate(dmgmod,o,m)
431 int dmgmod;
432 pob o;
433 struct monster *m;
434 {
435   o->known = 2;
436   if (Player.alignment < 0) {
437     mprint("Your opponent screams in agony!");
438     p_hit(m,Player.dmg+dmgmod,UNSTOPPABLE);
439     Player.alignment--;
440     if (Player.hp < Player.maxhp) {
441       mprint("You feel a thrill of power surging up your blade!");
442       Player.hp = min(Player.maxhp,Player.hp+Player.dmg+dmgmod);
443     }
444   }
445   else {
446     mprint("Your blade turns in your hands and hits you!");
447     mprint("You hear evil laughter....");
448     level_drain(Player.dmg,"the sword Desecrator");
449     Player.alignment-=10;
450     mprint("A strange force spreads from the wound throughout your body...");
451     mprint("You feel much more chaotic now.");
452   }
453 }
454 
455 
456 
weapon_firestar(dmgmod,o,m)457 void weapon_firestar(dmgmod,o,m)
458 int dmgmod;
459 pob o;
460 struct monster *m;
461 {
462   if (random_range(3) == 1) {
463     o->known = 2;
464     fball(Player.x,Player.y,Player.x,Player.y,max(Player.dmg,25));
465   }
466   if (m->hp > 0) weapon_normal_hit(dmgmod,o,m);
467 }
468 
weapon_defend(dmgmod,o,m)469 void weapon_defend(dmgmod,o,m)
470 int dmgmod;
471 pob o;
472 struct monster *m;
473 {
474   if ((Player.alignment < 0) && (o->blessing > 0)) {
475       mprint("The Holy Defender screams in your hands....");
476       mprint("You stagger before the sound of its rage....");
477       p_damage(50,UNSTOPPABLE,"a pissed-off Holy Defender");
478       mprint("The weapon finally quiets. It seems less holy now.");
479       o->truename = o->cursestr;
480       Player.status[PROTECTION] -= (o->hit);
481       o->plus = 0-abs(o->plus);
482       o->blessing = -1;
483     }
484   if ((o->blessing > 0) &&
485       ((m->specialf == M_SP_DEMON) ||
486        (m->meleef == M_MELEE_SPIRIT))) {
487     mprint("Your opponent shies back before your holy weapon!");
488     m->hit = 0;
489     m->speed *=2;
490   }
491   weapon_normal_hit(dmgmod,o,m);
492 }
493 
weapon_victrix(dmgmod,o,m)494 void weapon_victrix(dmgmod,o,m)
495 int dmgmod;
496 pob o;
497 struct monster *m;
498 {
499   if (m->meleef == M_MELEE_SPIRIT) {
500     mprint("Your opponent dissipates in a harmless cloud of vapors...");
501     m_death(m);
502   }
503   else weapon_normal_hit(dmgmod,o,m);
504 }
505 
i_defend(o)506 void i_defend(o)
507 pob o;
508 {
509   o->known = 2;
510   if (o->used) {
511     mprint("You feel under an aegis!");
512     Player.status[PROTECTION] += o->hit;
513   }
514   else Player.status[PROTECTION] -= o->hit;
515 }
516 
517 
i_victrix(o)518 void i_victrix(o)
519 pob o;
520 {
521   o->known = 2;
522   o->blessing = abs(o->blessing);
523   if (o->used) {
524     Player.immunity[POISON]++;
525     Player.immunity[FEAR]++;
526     Player.immunity[INFECTION]++;
527   }
528   else {
529     Player.immunity[POISON]--;
530     Player.immunity[FEAR]--;
531     Player.immunity[INFECTION]--;
532   }
533 }
534 
535 
i_desecrate(o)536 void i_desecrate(o)
537 pob o;
538 {
539   if (o->known < 1)  o->known = 2;
540   if (o->blessing > 0) {
541     mprint("How weird, a blessed desecrator... ");
542     mprint("The structure of reality cannot permit such a thing....");
543     dispose_lost_objects(1,o);
544   }
545   else if (Level->site[Player.x][Player.y].locchar == ALTAR)
546     sanctify(-1);
547 }
548 
549 
550 /* shield functions */
i_normal_shield(o)551 void i_normal_shield(o)
552 pob o;
553 {
554   if (o->used) mprint("You sling your shield across a forearm.");
555 }
556 
557 
i_perm_deflect(o)558 void i_perm_deflect(o)
559 pob o;
560 {
561   if (o->known < 1)  o->known = 2;
562   if (o->blessing > -1) {
563     if (o->used) {
564       mprint("You feel buffered.");
565       Player.status[DEFLECTION] += 1500;
566     }
567     else {
568       Player.status[DEFLECTION] -= 1500;
569       if (Player.status[DEFLECTION] < 1) {
570 	mprint("You feel less defended");
571 	Player.status[DEFLECTION] = 0;
572       }
573     }
574   }
575   else {
576     if (o->used) {
577       mprint("You feel naked.");
578       Player.status[VULNERABLE] += 1500;
579       Player.status[DEFLECTION] = 0;
580     }
581     else {
582       Player.status[VULNERABLE] -= 1500;
583       if (Player.status[VULNERABLE] < 1) {
584 	mprint("You feel less vulnerable");
585 	Player.status[VULNERABLE] = 0;
586       }
587     }
588   }
589 }
590