Ejemplo n.º 1
0
void
objfun_soul_moan(OBJ_DATA *obj, CHAR_DATA *keeper)
{
    if (keeper == NULL || keeper->in_room == NULL)
        return;

    if (!IS_NPC(keeper)
        && (keeper->stance == STANCE_AMBUSH || keeper->stance == STANCE_AC_BEST)
        )
        return;

    /* Come on... it was SO annoying! */
    if (number_percent() < 2) {
        act("$O@@NThe @@eSoul@@N in $p@@N carried by @@a$n@@N moans in agony.", keeper, obj, NULL, TO_ROOM);
        act("$O@@NThe @@eSoul@@N in $p @@Ncarried by you moans to be set free!", keeper, obj, NULL, TO_CHAR);
        return;
    }

    if (number_percent() < 2) {
        act("$O@@NThe @@eSoul@@N in $p@@N carried by @@a$n@@N tries to break free of its inprisonment!", keeper, obj, NULL, TO_ROOM);
        act("$O@@NThe @@eSoul@@N in $p @@Ncarried by you starts writhing--look out!!", keeper, obj, NULL, TO_CHAR);
        return;
    }

    return;
}
Ejemplo n.º 2
0
        static bool CheckFailure(CHAR_DATA * ch, EchoAffect *, void * tag)
        {
            // Check for skill
            ForgeContext * context(static_cast<ForgeContext*>(tag));
            if (number_percent() <= context->skill)
            {    
                check_improve(ch, NULL, gsn_forgeweapon, true, 6);
                return false;
            }

            // Failed; increase the flaw count
            ++context->flaws;
            if (number_percent() <= context->flaws * 25)
            {
                // Fatal error
                act("You lose focus on your work, destroying it completely!", ch, NULL, NULL, TO_CHAR);
                act("$n loses focus on $s work, destroying it completely!", ch, NULL, NULL, TO_ROOM);
                check_improve(ch, NULL, gsn_forgeweapon, false, 6);
                delete context;
                return true;
            }

            // Non-fatal error
            act("You make a small error while folding the metal, introducing a slight flaw into the weapon.", ch, NULL, NULL, TO_CHAR);
            check_improve(ch, NULL, gsn_forgeweapon, false, 6);
            return false;
        }
Ejemplo n.º 3
0
/* checks for skill improvement */
void check_improve( CHAR_DATA *ch, int sn, bool success, int multiplier ) {
  int chance;
  char buf[100];

  if (IS_NPC(ch))
    return;

  // Modified by SinaC 2001
  if (ch->level < class_abilitylevel( /*ch->cstat(classes)*/ch, sn )
      // Modified by SinaC 2003
      ||  class_abilityrating( ch, sn, ch->pcdata->ability_info[sn].casting_level ) == 0
      ||  ch->pcdata->ability_info[sn].learned == 0
      ||  ch->pcdata->ability_info[sn].learned == 100)
    return;  /* skill is not known */

  /* check to see if the character has a chance to learn */
  chance = 10 * int_app[ch->cstat(INT)].learn;
  chance /= ( multiplier
	      *	class_abilityrating( ch, sn, ch->pcdata->ability_info[sn].casting_level )
	      *	4 );
  chance += ch->level;

  if (number_range(1,1000) > chance)
    return;

  /* now that the character has a CHANCE to learn, see if they really have */

  bool done = FALSE; // Added by SinaC 2003
  if (success) {
    chance = URANGE(5,100 - ch->pcdata->ability_info[sn].learned, 95);
    if (number_percent() < chance) {
      sprintf(buf,"You have become better at %s!\n\r",
	      ability_table[sn].name);
      send_to_char(buf,ch);
      ch->pcdata->ability_info[sn].learned++;
      gain_exp(ch,2 * class_abilityrating( ch, sn, ch->pcdata->ability_info[sn].casting_level), TRUE);
      done = TRUE;
    }
  }
  else {
    chance = URANGE(5,ch->pcdata->ability_info[sn].learned/2,30);
    if (number_percent() < chance) {
      sprintf(buf,
	      "You learn from your mistakes, and your %s skill improves.\n\r",
	      ability_table[sn].name);
      send_to_char(buf,ch);
      ch->pcdata->ability_info[sn].learned += number_range(1,3);
      ch->pcdata->ability_info[sn].learned = UMIN(ch->pcdata->ability_info[sn].learned,100);
      gain_exp(ch,2 * class_abilityrating( ch, sn, ch->pcdata->ability_info[sn].casting_level), TRUE);
      done = TRUE;
    }
  }
  if ( done && ch->pcdata->ability_info[sn].learned == 100 ) // Added by SinaC 2003
    send_to_charf(ch,"You are now master in '%s'.\n\r", ability_table[sn].name );
}
Ejemplo n.º 4
0
void do_enmity(CHAR_DATA *ch, char *argument)
{
    char arg1[MAX_INPUT_LENGTH];
    char arg2[MAX_INPUT_LENGTH];
    CHAR_DATA *victim1;
    CHAR_DATA *victim2;

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );

    if (IS_NPC(ch)) return;
    if (!IS_CLASS(ch, CLASS_TANARRI))
    {
        send_to_char("Huh?\n\r",ch);
        return;
    }
    if (!IS_SET(ch->pcdata->powers[TANARRI_POWER], TANARRI_EMNITY))
    {
        send_to_char("you don't have that power yet.\n\r",ch);
        return;
    }
    if ((victim1 = get_char_room(ch, NULL, arg1)) == NULL)
    {
        send_to_char("They are not here.\n\r", ch);
        return;
    }
    if ((victim2 = get_char_room(ch, NULL, arg2)) == NULL)
    {
        send_to_char("They are not here.\n\r", ch);
        return;
    }
    if (IS_NPC(victim1) || IS_NPC(victim2))
    {
        send_to_char("Not on NPC's\n\r",ch);
        return;
    }
    do_say(ch,"Xenus, Morkain, Hau!");
    if (number_percent() > 60)
    {
        SET_BIT(victim1->pcdata->tempflag, TEMP_AGGRESSIVE);
        do_kill(victim1, victim2->pcdata->switchname);
        REMOVE_BIT(victim1->pcdata->tempflag, TEMP_AGGRESSIVE);
    }
    else send_to_char("#RSomeone is trying to control your actions!!!#n\n\r",victim1);
    if (number_percent() > 60)
    {
        SET_BIT(victim2->pcdata->tempflag, TEMP_AGGRESSIVE);
        do_kill(victim2, victim1->pcdata->switchname);
        REMOVE_BIT(victim2->pcdata->tempflag, TEMP_AGGRESSIVE);
    }
    else send_to_char("#RSomeone is trying to control your actions!!!#n\n\r",victim2);
    WAIT_STATE(ch,24);
    return;
}
Ejemplo n.º 5
0
void Weave::ContinueLeyLine(ROOM_INDEX_DATA & room, Direction::Value direction, void * id, unsigned int length, unsigned int expectedLength, int orderPower, int positivePower)
{
    // Check whether to terminate here
    if (length >= expectedLength)
        return;

    // Determine whether to try to continue down this path; more likely if more ordered
    std::vector<Direction::Value> newDirections;
    if (Direction::Adjacent(room, direction) != NULL && number_percent() < (80 + (orderPower * 10)))
        newDirections.push_back(direction);
    else
    {
        // Not necessarily continuing down the same path (though it could still happen by chance)
        // Build a list of directions with valid rooms, ignoring the way back
        std::vector<Direction::Value> validDirections(Direction::ValidDirectionsFrom(room, Direction::ReverseOf(direction)));
        if (validDirections.empty())
            return;

        // Check how many branches to make
        unsigned int branches(1);
        while (branches <= validDirections.size() && number_percent() < 10 + (orderPower * 5))
            ++branches;
        
        // Produce the branches
        for (unsigned int i(0); i < branches; ++i)
        {
            // Get a random direction
            Direction::Value branchDirection(PopNextDirection(room, validDirections));
            if (branchDirection == Direction::Max)
                break;

            newDirections.push_back(branchDirection);
        }
    }

    // Add the ley info to each chosen room
    for (unsigned int i(0); i < newDirections.size(); ++i)
    {
        // TODO: should this LeyInfo vary at all?
        // Set up the ley group
        LeyInfo info(id, orderPower, positivePower);
        ROOM_INDEX_DATA & targetRoom(*Direction::Adjacent(room, newDirections[i]));
        if (targetRoom.ley_group == NULL)
            targetRoom.ley_group = new LeyGroup();
        
        // Add the ley info if not already present
        if (id != &targetRoom && targetRoom.ley_group->LineByID(id) == LeyGroup::NotFound)
            targetRoom.ley_group->Add(info);

        // Recursively generate with the new direction
        s_changedRooms.insert(&room);
        ContinueLeyLine(targetRoom, newDirections[i], id, length + 1, expectedLength, orderPower, positivePower);
    }
}
Ejemplo n.º 6
0
void Character::spell_fire_breath (int sn, int lvl, void *vo)
{
  Character *victim = (Character *) vo;

  if (number_percent () < 2 * lvl && !victim->saves_spell (lvl)) {
    Object *obj_lose;
    ObjIter o, onext;
    for (o = victim->carrying.begin(); o != victim->carrying.end(); o = onext) {
      obj_lose = *o;
      onext = ++o;
      const char *msg;

      if (number_percent() <= 75)
        continue;

      switch (obj_lose->item_type) {
      default:
        continue;
      case ITEM_CONTAINER:
        msg = "$p ignites and burns!";
        break;
      case ITEM_POTION:
        msg = "$p bubbles and boils!";
        break;
      case ITEM_SCROLL:
        msg = "$p crackles and burns!";
        break;
      case ITEM_STAFF:
        msg = "$p smokes and chars!";
        break;
      case ITEM_WAND:
        msg = "$p sparks and sputters!";
        break;
      case ITEM_FOOD:
        msg = "$p blackens and crisps!";
        break;
      case ITEM_PILL:
        msg = "$p melts and drips!";
        break;
      }

      victim->act (msg, obj_lose, NULL, TO_CHAR);
      obj_lose->extract_obj ();
    }
  }

  int hpch = std::max (10, hit);
  int dam = number_range (hpch / 16 + 1, hpch / 8);
  if (victim->saves_spell (lvl))
    dam /= 2;
  damage (this, victim, dam, sn);
  return;
}
Ejemplo n.º 7
0
void do_confuse(CHAR_DATA *ch, char *argument) {

	CHAR_DATA *victim;

	if (IS_NPC(ch)) return;

	if (!IS_CLASS(ch, CLASS_DROW) || !IS_SET(ch->pcdata->powers[1], DPOWER_CONFUSE)) {
	send_to_char("Huh?\n\r",  ch);
	return;}

	if ((victim = ch->fighting) == NULL) {
	send_to_char("You are not fighting anyone.\n\r",  ch);
	return;}

	if (ch->move < 75) {
	send_to_char("You need 75 move to confuse your opponent.\n\r",ch);
	return;}

	act("$n attempts to confuse you.",ch,NULL,victim,TO_VICT);
	act("You attempt to confuse $N.",ch,NULL,victim,TO_CHAR);
	act("$n attempts to confuse $N.",ch,NULL,victim,TO_NOTVICT);

	ch->move -=75;

	if ( number_percent() > 25 ) {
	send_to_char("You failed.\n\r", ch );
	return;}

	else {
		do_flee(victim,"");	
	WAIT_STATE(ch, 16);
	return;	}

	return;
}
Ejemplo n.º 8
0
void do_enrage(CHAR_DATA *ch, char *argument) 
{
  char arg[MAX_INPUT_LENGTH];
  CHAR_DATA *victim;

  argument = one_argument( argument, arg );

  if (IS_NPC(ch)) return;
  if (!IS_CLASS(ch, CLASS_TANARRI))
  {
    send_to_char("Huh?\n\r",ch);
    return;
  }
  if (!IS_SET(ch->pcdata->powers[TANARRI_POWER], TANARRI_ENRAGE))
  {
    send_to_char("you don't have that power yet.\n\r",ch);
    return;
  }
  if ((victim = get_char_room(ch, arg)) == NULL)
  {
    send_to_char("They are not here.\n\r", ch);
    return;
  }
  if (IS_NPC(victim) || victim->level < 3)
  {
    send_to_char("Not on them\n\r",ch);
    return;
  }
  do_say(ch, "Kara, Kara, Xenos!");
  if (number_percent() > 40) do_berserk2(victim,"");
  else send_to_char("#RSomeone is trying to control your actions!!!#n\n\r",victim);
  WAIT_STATE(ch,18);
  return;
}
Ejemplo n.º 9
0
void do_kick( CHAR_DATA *ch, char *argument )
{
    CHAR_DATA *victim;

    if ( !IS_NPC(ch)
    &&   !(ch->ability[BRAWL].value > 0) )
    {
	send_to_char("You better leave the martial arts to fighters.\n\r", ch );
	return;
    }

    if (IS_NPC(ch) && !IS_SET(ch->off_flags,OFF_KICK))
	return;

    if ( ( victim = ch->fighting ) == NULL )
    {
	send_to_char( "You aren't fighting anyone.\n\r", ch );
	return;
    }

    WAIT_STATE( ch, skill_table[gsn_kick].beats );
    if ( get_skill(ch,gsn_kick) > number_percent())
    {
	damage(ch,victim,number_range( 1, get_curr_stat(ch, STAT_STR) + 1 ), gsn_kick,DAM_BASH,TRUE,0,-1);
    }
    else
    {
	damage( ch, victim, 0, gsn_kick,DAM_BASH,TRUE,0,-1);
    }
    return;
}
Ejemplo n.º 10
0
void do_recall (CHAR_DATA * ch, char *argument)
{
    char buf[MAX_STRING_LENGTH];
    ROOM_INDEX_DATA *location;

    if (IS_NPC (ch))
    {
        send_to_char ("Only players can recall.\n\r", ch);
        return;
    }

    act ("$n prays for transportation!", ch, 0, 0, TO_ROOM);

    if ((location = get_room_index (100)) == NULL)
    {
        send_to_char ("You are completely lost.\n\r", ch);
        return;
    }

    if (ch->in_room == location)
        return;

    if (IS_SET (ch->in_room->room_flags, ROOM_NO_RECALL))
    {
        send_to_char ("Mota has forsaken you.\n\r", ch);
        return;
    }

           if(ch->infight)
    {
        int lose, skill;

        skill = get_skill (ch, gsn_recall);

        if (number_percent () < 80 * skill / 100)
        {
            WAIT_STATE (ch, 4);
            sprintf (buf, "You failed!.\n\r");
            send_to_char (buf, ch);
            return;
        }

        lose = (ch->desc != NULL) ? 25 : 50;
        gain_exp (ch, 0 - lose);
        sprintf (buf, "You recall from combat!  You lose %d exps.\n\r", lose);
        send_to_char (buf, ch);
        stop_fighting (ch, TRUE);

    }

    ch->move /= 2;
    act ("$n disappears.", ch, NULL, NULL, TO_ROOM);
    char_from_room (ch);
    char_to_room (ch, location);
    act ("$n appears in the room.", ch, NULL, NULL, TO_ROOM);
    do_function (ch, &do_look, "auto");

    return;
}
Ejemplo n.º 11
0
/* checks for skill improvement */
void check_improve( CHAR_DATA *ch, int sn, bool success, int multiplier )
{
	int chance = 0;

	if (IS_NPC(ch))
		return;

	if (ch->level < skill_table[sn].skill_level[ch->iclass]
		||  skill_table[sn].rating[ch->iclass] == 0
		||  ch->pcdata->learned[sn] == 0
		||  ch->pcdata->learned[sn] == 100)
	return;  /* skill is not known */ 

	/* check to see if the character has a chance to learn */
	chance = 10 * int_app[get_curr_stat(ch,STAT_INT)].learn;
	chance /= (	multiplier * skill_table[sn].rating[ch->iclass] * 4);
	chance += ch->level;

	if (number_range(1,1000) > chance)
		return;

	/* now that the character has a CHANCE to learn, see if they really have */	

	if (success)
	{
		chance = URANGE(5,100 - ch->pcdata->learned[sn], 95);
		if (number_percent() < chance)
		{
			send_to_char(Format("You have become better at %s!\n\r", skill_table[sn].name),ch);
			ch->pcdata->learned[sn]++;
			gain_exp(ch,2 * skill_table[sn].rating[ch->iclass]);
		}
	}

	else
	{
		chance = URANGE(5,ch->pcdata->learned[sn]/2,30);
		if (number_percent() < chance)
		{
			send_to_char(Format("You learn from your mistakes, and your %s skill improves.\n\r", skill_table[sn].name),ch);
			ch->pcdata->learned[sn] += number_range(1,3);
			ch->pcdata->learned[sn] = UMIN(ch->pcdata->learned[sn],100);
			gain_exp(ch,2 * skill_table[sn].rating[ch->iclass]);
		}
	}
}
Ejemplo n.º 12
0
END_TEST

START_TEST(test_field_map)
{
    struct test
    {
        long id;
        const char *name;
        int value;
    };

    struct test T;

    T.id = 0;
    T.name = str_dup("testA");
    T.value = number_percent();

    field_map table[] =
    {
        {"name", &T.name, SQL_TEXT},
        {"intval", &T.value, SQL_INT},
        {0}
    };

    fail_if(T.value != fm_int(&table[1]));

    T.id = db_save(table, DBNAME, T.id);

    int check = number_percent();

    char buf[BUF_SIZ];

    sprintf(buf, "update "DBNAME" set intval=%d where %s=%ld and name='%s' and intval='%d'", check, tablenameid(DBNAME), T.id, T.name, T.value);

    if (sql_exec(buf) != SQL_OK)
    {
        fail("could not update saved data entry");
    }

    db_load_by_id(table, DBNAME, T.id);

    fail_if(T.value != check);
}
Ejemplo n.º 13
0
/*
 * NPC spells.
 */
void Character::spell_acid_breath (int sn, int lvl, void *vo)
{
  Character *victim = (Character *) vo;

  if (number_percent () < 2 * lvl && !victim->saves_spell (lvl)) {
    Object *obj_lose;
    ObjIter o, onext;
    for (o = victim->carrying.begin(); o != victim->carrying.end(); o = onext) {
      obj_lose = *o;
      onext = ++o;
      int iWear;

      if (number_percent() <= 75)
        continue;

      switch (obj_lose->item_type) {
      case ITEM_ARMOR:
        if (obj_lose->value[0] > 0) {
          victim->act ("$p is pitted and etched!", obj_lose, NULL, TO_CHAR);
          if ((iWear = obj_lose->wear_loc) != WEAR_NONE)
            victim->armor -= obj_lose->apply_ac (iWear);
          obj_lose->value[0] -= 1;
          obj_lose->cost = 0;
          if (iWear != WEAR_NONE)
            victim->armor += obj_lose->apply_ac (iWear);
        }
        break;

      case ITEM_CONTAINER:
        victim->act ("$p fumes and dissolves!", obj_lose, NULL, TO_CHAR);
        obj_lose->extract_obj ();
        break;
      }
    }
  }

  int hpch = std::max (10, hit);
  int dam = number_range (hpch / 16 + 1, hpch / 8);
  if (victim->saves_spell (lvl))
    dam /= 2;
  damage (this, victim, dam, sn);
  return;
}
Ejemplo n.º 14
0
void do_gag( CHAR_DATA * ch, char *argument )
{
   CHAR_DATA *victim;
   int schance;

   if( argument[0] == '\0' )
   {
      send_to_char( "Syntax: Gag <victim>\n\r", ch );
      return;
   }

   if( ( victim = get_char_room( ch, argument ) ) == NULL )
   {
      send_to_char( "They are not here.\n\r", ch );
      return;
   }

   if( victim == ch )
   {
      send_to_char( "You can not gag yourself!\n\r", ch );
      return;
   }

   if( IS_NPC( victim ) )
   {
      send_to_char( "You can only gag players.\n\r", ch );
      return;
   }

   if( ( victim->position != POS_STUNNED ) && ( victim->position != POS_SLEEPING )
       && !IS_SET( victim->pcdata->act2, ACT_BOUND ) )
   {
      send_to_char( "They need to be stunned, asleep, or bound.\n\r", ch );
      return;
   }

   schance = ( int )( ch->pcdata->learned[gsn_gag] );

   if( number_percent(  ) < schance )
   {
      act( AT_WHITE, "You quickly place a gag over $N's mouth.", ch, NULL, victim, TO_CHAR );
      act( AT_WHITE, "$n roughly puts a gag over your mouth.", ch, NULL, victim, TO_VICT );
      act( AT_WHITE, "$n roughly places a gag on $N's mouth.", ch, NULL, victim, TO_NOTVICT );
      SET_BIT( victim->pcdata->act2, ACT_GAGGED );
      learn_from_success( ch, gsn_gag );
   }
   else
   {
      send_to_char( "You look puzzled as you wonder how to put on such a contraption.\n\r", ch );
      learn_from_failure( ch, gsn_gag );
   }

   return;
}
Ejemplo n.º 15
0
void power_up_mob( CHAR_DATA * ch )
{
    int num_percent;

    /*
     * you can only have one cloak spell
     */
    if ( !IS_AFFECTED( ch, AFF_CLOAK_ABSORPTION )
            && !IS_AFFECTED( ch, AFF_CLOAK_REFLECTION ) && !IS_AFFECTED( ch, AFF_CLOAK_FLAMING ) )
    {
        num_percent = number_percent(  );

        if ( num_percent > 75 )
        {
            if ( ch->mana >= mana_cost( ch, skill_lookup( "cloak:flaming" ) ) )
                do_cast( ch, "'cloak:flaming'" );
            return;
        }

        if ( num_percent > 50 )
        {
            if ( ch->mana >= mana_cost( ch, skill_lookup( "cloak:reflection" ) ) )
                do_cast( ch, "cloak:reflection" );
            return;
        }

        if ( num_percent > 25 )
        {
            if ( ch->mana >= mana_cost( ch, skill_lookup( "cloak:absorption" ) ) )
                do_cast( ch, "cloak:absorption" );
            return;
        }
    }

    /*
     * usually i only have mobs do one thing per round but what they hell
     * * let the kids have their fun :)
     */
    if ( !IS_AFFECTED( ch, AFF_SANCTUARY ) )
        if ( ch->mana >= mana_cost( ch, skill_lookup( "sanctuary" ) ) )
            do_cast( ch, "sanctuary" );
    if ( !IS_AFFECTED( ch, AFF_PROTECT ) )
        if ( ch->mana >= mana_cost( ch, skill_lookup( "protection" ) ) )
            do_cast( ch, "protection" );
    if ( !IS_AFFECTED( ch, skill_lookup( "bless" ) ) )
        if ( ch->mana >= mana_cost( ch, skill_lookup( "bless" ) ) )
            do_cast( ch, "bless" );
    if ( !IS_AFFECTED( ch, skill_lookup( "stone skin" ) ) )
        if ( ch->mana >= mana_cost( ch, skill_lookup( "stone skin" ) ) )
            do_cast( ch, "stone" );
    return;
}
Ejemplo n.º 16
0
void Weave::ShowNew(const ROOM_INDEX_DATA & room)
{
    for (CHAR_DATA * ch(room.people); ch != NULL; ch = ch->next_in_room)
    {
        // Check for skill
        if (number_percent() >= get_modifier(ch->affected, gsn_weavesense) && !is_an_avatar(ch))
            continue;

        // Skill check passed
        check_improve(ch, NULL, gsn_weavesense, TRUE, 4);
        send_to_char("You sense the Weave twist and flex around you, its primal energy branching and flowing in new patterns!\n", ch);
    }
}
Ejemplo n.º 17
0
bool emote_sniff( CHAR_DATA *ch, CHAR_DATA *victim )
{
  int eyes = 0;
    
  if ( ch == victim )
    eyes = 101;

  if (HAS_HOLYLIGHT(ch)) {
    eyes = 101;
  }

  return (number_percent() < eyes);
}
Ejemplo n.º 18
0
bool spec_poison( CHAR_DATA * ch )
{
   CHAR_DATA *victim;

   if( ch->position != POS_FIGHTING || ( victim = who_fighting( ch ) ) == NULL || number_percent(  ) > 2 * ch->top_level )
      return FALSE;

   act( AT_HIT, "You bite $N!", ch, NULL, victim, TO_CHAR );
   act( AT_ACTION, "$n bites $N!", ch, NULL, victim, TO_NOTVICT );
   act( AT_POISON, "$n bites you!", ch, NULL, victim, TO_VICT );
   spell_poison( gsn_poison, ch->top_level, ch, victim );
   return TRUE;
}
Ejemplo n.º 19
0
int spell_ethereal_snake_devour(int sn, int level, CHAR_DATA *ch, void *vo )
{

    CHAR_DATA *victim = (CHAR_DATA *) vo;
    OBJ_DATA  *obj_lose;
    OBJ_DATA  *obj_next;
        
    if ( !IS_NPC(victim) )
    {
      send_to_char(AT_BLUE, "You failed.\n\r", ch);
      return SKPELL_MISSED;
    }
        
    if ( number_percent( ) < level && !saves_spell( level, victim ) )
      for ( obj_lose = victim->carrying; obj_lose; obj_lose = obj_next )
      {
          obj_next = obj_lose->next_content;
          if ( obj_lose->deleted )
              continue;
   
          if ( number_bits( 2 ) != 0 )
              continue;
     
          act(AT_WHITE, "$p has been devoured by an ethereal snake!",      victim, obj_lose, NULL, TO_CHAR );
          act(AT_WHITE, "$n's $p has been devoured by an ethereal snake!", victim, obj_lose, NULL, TO_ROOM );
          extract_obj( obj_lose ) ;
      }
        
    if ( !saves_spell( level, victim ) )

    /*
     * Devour char, do not generate a corpse, do not
     * give experience for kill.  Extract_char will take care   
     * of items carried/wielded by victim.
     */
    {
        act(AT_WHITE, "Your ethereal snake has DEVOURED $N!",         ch, NULL, victim, TO_CHAR );
        act(AT_WHITE, "You have been DEVOURED by $n's ethereal snake!", ch, NULL, victim, TO_VICT );
        act(AT_WHITE, "$n's ethereal snake DEDVOURS $N!",       ch, NULL, victim, TO_ROOM );
    
        if ( IS_NPC( victim ) )
	{
            extract_char( victim, TRUE );
	}
        else
	{
            extract_char( victim, FALSE );
	}
    }     
    return SKPELL_NO_DAMAGE;
}
Ejemplo n.º 20
0
static bool tprog_percent_check(CHAR_DATA * actor, OBJ_DATA * obj, void *vo,
			 int type, TRAP_DATA * tprogs)
{
	TRAP_DATA *tprg;

	for (tprg = tprogs; tprg != NULL; tprg = tprg->next_here)
		if ((tprg->type & type)
		    && (number_percent() < atoi(tprg->arglist))) {
			mprog_driver(tprg->comlist, smob, actor, obj, vo);
			return TRUE;
		}

	return FALSE;
}
Ejemplo n.º 21
0
void Character::spell_frost_breath (int sn, int lvl, void *vo)
{
  Character *victim = (Character *) vo;

  if (number_percent () < 2 * lvl && !victim->saves_spell (lvl)) {
    Object *obj_lose;
    ObjIter o, onext;
    for (o = victim->carrying.begin(); o != victim->carrying.end(); o = onext) {
      obj_lose = *o;
      onext = ++o;
      const char *msg;

      if (number_percent() <= 75)
        continue;

      switch (obj_lose->item_type) {
      default:
        continue;
      case ITEM_CONTAINER:
      case ITEM_DRINK_CON:
      case ITEM_POTION:
        msg = "$p freezes and shatters!";
        break;
      }

      victim->act (msg, obj_lose, NULL, TO_CHAR);
      obj_lose->extract_obj ();
    }
  }

  int hpch = std::max (10, hit);
  int dam = number_range (hpch / 16 + 1, hpch / 8);
  if (victim->saves_spell (lvl))
    dam /= 2;
  damage (this, victim, dam, sn);
  return;
}
Ejemplo n.º 22
0
bool spec_poison( CHAR_DATA *ch )
{
	CHAR_DATA *victim;

	if ( ch->position != POS_FIGHTING
	|| ( victim = ch->fighting ) == NULL
	||   number_percent( ) > 2 * ch->level )
	return FALSE;

	act( "You bite $N!",  ch, NULL, victim, TO_CHAR    );
	act( "$n bites $N!",  ch, NULL, victim, TO_NOTVICT );
	act( "$n bites you!", ch, NULL, victim, TO_VICT    );
	spell_poison( gsn_poison, ch->level, ch, victim,TARGET_CHAR);
	return TRUE;
}
Ejemplo n.º 23
0
CHAR_DATA *get_quest_target( int min_level, int max_level )
{
    CHAR_DATA *target = NULL;
    list<CHAR_DATA *>::iterator li;
    int min_index = 0;   /* the minimum number of times to go through the list */

    if ( max_level > 140 )
        max_level = 140;
    min_index = number_range(0, mob_index_list.size() - 1);

    for ( li = char_list.begin(); li != char_list.end(); li++ )
    {
        target = *li;
        if ( !IS_NPC( target ) )
            continue;
        min_index--;

        if ( min_index > 0 )
            continue;


        /*
         * Check if mobile is suitable for the quest -
         * Ignore mobs that are likely to be in well known places, such
         * as train/prac mobs, healers, etc
         */

        if ( ( target->level < min_level )
                || ( target->level > max_level )
                || ( IS_VAMP( target ) )
                || ( target->in_room->area->flags.test(AFLAG_NO_SHOW) )
                || ( target->act.test(ACT_SENTINEL) )
                || ( target->act.test(ACT_PET) )
                || ( !str_cmp( rev_spec_lookup( target->npcdata->spec_fun ), "spec_stephen" ) ) )
            continue;

        /*
         * Lastly, some random choice
         */
        if ( number_percent(  ) < 2 )
            break;
    }

    if ( !IS_NPC(target) )
        target = NULL;

    return target;
}
Ejemplo n.º 24
0
bool room_trap_handler( CHAR_DATA *ch )
{
	TRAP_DATA * trap;
	int chance = 50;
	char buf[ MAX_INPUT_LENGTH ];

	if ( IS_NPC( ch ) )
		return FALSE;

	if ( !ch || !ch->in_room )
		return FALSE;

	if ( ( trap = get_trap_index( ch->in_room->trap ) ) == NULL )
		return FALSE;

	if ( !trap->active || !EXT_IS_SET( ch->in_room->room_flags, ROOM_TRAP ) )
		return FALSE;

	chance += 5 * trap->level;

	switch ( ch->class )
	{
		case CLASS_THIEF:
			chance -= 2*ch->level;
			chance -= UMAX( 0, get_curr_stat_deprecated( ch, STAT_DEX ) - 18 ) *5;
			break;
		default: chance -= ch->level;break;
	}

	chance = URANGE( 10, chance, 95 );

	if ( number_percent() > chance )
		return FALSE;

	if ( !supermob )
		init_supermob();

	char_from_room ( supermob );
	char_to_room( supermob, ch->in_room );
	EXT_REMOVE_BIT( ch->in_room->room_flags, ROOM_TRAP );

	sprintf( buf, "trap%d", trap->vnum );
	create_rprog_env( buf, trap->triggered, ch->in_room, ch, NULL, NULL, NULL, NULL );
	program_flow();
	release_supermob();
	return TRUE;
}
Ejemplo n.º 25
0
/*
 * Get a random PC in the room (for $r parameter)
 */
CHAR_DATA *get_random_char( CHAR_DATA *mob )
{
    CHAR_DATA *vch, *victim = NULL;
    int now = 0, highest = 0;
    for( vch = mob->in_room->people; vch; vch = vch->next_in_room )
    {
        if ( mob != vch 
        &&   !IS_NPC( vch ) 
        &&   can_see( mob, vch )
        &&   ( now = number_percent() ) > highest )
        {
            victim = vch;
            highest = now;
        }
    }
    return victim;
}
Ejemplo n.º 26
0
CHAR_DATA *get_quest_giver( int min_level, int max_level )
{
   CHAR_DATA *target;
   int    min_index = 0;



/*   int max_distance = 20; unused */
/*   char *dirs = NULL; unused */
   min_index = number_range(0, 1000);

   for ( target = char_list; target != NULL; target = target->next )
   {
      if ( !IS_NPC( target ) )
         continue;
      min_index -= 1;

      if ( min_index > 0 )
        continue;

		//try and prevent quests to unlinked areas!
	  if (area_is_linked(target->in_room->area->vnum) == FALSE)
	  {
		  continue;
	  }

         
      /*
       * Check if mobile is suitable for the quest -
       * Ignore mobs that are likely to be in well known places, such
       * as train/prac mobs, healers, etc
       */
      
     if (    ( target->level < min_level )
          || ( target->level > max_level )
		  || ( target->in_room->area->vnum == number_range(5, 58)))
             continue;
     {
       if ( number_percent() < 2 )
        break;
     }
      
   }  

   return target;
}         
Ejemplo n.º 27
0
/*
 * A general purpose percentage trigger. Checks if a random percentage
 * number is less than trigger phrase
 */
bool mp_percent_trigger( 
	CHAR_DATA *mob, CHAR_DATA *ch, 
	const void *arg1, const void *arg2, int type )
{
    MPROG_LIST *prg;

    for ( prg = mob->pIndexData->mprogs; prg != NULL; prg = prg->next )
    {
    	if ( prg->trig_type == type 
	&&   number_percent() < atoi( prg->trig_phrase ) )
        {
	    program_flow( prg->vnum, prg->code, mob, ch, arg1, arg2 );
	    return ( TRUE );
	}
    }
    return ( FALSE );
}
Ejemplo n.º 28
0
void do_backstab( CHAR_DATA *ch, char *argument )
{
	char arg[MIL]={'\0'};
	CHAR_DATA *victim;
	/*OBJ_DATA *obj;*/

	one_argument( argument, arg );

	if (IS_NULLSTR(arg))
	{
		send_to_char("Backstab whom?\n\r",ch);
		return;
	}

	if (ch->fighting != NULL)
	{
		send_to_char("You're facing the wrong end.\n\r",ch);
		return;
	}

	else if ((victim = get_char_room(ch,arg)) == NULL)
	{
		send_to_char("They aren't here.\n\r",ch);
		return;
	}

	if ( victim == ch )
	{
		send_to_char( "How can you sneak up on yourself?\n\r", ch );
		return;
	}

	WAIT_STATE( ch, skill_table[gsn_backstab].beats );
	if ( number_percent( ) < get_skill(ch,gsn_backstab)
			|| ( get_skill(ch,gsn_backstab) >= 2 && !IS_AWAKE(victim) ) )
	{
		multi_hit( ch, victim, gsn_backstab );
	}
	else
	{
		damage( ch, victim, 0, gsn_backstab,DAM_NONE,TRUE,0,-1);
	}

	return;
}
Ejemplo n.º 29
0
void show_char_to_char_2(struct char_data *victim, struct char_data *ch)
{
    struct gameobject *obj;
    struct dynamic_skill *skill_peek;
    int iWear;
    bool found;

    if (can_see(victim, ch)) {
	if (ch == victim) {
	    act("$n glances at $mself.", ch, NULL, NULL, TO_ROOM);
	} else {
	    act("$n glances at you.", ch, NULL, victim, TO_VICT);
	    act("$n glances at $N.", ch, NULL, victim, TO_NOTVICT);
	}
    }

    show_damage_display(ch, victim);

    found = false;
    for (iWear = 0; where_name[iWear].wear_loc >= 0; iWear++) {
	if ((obj = get_eq_char(victim, where_name[iWear].wear_loc)) != NULL
		&& can_see_obj(ch, obj)) {
	    if (!found) {
		send_to_char("\n\r", ch);
		act("$N is using:", ch, NULL, victim, TO_CHAR);
		found = true;
	    }
	    send_to_char(where_name[iWear].desc, ch);
	    send_to_char("(", ch);
	    send_to_char(format_obj_to_char(obj, ch, true), ch);
	    send_to_char(")", ch);
	    send_to_char("\n\r", ch);
	}
    }

    if (victim != ch && !IS_NPC(ch)
	    && (skill_peek = gsp_peek) != NULL
	    && number_percent() < get_learned_percent(ch, skill_peek)) {
	send_to_char("\n\rYou peek at the inventory:\n\r", ch);
	check_improve(ch, skill_peek, true, 4);
	show_list_to_char(victim->carrying, ch, true, true);
    }

    return;
}
Ejemplo n.º 30
0
bool rp_percent_trigger( CHAR_DATA *mob, CHAR_DATA *ch,
                         void *arg1, void *arg2, BITVECT_DATA *type )
{
	PROG_LIST * prg;
	if ( !mob ) return ( FALSE );

	for ( prg = mob->in_room->progs; prg != NULL; prg = prg->next )
	{
		if ( prg->trig_type == type
		     && number_percent() <= atoi( prg->trig_phrase ) )
		{
			create_rprog_env( prg->name, prg->code, mob->in_room, ch, arg1, arg2, prg->trig_type, prg->trig_phrase );
			program_flow();
			return ( TRUE );
		}
	}
	return ( FALSE );
}