Beispiel #1
0
int PlaceQueens(int** chessboard, int size, int level)
{
	count++;
	int Q_placed = 0; /*
	Q_placed is a flag reflecting that whether a Queen
	is placed on the current level or not.
	This value is returned to preceeding levels.
	*/
	int QNextLevel; /*
	QNextLevel is a flag reflecting that whether a Queen
	is placed on the next level or not.
	During recurssion this Flag will allow recurssion
	 */
	int flag;    /*
	Determines whether a Queen can be placed at current
	position or not.
	*/
	int i;
	for (i = 0; i < size; i++)
	{
		 /*Breaks the loops after all the Queens have been placed*/
		if (Q_placed == 1)
			break;
		 /*Check whether Queen can be placed or not*/
		 flag = CheckKill(chessboard, size, level, i);
		 /*If Queen can be placed*/
		 if (flag == 0)
		 {
			 /*Queen Placed. This will be changed if Next level Queen is
			 not placed succesfully*/
			 Q_placed = 1;
			 /*Queen Placed. */
			 chessboard[level][i] = 1;
			 PlaceQueen(level, i);
			  /*Check for Last level*/
			 if (level == size - 1)
				;
			 else /*Place a next level Queen*/
			 {
				QNextLevel = PlaceQueens(chessboard, size, level + 1);
				/*If next level Queen is not Placed.*/
				if (QNextLevel == 0)
				{
					  /*Mark this level Queen as Not Placed*/
					  Q_placed = 0;
					  chessboard[level][i] = 0;
					  RemoveQueen(level, i);
					  if (i == size - 1)
						HomeQueen(level);
				}
			 }
		 }
		 else if (flag == 1)
		 {
			PlaceQueen(level, i);
			RemoveQueen(level, i);
			if (i == size - 1)
				HomeQueen(level);
		 }
	}
	return Q_placed;
}
Beispiel #2
0
void do_disarm(struct char_data *ch, char *argument, int cmd)
{
  char name[30];
  int percent;
  struct char_data *victim;
  struct obj_data *w;
  int chance;
  int cost;

  if (check_peaceful(ch,"You feel too peaceful to contemplate violence.\n\r"))
    return;
  
  only_argument(argument, name);
  if (!(victim = get_char_room_vis(ch, name))) 
  {
    if (ch->specials.fighting) 
    {
      victim = ch->specials.fighting;
    }
    else
    {
      send_to_char("Disarm who?\n\r", ch);
      return;
    }
  }
  
  if (victim == ch) 
  {
    send_to_char("Aren't we funny today...\n\r", ch);
    return;
  }

  if(!CheckKill(ch,victim)) return;

  if(ch->attackers > 3) 
  {
    send_to_char("There is no room to disarm!\n\r", ch);
    return;
  }

  if(victim->attackers > 3)
  {
    send_to_char("There is no room to disarm!\n\r",ch);
    return;
  }

  cost = 25 - (GET_LEVEL(ch,BestFightingClass(ch))/10);

  if(GET_MANA(ch)<cost)
  {
    send_to_char("You trip and fall while trying to disarm.\n\r",ch);
    return;
  }

  percent=number(1,101); /* 101% is a complete failure */
  percent -= dex_app[GET_DEX(ch)].reaction;
  percent += dex_app[GET_DEX(victim)].reaction;

  if(!ch->equipment[WIELD] && !ch->equipment[WIELD_TWOH]) 
  {
    percent -= 50;
  }

  if(percent > ch->skills[SKILL_DISARM].learned) 
  {
    /*   failure   */

    GET_MANA(ch) -= 10;
    act("You try to disarm $N, but fail miserably.",TRUE,ch,0,victim,TO_CHAR);
    if((ch->equipment[WIELD]) && (number(1,10) > 8))
    {
        send_to_char("Your weapon flies from your hand while trying!\n\r",ch);
	w = unequip_char(ch,WIELD);
	obj_from_char(w);
	obj_to_room(w,ch->in_room);
	act("$n tries to disarm $N, but $n loses his weapon!",TRUE,ch,0,victim,TO_ROOM);
    }
    else
    if((ch->equipment[WIELD_TWOH]) && (number(1,10) > 9))
    {
        send_to_char("Your weapon slips from your hands while trying!\n\r",ch);
	w = unequip_char(ch,WIELD_TWOH);
	obj_from_char(w);
	obj_to_room(w,ch->in_room);
	act("$n tries to disarm $N, but $n loses his weapon!",TRUE,ch,0,victim,TO_ROOM);
    }
    GET_POS(ch) = POSITION_SITTING;

    if((IS_NPC(victim)) && (GET_POS(victim) > POSITION_SLEEPING) && (!victim->specials.fighting)) 
    {
      set_fighting(victim, ch);
    }
    WAIT_STATE(ch, PULSE_VIOLENCE*2);
  }
  else
  {
    if(victim->equipment[WIELD]) 
    {
      GET_MANA(ch) -= 25;
      w = unequip_char(victim, WIELD);
      act("$n makes an impressive fighting move.",TRUE, ch, 0, 0, TO_ROOM);
      act("You send $p flying from $N's grasp.", TRUE, ch, w, victim, TO_CHAR);
      act("$p flies from your grasp.", TRUE, ch, w, victim, TO_VICT);
      obj_from_char(w);
      obj_to_room(w, victim->in_room);
      if(ch->skills[SKILL_DISARM].learned < 50)
	ch->skills[SKILL_DISARM].learned += 2;
    }
    else
    if(victim->equipment[WIELD_TWOH])
    {
      GET_MANA(ch) -= cost;
      if(IS_NPC(victim))
	chance = 70;
      else
        chance = victim->skills[SKILL_TWO_HANDED].learned; 

      percent=number(1,101); /* 101% is a complete failure */
      if(percent > chance)
      {
        w = unequip_char(victim, WIELD_TWOH);
        act("$n makes a very impressive fighting move.",TRUE, ch, 0, 0, TO_ROOM);
        act("You send $p flying from $N's grasp.", TRUE, ch, w, victim, TO_CHAR);
        act("$p flies from your grasp.", TRUE, ch, w, victim, TO_VICT);
        obj_from_char(w);
        obj_to_room(w, victim->in_room);
        if(ch->skills[SKILL_DISARM].learned < 50)
	  ch->skills[SKILL_DISARM].learned += 4;
      }
      else
      {
        act("You try to disarm $N, but fail miserably.",TRUE,ch,0,victim,TO_CHAR);
      }
    }
    else
    {
      act("You try to disarm $N, but $E doesn't have a weapon.", 
	  TRUE, ch, 0, victim, TO_CHAR);
      act("$n makes an impressive fighting move, but does little more.",
	  TRUE, ch, 0, 0, TO_ROOM);
    }

    if ((IS_NPC(victim)) && (GET_POS(victim) > POSITION_SLEEPING) &&
        (!victim->specials.fighting)) {
      set_fighting(victim, ch);
    }
    WAIT_STATE(ch, PULSE_VIOLENCE*1);
  }  
}