yangkun_branch
yk 1 year ago
parent 7a0a885c06
commit 862f1a236c

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

Loading…
Cancel
Save