Beispiel #1
0
/*
 * subtracts amount of hitpoints from ch's current and starts points event
 */
void alter_hit(struct char_data *ch, int amount)
{
  struct regen_event_obj *regen;
  long time;
  int gain;

  GET_HIT(ch) = MIN(GET_HIT(ch) - amount, GET_MAX_HIT(ch));

  if (GET_HIT(ch) <= HIT_INCAP||IS_AFFECTED(ch,AFF_TRAMORTITO))
    return;
  if (PLR_FLAGGED(ch, PLR_FANTASMA) && amount > 0)
    return;

  if (GET_HIT(ch) < GET_MAX_HIT(ch) && !GET_POINTS_EVENT(ch, REGEN_HIT)) {
    CREATE(regen, struct regen_event_obj, 1);	
    regen->ch = ch;
    regen->type = REGEN_HIT;
    gain = hit_gain(ch);
    time = PULSES_PER_MUD_HOUR / (gain ? gain : 1);
    GET_POINTS_EVENT(ch, REGEN_HIT) = event_create(points_event, regen, time);

    if (amount >= 0) {
	
      /*
       * if the character gained hp, update position and
       * restart mana and move regeneration if needed.
       */
      update_pos(ch);
      alter_mana(ch, 0);
      alter_move(ch, 0);
    }
  }
Beispiel #2
0
 /* Hey! Don't go calling this w/o making checks! */
static void
npc_regen(struct char_data * ch) {
  int regen_rate = 2;
  GET_HIT(ch) += GET_LEVEL(ch) * regen_rate;
  if(GET_HIT(ch) > GET_MAX_HIT(ch))
     GET_HIT(ch) = GET_MAX_HIT(ch);
}
Beispiel #3
0
int
calculate_mob_aggression(struct creature *ch, struct creature *vict)
{
    // aggression is the average of the percent health of self and the
    // percent damage of the other
    return (GET_HIT(ch) * 100 / GET_MAX_HIT(ch)
        + (100 - GET_HIT(vict) * 100 / GET_MAX_HIT(vict))) / 2;
}
Beispiel #4
0
/*
** doInvigorate
*/
void
doInvigorate(CharData* ch)
{
   int gain = 0;

   gain += number(1, GET_LEVEL(ch)/3);
   gain += number(1, (GET_MAX_HIT(ch) - GET_LEVEL(ch)*12)/15);

   if (GET_HIT(ch) < GET_MAX_HIT(ch)) 
       GET_HIT(ch) = MIN( GET_MAX_HIT(ch), GET_HIT(ch) + gain );
}
Beispiel #5
0
static void event_fill_zone_with_mobs(int rnum, struct room_data *rp,
				      struct event_mob_in_zone *mobs)
{
    int                                     i = 0;
    int                                     j = 0;
    int                                     couldbe = 0;
    int                                     exit_found = FALSE;
    struct char_data                       *monster = NULL;
    struct obj_data                        *object = NULL;

    if (DEBUG > 1)
	log_info("called %s with %d, %08zx, %08zx", __PRETTY_FUNCTION__, rnum, (size_t) rp,
		 (size_t) mobs);

    if (!rp || rp->number < mobs->bottom || rp->number > mobs->top)
	return;
    if (IS_SET(rp->room_flags, (NO_MOB | PEACEFUL | PRIVATE)))
	return;
    exit_found = 0;
    for (i = 0; i < MAX_NUM_EXITS; i++)			       /* neswud */
	if (rp->dir_option[i]) {
	    exit_found = 1;
	    break;
	}
    if (!exit_found)
	return;
    couldbe = number(mobs->atleast, mobs->atmost);
    for (j = 0; j < couldbe; j++) {
	if (number(0, 99) >= mobs->chance)
	    continue;
	i = number(1, mobs->count) - 1;
	if (!(monster = read_mobile(mobs->mobset[i].vnum, VIRTUAL)))
	    continue;
	monster->points.max_hit = dice(mobs->mobset[i].hp_dice,
				       mobs->mobset[i].hp_die) + mobs->mobset[i].hp_mod;
	GET_HIT(monster) = GET_MAX_HIT(monster);
	GET_EXP(monster) = (dice(mobs->mobset[i].exp_dice, mobs->mobset[i].exp_die)
			    + mobs->mobset[i].exp_mod) * GET_MAX_HIT(monster);
	GET_GOLD(monster) = number(mobs->mobset[i].gold_dice, mobs->mobset[i].gold_die)
	    + mobs->mobset[i].gold_mod;
	if (mobs->mobset[i].obj_vnum >= 0) {
	    if (number(0, 99) < mobs->mobset[i].obj_chance) {
		if ((object = read_object(mobs->mobset[i].obj_vnum, VIRTUAL)))
		    obj_to_char(object, monster);
	    }
	}
	char_to_room(monster, rnum);
	mob_count++;
	act("In a shimmering column of blue light, $N appears!", FALSE,
	    monster, 0, monster, TO_ROOM);
    }
}
Beispiel #6
0
/* Some initializations for characters, including initial skills */
void do_start(struct char_data *ch)
{
  GET_LEVEL(ch) = 1;
  GET_TOT_LEVEL(ch) = 1;
  GET_EXP(ch) = 1;
  GET_CLASS_1(ch) = GET_CLASS(ch);
  GET_MULTIS(ch) = 1;

  set_title(ch, NULL);
  roll_real_abils(ch);

  GET_MAX_HIT(ch)  = 10;
  GET_MAX_MANA(ch) = 100;
  GET_MAX_MOVE(ch) = 100;

  switch (GET_CLASS(ch)) {

  case CLASS_ADEPT:
    break;

  case CLASS_MEDIC:
    break;

  case CLASS_BANDIT:
    SET_SKILL(ch, SKILL_SNEAK, 10);
    SET_SKILL(ch, SKILL_HIDE, 5);
    SET_SKILL(ch, SKILL_STEAL, 15);
    SET_SKILL(ch, SKILL_BACKSTAB, 10);
    SET_SKILL(ch, SKILL_PICK_LOCK, 10);
    SET_SKILL(ch, SKILL_TRACK, 10);
    break;

  case CLASS_SOLDIER:
    break;
  }

  advance_level(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, HUNGER) = 24;
  GET_COND(ch, DRUNK) = 0;

  if (CONFIG_SITEOK_ALL)
    SET_BIT_AR(PLR_FLAGS(ch), PLR_SITEOK);
}
Beispiel #7
0
void loss_breath(struct char_data * ch, int breath)
{

	if (AFF2_FLAGGED(ch, AFF2_IRON_BODY))
		return;

	if (ROOM_AFFECTED(ch->in_room, RAFF_LIQUID_AIR)) {
		GET_OXI(ch) -= number(2, 10);
	}

	if(GET_LEVEL(ch) < LVL_IMMORT && breath > 0)
	{
		if(GET_OXI(ch) >= 1)
		{
			GET_OXI(ch) -= breath;
			send_to_char("Your breath becomes deeper and slower...\r\n", ch);
		} else {
			if(GET_HIT(ch) > 0)
			{
            	GET_HIT(ch) -= (GET_MAX_HIT(ch)*0.15);
            	send_to_char("&RYou need some oxygen, your life is almost extinguished!&n\r\n", ch);
			} else {
	           	GET_HIT(ch) = 0;
	           	send_to_char("&RYour breath becomes so slow that you die because of it.&n\r\n", ch);
            	raw_kill(ch, NULL);
			}
		}
	}
}
Beispiel #8
0
void mag_points(int level, struct char_data *ch, struct char_data *victim,
		     int spellnum, int savetype)
{
  int healing = 0, move = 0;

  if (victim == NULL)
    return;

  switch (spellnum) {
  case SPELL_CURE_LIGHT:
    healing = dice(1, 8) + 1 + (level / 4);
    send_to_char(victim, "You feel better.\r\n");
    break;
  case SPELL_CURE_CRITIC:
    healing = dice(3, 8) + 3 + (level / 4);
    send_to_char(victim, "You feel a lot better!\r\n");
    break;
  case SPELL_HEAL:
    healing = 100 + dice(3, 8);
    send_to_char(victim, "A warm feeling floods your body.\r\n");
    break;
  }
  GET_HIT(victim) = MIN(GET_MAX_HIT(victim), GET_HIT(victim) + healing);
  GET_MOVE(victim) = MIN(GET_MAX_MOVE(victim), GET_MOVE(victim) + move);
  update_pos(victim);
}
Beispiel #9
0
void ChangeMobHitp(struct char_data *ch, char *arg, int type)
{
 char buf[255];
 struct char_data *mob; 
 int change;

 if(type != ENTER_CHECK)
    if(!*arg || (*arg == '\n')) {
        ch->specials.medit = MOB_MAIN_MENU;
        UpdateMobMenu(ch);
        return;
    }

 mob=ch->specials.mobedit; 
 if(type != ENTER_CHECK) {
    change=atoi(arg);
    if(change<=0) change=1;
    mob->points.max_hit = change;
    ch->specials.medit = MOB_MAIN_MENU;
    UpdateMobMenu(ch);
    return;
 }
 
 sprintf(buf, VT_HOMECLR);
 send_to_char(buf, ch);
 
 sprintf(buf, "Current Maximum Hit Points: %d", GET_MAX_HIT(mob)); 
 send_to_char(buf, ch);
 send_to_char("\n\r\n\rNew Maximum Hit Points: ", ch);
 
 return;
} 
Beispiel #10
0
/* nb, also mess up anyone affected by AFF_POISON */
void pulse_heal(void)
{
    CharData *ch;
    int gain = number(18,24);

    for (ch = character_list; ch; ch = ch->next) {
        if(ch->in_room == NOWHERE)
            continue;

        if(!(pvpFactor() > 1)) {
            if( GET_POS(ch) == POS_INCAP )      damage(ch, ch, 1, TYPE_SUFFERING);
            else if( GET_POS(ch) == POS_MORTALLYW )  damage(ch, ch, 2, TYPE_SUFFERING);
            else if( GET_POS(ch) == POS_DEAD) {
                if(IN_ARENA(ch) || IN_QUEST_FIELD(ch) ||
                   ZONE_FLAGGED(world[ch->in_room].zone, ZONE_ARENA) ||
                   ZONE_FLAGGED(world[ch->in_room].zone, ZONE_SLEEPTAG))
                    // If they're dying in the arena, they eventually get better (or killed by someone)
                {
                    GET_HIT(ch) = number(GET_HIT(ch), 1);
                    sendChar(ch, "You slowly recover.\r\n");
                    update_pos(ch);
                }
                else {
                    raw_kill(ch, NULL);
                    continue;
                }
            }
        }

        if (IS_AFFECTED(ch, AFF_PULSE_HIT))
            if (GET_HIT(ch) < GET_MAX_HIT(ch)) GET_HIT(ch) += gain;
        if (IS_AFFECTED(ch, AFF_PULSE_MANA))
            if (GET_MANA(ch) < GET_MAX_MANA(ch)) GET_MANA(ch) += gain;
        if (IS_AFFECTED(ch, AFF_POISON)) doPoison(ch);
        if (IS_AFFECTED(ch, AFF_DISEASE)) doDisease(ch);
	if (affected_by_spell(ch, SKILL_INVIGORATE)) doInvigorate(ch);
        if (IS_BOUNTY_HUNTER(ch) && GET_ADVANCE_LEVEL(ch) >= 1 && IS_AFFECTED(ch, AFF_HIDE)) GET_MOVE(ch) = MIN(GET_MOVE(ch) + 3*gain, GET_MAX_MOVE(ch));
        if (IS_PRESTIDIGITATOR(ch)) GET_MANA(ch) = MIN(GET_MANA(ch) + GET_ADVANCE_LEVEL(ch) * 2, GET_MAX_MANA(ch));
        if (affected_by_spell(ch, SPELL_HIPPOCRATIC_OATH)) GET_MANA(ch) = MIN(GET_MANA(ch) + 25, GET_MAX_MANA(ch));
        if (affected_by_spell(ch, SKILL_PET_MEND)) GET_HIT(ch) = MIN(GET_HIT(ch) * 115 / 100, GET_MAX_HIT(ch));
        if (IS_HOLY_PRIEST(ch)) GET_MANA(ch) = MIN(GET_MANA(ch) + 10 + 2*GET_ADVANCE_LEVEL(ch), GET_MAX_MANA(ch));

        /* The room might be poisoned! (Or later, otherwise dangerous) */
        if (ch->in_room != NOWHERE) {
            if (ROOM_FLAGGED(ch->in_room, ROOM_POISONED)) {
                if (!mag_savingthrow(ch, SAVING_SPELL)) {
                    act("$n chokes and gags!", TRUE, ch, 0, 0, TO_ROOM);
                    act("You choke and gag!", TRUE, ch, 0, 0, TO_CHAR);
                    add_affect( ch, ch, SPELL_POISON, 30, APPLY_NONE, 0, 5 TICKS,
                            AFF_POISON, FALSE, FALSE, FALSE, FALSE);
                }
            }
        }

        if(IS_DEFENDER(ch) && !affected_by_spell(ch, SKILL_DEFENDER_HEALTH))
            add_affect(ch, ch, SKILL_DEFENDER_HEALTH, GET_LEVEL(ch), APPLY_HIT, GET_ADVANCE_LEVEL(ch)*5, -1, FALSE, FALSE, FALSE, FALSE, FALSE);

    }
}
Beispiel #11
0
void hitprcnt_mtrigger(char_data *ch)
{
  trig_data *t;
  char buf[MAX_INPUT_LENGTH];
  
  if (!SCRIPT_CHECK(ch, MTRIG_HITPRCNT) || !FIGHTING(ch) ||
      AFF_FLAGGED(ch, AFF_CHARM))
    return;
  
  for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
    if (TRIGGER_CHECK(t, MTRIG_HITPRCNT) && GET_MAX_HIT(ch) &&
	(((GET_HIT(ch) * 100) / GET_MAX_HIT(ch)) <= GET_TRIG_NARG(t))) {

      ADD_UID_VAR(buf, t, FIGHTING(ch), "actor", 0)
      script_driver(ch, t, MOB_TRIGGER, TRIG_NEW);
      break;
    }
  }
}
Beispiel #12
0
int calcHitBonus(CharData *ch) {
    int bonus = 0;
    
    if(GET_CON(ch) > 18)
        bonus += (GET_CON(ch) - 18)*5;

    if(affected_by_spell(ch, SPELL_REGENERATE))
        bonus += spell_level(ch, SPELL_REGENERATE) + GET_MAX_HIT(ch)/8;        
    
    if(IS_DEFENDER(ch))
        bonus += 30 + 10*GET_ADVANCE_LEVEL(ch);
    
    return bonus;
}
Beispiel #13
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 */
void js_hitpercent_triggers(Character * ch, Character * victim)
{
    if (!ch->js_scripts || ch->js_scripts->size() == 0 || !FIGHTING(ch))
        return;
    for (int i = 0; i < ch->js_scripts->size(); ++i)
    {
        if (ch->js_scripts->at(i)->isFlagged(JS::CHARACTER_HITPERCENT))
        {
            JSTrigger* trig = ch->js_scripts->at(i);
        
            if (is_allowed_violent(ch, victim, trig) && GET_MAX_HIT(ch) && (((GET_HIT(ch) * 100) / GET_MAX_HIT(ch)) <= trig->narg))
            {
                JSManager::get()->execute(trig, ch, victim);
            }
        }
    }
}
Beispiel #15
0
void do_mob_report (struct char_data *ch)
{
	struct char_data *mob; 
	FILE *reportfile; 
	int i;

	if (!(reportfile = fopen("report.mob", "w"))) {
		mlog("SYSERR:  Mob report file unavailable.");
		send_to_char ("Report.mob could not be generated.\r\n",ch);
		return;
	}
	sprintf(buf, "MOBS\n----\n");
	for (i=0; i<top_of_mobt;i++) {
		mob=read_mobile(i, REAL);
		char_to_room(mob, 0);
		sprintf(buf+strlen(buf), "[%5d] %s  Spec Proc: ",
		GET_MOB_VNUM(mob), GET_NAME(mob));

		if (mob_index[GET_MOB_RNUM(mob)].func!=NULL)
			get_spec_name(GET_MOB_RNUM(mob), buf2,'m');
		else sprintf(buf2, "none"); 
		sprintf(buf+strlen(buf), "%s\n",buf2);

		sprintf(buf+strlen(buf),mob->player.description);
		sprintf(buf+strlen(buf),"Difficulty: %d   XP: %d  HP: %d  Mana: %d  Gold %d\n",
		GET_DIFFICULTY(mob), GET_EXP(mob), GET_MAX_HIT(mob), GET_MAX_MANA(mob), GET_GOLD(mob));
		sprintf(buf+strlen(buf),"Passive Defense: %d   Damage Reduction: %d  ", 
		GET_PD(mob), GET_REDUCTION(mob));
		sprintf(buf+strlen(buf), "Attack Type: %s\n",
		attack_hit_text[mob->mob_specials.attack_type].singular);

		sprintbit(MOB_FLAGS(mob), action_bits, buf2, sizeof(buf2));
		sprintf(buf+strlen(buf),"Flags:  %s\n", buf2);

		sprintbit(AFF_FLAGS(mob), affected_bits, buf2, sizeof(buf2));
		sprintf(buf+strlen(buf),"Affects:  %s\n\n-------\n", buf2);
		extract_char(mob);
		fprintf(reportfile, buf);
		buf[0]='\0';
	}/*for i=0...*/
	fclose (reportfile);
	send_to_char ("report.mob printed\r\n",ch);
}
Beispiel #16
0
void
psionic_activity(struct creature *ch)
{
    if (room_is_dark(ch->in_room)
        && !has_dark_sight(ch)
        && can_cast_spell(ch, SPELL_RETINA))
        cast_spell(ch, ch, NULL, NULL, SPELL_RETINA);
    else if (GET_HIT(ch) < GET_MAX_HIT(ch) * 0.80) {
        if (can_cast_spell(ch, SPELL_CELL_REGEN))
            cast_spell(ch, ch, NULL, NULL, SPELL_CELL_REGEN);
        else if (can_cast_spell(ch, SPELL_WOUND_CLOSURE))
            cast_spell(ch, ch, NULL, NULL, SPELL_WOUND_CLOSURE);
    } else if (!AFF_FLAGGED(ch, AFF_NOPAIN)
        && !AFF_FLAGGED(ch, AFF_SANCTUARY)
        && can_cast_spell(ch, SPELL_NOPAIN))
        cast_spell(ch, ch, NULL, NULL, SPELL_NOPAIN);
    else if (!room_has_air(ch->in_room) &&
        !can_travel_sector(ch, ch->in_room->sector_type, 0) &&
        can_cast_spell(ch, SPELL_BREATHING_STASIS) &&
        !AFF3_FLAGGED(ch, AFF3_NOBREATHE))
        cast_spell(ch, ch, NULL, NULL, SPELL_BREATHING_STASIS);
    else if (!AFF2_FLAGGED(ch, AFF2_TELEKINESIS)
        && can_cast_spell(ch, SPELL_TELEKINESIS))
        cast_spell(ch, ch, NULL, NULL, SPELL_TELEKINESIS);
    else if (!affected_by_spell(ch, SPELL_DERMAL_HARDENING)
        && can_cast_spell(ch, SPELL_DERMAL_HARDENING))
        cast_spell(ch, ch, NULL, NULL, SPELL_DERMAL_HARDENING);
    else if (!AFF3_FLAGGED(ch, AFF3_PSISHIELD)
        && can_cast_spell(ch, SPELL_PSISHIELD))
        cast_spell(ch, ch, NULL, NULL, SPELL_PSISHIELD);
    else if (can_cast_spell(ch, SPELL_PSYCHIC_RESISTANCE) &&
        !affected_by_spell(ch, SPELL_PSYCHIC_RESISTANCE))
        cast_spell(ch, ch, NULL, NULL, SPELL_PSYCHIC_RESISTANCE);
    else if (can_cast_spell(ch, SPELL_POWER)
        && !affected_by_spell(ch, SPELL_POWER))
        cast_spell(ch, ch, NULL, NULL, SPELL_POWER);
    else if (!AFF_FLAGGED(ch, AFF_CONFIDENCE)
        && can_cast_spell(ch, SPELL_CONFIDENCE))
        cast_spell(ch, ch, NULL, NULL, SPELL_CONFIDENCE);
}
Beispiel #17
0
void regen_update( void ) {
    CharData *i, *next_char;
    int hit, mana, move;
    int vivify_level;

    for( i = character_list; i; i = next_char )
    {
        next_char = i->next;

        if(affected_by_spell(i, SKILL_EMACIATED) && (GET_COND(i, HUNGER) != 0 || IS_VAMPIRE(i)) && GET_COND(i, THIRST) != 0) {
            if(!affected_by_spell(i, SKILL_EMACIATED_MANA) && !affected_by_spell(i, SKILL_EMACIATED_HIT))
                affect_from_char(i, SKILL_EMACIATED);
            else if(percentSuccess(4)) {
                affect_from_char(i, SKILL_EMACIATED_MANA);
                affect_from_char(i, SKILL_EMACIATED_HIT);
            }
        }

        // Dwarves sober up 3x faster than most races (unless they drink more...)
        if(IS_DWARF(i) && !number(0, 35))
            gain_condition(i, DRUNK, -1);

        vivify_level = spell_level(i, SPELL_VIVIFY);
        affect_from_char(i, SPELL_VIVIFY);
        if(GET_POS(i) <= POS_MEDITATING) {
            add_affect(i, i, SPELL_VIVIFY, MIN(vivify_level + 1, 100), APPLY_NONE, 0, -1,
                    0, FALSE, FALSE, FALSE, FALSE);
        }

        if(GET_POS(i) >= POS_MORTALLYW)
        {
            hit = hit_gain(i);
            mana = mana_gain(i);
            move = move_gain(i);

            if(affected_by_spell(i, SPELL_VIVIFY)) {
                if(hit > 0)
                    hit += spell_level(i, SPELL_VIVIFY) * GET_MAX_HIT(i)/600;
                if(mana > 0)
                    mana += spell_level(i, SPELL_VIVIFY) * GET_MAX_MANA(i)/600;
                if(move > 0)
                    move += spell_level(i, SPELL_VIVIFY) * GET_MAX_MOVE(i)/600;
            }

            // Regeneration is increased on pvp holidays.  If you're incapactitated, you will
            // eventually recover.
            if(pvpHoliday(i)) {
                if (GET_POS(i) < POS_SLEEPING)
                    hit = 20;
                else {
                    hit  = (hit  > 0) ? hit *3 : 20;
                    mana = (mana > 0) ? mana*2 : 40;
                    move = (move > 0) ? move*2 : 40;
                }
            }
                

            // 72 seconds per tick...
            if(hit < 0 || GET_HIT(i) < GET_MAX_HIT(i)) {
                if(hit>0)
                    GET_HIT(i) += hit/72 + (hit % 72 > number(0, 71)? 1:0);
                else
                    GET_HIT(i)  = MAX(GET_HIT(i) + hit/72 + (-hit % 72 > number(0, 71)?-1:0), -9);
            }
            else {
                int surplus = (GET_HIT(i) - GET_MAX_HIT(i));
                GET_HIT(i) -= surplus / 72 + (surplus % 72 > number(0, 71)? 1:0);
            }


            if(mana>0)
                GET_MANA(i) = MAX(MIN(GET_MANA(i) + mana/72 + (mana % 72 > number(0, 71)?1:0), GET_MAX_MANA(i)), 0);
            else
                GET_MANA(i) = MIN(GET_MANA(i) + mana/72 + (-mana % 72 > number(0, 71)?-1:0), GET_MAX_MANA(i));

            if(move>0)
                GET_MOVE(i) = MIN(GET_MOVE(i) + move/72 + (move % 72 > number(0, 71)?1:0), GET_MAX_MOVE(i));
            else
                GET_MOVE(i) = MAX(MIN(GET_MOVE(i) + move/72 + (-move % 72 > number(0, 71)?-1:0), GET_MAX_MOVE(i)), 0);

            update_pos(i);
        }
    }
}
Beispiel #18
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 #19
0
void
check_idling( CharData * ch )
{
#define VOID_TIME 8
#define EXTRACT_TIME 32
  void Crash_rentsave(CharData *ch, int cost);
  void Crash_cryosave(CharData *ch, int cost);

  /*
  ** CONJURED timer
  */
  int i = 0;

  for(;i < 4;i++) {
      if( GET_CONJ_CNT(ch, i) > 0)
      {
          SET_CONJ_CNT(ch, i) -= 1;
          
          if(SET_CONJ_CNT(ch, i) == 0)
              switch(GET_CLASS(ch)) {
                  case CLASS_RANGER:
                      sendChar( ch, "The creatures of the wild will answer your call again.\r\n" );
                      break;
                  case CLASS_NECROMANCER:
                      sendChar(ch, "The dead will heed your summons once more.\r\n");
                  case CLASS_MAGIC_USER:
                      switch(i) {
                          case TIMER_GATE: sendChar(ch, "Demons will answer your summons again.\r\n"); break;
                          case TIMER_MONSTER: sendChar(ch, "Monsters will answer your summons again.\r\n"); break;
                          case TIMER_ELEMENTAL: sendChar(ch, "Elementals will answer your summons again.\r\n"); break;
                      }
                      break;
                  default:
                      sendChar( ch, "Conjured creatures will answer your summons again.\r\n" );
              }
      }
  }
  
  /*
  ** HUNTED timer
  */
  if( IS_SET_AR( PLR_FLAGS(ch), PLR_HUNTED ) && ch->desc &&
    (--(ch)->player_specials->saved.phunt_countdown <= 0))
  {
    sendChar( ch, "You are no longer hunted.\r\n" );
    unset_hunted_player(ch);
  }
  /*
  ** THIEF timer
  */
  if( IS_SET_AR(PLR_FLAGS(ch), PLR_THIEF) && ch->desc &&
    (--(ch)->player_specials->saved.pthief_countdown <= 0))
  {
    REMOVE_BIT_AR(PLR_FLAGS(ch), PLR_THIEF);
    send_to_char("You are no longer a registered thief.\r\n", ch);
    (ch)->player_specials->saved.pthief_countdown = 0;
  }
  /* KILLER timer */
  if (IS_SET_AR(PLR_FLAGS(ch), PLR_KILLER)
     && (--(ch)->player_specials->saved.pkill_countdown <= 0))
  {
    REMOVE_BIT_AR(PLR_FLAGS(ch), PLR_KILLER);
    send_to_char("You are no longer a registered killer.\r\n", ch);
    (ch)->player_specials->saved.pkill_countdown = 0;
  }
  /* JAILED timer */
  if (IS_SET_AR(PLR_FLAGS(ch), PLR_JAILED)
     && (--(ch)->player_specials->saved.jail_timer <= 0))
  {
    int jail_exit_room;
    REMOVE_BIT_AR(PLR_FLAGS(ch), PLR_JAILED);

    if (PRF_FLAGGED(ch, PRF_GOLD_TEAM) && IN_ROOM(ch) == real_room(GOLD_TEAM_JAIL))
    {
      jail_exit_room = real_room(GOLD_TEAM_START_ROOM);
      GET_HIT(ch) = GET_MAX_HIT(ch);
      GET_MANA(ch) = GET_MAX_MANA(ch);
      GET_MOVE(ch) = GET_MAX_MOVE(ch);
      char_from_room(ch);
      char_to_room(ch, jail_exit_room);
      look_at_room(ch, 0);
    }
    if (PRF_FLAGGED(ch, PRF_BLACK_TEAM) && IN_ROOM(ch) == real_room(BLACK_TEAM_JAIL))
    {
      jail_exit_room = real_room(BLACK_TEAM_START_ROOM);
      GET_HIT(ch) = GET_MAX_HIT(ch);
      GET_MANA(ch) = GET_MAX_MANA(ch);
      GET_MOVE(ch) = GET_MAX_MOVE(ch);
      char_from_room(ch);
      char_to_room(ch, jail_exit_room);
      look_at_room(ch, 0);
    }    
    if (PRF_FLAGGED(ch, PRF_ROGUE_TEAM) && IN_ROOM(ch) == real_room(ROGUE_TEAM_JAIL))
    {
      jail_exit_room = real_room(ROGUE_TEAM_START_ROOM);
      GET_HIT(ch) = GET_MAX_HIT(ch);
      GET_MANA(ch) = GET_MAX_MANA(ch);
      GET_MOVE(ch) = GET_MAX_MOVE(ch);
      char_from_room(ch);
      char_to_room(ch, jail_exit_room);
      look_at_room(ch, 0);
    }    
    sendChar(ch, "Your imprisonement is over.\r\n");
//    if (PRF_FLAGGED(ch, PRF_GOLD_TEAM))
//	jail_exit_room = IN_ROOM(ch);
//    else if (PRF_FLAGGED(ch, PRF_BLACK_TEAM))
//	jail_exit_room = IN_ROOM(ch);
//	else if (PRF_FLAGGED(ch, PRF_ROGUE_TEAM))
//	jail_exit_room = IN_ROOM(ch);
//    else
//	jail_exit_room = getStartRoom(ch);

//    char_to_room(ch, jail_exit_room);
//    look_at_room(ch, 0);
  }
  /*
  ** If your hunted there is NO escape.
  */
  if(( ++(ch->char_specials.timer) > VOID_TIME ) &&
    !IS_SET_AR(PLR_FLAGS(ch), PLR_HUNTED))
  {
    if (GET_WAS_IN(ch) == NOWHERE && ch->in_room != NOWHERE)
    {
      GET_WAS_IN(ch) = ch->in_room;
      end_fight(ch);
      act("$n disappears into the void.", TRUE, ch, 0, 0, TO_ROOM);
      send_to_char("You have been idle, and are pulled into a void.\r\n", ch);
      save_char(ch, NOWHERE);
      Crash_crashsave(ch);
      GET_WAS_IN(ch) = ch->in_room;
      char_from_room(ch);
      char_to_room(ch, 1);
    }
    //else if (ch->char_specials.timer > EXTRACT_TIME)
    //{
      //if (ch->in_room != NOWHERE)
	//char_from_room(ch);
      //char_to_room(ch, 1);
      //if (ch->desc)
	//SET_DCPENDING(ch->desc);
      //ch->desc = NULL;

      //Crash_idlesave(ch);	/* apparently causing problems? */
      //crashRentSave(ch, -1);

      //mudlog( NRM, LVL_LRGOD, TRUE, "%s force-rented and extracted (idle).", GET_NAME(ch));
      //extract_char(ch);
    //}
  }
#undef VOID_TIME
#undef EXTRACT_TIME
}
Beispiel #20
0
int calcHitBase(CharData *ch) {
    int base = 0;

    if(IS_NPC(ch))
        base += 18;
    else {
        base += graf(age(ch).year, 37, 38, 43, 46, 40, 34, 32);
    }

    /* Level/Class bonuses */
    switch(GET_CLASS(ch)) {
        case CLASS_WARRIOR:
            base += GET_LEVEL(ch)*5/3;
            break;
        case CLASS_RANGER:
        case CLASS_SOLAMNIC_KNIGHT:
        case CLASS_DEATH_KNIGHT:
            base += GET_LEVEL(ch)*4/3;
            break;
        case CLASS_THIEF:
        case CLASS_ASSASSIN:
            base += GET_LEVEL(ch);
            break;
        case CLASS_SHOU_LIN:
        case CLASS_CLERIC:
        case CLASS_SHADOW_DANCER:
            base += GET_LEVEL(ch)*2/3;
            break;
        case CLASS_MAGIC_USER:
        case CLASS_NECROMANCER:
            base += GET_LEVEL(ch)/3;
            break;
        default:
            mudlog(NRM, LVL_IMMORT, TRUE, "ERROR calcManaBase: %s's class not recognized!", GET_NAME(ch));
            break;
    }

    if(affected_by_spell(ch, SKILL_ADRENALINE)) {
        struct affected_type *af;
        for (af = ch->affected; af; af = af->next) {
            if(af->type == SKILL_ADRENALINE)
                base += af->modifier;
        }
    }

    /* Position calculations    */
    switch (GET_POS(ch)) {
        case POS_MEDITATING:
            if(IS_CHI_WARRIOR(ch) && GET_ADVANCE_LEVEL(ch) >= SECOND_ADVANCE_SKILL)
                base += GET_LEVEL(ch)/10;
        case POS_SLEEPING:
            base += 20;    /* Divide by 2 */
            break;
        case POS_RESTING:
            base += 12;	/* Divide by 4 */
            break;
    }

    // Naturalist hunters get 1% bonus regen to pets per advance level.
    if (affected_by_spell(ch, SPELL_CALL_OF_THE_WILD) && ch->master && IS_NATURALIST(ch->master))
        base += GET_MAX_HIT(ch)*GET_ADVANCE_LEVEL(ch->master)/100;
    
    return base;
}
Beispiel #21
0
/*
 * Write the char to the file.
 *
 * @param ch the character to be written
 * @param fp the file to write to
 */
void fwrite_char( struct char_data *ch, FILE *fp )
{
  extern struct race_data * races;
  
  struct affected_type *paf;
  int          sn, i;
  
  fprintf( fp, "#%s\n", IS_NPC( ch ) ? "MOB" : "PLAYER"		);
  
  fprintf( fp, "Name        %s~\n",	GET_NAME(ch)			);
  fprintf( fp, "ShtDsc      %s~\n",	GET_SHORT_DESC(ch) ?
	   GET_SHORT_DESC(ch) : "" );
  fprintf( fp, "LngDsc      %s~\n",	GET_LONG_DESC(ch) ?
	   GET_LONG_DESC(ch) : "" );
  fprintf( fp, "Dscr        %s~\n",	GET_DESCRIPTION(ch) ?
	   GET_DESCRIPTION(ch) : "" );
  // fprintf( fp, "Prmpt       %s~\n",	ch->pcdata->prompt	);
  fprintf( fp, "Sx          %d\n",	GET_SEX(ch)			);
  fprintf( fp, "Race        %s~\n",	races[ (int)GET_RACE(ch) ].name );
  fprintf( fp, "Lvl         %d\n",	GET_LEVEL(ch)			);
  fprintf( fp, "Trst        %d\n",	GET_TRUST(ch)			);
  /*
    fprintf( fp, "Playd       %ld\n",
    GET_PLAYED(ch) + (int)( time( 0 ) - GET_LOGON(ch) )		);
  */
  // fprintf( fp, "Note        %ld\n",   (unsigned long)ch->last_note );
  fprintf( fp, "Room        %ld\n",
	   (  ch->in_room == NOWHERE && ch->was_in_room )
	   ? ch->was_in_room : ch->in_room );
  
  fprintf( fp, "HpMnMv      %d %d %d %d %d %d\n",
	   GET_HIT(ch), GET_MAX_HIT(ch),
	   GET_MANA(ch), GET_MAX_MANA(ch),
	   GET_MOVE(ch), GET_MAX_MOVE(ch) );
  fprintf( fp, "Gold        %ld\n",	GET_GOLD(ch)		);
  fprintf( fp, "Exp         %ld\n",	GET_EXP(ch)		);
  fprintf( fp, "Act         %lld\n",  PLR_FLAGS(ch)           );
  fprintf( fp, "Act2        %lld\n",  PLR2_FLAGS(ch)          );
  fprintf( fp, "Pref        %lld\n",  PRF_FLAGS(ch)		);
  fprintf( fp, "Pref2       %lld\n",  PRF2_FLAGS(ch)		);
  fprintf( fp, "AffdBy      %lld\n",	AFF_FLAGS(ch)		);
  fprintf( fp, "AffdBy2     %lld\n",	AFF2_FLAGS(ch)		);
  /* Bug fix from Alander */
  fprintf( fp, "Pos         %d\n",
	   GET_POS(ch) == POS_FIGHTING ? POS_STANDING : GET_POS(ch) );
  fprintf( fp, "Prac        %d\n",    GET_PRACTICES(ch)       );
  fprintf( fp, "PAlign      %d\n",	GET_PERMALIGN(ch)	);
  fprintf( fp, "CAlign      %d\n",	GET_ALIGNMENT(ch)	);
  fprintf( fp, "SavThr      " );
  for ( i = 0; i < NUM_SAVES; i++ )
    fprintf( fp, "%d%s",    GET_SAVE(ch, i), (i != NUM_SAVES-1 ? ", " : "\n")	);
  fprintf( fp, "Hitroll     %d\n",	GET_HITROLL(ch)		);
  fprintf( fp, "Damroll     %d\n",	GET_DAMROLL(ch)		);
  fprintf( fp, "Armr        " );
  for ( i = 0; i < ARMOR_LIMIT; i++ )
    fprintf( fp, "%d%s",   GET_AC(ch, i), (i != ARMOR_LIMIT-1 ? ", " : "\n") );
  fprintf( fp, "Wimp        %d\n",	GET_WIMP_LEV(ch)	);
  
  if ( IS_NPC( ch ) ) {
    fprintf( fp, "Vnum        %ld\n",	GET_MOB_VNUM(ch)	);
  } else {
    fprintf( fp, "Paswd       %s~\n",	GET_PASSWD(ch)		);
    fprintf( fp, "Poofin      %s~\n",	POOFIN(ch) ?
	     POOFIN(ch) : "" );
    fprintf( fp, "Poofout     %s~\n",	POOFOUT(ch) ?
	     POOFOUT(ch) : "" );
    fprintf( fp, "Ttle        %s~\n",	GET_TITLE(ch) ?
	     GET_TITLE(ch) : "" );
    fprintf( fp, "AtrPrm      %d/%d %d %d %d %d %d %d\n",
	     ch->real_abils.str,
	     ch->real_abils.str_add,
	     ch->real_abils.intel,
	     ch->real_abils.wis,
	     ch->real_abils.dex,
	     ch->real_abils.con,
	     ch->real_abils.cha,
	     ch->real_abils.will );
    
    fprintf( fp, "AtrMd       %d/%d %d %d %d %d %d %d\n",
	     ch->aff_abils.str, 
	     ch->aff_abils.str_add, 
	     ch->aff_abils.intel, 
	     ch->aff_abils.wis, 
	     ch->aff_abils.dex, 
	     ch->aff_abils.con, 
	     ch->aff_abils.cha, 
	     ch->aff_abils.will );
    
    fprintf( fp, "Conditions  " );
    for ( i = 0; i < MAX_COND; i++ )
      fprintf( fp, "%d%s", GET_COND(ch, i), (i != MAX_COND-1 ? ", " : "\n") );
    
    fprintf( fp, "Addictions  " );
    for ( i = 0; i < MAX_COND; i++ )
      fprintf( fp, "%d%s", GET_ADDICT(ch, i), (i != MAX_COND-1 ? ", " : "\n") );
    
    for ( sn = 0; sn < MAX_SKILLS; sn++ ) {
      if ( skill_name( sn ) &&
           strcmp( skill_name( sn ), "!UNUSED!" ) &&
           GET_SKILL(ch, sn) > 0 ) {
	fprintf( fp, "Skill       %d '%s'\n",
		 GET_SKILL(ch, sn),
		 skill_name( sn ) );
      }
    }
  }
  
  for ( paf = ch->affected; paf; paf = paf->next )  {
    fprintf( fp, "Afft       %18s~ %3d %3d %3d %lld\n",
	     skill_name( paf->type ),
	     paf->duration,
	     paf->modifier,
	     paf->location,
	     paf->bitvector );
  }
  
  for ( paf = ch->affected2; paf; paf = paf->next )  {
    fprintf( fp, "Afft2       %18s~ %3d %3d %3d %lld\n",
	     skill_name( paf->type ),
	     paf->duration,
	     paf->modifier,
	     paf->location,
	     paf->bitvector );
  }
  
  fprintf( fp, "End\n\n" );
  return;
}
Beispiel #22
0
void aff_apply_modify(struct char_data *ch, byte loc, sbyte mod, char *msg)
{
  switch (loc) {
  case APPLY_NONE:
    break;

  case APPLY_STR:
    GET_STR(ch) += mod;
    break;
  case APPLY_DEX:
    GET_DEX(ch) += mod;
    break;
  case APPLY_INT:
    GET_INT(ch) += mod;
    break;
  case APPLY_WIS:
    GET_WIS(ch) += mod;
    break;
  case APPLY_CON:
    GET_CON(ch) += mod;
    break;
  case APPLY_CHA:
    GET_CHA(ch) += mod;
    break;

  case APPLY_AGE:
    ch->player.time.birth -= (mod * SECS_PER_MUD_YEAR);
    break;

  case APPLY_CHAR_WEIGHT:
    GET_WEIGHT(ch) += mod;
    break;

  case APPLY_CHAR_HEIGHT:
    GET_HEIGHT(ch) += mod;
    break;

  case APPLY_MANA:
    GET_MAX_MANA(ch) += mod;
    break;

  case APPLY_HIT:
    GET_MAX_HIT(ch) += mod;
    break;

  case APPLY_MOVE:
    GET_MAX_MOVE(ch) += mod;
    break;

  case APPLY_AC:
    GET_AC(ch) += mod;
    break;

  case APPLY_HITROLL:
    GET_HITROLL(ch) += mod;
    break;

  case APPLY_DAMROLL:
    GET_DAMROLL(ch) += mod;
    break;

  case APPLY_SAVING_PARA:
    GET_SAVE(ch, SAVING_PARA) += mod;
    break;

  case APPLY_SAVING_ROD:
    GET_SAVE(ch, SAVING_ROD) += mod;
    break;

  case APPLY_SAVING_PETRI:
    GET_SAVE(ch, SAVING_PETRI) += mod;
    break;

  case APPLY_SAVING_BREATH:
    GET_SAVE(ch, SAVING_BREATH) += mod;
    break;

  case APPLY_SAVING_SPELL:
    GET_SAVE(ch, SAVING_SPELL) += mod;
    break;

  default:
    log("SYSERR: Unknown apply adjust %d attempt (%s, affect_modify).", loc, __FILE__);
    break;

  } /* switch */
}
Beispiel #23
0
/*
 * Read in a char.
 */
int fread_char( struct char_data *ch, FILE *fp )
{
  int         error_count = 0;
  char        *word;
  char        buf [ MAX_STRING_LENGTH ];
  struct affected_type *paf;
  int         sn;
  int         i;
  int         j;
  int         status;
  int         status1;
  char        *p;
  int         tmpi;
  int         num_keys;
  int         last_key = 0;
  
  char        def_sdesc  [] = "Your short description was corrupted.";
  char        def_ldesc  [] = "Your long description was corrupted.";
  char        def_desc   [] = "Your description was corrupted.";
  char        def_title  [] = "Your title was corrupted.";
  
  struct key_data key_tab [] = {
    { "ShtDsc", TRUE,  (int) &def_sdesc,	{ &GET_SHORT_DESC(ch),   NULL } },
    { "LngDsc", TRUE,  (int) &def_ldesc,	{ &GET_LONG_DESC(ch),    NULL } },
    { "Dscr",   TRUE,  (int) &def_desc,		{ &GET_DESCRIPTION(ch),  NULL } },
    { "Sx",     FALSE, SEX_MALE,		{ &GET_SEX(ch),          NULL } },
    { "Race",   FALSE, MAND,			{ &GET_RACE(ch),         NULL } },
    { "Lvl",    FALSE, MAND,			{ &GET_LEVEL(ch),        NULL } },
    { "Trst",   FALSE, 0,			{ &GET_TRUST(ch),        NULL } },
    { "HpMnMv", FALSE, MAND,			{ &GET_HIT(ch),
						  &GET_MAX_HIT(ch),
						  &GET_MANA(ch),
						  &GET_MAX_MANA(ch),
						  &GET_MOVE(ch),
						  &GET_MAX_MOVE(ch),     NULL } },
    { "Gold",   FALSE, 0,			{ &GET_GOLD(ch),         NULL } },
    { "Exp",    FALSE, MAND,			{ &GET_EXP(ch),          NULL } },
    { "Act",     FALSE, DEFLT,			{ &PLR_FLAGS(ch),        NULL } },
    { "Act2",    FALSE, DEFLT,			{ &PLR2_FLAGS(ch),       NULL } },
    { "AffdBy",  FALSE, 0,			{ &AFF_FLAGS(ch),        NULL } },
    { "AffdBy2", FALSE, 0,			{ &AFF2_FLAGS(ch),       NULL } },
    { "Pref",    FALSE, 0,			{ &PRF_FLAGS(ch),        NULL } },
    { "Pref2",   FALSE, 0,			{ &PRF2_FLAGS(ch),       NULL } },
    { "Pos",    FALSE, POS_STANDING, 		{ &GET_POS(ch),          NULL } },
    { "Prac",   FALSE, MAND,			{ &GET_PRACTICES(ch),    NULL } },
    { "PAlign",  FALSE, 0,			{ &GET_PERMALIGN(ch),    NULL } },
    { "CAlign",  FALSE, 0,			{ &GET_ALIGNMENT(ch),    NULL } },
    { "Ttle",   TRUE,  (int) &def_title,	{ &GET_TITLE(ch),        NULL } },
#if 0
    { "SavThr", FALSE, MAND,			{ &ch->saving_throw,  NULL } },
    { "Hit",    FALSE, MAND,			{ &ch->hitroll,       NULL } },
    { "Dam",    FALSE, MAND,			{ &ch->damroll,       NULL } },
    { "Armr",   FALSE, MAND,			{ &ch->armor,         NULL } },
    { "Wimp",   FALSE, 10,			{ &ch->wimpy,         NULL } },
    { "Deaf",   FALSE, 0,			{ &ch->deaf,          NULL } },
    { "Immskll",TRUE,  DEFLT,			{ &ch->pcdata->immskll,
                                                  NULL } },
    { "AtrPrm", FALSE, MAND,			{ &ch->pcdata->perm_str,
						  &ch->pcdata->perm_int,
						  &ch->pcdata->perm_wis,
						  &ch->pcdata->perm_dex,
						  &ch->pcdata->perm_con,
                                                  NULL } },
    { "AtrMd",  FALSE, MAND,			{ &ch->pcdata->mod_str,
						  &ch->pcdata->mod_int,
						  &ch->pcdata->mod_wis,
						  &ch->pcdata->mod_dex,
						  &ch->pcdata->mod_con,
                                                  NULL } },
    { "Cond",   FALSE, DEFLT,			{ &ch->pcdata->condition [0],
						  &ch->pcdata->condition [1],
						  &ch->pcdata->condition [2],
                                                  NULL } },
    { "Pglen",  FALSE, 20,			{ &ch->pcdata->pagelen,
                                                  NULL } },
    { "Playd",   FALSE, 0,			{ &ch->played,        NULL } },
#endif
    { "Paswd",   TRUE,  MAND,			{ &GET_PASSWD(ch),    NULL } },
    { "Poofin",  TRUE,  DEFLT,			{ &POOFIN(ch),        NULL } },
    { "Poofout", TRUE,  DEFLT,			{ &POOFOUT(ch),       NULL } },
    { "\0",     FALSE, 0                                                   } };
  
  for ( num_keys = 0; *key_tab [num_keys].key; )
    num_keys++;
  
  for ( ; !feof (fp) ; )
  {
    
    word = fread_word_stat( fp, &status );
    
    if ( !word )
    {
      log( "fread_char:  Error reading key.  EOF?" );
      fread_to_eol( fp );
      break;
    }
    
    /* This little diddy searches for the keyword
       from the last keyword found */
    
    for ( i = last_key;
          i < last_key + num_keys &&
                str_cmp (key_tab [i % num_keys].key, word); )
      i++;
    
    i = i % num_keys;
    
    if ( !str_cmp (key_tab [i].key, word) )
      last_key = i;
    else
      i = num_keys;
    
    if ( *key_tab [i].key )         /* Key entry found in key_tab */
    {
      if ( key_tab [i].string == SPECIFIED )
        log( "Key already specified." );
      
      /* Entry is a string */
      
      else
        if ( key_tab [i].string )
        {
          if ( ( p = fread_string( fp, (char*)&status ) ) && !status )
          {
            free( *(char **)key_tab [i].ptrs [0] );
            *(char **)key_tab [i].ptrs [0] = p;
          }
        }
      
      /* Entry is an integer */
        else
          for ( j = 0; key_tab [i].ptrs [j]; j++ )
          {
            tmpi = fread_number_stat( fp, &status );
            if ( !status )
              *(int *)key_tab [i].ptrs [j] = tmpi;
          }
      
      if ( status )
      {
        fread_to_eol( fp );
        continue;
      }
      else
        key_tab [i].string = SPECIFIED;
    }
    
    else if ( *word == '*' || !str_cmp( word, "Nm" ) )
      fread_to_eol( fp );
    
    else if ( !str_cmp( word, "End" ) )
      break;
    
    else if ( !str_cmp( word, "Room" ) )
    {
      ch->in_room = fread_number_stat( fp, &status );
      if ( !ch->in_room )
        ch->in_room = NOWHERE;
    }
    
    else if ( !str_cmp( word, "Race" ) )
    {
      i  = race_lookup( fread_string( fp, (char*)&status ) );
      
      if ( status )
        log( "Fread_char: Unknown Race." );
      else
        GET_RACE(ch) = i;
    }
    
    else if ( !str_cmp( word, "Skill" ) )
    {
      i  = fread_number_stat( fp, &status );
      sn = skill_lookup( fread_word_stat( fp, &status1 ) );
      
      if ( status || status1 )
      {
        log( "Fread_char: Error reading skill." );
        fread_to_eol( fp );
        continue;
      }
      
      if ( sn < 0 )
        log( "Fread_char: unknown skill." );
      else
        GET_SKILL(ch, sn) = i;
    }
    
    else if ( !str_cmp ( word, "Afft" ) )
    {
      
      int status;

      CREATE(paf, struct affected_type, 1);
      memset(paf, 0, sizeof( struct affected_type ));
      
      paf->type           = skill_lookup( fread_string( fp,
                                                        (char*)&status ) );
      paf->duration       = fread_number_stat( fp, &status );
      paf->modifier       = fread_number_stat( fp, &status );
      paf->location       = fread_number_stat( fp, &status );
      paf->bitvector      = fread_number_stat( fp, &status );
      paf->next           = ch->affected;
      ch->affected        = paf;
    }
    
    else
    {
Beispiel #24
0
void
perform_smoke(struct creature *ch, int type)
{

    const char *to_vict = NULL;
    struct affected_type af;
    int hp_mod = 0, mana_mod = 0, move_mod = 0, spell = 0;
    uint8_t lev = 0;
    int accum_dur = 0, accum_affect = 0;

    init_affect(&af);
    af.type = SMOKE_EFFECTS;
    af.level = 30;
    af.owner = GET_IDNUM(ch);

    switch (type) {
    case SMOKE_DIRTWEED:
        to_vict = "Your head hurts.";
        af.duration = 3;
        af.modifier = -2;
        af.location = APPLY_INT;
        af.bitvector = AFF_CONFUSION;
        af.aff_index = 1;
        accum_dur = 1;
        accum_affect = 1;
        move_mod = -number(3, 10);
        mana_mod = -number(1, 2);
        break;
    case SMOKE_DESERTWEED:
        af.location = APPLY_MOVE;
        af.duration = 4;
        af.modifier = 10;
        mana_mod = dice(1, 4);
        move_mod = dice(3, 4);
        break;
    case SMOKE_INDICA:
        to_vict = "Your mind is elevated to another plane.";
        af.location = APPLY_WIS;
        af.duration = 5;
        af.modifier = number(1, 2);
        mana_mod = dice(6, 4);
        move_mod = -number(1, 3);
        break;
    case SMOKE_UNHOLY_REEFER:
        af.location = APPLY_WIS;
        af.duration = 5;
        af.modifier = number(0, 2);
        mana_mod = number(1, 4);
        move_mod = -number(1, 3);
        spell = SPELL_ESSENCE_OF_EVIL;
        lev = 20;
        break;
    case SMOKE_MARIJUANA:
        to_vict = "You feel stoned.";
        af.location = APPLY_INT;
        af.duration = 3;
        af.modifier = -1;
        mana_mod = dice(4, 4);
        break;
    case SMOKE_TOBACCO:
        af.location = APPLY_MOVE;
        af.duration = 3;
        af.modifier = -number(10, 20);
        accum_dur = 1;
        mana_mod = dice(3, 3);
        break;
    case SMOKE_HEMLOCK:
        to_vict = "The smoke burns your lungs!";
        af.location = APPLY_HIT;
        af.duration = number(3, 6);
        af.modifier = -number(30, 60);
        accum_affect = 1;
        hp_mod = -number(10, 16);
        mana_mod = -10;
        move_mod = -10;
        spell = SPELL_POISON;
        lev = LVL_AMBASSADOR;
        break;
    case SMOKE_PEYOTE:
        to_vict = "You feel a strange sensation.";
        spell = SPELL_ASTRAL_SPELL;
        lev = LVL_GRIMP;
        af.location = APPLY_MANA;
        af.modifier = number(10, 20);
        af.duration = number(1, 3);
        move_mod = number(6, 12);
        break;
    case SMOKE_HOMEGROWN:
        to_vict = "There's no place like home...";
        spell = SPELL_WORD_OF_RECALL;
        lev = number(30, 60);
        mana_mod = number(20, 40);
        move_mod = number(2, 10);
        break;

    default:
        af.type = 0;
        break;
    }

    if (to_vict)
        act(to_vict, false, ch, NULL, NULL, TO_CHAR);

    GET_HIT(ch) = MIN(MAX(GET_HIT(ch) + hp_mod, 0), GET_MAX_HIT(ch));
    GET_MANA(ch) = MIN(MAX(GET_MANA(ch) + mana_mod, 0), GET_MAX_MANA(ch));
    GET_MOVE(ch) = MIN(MAX(GET_MOVE(ch) + move_mod, 0), GET_MAX_MOVE(ch));

    if (af.type &&
        (!affected_by_spell(ch, af.type) || accum_affect || accum_dur))
        affect_join(ch, &af, accum_dur, true, accum_affect, true);

    if (spell && lev)
        call_magic(ch, ch, NULL, NULL, spell, (int)lev, CAST_CHEM);

    WAIT_STATE(ch, 6);

}
Beispiel #25
0
// Create a brand new character
struct creature *
account_create_char(struct account *account, const char *name)
{
    struct creature *ch;
    int i;

    if (chars_available(account) <= 0)
        return NULL;

    ch = make_creature(true);

    ch->player.name = strdup(tmp_capitalize(tmp_tolower(name)));
    ch->char_specials.saved.idnum = top_player_idnum() + 1;
    account->chars =
        g_list_append(account->chars, GINT_TO_POINTER(GET_IDNUM(ch)));

    sql_exec
        ("insert into players (idnum, name, account) values (%ld, '%s', %d)",
        GET_IDNUM(ch), tmp_sqlescape(name), account->id);

    // New characters shouldn't get old mail.
    if (has_mail(GET_IDNUM(ch))) {
        if (purge_mail(GET_IDNUM(ch)) > 0) {
            errlog("Purging pre-existing mailfile for new character.(%s)",
                GET_NAME(ch));
        }
    }
    // *** if this is our first player --- he be God ***
    if (GET_IDNUM(ch) == 1) {
        GET_EXP(ch) = 160000000;
        GET_LEVEL(ch) = LVL_GRIMP;

        ch->points.max_hit = 666;
        ch->points.max_mana = 555;
        ch->points.max_move = 444;

        GET_HOME(ch) = HOME_MODRIAN;
        ch->player_specials->saved.load_room = -1;
        ch->player_specials->saved.home_room = 1204;
    } else {
        ch->points.max_hit = 100;
        ch->points.max_mana = 100;
        ch->points.max_move = 82;

        GET_HOME(ch) = HOME_NEWBIE_SCHOOL;
        ch->player_specials->saved.load_room = -1;
        ch->player_specials->saved.home_room = -1;
    }
    ch->player_specials->rentcode = RENT_CREATING;

    set_title(ch, "");

    ch->player.short_descr = NULL;
    ch->player.long_descr = NULL;
    ch->player.description = NULL;

    ch->player.time.birth = time(NULL);
    ch->player.time.death = 0;
    ch->player.time.played = 0;
    ch->player.time.logon = time(NULL);

    for (i = 0; i < MAX_SKILLS; i++)
        ch->player_specials->saved.skills[i] = 0;

    for (i = 0; i < MAX_WEAPON_SPEC; i++) {
        ch->player_specials->saved.weap_spec[i].vnum = 0;
        ch->player_specials->saved.weap_spec[i].level = 0;
    }
    ch->player_specials->saved.imm_qp = 0;
    ch->player_specials->saved.quest_id = 0;
    ch->player_specials->saved.qlog_level = 0;

    GET_REMORT_CLASS(ch) = -1;
    ch->player.weight = 100;
    ch->player.height = 100;

    ch->points.hit = GET_MAX_HIT(ch);
    ch->points.mana = GET_MAX_MANA(ch);
    ch->points.move = GET_MAX_MOVE(ch);
    ch->points.armor = 100;

    SET_BIT(PRF_FLAGS(ch),
        PRF_DISPHP | PRF_DISPMANA | PRF_DISPMOVE | PRF_AUTOEXIT | PRF_NOSPEW |
        PRF_NOPLUG);
    SET_BIT(PRF2_FLAGS(ch),
        PRF2_AUTO_DIAGNOSE | PRF2_AUTOPROMPT | PRF2_DISPALIGN |
        PRF2_NEWBIE_HELPER);

    ch->char_specials.saved.affected_by = 0;
    ch->char_specials.saved.affected2_by = 0;
    ch->char_specials.saved.affected3_by = 0;

    for (i = 0; i < 5; i++)
        GET_SAVE(ch, i) = 0;

    GET_COND(ch, FULL) = (GET_LEVEL(ch) == LVL_GRIMP ? -1 : 24);
    GET_COND(ch, THIRST) = (GET_LEVEL(ch) == LVL_GRIMP ? -1 : 24);
    GET_COND(ch, DRUNK) = (GET_LEVEL(ch) == LVL_GRIMP ? -1 : 0);

    POOFIN(ch) = NULL;
    POOFOUT(ch) = NULL;
    return ch;
}
Beispiel #26
0
void affect_modify(struct char_data * ch, byte loc, sbyte mod, long bitv,
		        bool add)
{
  if (add) {
    SET_BIT(AFF_FLAGS(ch), bitv);
  } else {
    REMOVE_BIT(AFF_FLAGS(ch), bitv);
    mod = -mod;
  }

  switch (loc) {
  case APPLY_NONE:
    break;

  case APPLY_STR:
    GET_STR(ch) += mod;
    break;
  case APPLY_DEX:
    GET_DEX(ch) += mod;
    break;
  case APPLY_INT:
    GET_INT(ch) += mod;
    break;
  case APPLY_WIS:
    GET_WIS(ch) += mod;
    break;
  case APPLY_CON:
    GET_CON(ch) += mod;
    break;
  case APPLY_CHA:
    GET_CHA(ch) += mod;
    break;

  case APPLY_CLASS:
    /* ??? GET_CLASS(ch) += mod; */
    break;

  case APPLY_LEVEL:
    /* ??? GET_LEVEL(ch) += mod; */
    break;

  case APPLY_AGE:
    ch->player.time.birth -= (mod * SECS_PER_MUD_YEAR);
    break;

  case APPLY_CHAR_WEIGHT:
    GET_WEIGHT(ch) += mod;
    break;

  case APPLY_CHAR_HEIGHT:
    GET_HEIGHT(ch) += mod;
    break;

  case APPLY_HIT:
    GET_MAX_HIT(ch) += mod;
    break;

  case APPLY_MOVE:
    GET_MAX_MOVE(ch) += mod;
    break;

  case APPLY_GOLD:
    break;

  case APPLY_EXP:
    break;

  case APPLY_AC:
    GET_AC(ch) += mod;
    break;

  case APPLY_HITROLL:
    GET_HITROLL(ch) += mod;
    break;

  case APPLY_DAMROLL:
    GET_DAMROLL(ch) += mod;
    break;

  case APPLY_SAVING_PARA:
    GET_SAVE(ch, SAVING_PARA) += mod;
    break;

  case APPLY_SAVING_ROD:
    GET_SAVE(ch, SAVING_ROD) += mod;
    break;

  case APPLY_SAVING_PETRI:
    GET_SAVE(ch, SAVING_PETRI) += mod;
    break;

  case APPLY_SAVING_BREATH:
    GET_SAVE(ch, SAVING_BREATH) += mod;
    break;

  case APPLY_SAVING_SPELL:
    GET_SAVE(ch, SAVING_SPELL) += mod;
    break;

  case APPLY_LIGHT:
    break;

  case APPLY_UNDEFINED:
  case APPLY_UNDEFINED_2:
    break;

  default:
    {
      log("SYSERR: Unknown apply adjust %p attempt (%s, affect_modify).",
        log, __FILE__);
    }
    break;

  } /* switch */
}
Beispiel #27
0
/*
 * Alert: As of bpl14, this function returns the following codes:
 *	< 0	Victim died.
 *	= 0	No damage.
 *	> 0	How much damage done.
 */
int damage(struct char_data *ch, struct char_data *victim, int dam, int attacktype)
{
  if (GET_POS(victim) <= POS_DEAD) {
    /* This is "normal"-ish now with delayed extraction. -gg 3/15/2001 */
    if (PLR_FLAGGED(victim, PLR_NOTDEADYET) || MOB_FLAGGED(victim, MOB_NOTDEADYET))
      return (-1);

    log("SYSERR: Attempt to damage corpse '%s' in room #%d by '%s'.",
		GET_NAME(victim), GET_ROOM_VNUM(IN_ROOM(victim)), GET_NAME(ch));
    die(victim);
    return (-1);			/* -je, 7/7/92 */
  }

  /* peaceful rooms */
  if (ch != victim && ROOM_FLAGGED(IN_ROOM(ch), ROOM_PEACEFUL)) {
    send_to_char(ch, "This room just has such a peaceful, easy feeling...\r\n");
    return (0);
  }

  /* shopkeeper protection */
  if (!ok_damage_shopkeeper(ch, victim))
    return (0);

  /* You can't damage an immortal! */
  if (!IS_NPC(victim) && (GET_LEVEL(victim) >= LVL_IMMORT))
    dam = 0;

  if (victim != ch) {
    /* Start the attacker fighting the victim */
    if (GET_POS(ch) > POS_STUNNED && (FIGHTING(ch) == NULL))
      set_fighting(ch, victim);

    /* Start the victim fighting the attacker */
    if (GET_POS(victim) > POS_STUNNED && (FIGHTING(victim) == NULL)) {
      set_fighting(victim, ch);
      if (MOB_FLAGGED(victim, MOB_MEMORY) && !IS_NPC(ch))
	remember(victim, ch);
    }
  }

  /* If you attack a pet, it hates your guts */
  if (victim->master == ch)
    stop_follower(victim);

  /* If the attacker is invisible, he becomes visible */
  if (AFF_FLAGGED(ch, AFF_INVISIBLE | AFF_HIDE))
    appear(ch);

  /* Cut damage in half if victim has sanct, to a minimum 1 */
  if (AFF_FLAGGED(victim, AFF_SANCTUARY) && dam >= 2)
    dam /= 2;

  /* Check for PK if this is not a PK MUD */
  if (!pk_allowed) {
    check_killer(ch, victim);
    if (PLR_FLAGGED(ch, PLR_KILLER) && (ch != victim))
      dam = 0;
  }

  /* Set the maximum damage per round and subtract the hit points */
  dam = MAX(MIN(dam, 100), 0);
  GET_HIT(victim) -= dam;

  /* Gain exp for the hit */
  if (ch != victim)
    gain_exp(ch, GET_LEVEL(victim) * dam);

  update_pos(victim);

  /*
   * skill_message sends a message from the messages file in lib/misc.
   * dam_message just sends a generic "You hit $n extremely hard.".
   * skill_message is preferable to dam_message because it is more
   * descriptive.
   * 
   * If we are _not_ attacking with a weapon (i.e. a spell), always use
   * skill_message. If we are attacking with a weapon: If this is a miss or a
   * death blow, send a skill_message if one exists; if not, default to a
   * dam_message. Otherwise, always send a dam_message.
   */
  if (!IS_WEAPON(attacktype))
    skill_message(dam, ch, victim, attacktype);
  else {
    if (GET_POS(victim) == POS_DEAD || dam == 0) {
      if (!skill_message(dam, ch, victim, attacktype))
	dam_message(dam, ch, victim, attacktype);
    } else {
      dam_message(dam, ch, victim, attacktype);
    }
  }

  /* Use send_to_char -- act() doesn't send message if you are DEAD. */
  switch (GET_POS(victim)) {
  case POS_MORTALLYW:
    act("$n is mortally wounded, and will die soon, if not aided.", TRUE, victim, 0, 0, CommTarget::TO_ROOM);
    send_to_char(victim, "You are mortally wounded, and will die soon, if not aided.\r\n");
    break;
  case POS_INCAP:
    act("$n is incapacitated and will slowly die, if not aided.", TRUE, victim, 0, 0, CommTarget::TO_ROOM);
    send_to_char(victim, "You are incapacitated an will slowly die, if not aided.\r\n");
    break;
  case POS_STUNNED:
    act("$n is stunned, but will probably regain consciousness again.", TRUE, victim, 0, 0, CommTarget::TO_ROOM);
    send_to_char(victim, "You're stunned, but will probably regain consciousness again.\r\n");
    break;
  case POS_DEAD:
    act("$n is dead!  R.I.P.", FALSE, victim, 0, 0, CommTarget::TO_ROOM);
    send_to_char(victim, "You are dead!  Sorry...\r\n");
    break;

  default:			/* >= POSITION SLEEPING */
    if (dam > (GET_MAX_HIT(victim) / 4))
      send_to_char(victim, "That really did HURT!\r\n");

    if (GET_HIT(victim) < (GET_MAX_HIT(victim) / 4)) {
      send_to_char(victim, "%sYou wish that your wounds would stop BLEEDING so much!%s\r\n",
		CCRED(victim, C_SPR), CCNRM(victim, C_SPR));
      if (ch != victim && MOB_FLAGGED(victim, MOB_WIMPY))
	do_flee(victim, NULL, 0, 0);
    }
    if (!IS_NPC(victim) && GET_WIMP_LEV(victim) && (victim != ch) &&
	GET_HIT(victim) < GET_WIMP_LEV(victim) && GET_HIT(victim) > 0) {
      send_to_char(victim, "You wimp out, and attempt to flee!\r\n");
      do_flee(victim, NULL, 0, 0);
    }
    break;
  }

  /* Help out poor linkless people who are attacked */
  if (!IS_NPC(victim) && !(victim->desc) && GET_POS(victim) > POS_STUNNED) {
    do_flee(victim, NULL, 0, 0);
    if (!FIGHTING(victim)) {
      act("$n is rescued by divine forces.", FALSE, victim, 0, 0, CommTarget::TO_ROOM);
      GET_WAS_IN(victim) = IN_ROOM(victim);
      char_from_room(victim);
      char_to_room(victim, 0);
    }
  }

  /* stop someone from fighting if they're stunned or worse */
  if (GET_POS(victim) <= POS_STUNNED && FIGHTING(victim) != NULL)
    stop_fighting(victim);

  /* Uh oh.  Victim died. */
  if (GET_POS(victim) == POS_DEAD) {
    if (ch != victim && (IS_NPC(victim) || victim->desc)) {
      if (AFF_FLAGGED(ch, AFF_GROUP))
	group_gain(ch, victim);
      else
        solo_gain(ch, victim);
    }

    if (!IS_NPC(victim)) {
      mudlog(BRF, LVL_IMMORT, TRUE, "%s killed by %s at %s", GET_NAME(victim), GET_NAME(ch), world[IN_ROOM(victim)].name);
      if (MOB_FLAGGED(ch, MOB_MEMORY))
	forget(ch, victim);
    }
    die(victim);
    return (-1);
  }
  return (dam);
}
Beispiel #28
0
int mag_points_char(struct spell_info_type *sinfo, struct char_data *caster, struct char_data *vict, int level)
{
  int modifier = dice(sinfo->num_dice, sinfo->size_dice);

  if (sinfo->unaffect)
    modifier = -modifier;

  modifier = modBySpecialization(caster, sinfo, modifier);
  gain_exp(caster, modifier * 2);
  switch (sinfo->point_loc) {
    case APPLY_AGE:
      vict->player.time.birth += (SECS_PER_MUD_YEAR * modifier);
      break;
    case APPLY_STR:
      GET_VSTR(vict) += modifier;
      GET_STR(vict) = MIN(100, GET_VSTR(vict));
      break;
    case APPLY_DEX:
      GET_VDEX(vict) += modifier;
      GET_DEX(vict) = MIN(100, GET_VDEX(vict));
      break;
    case APPLY_INT:
      GET_VINT(vict) += modifier;
      GET_INT(vict) = MIN(100, GET_VINT(vict));
      break;
    case APPLY_WIS:
      GET_VWIS(vict) += modifier;
      GET_WIS(vict) = MIN(100, GET_VWIS(vict));
      break;
    case APPLY_CON:
      GET_VCON(vict) += modifier;
      GET_CON(vict) = MIN(100, GET_VCON(vict));
      break;
    case APPLY_AGI:
      GET_VAGI(vict) += modifier;
      GET_AGI(vict) = MIN(100, GET_VAGI(vict));
      break;
    case APPLY_MANA:
      GET_MANA(vict) += modifier;
      if (GET_MANA(vict) > GET_MAX_MANA(vict))
        GET_MANA(vict) = GET_MAX_MANA(vict);
      break;
    case APPLY_HIT:
      GET_HIT(vict) += modifier;
      if (GET_HIT(vict) > GET_MAX_HIT(vict))
        GET_HIT(vict) = GET_MAX_HIT(vict);
      break;
    case APPLY_MOVE:
      GET_MOVE(vict) += modifier;
      if (GET_MOVE(vict) > GET_MAX_MOVE(vict))
        GET_MOVE(vict) = GET_MAX_MOVE(vict);
      break;
    case APPLY_HITROLL:
      GET_HITROLL(vict) += modifier;
      break;
    case APPLY_DAMROLL:
      GET_DAMROLL(vict) += modifier;
      break;
    case APPLY_SAVING_PARA:
      GET_SAVE(vict,SAVING_PARA) += modifier;
      break;
    case APPLY_SAVING_ROD:
      GET_SAVE(vict,SAVING_ROD) += modifier;
      break;
    case APPLY_SAVING_PETRI:
      GET_SAVE(vict,SAVING_PETRI) += modifier;
      break;
    case APPLY_SAVING_BREATH:
      GET_SAVE(vict,SAVING_BREATH) += modifier;
      break;
    case APPLY_SAVING_SPELL:
      GET_SAVE(vict,SAVING_SPELL) += modifier;
      break;
    case APPLY_MAX_HIT:
      GET_MAX_HIT(vict) += modifier;
      break;
    case APPLY_MAX_MANA:
      GET_MAX_MANA(vict) += modifier;
      break;
    case APPLY_MAX_MOVE:
      GET_MAX_MOVE(vict) += modifier;
      break;
    case APPLY_RES_DARK:
      GET_RESIST(vict, DAM_DARK) += modifier;
      break;
    case APPLY_RES_FIRE:
      GET_RESIST(vict, DAM_FIRE) += modifier;
      break;
    case APPLY_RES_COLD:
      GET_RESIST(vict, DAM_COLD) += modifier;
      break;
    case APPLY_RES_ACID:
      GET_RESIST(vict, DAM_ACID) += modifier;
      break;
    case APPLY_RES_POISON:
      GET_RESIST(vict, DAM_POISON) += modifier;
      break;
    case APPLY_RES_DISEASE:
      GET_RESIST(vict, DAM_DISEASE) += modifier;
      break;
    case APPLY_RES_CHARM:
      GET_RESIST(vict, DAM_CHARM) += modifier;
      break;
    case APPLY_RES_SLEEP:
      GET_RESIST(vict, DAM_SLEEP) += modifier;
      break;
    case APPLY_RES_SLASH:
      GET_RESIST(vict, DAM_SLASH) += modifier;
      break;
    case APPLY_RES_PIERCE:
      GET_RESIST(vict, DAM_PIERCE) += modifier;
      break;
    case APPLY_RES_BLUDGEON:
      GET_RESIST(vict, DAM_BLUDGEON) += modifier;
      break;
    case APPLY_RES_NWEAP:
      GET_RESIST(vict, DAM_NWEAP) += modifier;
      break;
    case APPLY_RES_MWEAP:
      GET_RESIST(vict, DAM_MWEAP) += modifier;
      break;
    case APPLY_RES_MAGIC:
      GET_RESIST(vict, DAM_MAGIC) += modifier;
      break;
    case APPLY_RES_ELECTRICITY:
      GET_RESIST(vict, DAM_ELECTRICITY) += modifier;
      break;
  }
  return 1;
}
Beispiel #29
0
/* Update PCs, NPCs, and objects */
void point_update(void)
{
  struct char_data *i, *next_char;
  struct obj_data *j, *next_thing, *jj, *next_thing2;

  /* characters */
  for (i = character_list; i; i = next_char) {
    next_char = i->next;
	
    gain_condition(i, FULL, -1);
    gain_condition(i, DRUNK, -1);
    gain_condition(i, THIRST, -1);
	
    if (GET_POS(i) >= POS_STUNNED) {
      GET_HIT(i) = MIN(GET_HIT(i) + hit_gain(i), GET_MAX_HIT(i));
      GET_MANA(i) = MIN(GET_MANA(i) + mana_gain(i), GET_MAX_MANA(i));
      GET_MOVE(i) = MIN(GET_MOVE(i) + move_gain(i), GET_MAX_MOVE(i));
      if (AFF_FLAGGED(i, AFF_POISON))
	if (damage(i, i, 2, SPELL_POISON) == -1)
	  continue;	/* Oops, they died. -gg 6/24/98 */
      if (GET_POS(i) <= POS_STUNNED)
	update_pos(i);
    } else if (GET_POS(i) == POS_INCAP) {
      if (damage(i, i, 1, TYPE_SUFFERING) == -1)
	continue;
    } else if (GET_POS(i) == POS_MORTALLYW) {
      if (damage(i, i, 2, TYPE_SUFFERING) == -1)
	continue;
    }
    if (!IS_NPC(i)) {
      update_char_objects(i);
      if (GET_LEVEL(i) < idle_max_level)
	check_idling(i);
    }
  }

  /* objects */
  for (j = object_list; j; j = next_thing) {
    next_thing = j->next;	/* Next in object list */

    /* If this is a corpse */
    if (IS_CORPSE(j)) {
      /* timer count down */
      if (GET_OBJ_TIMER(j) > 0)
	GET_OBJ_TIMER(j)--;

      if (!GET_OBJ_TIMER(j)) {

	if (j->carried_by)
	  act("$p decays in your hands.", FALSE, j->carried_by, j, 0, TO_CHAR);
	else if ((IN_ROOM(j) != NOWHERE) && (world[IN_ROOM(j)].people)) {
	  act("A quivering horde of maggots consumes $p.",
	      TRUE, world[IN_ROOM(j)].people, j, 0, TO_ROOM);
	  act("A quivering horde of maggots consumes $p.",
	      TRUE, world[IN_ROOM(j)].people, j, 0, TO_CHAR);
	}
	for (jj = j->contains; jj; jj = next_thing2) {
	  next_thing2 = jj->next_content;	/* Next in inventory */
	  obj_from_obj(jj);

	  if (j->in_obj)
	    obj_to_obj(jj, j->in_obj);
	  else if (j->carried_by)
	    obj_to_room(jj, IN_ROOM(j->carried_by));
	  else if (IN_ROOM(j) != NOWHERE)
	    obj_to_room(jj, IN_ROOM(j));
	  else
	    core_dump();
	}
	extract_obj(j);
      }
    }
    /* If the timer is set, count it down and at 0, try the trigger */
    /* note to .rej hand-patchers: make this last in your point-update() */
    else if (GET_OBJ_TIMER(j)>0) {
      GET_OBJ_TIMER(j)--; 
      if (!GET_OBJ_TIMER(j))
        timer_otrigger(j);
    }
  }
}
Beispiel #30
0
bool
psionic_mob_fight(struct creature *ch, struct creature *precious_vict)
{
    struct creature *vict = NULL;

    if (!is_fighting(ch))
        return false;

    // pick an enemy
    if (!(vict = choose_opponent(ch, precious_vict)))
        return false;

    int aggression = calculate_mob_aggression(ch, vict);

    // Psions can't really do anything when there's a psishield in place
    if (AFF3_FLAGGED(vict, AFF3_PSISHIELD)
        && can_cast_spell(ch, SPELL_PSIONIC_SHATTER)) {
        cast_spell(ch, vict, NULL, NULL, SPELL_PSIONIC_SHATTER);
        return true;
    }
    // Prioritize healing with aggression
    if (GET_HIT(ch) < (GET_MAX_HIT(ch) * MIN(20, MAX(80, aggression)) / 100)
        && can_cast_spell(ch, SPELL_WOUND_CLOSURE)) {
        cast_spell(ch, ch, NULL, NULL, SPELL_WOUND_CLOSURE);
        return true;
    }

    if (aggression > 75) {
        // extremely aggressive - just attack hard
        if (can_cast_spell(ch, SKILL_PSIBLAST)) {
            perform_offensive_skill(ch, vict, SKILL_PSIBLAST);
            return true;
        } else if (GET_POSITION(vict) > POS_SITTING
            && can_cast_spell(ch, SPELL_EGO_WHIP)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_EGO_WHIP);
            return true;
        }
    }
    if (aggression > 50) {
        // somewhat aggressive - balance attacking with crippling
        if (GET_MANA(ch) < GET_MAX_MANA(ch) / 2
            && can_cast_spell(ch, SKILL_PSIDRAIN)
            && can_psidrain(ch, vict, NULL, false)) {
            perform_psidrain(ch, vict);
            return true;
        } else if (!affected_by_spell(vict, SPELL_PSYCHIC_CRUSH)
            && can_cast_spell(ch, SPELL_PSYCHIC_CRUSH)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_PSYCHIC_CRUSH);
            return true;
        } else if (!affected_by_spell(vict, SPELL_MOTOR_SPASM)
            && can_cast_spell(ch, SPELL_MOTOR_SPASM)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_MOTOR_SPASM);
            return true;
        } else if (!affected_by_spell(ch, SPELL_ADRENALINE)
            && can_cast_spell(ch, SPELL_ADRENALINE)) {
            cast_spell(ch, ch, NULL, NULL, SPELL_ADRENALINE);
            return true;
        } else if (GET_POSITION(vict) > POS_SITTING
            && can_cast_spell(ch, SPELL_EGO_WHIP)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_EGO_WHIP);
            return true;
        } else if (can_cast_spell(ch, SKILL_PSIBLAST)) {
            perform_offensive_skill(ch, vict, SKILL_PSIBLAST);
            return true;
        }
    }
    if (aggression > 25) {
        // not very aggressive - play more defensively
        if (IS_PSIONIC(vict)
            && !affected_by_spell(ch, SPELL_PSYCHIC_RESISTANCE)
            && can_cast_spell(ch, SPELL_PSYCHIC_RESISTANCE)) {
            cast_spell(ch, ch, NULL, NULL, SPELL_PSYCHIC_RESISTANCE);
            return true;
        } else if (!IS_CONFUSED(vict)
            && can_cast_spell(ch, SPELL_CONFUSION)
            && (IS_MAGE(vict) || IS_PSIONIC(vict) || IS_CLERIC(vict) ||
                IS_KNIGHT(vict) || IS_PHYSIC(vict))) {
            cast_spell(ch, vict, NULL, NULL, SPELL_CONFUSION);
            return true;
        } else if (GET_MOVE(ch) < GET_MAX_MOVE(ch) / 4
            && can_cast_spell(ch, SPELL_ENDURANCE)) {
            cast_spell(ch, ch, NULL, NULL, SPELL_ENDURANCE);
            return true;
        } else if (GET_MOVE(ch) < GET_MAX_MOVE(ch) / 4
            && can_cast_spell(ch, SPELL_DERMAL_HARDENING)) {
            cast_spell(ch, ch, NULL, NULL, SPELL_DERMAL_HARDENING);
            return true;
        } else if (!AFF2_FLAGGED(ch, AFF2_VERTIGO)
            && can_cast_spell(ch, SPELL_VERTIGO)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_VERTIGO);
            return true;
        } else if (!affected_by_spell(vict, SPELL_PSYCHIC_FEEDBACK)
            && can_cast_spell(ch, SPELL_PSYCHIC_FEEDBACK)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_PSYCHIC_FEEDBACK);
            return true;
        } else if (!affected_by_spell(vict, SPELL_WEAKNESS)
            && can_cast_spell(ch, SPELL_WEAKNESS)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_WEAKNESS);
            return true;
        } else if (!affected_by_spell(vict, SPELL_CLUMSINESS)
            && can_cast_spell(ch, SPELL_CLUMSINESS)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_CLUMSINESS);
            return true;
        } else if (can_cast_spell(ch, SKILL_PSIBLAST)) {
            perform_offensive_skill(ch, vict, SKILL_PSIBLAST);
            return true;
        }
    }
    if (aggression > 5) {
        // attempt to neutralize or get away
        if (GET_POSITION(vict) > POS_SLEEPING
            && can_cast_spell(ch, SPELL_MELATONIC_FLOOD)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_MELATONIC_FLOOD);
            return true;
        } else if (can_cast_spell(ch, SPELL_ASTRAL_SPELL)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_ASTRAL_SPELL);
            return true;
        } else if (can_cast_spell(ch, SPELL_AMNESIA)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_AMNESIA);
            return true;
        } else if (can_cast_spell(ch, SPELL_FEAR)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_FEAR);
            return true;
        }
    }

    return false;
}