Add ResStream.read_long/write_long and use them for every CObjects field the client loads with ResStream_ReadInt32 (sb.exe 0x7E1700) as a value: rank info, attribute/skill/resource amounts, requirements, door/deed/container/key fields, natural attacks, hardpoints, sound event types and sparse VAL_LONG (LoadSaveBehavior<long>). Hash/enum fields, list counts and flag words keep unsigned reads. The binary is unchanged; JSON now shows e.g. -1 instead of 4294967295 (rank_hirelings, rank_rank) and -10 instead of 4294967286 (attr_adj). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
69 lines
3.0 KiB
Python
69 lines
3.0 KiB
Python
# • ▌ ▄ ·. ▄▄▄▄· ▄▄▄ .·▄▄▄▄ ▪ ▄▄▄▄▄ ▄▄▄ ▄▄▄·▄▄▄
|
|
# ·██ ▐███▪▐█ ▀█▪ ▀▄.▀·██▪ ██ ██ •██ ▪ ▀▄ █· ▐█ ▄█▀▄ █·▪
|
|
# ▐█ ▌▐▌▐█·▐█▀▀█▄ ▐▀▀▪▄▐█· ▐█▌▐█· ▐█.▪ ▄█▀▄ ▐▀▀▄ ██▀·▐▀▀▄ ▄█▀▄
|
|
# ██ ██▌▐█▌██▄▪▐█ ▐█▄▄▌██. ██ ▐█▌ ▐█▌·▐█▌.▐▌▐█•█▌ ▐█▪·•▐█•█▌▐█▌.▐▌
|
|
# ▀▀ █▪▀▀▀·▀▀▀▀ ▀▀▀ ▀▀▀▀▀• ▀▀▀ ▀▀▀ ▀█▄▀▪.▀ ▀ .▀ .▀ ▀ ▀█▄▀▪
|
|
# Magicbane Emulator Project © 2013 - 2022
|
|
# www.magicbane.com
|
|
|
|
from collections import OrderedDict
|
|
|
|
from arcane.enums.arc_combat import *
|
|
from arcane.util import ResStream
|
|
from .ArcObj import ArcObj
|
|
|
|
|
|
class ArcCombatObj(ArcObj):
|
|
def load_binary(self, stream: ResStream):
|
|
super().load_binary(stream)
|
|
self.combat_health_current = stream.read_float()
|
|
self.combat_health_full = stream.read_float()
|
|
self.combat_attack_resist = [
|
|
stream.read_float() for _ in range(0x10)
|
|
]
|
|
num_powers = stream.read_dword()
|
|
self.combat_powers = [
|
|
[
|
|
stream.read_dword(),
|
|
stream.read_long(),
|
|
] for _ in range(num_powers)
|
|
]
|
|
|
|
def save_binary(self, stream: ResStream):
|
|
super().save_binary(stream)
|
|
stream.write_float(self.combat_health_current)
|
|
stream.write_float(self.combat_health_full)
|
|
for i in range(0x10):
|
|
stream.write_float(self.combat_attack_resist[i])
|
|
stream.write_dword(len(self.combat_powers))
|
|
for power in self.combat_powers:
|
|
stream.write_dword(power[0])
|
|
stream.write_long(power[1])
|
|
|
|
def load_json(self, data):
|
|
super().load_json(data)
|
|
self.combat_health_current = data['combat_health_current']
|
|
self.combat_health_full = data['combat_health_full']
|
|
self.combat_attack_resist = []
|
|
for i in range(0x10):
|
|
self.combat_attack_resist.append(data['combat_attack_resist'][
|
|
ATTACK_RESIST_TO_STRING[i]
|
|
])
|
|
self.combat_powers = data['combat_powers']
|
|
|
|
def save_json(self):
|
|
data = super().save_json()
|
|
data['combat_health_current'] = self.combat_health_current
|
|
data['combat_health_full'] = self.combat_health_full
|
|
data['combat_attack_resist'] = OrderedDict()
|
|
for i in range(0x10):
|
|
data['combat_attack_resist'][
|
|
ATTACK_RESIST_TO_STRING[i]
|
|
] = self.combat_attack_resist[i]
|
|
data['combat_powers'] = self.combat_powers
|
|
return data
|
|
|
|
|
|
class ArcCharacter(ArcCombatObj):
|
|
pass
|