| 984 | } |
| 985 | |
| 986 | void Game_Actor::ChangeClass(int new_class_id, |
| 987 | int new_level, |
| 988 | ClassChangeSkillMode new_skill, |
| 989 | ClassChangeParamMode new_param, |
| 990 | PendingMessage* pm |
| 991 | ) |
| 992 | { |
| 993 | const auto* cls = lcf::ReaderUtil::GetElement(lcf::Data::classes, new_class_id); |
| 994 | if (new_class_id != 0 && cls == nullptr) { |
| 995 | Output::Warning("Actor {}: Can't change to invalid class {}", GetId(), new_class_id); |
| 996 | return; |
| 997 | } |
| 998 | |
| 999 | // RPG_RT always removes all equipment on level change. |
| 1000 | RemoveWholeEquipment(); |
| 1001 | |
| 1002 | const auto prev_level = GetLevel(); |
| 1003 | const auto hp = GetHp(); |
| 1004 | const auto sp = GetSp(); |
| 1005 | |
| 1006 | auto max_hp = GetBaseMaxHp(); |
| 1007 | auto max_sp = GetBaseMaxSp(); |
| 1008 | auto atk = GetBaseAtk(); |
| 1009 | auto def = GetBaseDef(); |
| 1010 | auto spi = GetBaseSpi(); |
| 1011 | auto agi = GetBaseAgi(); |
| 1012 | |
| 1013 | SetLevel(1); |
| 1014 | data.hp_mod = 0; |
| 1015 | data.sp_mod = 0; |
| 1016 | data.attack_mod = 0; |
| 1017 | data.defense_mod = 0; |
| 1018 | data.spirit_mod = 0; |
| 1019 | data.agility_mod = 0; |
| 1020 | |
| 1021 | data.class_id = new_class_id; |
| 1022 | data.changed_battle_commands = true; // Any change counts as a battle commands change. |
| 1023 | |
| 1024 | // The class settings are not applied when the actor has a class on startup |
| 1025 | // but only when the "Change Class" event command is used. |
| 1026 | |
| 1027 | if (cls) { |
| 1028 | data.super_guard = cls->super_guard; |
| 1029 | data.lock_equipment = cls->lock_equipment; |
| 1030 | data.two_weapon = cls->two_weapon; |
| 1031 | data.auto_battle = cls->auto_battle; |
| 1032 | |
| 1033 | data.battler_animation = cls->battler_animation; |
| 1034 | |
| 1035 | data.battle_commands = cls->battle_commands; |
| 1036 | } else { |
| 1037 | data.super_guard = dbActor->super_guard; |
| 1038 | data.lock_equipment = dbActor->lock_equipment; |
| 1039 | data.two_weapon = dbActor->two_weapon; |
| 1040 | data.auto_battle = dbActor->auto_battle; |
| 1041 | |
| 1042 | data.battler_animation = 0; |
| 1043 |
no test coverage detected