Compare commits

...

6 Commits

Author SHA1 Message Date
yk e1ed67a1cf yk
1 year ago
yk 862f1a236c yk
1 year ago
yk 7a0a885c06 yk
1 year ago
yk 10a2674705 yk
1 year ago
yk ae47fc013e i miss you
1 year ago
yk c9aefff673 sb
1 year ago

@ -230,60 +230,77 @@ kick_monster(struct monst *mon, coordxy x, coordxy y)
* [80%-90%) | 1/3 | 1/2
* [90%-100%) | 1/2 | 1
*/
if (i < (j * 3) / 10) {
if (!rn2((i < j / 10) ? 2 : (i < j / 5) ? 3 : 4)) {
if (martial())
goto doit;
Your("clumsy kick does no damage.");
(void) passive(mon, uarmf, FALSE, 1, AT_KICK, FALSE);
/* This is a C language code snippet that describes a player character's kicking action in a game. */
if (i < (j * 3) / 10) {
/* If the condition (i < (j * 3) / 10) is true, execute the following code block: */
if (!rn2((i < j / 10) ? 2 : (i < j / 5) ? 3 : 4)) {
/* If the result of rn2((i < j / 10) ? 2 : (i < j / 5) ? 3 : 4) is false (0), do the following: */
if (martial()) {
goto doit;
} else {
/* Output "Your clumsy kick does no damage." and call passive() function, then return. */
pline("Your clumsy kick does no damage.");
passive();
return;
}
if (i < j / 10)
clumsy = TRUE;
else if (!rn2((i < j / 5) ? 2 : 3))
clumsy = TRUE;
}
if (Fumbling)
if (i < j / 10) {
clumsy = TRUE;
else if (uarm && objects[uarm->otyp].oc_bulky && ACURR(A_DEX) < rnd(25))
} else if (!rn2((i < j / 5) ? 2 : 3)) {
clumsy = TRUE;
doit:
You("kick %s.", mon_nam(mon));
if (!rn2(clumsy ? 3 : 4) && (clumsy || !bigmonst(mon->data))
&& mon->mcansee && !mon->mtrapped && !thick_skinned(mon->data)
&& mon->data->mlet != S_EEL && haseyes(mon->data) && mon->mcanmove
&& !mon->mstun && !mon->mconf && !mon->msleeping
&& mon->data->mmove >= 12) {
if (!nohands(mon->data) && !rn2(martial() ? 5 : 3)) {
pline("%s blocks your %skick.", Monnam(mon),
}
}
if (Fumbling) {
clumsy = TRUE;
} else if (uarm && objects[uarm->otyp].oc_bulky && ACURR(A_DEX) < rnd(25)) {
clumsy = TRUE;
}
doit:
/* Output "You kick __." where __ is the name of the enemy. */
pline("You kick %s.", mon_nam(mon));
if ((!rn2(clumsy ? 3 : 4) || (clumsy || mon->data->msize == MZ_SMALL)) &&
mon->mcansee && !mon->mtrapped && !thick_skinned(mon->data) &&
mon->data->mlet != S_EEL && haseyes(mon->data) &&
mon->mcanmove && !mon->mstun && !mon->mconf && !mon->msleeping &&
mon->data->mmove >= 12) {
if (!nohands(mon->data) && !rn2(martial() ? 5 : 3)) {
/* Output "%s blocks your %skick." where %s is the name of the enemy,
* %skick can be "clumsy ", and call passive() function, then return. */
pline("%s blocks your %skick.", Monnam(mon), clumsy ? "clumsy " : "");
passive();
return;
} else {
maybe_mnexto(mon);
if (mon->mx != x || mon->my != y) {
unmap_invisible(x, y);
/* Output "%s %s, %s evading your %skick." where %s is the name of the enemy,
* %s can be "teleports", "floats", "swoops", or "slides",
* %s can be "easily" or "nimbly", and %s can be "clumsy ".
* Then call passive() function, and return. */
pline("%s %s, %s evading your %skick.", Monnam(mon),
teleport_control(mon) ? "teleports" :
is_floater(mon->data) ? "floats" :
is_flyer(mon->data) ? "swoops" : "slides",
(is_floater(mon->data) || mon->data->mmove >= 12) ? "easily" : "nimbly",
clumsy ? "clumsy " : "");
(void) passive(mon, uarmf, FALSE, 1, AT_KICK, FALSE);
passive();
return;
} else {
maybe_mnexto(mon);
if (mon->mx != x || mon->my != y) {
(void) unmap_invisible(x, y);
pline("%s %s, %s evading your %skick.", Monnam(mon),
(can_teleport(mon->data) && !noteleport_level(mon))
? "teleports"
: is_floater(mon->data)
? "floats"
: is_flyer(mon->data) ? "swoops"
: (nolimbs(mon->data)
|| slithy(mon->data))
? "slides"
: "jumps",
clumsy ? "easily" : "nimbly", clumsy ? "clumsy " : "");
(void) passive(mon, uarmf, FALSE, 1, AT_KICK, FALSE);
return;
}
}
}
kickdmg(mon, clumsy);
}
kickdmg(mon, clumsy);
/*
* Return TRUE if caught (the gold taken care of), FALSE otherwise.
* The gold object is *not* attached to the fobj chain!

@ -97,38 +97,49 @@ const uchar def_r_oc_syms[MAXOCLASSES] = {
* recognized, then MAXOCLASSES is returned. Used in detect.c, invent.c,
* objnam.c, options.c, pickup.c, sp_lev.c, lev_main.c, and tilemap.c.
*/
int
def_char_to_objclass(char ch)
int def_char_to_objclass(char ch)
{
int i;
for (i = 1; i < MAXOCLASSES; i++)
// Iterate through the object classes
for (i = 1; i < MAXOCLASSES; i++) {
// Check if the character matches the symbol of the current object class
if (ch == def_oc_syms[i].sym)
break;
}
// Return the index representing the object class if a match is found
// If no match is found, return MAXOCLASSES
return i;
}
/*
* Convert a character into a monster class. This returns the _first_
* match made. If there are are no matches, return MAXMCLASSES.
* Used in detect.c, options.c, read.c, sp_lev.c, and lev_main.c
*/
int
def_char_to_monclass(char ch)
int def_char_to_monclass(char ch)
{
int i;
for (i = 1; i < MAXMCLASSES; i++)
// Iterate through the monster classes
for (i = 1; i < MAXMCLASSES; i++) {
// Check if the character matches the symbol of the current monster class
if (ch == def_monsyms[i].sym)
break;
}
// Return the index representing the monster class if a match is found
// If no match is found, return MAXMCLASSES
return i;
}
/* does 'ch' represent a furniture character? returns index into defsyms[] */
int
def_char_is_furniture(char ch)
int def_char_is_furniture(char ch)
{
/* note: these refer to defsyms[] order which is much different from
/* Note: these refer to defsyms[] order which is much different from
levl[][].typ order but both keep furniture in a contiguous block */
static const char first_furniture[] = "stair", /* "staircase up" */
last_furniture[] = "fountain";
@ -137,17 +148,22 @@ def_char_is_furniture(char ch)
for (i = 0; i < MAXPCHARS; ++i) {
if (!furniture) {
// Check if the current explanation matches the start of furniture
if (!strncmp(defsyms[i].explanation, first_furniture, 5))
furniture = TRUE;
}
if (furniture) {
// If the current symbol matches the input character, return the index
if (defsyms[i].sym == (uchar) ch)
return i;
// If the current explanation matches the end of furniture, break the loop
if (!strcmp(defsyms[i].explanation, last_furniture))
break; /* reached last furniture */
}
}
// If no match is found, return -1
return -1;
}
/*drawing.c*/

@ -8,51 +8,51 @@
#include <limits.h>
#endif
static int enermod(int);
static int enermod(int en);
long
newuexp(int lev)
long newuexp(int lev)
{
if (lev < 1) /* for newuexp(u.ulevel - 1) when u.ulevel is 1 */
return 0L;
if (lev < 10)
return (10L * (1L << lev));
return (10L * (1L << lev)); // Experience calculation for levels 1-9
if (lev < 20)
return (10000L * (1L << (lev - 10)));
return (10000000L * ((long) (lev - 19)));
return (10000L * (1L << (lev - 10))); // Experience calculation for levels 10-19
return (10000000L * ((long) (lev - 19))); // Experience calculation for levels 20 and above
}
static int
enermod(int en)
static int enermod(int en)
{
switch (Role_switch) {
case PM_CLERIC:
case PM_WIZARD:
return (2 * en);
return (2 * en); // Energy modification for Clerics and Wizards
case PM_HEALER:
case PM_KNIGHT:
return ((3 * en) / 2);
return ((3 * en) / 2); // Energy modification for Healers and Knights
case PM_BARBARIAN:
case PM_VALKYRIE:
return ((3 * en) / 4);
return ((3 * en) / 4); // Energy modification for Barbarians and Valkyries
default:
return en;
return en; // No modification for other roles
}
}
/* calculate spell power/energy points for new level */
int
newpw(void)
int newpw(void)
{
int en = 0, enrnd, enfix;
if (u.ulevel == 0) {
// For level 0 characters (starting level), calculate initial en based on role and race
en = gu.urole.enadv.infix + gu.urace.enadv.infix;
if (gu.urole.enadv.inrnd > 0)
en += rnd(gu.urole.enadv.inrnd);
if (gu.urace.enadv.inrnd > 0)
en += rnd(gu.urace.enadv.inrnd);
} else {
// For higher levels, calculate en based on attributes and role/race modifiers
enrnd = (int) ACURR(A_WIS) / 2;
if (u.ulevel < gu.urole.xlev) {
enrnd += gu.urole.enadv.lornd + gu.urace.enadv.lornd;
@ -61,23 +61,26 @@ newpw(void)
enrnd += gu.urole.enadv.hirnd + gu.urace.enadv.hirnd;
enfix = gu.urole.enadv.hifix + gu.urace.enadv.hifix;
}
en = enermod(rn1(enrnd, enfix));
en = enermod(rn1(enrnd, enfix)); // Apply energy modifier based on role
}
if (en <= 0)
en = 1;
en = 1; // If en is negative or zero, set it to 1
if (u.ulevel < MAXULEV) {
/* remember increment; future level drain could take it away again */
u.ueninc[u.ulevel] = (xint16) en;
u.ueninc[u.ulevel] = (xint16) en; // Store the energy increment for the current level
} else {
/* after level 30, throttle energy gains from extra experience;
once max reaches 600, further increments will be just 1 more */
char lim = 4 - u.uenmax / 200;
char lim = 4 - u.uenmax / 200; // Calculate the maximum limit for energy gain
lim = max(lim, 1);
lim = max(lim, 1); // Make sure the limit is at least 1
if (en > lim)
en = lim;
en = lim; // Cap the energy gain to the calculated limit
}
return en;
return en; // Return the maximum power points (en)
}
/* return # of exp points for mtmp after nk killed */
@ -112,19 +115,28 @@ experience(register struct monst *mtmp, register int nk)
/* For each "special" damage type give extra experience */
for (i = 0; i < NATTK; i++) {
tmp2 = ptr->mattk[i].adtyp;
if (tmp2 > AD_PHYS && tmp2 < AD_BLND)
tmp += 2 * mtmp->m_lev;
else if ((tmp2 == AD_DRLI) || (tmp2 == AD_STON) || (tmp2 == AD_SLIM))
tmp += 50;
else if (tmp2 != AD_PHYS)
tmp += mtmp->m_lev;
/* extra heavy damage bonus */
if ((int) (ptr->mattk[i].damd * ptr->mattk[i].damn) > 23)
tmp += mtmp->m_lev;
if (tmp2 == AD_WRAP && ptr->mlet == S_EEL && !Amphibious)
tmp += 1000;
tmp2 = ptr->mattk[i].adtyp; // Get the attack type of the monster's attack
// Check various conditions and add the corresponding damage bonus
if (tmp2 > AD_PHYS && tmp2 < AD_BLND) {
tmp += 2 * mtmp->m_lev;
} else if ((tmp2 == AD_DRLI) || (tmp2 == AD_STON) || (tmp2 == AD_SLIM)) {
tmp += 50;
} else if (tmp2 != AD_PHYS) {
tmp += mtmp->m_lev;
}
// Check for an extra heavy damage bonus
if ((int) (ptr->mattk[i].damd * ptr->mattk[i].damn) > 23) {
tmp += mtmp->m_lev;
}
// Add an additional bonus for specific conditions
if (tmp2 == AD_WRAP && ptr->mlet == S_EEL && !Amphibious) {
tmp += 1000;
}
}
/* For certain "extra nasty" monsters, give even more */
if (extra_nasty(ptr))
@ -252,37 +264,37 @@ losexp(
we don't allow it to go up because that contradicts assumptions
elsewhere (such as healing wielder who drains with Stormbringer) */
if (u.uhpmax > olduhpmax)
setuhpmax(olduhpmax);
u.uhp -= num;
if (u.uhp < 1)
u.uhp = 1;
else if (u.uhp > u.uhpmax)
u.uhp = u.uhpmax;
num = (int) u.ueninc[u.ulevel];
u.uenmax -= num;
if (u.uenmax < 0)
u.uenmax = 0;
u.uen -= num;
if (u.uen < 0)
u.uen = 0;
else if (u.uen > u.uenmax)
u.uen = u.uenmax;
if (u.uexp > 0)
u.uexp = newuexp(u.ulevel) - 1;
setuhpmax(olduhpmax); // If the maximum hit points (u.uhpmax) is greater than the previous maximum (olduhpmax), set it to the old maximum
u.uhp -= num; // Subtract 'num' from the current hit points (u.uhp)
if (u.uhp < 1)
u.uhp = 1; // If the hit points are less than 1, set them to 1 (minimum value)
else if (u.uhp > u.uhpmax)
u.uhp = u.uhpmax; // If the hit points are greater than the maximum hit points, set them to the maximum hit points
num = (int) u.ueninc[u.ulevel]; // Get the energy increment for the current player level
u.uenmax -= num; // Subtract 'num' from the maximum energy points (u.uenmax)
if (u.uenmax < 0)
u.uenmax = 0; // If the maximum energy points are less than 0, set them to 0 (minimum value)
u.uen -= num; // Subtract 'num' from the current energy points (u.uen)
if (u.uen < 0)
u.uen = 0; // If the energy points are less than 0, set them to 0 (minimum value)
else if (u.uen > u.uenmax)
u.uen = u.uenmax; // If the energy points are greater than the maximum energy points, set them to the maximum energy points
if (u.uexp > 0)
u.uexp = newuexp(u.ulevel) - 1; // If the experience points (u.uexp) are greater than 0, update them based on the current player level
if (Upolyd) {
num = monhp_per_lvl(&gy.youmonst); // Calculate the hit points per level for the current polymorphed form
u.mhmax -= num; // Subtract 'num' from the maximum monster hit points (u.mhmax)
u.mh -= num; // Subtract 'num' from the current monster hit points (u.mh)
if (u.mh <= 0)
rehumanize(); // If the monster hit points are less than or equal to 0, change back to the player form
}
if (Upolyd) {
num = monhp_per_lvl(&gy.youmonst);
u.mhmax -= num;
u.mh -= num;
if (u.mh <= 0)
rehumanize();
}
gc.context.botl = TRUE; // Set a flag to indicate that the status line needs to be updated
gc.context.botl = TRUE;
}
/*
* Make experience gaining similar to AD&D(tm), whereby you can at most go

@ -17,123 +17,178 @@ static void roguejoin(coordxy, coordxy, coordxy, coordxy, int);
static void roguecorr(coordxy, coordxy, int);
static void miniwalk(coordxy, coordxy);
static
void
roguejoin(coordxy x1, coordxy y1, coordxy x2, coordxy y2, int horiz)
static void roguejoin(coordxy x1, coordxy y1, coordxy x2, coordxy y2, int horiz)
{
register coordxy x, y, middle;
if (horiz) {
// Calculate the midpoint for the horizontal corridor
middle = x1 + rn2(x2 - x1 + 1);
// Create the first segment of the corridor along the x-axis
for (x = min(x1, middle); x <= max(x1, middle); x++)
corr(x, y1);
// Create the vertical segment of the corridor
for (y = min(y1, y2); y <= max(y1, y2); y++)
corr(middle, y);
// Create the second segment of the corridor along the x-axis
for (x = min(middle, x2); x <= max(middle, x2); x++)
corr(x, y2);
} else {
// Calculate the midpoint for the vertical corridor
middle = y1 + rn2(y2 - y1 + 1);
// Create the first segment of the corridor along the y-axis
for (y = min(y1, middle); y <= max(y1, middle); y++)
corr(x1, y);
// Create the horizontal segment of the corridor
for (x = min(x1, x2); x <= max(x1, x2); x++)
corr(x, middle);
// Create the second segment of the corridor along the y-axis
for (y = min(middle, y2); y <= max(middle, y2); y++)
corr(x2, y);
}
}
static
void
roguecorr(coordxy x, coordxy y, int dir)
static void roguecorr(coordxy x, coordxy y, int dir)
{
register coordxy fromx, fromy, tox, toy;
if (dir == XL_DOWN) {
// Disable the down door in the current room
gr.r[x][y].doortable &= ~XL_DOWN;
if (!gr.r[x][y].real) {
// If the current room is not a real room, calculate the starting coordinates for the virtual room
fromx = gr.r[x][y].rlx;
fromy = gr.r[x][y].rly;
fromx += 1 + 26 * x;
fromy += 7 * y;
} else {
// If the current room is a real room, calculate the starting coordinates based on the room size and position
fromx = gr.r[x][y].rlx + rn2(gr.r[x][y].dx);
fromy = gr.r[x][y].rly + gr.r[x][y].dy;
fromx += 1 + 26 * x;
fromy += 7 * y;
// Check if there is a wall at the starting coordinates. If not, output an error message.
if (!IS_WALL(levl[fromx][fromy].typ))
impossible("down: no wall at %d,%d?", fromx, fromy);
// Create a door at the starting coordinates and mark it as no door
dodoor(fromx, fromy, &gr.rooms[gr.r[x][y].nroom]);
levl[fromx][fromy].doormask = D_NODOOR;
fromy++;
}
if (y >= 2) {
// If the current row is greater than or equal to 2, output an error message
impossible("down door from %d,%d going nowhere?", x, y);
return;
}
// Move to the next row
y++;
// Disable the up door in the next room
gr.r[x][y].doortable &= ~XL_UP;
if (!gr.r[x][y].real) {
// If the next room is not a real room, calculate the ending coordinates for the virtual room
tox = gr.r[x][y].rlx;
toy = gr.r[x][y].rly;
tox += 1 + 26 * x;
toy += 7 * y;
} else {
// If the next room is a real room, calculate the ending coordinates based on the room size and position
tox = gr.r[x][y].rlx + rn2(gr.r[x][y].dx);
toy = gr.r[x][y].rly - 1;
tox += 1 + 26 * x;
toy += 7 * y;
// Check if there is a wall at the ending coordinates. If not, output an error message.
if (!IS_WALL(levl[tox][toy].typ))
impossible("up: no wall at %d,%d?", tox, toy);
// Create a door at the ending coordinates and mark it as no door
dodoor(tox, toy, &gr.rooms[gr.r[x][y].nroom]);
levl[tox][toy].doormask = D_NODOOR;
toy--;
}
// Call the `roguejoin` function to create a corridor connecting the starting and ending coordinates
roguejoin(fromx, fromy, tox, toy, FALSE);
return;
} else if (dir == XL_RIGHT) {
gr.r[x][y].doortable &= ~XL_RIGHT;
if (!gr.r[x][y].real) {
fromx = gr.r[x][y].rlx;
fromy = gr.r[x][y].rly;
fromx += 1 + 26 * x;
fromy += 7 * y;
} else {
fromx = gr.r[x][y].rlx + gr.r[x][y].dx;
fromy = gr.r[x][y].rly + rn2(gr.r[x][y].dy);
fromx += 1 + 26 * x;
fromy += 7 * y;
if (!IS_WALL(levl[fromx][fromy].typ))
impossible("down: no wall at %d,%d?", fromx, fromy);
dodoor(fromx, fromy, &gr.rooms[gr.r[x][y].nroom]);
levl[fromx][fromy].doormask = D_NODOOR;
fromx++;
}
if (x >= 2) {
impossible("right door from %d,%d going nowhere?", x, y);
return;
}
x++;
gr.r[x][y].doortable &= ~XL_LEFT;
if (!gr.r[x][y].real) {
tox = gr.r[x][y].rlx;
toy = gr.r[x][y].rly;
tox += 1 + 26 * x;
toy += 7 * y;
} else {
tox = gr.r[x][y].rlx - 1;
toy = gr.r[x][y].rly + rn2(gr.r[x][y].dy);
tox += 1 + 26 * x;
toy += 7 * y;
if (!IS_WALL(levl[tox][toy].typ))
impossible("left: no wall at %d,%d?", tox, toy);
dodoor(tox, toy, &gr.rooms[gr.r[x][y].nroom]);
levl[tox][toy].doormask = D_NODOOR;
tox--;
}
roguejoin(fromx, fromy, tox, toy, TRUE);
return;
} else
impossible("corridor in direction %d?", dir);
} else if (dir == XL_RIGHT) {
// Disable the right door in the current room
gr.r[x][y].doortable &= ~XL_RIGHT;
if (!gr.r[x][y].real) {
// If the current room is not a real room, calculate the starting coordinates for the virtual room
fromx = gr.r[x][y].rlx;
fromy = gr.r[x][y].rly;
fromx += 1 + 26 * x;
fromy += 7 * y;
} else {
// If the current room is a real room, calculate the starting coordinates based on the room size and position
fromx = gr.r[x][y].rlx + gr.r[x][y].dx;
fromy = gr.r[x][y].rly + rn2(gr.r[x][y].dy);
fromx += 1 + 26 * x;
fromy += 7 * y;
// Check if there is a wall at the starting coordinates. If not, output an error message.
if (!IS_WALL(levl[fromx][fromy].typ))
impossible("down: no wall at %d,%d?", fromx, fromy);
// Create a door at the starting coordinates and mark it as no door
dodoor(fromx, fromy, &gr.rooms[gr.r[x][y].nroom]);
levl[fromx][fromy].doormask = D_NODOOR;
fromx++;
}
if (x >= 2) {
impossible("right door from %d,%d going nowhere?", x, y);
return;
}
// Move to the next column
x++;
// Disable the left door in the next room
gr.r[x][y].doortable &= ~XL_LEFT;
if (!gr.r[x][y].real) {
// If the next room is not a real room, calculate the ending coordinates for the virtual room
tox = gr.r[x][y].rlx;
toy = gr.r[x][y].rly;
tox += 1 + 26 * x;
toy += 7 * y;
} else {
// If the next room is a real room, calculate the ending coordinates based on the room size and position
tox = gr.r[x][y].rlx - 1;
toy = gr.r[x][y].rly + rn2(gr.r[x][y].dy);
tox += 1 + 26 * x;
toy += 7 * y;
// Check if there is a wall at the ending coordinates. If not, output an error message.
if (!IS_WALL(levl[tox][toy].typ))
impossible("left: no wall at %d,%d?", tox, toy);
// Create a door at the ending coordinates and mark it as no door
dodoor(tox, toy, &gr.rooms[gr.r[x][y].nroom]);
levl[tox][toy].doormask = D_NODOOR;
tox--;
}
// Call the `roguejoin` function to create a corridor connecting the starting and ending coordinates
roguejoin(fromx, fromy, tox, toy, TRUE);
return;
} else {
impossible("corridor in direction %d?", dir);
}
/* Modified walkfrom() from mkmaze.c */
@ -287,9 +342,9 @@ corr(coordxy x, coordxy y)
}
}
void
makerogueghost(void)
void makerogueghost(void)
{
// Declare variables
register struct monst *ghost;
struct obj *ghostobj;
struct mkroom *croom;
@ -297,14 +352,23 @@ makerogueghost(void)
if (!gn.nroom)
return; /* Should never happen */
// Select a random room
croom = &gr.rooms[rn2(gn.nroom)];
// Select a random coordinate within the room
x = somex(croom);
y = somey(croom);
// Create a ghost monster at the selected coordinates
if (!(ghost = makemon(&mons[PM_GHOST], x, y, NO_MM_FLAGS)))
return;
// Make the ghost sleep and give it a name
ghost->msleeping = 1;
ghost = christen_monst(ghost, roguename());
// Randomly create and place different items near the ghost
if (rn2(4)) {
ghostobj = mksobj_at(FOOD_RATION, x, y, FALSE, FALSE);
ghostobj->quan = (long) rnd(7);
@ -354,4 +418,5 @@ makerogueghost(void)
}
}
/*extralev.c*/

@ -0,0 +1 @@
i miss you
Loading…
Cancel
Save