예제 #1
0
파일: hit.c 프로젝트: AhmadTux/DragonFlyBSD
void
mon_hit(object *monster)
{
	short damage, hit_chance;
	const char *mn;
	float minus;

	if (fight_monster && (monster != fight_monster)) {
		fight_monster = NULL;
	}
	monster->trow = NO_ROOM;
	if (cur_level >= (AMULET_LEVEL * 2)) {
		hit_chance = 100;
	} else {
		hit_chance = monster->m_hit_chance;
		hit_chance -= (((2 * rogue.exp) + (2 * ring_exp)) - r_rings);
	}
	if (wizard) {
		hit_chance /= 2;
	}
	if (!fight_monster) {
		interrupted = 1;
	}
	mn = mon_name(monster);

	if (!rand_percent(hit_chance)) {
		if (!fight_monster) {
			sprintf(hit_message + strlen(hit_message), "the %s misses", mn);
			message(hit_message, 1);
			hit_message[0] = 0;
		}
		return;
	}
	if (!fight_monster) {
		sprintf(hit_message + strlen(hit_message), "the %s hit", mn);
		message(hit_message, 1);
		hit_message[0] = 0;
	}
	if (!(monster->m_flags & STATIONARY)) {
		damage = get_damage(monster->m_damage, 1);
		if (cur_level >= (AMULET_LEVEL * 2)) {
			minus = (float)((AMULET_LEVEL * 2) - cur_level);
		} else {
			minus = (float)get_armor_class(rogue.armor) * 3.00;
			minus = minus / 100.00 * (float)damage;
		}
		damage -= (short)minus;
	} else {
		damage = monster->stationary_damage++;
	}
	if (wizard) {
		damage /= 3;
	}
	if (damage > 0) {
		rogue_damage(damage, monster, 0);
	}
	if (monster->m_flags & SPECIAL_HIT) {
		special_hit(monster);
	}
}
예제 #2
0
void
freeze(object *monster)
{
    short freeze_percent = 99;
    short i, n;

    if (rand_percent(12)) {
	return;
    }
    freeze_percent -= (rogue.str_current + (rogue.str_current / 2));
    freeze_percent -= ((rogue.exp + ring_exp) * 4);
    freeze_percent -= (get_armor_class(rogue.armor) * 5);
    freeze_percent -= (rogue.hp_max / 3);

    if (freeze_percent > 10) {
	monster->m_flags |= FREEZING_ROGUE;
	message(mesg[203], 1);
	n = get_rand(4, 8);
	for (i = 0; i < n; i++) {
	    mv_mons();
	}
	if (rand_percent(freeze_percent)) {
	    for (i = 0; i < 50; i++) {
		mv_mons();
	    }
	    killed_by((object *) 0, HYPOTHERMIA);
	}
	message(you_can_move_again, 1);
	monster->m_flags &= (~FREEZING_ROGUE);
    }
}
예제 #3
0
void
rust(object *monster)
{
    if ((!rogue.armor) || (get_armor_class(rogue.armor) <= 1) ||
	(rogue.armor->which_kind == LEATHER)) {
	return;
    }
    if ((rogue.armor->is_protected) || maintain_armor) {
	if (monster && (!(monster->m_flags & RUST_VANISHED))) {
	    message(mesg[201], 0);
	    monster->m_flags |= RUST_VANISHED;
	}
    } else {
	rogue.armor->d_enchant--;
	message(mesg[202], 0);
	print_stats(STAT_ARMOR);
    }
}
예제 #4
0
void
sting(object *monster)
{
    short sting_chance = 35;
    char msg[80];

    if ((rogue.str_current <= 3) || sustain_strength) {
	return;
    }
    sting_chance += (6 * (6 - get_armor_class(rogue.armor)));

    if ((rogue.exp + ring_exp) > 8) {
	sting_chance -= (6 * ((rogue.exp + ring_exp) - 8));
    }
    if (rand_percent(sting_chance)) {
	sprintf(msg, mesg[207], mon_name(monster));
	message(msg, 0);
	rogue.str_current--;
	print_stats(STAT_STRENGTH);
    }
}
예제 #5
0
void
print_stats(int stat_mask)
{
    char buf[16];
    boolean label;
    int row = ROGUE_LINES - 1;

    label = (stat_mask & STAT_LABEL) ? 1 : 0;

    if (stat_mask & STAT_LEVEL) {
	if (label) {
	    mvaddstr_rogue(row, 0, mesg[56]);
	}
	/* max level taken care of in make_level() */
	sprintf(buf, "%d", cur_level);
#if defined( JAPAN )
	mvaddstr_rogue(row, 4, buf);
#else /* not JAPAN */
	mvaddstr_rogue(row, 7, buf);
#endif /* not JAPAN */
	pad(buf, 2);
    }
    if (stat_mask & STAT_GOLD) {
	if (label) {
	    if (rogue.gold > MAX_GOLD) {
		rogue.gold = MAX_GOLD;
	    }
#if defined( JAPAN )
	    mvaddstr_rogue(row, 7, mesg[57]);
#else /* not JAPAN */
	    mvaddstr_rogue(row, 10, mesg[57]);
#endif /* not JAPAN */
	}
	sprintf(buf, "%ld", rogue.gold);
#if defined( JAPAN )
	mvaddstr_rogue(row, 13, buf);
#else /* not JAPAN */
	mvaddstr_rogue(row, 16, buf);
#endif /* not JAPAN */
	pad(buf, 6);
    }
    if (stat_mask & STAT_HP) {
	if (label) {
#if defined( JAPAN )
	    mvaddstr_rogue(row, 20, mesg[58]);
#else /* not JAPAN */
	    mvaddstr_rogue(row, 23, mesg[58]);
#endif /* not JAPAN */
	    if (rogue.hp_max > MAX_HP) {
		rogue.hp_current -= (rogue.hp_max - MAX_HP);
		rogue.hp_max = MAX_HP;
	    }
	}
	sprintf(buf, "%d(%d)", rogue.hp_current, rogue.hp_max);
#if defined( JAPAN )
	mvaddstr_rogue(row, 26, buf);
#else /* not JAPAN */
	mvaddstr_rogue(row, 27, buf);
#endif /* not JAPAN */
	pad(buf, 8);
    }
    if (stat_mask & STAT_STRENGTH) {
	if (label) {
#if defined( JAPAN )
	    mvaddstr_rogue(row, 35, mesg[59]);
#else /* not JAPAN */
	    mvaddstr_rogue(row, 36, mesg[59]);
#endif /* not JAPAN */
	}
	if (rogue.str_max > MAX_STRENGTH) {
	    rogue.str_current -= (rogue.str_max - MAX_STRENGTH);
	    rogue.str_max = MAX_STRENGTH;
	}
	sprintf(buf, "%d(%d)", (rogue.str_current + add_strength),
		rogue.str_max);
	mvaddstr_rogue(row, 41, buf);
	pad(buf, 6);
    }
    if (stat_mask & STAT_ARMOR) {
	if (label) {
	    mvaddstr_rogue(row, 48, mesg[60]);
	}
	if (rogue.armor && (rogue.armor->d_enchant > MAX_ARMOR)) {
	    rogue.armor->d_enchant = MAX_ARMOR;
	}
	sprintf(buf, "%d", get_armor_class(rogue.armor));
#if defined( JAPAN )
	mvaddstr_rogue(row, 54, buf);
#else /* not JAPAN */
	mvaddstr_rogue(row, 53, buf);
#endif /* not JAPAN */
	pad(buf, 2);
    }
    if (stat_mask & STAT_EXP) {
	if (label) {
#if defined( JAPAN )
	    mvaddstr_rogue(row, 57, mesg[61]);
#else /* not JAPAN */
	    mvaddstr_rogue(row, 56, mesg[61]);
#endif /* not JAPAN */
	}
	/*  Max exp taken care of in add_exp() */
	sprintf(buf, "%d/%ld", rogue.exp, rogue.exp_points);
#if defined( JAPAN )
	mvaddstr_rogue(row, 63, buf);
#else /* not JAPAN */
	mvaddstr_rogue(row, 61, buf);
#endif /* not JAPAN */
	pad(buf, 11);
    }
    if (stat_mask & STAT_HUNGER) {
#if defined( JAPAN )
	mvaddstr_rogue(row, 75, hunger_str);
	clrtoeol();
#else /* not JAPAN */
	mvaddstr_rogue(row, 73, hunger_str);
	clrtoeol();
#endif /* not JAPAN */
    }
    refresh();
}
예제 #6
0
void get_desc( object *obj, char *desc, boolean capitalize )
{
	char *item_name;
	struct id *id_table;
	char more_info[32];
	short i;

	if (obj->what_is == AMULET)
	{
		if( capitalize )
			(void) strcpy(desc, "The Amulet of Yendor ") ;
		else
			(void) strcpy(desc, "the Amulet of Yendor ") ;
		return;
	}
	item_name = name_of(obj);

	if (obj->what_is == GOLD)
	{
		sprintf(desc, "%d pieces of gold.", obj->quantity);
		return;
	}

	if (obj->what_is != ARMOR)
	{
		if (obj->quantity == 1)
		{
			if( capitalize )
				(void) strcpy(desc, "A ") ;
			else
				(void) strcpy(desc, "a ") ;
		}
		else
		{
			sprintf(desc, "%d ", obj->quantity);
		}
	}
	if (obj->what_is == FOOD)
	{
		if (obj->which_kind == RATION)
		{
			if (obj->quantity > 1)
			{
				sprintf( desc, "%d rations of %s", obj->quantity, item_name ) ;
			}
			else
			{
				if( capitalize )
					sprintf( desc, "A ration of %s", item_name ) ;
				else
					sprintf( desc, "a ration of %s", item_name ) ;
			}
		}
		// (zerogue 0.4.1) Add stack description for fruits.
		else
		{
			if( obj->quantity > 1 )
				sprintf( desc, "%d %s", obj->quantity, item_name ) ;
			else
			{
				if( capitalize )
					sprintf( desc, "A %s", item_name ) ;
				else
					sprintf( desc, "a %s", item_name ) ;
			}
		}
		goto ANA;
	}
	id_table = get_id_table(obj);

	if (wizard)
	{
		goto ID;
	}
	if (obj->what_is & (WEAPON | ARMOR | WAND | RING))
	{
		goto CHECK;
	}

	switch(id_table[obj->which_kind].id_status)
	{
	case UNIDENTIFIED:
CHECK:
		switch(obj->what_is)
		{
		case SCROLL:
			(void) strcat(desc, item_name);
			(void) strcat(desc, "entitled: ");
			(void) strcat(desc, id_table[obj->which_kind].title);
			break;
		case POTION:
			(void) strcat(desc, id_table[obj->which_kind].title);
			(void) strcat(desc, item_name);
			break;
		case WAND:
		case RING:
			if (obj->identified
			    || (id_table[obj->which_kind].id_status == IDENTIFIED))
			{
				goto ID;
			}
			if (id_table[obj->which_kind].id_status == CALLED)
			{
				goto CALL;
			}
			(void) strcat(desc, id_table[obj->which_kind].title);
			(void) strcat(desc, item_name);
			break;
		case ARMOR:
			if (obj->identified)
			{
				goto ID;
			}
			(void) strcpy(desc, id_table[obj->which_kind].title);
			break;
		case WEAPON:
			if (obj->identified)
			{
				goto ID;
			}
			(void) strcat(desc, name_of(obj));
			break;
		}
		break;
	case CALLED:
CALL:	switch(obj->what_is)
	{
		case SCROLL:
		case POTION:
		case WAND:
		case RING:
			(void) strcat(desc, item_name);
			(void) strcat(desc, "called ");
			(void) strcat(desc, id_table[obj->which_kind].title);
			break;
		}
		break;
	case IDENTIFIED:
ID:		switch(obj->what_is)
		{
		case SCROLL:
		case POTION:
			(void) strcat(desc, item_name);
			(void) strcat(desc, id_table[obj->which_kind].real);
			break;
		case RING:
			if (wizard || obj->identified)
			{
				if ((obj->which_kind == DEXTERITY) ||
					(obj->which_kind == ADD_STRENGTH))
				{
					sprintf(more_info, "%s%d ", ((obj->oclass > 0) ? "+" : ""),
						obj->oclass);
					(void) strcat(desc, more_info);
				}
			}
			(void) strcat(desc, item_name);
			(void) strcat(desc, id_table[obj->which_kind].real);
			break;
		case WAND:
			(void) strcat(desc, item_name);
			(void) strcat(desc, id_table[obj->which_kind].real);
			if (wizard || obj->identified)
			{
				sprintf(more_info, "[%d]", obj->oclass);
				(void) strcat(desc, more_info);
			}
			break;
		case ARMOR:
			sprintf(desc, "%s%d ", ((obj->d_enchant >= 0) ? "+" : ""),
			obj->d_enchant);
			(void) strcat(desc, id_table[obj->which_kind].title);
			sprintf( more_info, "[%d%s%s] ", get_armor_class(obj), (obj->is_protected ? "+" : ""), (obj->is_cursed ? "-" : "") ) ;
			(void) strcat(desc, more_info);
			break;
		case WEAPON:
			sprintf(desc+strlen(desc), "%s%d,%s%d ",
			((obj->hit_enchant >= 0) ? "+" : ""),
			obj->hit_enchant,
			((obj->d_enchant >= 0) ? "+" : ""),
			obj->d_enchant);
			(void) strcat(desc, name_of(obj));
			break;
		}
		break;
	}
ANA:
	if (!strncmp(desc, "a ", 2))
	{
		if (is_vowel(desc[2]))
		{
			for (i = strlen(desc) + 1; i > 1; i--)
			{
				desc[i] = desc[i-1];
			}
			desc[1] = 'n';
		}
	}
	if (obj->in_use_flags & BEING_WIELDED) {
		(void) strcat(desc, "in hand");
	} else if (obj->in_use_flags & BEING_WORN) {
		(void) strcat(desc, "being worn");
	} else if (obj->in_use_flags & ON_LEFT_HAND) {
		(void) strcat(desc, "on left hand");
	} else if (obj->in_use_flags & ON_RIGHT_HAND) {
		(void) strcat(desc, "on right hand");
	}
}
예제 #7
0
파일: invent.c 프로젝트: masoo/rogueclone2s
void
get_desc(object *obj, char *desc, bool capitalized)
{
    char *item_name, *p;
    struct id *id_table;
    char more_info[32];
    short i;

    *desc = 0;
    if (obj->what_is == AMULET) {
	(void) strcpy(desc, mesg[27]);
	return;
    }
    item_name = name_of(obj);
    if (obj->what_is == GOLD) {
	znum(desc, obj->quantity, 0);
	strcat(desc, mesg[28]);
	return;
    }
    if (obj->what_is == WEAPON && obj->quantity > 1) {
	znum(desc, obj->quantity, 0);
	strcat(desc, mesg[29]);
    } else if (obj->what_is == FOOD) {
	znum(desc, obj->quantity, 0);
	strcat(desc, (obj->which_kind == RATION) ? mesg[30] : mesg[31]);
	(void) strcat(desc, item_name);
	goto ANA;
    } else if (obj->what_is != ARMOR && obj->quantity > 1) {
	znum(desc, obj->quantity, 0);
	strcat(desc, mesg[32]);
    }
    id_table = get_id_table(obj);

    if (wizard) {
	goto ID;
    }
    if (obj->what_is & (WEAPON | ARMOR | WAND | RING)) {
	goto CHECK;
    }

    switch (id_table[obj->which_kind].id_status) {
    case UNIDENTIFIED:
    CHECK:
	switch (obj->what_is) {
	case SCROL:
	    (void) strcat(desc, id_table[obj->which_kind].title);
	    (void) strcat(desc, mesg[33]);
	    (void) strcat(desc, item_name);
	    break;
	case POTION:
	    (void) strcat(desc, id_table[obj->which_kind].title);
	    (void) strcat(desc, item_name);
	    break;
	case WAND:
	case RING:
	    if (obj->identified ||
		(id_table[obj->which_kind].id_status == IDENTIFIED)) {
		goto ID;
	    }
	    if (id_table[obj->which_kind].id_status == CALLED) {
		goto CALL;
	    }
	    (void) strcat(desc, id_table[obj->which_kind].title);
	    (void) strcat(desc, item_name);
	    break;
	case ARMOR:
	    if (obj->identified) {
		goto ID;
	    }
	    (void) strcpy(desc, id_table[obj->which_kind].title);
	    break;
	case WEAPON:
	    if (obj->identified) {
		goto ID;
	    }
	    (void) strcat(desc, name_of(obj));
	    break;
	}
	break;
    case CALLED:
    CALL:
	switch (obj->what_is) {
	case SCROL:
	case POTION:
	case WAND:
	case RING:
	    p = id_table[obj->which_kind].title;
#if defined( EUC )
	    if (*desc && *p >= ' ' && !(0x80 & *p)) {
		(void) strcat(desc, " ");
	    }
#else /* not EUC(Shift JIS) */
	    if (*desc && (*p >= ' ' && *p <= '~' || *p >= '\240' && *p < '\340')) {
		(void) strcat(desc, " ");
	    }
#endif /* not EUC */
	    (void) strcat(desc, p);
	    (void) strcat(desc, mesg[34]);
	    (void) strcat(desc, item_name);
	    break;
	}
	break;
    case IDENTIFIED:
    ID:
	switch (obj->what_is) {
	case SCROL:
	case POTION:
	    (void) strcat(desc, id_table[obj->which_kind].real);
	    (void) strcat(desc, item_name);
	    break;
	case RING:
	    (void) strcat(desc, id_table[obj->which_kind].real);
	    if (wizard || obj->identified) {
		if ((obj->which_kind == DEXTERITY) ||
		    (obj->which_kind == ADD_STRENGTH)) {
		    strcpy(more_info, "(");
		    znum(more_info, obj->class, 1);
		    strcat(more_info, ")");
		    (void) strcat(desc, more_info);
		}
	    }
	    (void) strcat(desc, item_name);
	    break;
	case WAND:
	    (void) strcat(desc, id_table[obj->which_kind].real);
	    (void) strcat(desc, item_name);
	    if (wizard || obj->identified) {
		strcpy(more_info, "[");
		znum(more_info, obj->class, 0);
		strcat(more_info, "]");
		(void) strcat(desc, more_info);
	    }
	    break;
	case ARMOR:
	    strcpy(desc, "(");
	    znum(desc, obj->d_enchant, 1);
	    strcat(desc, ")");
	    (void) strcat(desc, id_table[obj->which_kind].title);
	    strcpy(more_info, "[");
	    znum(more_info, get_armor_class(obj), 0);
	    strcat(more_info, "]");
	    (void) strcat(desc, more_info);
	    break;
	case WEAPON:
	    strcat(desc, "(");
	    znum(desc, obj->hit_enchant, 1);
	    strcat(desc, ",");
	    znum(desc, obj->d_enchant, 1);
	    strcat(desc, ")");
	    (void) strcat(desc, name_of(obj));
	    break;
	}
예제 #8
0
void print_stats(int stat_mask)
{
	char buf[16];
	boolean label;
	int row = DROWS - 1;

	label = (stat_mask & STAT_LABEL) ? 1 : 0;

	if (stat_mask & STAT_LEVEL)
	{
		if (label)
		{
			mvaddstr(row, 0, "Level: ");
		}
		/* max level taken care of in make_level() */
		sprintf(buf, "%d", cur_level);
		mvaddstr(row, 7, buf);
		pad(buf, 2);
	}
	if (stat_mask & STAT_GOLD)
	{
		if (label)
		{
			if (rogue.gold > MAX_GOLD)
			{
				rogue.gold = MAX_GOLD;
			}
			mvaddstr(row, 10, "Gold: ");
		}
		sprintf(buf, "%ld", rogue.gold);
		mvaddstr(row, 16, buf);
		pad(buf, 6);
	}
	if (stat_mask & STAT_HP)
	{
		if (label)
		{
			mvaddstr(row, 23, "HP: ");
			if (rogue.hp_max > MAX_HP)
			{
				rogue.hp_current -= (rogue.hp_max - MAX_HP);
				rogue.hp_max = MAX_HP;
			}
		}
		sprintf(buf, "%d(%d)", rogue.hp_current, rogue.hp_max);
		mvaddstr(row, 27, buf);
		pad(buf, 8);
	}
	if (stat_mask & STAT_STRENGTH)
	{
		if (label)
		{
			mvaddstr(row, 36, "Str: ");
		}
		if (rogue.str_max > MAX_STRENGTH)
		{
			rogue.str_current -= (rogue.str_max - MAX_STRENGTH);
			rogue.str_max = MAX_STRENGTH;
		}
		sprintf(buf, "%d(%d)", (rogue.str_current + add_strength), rogue.str_max);
		mvaddstr(row, 41, buf);
		pad(buf, 6);
	}
	if (stat_mask & STAT_ARMOR)
	{
		if (label)
		{
			mvaddstr(row, 48, "Arm: ");
		}
		if (rogue.armor && (rogue.armor->d_enchant > MAX_ARMOR))
		{
			rogue.armor->d_enchant = MAX_ARMOR;
		}
		sprintf(buf, "%d", get_armor_class(rogue.armor));
		mvaddstr(row, 53, buf);
		pad(buf, 2);
	}
	if (stat_mask & STAT_EXP)
	{
		if (label)
		{
			mvaddstr(row, 56, "Exp: ");
		}
		/*  Max exp taken care of in add_exp() */
		/* (zerogue 0.4.1) Adds markers if a level modifier is in effect. */
		if( expmod != 0 )
			sprintf( buf, "[%d]/%ld", get_rogue_level(1), rogue.exp_points) ;
		else
			sprintf(buf, "%d/%ld", rogue.exp, rogue.exp_points) ;
			
		mvaddstr(row, 61, buf);
		pad(buf, 11);
	}
	if (stat_mask & STAT_HUNGER)
	{
		mvaddstr(row, 73, hunger_str);
		clrtoeol();
	}
	refresh();
}