Skip to content

Commit

Permalink
Merge pull request #1657 from Ghabry/change-class-fix
Browse files Browse the repository at this point in the history
Change Class: Fix unsetting class (regression fix) and remove all equipment
  • Loading branch information
carstene1ns committed Mar 2, 2019
2 parents cd1248d + c828e6b commit cdf0a8a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/game_interpreter.cpp
Expand Up @@ -2917,7 +2917,7 @@ bool Game_Interpreter::CommandChangeClass(RPG::EventCommand const& com) { // cod
bool show = com.parameters[6] > 0;

const RPG::Class* cls = ReaderUtil::GetElement(Data::classes, class_id);
if (!cls) {
if (!cls && class_id != 0) {
Output::Warning("ChangeClass: Can't change class. Class %d is invalid", class_id);
return true;
}
Expand All @@ -2929,6 +2929,8 @@ bool Game_Interpreter::CommandChangeClass(RPG::EventCommand const& com) { // cod
int cur_exp = actor->GetExp();
int cur_cid = actor->GetClass() ? actor->GetClass()->ID : -1;

actor->RemoveWholeEquipment();

switch (stats_mode) {
case 2:
actor->SetClass(class_id);
Expand Down Expand Up @@ -3008,7 +3010,7 @@ bool Game_Interpreter::CommandChangeClass(RPG::EventCommand const& com) { // cod
// Learn based on level (replace)
actor->UnlearnAllSkills();
}
if (skill_mode > 0) {
if (skill_mode > 0 && cls) {
// Learn additionally
for (const RPG::Learning& learn : cls->skills) {
if (level >= learn.level) {
Expand Down

0 comments on commit cdf0a8a

Please sign in to comment.