Skip to content

Commit

Permalink
unlock pal skill + update status points on player leveling up
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisCris committed Feb 9, 2025
1 parent 3786e3e commit a9acf38
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 13 deletions.
13 changes: 7 additions & 6 deletions frontend/palworld-pal-editor-webui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ const isMinLv = () => {
</div>
</div>
</div>
<div class="EditorItem flex-v item left">
<!-- <div class="EditorItem flex-v item left">
<p class="cat">
{{ palStore.getTranslatedText("Editor_IV") }}
</p>
</div>
</div> -->
<div class="EditorItem flex-h maxW">
<div class="levels-container">
<div class="level-row" v-for="(items, level) in palStore.TECH_LV_DICT" :key="level">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const palStore = usePalEditorStore()
<PalList v-if="palStore.SELECTED_PLAYER_ID || palStore.BASE_PAL_BTN_CLK_FLAG"></PalList>
<PlayerEditor v-if="palStore.SHOW_PLAYER_EDIT_FLAG"></PlayerEditor>
<PalEditor v-else-if="palStore.SELECTED_PAL_ID && palStore.SELECTED_PAL_DATA"></PalEditor>
<p v-else>?error occured?</p>
<p v-else>SELECT A PAL OR PLAYER TO START ;)</p>
</div>
</div>
</template>
Expand Down
3 changes: 3 additions & 0 deletions src/palworld_pal_editor/core/pal_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ class PalObjects:
EMPTY_UUID = toUUID("00000000-0000-0000-0000-000000000000")
TIME = 638486453957560000

UInt16Max = 65535
UInt16Min = 0

@staticmethod
def StrProperty(value: str):
return {"id": None, "type": "StrProperty", "value": value}
Expand Down
63 changes: 59 additions & 4 deletions src/palworld_pal_editor/core/player_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def __init__(
raise Exception(
f"InstanceId unmatch: Level.sav: {self.InstanceId} v.s. playerid.sav {sav_InstanceId}"
)


def __str__(self) -> str:
return "{} - {} - {}".format(self.NickName, self.PlayerUId, self.InstanceId)
Expand Down Expand Up @@ -103,6 +104,20 @@ def NickName(self, value: str) -> None:
if not self.NickName:
self._player_param.pop("NickName", None)

@property
def UnusedStatusPoint(self) -> Optional[int]:
return PalObjects.get_BaseType(self._player_param.get("UnusedStatusPoint"))

@UnusedStatusPoint.setter
@LOGGER.change_logger("UnusedStatusPoint")
@type_guard
def UnusedStatusPoint(self, value: int) -> None:
value = clamp(PalObjects.UInt16Min, PalObjects.UInt16Max, value)
if self.UnusedStatusPoint is None:
self._player_param["UnusedStatusPoint"] = PalObjects.IntProperty(value)
else:
PalObjects.set_BaseType(self._player_param["UnusedStatusPoint"], value)

@property
def Level(self) -> Optional[int]:
return PalObjects.get_ByteProperty(self._player_param.get("Level"))
Expand All @@ -113,10 +128,17 @@ def Level(self) -> Optional[int]:
def Level(self, value: int) -> None:
value = clamp(1, PlayerEntity.MAX_INVALID_LEVEL, value)
if self.Level is None:
self._player_param["Level"] = PalObjects.ByteProperty(value)
else:
PalObjects.set_ByteProperty(self._player_param["Level"], value)
self._player_param["Level"] = PalObjects.ByteProperty(1)

status_points = value - self.Level
new_unused_status_point = (self.UnusedStatusPoint or 0) + status_points
if new_unused_status_point < 0:
LOGGER.warning(f"Player {self} has insufficient status points to level down.")
return

PalObjects.set_ByteProperty(self._player_param["Level"], value)
self.Exp = DataProvider.get_player_level_xp(self.Level)
self.UnusedStatusPoint = new_unused_status_point

@property
def Exp(self) -> Optional[int]:
Expand Down Expand Up @@ -200,6 +222,32 @@ def add_pal(self, pal_entity: PalEntity) -> bool:
pal_entity.set_owner_player_entity(self)
return True

@property
def TechnologPoint(self) -> Optional[int]:
return PalObjects.get_BaseType(self._player_save_data.get("TechnologPoint"))

@TechnologPoint.setter
@LOGGER.change_logger("TechnologPoint")
@type_guard
def TechnologPoint(self, value: int) -> None:
if self.TechnologPoint is None:
self._player_save_data["TechnologPoint"] = PalObjects.IntProperty(value)
else:
PalObjects.set_BaseType(self._player_save_data["TechnologPoint"], value)

@property
def bossTechPoint(self) -> Optional[int]:
return PalObjects.get_BaseType(self._player_save_data.get("bossTechPoint"))

@bossTechPoint.setter
@LOGGER.change_logger("bossTechPoint")
@type_guard
def bossTechPoint(self, value: int) -> None:
if self.bossTechPoint is None:
self._player_save_data["bossTechPoint"] = PalObjects.IntProperty(value)
else:
PalObjects.set_BaseType(self._player_save_data["bossTechPoint"], value)

def try_create_pal_record_data(self):
if "RecordData" not in self._player_save_data:
self._player_save_data["RecordData"] = PalObjects.PalLoggedinPlayerSaveDataRecordData()
Expand Down Expand Up @@ -276,8 +324,15 @@ def handle_special_keys(key) -> str:
continue

key = handle_special_keys(pal_entity.RawSpecieKey)
self.inc_pal_capture_count(key)
self.unlock_paldeck(key)
self.inc_pal_capture_count(key)

tech_key = "SkillUnlock_" + key
if DataProvider.get_tech_i18n(tech_key) is None:
LOGGER.warning(f"Technology {tech_key} not found, please report this to the dev.")
else:
self.toggle_UnlockedRecipeTechnologyNames(tech_key, True)

pal_entity.is_new_pal = False

self._new_palbox.clear()
Expand Down

0 comments on commit a9acf38

Please sign in to comment.