2 * interplayer.c - player to player routines for Phantasia
8 /************************************************************************
10 / FUNCTION NAME: checkbattle()
12 / FUNCTION: check to see if current player should battle another
14 / AUTHOR: E. A. Estes, 12/4/85
20 / MODULES CALLED: battleplayer(), fread(), fseek()
22 / GLOBAL INPUTS: Other, Users, Player, Fileloc, *Playersfp
24 / GLOBAL OUTPUTS: Users
27 / Seach player file for a foe at the same coordinates as the
29 / Also update user count.
31 *************************************************************************/
35 long foeloc = 0L; /* location in file of person to fight */
38 fseek(Playersfp, 0L, 0);
40 while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
42 if (Other.p_status != S_OFF
43 && Other.p_status != S_NOTUSED
44 && Other.p_status != S_HUNGUP
45 && (Other.p_status != S_CLOAKED || Other.p_specialtype != SC_VALAR))
46 /* player is on and not a cloaked valar */
50 if (Player.p_x == Other.p_x
51 && Player.p_y == Other.p_y
52 /* same coordinates */
55 && Player.p_status == S_PLAYING
56 && (Other.p_status == S_PLAYING || Other.p_status == S_INBATTLE)
57 /* both are playing */
58 && Other.p_specialtype != SC_VALAR
59 && Player.p_specialtype != SC_VALAR)
60 /* neither is valar */
66 foeloc += SZ_PLAYERSTRUCT;
70 /************************************************************************
72 / FUNCTION NAME: battleplayer()
74 / FUNCTION: inter-terminal battle with another player
76 / AUTHOR: E. A. Estes, 2/15/86
79 / long foeplace - location in player file of person to battle
83 / MODULES CALLED: readrecord(), readmessage(), writerecord(), collecttaxes(),
84 / displaystats(), fabs(), more(), death(), sleep(), wmove(), waddch(), printw(),
85 / myturn(), altercoordinates(), waddstr(), wrefresh(), mvprintw(),
86 / getanswer(), wclrtoeol(), wclrtobot()
88 / GLOBAL INPUTS: Foestrikes, LINES, Lines, Other, Shield, Player, *stdscr,
91 / GLOBAL OUTPUTS: Foestrikes, Lines, Shield, Player, Luckout, *Enemyname
94 / Inter-terminal battle is a very fragile and slightly klugy thing.
95 / At any time, one player is master and the other is slave.
96 / We pick who is master first by speed and level. After that,
97 / the slave waits for the master to relinquish its turn, and
98 / the slave becomes master, and so on.
100 / The items in the player structure which control the handshake are:
102 / master increments this to relinquish control
104 / master sets this to specify particular action
106 / set to total damage inflicted so far; changes to indicate action
108 *************************************************************************/
110 battleplayer(foeplace)
113 double dtemp; /* for temporary calculations */
114 double oldhits = 0.0; /* previous damage inflicted by foe */
115 register int loop; /* for timing out */
117 short oldtampered; /* old value of foe's p_tampered */
121 mvaddstr(4, 0, "Preparing for battle!\n");
128 /* set up variables, file, etc. */
129 Player.p_status = S_INBATTLE;
130 Shield = Player.p_energy;
132 /* if p_tampered is not 0, someone else may try to change it (king, etc.) */
133 Player.p_tampered = oldtampered = 1;
134 Player.p_1scratch = 0.0;
135 Player.p_istat = I_OFF;
137 readrecord(&Other, foeplace);
138 if (fabs(Player.p_level - Other.p_level) > 20.0)
139 /* see if players are greatly mismatched */
141 dtemp = (Player.p_level - Other.p_level) / MAX(Player.p_level, Other.p_level);
143 /* foe outweighs this one */
144 Player.p_speed *= 2.0;
147 writerecord(&Player, Fileloc); /* write out all our info */
149 if (Player.p_blindness)
150 Enemyname = "someone";
152 Enemyname = Other.p_name;
154 mvprintw(6, 0, "You have encountered %s Level: %.0f\n", Enemyname, Other.p_level);
157 for (loop = 0; Other.p_status != S_INBATTLE && loop < 30; ++loop)
158 /* wait for foe to respond */
160 readrecord(&Other, foeplace);
164 if (Other.p_status != S_INBATTLE)
165 /* foe did not respond */
167 mvprintw(5, 0, "%s is not responding.\n", Enemyname);
170 /* else, we are ready to battle */
176 * determine who is first master
177 * if neither player is faster, check level
178 * if neither level is greater, battle is not allowed
179 * (this should never happen, but we have to handle it)
181 if (Player.p_speed > Other.p_speed)
183 else if (Other.p_speed > Player.p_speed)
185 else if (Player.p_level > Other.p_level)
187 else if (Other.p_level > Player.p_level)
190 /* no one is faster */
192 printw("You can't fight %s yet.", Enemyname);
200 mvprintw(1, 26, "%20.0f", Shield); /* overprint energy */
203 /* take action against foe */
206 /* wait for foe to take action */
208 mvaddstr(4, 0, "Waiting...\n");
212 for (loop = 0; loop < 20; ++loop)
213 /* wait for foe to act */
215 readrecord(&Other, foeplace);
216 if (Other.p_1scratch != oldhits)
217 /* p_1scratch changes to indicate action */
220 /* wait and try again */
228 if (Other.p_1scratch == oldhits)
231 mvaddstr(22, 0, "Timeout: waiting for response. Do you want to wait ? ");
232 ch = getanswer("NY", FALSE);
241 /* foe took action */
243 switch (Other.p_istat)
245 case I_RAN: /* foe ran away */
246 mvprintw(Lines++, 0, "%s ran away!", Enemyname);
249 case I_STUCK: /* foe tried to run, but couldn't */
250 mvprintw(Lines++, 0, "%s tried to run away.", Enemyname);
253 case I_BLEWIT: /* foe tried to luckout, but didn't */
254 mvprintw(Lines++, 0, "%s tried to luckout!", Enemyname);
258 dtemp = Other.p_1scratch - oldhits;
259 mvprintw(Lines++, 0, "%s hit you %.0f times!", Enemyname, dtemp);
264 oldhits = Other.p_1scratch; /* keep track of old hits */
266 if (Other.p_tampered != oldtampered)
267 /* p_tampered changes to relinquish turn */
269 oldtampered = Other.p_tampered;
275 /* decide what happens next */
277 if (Lines > LINES - 2)
284 if (Other.p_istat == I_KILLED || Shield < 0.0)
287 Shield = -2.0; /* insure this value is negative */
291 if (Player.p_istat == I_KILLED)
292 /* we killed foe; award treasre */
294 mvprintw(Lines++, 0, "You killed %s!", Enemyname);
295 Player.p_experience += Other.p_experience;
296 Player.p_crowns += (Player.p_level < 1000.0) ? Other.p_crowns : 0;
297 Player.p_amulets += Other.p_amulets;
298 Player.p_charms += Other.p_charms;
299 collecttaxes(Other.p_gold, Other.p_gems);
300 Player.p_sword = MAX(Player.p_sword, Other.p_sword);
301 Player.p_shield = MAX(Player.p_shield, Other.p_shield);
302 Player.p_quksilver = MAX(Player.p_quksilver, Other.p_quksilver);
303 if (Other.p_virgin && !Player.p_virgin)
305 mvaddstr(Lines++, 0, "You have rescued a virgin. Will you be honorable ? ");
306 if ((ch = getanswer("YN", FALSE)) == 'Y')
307 Player.p_virgin = TRUE;
311 Player.p_experience += 8000.0;
314 sleep(3); /* give other person time to die */
317 else if (Player.p_istat == I_RAN || Other.p_istat == I_RAN)
318 /* either player ran away */
323 /* clean up things and leave */
324 writerecord(&Player, Fileloc); /* update a final time */
325 altercoordinates(0.0, 0.0, A_NEAR); /* move away from battle site */
326 Player.p_energy = Shield; /* set energy to actual value */
327 Player.p_tampered = T_OFF; /* clear p_tampered */
329 more(Lines); /* pause */
332 clrtobot(); /* clear bottom area of screen */
334 if (Player.p_energy < 0.0)
336 death("Interterminal battle");
339 /************************************************************************
341 / FUNCTION NAME: myturn()
343 / FUNCTION: process players action against foe in battle
345 / AUTHOR: E. A. Estes, 2/7/86
351 / MODULES CALLED: writerecord(), inputoption(), floor(), wmove(), drandom(),
352 / waddstr(), wrefresh(), mvprintw(), wclrtoeol(), wclrtobot()
354 / GLOBAL INPUTS: Lines, Other, Player, *stdscr, Fileloc, Luckout,
357 / GLOBAL OUTPUTS: Foestrikes, Lines, Player, Luckout
360 / Take action action against foe, and decide who is master
361 / for next iteration.
363 *************************************************************************/
367 double dtemp; /* for temporary calculations */
370 mvaddstr(7, 0, "1:Fight 2:Run Away! 3:Power Blast ");
374 addstr("4:Luckout ");
383 dtemp = ROLL(2.0, Player.p_might);
385 mvprintw(Lines++, 0, "You hit %s %.0f times!", Enemyname, dtemp);
387 Player.p_1scratch += dtemp;
388 Player.p_istat = I_OFF;
391 case '2': /* run away */
392 Player.p_1scratch -= 1.0; /* change this to indicate action */
393 if (drandom() > 0.25)
395 mvaddstr(Lines++, 0, "You got away!");
396 Player.p_istat = I_RAN;
400 mvprintw(Lines++, 0, "%s is still after you!", Enemyname);
401 Player.p_istat = I_STUCK;
405 case '3': /* power blast */
406 dtemp = MIN(Player.p_mana, Player.p_level * 5.0);
407 Player.p_mana -= dtemp;
408 dtemp *= (drandom() + 0.5) * Player.p_magiclvl * 0.2 + 2.0;
409 mvprintw(Lines++, 0, "You blasted %s !", Enemyname);
412 case '4': /* luckout */
413 if (Luckout || drandom() > 0.1)
416 mvaddstr(Lines++, 0, "You already tried that!");
419 mvaddstr(Lines++, 0, "Not this time . . .");
423 Player.p_1scratch -= 1.0;
424 Player.p_istat = I_BLEWIT;
428 mvaddstr(Lines++, 0, "You just lucked out!");
429 Player.p_1scratch = Other.p_energy * 1.1;
435 Player.p_1scratch = floor(Player.p_1scratch); /* clean up any mess */
437 if (Player.p_1scratch > Other.p_energy)
438 Player.p_istat = I_KILLED;
439 else if (drandom() * Player.p_speed < drandom() * Other.p_speed)
440 /* relinquish control */
446 writerecord(&Player, Fileloc); /* let foe know what we did */
449 /************************************************************************
451 / FUNCTION NAME: checktampered()
453 / FUNCTION: check if current player has been tampered with
455 / AUTHOR: E. A. Estes, 12/4/85
461 / MODULES CALLED: readrecord(), fread(), fseek(), tampered(), writevoid()
463 / GLOBAL INPUTS: *Energyvoidfp, Other, Player, Fileloc, Enrgyvoid
465 / GLOBAL OUTPUTS: Enrgyvoid
468 / Check for energy voids, holy grail, and tampering by other
471 *************************************************************************/
475 long loc = 0L; /* location in energy void file */
477 /* first check for energy voids */
478 fseek(Energyvoidfp, 0L, 0);
479 while (fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp) == 1)
480 if (Enrgyvoid.ev_active
481 && Enrgyvoid.ev_x == Player.p_x
482 && Enrgyvoid.ev_y == Player.p_y)
486 /* not the holy grail; inactivate energy void */
488 Enrgyvoid.ev_active = FALSE;
489 writevoid(&Enrgyvoid, loc);
490 tampered(T_NRGVOID, 0.0, 0.0);
492 else if (Player.p_status != S_CLOAKED)
494 tampered(T_GRAIL, 0.0, 0.0);
498 loc += SZ_VOIDSTRUCT;
500 /* now check for other things */
501 readrecord(&Other, Fileloc);
502 if (Other.p_tampered != T_OFF)
503 tampered(Other.p_tampered, Other.p_1scratch, Other.p_2scratch);
506 /************************************************************************
508 / FUNCTION NAME: tampered()
510 / FUNCTION: take care of tampering by other players
512 / AUTHOR: E. A. Estes, 12/4/85
515 / int what - what type of tampering
516 / double arg1, arg2 - rest of tampering info
520 / MODULES CALLED: writerecord(), more(), fread(), death(), fseek(), sleep(),
521 / floor(), wmove(), waddch(), drandom(), printw(), altercoordinates(),
522 / waddstr(), wrefresh(), encounter(), writevoid()
524 / GLOBAL INPUTS: Other, Player, *stdscr, Enrgyvoid, *Playersfp
526 / GLOBAL OUTPUTS: Other, Player, Changed, Enrgyvoid
529 / Take care of energy voids, holy grail, decree and intervention
530 / action on current player.
532 *************************************************************************/
534 tampered(what, arg1, arg2)
539 long loc; /* location in file of other players */
544 Player.p_tampered = T_OFF; /* no longer tampered with */
549 addstr("You've hit an energy void !\n");
550 Player.p_mana /= 3.0;
551 Player.p_energy /= 2.0;
552 Player.p_gold = floor(Player.p_gold/1.25) + 0.1;
553 altercoordinates(0.0, 0.0, A_NEAR);
557 addstr("The king transported you ! ");
558 if (Player.p_charms > 0)
560 addstr("But your charm saved you. . .\n");
565 altercoordinates(0.0, 0.0, A_FAR);
571 printw("The king has bestowed %.0f gold pieces on you !\n", arg1);
572 Player.p_gold += arg1;
576 addstr("You've been cursed ! ");
577 if (Player.p_blessing)
579 addstr("But your blessing saved you. . .\n");
580 Player.p_blessing = FALSE;
585 Player.p_poison += 2.0;
586 Player.p_energy = 10.0;
587 Player.p_maxenergy *= 0.95;
588 Player.p_status = S_PLAYING; /* no longer cloaked */
593 addstr("You have been vaporized!\n");
595 death("Vaporization");
599 addstr("The Valar zapped you with a monster!\n");
601 encounter((int) arg1);
605 addstr("The Valar has blessed you!\n");
606 Player.p_energy = (Player.p_maxenergy *= 1.05) + Player.p_shield;
607 Player.p_mana += 500.0;
608 Player.p_strength += 0.5;
609 Player.p_brains += 0.5;
610 Player.p_magiclvl += 0.5;
611 Player.p_poison = MIN(0.5, Player.p_poison);
615 addstr("You've been relocated. . .\n");
616 altercoordinates(arg1, arg2, A_FORCED);
620 addstr("You've been healed!\n");
621 Player.p_poison -= 0.25;
622 Player.p_energy = Player.p_maxenergy + Player.p_shield;
626 addstr("You are no longer Valar!\n");
627 Player.p_specialtype = SC_COUNCIL;
631 addstr("You have found The Holy Grail!!\n");
632 if (Player.p_specialtype < SC_COUNCIL)
633 /* must be council of wise to behold grail */
635 addstr("However, you are not experienced enough to behold it.\n");
636 Player.p_sin *= Player.p_sin;
637 Player.p_mana += 1000;
639 else if (Player.p_specialtype == SC_VALAR
640 || Player.p_specialtype == SC_EXVALAR)
642 addstr("You have made it to the position of Valar once already.\n");
643 addstr("The Grail is of no more use to you now.\n");
647 addstr("It is now time to see if you are worthy to behold it. . .\n");
651 if (drandom() / 2.0 < Player.p_sin)
653 addstr("You have failed!\n");
660 Player.p_experience =
661 Player.p_quickness = 1.0;
663 altercoordinates(1.0, 1.0, A_FORCED);
664 Player.p_level = 0.0;
668 addstr("You made to position of Valar!\n");
669 Player.p_specialtype = SC_VALAR;
671 fseek(Playersfp, 0L, 0);
673 while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
674 /* search for existing valar */
675 if (Other.p_specialtype == SC_VALAR
676 && Other.p_status != S_NOTUSED)
677 /* found old valar */
679 Other.p_tampered = T_EXVALAR;
680 writerecord(&Other, loc);
684 loc += SZ_PLAYERSTRUCT;
688 /* move grail to new location */
689 Enrgyvoid.ev_active = TRUE;
690 Enrgyvoid.ev_x = ROLL(-1.0e6, 2.0e6);
691 Enrgyvoid.ev_y = ROLL(-1.0e6, 2.0e6);
692 writevoid(&Enrgyvoid, 0L);
699 /************************************************************************
701 / FUNCTION NAME: userlist()
703 / FUNCTION: print list of players and locations
705 / AUTHOR: E. A. Estes, 2/28/86
708 / bool ingameflag - set if called while playing
712 / MODULES CALLED: descrstatus(), descrlocation(), more(), fread(), fseek(),
713 / floor(), wmove(), printw(), waddstr(), distance(), wrefresh(),
714 / descrtype(), wclrtobot()
716 / GLOBAL INPUTS: LINES, Other, Circle, Wizard, Player, *stdscr, *Playersfp
718 / GLOBAL OUTPUTS: none
721 / We can only see the coordinate of those closer to the origin
723 / Kings and council of the wise can see and can be seen by everyone.
724 / Palantirs are good for seeing everyone; and the valar can use
725 / one to see through a 'cloak' spell.
726 / The valar has no coordinates, and is completely invisible if
729 *************************************************************************/
734 register int numusers = 0; /* number of users on file */
736 if (ingameflag && Player.p_blindness)
738 mvaddstr(8, 0, "You cannot see anyone.\n");
742 fseek(Playersfp, 0L, 0);
744 "Name X Y Lvl Type Login Status\n");
746 while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
748 if (Other.p_status == S_NOTUSED
749 /* record is unused */
750 || (Other.p_specialtype == SC_VALAR && Other.p_status == S_CLOAKED))
754 /* wizard can see everything on file */
761 /* must be playing for the rest of these conditions */
762 (Player.p_specialtype >= SC_KING
763 /* kings and higher can see others */
764 || Other.p_specialtype >= SC_KING
765 /* kings and higher can be seen by others */
766 || Circle >= CIRCLE(Other.p_x, Other.p_y)
767 /* those nearer the origin can be seen */
768 || Player.p_palantir)
769 /* palantir enables one to see others */
770 && (Other.p_status != S_CLOAKED
771 || (Player.p_specialtype == SC_VALAR && Player.p_palantir))
772 /* not cloaked; valar can see through cloak with a palantir */
773 && Other.p_specialtype != SC_VALAR)
775 /* coordinates should be printed */
776 printw("%-20s %8.0f %8.0f ",
777 Other.p_name, Other.p_x, Other.p_y);
779 /* cannot see player's coordinates */
780 printw("%-20s %19.19s ",
781 Other.p_name, descrlocation(&Other, TRUE));
783 printw("%6.0f %s %-9.9s%s\n", Other.p_level, descrtype(&Other, TRUE),
784 Other.p_login, descrstatus(&Other));
786 if ((numusers % (LINES - 10)) == 0)
794 printw("Total players on file = %d\n", numusers);
798 /************************************************************************
800 / FUNCTION NAME: throneroom()
802 / FUNCTION: king stuff upon entering throne
804 / AUTHOR: E. A. Estes, 12/16/85
810 / MODULES CALLED: writerecord(), fread(), fseek(), fopen(), wmove(), fclose(),
811 / fwrite(), altercoordinates(), waddstr(), fprintf()
813 / GLOBAL INPUTS: *Energyvoidfp, Other, Player, *stdscr,
814 / Enrgyvoid, *Playersfp
816 / GLOBAL OUTPUTS: Other, Player, Changed
819 / If player is not already king, make him/her so if the old king
821 / Clear energy voids with new king.
822 / Print 'decree' prompt.
824 *************************************************************************/
828 FILE *fp; /* to clear energy voids */
829 long loc = 0L; /* location of old king in player file */
831 if (Player.p_specialtype < SC_KING)
832 /* not already king -- assumes crown */
834 fseek(Playersfp, 0L, 0);
835 while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
836 if (Other.p_specialtype == SC_KING && Other.p_status != S_NOTUSED)
839 if (Other.p_status != S_OFF)
840 /* old king is playing */
842 mvaddstr( 4, 0, "The king is playing, so you cannot steal his throne\n");
843 altercoordinates(0.0, 0.0, A_NEAR);
848 /* old king is not playing - remove him/her */
850 Other.p_specialtype = SC_NONE;
853 writerecord(&Other, loc);
858 loc += SZ_PLAYERSTRUCT;
860 /* make player new king */
862 Player.p_specialtype = SC_KING;
863 mvaddstr(4, 0, "You have become king!\n");
865 /* let everyone else know */
866 fp = fopen(_PATH_MESS, "w");
867 fprintf(fp, "All hail the new king!");
870 /* clear all energy voids; retain location of holy grail */
871 fseek(Energyvoidfp, 0L, 0);
872 fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp);
873 fp = fopen(_PATH_VOID, "w");
874 fwrite((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, fp);
878 mvaddstr(6, 0, "0:Decree ");
881 /************************************************************************
883 / FUNCTION NAME: dotampered()
885 / FUNCTION: king and valar special options
887 / AUTHOR: E. A. Estes, 2/28/86
893 / MODULES CALLED: writerecord(), truncstring(), fread(), fseek(), fopen(),
894 / floor(), wmove(), drandom(), fclose(), fwrite(), sscanf(), strcmp(),
895 / infloat(), waddstr(), findname(), distance(), userlist(), mvprintw(),
896 / allocvoid(), getanswer(), getstring(), wclrtoeol(), writevoid()
898 / GLOBAL INPUTS: *Energyvoidfp, Other, Illcmd[], Wizard, Player, *stdscr,
899 / Databuf[], Enrgyvoid
901 / GLOBAL OUTPUTS: Other, Player, Enrgyvoid
904 / Tamper with other players. Handle king/valar specific options.
906 *************************************************************************/
910 short tamper; /* value for tampering with other players */
911 char *option; /* pointer to option description */
912 double temp1 = 0.0, temp2 = 0.0; /* other tampering values */
914 long loc; /* location in energy void file */
915 FILE *fp; /* for opening gold file */
919 if (Player.p_specialtype < SC_COUNCIL && !Wizard)
922 addstr("1:Transport 2:Curse 3:Energy Void 4:Bestow 5:Collect Taxes ");
924 ch = getanswer(" ", TRUE);
930 case '1': /* transport someone */
931 tamper = T_TRANSPORT;
932 option = "transport";
935 case '2': /* curse another */
940 case '3': /* create energy void */
941 if ((loc = allocvoid()) > 20L * SZ_VOIDSTRUCT)
942 /* can only have 20 void active at once */
943 mvaddstr(5, 0, "Sorry, void creation limit reached.\n");
946 addstr("Enter the X Y coordinates of void ? ");
947 getstring(Databuf, SZ_DATABUF);
948 sscanf(Databuf, "%lf %lf", &temp1, &temp2);
949 Enrgyvoid.ev_x = floor(temp1);
950 Enrgyvoid.ev_y = floor(temp2);
951 Enrgyvoid.ev_active = TRUE;
952 writevoid(&Enrgyvoid, loc);
953 mvaddstr(5, 0, "It is done.\n");
957 case '4': /* bestow gold to subject */
959 addstr("How much gold to bestow ? ");
961 if (temp1 > Player.p_gold || temp1 < 0)
963 mvaddstr(5, 0, "You don't have that !\n");
967 /* adjust gold after we are sure it will be given to someone */
968 option = "give gold to";
971 case '5': /* collect accumulated taxes */
972 if ((fp = fopen(_PATH_GOLD, "r+")) != NULL)
975 fread((char *) &temp1, sizeof(double), 1, fp);
977 /* clear out value */
979 fwrite((char *) &temp2, sizeof(double), 1, fp);
983 mvprintw(4, 0, "You have collected %.0f in gold.\n", temp1);
984 Player.p_gold += floor(temp1);
990 /* end of king options */
993 /* council of wise, valar, wizard options */
996 if (Player.p_palantir || Wizard)
997 addstr("2:Seek Grail ");
998 if (Player.p_specialtype == SC_VALAR || Wizard)
999 addstr("3:Throw Monster 4:Relocate 5:Bless ");
1001 addstr("6:Vaporize ");
1003 ch = getanswer(" ", TRUE);
1006 if (ch > '2' && Player.p_specialtype != SC_VALAR)
1012 if (Player.p_mana < MM_INTERVENE)
1014 mvaddstr(5, 0, "No mana left.\n");
1018 Player.p_mana -= MM_INTERVENE;
1023 case '1': /* heal another */
1028 case '2': /* seek grail */
1029 if (Player.p_palantir)
1030 /* need a palantir to seek */
1032 fseek(Energyvoidfp, 0L, 0);
1033 fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp);
1034 temp1 = distance(Player.p_x, Enrgyvoid.ev_x, Player.p_y, Enrgyvoid.ev_y);
1035 temp1 += ROLL(-temp1 / 10.0, temp1 / 5.0); /* add some error */
1036 mvprintw(5, 0, "The palantir says the Grail is about %.0f away.\n", temp1);
1040 mvaddstr(5, 0, "You need a palantir to seek the Grail.\n");
1043 case '3': /* lob monster at someone */
1044 mvaddstr(4, 0, "Which monster [0-99] ? ");
1046 temp1 = MAX(0.0, MIN(99.0, temp1));
1048 option = "throw a monster at";
1051 case '4': /* move another player */
1052 mvaddstr(4, 0, "New X Y coordinates ? ");
1053 getstring(Databuf, SZ_DATABUF);
1054 sscanf(Databuf, "%lf %lf", &temp1, &temp2);
1055 tamper = T_RELOCATE;
1056 option = "relocate";
1059 case '5': /* bless a player */
1064 case '6': /* kill off a player */
1067 tamper = T_VAPORIZED;
1068 option = "vaporize";
1078 /* adjust age after we are sure intervention will be done */
1079 /* end of valar, etc. options */
1083 /* prompt for player to affect */
1085 mvprintw(4, 0, "Who do you want to %s ? ", option);
1086 getstring(Databuf, SZ_DATABUF);
1087 truncstring(Databuf);
1089 if (Databuf[0] == '\0')
1095 if (strcmp(Player.p_name, Databuf) != 0)
1096 /* name other than self */
1098 if ((loc = findname(Databuf, &Other)) >= 0L)
1100 if (Other.p_tampered != T_OFF)
1102 mvaddstr(5, 0, "That person has something pending already.\n");
1107 if (tamper == T_RELOCATE
1108 && CIRCLE(temp1, temp2) < CIRCLE(Other.p_x, Other.p_y)
1110 mvaddstr(5, 0, "Cannot move someone closer to the Lord's Chamber.\n");
1113 if (tamper == T_BESTOW) Player.p_gold -= floor(temp1);
1114 if (!Wizard && (tamper == T_HEAL || tamper == T_MONSTER ||
1115 tamper == T_RELOCATE || tamper == T_BLESSED))
1116 Player.p_age += N_AGE; /* age penalty */
1117 Other.p_tampered = tamper;
1118 Other.p_1scratch = floor(temp1);
1119 Other.p_2scratch = floor(temp2);
1120 writerecord(&Other, loc);
1121 mvaddstr(5, 0, "It is done.\n");
1127 /* player not found */
1128 mvaddstr(5, 0, "There is no one by that name.\n");
1132 mvaddstr(5, 0, "You may not do it to yourself!\n");
1135 /************************************************************************
1137 / FUNCTION NAME: writevoid()
1139 / FUNCTION: update energy void entry in energy void file
1141 / AUTHOR: E. A. Estes, 12/4/85
1144 / struct energyvoid *vp - pointer to structure to write to file
1145 / long loc - location in file to update
1147 / RETURN VALUE: none
1149 / MODULES CALLED: fseek(), fwrite(), fflush()
1151 / GLOBAL INPUTS: *Energyvoidfp
1153 / GLOBAL OUTPUTS: none
1156 / Write out energy void structure at specified location.
1158 *************************************************************************/
1161 register struct energyvoid *vp;
1165 fseek(Energyvoidfp, loc, 0);
1166 fwrite((char *) vp, SZ_VOIDSTRUCT, 1, Energyvoidfp);
1167 fflush(Energyvoidfp);
1168 fseek(Energyvoidfp, 0L, 0);
1171 /************************************************************************
1173 / FUNCTION NAME: allocvoid()
1175 / FUNCTION: allocate space for a new energy void
1177 / AUTHOR: E. A. Estes, 12/4/85
1181 / RETURN VALUE: location of new energy void space
1183 / MODULES CALLED: fread(), fseek()
1185 / GLOBAL INPUTS: *Energyvoidfp, Enrgyvoid
1187 / GLOBAL OUTPUTS: none
1190 / Search energy void file for an inactive entry and return its
1192 / If no inactive ones are found, return one more than last location.
1194 *************************************************************************/
1199 long loc = 0L; /* location of new energy void */
1201 fseek(Energyvoidfp, 0L, 0);
1202 while (fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp) == 1)
1203 if (Enrgyvoid.ev_active)
1204 loc += SZ_VOIDSTRUCT;