コード例 #1
0
ファイル: battle.c プロジェクト: phoboz/yz
static void set_curr_battle_actor(
    BATTLE *battle,
    BATTLE_ACTOR *ba
)
{
    battle->currActor = ba;
    battle->currActor->cursor.i = battle->currActor->i;
    battle->currActor->cursor.j = battle->currActor->j;
    move_world(battle->world, battle->currActor->player);
}
コード例 #2
0
ファイル: object.c プロジェクト: davidpeng/ularn
void act_on_object(int ans)
{
  int i, j;
  int dx, dy;

  /* can't find objects is time is stopped */
  if (c[TIMESTOP]) return;

  i=item[playerx][playery];
  if (i == ONOTHING) return;

  showcell(playerx,playery);
  yrepcount=0;

  switch (i)
  {
    case OPOTION:
      i = iarg[playerx][playery];
      opotion(i, ans);
      break;

    case OSCROLL:
      i = iarg[playerx][playery];
      oscroll(i, ans);
      break;

    case OALTAR:
      oaltar(ans);
      move_world(0);
      break;

    case OBOOK:
      obook(ans);
      break;

    case OCOOKIE:
      ocookie(ans);
      break;

    case OTHRONE:
      othrone(0, ans);
      break;

    case OTHRONE2:
      othrone(1, ans);
      break;

    case ODEADTHRONE:
      odeadthrone(ans);
      break;

    case OORB:
      take_item(ans);
      break;

    case OBRASSLAMP:
      if (ans=='r')
      {
        i=rnd(100);
        if (i>90)
        {
          Print("The magic genie was very upset at being disturbed!");
      
          losehp(DIED_ANNOYED_GENIE, (int)c[HP]/2+1);
          UlarnBeep();
        }

        /* higher level, better chance of spell */
        else if ( (rnd(100)+c[LEVEL]/2) > 80)
        {
		  j = 0;
		  for (i = 0; i < SPELL_COUNT; i++)
		  {
			if (!spelknow[i])
			{
			  add_option(i, spelname[i], "");
			  j++;
			}
		  }
		  if (j > 0)
		  {
			  print_header("A magic genie appears!  What spell would you like?");
			  set_callback("obrasslamp");
			  break;
		  }
		  else
			  Print("A magic genie appears!  The genie has no new spells to teach you.");
        }
        else
        {
          Print("Nothing happened.");
        }

        if (rnd(100) < 15)
        {
          Print("The genie prefers not to be disturbed again!");
          forget();
          c[LAMP]=0;  /* chance of finding lamp again */
        }

        UpdateStatus();
      }
      else if (ans=='t')
      {
        if (take(OBRASSLAMP,0)==0)
          forget();
      }
      return;

    case OWWAND:
      take_item(ans);
      break;

    case OHANDofFEAR:
      take_item(ans);
      break;

    case OSTAIRSUP:
      ostairs(1, ans);  /* up */
      break;

    case OFOUNTAIN:
      ofountain(ans);
      break;

    case OCHEST:
      ochest(ans);
      break;

    case OSCHOOL:
      if (ans == 'g')
      {
		  oschool();
      }
      break;

    case OBANK2:
    case OBANK:
      if (ans == 'g')
      {
        if (i==OBANK)
			obank();
        else
			obank2();
      }
      break;

    case ODNDSTORE:
      if (ans == 'g')
		  dndstore();
      break;

    case OSTAIRSDOWN:
      ostairs(-1, ans); /* down */
      break;

    case OCLOSEDDOOR:
      
      /* can't move objects if time is stopped */
      if (c[TIMESTOP]) return;

      dx = playerx;
      dy = playery;

      if (dropflag)
        return;

      if ((ans==ESC) || (ans=='i'))
      {
        playerx = lastpx;
        playery = lastpy;
        lastpx = (char) dx;
        lastpy = (char) dy;
        break;
      }
      else
      {
        /* Try and open the door that is here */
        oopendoor(playerx, playery);

        if (item[playerx][playery] == OCLOSEDDOOR)
        {
          /*
           * Door didn't open.
           * Move the player back where they came from.
           */

          playerx = lastpx;
          playery = lastpy;
          lastpx = (char) dx;
          lastpy = (char) dy;
        }
        
        move_world(0);
      }
      break;

    case OENTRANCE:
      if (ans == 'g')
      {
        newcavelevel(1);
        playerx = 33;
        playery = MAXY - 2;

        /* Make sure the entrance to the dungeon is clear */
        item[33][MAXY-1] = ONOTHING;
        mitem[33][MAXY-1].mon = MONST_NONE;

        draws(0,MAXX,0,MAXY);
        UpdateStatusAndEffects();
        return;
      }
      break;

    case OVOLDOWN:
      if ((ans==ESC) || (ans=='i'))
      {
        break;
      }
      if (level!=0)
      {
        Print("The shaft only extends 5 feet downward!");
        return;
      }
      if (packweight() > 45+3*(c[STRENGTH]+c[STREXTRA]))
      {
        Print("You slip and fall down the shaft.");
        UlarnBeep();
        
        losehp(DIED_SLIPPED_VOLCANO_SHAFT, 30+rnd(20));
        UpdateStatus();
      }
      nap(3000);
      newcavelevel(DBOTTOM+1); /* down to V1 */
      playerx = (char) rnd(MAXX-2);
      playery = (char) rnd(MAXY-2);
      positionplayer();
      draws(0,MAXX,0,MAXY);
      UpdateStatusAndEffects();
      return;

    case OVOLUP:
      if ((ans==ESC) || (ans=='i'))
      {
        break;
      }
      if (packweight() > 40+5*(c[DEXTERITY]+c[STRENGTH]+c[STREXTRA]))
      {
        Print("You slip and fall down the shaft.");
        UlarnBeep();
        
        losehp(DIED_SLIPPED_VOLCANO_SHAFT, 15+rnd(20));
        UpdateStatus();
        return;
      }

      nap(3000);
      newcavelevel(0);
      for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++)
      {
        /* put player near volcano shaft */
        if (item[j][i]==OVOLDOWN)
        {
          playerx = (char) j;
          playery = (char) i;
          j=MAXX;
          i=MAXY;
          positionplayer();
        }
      }
      draws(0,MAXX,0,MAXY);
      UpdateStatusAndEffects();
      return;

    case OTRADEPOST:
      if (ans == 'g')
      {
		  otradepost();
      }
      return;

    case OHOME:
      if (ans == 'g')
      {
        ohome();
      }
      return;

    case OPAD:
      if (ans == 'c')
      {
		  opad();
      }
      return;

    case OSPEED:
      if (ans=='s')
      {
        Print("Ohwowmanlikethingstotallyseemtoslowdown!");
        c[HASTESELF] += 200 + c[LEVEL];
        c[HALFDAM] += 300 + rnd(200);
        adjust_ability(INTELLIGENCE, -2);
        adjust_ability(WISDOM, -2);
        adjust_ability(CONSTITUTION, -2);
        adjust_ability(DEXTERITY, -2);
        adjust_ability(STRENGTH, -2);
        forget();
        UpdateStatus();
      }
      else if (ans=='t')
      {
        if (take(OSPEED,0)==0) forget();
      }
      break;

    case OSHROOMS:
      if (ans=='e')
      {
        Print("Things start to get real spacey...");
        c[HASTEMONST] += rnd(75) + 25;
        c[CONFUSE] += 30+rnd(10);
        adjust_ability(WISDOM, 2);
        adjust_ability(CHARISMA, 2);
        forget();
        UpdateStatus();
      }
      else if (ans=='t')
      {
        if (take(OSHROOMS,0)==0) forget();
      }
      break;

    case OACID:
      if (ans=='e')
      {
        Print("You are now frying your ass off!");
        c[CONFUSE] += 30 + rnd(10);
        adjust_ability(WISDOM, 2);
        adjust_ability(INTELLIGENCE, 2);
        c[AWARENESS] += 1500;
        c[AGGRAVATE] += 1500;
        {
          int j, k; /* heal monsters */
          for(j = 0 ; j < MAXY ; j++)
          {
            for(k = 0 ; k < MAXX ; k++)
            {
              if (mitem[k][j].mon)
              {
                hitp[k][j] = monster[(int) mitem[k][j].mon].hitpoints;
              }
            }
          }
        }
        forget();
        UpdateStatus();
      }
      else if (ans=='t')
      {
        if (take(OACID,0)==0) forget();
      }
      break;

    case OHASH:
      if (ans=='s')
      {
        Print("WOW! You feel stooooooned...");
        c[HASTEMONST] += rnd(75)+25;
        adjust_ability(INTELLIGENCE, 2);
        adjust_ability(WISDOM, 2);
        adjust_ability(CONSTITUTION, -2);
        adjust_ability(DEXTERITY, -2);
        c[HALFDAM] += 300+rnd(200);
        c[CLUMSINESS] += rnd(1800)+200;
        forget();
        UpdateStatus();
      }
      else if (ans=='t')
      {
        if (take(OHASH,0)==0) forget();
      }
      break;

    case OCOKE:
      if (ans=='s')
      {
        Print("Your nose begins to bleed!");
        adjust_ability(DEXTERITY, -2);
        adjust_ability(CONSTITUTION, -2);
        adjust_ability(CHARISMA, 3);

        for(i = ABILITY_FIRST ; i <= ABILITY_LAST ; i++)
        {
          adjust_ability(i, 33);
        }
        c[COKED] += 10;
        forget();
        UpdateStatus();
      }
      else if (ans=='t')
      {
        if (take(OCOKE, 0) == 0) forget();
      }
      break;

    case OWALL:
      break;

    case OANNIHILATION:
      if (player_has_item(OSPHTALISMAN))
      {
        Print("The Talisman of the Sphere protects you from annihilation!");
        return;
      }
      
      /* annihilated by sphere of annihilation */
      died(DIED_SPHERE_ANNIHILATION, 0);
      return;

    case OLRS:
      if (nearbymonst()) return;

      if (ans == 'g')
      {
		  olrs();
      }
      break;

    default:
	  if (ans == 't')
	  {
		  if (take(i, iarg[playerx][playery]) == 0)
			  forget();
	  }
      break;
  }
}