📄 interplayer.c
字号:
Player.p_mana += 500.0; Player.p_strength += 0.5; Player.p_brains += 0.5; Player.p_magiclvl += 0.5; Player.p_poison = MIN(0.5, Player.p_poison); break; case T_RELOCATE: addstr("You've been relocated. . .\n"); altercoordinates(arg1, arg2, A_FORCED); break; case T_HEAL: addstr("You've been healed!\n"); Player.p_poison -= 0.25; Player.p_energy = Player.p_maxenergy + Player.p_shield; break; case T_EXVALAR: addstr("You are no longer Valar!\n"); Player.p_specialtype = SC_COUNCIL; break; case T_GRAIL: addstr("You have found The Holy Grail!!\n"); if (Player.p_specialtype < SC_COUNCIL) /* must be council of wise to behold grail */ { addstr("However, you are not experienced enough to behold it.\n"); Player.p_sin *= Player.p_sin; Player.p_mana += 1000; } else if (Player.p_specialtype == SC_VALAR || Player.p_specialtype == SC_EXVALAR) { addstr("You have made it to the position of Valar once already.\n"); addstr("The Grail is of no more use to you now.\n"); } else { addstr("It is now time to see if you are worthy to behold it. . .\n"); refresh(); sleep(4); if (drandom() / 2.0 < Player.p_sin) { addstr("You have failed!\n"); Player.p_strength = Player.p_mana = Player.p_energy = Player.p_maxenergy = Player.p_magiclvl = Player.p_brains = Player.p_experience = Player.p_quickness = 1.0; altercoordinates(1.0, 1.0, A_FORCED); Player.p_level = 0.0; } else { addstr("You made to position of Valar!\n"); Player.p_specialtype = SC_VALAR; Player.p_lives = 5; fseek(Playersfp, 0L, 0); loc = 0L; while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1) /* search for existing valar */ if (Other.p_specialtype == SC_VALAR && Other.p_status != S_NOTUSED) /* found old valar */ { Other.p_tampered = T_EXVALAR; writerecord(&Other, loc); break; } else loc += SZ_PLAYERSTRUCT; } } /* move grail to new location */ Enrgyvoid.ev_active = TRUE; Enrgyvoid.ev_x = ROLL(-1.0e6, 2.0e6); Enrgyvoid.ev_y = ROLL(-1.0e6, 2.0e6); writevoid(&Enrgyvoid, 0L); break; } refresh(); sleep(2);}/**//************************************************************************// FUNCTION NAME: userlist()// FUNCTION: print list of players and locations// AUTHOR: E. A. Estes, 2/28/86// ARGUMENTS:/ bool ingameflag - set if called while playing// RETURN VALUE: none// MODULES CALLED: descrstatus(), descrlocation(), more(), fread(), fseek(), / floor(), wmove(), printw(), waddstr(), distance(), wrefresh(), / descrtype(), wclrtobot()// GLOBAL INPUTS: LINES, Other, Circle, Wizard, Player, *stdscr, *Playersfp// GLOBAL OUTPUTS: none// DESCRIPTION:/ We can only see the coordinate of those closer to the origin/ from us./ Kings and council of the wise can see and can be seen by everyone./ Palantirs are good for seeing everyone; and the valar can use/ one to see through a 'cloak' spell./ The valar has no coordinates, and is completely invisible if/ cloaked.//************************************************************************/userlist(ingameflag)bool ingameflag;{register int numusers = 0; /* number of users on file */ if (ingameflag && Player.p_blindness) { mvaddstr(8, 0, "You cannot see anyone.\n"); return; } fseek(Playersfp, 0L, 0); mvaddstr(8, 0, "Name X Y Lvl Type Login Status\n"); while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1) { if (Other.p_status == S_NOTUSED /* record is unused */ || (Other.p_specialtype == SC_VALAR && Other.p_status == S_CLOAKED)) /* cloaked valar */ { if (!Wizard) /* wizard can see everything on file */ continue; } ++numusers; if (ingameflag && /* must be playing for the rest of these conditions */ (Player.p_specialtype >= SC_KING /* kings and higher can see others */ || Other.p_specialtype >= SC_KING /* kings and higher can be seen by others */ || Circle >= CIRCLE(Other.p_x, Other.p_y) /* those nearer the origin can be seen */ || Player.p_palantir) /* palantir enables one to see others */ && (Other.p_status != S_CLOAKED || (Player.p_specialtype == SC_VALAR && Player.p_palantir)) /* not cloaked; valar can see through cloak with a palantir */ && Other.p_specialtype != SC_VALAR) /* not a valar */ /* coordinates should be printed */ printw("%-20s %8.0f %8.0f ", Other.p_name, Other.p_x, Other.p_y); else /* cannot see player's coordinates */ printw("%-20s %19.19s ", Other.p_name, descrlocation(&Other, TRUE)); printw("%6.0f %s %-9.9s%s\n", Other.p_level, descrtype(&Other, TRUE), Other.p_login, descrstatus(&Other)); if ((numusers % (LINES - 10)) == 0) { more(LINES - 1); move(9, 0); clrtobot(); } } printw("Total players on file = %d\n", numusers); refresh();}/**//************************************************************************// FUNCTION NAME: throneroom()// FUNCTION: king stuff upon entering throne// AUTHOR: E. A. Estes, 12/16/85// ARGUMENTS: none// RETURN VALUE: none// MODULES CALLED: writerecord(), fread(), fseek(), fopen(), wmove(), fclose(), / fwrite(), altercoordinates(), waddstr(), fprintf()// GLOBAL INPUTS: *Energyvoidfp, Other, Player, *stdscr,/ Enrgyvoid, *Playersfp// GLOBAL OUTPUTS: Other, Player, Changed// DESCRIPTION:/ If player is not already king, make him/her so if the old king/ is not playing./ Clear energy voids with new king./ Print 'decree' prompt.//************************************************************************/throneroom(){FILE *fp; /* to clear energy voids */long loc = 0L; /* location of old king in player file */ if (Player.p_specialtype < SC_KING) /* not already king -- assumes crown */ { fseek(Playersfp, 0L, 0); while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1) if (Other.p_specialtype == SC_KING && Other.p_status != S_NOTUSED) /* found old king */ { if (Other.p_status != S_OFF) /* old king is playing */ { mvaddstr( 4, 0, "The king is playing, so you cannot steal his throne\n"); altercoordinates(0.0, 0.0, A_NEAR); move(6, 0); return; } else /* old king is not playing - remove him/her */ { Other.p_specialtype = SC_NONE; if (Other.p_crowns) --Other.p_crowns; writerecord(&Other, loc); break; } } else loc += SZ_PLAYERSTRUCT; /* make player new king */ Changed = TRUE; Player.p_specialtype = SC_KING; mvaddstr(4, 0, "You have become king!\n"); /* let everyone else know */ fp = fopen(_PATH_MESS, "w"); fprintf(fp, "All hail the new king!"); fclose(fp); /* clear all energy voids; retain location of holy grail */ fseek(Energyvoidfp, 0L, 0); fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp); fp = fopen(_PATH_VOID, "w"); fwrite((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, fp); fclose(fp); } mvaddstr(6, 0, "0:Decree ");}/**//************************************************************************// FUNCTION NAME: dotampered()// FUNCTION: king and valar special options// AUTHOR: E. A. Estes, 2/28/86// ARGUMENTS: none// RETURN VALUE: none// MODULES CALLED: writerecord(), truncstring(), fread(), fseek(), fopen(), / floor(), wmove(), drandom(), fclose(), fwrite(), sscanf(), strcmp(), / infloat(), waddstr(), findname(), distance(), userlist(), mvprintw(), / allocvoid(), getanswer(), getstring(), wclrtoeol(), writevoid()// GLOBAL INPUTS: *Energyvoidfp, Other, Illcmd[], Wizard, Player, *stdscr, / Databuf[], Enrgyvoid// GLOBAL OUTPUTS: Other, Player, Enrgyvoid// DESCRIPTION:/ Tamper with other players. Handle king/valar specific options.//************************************************************************/dotampered(){short tamper; /* value for tampering with other players */char *option; /* pointer to option description */double temp1 = 0.0, temp2 = 0.0; /* other tampering values */int ch; /* input */long loc; /* location in energy void file */FILE *fp; /* for opening gold file */ move(6, 0); clrtoeol(); if (Player.p_specialtype < SC_COUNCIL && !Wizard) /* king options */ { addstr("1:Transport 2:Curse 3:Energy Void 4:Bestow 5:Collect Taxes "); ch = getanswer(" ", TRUE); move(6, 0); clrtoeol(); move(4, 0); switch (ch) { case '1': /* transport someone */ tamper = T_TRANSPORT; option = "transport"; break; case '2': /* curse another */ tamper = T_CURSED; option = "curse"; break; case '3': /* create energy void */ if ((loc = allocvoid()) > 20L * SZ_VOIDSTRUCT) /* can only have 20 void active at once */ mvaddstr(5, 0, "Sorry, void creation limit reached.\n"); else { addstr("Enter the X Y coordinates of void ? "); getstring(Databuf, SZ_DATABUF); sscanf(Databuf, "%lf %lf", &temp1, &temp2); Enrgyvoid.ev_x = floor(temp1); Enrgyvoid.ev_y = floor(temp2); Enrgyvoid.ev_active = TRUE; writevoid(&Enrgyvoid, loc); mvaddstr(5, 0, "It is done.\n"); } return; case '4': /* bestow gold to subject */ tamper = T_BESTOW; addstr("How much gold to bestow ? "); temp1 = infloat(); if (temp1 > Player.p_gold || temp1 < 0) { mvaddstr(5, 0, "You don't have that !\n"); return; } /* adjust gold after we are sure it will be given to someone */ option = "give gold to"; break; case '5': /* collect accumulated taxes */ if ((fp = fopen(_PATH_GOLD, "r+")) != NULL) /* collect taxes */ { fread((char *) &temp1, sizeof(double), 1, fp); fseek(fp, 0L, 0); /* clear out value */ temp2 = 0.0; fwrite((char *) &temp2, sizeof(double), 1, fp); fclose(fp); } mvprintw(4, 0, "You have collected %.0f in gold.\n", temp1); Player.p_gold += floor(temp1); return; default: return; } /* end of king options */ } else /* council of wise, valar, wizard options */ { addstr("1:Heal "); if (Player.p_palantir || Wizard) addstr("2:Seek Grail "); if (Player.p_specialtype == SC_VALAR || Wizard) addstr("3:Throw Monster 4:Relocate 5:Bless "); if (Wizard) addstr("6:Vaporize "); ch = getanswer(" ", TRUE); if (!Wizard) { if (ch > '2' && Player.p_specialtype != SC_VALAR) { ILLCMD(); return; } if (Player.p_mana < MM_INTERVENE) { mvaddstr(5, 0, "No mana left.\n"); return; } else Player.p_mana -= MM_INTERVENE; } switch (ch) { case '1': /* heal another */ tamper = T_HEAL; option = "heal"; break; case '2': /* seek grail */ if (Player.p_palantir) /* need a palantir to seek */ { fseek(Energyvoidfp, 0L, 0); fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp); temp1 = distance(Player.p_x, Enrgyvoid.ev_x, Player.p_y, Enrgyvoid.ev_y); temp1 += ROLL(-temp1 / 10.0, temp1 / 5.0); /* add some error */ mvprintw(5, 0, "The palantir says the Grail is about %.0f away.\n", temp1); } else /* no palantir */ mvaddstr(5, 0, "You need a palantir to seek the Grail.\n"); return; case '3': /* lob monster at someone */ mvaddstr(4, 0, "Which monster [0-99] ? "); temp1 = infloat(); temp1 = MAX(0.0, MIN(99.0, temp1)); tamper = T_MONSTER; option = "throw a monster at"; break; case '4': /* move another player */ mvaddstr(4, 0, "New X Y coordinates ? "); getstring(Databuf, SZ_DATABUF); sscanf(Databuf, "%lf %lf", &temp1, &temp2); tamper = T_RELOCATE; option = "relocate"; break; case '5': /* bless a player */ tamper = T_BLESSED; option = "bless"; break; case '6': /* kill off a player */ if (Wizard) { tamper = T_VAPORIZED; option = "vaporize"; break; } else return; default: return; } /* adjust age after we are sure intervention will be done */ /* end of valar, etc. options */ } for (;;) /* prompt for player to affect */ { mvprintw(4, 0, "Who do you want to %s ? ", option); getstring(Databuf, SZ_DATABUF); truncstring(Databuf); if (Databuf[0] == '\0') userlist(TRUE); else break; } if (strcmp(Player.p_name, Databuf) != 0) /* name other than self */ { if ((loc = findname(Databuf, &Other)) >= 0L) { if (Other.p_tampered != T_OFF) { mvaddstr(5, 0, "That person has something pending already.\n"); return; } else { if (tamper == T_RELOCATE && CIRCLE(temp1, temp2) < CIRCLE(Other.p_x, Other.p_y) && !Wizard) mvaddstr(5, 0, "Cannot move someone closer to the Lord's Chamber.\n"); else { if (tamper == T_BESTOW) Player.p_gold -= floor(temp1); if (!Wizard && (tamper == T_HEAL || tamper == T_MONSTER || tamper == T_RELOCATE || tamper == T_BLESSED)) Player.p_age += N_AGE; /* age penalty */ Other.p_tampered = tamper; Other.p_1scratch = floor(temp1); Other.p_2scratch = floor(temp2); writerecord(&Other, loc); mvaddstr(5, 0, "It is done.\n"); } return; } } else /* player not found */ mvaddstr(5, 0, "There is no one by that name.\n"); } else /* self */ mvaddstr(5, 0, "You may not do it to yourself!\n");}/**//************************************************************************// FUNCTION NAME: writevoid()// FUNCTION: update energy void entry in energy void file// AUTHOR: E. A. Estes, 12/4/85// ARGUMENTS:/ struct energyvoid *vp - pointer to structure to write to file/ long loc - location in file to update// RETURN VALUE: none// MODULES CALLED: fseek(), fwrite(), fflush()// GLOBAL INPUTS: *Energyvoidfp// GLOBAL OUTPUTS: none// DESCRIPTION:/ Write out energy void structure at specified location.//************************************************************************/writevoid(vp, loc)register struct energyvoid *vp;long loc;{ fseek(Energyvoidfp, loc, 0); fwrite((char *) vp, SZ_VOIDSTRUCT, 1, Energyvoidfp); fflush(Energyvoidfp); fseek(Energyvoidfp, 0L, 0);}/**//************************************************************************// FUNCTION NAME: allocvoid()// FUNCTION: allocate space for a new energy void// AUTHOR: E. A. Estes, 12/4/85// ARGUMENTS: none// RETURN VALUE: location of new energy void space// MODULES CALLED: fread(), fseek()// GLOBAL INPUTS: *Energyvoidfp, Enrgyvoid// GLOBAL OUTPUTS: none// DESCRIPTION:/ Search energy void file for an inactive entry and return its/ location./ If no inactive ones are found, return one more than last location.//************************************************************************/longallocvoid(){long loc = 0L; /* location of new energy void */ fseek(Energyvoidfp, 0L, 0); while (fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp) == 1) if (Enrgyvoid.ev_active) loc += SZ_VOIDSTRUCT; else break; return(loc);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -