Beispiel #1
0
int
is_ok_char(struct char_data * keeper, struct char_data * ch, int shop_nr)
{
  char buf[200];

  if (!(CAN_SEE(keeper, ch)))
    {
      do_say(keeper, MSG_NO_SEE_CHAR, cmd_say, 0);
      return (FALSE);
    }
  if (IS_GOD(ch))
    return (TRUE);

  if ((IS_GOOD(ch) && NOTRADE_GOOD(shop_nr)) ||
      (IS_EVIL(ch) && NOTRADE_EVIL(shop_nr)) ||
      (IS_NEUTRAL(ch) && NOTRADE_NEUTRAL(shop_nr)))
    {
      sprintf(buf, "%s %s", GET_NAME(ch), MSG_NO_SELL_ALIGN);
      do_tell(keeper, buf, cmd_tell, 0);
      return (FALSE);
    }
  if (IS_NPC(ch))
    return (TRUE);

  if ((IS_MAGIC_USER(ch) && NOTRADE_MAGIC_USER(shop_nr)) ||
      (IS_CLERIC(ch) && NOTRADE_CLERIC(shop_nr)) ||
      (IS_THIEF(ch) && NOTRADE_THIEF(shop_nr)) ||
      (IS_WARRIOR(ch) && NOTRADE_WARRIOR(shop_nr)))
    {
      sprintf(buf, "%s %s", GET_NAME(ch), MSG_NO_SELL_CLASS);
      do_tell(keeper, buf, cmd_tell, 0);
      return (FALSE);
    }
  return (TRUE);
}
Beispiel #2
0
static void
quest_weapon_enchant(struct creature *ch, struct obj_data *obj, int lvl)
{
    int i;
    for (i = MAX_OBJ_AFFECT - 1; i >= 0; i--) {
        if (obj->affected[i].location == APPLY_HITROLL ||
            obj->affected[i].location == APPLY_DAMROLL) {
            obj->affected[i].location = APPLY_NONE;
            obj->affected[i].modifier = 0;
        } else if (i < MAX_OBJ_AFFECT - 2 && obj->affected[i].location) {
            obj->affected[i + 2].location = obj->affected[i].location;
            obj->affected[i + 2].modifier = obj->affected[i].modifier;
        }
    }

    obj->affected[0].location = APPLY_HITROLL;
    obj->affected[0].modifier = MAX(2, number(2, 4)) +
        (lvl >= 50) + (lvl >= 56) + (lvl >= 60) + (lvl >= 67);

    obj->affected[1].location = APPLY_DAMROLL;
    obj->affected[1].modifier = MAX(2, number(2, 4)) +
        (lvl >= 50) + (lvl >= 56) + (lvl >= 60) + (lvl >= 67);

    if (IS_GOOD(ch)) {
        SET_BIT(GET_OBJ_EXTRA(obj), ITEM_ANTI_EVIL);
        act("$p glows a bright blue.", false, ch, obj, NULL, TO_CHAR);
    } else if (IS_EVIL(ch)) {
        SET_BIT(GET_OBJ_EXTRA(obj), ITEM_ANTI_GOOD);
        act("$p glows a bright red.", false, ch, obj, NULL, TO_CHAR);
    } else {
        act("$p glows a bright yellow.", false, ch, obj, NULL, TO_CHAR);
    }

    SET_BIT(GET_OBJ_EXTRA(obj), ITEM_MAGIC | ITEM_GLOW);
}
Beispiel #3
0
// Returns a tmpstr allocated char* containing an appropriate ANSI
// color code for the given target struct creature (tch) with the given
// recipient struct creature(ch)'s color settings in mind.
const char *
get_char_class_color_code(struct creature *ch, struct creature *tch,
    int char_class)
{
    switch (char_class) {
    case CLASS_MAGIC_USER:
        return CCMAG(ch, C_NRM);
    case CLASS_CLERIC:
        if (IS_GOOD(tch)) {
            return CCBLU_BLD(ch, C_NRM);
        } else if (IS_EVIL(tch)) {
            return CCRED_BLD(ch, C_NRM);
        } else {
            return CCYEL(ch, C_NRM);
        }
    case CLASS_KNIGHT:
        if (IS_GOOD(tch)) {
            return CCBLU_BLD(ch, C_NRM);
        } else if (IS_EVIL(tch)) {
            return CCRED(ch, C_NRM);
        } else {
            return CCYEL(ch, C_NRM);
        }
    case CLASS_RANGER:
        return CCGRN(ch, C_NRM);
    case CLASS_BARB:
        return CCCYN(ch, C_NRM);
    case CLASS_THIEF:
        return CCNRM_BLD(ch, C_NRM);
    case CLASS_CYBORG:
        return CCCYN(ch, C_NRM);
    case CLASS_PSIONIC:
        return CCMAG(ch, C_NRM);
    case CLASS_PHYSIC:
        return CCNRM_BLD(ch, C_NRM);
    case CLASS_BARD:
        return CCYEL_BLD(ch, C_NRM);
    case CLASS_MONK:
        return CCGRN(ch, C_NRM);
    case CLASS_MERCENARY:
        return CCYEL(ch, C_NRM);
    default:
        return CCNRM(ch, C_NRM);
    }
}
Beispiel #4
0
int invalid_align(struct char_data *ch, struct obj_data *obj)
{
  if (OBJ_FLAGGED(obj, ITEM_ANTI_EVIL) && IS_EVIL(ch))
    return TRUE;
  if (OBJ_FLAGGED(obj, ITEM_ANTI_GOOD) && IS_GOOD(ch))
    return TRUE;
  if (OBJ_FLAGGED(obj, ITEM_ANTI_NEUTRAL) && IS_NEUTRAL(ch))
    return TRUE;
  return FALSE;
}
Beispiel #5
0
int calcManaMulti(CharData *ch) {
    int multi = 100;

    if(ROOM_FLAGGED(ch->in_room, ROOM_MANA_REGEN))
        multi += 50;
    
    if(IS_AFFECTED(ch, AFF_WRAITHFORM))
        multi += 25;

    if((GET_CLASS(ch) == CLASS_SHADOW_DANCER) && (IS_DARK(ch->in_room) || IS_AFFECTED(ch, AFF_SHADOW_SPHERE)))
        multi += 50;

    if(IS_AFFECTED(ch, AFF_POISON))
        multi -= 100;

    if(!IS_NPC(ch)) {
        if( !IS_NPC(ch) && ROOM_FLAGGED(ch->in_room, ROOM_SUFFER) && ( GET_LEVEL(ch) < LVL_IMMORT ))
            multi -= 90;
        else if (!GET_COND(ch, THIRST) && IS_AMARA(ch))
            multi -= 90;
        else if (IS_IZARTI(ch) && IS_EVIL(ch))
            multi -= 90;
        else if (IS_DEMON(ch) && IS_GOOD(ch))
            multi -= 90;
    }

    if(GET_RACE(ch) == RACE_STROLL)
        multi += 100;

    /* Position calculations    */
    switch (GET_POS(ch)) {
        case POS_MEDITATING:
        case POS_SLEEPING:
            multi += 120;
            break;
        case POS_RESTING:
            multi += 60;
            break;
    }

    multi += (int)GET_SKILL(ch, SKILL_DEVOTION);

    // Don't let a player's regeneration completely stagnate...
    multi = MAX(multi, 25);
    return multi;
}
Beispiel #6
0
/* Hitpoint gain per game hour */
int hit_gain(CharData * ch)
{    
    // Character is messed
    if (IN_ROOM(ch) == -1) return 0;

    // Delusion health deflates fairly quickly
    if(affected_by_spell(ch, SKILL_DELUSION))
        return -(GET_MAX_HIT(ch) * spell_level(ch, SKILL_DELUSION) / 9);

    /* Are they rotting away ? */
    if (!IS_NPC(ch) && IS_UNDEAD(ch)) {
        return ( (GET_LEVEL(ch) < 50) && (ch->desc) ) ? -GET_LEVEL(ch) : 0;
    }

    /* Race calculations */
    /* vampires don't regenerate in sunlight, unless they're shadow sphered */
    if (!IS_NPC(ch) && IS_VAMPIRE(ch) &&
            IS_SUNLIGHT(IN_ROOM(ch)) && !IS_AFFECTED(ch, AFF_SHADOW_SPHERE))
        return 0;

    if(!IS_NPC(ch)) {
        int suffer = 0;

        if(ROOM_FLAGGED(ch->in_room, ROOM_SUFFER) && ( GET_LEVEL(ch) < LVL_IMMORT ))
            suffer = 1;
        else if(!GET_COND(ch, THIRST) && IS_AMARA(ch))
            suffer = 1;
        else if (IS_IZARTI(ch) && IS_EVIL(ch))
            suffer = 1;
        else if (IS_DEMON(ch) && IS_GOOD(ch))
            suffer = 1;

        if(suffer == 1) {
            if(percentSuccess(2))
                damage(ch, ch, -SUFFER_RATE, TYPE_ROOM_SUFFER);
            return 0;
        }
    }

    int base = calcHitBase(ch);
    int multiplier = calcHitMulti(ch);
    int bonus = calcHitBonus(ch);

    int gain = base*multiplier/100 + bonus;
    return (gain);
}/* hit_gain */
Beispiel #7
0
void equip_char(struct char_data *ch, struct obj_data *obj, int pos)
{
    int j;

    assert(pos>=0 && pos<MAX_WEAR);
    assert(!(ch->equipment[pos]));

    if (obj->carried_by) {
	log("EQUIP: Obj is carried_by when equip.");
	return;
    }

    if (obj->in_room!=NOWHERE) {
	log("EQUIP: Obj is in_room when equip.");
	return;
    }

    if ((IS_OBJ_STAT(obj, ITEM_ANTI_EVIL) && IS_EVIL(ch)) ||
	(IS_OBJ_STAT(obj, ITEM_ANTI_GOOD) && IS_GOOD(ch)) ||
	(IS_OBJ_STAT(obj, ITEM_ANTI_NEUTRAL) && IS_NEUTRAL(ch))) {
	if (ch->in_room != NOWHERE) {
/*
	    act("You are zapped by $p and instantly drop it.", FALSE, ch, obj, 0, TO_CHAR);
	    act("$n is zapped by $p and instantly drop it.", FALSE, ch, obj, 0, TO_ROOM);
	    obj_to_room(obj, ch->in_room);
	    return; */
	} else {
	    log("ch->in_room = NOWHERE when equipping char.");
	}
    }

    ch->equipment[pos] = obj;

    if (GET_ITEM_TYPE(obj) == ITEM_ARMOR)
	GET_AC(ch) -= apply_ac(ch, pos);

    for(j=0; j<MAX_OBJ_AFFECT; j++)
	affect_modify(ch, obj->affected[j].location,
	  obj->affected[j].modifier,
	  obj->obj_flags.bitvector, TRUE);

    affect_total(ch);
}
Beispiel #8
0
void do_pray( CHAR_DATA * ch, char * argument ) {
  if ( !IS_GOOD( ch ) ) {
    send_to_char( AT_BLUE, "Thalador forgives some of your sins.\n\r", ch );
    ch->alignment += 10;
  } else if ( !IS_NPC( ch ) && ch->pcdata->learned[ gsn_prayer ] < number_percent() ) {
    send_to_char( AT_BLUE, "Thalador smiles upon you, and sends you a gold coin.\n\r", ch );
    ch->money.gold += 1;
  } else if ( !is_affected( ch, gsn_prayer ) ) {
    AFFECT_DATA af;

    af.duration  = ch->level / 3;
    af.level     = ch->level;
    af.type      = gsn_prayer;
    af.bitvector = 0;

    af.location = APPLY_HIT;
    af.modifier = number_range( ch->level, ch->level * 2 );
    affect_to_char( ch, &af );

    af.location = APPLY_MANA;
    af.modifier = number_range( ch->level / 2, ch->level );
    affect_to_char( ch, &af );

    af.location = APPLY_INT;
    af.modifier = ( ( ch->level - 1 ) / 50 ) + 1;
    affect_to_char( ch, &af );

    af.location = APPLY_DEX;
    affect_to_char( ch, &af );

    send_to_char( AT_BLUE, "Thalador places his blessing upon you.\n\r", ch );
    update_skpell( ch, gsn_prayer );
  } else {
    send_to_char( AT_BLUE, "Thalador frowns at your greed.\n\r", ch );
    ch->alignment -= 10;
  }

  send_to_char( AT_GREY, "You fall to the ground, unconscious.\n\r", ch );
  act( AT_GREY, "$n falls to the ground, unconscious.", ch, NULL, NULL, TO_ROOM );
  STUN_CHAR( ch, 4, STUN_COMMAND );
  return;
}
Beispiel #9
0
int calcMoveMulti(CharData *ch) {
    int multi = 100;
    
    if(IS_AFFECTED(ch, AFF_PLAGUE) > 0)
        multi -= 50;

    /* vampires barely regen vigor in sunlight, unless they're shadow sphered */
    if (!IS_NPC(ch) && IS_VAMPIRE(ch) && IS_SUNLIGHT(IN_ROOM(ch)) && !IS_AFFECTED(ch, AFF_SHADOW_SPHERE))
        multi -= 90;
    else if (IS_AFFECTED(ch, AFF_POISON))
        multi -= 90;
    else if ((GET_COND(ch, HUNGER) == 0 && !IS_VAMPIRE(ch)) || (GET_COND(ch, THIRST) == 0))
        multi -= 90;

    if( ROOM_FLAGGED(ch->in_room, ROOM_SUFFER) && ( GET_LEVEL(ch) < LVL_IMMORT ))
        multi -= 90;
    else if (!GET_COND(ch, THIRST) && IS_AMARA(ch))
        multi -= 90;
    else if (IS_IZARTI(ch) && IS_EVIL(ch))
        multi -= 90;
    else if (IS_DEMON(ch) && IS_GOOD(ch))
        multi -= 90;

    /* Position calculations    */
    switch (GET_POS(ch)) {
        case POS_MEDITATING:
        case POS_SLEEPING:
            multi += 120;
            break;
        case POS_RESTING:
            multi += 80;
            break;
        case POS_SITTING:
            multi += 40;	/* Divide by 8 */
            break;
    }

    // Don't let a player's regeneration completely stagnate...
    multi = MAX(multi, 25);
    return multi;
}
Beispiel #10
0
static void
quest_armor_enchant(struct creature *ch, struct obj_data *obj, int lvl)
{
    int i;

    for (i = 0; i < MAX_OBJ_AFFECT - 1; i++) {
        if (obj->affected[i].location == APPLY_AC ||
            obj->affected[i].location == APPLY_SAVING_BREATH ||
            obj->affected[i].location == APPLY_SAVING_SPELL ||
            obj->affected[i].location == APPLY_SAVING_PARA) {
            obj->affected[i].location = APPLY_NONE;
            obj->affected[i].modifier = 0;
        }
    }

    obj->affected[0].location = APPLY_AC;
    obj->affected[0].modifier = -(lvl / 8) - 5;

    obj->affected[1].location = APPLY_SAVING_PARA;
    obj->affected[1].modifier = -(4 + (lvl >= 53));

    obj->affected[2].location = APPLY_SAVING_BREATH;
    obj->affected[2].modifier = -(4 + (lvl >= 53));

    obj->affected[3].location = APPLY_SAVING_SPELL;
    obj->affected[3].modifier = -(4 + (lvl >= 53));

    if (IS_GOOD(ch)) {
        SET_BIT(GET_OBJ_EXTRA(obj), ITEM_ANTI_EVIL);
        act("$p glows a bright blue.", false, ch, obj, NULL, TO_CHAR);
    } else if (IS_EVIL(ch)) {
        SET_BIT(GET_OBJ_EXTRA(obj), ITEM_ANTI_GOOD);
        act("$p glows a bright red.", false, ch, obj, NULL, TO_CHAR);
    } else {
        act("$p glows a bright yellow.", false, ch, obj, NULL, TO_CHAR);
    }

    SET_BIT(GET_OBJ_EXTRA(obj), ITEM_MAGIC | ITEM_GLOW);
}
Beispiel #11
0
// Returns a const char* containing an appropriate '&c' color code for the given target
// struct creature (tch) suitable for use with send_to_desc.
const char *
get_char_class_color(struct creature *tch, int char_class)
{
    switch (char_class) {
    case CLASS_MAGIC_USER:
        return "&m";
    case CLASS_CLERIC:
    case CLASS_KNIGHT:
        if (IS_GOOD(tch)) {
            return "&B";
        } else if (IS_EVIL(tch)) {
            return "&R";
        } else {
            return "&y";
        }
    case CLASS_RANGER:
        return "&g";
    case CLASS_BARB:
        return "&c";
    case CLASS_THIEF:
        return "&N";
    case CLASS_CYBORG:
        return "&c";
    case CLASS_PSIONIC:
        return "&m";
    case CLASS_PHYSIC:
        return "&N";
    case CLASS_BARD:
        return "&Y";
    case CLASS_MONK:
        return "&g";
    case CLASS_MERCENARY:
        return "&y";
    default:
        return "&n";
    }
}
Beispiel #12
0
/* Some initializations for characters, including initial skills
   If mode == 0, then act as though the character was entering the
   game for the first time.  Otherwise, act as though the character
   is being set to that level.
 */
void
do_start(struct creature *ch, int mode)
{
    void advance_level(struct creature *ch, int8_t keep_internal);
    int8_t new_player = 0;
    int i;
    struct obj_data *implant_save[NUM_WEARS];
    struct obj_data *tattoo_save[NUM_WEARS];

    // remove implant affects
    for (i = 0; i < NUM_WEARS; i++) {
        if (GET_IMPLANT(ch, i))
            implant_save[i] = raw_unequip_char(ch, i, EQUIP_IMPLANT);
        else
            implant_save[i] = NULL;
        if (GET_TATTOO(ch, i))
            tattoo_save[i] = raw_unequip_char(ch, i, EQUIP_TATTOO);
        else
            tattoo_save[i] = NULL;
    }

    if (GET_EXP(ch) == 0 && !IS_REMORT(ch) && !IS_VAMPIRE(ch))
        new_player = true;

    GET_LEVEL(ch) = 1;
    GET_EXP(ch) = 1;

    if (mode)
        roll_real_abils(ch);

    for (i = 1; i <= MAX_SKILLS; i++)
        SET_SKILL(ch, i, 0);

    if (IS_VAMPIRE(ch))
        GET_LIFE_POINTS(ch) = 1;
    else
        GET_LIFE_POINTS(ch) = 3 * (GET_WIS(ch) + GET_CON(ch)) / 40;

    ch->points.max_hit = 20;
    ch->points.max_mana = 100;
    ch->points.max_move = 82;

    if (IS_TABAXI(ch)) {
        SET_SKILL(ch, SKILL_CLAW, LEARNED(ch));
        SET_SKILL(ch, SKILL_BITE, LEARNED(ch));
    }
    if (IS_ELF(ch)) {
        SET_SKILL(ch, SKILL_ARCHERY, LEARNED(ch));
    }

    switch (GET_CLASS(ch)) {
    case CLASS_MAGIC_USER:
        SET_SKILL(ch, SKILL_PUNCH, 10);
        break;
    case CLASS_CLERIC:
        SET_SKILL(ch, SKILL_PUNCH, 10);
        break;
    case CLASS_THIEF:
        SET_SKILL(ch, SKILL_PUNCH, 15);
        SET_SKILL(ch, SKILL_SNEAK, 10);
        SET_SKILL(ch, SKILL_HIDE, 5);
        SET_SKILL(ch, SKILL_STEAL, 15);
        break;
    case CLASS_WARRIOR:
        SET_SKILL(ch, SKILL_PUNCH, 20);
        break;
    case CLASS_BARB:
        SET_SKILL(ch, SKILL_PUNCH, 15);
        break;
    case CLASS_PSIONIC:
        SET_SKILL(ch, SKILL_PUNCH, 10);
        break;
    case CLASS_PHYSIC:
        SET_SKILL(ch, SKILL_PUNCH, 10);
        break;
    case CLASS_CYBORG:
        SET_SKILL(ch, SKILL_PUNCH, 10);
        break;
    case CLASS_KNIGHT:
        SET_SKILL(ch, SKILL_PUNCH, 20);
        break;
    case CLASS_RANGER:
        SET_SKILL(ch, SKILL_PUNCH, 15);
        GET_MAX_MOVE(ch) += dice(4, 9);
        break;
    case CLASS_MONK:
        SET_SKILL(ch, SKILL_PUNCH, 20);
        break;
    case CLASS_MERCENARY:
        SET_SKILL(ch, SKILL_PUNCH, 20);
    case CLASS_BARD:
        SET_SKILL(ch, SKILL_PUNCH, 25);
        SET_SKILL(ch, SKILL_ARCHERY, 25);
        break;

    }

    if (new_player) {
        if (PAST_CLASS(GET_CLASS(ch))) {
            deposit_past_bank(ch->desc->account,
                8192 + number(256, 2048) + GET_INT(ch) + GET_WIS(ch));
            ch->points.gold =
                8192 + number(256, 2048) + GET_INT(ch) + GET_WIS(ch);
        } else if (FUTURE_CLASS(GET_CLASS(ch))) {
            deposit_future_bank(ch->desc->account,
                8192 + number(256, 2048) + GET_INT(ch) + GET_WIS(ch));
            ch->points.cash =
                8192 + number(256, 2048) + GET_INT(ch) + GET_WIS(ch);
        }

        // New players do not start with the gown at this point
        // This has been left in for reference for generic newbie starting gear for the future.
        // New players start with a hospital gown and items most dear to them
        /*
        struct obj_data *gown = read_object(33800);
        if (gown != NULL) {
            equip_char(ch, gown, WEAR_ABOUT, EQUIP_WORN);
        }
        */

        // Good clerics start with a holy symbol on neck
        if ((GET_CLASS(ch) == CLASS_CLERIC) && IS_GOOD(ch)) {
            struct obj_data *talisman = read_object(1280);
            if (talisman != NULL) {
                equip_char(ch, talisman, WEAR_NECK_1, EQUIP_WORN);
            }
        }

        // Evil clerics start with a holy symbol on hold
        if ((GET_CLASS(ch) == CLASS_CLERIC) && IS_EVIL(ch)) {
            struct obj_data *symbol = read_object(1260);
            if (symbol != NULL) {
                equip_char(ch, symbol, WEAR_HOLD, EQUIP_WORN);
            }
        }

        // Good knights start with a holy symbol on finger
        if ((GET_CLASS(ch) == CLASS_KNIGHT) && IS_GOOD(ch)) {
            struct obj_data *ring = read_object(1287);
            if (ring != NULL) {
                equip_char(ch, ring, WEAR_FINGER_L, EQUIP_WORN);
            }
        }

        // Evil knights start with a holy symbol on neck
        if ((GET_CLASS(ch) == CLASS_KNIGHT) && IS_EVIL(ch)) {
            struct obj_data *pendant = read_object(1270);
            if (pendant != NULL) {
                equip_char(ch, pendant, WEAR_NECK_1, EQUIP_WORN);
            }
        }

        // Bards start with a percussion instrument held, and stringed in inventory
        if (GET_CLASS(ch) == CLASS_BARD) {
            struct obj_data *lute = read_object(3218);
            if (lute != NULL) {
                obj_to_char(lute, ch);
            }
        }
   
        set_title(ch, "the complete newbie");
    }

    advance_level(ch, 0);

    GET_MAX_MOVE(ch) += GET_CON(ch);

    GET_HIT(ch) = GET_MAX_HIT(ch);
    GET_MANA(ch) = GET_MAX_MANA(ch);
    GET_MOVE(ch) = GET_MAX_MOVE(ch);

    GET_COND(ch, THIRST) = 24;
    GET_COND(ch, FULL) = 24;
    GET_COND(ch, DRUNK) = 0;

    if (new_player) {
        ch->player.time.played = 0;
        ch->player.time.logon = time(NULL);
    }

    for (i = 0; i < NUM_WEARS; i++) {
        if (implant_save[i])
            equip_char(ch, implant_save[i], i, EQUIP_IMPLANT);
        if (tattoo_save[i])
            equip_char(ch, tattoo_save[i], i, EQUIP_TATTOO);
    }
}
Beispiel #13
0
/*
 * Every spell that does damage comes through here.  This calculates the
 * amount of damage, adds in any modifiers, determines what the saves are,
 * tests for save and calls damage().
 *
 * -1 = dead, otherwise the amount of damage done.
 */
int mag_damage(int level, struct char_data *ch, struct char_data *victim,
		     int spellnum, int savetype)
{
  int dam = 0;

  if (victim == NULL || ch == NULL)
    return (0);

  switch (spellnum) {
    /* Mostly mages */
  case SPELL_MAGIC_MISSILE:
  case SPELL_CHILL_TOUCH:	/* chill touch also has an affect */
    if (IS_MAGIC_USER(ch))
      dam = dice(1, 8) + 1;
    else
      dam = dice(1, 6) + 1;
    break;
  case SPELL_BURNING_HANDS:
    if (IS_MAGIC_USER(ch))
      dam = dice(3, 8) + 3;
    else
      dam = dice(3, 6) + 3;
    break;
  case SPELL_SHOCKING_GRASP:
    if (IS_MAGIC_USER(ch))
      dam = dice(5, 8) + 5;
    else
      dam = dice(5, 6) + 5;
    break;
  case SPELL_LIGHTNING_BOLT:
    if (IS_MAGIC_USER(ch))
      dam = dice(7, 8) + 7;
    else
      dam = dice(7, 6) + 7;
    break;
  case SPELL_COLOR_SPRAY:
    if (IS_MAGIC_USER(ch))
      dam = dice(9, 8) + 9;
    else
      dam = dice(9, 6) + 9;
    break;
  case SPELL_FIREBALL:
    if (IS_MAGIC_USER(ch))
      dam = dice(11, 8) + 11;
    else
      dam = dice(11, 6) + 11;
    break;

    /* Mostly clerics */
  case SPELL_DISPEL_EVIL:
    dam = dice(6, 8) + 6;
    if (IS_EVIL(ch)) {
      victim = ch;
      dam = GET_HIT(ch) - 1;
    } else if (IS_GOOD(victim)) {
      act("The gods protect $N.", FALSE, ch, 0, victim, TO_CHAR);
      return (0);
    }
    break;
  case SPELL_DISPEL_GOOD:
    dam = dice(6, 8) + 6;
    if (IS_GOOD(ch)) {
      victim = ch;
      dam = GET_HIT(ch) - 1;
    } else if (IS_EVIL(victim)) {
      act("The gods protect $N.", FALSE, ch, 0, victim, TO_CHAR);
      return (0);
    }
    break;


  case SPELL_CALL_LIGHTNING:
    dam = dice(7, 8) + 7;
    break;

  case SPELL_HARM:
    dam = dice(8, 8) + 8;
    break;

  case SPELL_ENERGY_DRAIN:
    if (GET_LEVEL(victim) <= 2)
      dam = 100;
    else
      dam = dice(1, 10);
    break;

    /* Area spells */
  case SPELL_EARTHQUAKE:
    dam = dice(2, 8) + level;
    break;

  } /* switch(spellnum) */


  /* divide damage by two if victim makes his saving throw */
  if (mag_savingthrow(victim, savetype, 0))
    dam /= 2;

  /* and finally, inflict the damage */
  return (damage(ch, victim, dam, spellnum));
}
Beispiel #14
0
void do_track( CHAR_DATA *ch, char *argument )
{
	char       buf [ MAX_STRING_LENGTH ];
	char       arg [ MAX_STRING_LENGTH ];
	CHAR_DATA *victim;
	int        direction, skill;
	bool       fArea=TRUE;

	skill=get_skill(ch, gsn_track);

	if (IS_NPC(ch))
	{
		return;
	}

	if ( ch->mount )
	{
		send_to_char( "Najpierw zsi±d¼ ze swojego wierzchowca.\n\r", ch );
		return;
	}

	if ( !IS_IMMORTAL( ch ) && IS_AFFECTED( ch, AFF_BLIND ) )
	{
		act("$n klêka i bezradnie potrz±sa g³ow±.",ch,NULL,NULL,TO_ROOM);
		send_to_char("Klekasz, ale przecie¿ niczego nie widzisz.\n\r",ch);
		return;
	}
	if ( room_is_dark( ch, ch->in_room ) &&  !(IS_AFFECTED( ch, AFF_DARK_VISION ) || IS_IMMORTAL( ch ) ))
	{
		send_to_char("Klekasz, ale jest tu tak ciemno, ¿e niczego nie widzisz.\n\r",ch);
		return;
	}

	// wycinamy niektóre ze sektorów
	switch ( ch->in_room->sector_type )
	{
		case  6:  //woda p³yw
		case  7:  //woda niep
		case 19:  //rzeka
		case 20:  //jezioro
		case 21:  //morze
		case 22:  //ocean
		case 23:  //lawa
		case 24:  //ruchome piaski
		case 25:  //gor±ce ¼ród³o
		case 34:  //pod wod±
		case 37:  //ciemna woda
		case 39:  //podziemne jezioro
			send_to_char( "Tutaj chyba nie da siê szukaæ ¶ladów.\n\r", ch );
			return;
	}

	// komunikaty dla tych, którzy nie umiej± szukaæ ¶ladów
	if ( skill == 0 )
	{
		switch (number_range(1,7))
		{
			case 1:
				act("$n klêka i nie wie co robiæ dalej.",ch,NULL,NULL,TO_ROOM);
				send_to_char("Klêkasz i nie za bardzo wiesz co robiæ dalej.\n\r",ch);
				break;
			case 2:
				act("$n klêka i niczego nie widzi.",ch,NULL,NULL,TO_ROOM);
				send_to_char("Klêkasz i niczego nie widzisz.\n\r",ch);
				break;
			case 3:
				act("$n mocno tupie, klêka i przygl±da siê ¶ladom.",ch,NULL,NULL,TO_ROOM);
				send_to_char("Mocno tupiesz, klêkasz i przygl±dasz siê ¶ladom.\n\r",ch);
				break;
			case 4:
				act("$n klêka i ¶ledzi tropy, ale nie ma o tym zielonego pojêcia.",ch,NULL,NULL,TO_ROOM);
				send_to_char("Klêkasz i ¶ledzisz tropy, choæ nie masz o tym zielonego pojêcia.\n\r",ch);
				break;
			case 5:
				act("$n klêka i robi nieszczê¶liw± minê.",ch,NULL,NULL,TO_ROOM);
				send_to_char("Klêkasz i robisz nieszczê¶liw± minê.\n\r",ch);
				break;
			case 6:
				act("$n rozgl±da siê dooko³a.",ch,NULL,NULL,TO_ROOM);
				send_to_char("Rozgl±dasz siê dooko³a, ale to nie pomaga.\n\r",ch);
				break;
			case 7:
				act("$n zastanawia siê nad tym, ¿e tropienie to niez³a umiejêtno¶æ.",ch,NULL,NULL,TO_ROOM);
				send_to_char("Zastanawiasz siê nad tym, ¿e tropienie to niez³a umiejêtno¶æ.\n\r",ch);
				break;
			default :
				send_to_char( "Nie masz pojêcia jak to siê robi.\n\r", ch );
				act("$n klêka i ¶ledzi tropy, ale nie ma o tym zielonego pojêcia.",ch,NULL,NULL,TO_ROOM);
				break;
		}
		return;
	}

	// bonus/kara od dobrej lokacji s± wiêksze ni¿ od z³ej
	if ( EXT_IS_SET( ch->in_room->room_flags, ROOM_CONSECRATE ))
	{
		if (IS_EVIL( ch ) ) skill -= number_range(1,5);
		if (IS_GOOD( ch ) ) skill += number_range(1,5);
	}

	if ( EXT_IS_SET( ch->in_room->room_flags, ROOM_DESECRATE ))
	{
		if (IS_EVIL( ch ) ) skill += number_range(0,4);
		if (IS_GOOD( ch ) ) skill -= number_range(0,4);
	}

	// sprawdzamy czy skill nie zrobi³ siê nam mniejszy ni¿ 1
	if (skill < 1)
	{
		skill = 1;
	}

	// no to zaczynamy w³a¶ciwe trackowanie :D
	one_argument( argument, arg );

#ifdef ENABLE_NEW_TRACK
	if(MAX_TRACK_LEN > 0)
	{
		track_new(ch, skill, argument);
		return;
	}
#endif

	if ( arg[0] == '\0' )
	{
		act("$n klêka i zaczyna z uwag± przygl±daæ siê ¶ladom.",ch,NULL,NULL,TO_ROOM);
		act("Klêkasz i z uwag± przygl±dasz siê ¶ladom.",ch,NULL,NULL,TO_CHAR);
		return;
	}

	if ( fArea )
	{
		victim = get_char_area( ch, arg );
	}
	else
	{
		victim = get_char_world( ch, arg );
	}

	if ( !victim )
	{
		act("$n klêka i zaczyna z uwag± przygl±daæ siê ¶ladom.",ch,NULL,NULL,TO_ROOM);
		act("Klêkasz, przygl±dasz siê ¶ladom, ale nie znajdujesz ¿adnego tropu.",ch,NULL,NULL,TO_CHAR);
		WAIT_STATE( ch, skill_table[gsn_track].beats );
		return;
	}

	if(victim==ch)
	{
		act("Zastanawiasz siê przez chwilê czy to ma sens, no có¿...",ch,NULL,NULL,TO_CHAR);
		return;
	}

	if ( ch->in_room == victim->in_room )
	{
		act( "Klêkasz i badasz trop, po chwili zdajesz sobie sprawê, ¿e $N stoi ko³o ciebie.", ch, NULL, victim, TO_CHAR );
		act("$n klêka i zaczyna z uwag± przygl±daæ siê ¶ladom.",ch,NULL,NULL,TO_ROOM);
		return;
	}

	if ( skill < number_range( 20, 40 ) )
	{
		act("$n klêka i zaczyna z uwag± przygl±daæ siê ¶ladom.",ch,NULL,NULL,TO_ROOM);
		act("Klêkasz, przygl±dasz siê ¶ladom, ale nie znajdujesz ¿adnego tropu.",ch,NULL,NULL,TO_CHAR);
		WAIT_STATE( ch, skill_table[gsn_track].beats );
		check_improve(ch, NULL, gsn_track, FALSE, 12);
		return;
	}

	if ( IS_AFFECTED ( victim, AFF_SPIRIT_WALK ) )
	{
		act("$n klêka i zaczyna z uwag± przygl±daæ siê ¶ladom.",ch,NULL,NULL,TO_ROOM);
		act("Klêkasz, przygl±dasz siê ¶ladom, ale nie znajdujesz ¿adnego tropu.",ch,NULL,NULL,TO_CHAR);
		WAIT_STATE( ch, skill_table[gsn_track].beats );
		return;
	}
	else
	{
		act("$n klêka i zaczyna z uwag± przygl±daæ siê ¶ladom.",ch,NULL,NULL,TO_ROOM);
		act("Klêkasz i przygladasz siê ¶ladom, chyba widzisz jaki¶ trop.",ch,NULL,NULL,TO_CHAR);
	}

	WAIT_STATE( ch, skill_table[gsn_track].beats );


	direction = find_path( ch->in_room->vnum, victim->in_room->vnum, ch, -40000, fArea );

	if ( direction == -1 )
	{
		act( "Niestety, nie mo¿esz nic wiêcej odczytaæ ze ¶ladów.", ch, NULL, victim, TO_CHAR );
		return;
	}

	if ( direction < 0 || direction >= MAX_DIR )
	{
		send_to_char( "Hmm... co¶ jest nie tak.\n\r", ch );
		return;
	}

/*
 * Give a random direction if the player misses the die roll.
 */
	if ( number_percent() > skill )
	{
		do
		{
			direction = number_door( );
		}
		while (   !( ch->in_room->exit[direction] ) || !( ch->in_room->exit[direction]->u1.to_room ) );
	}

	check_improve(ch, NULL, gsn_track, TRUE, 9);

/*
 * Display the results of the search.
 */


	sprintf( buf, "Znajdujesz ¶lady $Z prowadz±ce na %s.", direction == 4 ? "górê" : dir_name[direction] );
	act( buf, ch, NULL, victim, TO_CHAR );
	return;
}
Beispiel #15
0
void set_graphics_mode(const struct multiboot_header *mbh,
		       struct multiboot_info *mbi)
{
    com32sys_t rm;
    uint16_t mode, bestmode, *mode_ptr;
    struct vesa_general_info *gi;
    struct vesa_mode_info *mi;
    int pxf, bestpxf;
    int wantx, wanty;
    int err, besterr;
    bool better;
    addr_t viaddr;

    /* Only do this if requested by the OS image */
    if (!(mbh->flags & MULTIBOOT_VIDEO_MODE) || mbh->mode_type != 0)
	return;

    gi = lmalloc(sizeof *gi);
    if (!gi)
	return;

    mi = lmalloc(sizeof *mi);
    if (!mi)
	goto out;

    memset(&rm, 0, sizeof rm);
    memset(gi, 0, sizeof *gi);

    gi->signature = VBE2_MAGIC;	/* Get VBE2 extended data */
    rm.eax.w[0] = 0x4F00;	/* Get SVGA general information */
    rm.edi.w[0] = OFFS(gi);
    rm.es = SEG(gi);
    __intcall(0x10, &rm, &rm);

    if (rm.eax.w[0] != 0x004F)
	goto out;		/* Function call failed */
    if (gi->signature != VESA_MAGIC)
	goto out;		/* No magic */
    if (gi->version < 0x0102)
	goto out;		/* VESA 1.2+ required */

    memcpy(&vesa_info.gi, gi, sizeof *gi);

    /* Search for a suitable mode with a suitable color and memory model... */

    mode_ptr = GET_PTR(gi->video_mode_ptr);
    bestmode = 0;
    bestpxf = 0;
    wantx = mbh->width  ? mbh->width  : 0xffff;
    wanty = mbh->height ? mbh->height : 0xffff;
    besterr = wantx + wanty;

    while ((mode = *mode_ptr++) != 0xFFFF) {
	mode &= 0x1FF;		/* The rest are attributes of sorts */

        memset(&rm, 0, sizeof rm);
	memset(mi, 0, sizeof *mi);
	rm.eax.w[0] = 0x4F01;	/* Get SVGA mode information */
	rm.ecx.w[0] = mode;
	rm.edi.w[0] = OFFS(mi);
	rm.es = SEG(mi);
	__intcall(0x10, &rm, &rm);

	/* Must be a supported mode */
	if (rm.eax.w[0] != 0x004f)
	    continue;

	/* Must be an LFB color graphics mode supported by the hardware.

	   The bits tested are:
	   7 - linear frame buffer
	   4 - graphics mode
	   3 - color mode
	   1 - mode information available (mandatory in VBE 1.2+)
	   0 - mode supported by hardware
	 */
	if ((mi->mode_attr & 0x009b) != 0x009b)
	    continue;

	/* We don't support multibank (interlaced memory) modes */
	/*
	 *  Note: The Bochs VESA BIOS (vbe.c 1.58 2006/08/19) violates the
	 * specification which states that banks == 1 for unbanked modes;
	 * fortunately it does report bank_size == 0 for those.
	 */
	if (mi->banks > 1 && mi->bank_size)
	    continue;

	/* Must either be a packed-pixel mode or a direct color mode
	   (depending on VESA version ); must be a supported pixel format */

	if (mi->bpp == 32 &&
	    (mi->memory_layout == 4 ||
	     (mi->memory_layout == 6 && mi->rpos == 16 && mi->gpos == 8 &&
	      mi->bpos == 0)))
	    pxf = 32;
	else if (mi->bpp == 24 &&
		 (mi->memory_layout == 4 ||
		  (mi->memory_layout == 6 && mi->rpos == 16 && mi->gpos == 8 &&
		   mi->bpos == 0)))
	    pxf = 24;
	else if (mi->bpp == 16 &&
		 (mi->memory_layout == 4 ||
		  (mi->memory_layout == 6 && mi->rpos == 11 && mi->gpos == 5 &&
		   mi->bpos == 0)))
	    pxf = 16;
	else if (mi->bpp == 15 &&
		 (mi->memory_layout == 4 ||
		  (mi->memory_layout == 6 && mi->rpos == 10 && mi->gpos == 5 &&
		   mi->bpos == 0)))
	    pxf = 15;
	else
	    continue;

	better = false;
	err = abs(mi->h_res - wantx) + abs(mi->v_res - wanty);

#define IS_GOOD(mi, bestx, besty) \
	((mi)->h_res >= (bestx) && (mi)->v_res >= (besty))

	if (!bestpxf)
	    better = true;
	else if (!IS_GOOD(&vesa_info.mi, wantx, wanty) &&
		 IS_GOOD(mi, wantx, wanty))
	    /* This matches criteria, which the previous one didn't */
	    better = true;
	else if (IS_GOOD(&vesa_info.mi, wantx, wanty) &&
		 !IS_GOOD(mi, wantx, wanty))
	    /* This doesn't match criteria, and the previous one did */
	    better = false;
	else if (err < besterr)
	    better = true;
	else if (err == besterr && (pxf == (int)mbh->depth || pxf > bestpxf))
	    better = true;

	if (better) {
	    bestmode = mode;
	    bestpxf = pxf;
	    memcpy(&vesa_info.mi, mi, sizeof *mi);
	}
    }

    if (!bestpxf)
	goto out;		/* No mode found */

    mi = &vesa_info.mi;
    mode = bestmode;

    /* Now set video mode */
    memset(&rm, 0, sizeof rm);
    rm.eax.w[0] = 0x4F02;	/* Set SVGA video mode */
    mode |= 0x4000;		/* Request linear framebuffer */
    rm.ebx.w[0] = mode;
    __intcall(0x10, &rm, &rm);
    if (rm.eax.w[0] != 0x004F)
	goto out;		/* Failed to set mode */

    mbi->flags |= MB_INFO_VIDEO_INFO;
    mbi->vbe_mode = mode;
    viaddr = map_data(&vesa_info, sizeof vesa_info, 4, 0);
    mbi->vbe_control_info = viaddr + offsetof(struct vesa_info, gi);
    mbi->vbe_mode_info = viaddr + offsetof(struct vesa_info, mi);

    /* Get the VBE 2.x PM entry point if supported */
    rm.eax.w[0] = 0x4F0A;
    rm.ebx.w[0] = 0;
    __intcall(0x10, &rm, &rm);
    if (rm.eax.w[0] == 0x004F) {
	mbi->vbe_interface_seg = rm.es;
	mbi->vbe_interface_off = rm.edi.w[0];
	mbi->vbe_interface_len = rm.ecx.w[0];
    }

    /* In theory this should be:
     *
     * UsingVga = (mi->mode_attr & 4) ? 0x0007 : 0x000f;
     *
     * However, that would assume all systems that claim to handle text
     * output in VESA modes actually do that...
     */
    graphics_using_vga(0x0F, vesa_info.mi.h_res, vesa_info.mi.v_res);

out:
    lfree(mi);
    lfree(gi);
}
Beispiel #16
0
void mobile_activity(void)
{
  register struct char_data *ch, *next_ch, *vict;
  struct char_data *min_vict = NULL;
  struct obj_data *obj, *next_obj, *best_obj, *cont;
  int door, found, max, where;
  int casual, max_abil=0, curr_abil, gold;
  memory_rec *names;
  room_rnum target_room;

  extern int no_specials;
  ACMD(do_get);

  for (ch = character_list; ch; ch = next_ch) {
    next_ch = ch->next;
    
    if (!IS_MOB(ch))
      continue;
    
    //lance ripristina il master!
 	  if (IS_NPC(ch) && MOB_FLAGGED(ch, MOB_SAVE))
 		  chkmaster(ch);

    // Examine call for special procedure
    if (MOB_FLAGGED(ch, MOB_SPEC) && !no_specials) {
      if (mob_index[GET_MOB_RNUM(ch)].func == NULL) {
	      sprintf(buf, "SYSERR: %s (#%d): Attempting to call non-existing mob func", GET_NAME(ch), GET_MOB_VNUM(ch));
	      log(buf);
	      REMOVE_BIT(MOB_FLAGS(ch), MOB_SPEC);
      }
      else {
	      //(mob_index[GET_MOB_RNUM(ch)].func) (ch, ch, 0, "");
	      if ((mob_index[GET_MOB_RNUM(ch)].func) (ch, ch, 0, ""))
	        continue;	     /*  go to next char*/
      }
    }

// If the mob has no specproc, do the default actions
    if (FIGHTING(ch) || !AWAKE(ch))
      continue;

// Nuovo Scavenger (picking up objects) by Rusty 
    if (MOB_FLAGGED(ch, MOB_SCAVENGER))
	  if (world[ch->in_room].contents && (number(0, 10) > 5)) {
		  max = -1000;
		  best_obj = NULL;
		  for (obj = world[ch->in_room].contents; obj; obj = obj->next_content)
	  	if (CAN_GET_OBJ(ch, obj) && objlevel(obj) > max) {
			  best_obj = obj;
			  max = objlevel(obj);
			}
    
		  if (best_obj != NULL) {
			  obj_from_room(best_obj);
			  obj_to_char(best_obj, ch);
			  act("$n prende $p.", FALSE, ch, best_obj, 0, TO_ROOM);

// Orione, tolta la procedura che fa indossare l'eq raccolto ai mob scavenger
// Scavenger Plus:Mob wear the best object
/*
			  where=find_eq_pos(ch, best_obj, 0);
			  if (CAN_WEAR(best_obj, ITEM_WEAR_WIELD))
			    where=WEAR_WIELD;

			  if ( (where>0) && GET_EQ(ch,where)) {
				  // se ce l'ha gia!
				  if ((objlevel((ch)->equipment[where]))< objlevel(best_obj)) {
				    obj_to_char((obj=unequip_char(ch, where)), ch);
					  act("$n smette di usare $p.", FALSE, ch, obj, 0, TO_ROOM);
				  } 
				  else {
					  where = NUM_WEARS; // cioe' oggetto non indossabile
				  }

				  if (GET_LEVEL(ch)>=objlevel(best_obj)) {
					  if (where>=0 && where <NUM_WEARS) {
						  obj_from_char(best_obj);
						  equip_char(ch,best_obj,where);
						  wear_message(ch,best_obj,where);
					  }
				  }
			  }
*/
		  }
	  } //End ifif

// Mob BodyGuard !?       
    if (MOB_FLAGGED(ch, MOB_BGUARD) && (ch->master)) {
      if (   (FIGHTING(ch->master) && (npc_rescue(ch, ch->master) == FALSE))
	        || (ch->master && WHOKILLED(ch->master)) ) {
        act("$N Si schiera Prontamente al tuo fianco!", FALSE,ch->master, 0, ch, TO_CHAR);
	      act("$n Si schiera prontamente al fianco di $N", FALSE, ch, 0, ch->master, TO_ROOM);
	      if (WHOKILLED(ch->master))	
	        hit(ch, WHOKILLED(ch->master), TYPE_UNDEFINED);/*in ogni caso assiste*/
	      else
	        hit(ch, FIGHTING(ch->master), TYPE_UNDEFINED);/*in ogni caso assiste*/
	    }
     
      if (FIGHTING(ch)) {
	      npc_rescue(ch, ch->master);
		    if (WHOKILLED(ch->master))
		      hit(ch, WHOKILLED(ch->master), TYPE_UNDEFINED);  /*in ogni caso assiste*/
		    continue;
		  }	  
    }

//MOB_THIEF
    if (   MOB_FLAGGED(ch, MOB_CRIMINAL)  && (GET_POS(ch) == POS_RESTING)
        && IS_AFFECTED(ch, AFF_HIDE) && GET_HIT(ch) >= 2*GET_MAX_HIT(ch)/3) {
      appear(ch);
      GET_POS(ch)=POS_STANDING;
    }
    if (   MOB_FLAGGED(ch, MOB_CRIMINAL) 
        && ( GET_POS(ch) == POS_STANDING) 
        && ( (casual = number(0, 11)) < 6 ) ) {   // 50%  Rubare

      // cerca le vittime  1) Devono aver almeno 1 coin  
      //                   2) Deve aver una buona prob di farcela
      for (found=FALSE, min_vict = NULL, vict = world[ch->in_room].people; vict; vict = vict->next_in_room) {
	      if (CAN_SEE(ch, vict) && (vict != ch)) {
	        if ((min_vict == NULL) || (max_abil < 100)) {
	        //se ha il 100% tanto vale fermarsi
	        //Calcolo dell abilita:presa esattamente da D n'D

	          curr_abil = MIN(90, (10*(GET_LEVEL(ch)) - 5*GET_LEVEL(vict)));
	          curr_abil -=  dex_app[GET_DEX(vict)].reaction;
	          if (GET_POS(vict) < POS_STANDING)
	            curr_abil += 200;
	    // Se la vittima e' addormentata-stunned - incap o morta ovviamente
	    //  deruberai questa sicuramente

	          if (   (curr_abil >= 40) 
	              && (GET_GOLD(vict) != 0) 
	              && (curr_abil > max_abil) ) {
	            min_vict = vict;
	            max_abil = curr_abil;
	            found=TRUE;
	          }
	        }
	      }
      }
      // Se ha trovato la vittima
      if (found == TRUE) {
	      if ((casual = number(1, 100)) > max_abil) {
	        if (!IS_NPC(min_vict))
	          act(" $n cerca di prendere dei soldi dal tuo Borsello", FALSE, ch, 0, min_vict, TO_CHAR);
	        else {
	          act("Oops...", FALSE, ch, 0, min_vict, TO_ROOM);
	          act("$n cerca di rubare soldi a $N..Ma viene Scoperto! ", FALSE, ch, 0, min_vict, TO_ROOM);
	        }
	        
	        //Beccato ... fa 2 tentativi di fuga
	        if (((door = number(1, 7)) < NUM_OF_DIRS) && CAN_GO(ch, door) &&
	             !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	          perform_move(ch,door,1,CAN_SHOW_ROOM);
	        if ((door -= 1) < NUM_OF_DIRS && CAN_GO(ch, door) &&
	             !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	          perform_move(ch,door,1,CAN_SHOW_ROOM);
	        if ((door += 2) < NUM_OF_DIRS && CAN_GO(ch, door) &&
	             !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	          perform_move(ch,door,1,CAN_SHOW_ROOM);
	        
	        if (IS_NPC(min_vict)) {
	          act("$n Urla: $N e' uno sporco LADRO!!!!", FALSE, min_vict, 0, ch, TO_ROOM);
	          hit(min_vict, ch, TYPE_UNDEFINED);
	        }
	      }
	      // Il Bastardo ce la fa!
	      else {
	        if (GET_POS(min_vict) < 5) {
	          GET_GOLD(ch) += GET_GOLD(min_vict);
	          GET_GOLD(min_vict) = 0;    //la ripulisce completamente
	        }
	        else {
	          gold = number((GET_GOLD(min_vict) / 10), (GET_GOLD(min_vict) / 2));
	          //gold = MIN(5000, gold);
	          if (gold > 0) {
	            GET_GOLD(ch) += gold;
	            GET_GOLD(min_vict) -= gold;
	            if (GET_GOLD(min_vict) < 0)
	              GET_GOLD(min_vict) = 0;
	          }
	        }
	        // Dopo il furto si allontana
	        if (((door = number(1, 6)) < NUM_OF_DIRS) && CAN_GO(ch, door) &&
	           !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	          perform_move(ch,door,1,CAN_SHOW_ROOM);
	        if ((door -=1) < NUM_OF_DIRS && CAN_GO(ch, door) &&
	           !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	          perform_move(ch,door,1,CAN_SHOW_ROOM);
	        if ((door +=2) < NUM_OF_DIRS && CAN_GO(ch, door) &&
	           !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	          perform_move(ch,door,1,CAN_SHOW_ROOM);
	      }
      }
      else { // Nessuna vittima appetibile:se ne va!
	      
	      if (((door = number(0, 6)) < NUM_OF_DIRS) && CAN_GO(ch, door) &&
	          !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	        perform_move(ch, door, 1, CAN_SHOW_ROOM);
      }
    }

// Mob Sciacalli indossano EQ    
    if (MOB_FLAGGED(ch, MOB_NECRO) && !FIGHTING(ch) && AWAKE(ch))
    if (world[ch->in_room].contents) {
	    max = -1000;
	    best_obj=NULL;
	    for (cont = world[ch->in_room].contents;cont;cont = cont->next_content)
	    if (GET_OBJ_TYPE(cont) == ITEM_CONTAINER) {
	      for (obj = cont->contains; obj; obj = next_obj) {
		      next_obj = obj->next_content;
		      if (obj != NULL) {
		        if (CAN_SEE_OBJ(ch, obj) && ( (max = objlevel(obj)) <= GET_LEVEL(ch)) ) {
		          perform_get_from_container(ch, obj, cont, FIND_OBJ_INV);
		          if (obj != NULL) {
		            where = find_eq_pos(ch, obj, 0);
		            if (CAN_WEAR(obj, ITEM_WEAR_HOLD))
			            where = WEAR_HOLD;
		            if (GET_OBJ_TYPE(obj)==ITEM_LIGHT)
			            where = WEAR_LIGHT;
		            if (CAN_WEAR(obj, ITEM_WEAR_WIELD))
			            where = WEAR_WIELD;
		            if (where < 0) {
			            sprintf(buf,"SYSERR:pos < 0 ,in cont %s obj %d %s In room %d", 
			                        cont->name, 
			                        GET_OBJ_RNUM(obj), 
			                        obj->name, 
			                        IN_ROOM(ch));
			            log(buf);
			            where = NUM_WEARS;
		            }
		            
		            if (GET_EQ(ch, where) && where < NUM_WEARS) {
			            if ((objlevel((ch)->equipment[where])) < objlevel(obj)) {
			              obj_to_char((best_obj = unequip_char(ch, where)), ch);
			              act("$n smette di usare $p.",FALSE, ch, best_obj, 0, TO_ROOM);
			            }
			            else
			              where = NUM_WEARS;
		            }
		            if (where >= 0 && where < NUM_WEARS) {
			            wear_message(ch, obj, where);
			            obj_from_char(obj);
			            equip_char(ch, obj, where);
		            }
		          }
		        }
		      }
	      }
	    } //End forif
	  } //End ifif

// Mob Movement
    if (HUNTING(ch)) 
      hunt_victim(ch);
    else {
	    if (MOB_FLAGGED(ch , MOB_SEARCHER)) {}
 	    else {
        if (ch->in_room != NOWHERE) {
          if (!IS_IN_WILD(ch)) {
            if (   !MOB_FLAGGED(ch, MOB_SENTINEL) 
                && (GET_POS(ch) == POS_STANDING) 
                && (   (door = number(0, 8)) < NUM_OF_DIRS) 
                    && CAN_GO(ch, door) 
                    && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) 
                    && (   !MOB_FLAGGED(ch, MOB_STAY_ZONE) 
                        || (world[EXIT(ch, door)->to_room].zone == world[ch->in_room].zone))) {
              perform_move(ch, door, 1, CAN_SHOW_ROOM);
            }
          }
          else {  // E' in wilderness
            if (MOB_FLAGGED(ch, MOB_WILDHUNT)) 
              door = wild_mobhunter(ch);
            else 
              door = number(0, 8);
            
            if (door >= 0 && door < NUM_OF_DIRS) 
              target_room = wild_target_room(ch, door);
            else 
              target_room = -1;
            
            if (   !MOB_FLAGGED(ch, MOB_SENTINEL) 
                && (GET_POS(ch) == POS_STANDING) 
                && (target_room != -1) 
                && (   !MOB_FLAGGED(ch, MOB_STAY_ZONE) 
                    || (world[target_room].wild_rnum == world[ch->in_room].wild_rnum))) {
              perform_move(ch, door, 1, CAN_SHOW_ROOM);
            }
          }
        }	
      }
    }

// Aggressive Mobs
    if (MOB_FLAGGED(ch, MOB_AGGRESSIVE | MOB_AGGR_TO_ALIGN)) {
      found = FALSE;
      for (vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room) {
	      if (IS_NPC(vict) || !CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE))
	        continue;
	      if (number(0, 3) < 2)
	        continue; // Simple simulate Random a Joke from Phantom ;P
	      if (GET_ABIL (vict, ABIL_TRATTATIVA) >= EXPERT_LIV)
	        continue; // I pg con trattativa ad esperto fanno pace con gli aggressivi (by Spini)
	      if (controllo_volo(ch, vict))
		continue;
	      if (affected_by_spell (vict, SPELLSKILL, DISEASE_PESTE))
		continue;

	      if (MOB_FLAGGED(ch, MOB_AGGR_NO_PROP) && (MASTER_ID(ch)==GET_IDNUM(vict)))
	        continue;
	      if (MOB_FLAGGED(ch, MOB_AGGR_NO_CLAN) && (CLAN_ID(ch)==GET_CLAN(vict)))
	        continue;
	      if (MOB_FLAGGED(ch, MOB_AGGR_NO_AL_CLAN) && (GET_CLAN_DIPLO(GET_CLAN(ch),GET_CLAN(vict)) == ALLIANCE))
	        continue;
	      if (MOB_FLAGGED(ch, MOB_AGGR_NO_EN_CLAN) && (GET_CLAN_DIPLO(GET_CLAN(ch),GET_CLAN(vict)) == WAR))
	        continue;
	      if (MOB_FLAGGED(ch, MOB_AGGR_NO_PC_CLAN) && (GET_CLAN_DIPLO(GET_CLAN(ch),GET_CLAN(vict)) == PEACE))
	        continue;
	      if (MOB_FLAGGED(ch, MOB_AGGR_VAS_CLAN) && (GET_CLAN_DIPLO(GET_CLAN(ch),GET_CLAN(vict)) == VASSALLO))
	  	    continue;

        if (   !MOB_FLAGGED(ch, MOB_AGGR_TO_ALIGN) 
            || (MOB_FLAGGED(ch, MOB_AGGR_EVIL) && IS_EVIL(vict)) 
            || (MOB_FLAGGED(ch, MOB_AGGR_NEUTRAL) && IS_NEUTRAL(vict)) 
            || (MOB_FLAGGED(ch, MOB_AGGR_GOOD) && IS_GOOD(vict)) ) {
	        if (GET_MOB_SPEC(ch)== thief)
	          npc_backstab(ch,vict);
	        else
	          hit(ch, vict, TYPE_UNDEFINED);
	        found = TRUE;
	      }
      }
    }

// Mob Memory
    if (MOB_FLAGGED(ch, MOB_MEMORY) && MEMORY(ch)) {
      found = FALSE;
      for (vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room) {
        if (!CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE))
          continue;
        for (names = MEMORY(ch); names && !found; names = names->next)
        if (names->id == GET_IDNUM(vict)) {
          found = TRUE;
          act("$n esclama, 'Hey!! Tu sei il tipo che mi ha attaccato!!!'", FALSE, ch, 0, 0, TO_ROOM);
          hit(ch, vict, TYPE_UNDEFINED);
        } //End forif
      }
    }

// Helper Mobs Paladino del bene
    if (   MOB_FLAGGED(ch, MOB_HELPER)
        && !MOB_FLAGGED(ch, MOB_CRIMINALHELPER) ) {
      found = FALSE;
      for (vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room)
      if (   ch != vict 
          && IS_NPC(vict) 
          && FIGHTING(vict) 
          && !IS_NPC(FIGHTING(vict)) 
          && ch != FIGHTING(vict) ) {			
        if (   MOB_FLAGGED(vict, MOB_CRIMINAL)
            || (   (ch->master)
                && (FIGHTING(vict) == ch->master) ) ) {
	        hit(ch, vict, TYPE_UNDEFINED);
	        found = TRUE;
	      } 		
	      else { 
	        act("$n arriva in aiuto di $N!", FALSE, ch, 0, vict, TO_ROOM);
	        hit(ch, FIGHTING(vict), TYPE_UNDEFINED);
	        found = TRUE;
	      }
	    } //End forif
    }
	
// Helper Mobs Servo del male
    if (   MOB_FLAGGED(ch, MOB_CRIMINALHELPER)
        && !MOB_FLAGGED(ch, MOB_HELPER) ) {
      found = FALSE;
      for (vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room)
      if (   ch != vict 
          && IS_NPC(vict) 
          && FIGHTING(vict) 
          && !IS_NPC(FIGHTING(vict)) 
          && ch != FIGHTING(vict) ) {			
        if (   MOB_FLAGGED(vict, MOB_CRIMINAL)
            || (   (ch->master) 
                && (vict == ch->master) ) ) {
          act("$n arriva in aiuto di $N!", FALSE, ch, 0, vict, TO_ROOM);
          hit(ch, FIGHTING(vict), TYPE_UNDEFINED);
          found = TRUE;
        }
      } //End forif
    }
	
// Add new mobile actions here

  }				// end for()
}
Beispiel #17
0
void mobile_activity(void)
{
  struct char_data *ch, *next_ch, *vict;
  struct obj_data *obj, *best_obj;
  int door, found, max;
  memory_rec *names;

  for (ch = character_list; ch; ch = next_ch) {
    next_ch = ch->next;

    if (!IS_MOB(ch))
      continue;

    /* Examine call for special procedure */
    if (MOB_FLAGGED(ch, MOB_SPEC) && !no_specials) {
      if (mob_index[GET_MOB_RNUM(ch)].func == NULL) {
	log("SYSERR: %s (#%d): Attempting to call non-existing mob function.",
		GET_NAME(ch), GET_MOB_VNUM(ch));
	REMOVE_BIT_AR(MOB_FLAGS(ch), MOB_SPEC);
      } else {
        char actbuf[MAX_INPUT_LENGTH] = "";
	if ((mob_index[GET_MOB_RNUM(ch)].func) (ch, ch, 0, actbuf))
	  continue;		/* go to next char */
      }
    }

    /* If the mob has no specproc, do the default actions */
    if (FIGHTING(ch) || !AWAKE(ch))
      continue;

    /* hunt a victim, if applicable */
    hunt_victim(ch);

    /* Scavenger (picking up objects) */
    if (MOB_FLAGGED(ch, MOB_SCAVENGER))
      if (world[IN_ROOM(ch)].contents && !rand_number(0, 10)) {
	max = 1;
	best_obj = NULL;
	for (obj = world[IN_ROOM(ch)].contents; obj; obj = obj->next_content)
	  if (CAN_GET_OBJ(ch, obj) && GET_OBJ_COST(obj) > max) {
	    best_obj = obj;
	    max = GET_OBJ_COST(obj);
	  }
	if (best_obj != NULL) {
	  obj_from_room(best_obj);
	  obj_to_char(best_obj, ch);
	  act("$n gets $p.", FALSE, ch, best_obj, 0, TO_ROOM);
	}
      }

    /* Mob Movement */
    if (!MOB_FLAGGED(ch, MOB_SENTINEL) && (GET_POS(ch) == POS_STANDING) &&
       ((door = rand_number(0, 18)) < DIR_COUNT) && CAN_GO(ch, door) &&
       !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB) &&
       !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_DEATH) &&
       (!MOB_FLAGGED(ch, MOB_STAY_ZONE) ||
           (world[EXIT(ch, door)->to_room].zone == world[IN_ROOM(ch)].zone))) 
    {
      /* If the mob is charmed, do not move the mob. */
      if (ch->master == NULL)
        perform_move(ch, door, 1);
    }

    /* Aggressive Mobs */
     if (!MOB_FLAGGED(ch, MOB_HELPER) && (!AFF_FLAGGED(ch, AFF_BLIND) || !AFF_FLAGGED(ch, AFF_CHARM))) {
      found = FALSE;
      for (vict = world[IN_ROOM(ch)].people; vict && !found; vict = vict->next_in_room) {
	if (IS_NPC(vict) || !CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE))
	  continue;

	if (MOB_FLAGGED(ch, MOB_WIMPY) && AWAKE(vict))
	  continue;

	if (MOB_FLAGGED(ch, MOB_AGGRESSIVE  ) ||
	   (MOB_FLAGGED(ch, MOB_AGGR_EVIL   ) && IS_EVIL(vict)) ||
	   (MOB_FLAGGED(ch, MOB_AGGR_NEUTRAL) && IS_NEUTRAL(vict)) ||
	   (MOB_FLAGGED(ch, MOB_AGGR_GOOD   ) && IS_GOOD(vict))) {

          /* Can a master successfully control the charmed monster? */
          if (aggressive_mob_on_a_leash(ch, ch->master, vict))
            continue;

	  hit(ch, vict, TYPE_UNDEFINED);
	  found = TRUE;
	}
      }
    }

    /* Mob Memory */
    if (MOB_FLAGGED(ch, MOB_MEMORY) && MEMORY(ch)) {
      found = FALSE;
      for (vict = world[IN_ROOM(ch)].people; vict && !found; vict = vict->next_in_room) {
	if (IS_NPC(vict) || !CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE))
	  continue;

	for (names = MEMORY(ch); names && !found; names = names->next) {
	  if (names->id != GET_IDNUM(vict))
            continue;

          /* Can a master successfully control the charmed monster? */
          if (aggressive_mob_on_a_leash(ch, ch->master, vict))
            continue;

          found = TRUE;
          act("'Hey!  You're the fiend that attacked me!!!', exclaims $n.", FALSE, ch, 0, 0, TO_ROOM);
          hit(ch, vict, TYPE_UNDEFINED);
        }
      }
    }

    /* Charmed Mob Rebellion: In order to rebel, there need to be more charmed 
     * monsters than the person can feasibly control at a time.  Then the
     * mobiles have a chance based on the charisma of their leader.
     * 1-4 = 0, 5-7 = 1, 8-10 = 2, 11-13 = 3, 14-16 = 4, 17-19 = 5, etc. */
    if (AFF_FLAGGED(ch, AFF_CHARM) && ch->master && num_followers_charmed(ch->master) > (GET_CHA(ch->master) - 2) / 3) {
      if (!aggressive_mob_on_a_leash(ch, ch->master, ch->master)) {
        if (CAN_SEE(ch, ch->master) && !PRF_FLAGGED(ch->master, PRF_NOHASSLE))
          hit(ch, ch->master, TYPE_UNDEFINED);
        stop_follower(ch);
      }
    }

    /* Helper Mobs */
    if (MOB_FLAGGED(ch, MOB_HELPER) && (!AFF_FLAGGED(ch, AFF_BLIND) || !AFF_FLAGGED(ch, AFF_CHARM))) 
    {
      found = FALSE;
      for (vict = world[IN_ROOM(ch)].people; vict && !found; vict = vict->next_in_room) 
      {
	      if (ch == vict || !IS_NPC(vict) || !FIGHTING(vict))
          continue; 
	      if (IS_NPC(FIGHTING(vict)) || ch == FIGHTING(vict))
          continue;

	      act("$n jumps to the aid of $N!", FALSE, ch, 0, vict, TO_ROOM);
	      hit(ch, FIGHTING(vict), TYPE_UNDEFINED);
	      found = TRUE;
      }
    }

    /* Add new mobile actions here */

  }				/* end for() */
}
Beispiel #18
0
void do_omni( CHAR_DATA *ch, char *argument )
{
    char buf[MAX_STRING_LENGTH];
    char buf2[MAX_STRING_LENGTH];
    BUFFER *output;
    DESCRIPTOR_DATA *d;
    int immmatch;
    int mortmatch;
    int hptemp;  
 /*
 * Initalize Variables.
 */

    immmatch = 0;
       mortmatch = 0;
    buf[0] = '\0';
    output = new_buf();

 /*          
 * Count and output */
      sprintf(buf,"\n\r{B---{WI{wm{Wm{wo{Wr{wt{Wa{wl{Ws{B----{x\n\r");
        add_buf(output,buf);
        sprintf( buf, "{WN{wa{Wm{we           {WL{we{Wv{we{Wl   {WW{wi{Wz      {WI{wn{Wc{wo{Wg    {WG{wh{Wo{ws{Wt    {W[{wV{Wn{wu{Wm{W]{x\n\r");      
        add_buf(output,buf);
    for ( d = descriptor_list; d != NULL; d = d->next )
    {
        CHAR_DATA *wch;

        if ( d->connected != CON_PLAYING || !can_see( ch, d->character ) )    
            continue;

        wch   = ( d->original != NULL ) ? d->original : d->character;

        if (!can_see(ch,wch)  || wch->level < 102)
            continue;

        immmatch++;

        sprintf( buf, "{R%-14s %-3d     %-3d      %-3d      %-3d      [%-3d]{x\n\r",
                        wch->name,
                        wch->level,
                        wch->invis_level,
                        wch->incog_level,
			   wch->ghost_level,
                        wch->in_room->vnum);
                        add_buf(output,buf);
    }


 /*
 * Count and output the Morts.
 */
        sprintf( buf, " \n\r {B----{YM{yo{Yr{yt{Ya{yl{Ys{B----{x\n\r");
        add_buf(output,buf);
        sprintf( buf, "{WN{wa{Wm{we           {WG{wo{Wd      {WR{wa{Wc{we{W/{wC{Wl{wa{Ws{ws  {WP{wo{Ws{wi{Wt{wi{Wo{wn      {WL{we{Wv   {w%%{Wh{wp{Ws    {w[{WV{wn{Wu{wm{W]{x\n\r");   

        add_buf(output,buf);
        hptemp = 0;

   for ( d = descriptor_list; d != NULL; d = d->next )    
    {
        CHAR_DATA *wch;
        char const *class;

        if ( d->connected != CON_PLAYING || !can_see( ch, d->character ) )
            continue;

        wch   = ( d->original != NULL ) ? d->original : d->character;

        if (!can_see(ch,wch) || wch->level > ch->level || wch->level > 101)   
            continue;

        mortmatch++;
        if ((wch->max_hit != wch->hit) && (wch->hit > 0))
                hptemp = (wch->hit*100)/wch->max_hit;
        else if (wch->max_hit == wch->hit)
                hptemp = 100;
        else if (wch->hit < 0)
                hptemp = 0;    

        class = class_table[wch->class].who_name;

        sprintf( buf, "{G%-14s %-7s  %6.6s/%3.3s  %-10s    %-3d   %-3d%%    [%-3d]{x\n\r",
                wch->name,
                IS_GOOD(wch)? "Good" : IS_EVIL(wch) ? "Evil" : "Neutral",
                wch->race < MAX_PC_RACE ? pc_race_table[wch->race].who_name : " ",
                class,
                capitalize( position_table[wch->position].name) ,
                wch->level,
                hptemp,
                wch->in_room->vnum);
        add_buf(output,buf);
    }

/*
 * Tally the counts and send the whole list out.
 */
   sprintf( buf2, "\n\r{CIMMs found: {w%d{x\n\r", immmatch );
    add_buf(output,buf2);
    sprintf( buf2, "{CMorts found: {y%d{x\n\r", mortmatch );    
    add_buf(output,buf2);
    page_to_char( buf_string(output), ch );
    free_buf(output);
    return;
}                          
Beispiel #19
0
/* ---------------------------------------------------------------------
 * CMD_EVAL
 * This monster evaluates an if/or/and statement
 * There are five kinds of statement:
 * 1) keyword and value (no $-code)	    if random 30
 * 2) keyword, comparison and value	    if people > 2
 * 3) keyword and actor		    	    if isnpc $n
 * 4) keyword, actor and value		    if carries $n sword
 * 5) keyword, actor, comparison and value  if level $n >= 10
 *
 *----------------------------------------------------------------------
 */
int cmd_eval( sh_int vnum, char *line, int check,
	CHAR_DATA *mob, CHAR_DATA *ch, 
	const void *arg1, const void *arg2, CHAR_DATA *rch )
{
    CHAR_DATA *lval_char = mob;
    CHAR_DATA *vch = (CHAR_DATA *) arg2;
    OBJ_DATA *obj1 = (OBJ_DATA  *) arg1;
    OBJ_DATA *obj2 = (OBJ_DATA  *) arg2;
    OBJ_DATA  *lval_obj = NULL;

    char *original, buf[MAX_INPUT_LENGTH], code;
    int lval = 0, oper = 0, rval = -1;

    original = line;
    line = one_argument( line, buf );
    if ( buf[0] == '\0' || mob == NULL )
	return FALSE;

    /*
     * If this mobile has no target, let's assume our victim is the one
     */
    if ( mob->mprog_target == NULL )
	mob->mprog_target = ch;

    switch ( check )
    {
	/*
	 * Case 1: keyword and value
	 */
	case CHK_RAND:
	    return( atoi( buf ) < number_percent() );
	case CHK_MOBHERE:
	    if ( is_number( buf ) )
		return( get_mob_vnum_room( mob, atoi(buf) ) );
	    else
		return( (bool) (get_char_room( mob, buf) != NULL) );
	case CHK_OBJHERE:
	    if ( is_number( buf ) )
		return( get_obj_vnum_room( mob, atoi(buf) ) );
	    else
		return( (bool) (get_obj_here( mob, buf) != NULL) );
        case CHK_MOBEXISTS:
	    return( (bool) (get_char_world( mob, buf) != NULL) );
	case CHK_OBJEXISTS:
	    return( (bool) (get_obj_world( mob, buf) != NULL) );
	/*
	 * Case 2 begins here: We sneakily use rval to indicate need
	 * 		       for numeric eval...
	 */
	case CHK_PEOPLE:
	    rval = count_people_room( mob, 0 ); break;
	case CHK_PLAYERS:
	    rval = count_people_room( mob, 1 ); break;
	case CHK_MOBS:
	    rval = count_people_room( mob, 2 ); break;
	case CHK_CLONES:
	    rval = count_people_room( mob, 3 ); break;
	case CHK_ORDER:
	    rval = get_order( mob ); break;
	case CHK_HOUR:
	    rval = time_info.hour; break;
	default:;
    }

    /*
     * Case 2 continued: evaluate expression
     */
    if ( rval >= 0 )
    {
	if ( (oper = keyword_lookup( fn_evals, buf )) < 0 )
	{
	    sprintf( buf, "Cmd_eval: prog %d syntax error(2) '%s'",
		vnum, original );
	    bug( buf, 0 );
	    return FALSE;
	}
	one_argument( line, buf );
	lval = rval;
	rval = atoi( buf );
	return( num_eval( lval, oper, rval ) );
    }

    /*
     * Case 3,4,5: Grab actors from $* codes
     */
    if ( buf[0] != '$' || buf[1] == '\0' )
    {
	sprintf( buf, "Cmd_eval: prog %d syntax error(3) '%s'",
		vnum, original );
	bug( buf, 0 );
        return FALSE;
    }
    else
        code = buf[1];
    switch( code )
    {
    	case 'i':
            lval_char = mob; break;
        case 'n':
            lval_char = ch; break;
        case 't':
            lval_char = vch; break;
        case 'r':
            lval_char = rch == NULL ? get_random_char( mob ) : rch ; break;
        case 'o':
            lval_obj = obj1; break;
        case 'p':
            lval_obj = obj2; break;
	case 'q':
	    lval_char = mob->mprog_target; break;
	default:
	    sprintf( buf, "Cmd_eval: prog %d syntax error(4) '%s'",
		vnum, original );
	    bug( buf, 0 );
	    return FALSE;
    }
    /*
     * From now on, we need an actor, so if none was found, bail out
     */
    if ( lval_char == NULL && lval_obj == NULL )
    	return FALSE;

    /*
     * Case 3: Keyword, comparison and value
     */
    switch( check )
    {
	case CHK_ISPC:
            return( lval_char != NULL && !IS_NPC( lval_char ) );
        case CHK_ISNPC:
            return( lval_char != NULL && IS_NPC( lval_char ) );
        case CHK_ISGOOD:
            return( lval_char != NULL && IS_GOOD( lval_char ) );
        case CHK_ISEVIL:
            return( lval_char != NULL && IS_EVIL( lval_char ) );
        case CHK_ISNEUTRAL:
            return( lval_char != NULL && IS_NEUTRAL( lval_char ) );
	case CHK_ISIMMORT:
            return( lval_char != NULL && IS_IMMORTAL( lval_char ) );
        case CHK_ISCHARM: /* A relic from MERC 2.2 MOBprograms */
            return( lval_char != NULL && IS_AFFECTED( lval_char, AFF_CHARM ) );
        case CHK_ISFOLLOW:
            return( lval_char != NULL && lval_char->master != NULL 
		 && lval_char->master->in_room == lval_char->in_room );
	case CHK_ISACTIVE:
	    return( lval_char != NULL && lval_char->position > POS_SLEEPING );
	case CHK_ISDELAY:
	    return( lval_char != NULL && lval_char->mprog_delay > 0 );
	case CHK_ISVISIBLE:
            switch( code )
            {
                default :
                case 'i':
                case 'n':
                case 't':
                case 'r':
		case 'q':
	    	    return( lval_char != NULL && can_see( mob, lval_char ) );
		case 'o':
		case 'p':
	    	    return( lval_obj != NULL && can_see_obj( mob, lval_obj ) );
	    }
	case CHK_HASTARGET:
	    return( lval_char != NULL && lval_char->mprog_target != NULL
		&&  lval_char->in_room == lval_char->mprog_target->in_room );
	case CHK_ISTARGET:
	    return( lval_char != NULL && mob->mprog_target == lval_char );
	default:;
     }

     /* 
      * Case 4: Keyword, actor and value
      */
     line = one_argument( line, buf );
     switch( check )
     {
	case CHK_AFFECTED:
	    return( lval_char != NULL 
		&&  IS_SET(lval_char->affected_by, flag_lookup(buf, affect_flags)) );
	case CHK_ACT:
	    return( lval_char != NULL 
		&&  IS_SET(lval_char->act, flag_lookup(buf, act_flags)) );
	case CHK_IMM:
	    return( lval_char != NULL 
		&&  IS_SET(lval_char->imm_flags, flag_lookup(buf, imm_flags)) );
	case CHK_OFF:
	    return( lval_char != NULL 
		&&  IS_SET(lval_char->off_flags, flag_lookup(buf, off_flags)) );
	case CHK_CARRIES:
	    if ( is_number( buf ) )
		return( lval_char != NULL && has_item( lval_char, atoi(buf), -1, FALSE ) );
	    else
		return( lval_char != NULL && (get_obj_carry( lval_char, buf ) != NULL) );
	case CHK_WEARS:
	    if ( is_number( buf ) )
		return( lval_char != NULL && has_item( lval_char, atoi(buf), -1, TRUE ) );
	    else
		return( lval_char != NULL && (get_obj_wear( lval_char, buf ) != NULL) );
	case CHK_HAS:
	    return( lval_char != NULL && has_item( lval_char, -1, item_lookup(buf), FALSE ) );
	case CHK_USES:
	    return( lval_char != NULL && has_item( lval_char, -1, item_lookup(buf), TRUE ) );
	case CHK_NAME:
            switch( code )
            {
                default :
                case 'i':
                case 'n':
                case 't':
                case 'r':
		case 'q':
		    return( lval_char != NULL && is_name( buf, lval_char->name ) );
		case 'o':
		case 'p':
		    return( lval_obj != NULL && is_name( buf, lval_obj->name ) );
	    }
	case CHK_POS:
	    return( lval_char != NULL && lval_char->position == position_lookup( buf ) );
	case CHK_CLAN:
	    return( lval_char != NULL && lval_char->clan == clan_lookup( buf ) );
	case CHK_RACE:
	    return( lval_char != NULL && lval_char->race == race_lookup( buf ) );
	case CHK_OBJTYPE:
	    return( lval_obj != NULL && lval_obj->item_type == item_lookup( buf ) );
	default:;
    }

    /*
     * Case 5: Keyword, actor, comparison and value
     */
    if ( (oper = keyword_lookup( fn_evals, buf )) < 0 )
    {
	sprintf( buf, "Cmd_eval: prog %d syntax error(5): '%s'",
		vnum, original );
	bug( buf, 0 );
	return FALSE;
    }
    one_argument( line, buf );
    rval = atoi( buf );

    switch( check )
    {
	case CHK_VNUM:
	    switch( code )
            {
                default :
                case 'i':
                case 'n':
                case 't':
                case 'r':
		case 'q':
                    if( lval_char != NULL && IS_NPC( lval_char ) )
                        lval = lval_char->pIndexData->vnum;
                    break;
                case 'o':
                case 'p':
                     if ( lval_obj != NULL )
                        lval = lval_obj->pIndexData->vnum;
            }
            break;
	case CHK_HPCNT:
	    if ( lval_char != NULL ) lval = (lval_char->hit * 100)/(UMAX(1,lval_char->max_hit)); break;
	case CHK_ROOM:
	    if ( lval_char != NULL && lval_char->in_room != NULL )
		lval = lval_char->in_room->vnum; break;
        case CHK_SEX:
	    if ( lval_char != NULL ) lval = lval_char->sex; break;
        case CHK_LEVEL:
            if ( lval_char != NULL ) lval = lval_char->level; break;
	case CHK_ALIGN:
            if ( lval_char != NULL ) lval = lval_char->alignment; break;
	case CHK_MONEY:  /* Money is converted to silver... */
	    if ( lval_char != NULL ) 
		lval = lval_char->gold + (lval_char->silver * 100); break;
	case CHK_OBJVAL0:
            if ( lval_obj != NULL ) lval = lval_obj->value[0]; break;
        case CHK_OBJVAL1:
            if ( lval_obj != NULL ) lval = lval_obj->value[1]; break;
        case CHK_OBJVAL2: 
            if ( lval_obj != NULL ) lval = lval_obj->value[2]; break;
        case CHK_OBJVAL3:
            if ( lval_obj != NULL ) lval = lval_obj->value[3]; break;
	case CHK_OBJVAL4:
	    if ( lval_obj != NULL ) lval = lval_obj->value[4]; break;
	case CHK_GRPSIZE:
	    if( lval_char != NULL ) lval = count_people_room( lval_char, 4 ); break;
	default:
            return FALSE;
    }
    return( num_eval( lval, oper, rval ) );
}
Beispiel #20
0
bool mob_magic_user(struct char_data *ch)
{
    struct char_data *vict;

    if(GET_CLASS(ch) != MOB_CLASS_MAGIC_USER)
        return (FALSE);

    if (GET_POS(ch) != POS_FIGHTING)
        return (FALSE);

    /* pseudo-randomly choose someone in the room who is fighting me */
    for (vict = world[IN_ROOM(ch)].people; vict; vict = vict->next_in_room)
        if (FIGHTING(vict) == ch && !rand_number(0, 4))
            break;

    /* if I didn't pick any of those, then just slam the guy I'm fighting */
    if (vict == NULL && IN_ROOM(FIGHTING(ch)) == IN_ROOM(ch))
        vict = FIGHTING(ch);

    /* Hm...didn't pick anyone...I'll wait a round. */
    if (vict == NULL)
        return (TRUE);

    if (GET_LEVEL(ch) > 13 && rand_number(0, 10) == 0)
        cast_spell(ch, vict, NULL, NOWHERE, SPELL_POISON);

    if (GET_LEVEL(ch) > 7 && rand_number(0, 8) == 0)
        cast_spell(ch, vict, NULL, NOWHERE, SPELL_BLINDNESS);

    if (GET_LEVEL(ch) > 12 && rand_number(0, 12) == 0) {
        if (IS_EVIL(ch))
            cast_spell(ch, vict, NULL, NOWHERE, SPELL_ENERGY_DRAIN);
        else if (IS_GOOD(ch))
            cast_spell(ch, vict, NULL, NOWHERE, SPELL_DISPEL_EVIL);
    }

    if (rand_number(0, 4))
        return (TRUE);

    switch (GET_LEVEL(ch)) {
    case 4:
    case 5:
        cast_spell(ch, vict, NULL, NOWHERE, SPELL_MAGIC_MISSILE);
        break;
    case 6:
    case 7:
        cast_spell(ch, vict, NULL, NOWHERE, SPELL_CHILL_TOUCH);
        break;
    case 8:
    case 9:
        cast_spell(ch, vict, NULL, NOWHERE, SPELL_BURNING_HANDS);
        break;
    case 10:
    case 11:
        cast_spell(ch, vict, NULL, NOWHERE, SPELL_SHOCKING_GRASP);
        break;
    case 12:
    case 13:
        cast_spell(ch, vict, NULL, NOWHERE, SPELL_LIGHTNING_BOLT);
        break;
    case 14:
    case 15:
    case 16:
    case 17:
        cast_spell(ch, vict, NULL, NOWHERE, SPELL_COLOR_SPRAY);
        break;
    default:
        cast_spell(ch, vict, NULL, NOWHERE, SPELL_FIREBALL);
        break;
    }
    return (TRUE);

}
Beispiel #21
0
void auto_equip(struct char_data *ch, struct obj_data *obj, int location)
{
  int j;

  if (location > 0) { /* was worn */
    switch (j = (location - 1)) {
      case WEAR_FINGER_R:
      case WEAR_FINGER_L:
	if (!CAN_WEAR(obj,ITEM_WEAR_FINGER))
	  location = LOC_INVENTORY;
	break;
      case WEAR_NECK_1:
      case WEAR_NECK_2:
	if (!CAN_WEAR(obj,ITEM_WEAR_NECK))
	  location = LOC_INVENTORY;
	break;
      case WEAR_BODY:
	if (!CAN_WEAR(obj,ITEM_WEAR_BODY))
	  location = LOC_INVENTORY;
	break;
      case WEAR_HEAD:
	if (!CAN_WEAR(obj,ITEM_WEAR_HEAD))
	  location = LOC_INVENTORY;
	break;
      case WEAR_LEGS:
	if (!CAN_WEAR(obj,ITEM_WEAR_LEGS))
	  location = LOC_INVENTORY;
	break;
      case WEAR_FOOT_R:
      case WEAR_FOOT_L:
	if (!CAN_WEAR(obj,ITEM_WEAR_FEET))
	  location = LOC_INVENTORY;
	break;
      case WEAR_HAND_R:
      case WEAR_HAND_L:
	if (!CAN_WEAR(obj,ITEM_WEAR_HANDS))
	  location = LOC_INVENTORY;
	break;
      case WEAR_ARM_R:
      case WEAR_ARM_L:
	if (!CAN_WEAR(obj,ITEM_WEAR_ARMS))
	  location = LOC_INVENTORY;
	break;
      case WEAR_BACK:
	if (!CAN_WEAR(obj,ITEM_WEAR_BACK))
	  location = LOC_INVENTORY;
	break;
      case WEAR_WAIST:
	if (!CAN_WEAR(obj,ITEM_WEAR_WAIST))
	  location = LOC_INVENTORY;
	break;
      case WEAR_WRIST_R:
      case WEAR_WRIST_L:
	if (!CAN_WEAR(obj,ITEM_WEAR_WRIST))
	  location = LOC_INVENTORY;
	break;
      case WEAR_WIELD:
      case WEAR_HOLD:
	if (!CAN_WEAR(obj, ITEM_WEAR_HOLD) &&
            !CAN_WEAR(obj, ITEM_WEAR_TAKE))
	  location = LOC_INVENTORY;
	break;
      default:
	location = LOC_INVENTORY;
    }
    if (location > 0) {
      if (!GET_EQ(ch,j)) {
        /* check ch's alignment to prevent $M from being zapped through auto-equip */
	if ((IS_OBJ_STAT(obj, ITEM_ANTI_EVIL) && IS_EVIL(ch)) ||
	    (IS_OBJ_STAT(obj, ITEM_ANTI_GOOD) && IS_GOOD(ch)) ||
	    (IS_OBJ_STAT(obj, ITEM_ANTI_NEUTRAL) && IS_NEUTRAL(ch)))
	  location = LOC_INVENTORY;
	else
	  equip_char(ch, obj, j);
      } else  { /* oops - saved player with double equipment[j]? */
        char aeq[128];
        sprintf(aeq, "SYSERR: autoeq: '%s' already equipped in position %d.", GET_NAME(ch), location);
        mudlog(aeq, BRF, LVL_IMMORT, TRUE);
        location = LOC_INVENTORY;
      }
    }
  }

  if ( location <= 0 )
    obj_to_char(obj, ch);
}
Beispiel #22
0
void equip_char(struct char_data * ch, struct obj_data * obj, int pos)
{
  int j;
  int invalid_class(struct char_data *ch, struct obj_data *obj);
  int invalid_race(struct char_data *ch, struct obj_data *obj);

  assert(pos >= 0 && pos < NUM_WEARS);

  if (GET_EQ(ch, pos)) {
    GET_NAME(ch, chname);
    sprintf(buf, "SYSERR: Char is already equipped: %s, %s", chname,
	    obj->short_description);
    FREE_NAME(chname);
    log(buf);
    return;
  }

if (obj->carried_by) {
  log("SYSERR: EQUIP: Obj is carried_by when equip.");
    return;
  }

  if (obj->in_room != NOWHERE) {
    log("SYSERR: EQUIP: Obj is in_room when equip.");
    return;
  }

  /*  Let's change the messages here.  Soli, 8/12/99  */
  if ((IS_OBJ_STAT(obj, ITEM_ANTI_EVIL) && IS_EVIL(ch)) ||
      (IS_OBJ_STAT(obj, ITEM_ANTI_GOOD) && IS_GOOD(ch)) ||
      (IS_OBJ_STAT(obj, ITEM_ANTI_NEUTRAL) && IS_NEUTRAL(ch)))
  {
      act("You are zapped by $p and instantly let go of it.", FALSE, ch, obj, 0, TO_CHAR);
      act("$n is zapped by $p and instantly lets go of it.", FALSE, ch, obj, 0, TO_ROOM);
      obj_to_char(obj, ch);	/* changed to drop in inventory instead of
				 * ground */
      return;
  }

  /*  I'm moving the other two to a seperate function, checked before we
      actually wear the eq.  Soli, 8/12/99  */

  GET_EQ(ch, pos) = obj;
  obj->worn_by = ch;
  obj->worn_on = pos;

  if (GET_OBJ_TYPE(obj) == ITEM_ARMOR)
    GET_AC(ch) -= apply_ac(ch, pos);

  if (ch->in_room != NOWHERE) {
    if (pos == WEAR_LIGHT && GET_OBJ_TYPE(obj) == ITEM_LIGHT)
      if (GET_OBJ_VAL(obj, 2))	/* if light is ON */
	world[ch->in_room].light++;
  } else {
    log("SYSERR: ch->in_room = NOWHERE when equipping char.");
  }

  for (j = 0; j < MAX_OBJ_AFFECT; j++)
    affect_modify(ch, obj->affected[j].location,
		  obj->affected[j].modifier,
		  obj->obj_flags.bitvector, TRUE);
  affect_total(ch);
}