From 9cd8807230ceafce3ed8cbc787e251fe9e3ebf65 Mon Sep 17 00:00:00 2001 From: FynnTW Date: Sat, 9 Nov 2024 17:29:30 +0200 Subject: [PATCH] fix experience --- M2TWEOP Code/M2TWEOP library/types/unit.cpp | 15 ++++++++++++--- M2TWEOP Code/M2TWEOP library/types/unit.h | 5 +++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/M2TWEOP Code/M2TWEOP library/types/unit.cpp b/M2TWEOP Code/M2TWEOP library/types/unit.cpp index 67a4d671..c5fcdd25 100644 --- a/M2TWEOP Code/M2TWEOP library/types/unit.cpp +++ b/M2TWEOP Code/M2TWEOP library/types/unit.cpp @@ -97,6 +97,15 @@ void unit::setArmour(const uint8_t armour) GAME_FUNC(void(__thiscall*)(unit*, uint8_t), setUnitArmorFunc)(this, arm); } +void unit::setExperience(const uint8_t exp) +{ + expScreen = exp; + for (int i = 0; i < SoldierCountStrat; i++) + { + soldiersArr[i].experience = exp; + } +} + void unit::setWeapon(uint8_t wpn) { const auto weapon = wpn; @@ -492,7 +501,7 @@ namespace unitActions mov eax, funcAddr call eax } - unit->unitPositionData->hasTargets = 1; + unit->unitPositionData->hasTargets = true; } /////////////////////////////////////// GROUP COMMANDS //////////////////////////////////////////////////////////// @@ -838,7 +847,7 @@ namespace unitHelpers { un->setArmour(arm); un->setWeapon(weapon); - un->expScreen = exp; + un->setExperience(exp); } return un; } @@ -917,7 +926,7 @@ namespace unitHelpers void setSoldiersCountAndExp(unit* un, int count, int exp) { - un->expScreen = exp; + un->setExperience(exp); setSoldiersCount(un, count); } diff --git a/M2TWEOP Code/M2TWEOP library/types/unit.h b/M2TWEOP Code/M2TWEOP library/types/unit.h index f2dce331..b8006c53 100644 --- a/M2TWEOP Code/M2TWEOP library/types/unit.h +++ b/M2TWEOP Code/M2TWEOP library/types/unit.h @@ -1803,9 +1803,9 @@ struct unit { return expScreen; } - void setExp(int exp) + void setExp(const int exp) { - expScreen = exp; + setExperience(exp); } int getArmourLevel() { @@ -1816,6 +1816,7 @@ struct unit return avgWeaponUpg; } void setArmour(uint8_t armour); + void setExperience(uint8_t exp); void setWeapon(uint8_t wpn); void setarmourLVL(int lvl) {