Fix displaying xp gained with Swift Learner bonus
This commit is contained in:
parent
7096116296
commit
b10c580d6f
|
@ -2822,7 +2822,9 @@ void _combat_give_exps(int exp_points)
|
|||
return;
|
||||
}
|
||||
|
||||
pcAddExperience(exp_points);
|
||||
// SFALL: Display actual xp received.
|
||||
int xpGained;
|
||||
pcAddExperience(exp_points, &xpGained);
|
||||
|
||||
v7.num = 621; // %s you earn %d exp. points.
|
||||
if (!messageListGetItem(&gProtoMessageList, &v7)) {
|
||||
|
@ -2841,7 +2843,7 @@ void _combat_give_exps(int exp_points)
|
|||
return;
|
||||
}
|
||||
|
||||
sprintf(text, v7.text, v9.text, exp_points);
|
||||
sprintf(text, v7.text, v9.text, xpGained);
|
||||
displayMonitorAddMessage(text);
|
||||
}
|
||||
|
||||
|
|
|
@ -3901,15 +3901,17 @@ int inventoryOpenLooting(Object* a1, Object* a2)
|
|||
stealingXp = std::min(300 - skillGetValue(a1, SKILL_STEAL), stealingXp);
|
||||
debugPrint("\n[[[%d]]]", 300 - skillGetValue(a1, SKILL_STEAL));
|
||||
|
||||
// SFALL: Display actual xp received.
|
||||
int xpGained;
|
||||
pcAddExperience(stealingXp, &xpGained);
|
||||
|
||||
// You gain %d experience points for successfully using your Steal skill.
|
||||
messageListItem.num = 29;
|
||||
if (messageListGetItem(&gInventoryMessageList, &messageListItem)) {
|
||||
char formattedText[200];
|
||||
sprintf(formattedText, messageListItem.text, stealingXp);
|
||||
sprintf(formattedText, messageListItem.text, xpGained);
|
||||
displayMonitorAddMessage(formattedText);
|
||||
}
|
||||
|
||||
pcAddExperience(stealingXp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
12
src/stat.cc
12
src/stat.cc
|
@ -717,14 +717,16 @@ int statRoll(Object* critter, int stat, int modifier, int* howMuch)
|
|||
}
|
||||
|
||||
// 0x4AFAA8
|
||||
int pcAddExperience(int xp)
|
||||
int pcAddExperience(int xp, int* xpGained)
|
||||
{
|
||||
return pcAddExperienceWithOptions(xp, true);
|
||||
return pcAddExperienceWithOptions(xp, true, xpGained);
|
||||
}
|
||||
|
||||
// 0x4AFAB8
|
||||
int pcAddExperienceWithOptions(int xp, bool a2)
|
||||
int pcAddExperienceWithOptions(int xp, bool a2, int* xpGained)
|
||||
{
|
||||
int oldXp = gPcStatValues[PC_STAT_EXPERIENCE];
|
||||
|
||||
int newXp = gPcStatValues[PC_STAT_EXPERIENCE];
|
||||
newXp += xp;
|
||||
newXp += perkGetRank(gDude, PERK_SWIFT_LEARNER) * 5 * xp / 100;
|
||||
|
@ -784,6 +786,10 @@ int pcAddExperienceWithOptions(int xp, bool a2)
|
|||
}
|
||||
}
|
||||
|
||||
if (xpGained != NULL) {
|
||||
*xpGained = newXp - oldXp;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,8 +35,8 @@ char* pcStatGetName(int pcStat);
|
|||
char* pcStatGetDescription(int pcStat);
|
||||
int statGetFrmId(int stat);
|
||||
int statRoll(Object* critter, int stat, int modifier, int* howMuch);
|
||||
int pcAddExperience(int xp);
|
||||
int pcAddExperienceWithOptions(int xp, bool a2);
|
||||
int pcAddExperience(int xp, int* xpGained = NULL);
|
||||
int pcAddExperienceWithOptions(int xp, bool a2, int* xpGained = NULL);
|
||||
int pcSetExperience(int a1);
|
||||
|
||||
static inline bool statIsValid(int stat)
|
||||
|
|
|
@ -3678,21 +3678,21 @@ int _wmRndEncounterOccurred()
|
|||
|
||||
int xp = 100 - outdoorsman;
|
||||
if (xp > 0) {
|
||||
// SFALL: Display actual xp received.
|
||||
debugPrint("WorldMap: Giving Player [%d] Experience For Catching Rnd Encounter!", xp);
|
||||
|
||||
int xpGained;
|
||||
pcAddExperience(xp, &xpGained);
|
||||
|
||||
MessageListItem messageListItem;
|
||||
char* text = getmsg(&gMiscMessageList, &messageListItem, 8500);
|
||||
if (strlen(text) < 110) {
|
||||
char formattedText[120];
|
||||
sprintf(formattedText, text, xp);
|
||||
sprintf(formattedText, text, xpGained);
|
||||
displayMonitorAddMessage(formattedText);
|
||||
} else {
|
||||
debugPrint("WorldMap: Error: Rnd Encounter string too long!");
|
||||
}
|
||||
|
||||
debugPrint("WorldMap: Giving Player [%d] Experience For Catching Rnd Encounter!", xp);
|
||||
|
||||
if (xp < 100) {
|
||||
pcAddExperience(xp);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue