2 * interplayer.c - player to player routines for Phantasia
4 * $FreeBSD: src/games/phantasia/interplayer.c,v 1.6 1999/11/16 02:57:33 billf Exp $
10 /************************************************************************
12 / FUNCTION NAME: checkbattle()
14 / FUNCTION: check to see if current player should battle another
16 / AUTHOR: E. A. Estes, 12/4/85
22 / MODULES CALLED: battleplayer(), fread(), fseek()
24 / GLOBAL INPUTS: Other, Users, Player, Fileloc, *Playersfp
26 / GLOBAL OUTPUTS: Users
29 / Seach player file for a foe at the same coordinates as the
31 / Also update user count.
33 *************************************************************************/
37 long foeloc = 0L; /* location in file of person to fight */
40 fseek(Playersfp, 0L, 0);
42 while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
44 if (Other.p_status != S_OFF
45 && Other.p_status != S_NOTUSED
46 && Other.p_status != S_HUNGUP
47 && (Other.p_status != S_CLOAKED || Other.p_specialtype != SC_VALAR))
48 /* player is on and not a cloaked valar */
52 if (Player.p_x == Other.p_x
53 && Player.p_y == Other.p_y
54 /* same coordinates */
57 && Player.p_status == S_PLAYING
58 && (Other.p_status == S_PLAYING || Other.p_status == S_INBATTLE)
59 /* both are playing */
60 && Other.p_specialtype != SC_VALAR
61 && Player.p_specialtype != SC_VALAR)
62 /* neither is valar */
68 foeloc += SZ_PLAYERSTRUCT;
72 /************************************************************************
74 / FUNCTION NAME: battleplayer()
76 / FUNCTION: inter-terminal battle with another player
78 / AUTHOR: E. A. Estes, 2/15/86
81 / long foeplace - location in player file of person to battle
85 / MODULES CALLED: readrecord(), readmessage(), writerecord(), collecttaxes(),
86 / displaystats(), fabs(), more(), death(), sleep(), wmove(), waddch(), printw(),
87 / myturn(), altercoordinates(), waddstr(), wrefresh(), mvprintw(),
88 / getanswer(), wclrtoeol(), wclrtobot()
90 / GLOBAL INPUTS: Foestrikes, LINES, Lines, Other, Shield, Player, *stdscr,
93 / GLOBAL OUTPUTS: Foestrikes, Lines, Shield, Player, Luckout, *Enemyname
96 / Inter-terminal battle is a very fragile and slightly klugy thing.
97 / At any time, one player is master and the other is slave.
98 / We pick who is master first by speed and level. After that,
99 / the slave waits for the master to relinquish its turn, and
100 / the slave becomes master, and so on.
102 / The items in the player structure which control the handshake are:
104 / master increments this to relinquish control
106 / master sets this to specify particular action
108 / set to total damage inflicted so far; changes to indicate action
110 *************************************************************************/
112 battleplayer(foeplace)
115 double dtemp; /* for temporary calculations */
116 double oldhits = 0.0; /* previous damage inflicted by foe */
117 int loop; /* for timing out */
119 short oldtampered; /* old value of foe's p_tampered */
123 mvaddstr(4, 0, "Preparing for battle!\n");
130 /* set up variables, file, etc. */
131 Player.p_status = S_INBATTLE;
132 Shield = Player.p_energy;
134 /* if p_tampered is not 0, someone else may try to change it (king, etc.) */
135 Player.p_tampered = oldtampered = 1;
136 Player.p_1scratch = 0.0;
137 Player.p_istat = I_OFF;
139 readrecord(&Other, foeplace);
140 if (fabs(Player.p_level - Other.p_level) > 20.0)
141 /* see if players are greatly mismatched */
143 dtemp = (Player.p_level - Other.p_level) / MAX(Player.p_level, Other.p_level);
145 /* foe outweighs this one */
146 Player.p_speed *= 2.0;
149 writerecord(&Player, Fileloc); /* write out all our info */
151 if (Player.p_blindness)
152 Enemyname = "someone";
154 Enemyname = Other.p_name;
156 mvprintw(6, 0, "You have encountered %s Level: %.0f\n", Enemyname, Other.p_level);
159 for (loop = 0; Other.p_status != S_INBATTLE && loop < 30; ++loop)
160 /* wait for foe to respond */
162 readrecord(&Other, foeplace);
166 if (Other.p_status != S_INBATTLE)
167 /* foe did not respond */
169 mvprintw(5, 0, "%s is not responding.\n", Enemyname);
172 /* else, we are ready to battle */
178 * determine who is first master
179 * if neither player is faster, check level
180 * if neither level is greater, battle is not allowed
181 * (this should never happen, but we have to handle it)
183 if (Player.p_speed > Other.p_speed)
185 else if (Other.p_speed > Player.p_speed)
187 else if (Player.p_level > Other.p_level)
189 else if (Other.p_level > Player.p_level)
192 /* no one is faster */
194 printw("You can't fight %s yet.", Enemyname);
202 mvprintw(1, 26, "%20.0f", Shield); /* overprint energy */
205 /* take action against foe */
208 /* wait for foe to take action */
210 mvaddstr(4, 0, "Waiting...\n");
214 for (loop = 0; loop < 20; ++loop)
215 /* wait for foe to act */
217 readrecord(&Other, foeplace);
218 if (Other.p_1scratch != oldhits)
219 /* p_1scratch changes to indicate action */
222 /* wait and try again */
230 if (Other.p_1scratch == oldhits)
233 mvaddstr(22, 0, "Timeout: waiting for response. Do you want to wait ? ");
234 ch = getanswer("NY", FALSE);
243 /* foe took action */
245 switch (Other.p_istat)
247 case I_RAN: /* foe ran away */
248 mvprintw(Lines++, 0, "%s ran away!", Enemyname);
251 case I_STUCK: /* foe tried to run, but couldn't */
252 mvprintw(Lines++, 0, "%s tried to run away.", Enemyname);
255 case I_BLEWIT: /* foe tried to luckout, but didn't */
256 mvprintw(Lines++, 0, "%s tried to luckout!", Enemyname);
260 dtemp = Other.p_1scratch - oldhits;
261 mvprintw(Lines++, 0, "%s hit you %.0f times!", Enemyname, dtemp);
266 oldhits = Other.p_1scratch; /* keep track of old hits */
268 if (Other.p_tampered != oldtampered)
269 /* p_tampered changes to relinquish turn */
271 oldtampered = Other.p_tampered;
277 /* decide what happens next */
279 if (Lines > LINES - 2)
286 if (Other.p_istat == I_KILLED || Shield < 0.0)
289 Shield = -2.0; /* insure this value is negative */
293 if (Player.p_istat == I_KILLED)
294 /* we killed foe; award treasre */
296 mvprintw(Lines++, 0, "You killed %s!", Enemyname);
297 Player.p_experience += Other.p_experience;
298 Player.p_crowns += (Player.p_level < 1000.0) ? Other.p_crowns : 0;
299 Player.p_amulets += Other.p_amulets;
300 Player.p_charms += Other.p_charms;
301 collecttaxes(Other.p_gold, Other.p_gems);
302 Player.p_sword = MAX(Player.p_sword, Other.p_sword);
303 Player.p_shield = MAX(Player.p_shield, Other.p_shield);
304 Player.p_quksilver = MAX(Player.p_quksilver, Other.p_quksilver);
305 if (Other.p_virgin && !Player.p_virgin)
307 mvaddstr(Lines++, 0, "You have rescued a virgin. Will you be honorable ? ");
308 if ((ch = getanswer("YN", FALSE)) == 'Y')
309 Player.p_virgin = TRUE;
313 Player.p_experience += 8000.0;
316 sleep(3); /* give other person time to die */
319 else if (Player.p_istat == I_RAN || Other.p_istat == I_RAN)
320 /* either player ran away */
325 /* clean up things and leave */
326 writerecord(&Player, Fileloc); /* update a final time */
327 altercoordinates(0.0, 0.0, A_NEAR); /* move away from battle site */
328 Player.p_energy = Shield; /* set energy to actual value */
329 Player.p_tampered = T_OFF; /* clear p_tampered */
331 more(Lines); /* pause */
334 clrtobot(); /* clear bottom area of screen */
336 if (Player.p_energy < 0.0)
338 death("Interterminal battle");
341 /************************************************************************
343 / FUNCTION NAME: myturn()
345 / FUNCTION: process players action against foe in battle
347 / AUTHOR: E. A. Estes, 2/7/86
353 / MODULES CALLED: writerecord(), inputoption(), floor(), wmove(), drandom(),
354 / waddstr(), wrefresh(), mvprintw(), wclrtoeol(), wclrtobot()
356 / GLOBAL INPUTS: Lines, Other, Player, *stdscr, Fileloc, Luckout,
359 / GLOBAL OUTPUTS: Foestrikes, Lines, Player, Luckout
362 / Take action action against foe, and decide who is master
363 / for next iteration.
365 *************************************************************************/
369 double dtemp; /* for temporary calculations */
372 mvaddstr(7, 0, "1:Fight 2:Run Away! 3:Power Blast ");
376 addstr("4:Luckout ");
385 dtemp = ROLL(2.0, Player.p_might);
387 mvprintw(Lines++, 0, "You hit %s %.0f times!", Enemyname, dtemp);
389 Player.p_1scratch += dtemp;
390 Player.p_istat = I_OFF;
393 case '2': /* run away */
394 Player.p_1scratch -= 1.0; /* change this to indicate action */
395 if (drandom() > 0.25)
397 mvaddstr(Lines++, 0, "You got away!");
398 Player.p_istat = I_RAN;
402 mvprintw(Lines++, 0, "%s is still after you!", Enemyname);
403 Player.p_istat = I_STUCK;
407 case '3': /* power blast */
408 dtemp = MIN(Player.p_mana, Player.p_level * 5.0);
409 Player.p_mana -= dtemp;
410 dtemp *= (drandom() + 0.5) * Player.p_magiclvl * 0.2 + 2.0;
411 mvprintw(Lines++, 0, "You blasted %s !", Enemyname);
414 case '4': /* luckout */
415 if (Luckout || drandom() > 0.1)
418 mvaddstr(Lines++, 0, "You already tried that!");
421 mvaddstr(Lines++, 0, "Not this time . . .");
425 Player.p_1scratch -= 1.0;
426 Player.p_istat = I_BLEWIT;
430 mvaddstr(Lines++, 0, "You just lucked out!");
431 Player.p_1scratch = Other.p_energy * 1.1;
437 Player.p_1scratch = floor(Player.p_1scratch); /* clean up any mess */
439 if (Player.p_1scratch > Other.p_energy)
440 Player.p_istat = I_KILLED;
441 else if (drandom() * Player.p_speed < drandom() * Other.p_speed)
442 /* relinquish control */
448 writerecord(&Player, Fileloc); /* let foe know what we did */
451 /************************************************************************
453 / FUNCTION NAME: checktampered()
455 / FUNCTION: check if current player has been tampered with
457 / AUTHOR: E. A. Estes, 12/4/85
463 / MODULES CALLED: readrecord(), fread(), fseek(), tampered(), writevoid()
465 / GLOBAL INPUTS: *Energyvoidfp, Other, Player, Fileloc, Enrgyvoid
467 / GLOBAL OUTPUTS: Enrgyvoid
470 / Check for energy voids, holy grail, and tampering by other
473 *************************************************************************/
477 long loc = 0L; /* location in energy void file */
479 /* first check for energy voids */
480 fseek(Energyvoidfp, 0L, 0);
481 while (fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp) == 1)
482 if (Enrgyvoid.ev_active
483 && Enrgyvoid.ev_x == Player.p_x
484 && Enrgyvoid.ev_y == Player.p_y)
488 /* not the holy grail; inactivate energy void */
490 Enrgyvoid.ev_active = FALSE;
491 writevoid(&Enrgyvoid, loc);
492 tampered(T_NRGVOID, 0.0, 0.0);
494 else if (Player.p_status != S_CLOAKED)
496 tampered(T_GRAIL, 0.0, 0.0);
500 loc += SZ_VOIDSTRUCT;
502 /* now check for other things */
503 readrecord(&Other, Fileloc);
504 if (Other.p_tampered != T_OFF)
505 tampered(Other.p_tampered, Other.p_1scratch, Other.p_2scratch);
508 /************************************************************************
510 / FUNCTION NAME: tampered()
512 / FUNCTION: take care of tampering by other players
514 / AUTHOR: E. A. Estes, 12/4/85
517 / int what - what type of tampering
518 / double arg1, arg2 - rest of tampering info
522 / MODULES CALLED: writerecord(), more(), fread(), death(), fseek(), sleep(),
523 / floor(), wmove(), waddch(), drandom(), printw(), altercoordinates(),
524 / waddstr(), wrefresh(), encounter(), writevoid()
526 / GLOBAL INPUTS: Other, Player, *stdscr, Enrgyvoid, *Playersfp
528 / GLOBAL OUTPUTS: Other, Player, Changed, Enrgyvoid
531 / Take care of energy voids, holy grail, decree and intervention
532 / action on current player.
534 *************************************************************************/
536 tampered(what, arg1, arg2)
541 long loc; /* location in file of other players */
546 Player.p_tampered = T_OFF; /* no longer tampered with */
551 addstr("You've hit an energy void !\n");
552 Player.p_mana /= 3.0;
553 Player.p_energy /= 2.0;
554 Player.p_gold = floor(Player.p_gold/1.25) + 0.1;
555 altercoordinates(0.0, 0.0, A_NEAR);
559 addstr("The king transported you ! ");
560 if (Player.p_charms > 0)
562 addstr("But your charm saved you. . .\n");
567 altercoordinates(0.0, 0.0, A_FAR);
573 printw("The king has bestowed %.0f gold pieces on you !\n", arg1);
574 Player.p_gold += arg1;
578 addstr("You've been cursed ! ");
579 if (Player.p_blessing)
581 addstr("But your blessing saved you. . .\n");
582 Player.p_blessing = FALSE;
587 Player.p_poison += 2.0;
588 Player.p_energy = 10.0;
589 Player.p_maxenergy *= 0.95;
590 Player.p_status = S_PLAYING; /* no longer cloaked */
595 addstr("You have been vaporized!\n");
597 death("Vaporization");
601 addstr("The Valar zapped you with a monster!\n");
603 encounter((int) arg1);
607 addstr("The Valar has blessed you!\n");
608 Player.p_energy = (Player.p_maxenergy *= 1.05) + Player.p_shield;
609 Player.p_mana += 500.0;
610 Player.p_strength += 0.5;
611 Player.p_brains += 0.5;
612 Player.p_magiclvl += 0.5;
613 Player.p_poison = MIN(0.5, Player.p_poison);
617 addstr("You've been relocated. . .\n");
618 altercoordinates(arg1, arg2, A_FORCED);
622 addstr("You've been healed!\n");
623 Player.p_poison -= 0.25;
624 Player.p_energy = Player.p_maxenergy + Player.p_shield;
628 addstr("You are no longer Valar!\n");
629 Player.p_specialtype = SC_COUNCIL;
633 addstr("You have found The Holy Grail!!\n");
634 if (Player.p_specialtype < SC_COUNCIL)
635 /* must be council of wise to behold grail */
637 addstr("However, you are not experienced enough to behold it.\n");
638 Player.p_sin *= Player.p_sin;
639 Player.p_mana += 1000;
641 else if (Player.p_specialtype == SC_VALAR
642 || Player.p_specialtype == SC_EXVALAR)
644 addstr("You have made it to the position of Valar once already.\n");
645 addstr("The Grail is of no more use to you now.\n");
649 addstr("It is now time to see if you are worthy to behold it. . .\n");
653 if (drandom() / 2.0 < Player.p_sin)
655 addstr("You have failed!\n");
662 Player.p_experience =
663 Player.p_quickness = 1.0;
665 altercoordinates(1.0, 1.0, A_FORCED);
666 Player.p_level = 0.0;
670 addstr("You made to position of Valar!\n");
671 Player.p_specialtype = SC_VALAR;
673 fseek(Playersfp, 0L, 0);
675 while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
676 /* search for existing valar */
677 if (Other.p_specialtype == SC_VALAR
678 && Other.p_status != S_NOTUSED)
679 /* found old valar */
681 Other.p_tampered = T_EXVALAR;
682 writerecord(&Other, loc);
686 loc += SZ_PLAYERSTRUCT;
690 /* move grail to new location */
691 Enrgyvoid.ev_active = TRUE;
692 Enrgyvoid.ev_x = ROLL(-1.0e6, 2.0e6);
693 Enrgyvoid.ev_y = ROLL(-1.0e6, 2.0e6);
694 writevoid(&Enrgyvoid, 0L);
701 /************************************************************************
703 / FUNCTION NAME: userlist()
705 / FUNCTION: print list of players and locations
707 / AUTHOR: E. A. Estes, 2/28/86
710 / bool ingameflag - set if called while playing
714 / MODULES CALLED: descrstatus(), descrlocation(), more(), fread(), fseek(),
715 / floor(), wmove(), printw(), waddstr(), distance(), wrefresh(),
716 / descrtype(), wclrtobot()
718 / GLOBAL INPUTS: LINES, Other, Circle, Wizard, Player, *stdscr, *Playersfp
720 / GLOBAL OUTPUTS: none
723 / We can only see the coordinate of those closer to the origin
725 / Kings and council of the wise can see and can be seen by everyone.
726 / Palantirs are good for seeing everyone; and the valar can use
727 / one to see through a 'cloak' spell.
728 / The valar has no coordinates, and is completely invisible if
731 *************************************************************************/
736 int numusers = 0; /* number of users on file */
738 if (ingameflag && Player.p_blindness)
740 mvaddstr(8, 0, "You cannot see anyone.\n");
744 fseek(Playersfp, 0L, 0);
746 "Name X Y Lvl Type Login Status\n");
748 while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
750 if (Other.p_status == S_NOTUSED
751 /* record is unused */
752 || (Other.p_specialtype == SC_VALAR && Other.p_status == S_CLOAKED))
756 /* wizard can see everything on file */
763 /* must be playing for the rest of these conditions */
764 (Player.p_specialtype >= SC_KING
765 /* kings and higher can see others */
766 || Other.p_specialtype >= SC_KING
767 /* kings and higher can be seen by others */
768 || Circle >= CIRCLE(Other.p_x, Other.p_y)
769 /* those nearer the origin can be seen */
770 || Player.p_palantir)
771 /* palantir enables one to see others */
772 && (Other.p_status != S_CLOAKED
773 || (Player.p_specialtype == SC_VALAR && Player.p_palantir))
774 /* not cloaked; valar can see through cloak with a palantir */
775 && Other.p_specialtype != SC_VALAR)
777 /* coordinates should be printed */
778 printw("%-20s %8.0f %8.0f ",
779 Other.p_name, Other.p_x, Other.p_y);
781 /* cannot see player's coordinates */
782 printw("%-20s %19.19s ",
783 Other.p_name, descrlocation(&Other, TRUE));
785 printw("%6.0f %s %-9.9s%s\n", Other.p_level, descrtype(&Other, TRUE),
786 Other.p_login, descrstatus(&Other));
788 if ((numusers % (LINES - 10)) == 0)
796 printw("Total players on file = %d\n", numusers);
800 /************************************************************************
802 / FUNCTION NAME: throneroom()
804 / FUNCTION: king stuff upon entering throne
806 / AUTHOR: E. A. Estes, 12/16/85
812 / MODULES CALLED: writerecord(), fread(), fseek(), fopen(), wmove(), fclose(),
813 / fwrite(), altercoordinates(), waddstr(), fprintf()
815 / GLOBAL INPUTS: *Energyvoidfp, Other, Player, *stdscr,
816 / Enrgyvoid, *Playersfp
818 / GLOBAL OUTPUTS: Other, Player, Changed
821 / If player is not already king, make him/her so if the old king
823 / Clear energy voids with new king.
824 / Print 'decree' prompt.
826 *************************************************************************/
830 FILE *fp; /* to clear energy voids */
831 long loc = 0L; /* location of old king in player file */
833 if (Player.p_specialtype < SC_KING)
834 /* not already king -- assumes crown */
836 fseek(Playersfp, 0L, 0);
837 while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
838 if (Other.p_specialtype == SC_KING && Other.p_status != S_NOTUSED)
841 if (Other.p_status != S_OFF)
842 /* old king is playing */
844 mvaddstr( 4, 0, "The king is playing, so you cannot steal his throne\n");
845 altercoordinates(0.0, 0.0, A_NEAR);
850 /* old king is not playing - remove him/her */
852 Other.p_specialtype = SC_NONE;
855 writerecord(&Other, loc);
860 loc += SZ_PLAYERSTRUCT;
862 /* make player new king */
864 Player.p_specialtype = SC_KING;
865 mvaddstr(4, 0, "You have become king!\n");
867 /* let everyone else know */
868 fp = fopen(_PATH_MESS, "w");
869 fprintf(fp, "All hail the new king!");
872 /* clear all energy voids; retain location of holy grail */
873 fseek(Energyvoidfp, 0L, 0);
874 fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp);
875 fp = fopen(_PATH_VOID, "w");
876 fwrite((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, fp);
880 mvaddstr(6, 0, "0:Decree ");
883 /************************************************************************
885 / FUNCTION NAME: dotampered()
887 / FUNCTION: king and valar special options
889 / AUTHOR: E. A. Estes, 2/28/86
895 / MODULES CALLED: writerecord(), truncstring(), fread(), fseek(), fopen(),
896 / floor(), wmove(), drandom(), fclose(), fwrite(), sscanf(), strcmp(),
897 / infloat(), waddstr(), findname(), distance(), userlist(), mvprintw(),
898 / allocvoid(), getanswer(), getstring(), wclrtoeol(), writevoid()
900 / GLOBAL INPUTS: *Energyvoidfp, Other, Illcmd[], Wizard, Player, *stdscr,
901 / Databuf[], Enrgyvoid
903 / GLOBAL OUTPUTS: Other, Player, Enrgyvoid
906 / Tamper with other players. Handle king/valar specific options.
908 *************************************************************************/
912 short tamper; /* value for tampering with other players */
913 char *option; /* pointer to option description */
914 double temp1 = 0.0, temp2 = 0.0; /* other tampering values */
916 long loc; /* location in energy void file */
917 FILE *fp; /* for opening gold file */
921 if (Player.p_specialtype < SC_COUNCIL && !Wizard)
924 addstr("1:Transport 2:Curse 3:Energy Void 4:Bestow 5:Collect Taxes ");
926 ch = getanswer(" ", TRUE);
932 case '1': /* transport someone */
933 tamper = T_TRANSPORT;
934 option = "transport";
937 case '2': /* curse another */
942 case '3': /* create energy void */
943 if ((loc = allocvoid()) > 20L * SZ_VOIDSTRUCT)
944 /* can only have 20 void active at once */
945 mvaddstr(5, 0, "Sorry, void creation limit reached.\n");
948 addstr("Enter the X Y coordinates of void ? ");
949 getstring(Databuf, SZ_DATABUF);
950 sscanf(Databuf, "%lf %lf", &temp1, &temp2);
951 Enrgyvoid.ev_x = floor(temp1);
952 Enrgyvoid.ev_y = floor(temp2);
953 Enrgyvoid.ev_active = TRUE;
954 writevoid(&Enrgyvoid, loc);
955 mvaddstr(5, 0, "It is done.\n");
959 case '4': /* bestow gold to subject */
961 addstr("How much gold to bestow ? ");
963 if (temp1 > Player.p_gold || temp1 < 0)
965 mvaddstr(5, 0, "You don't have that !\n");
969 /* adjust gold after we are sure it will be given to someone */
970 option = "give gold to";
973 case '5': /* collect accumulated taxes */
974 if ((fp = fopen(_PATH_GOLD, "r+")) != NULL)
977 fread((char *) &temp1, sizeof(double), 1, fp);
979 /* clear out value */
981 fwrite((char *) &temp2, sizeof(double), 1, fp);
985 mvprintw(4, 0, "You have collected %.0f in gold.\n", temp1);
986 Player.p_gold += floor(temp1);
992 /* end of king options */
995 /* council of wise, valar, wizard options */
998 if (Player.p_palantir || Wizard)
999 addstr("2:Seek Grail ");
1000 if (Player.p_specialtype == SC_VALAR || Wizard)
1001 addstr("3:Throw Monster 4:Relocate 5:Bless ");
1003 addstr("6:Vaporize ");
1005 ch = getanswer(" ", TRUE);
1008 if (ch > '2' && Player.p_specialtype != SC_VALAR)
1014 if (Player.p_mana < MM_INTERVENE)
1016 mvaddstr(5, 0, "No mana left.\n");
1020 Player.p_mana -= MM_INTERVENE;
1025 case '1': /* heal another */
1030 case '2': /* seek grail */
1031 if (Player.p_palantir)
1032 /* need a palantir to seek */
1034 fseek(Energyvoidfp, 0L, 0);
1035 fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp);
1036 temp1 = distance(Player.p_x, Enrgyvoid.ev_x, Player.p_y, Enrgyvoid.ev_y);
1037 temp1 += ROLL(-temp1 / 10.0, temp1 / 5.0); /* add some error */
1038 mvprintw(5, 0, "The palantir says the Grail is about %.0f away.\n", temp1);
1042 mvaddstr(5, 0, "You need a palantir to seek the Grail.\n");
1045 case '3': /* lob monster at someone */
1046 mvaddstr(4, 0, "Which monster [0-99] ? ");
1048 temp1 = MAX(0.0, MIN(99.0, temp1));
1050 option = "throw a monster at";
1053 case '4': /* move another player */
1054 mvaddstr(4, 0, "New X Y coordinates ? ");
1055 getstring(Databuf, SZ_DATABUF);
1056 sscanf(Databuf, "%lf %lf", &temp1, &temp2);
1057 tamper = T_RELOCATE;
1058 option = "relocate";
1061 case '5': /* bless a player */
1066 case '6': /* kill off a player */
1069 tamper = T_VAPORIZED;
1070 option = "vaporize";
1080 /* adjust age after we are sure intervention will be done */
1081 /* end of valar, etc. options */
1085 /* prompt for player to affect */
1087 mvprintw(4, 0, "Who do you want to %s ? ", option);
1088 getstring(Databuf, SZ_DATABUF);
1089 truncstring(Databuf);
1091 if (Databuf[0] == '\0')
1097 if (strcmp(Player.p_name, Databuf) != 0)
1098 /* name other than self */
1100 if ((loc = findname(Databuf, &Other)) >= 0L)
1102 if (Other.p_tampered != T_OFF)
1104 mvaddstr(5, 0, "That person has something pending already.\n");
1109 if (tamper == T_RELOCATE
1110 && CIRCLE(temp1, temp2) < CIRCLE(Other.p_x, Other.p_y)
1112 mvaddstr(5, 0, "Cannot move someone closer to the Lord's Chamber.\n");
1115 if (tamper == T_BESTOW) Player.p_gold -= floor(temp1);
1116 if (!Wizard && (tamper == T_HEAL || tamper == T_MONSTER ||
1117 tamper == T_RELOCATE || tamper == T_BLESSED))
1118 Player.p_age += N_AGE; /* age penalty */
1119 Other.p_tampered = tamper;
1120 Other.p_1scratch = floor(temp1);
1121 Other.p_2scratch = floor(temp2);
1122 writerecord(&Other, loc);
1123 mvaddstr(5, 0, "It is done.\n");
1129 /* player not found */
1130 mvaddstr(5, 0, "There is no one by that name.\n");
1134 mvaddstr(5, 0, "You may not do it to yourself!\n");
1137 /************************************************************************
1139 / FUNCTION NAME: writevoid()
1141 / FUNCTION: update energy void entry in energy void file
1143 / AUTHOR: E. A. Estes, 12/4/85
1146 / struct energyvoid *vp - pointer to structure to write to file
1147 / long loc - location in file to update
1149 / RETURN VALUE: none
1151 / MODULES CALLED: fseek(), fwrite(), fflush()
1153 / GLOBAL INPUTS: *Energyvoidfp
1155 / GLOBAL OUTPUTS: none
1158 / Write out energy void structure at specified location.
1160 *************************************************************************/
1163 struct energyvoid *vp;
1167 fseek(Energyvoidfp, loc, 0);
1168 fwrite((char *) vp, SZ_VOIDSTRUCT, 1, Energyvoidfp);
1169 fflush(Energyvoidfp);
1170 fseek(Energyvoidfp, 0L, 0);
1173 /************************************************************************
1175 / FUNCTION NAME: allocvoid()
1177 / FUNCTION: allocate space for a new energy void
1179 / AUTHOR: E. A. Estes, 12/4/85
1183 / RETURN VALUE: location of new energy void space
1185 / MODULES CALLED: fread(), fseek()
1187 / GLOBAL INPUTS: *Energyvoidfp, Enrgyvoid
1189 / GLOBAL OUTPUTS: none
1192 / Search energy void file for an inactive entry and return its
1194 / If no inactive ones are found, return one more than last location.
1196 *************************************************************************/
1201 long loc = 0L; /* location of new energy void */
1203 fseek(Energyvoidfp, 0L, 0);
1204 while (fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp) == 1)
1205 if (Enrgyvoid.ev_active)
1206 loc += SZ_VOIDSTRUCT;