/* loads the city level */ void resurrect_guards(void) { int i,j; char site; FILE *fd; strcpy(Str3,Omegalib); strcat(Str3,"city.dat"); fd = checkfopen(Str3,"rb"); site = cryptkey("city.dat"); for(j=0; j<Level->level_length; j++) { for(i=0; i<Level->level_width; i++) { site = getc(fd)^site; if (site == 'G') { make_site_monster(i,j,GUARD); Level->site[i][j].creature->monstring = "undead guardsman"; Level->site[i][j].creature->meleef = M_MELEE_SPIRIT; Level->site[i][j].creature->movef = M_MOVE_SPIRIT; Level->site[i][j].creature->strikef = M_STRIKE_MISSILE; Level->site[i][j].creature->immunity = EVERYTHING-pow2(NORMAL_DAMAGE); Level->site[i][j].creature->hp *= 2; Level->site[i][j].creature->hit *= 2; Level->site[i][j].creature->dmg *= 2; Level->site[i][j].creature->ac *= 2; m_status_set(Level->site[i][j].creature,HOSTILE); m_status_set(Level->site[i][j].creature,AWAKE); } } site = getc(fd)^site; } fclose(fd); }
void m_damage(struct monster *m, int dmg, int dtype) { m_status_set(m, AWAKE); m_status_set(m, HOSTILE); if(m_immunityp(m, dtype)) { if(los_p(Player.x, Player.y, m->x, m->y)) { if(m->uniqueness != COMMON) { strcpy(Str1, m->monstring); } else { strcpy(Str1, "The "); strcat(Str1, m->monstring); } strcat(Str1, " ignores the attack!"); mprint(Str1); } } else { m->hp -= dmg; if(m->hp < 1) { m_death(m); } } }
/* makes a log npc for houses and hovels */ void make_house_npc(int i, int j) { pml ml = ((pml) checkmalloc(sizeof(mltype))); pob ob; ml->m = ((pmt) checkmalloc(sizeof(montype))); *(ml->m) = Monsters[NPC]; make_log_npc(ml->m); if (ml->m->id == NPC) mprint("You detect signs of life in this house."); else mprint("An eerie shiver runs down your spine as you enter...."); /* if not == NPC, then we got a ghost off the npc list */ ml->m->x = i; ml->m->y = j; Level->site[i][j].creature = ml->m; ml->m->click = (Tick + 1) % 50; ml->next = Level->mlist; Level->mlist = ml; m_status_set(ml->m,HOSTILE); if (nighttime()) m_status_reset(ml->m,AWAKE); else m_status_set(ml->m,AWAKE); if (ml->m->startthing > -1) { ob = ((pob) checkmalloc(sizeof(objtype))); *ob = Objects[ml->m->startthing]; m_pickup(ml->m,ob); } }
/* makes a hiscore npc for mansions */ void make_mansion_npc(int i, int j) { pml ml = ((pml) checkmalloc(sizeof(mltype))); ml->m = ((pmt) checkmalloc(sizeof(montype))); *(ml->m) = Monsters[NPC]; make_hiscore_npc(ml->m,random_range(14) + 1); mprint("You detect signs of life in this house."); ml->m->x = i; ml->m->y = j; Level->site[i][j].creature = ml->m; ml->m->click = (Tick + 1) % 50; ml->next = Level->mlist; Level->mlist = ml; m_status_set(ml->m,HOSTILE); if (nighttime()) m_status_reset(ml->m,AWAKE); else m_status_set(ml->m,AWAKE); }
/* from f to t */ void ball(int fx, int fy, int tx, int ty, int dmg, int dtype) { int xx,yy,ex,ey,i; Monster *target; Symbol expchar=('@' | CLR(LIGHT_PURPLE)); xx = fx; yy = fy; switch(dtype) { case FLAME: expchar=('*' | CLR(LIGHT_RED)); break; case COLD: expchar=('o' | CLR(WHITE)); break; case ELECTRICITY: expchar=('^' | CLR(LIGHT_BLUE)); break; } do_los(expchar,&xx,&yy,tx,ty); draw_explosion(expchar,xx,yy); for(i=0; i<9; i++) { ex = xx + Dirs[0][i]; ey = yy + Dirs[1][i]; if ((ex == Player.x) && (ey == Player.y)) { switch(dtype) { case FLAME: mprint("You were blasted by a fireball!"); p_damage(random_range(dmg),FLAME,"a fireball"); break; case COLD: mprint("You were blasted by a snowball!"); p_damage(random_range(dmg),COLD,"a snowball"); break; case ELECTRICITY: mprint("You were blasted by ball lightning!"); p_damage(random_range(dmg),ELECTRICITY,"ball lightning"); break; case UNSTOPPABLE: mprint("Oh No! Manastorm!"); p_damage(random_range(dmg),UNSTOPPABLE,"a manastorm!"); break; } } if (NULL != (target = Level->site[ex][ey].creature)) { if (los_p(Player.x,Player.y,target->x,target->y)) { if (target->uniqueness == COMMON) { strcpy(Str1,"The "); strcat(Str1,target->name); } else strcpy(Str1,target->name); switch(dtype) { case FLAME: strcat(Str1," was zorched by a fireball!"); break; case COLD: strcat(Str1," was blasted by a snowball!"); break; case ELECTRICITY: strcat(Str1," was zapped by ball lightning!"); break; case UNSTOPPABLE: strcat(Str1," was nuked by a manastorm!"); break; } mprint(Str1); } m_status_set(target,HOSTILE); target->m_damage(random_range(dmg),dtype); } if (Level->site[ex][ey].locchar == HEDGE) if (Level->site[ex][ey].p_locf != L_TRIFID) { if ((dtype == FLAME)||(dtype == ELECTRICITY)) { mprint("The hedge is blasted away!"); Level->site[ex][ey].p_locf = L_NO_OP; Level->site[ex][ey].locchar = FLOOR; plotspot(ex,ey,true); lset(ex, ey, CHANGED); } else mprint("The hedge is unaffected."); } else mprint("The trifid absorbs the energy and laughs!"); else if (Level->site[ex][ey].locchar == WATER) if (dtype == FLAME) { mprint("The water is vaporised!"); Level->site[ex][ey].p_locf = L_NO_OP; Level->site[ex][ey].locchar = FLOOR; plotspot(ex,ey,true); lset(ex, ey, CHANGED); } } }
/* from f to t */ void bolt(int fx, int fy, int tx, int ty, int hit, int dmg, int dtype) { int xx,yy; Monster *target; Symbol boltchar = '?'; xx = fx; yy = fy; switch(dtype) { case FLAME: boltchar=('*' | CLR(LIGHT_RED)); break; case ELECTRICITY: boltchar = ('^' | CLR(LIGHT_BLUE)); break; case NORMAL_DAMAGE: boltchar = ('!' | CLR(BROWN)); break; case COLD: boltchar=('o' | CLR(WHITE)); break; default: assert(false); /* this should never happen, right? WDT */ } clearmsg(); do_los(boltchar,&xx,&yy,tx,ty); if ((xx == Player.x) && (yy == Player.y)) { if (Player.status[DEFLECTION] > 0) mprint("The bolt just missed you!"); else { switch (dtype) { case FLAME: mprint("You were blasted by a firebolt!"); p_damage(random_range(dmg),dtype,"a firebolt"); break; case ELECTRICITY: mprint("You were zapped by lightning!"); p_damage(random_range(dmg),dtype,"a bolt of lightning"); break; case NORMAL_DAMAGE: mprint("You were hit by a missile!"); p_damage(random_range(dmg),dtype,"a missile"); break; case COLD: mprint("You were hit by an icicle!"); p_damage(random_range(dmg),dtype,"an icicle"); break; } } } else if (NULL != (target = Level->site[xx][yy].creature)) { if (hitp(hit,target->ac)) { if (target->uniqueness == COMMON) { strcpy(Str1,"The "); strcat(Str1,target->name); } else strcpy(Str1,target->name); switch (dtype) { /* WDT: these sentances really ought to be livened up. Especially * in full verbose mode. */ case FLAME: strcat(Str1," was blasted by a firebolt!"); break; case ELECTRICITY: strcat(Str1," was zapped by lightning!"); break; case NORMAL_DAMAGE: strcat(Str1," was hit by a missile!"); break; case COLD: strcat(Str1," was hit by an icicle!"); break; } mprint(Str1); m_status_set(target,HOSTILE); target->m_damage(random_range(dmg),dtype); } else { if (target->uniqueness == COMMON) { strcpy(Str1,"The "); strcat(Str1,target->name); } else strcpy(Str1,target->name); switch (dtype) { case FLAME: strcat(Str1," was missed by a firebolt!"); break; case ELECTRICITY: strcat(Str1," was missed by lightning!"); break; case NORMAL_DAMAGE: strcat(Str1," was missed by a missile!"); break; case COLD: strcat(Str1," was missed by a flying icicle!"); break; } mprint(Str1); } } else if (Level->site[xx][yy].locchar == HEDGE) if (Level->site[xx][yy].p_locf != L_TRIFID) { if ((dtype == FLAME)||(dtype == ELECTRICITY)) { mprint("The hedge is blasted away!"); Level->site[xx][yy].p_locf = L_NO_OP; Level->site[xx][yy].locchar = FLOOR; plotspot(xx, yy, true); lset(xx, yy, CHANGED); } else mprint("The hedge is unaffected."); } else mprint("The trifid absorbs the energy and laughs!"); else if (Level->site[xx][yy].locchar == WATER) if (dtype == FLAME) { mprint("The water is vaporised!"); Level->site[xx][yy].p_locf = L_NO_OP; Level->site[xx][yy].locchar = FLOOR; lset(xx, yy, CHANGED); } }
/* Consider one monster's action */ void m_pulse(struct monster *m) { int range = distance(m->x, m->y, Player.x, Player.y); if(Time % 10 == 0) { if(m->hp < Monsters[m->id].hp) { ++m->hp; } } if(!m_statusp(m, AWAKE) && (range <= m->wakeup)) { m_status_set(m, AWAKE); resetgamestatus(FAST_MOVE); } if(m_statusp(m, AWAKE)) { if(m_statusp(m, WANDERING)) { if(m_statusp(m, MOBILE)) { m_random_move(m); } if(range <= m->sense) { m_status_reset(m, WANDERING); } } else { /* Not wandering */ if(m_statusp(m, HOSTILE)) { if((range > 2) && (range < m->sense) && (random_range(2) == 1)) { if(los_p(m->x, m->y, Player.x, Player.y) && (Player.status[INVISIBLE] == 0)) { monster_strike(m); } } } if((m_statusp(m, HOSTILE) || m_statusp(m, NEEDY)) && (range > 1) && m_statusp(m, MOBILE)) { monster_move(m); /* If monster is greedy, picks up treasure it finds */ if(m_statusp(m, GREEDY)) { while(Level->site[m->x][m->y].things != NULL) { m_pickup(m, Level->site[m->x][m->y].things->thing); Level->site[m->x][m->y].things = Level->site[m->x][m->y].things->next; } } } if(m_statusp(m, HOSTILE) && (range == 1)) { resetgamestatus(FAST_MOVE); tacmonster(m); } } /* Prevents monsters form casting spells from other side of dungeon */ if(range < max(5, m->level)) { monster_special(m); } } }
void l_arena(void) { char response; Object* newitem; int i,prize,monsterlevel; char *melee = NULL; print1("Rampart Coliseum"); if (Player.rank[ARENA] == 0) { print2("Enter the games, or Register as a Gladiator? [e,r,ESCAPE] "); do response = (char) mcigetc(); while ((response != 'e') && (response != 'r') && (response != ESCAPE)); } else { print2("Enter the games? [yn] "); response = ynq2(); if (response == 'y') response = 'e'; else response = ESCAPE; } if (response == 'r') { if (Player.rank[ARENA]>0) print2("You're already a gladiator...."); else if (Player.rank[ORDER]>0) print2("We don't let Paladins into our Guild."); else if (Player.rank[LEGION]>0) print2("We don't train no stinkin' mercs!"); else if (Player.str < 13) print2("Yer too weak to train!"); else if (Player.agi < 12) print2("Too clumsy to be a gladiator!"); else { print1("Ok, yer now an Arena Trainee."); print2("Here's a wooden sword, and a shield"); morewait(); clearmsg(); newitem = ((Object*) checkmalloc(sizeof(Object))); *newitem = Objects[OB_CLUB]; /* club */ gain_item(newitem); newitem = ((Object*) checkmalloc(sizeof(Object))); *newitem = Objects[OB_LRG_RND_SHIELD]; /* shield */ gain_item(newitem); Player.rank[ARENA] = TRAINEE; Arena_Opponent = 3; morewait(); clearmsg(); print1("You've got 5000Au credit at the Gym."); Gymcredit+=5000; } } else if (response == 'e') { print1("OK, we're arranging a match...."); morewait(); Arena_Monster = ((Monster*) checkmalloc(sizeof(Monster))); Arena_Victory = false; switch(Arena_Opponent) { case 0: *Arena_Monster = Monsters[GEEK]; break; case 1: *Arena_Monster = Monsters[HORNET]; break; case 2: *Arena_Monster = Monsters[HYENA]; break; case 3: *Arena_Monster = Monsters[GOBLIN]; break; case 4: *Arena_Monster = Monsters[GRUNT]; break; case 5: *Arena_Monster = Monsters[TOVE]; break; case 6: *Arena_Monster = Monsters[APPR_NINJA]; break; case 7: *Arena_Monster = Monsters[SALAMANDER]; break; case 8: *Arena_Monster = Monsters[ANT]; break; case 9: *Arena_Monster = Monsters[MANTICORE]; break; case 10: *Arena_Monster = Monsters[SPECTRE]; break; case 11: *Arena_Monster = Monsters[BANDERSNATCH]; break; case 12: *Arena_Monster = Monsters[LICHE]; break; case 13: *Arena_Monster = Monsters[AUTO_MAJOR]; break; case 14: *Arena_Monster = Monsters[JABBERWOCK]; break; case 15: *Arena_Monster = Monsters[JOTUN]; break; default: if ((Player.rank[ARENA] < 5) && (Player.rank[ARENA] > 0)) { strcpy(Str1,Champion); strcat(Str1,", the arena champion"); *Arena_Monster = Monsters[HISCORE_NPC]; Arena_Monster->name = salloc(Str1); strcpy(Str2,"The corpse of "); strcat(Str2,Str1); Arena_Monster->corpseString = salloc(Str2); m_status_set( Arena_Monster, ALLOC ); Arena_Monster->level = 20; Arena_Monster->hp = Championlevel*Championlevel*5; Arena_Monster->hit = Championlevel*4; Arena_Monster->ac = Championlevel*3; Arena_Monster->dmg = 100+Championlevel*2; Arena_Monster->xpv = Championlevel*Championlevel*5; Arena_Monster->speed = 3; melee = Arena_Monster->combatManeuvers = (char *) checkmalloc(30*sizeof(char)); strcpy(Arena_Monster->combatManeuvers,""); for(i=0; i<Championlevel/5; i++) strcat(Arena_Monster->combatManeuvers,"L?R?"); m_status_set(Arena_Monster, MOBILE); m_status_set(Arena_Monster, HOSTILE); } else { do i = random_range(ML9 - ML0) + ML0; while (i == NPC || i == HISCORE_NPC || i == ZERO_NPC || (Monsters[i].uniqueness != COMMON) || (Monsters[i].dmg == 0)); *Arena_Monster = Monsters[i]; } break; } monsterlevel = Arena_Monster->level; if (Arena_Monster->level != 20) { strcpy(Str1,nameprint()); strcat(Str1," the "); strcat(Str1,Arena_Monster->name); Arena_Monster->name = salloc(Str1); strcpy(Str2,"The corpse of "); strcat(Str2,Str1); Arena_Monster->corpseString = salloc(Str2); m_status_set( Arena_Monster, ALLOC ); } Arena_Monster->uniqueness = UNIQUE_MADE; print1("You have a challenger: "); print2(Arena_Monster->name); Arena_Monster->wasAttackedByPlayer = true; m_status_set(Arena_Monster,HOSTILE); /* DAG pump up the stats of the arena monster; from env.c */ /* DAG should we even do this for the champion? */ Arena_Monster->hp += Arena_Monster->level*10; Arena_Monster->hit += Arena_Monster->hit; Arena_Monster->dmg += Arena_Monster->dmg/2; morewait(); clearmsg(); change_environment(E_ARENA); print1("Let the battle begin...."); time_clock(true); while (Current_Environment == E_ARENA) time_clock(false); /* DAG all this nasty mess cleaned up... */ /* one process with m_status_set( Arena_Monster, ALLOC) */ /* free(name); */ /* free(corpse); */ if (melee) free(melee); if (! Arena_Victory) { print1("The crowd boos your craven behavior!!!"); if (Player.rank[ARENA] > 0) { print2("You are thrown out of the Gladiator's Guild!"); morewait(); clearmsg(); if (Gymcredit > 0) print1("Your credit at the gym is cut off!"); Gymcredit = 0; Player.rank[ARENA] = -1; } } else { Arena_Opponent++; if (monsterlevel == 20) { print1("The crowd roars its approval!"); if (Player.rank[ARENA]) { print2("You are the new Arena Champion!"); Championlevel = Player.level; strcpy(Champion,Player.name); Player.rank[ARENA] = 5; morewait(); Championbehavior = fixnpc(4); save_hiscore_npc(11); print1("You are awarded the Champion's Spear: Victrix!"); morewait(); newitem = ((Object*) checkmalloc(sizeof(Object))); *newitem = Objects[OB_VICTRIX]; gain_item(newitem); } else { print1("As you are not an official gladiator,"); nprint1("you are not made Champion."); morewait(); } } morewait(); clearmsg(); print1("Good fight! "); nprint1("Your prize is: "); prize = max(25,monsterlevel * 50); if (Player.rank[ARENA] > 0) prize *= 2; mnumprint(prize); nprint1("Au."); Player.cash+=prize; if ((Player.rank[ARENA]<4) && (Arena_Opponent>5) && (Arena_Opponent % 3 == 0)) { if (Player.rank[ARENA]>0) { Player.rank[ARENA]++; morewait(); print1("You've been promoted to a stronger class!"); print2("You are also entitled to additional training."); Gymcredit+=Arena_Opponent*1000; } } } xredraw(); } else clearmsg(); }