add summon unit & maze buff & refactor battle
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
import dataclasses
|
||||
from rail_proto.lib import AvatarSkillTree,EquipRelic
|
||||
|
||||
@dataclasses.dataclass
|
||||
class AvatarManager:
|
||||
avatar_id: int
|
||||
level: int
|
||||
exp: int
|
||||
promotion: int
|
||||
rank: int
|
||||
skills: list[AvatarSkillTree]
|
||||
equip_id: int = 0
|
||||
relic_list: dict[int,EquipRelic] = dataclasses.field(default_factory=dict)
|
||||
@@ -1,4 +1,6 @@
|
||||
import numpy as np
|
||||
|
||||
from game_server.resource.configdb.avatar_config import AvatarConfig
|
||||
from game_server.resource.configdb.stage_config import StageConfig
|
||||
from game_server.resource import ResourceManager
|
||||
from rail_proto.lib import (
|
||||
@@ -9,7 +11,8 @@ from rail_proto.lib import (
|
||||
SceneBattleInfo,
|
||||
SceneMonsterWave,
|
||||
SceneMonster,
|
||||
SceneEntityInfo
|
||||
SceneEntityInfo,
|
||||
BattleBuff, Avatar,
|
||||
)
|
||||
|
||||
class BattleManager:
|
||||
@@ -51,6 +54,20 @@ class BattleManager:
|
||||
for index, monster_list in enumerate(self.stages)
|
||||
]
|
||||
|
||||
def GetMazeBuffs(self, msg: SceneCastSkillCsReq)-> list[BattleBuff]:
|
||||
buffs = []
|
||||
for index, avatar_id in enumerate(self.player.lineup_manager.get(self.player.data.cur_lineup, None).avatar_list):
|
||||
if avatar_id == 1407 and msg.attacked_by_entity_id >> 20 != 1407 or avatar_id == 1407 and msg.attacked_by_entity_id >> 20 == 1407 and msg.skill_index == 0:
|
||||
continue
|
||||
for buff,lv in ResourceManager.instance().find_by_index(AvatarConfig,avatar_id).MazeBuffs.items():
|
||||
buffs.append(BattleBuff(
|
||||
id=buff,
|
||||
level=lv,
|
||||
owner_index=index,
|
||||
wave_flag=0xffffffff
|
||||
))
|
||||
return buffs
|
||||
|
||||
def EnterBattle(self, msg: SceneCastSkillCsReq, targets: list[int]) -> SceneCastSkillScRsp:
|
||||
self.stages: list[StageConfig] = []
|
||||
for entity_id in targets:
|
||||
@@ -74,7 +91,8 @@ class BattleManager:
|
||||
stage_id=self.stage_id,
|
||||
battle_id=self.battle_id,
|
||||
battle_avatar_list=self.GetBattleLineup(),
|
||||
monster_wave_list=self.GetBattleMonster()
|
||||
monster_wave_list=self.GetBattleMonster(),
|
||||
buff_list=self.GetMazeBuffs(msg)
|
||||
)
|
||||
)
|
||||
return SceneCastSkillScRsp()
|
||||
@@ -3,6 +3,8 @@ from game_server.game.enums.scene.game_mode_type import GameModeTypeEnum
|
||||
from game_server.resource import ResourceManager
|
||||
from game_server.resource.configdb.maze_plane import MazePlaneData
|
||||
from game_server.resource.configdb.map_entrance import MapEntranceData
|
||||
from game_server.resource.configdb.summon_unit_data import SummonUnitData
|
||||
|
||||
from game_server.game.motion.motion_info import Motion
|
||||
from rail_proto.lib import (
|
||||
SceneInfo,
|
||||
@@ -12,8 +14,15 @@ from rail_proto.lib import (
|
||||
SceneNpcInfo,
|
||||
SceneNpcMonsterInfo,
|
||||
SceneActorInfo,
|
||||
AvatarType
|
||||
AvatarType,
|
||||
SceneCastSkillCsReq,
|
||||
SceneGroupRefreshScNotify,
|
||||
GroupRefreshInfo,
|
||||
SceneGroupRefreshType,
|
||||
SceneEntityRefreshInfo, SceneSummonUnitInfo
|
||||
)
|
||||
from utils.time import cur_timestamp_ms
|
||||
|
||||
|
||||
class SceneManager(BaseModel):
|
||||
entry_id: int
|
||||
@@ -25,6 +34,17 @@ class SceneManager(BaseModel):
|
||||
entity_group_list: list[SceneEntityGroupInfo] = []
|
||||
entities: dict[int,SceneEntityInfo] = {}
|
||||
|
||||
@staticmethod
|
||||
def Actor(avatar_id,player_pos):
|
||||
return SceneEntityInfo(
|
||||
entity_id=avatar_id << 20,
|
||||
motion=player_pos,
|
||||
actor=SceneActorInfo(
|
||||
base_avatar_id=avatar_id,
|
||||
avatar_type=AvatarType.AVATAR_FORMAL_TYPE
|
||||
)
|
||||
)
|
||||
|
||||
def ToProto(self,session) -> SceneInfo:
|
||||
prop_entity_id = 10
|
||||
npc_entity_id = 10_000
|
||||
@@ -139,25 +159,50 @@ class SceneManager(BaseModel):
|
||||
).ToProto()
|
||||
player_group = SceneEntityGroupInfo(state=0,group_id=0)
|
||||
for avatar_id in session.player.lineup_manager.get(session.player.data.cur_lineup).avatar_list:
|
||||
player_entity = SceneEntityInfo(
|
||||
inst_id=0,
|
||||
entity_id=avatar_id << 20,
|
||||
motion=player_pos,
|
||||
actor=SceneActorInfo(
|
||||
avatar_type=AvatarType.AVATAR_FORMAL_TYPE.value,
|
||||
base_avatar_id=avatar_id,
|
||||
uid=session.player.data.uid,
|
||||
)
|
||||
)
|
||||
player_group.entity_list.append(player_entity)
|
||||
player_group.entity_list.append(self.Actor(avatar_id,player_pos))
|
||||
proto.entity_group_list.append(player_group)
|
||||
session.player.data.entry_id = self.entry_id
|
||||
session.player.data.plane_id = entrance.PlaneID
|
||||
session.player.data.floor_id = entrance.FloorID
|
||||
self.plane_id = entrance.PlaneID
|
||||
self.floor_id = entrance.FloorID
|
||||
return proto
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def SummonUnit(self,msg: SceneCastSkillCsReq,summon_id) -> SceneEntityInfo:
|
||||
return SceneEntityInfo(
|
||||
entity_id=msg.cast_entity_id,
|
||||
motion=Motion(
|
||||
x=msg.target_motion.pos.x,
|
||||
y=msg.target_motion.pos.y,
|
||||
z=msg.target_motion.pos.z,
|
||||
rotY=msg.target_motion.rot.y
|
||||
).ToProto(),
|
||||
summon_unit=SceneSummonUnitInfo(
|
||||
attach_entity_id=msg.attacked_by_entity_id,
|
||||
caster_entity_id=msg.attacked_by_entity_id,
|
||||
summon_unit_id=summon_id,
|
||||
life_time_ms=20000,
|
||||
create_time_ms=cur_timestamp_ms()
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
async def GetSummonUnit(self,session, msg: SceneCastSkillCsReq):
|
||||
summon_id = str(msg.attacked_by_entity_id >> 20) + "1"
|
||||
summon = ResourceManager.instance().find_all_by_index(SummonUnitData, summon_id)
|
||||
if summon:
|
||||
summon_unit = SceneGroupRefreshScNotify(
|
||||
floor_id=self.floor_id,
|
||||
group_refresh_list=[
|
||||
GroupRefreshInfo(
|
||||
refresh_type=SceneGroupRefreshType.SCENE_GROUP_REFRESH_TYPE_LOADED.value,
|
||||
refresh_entity=[
|
||||
SceneEntityRefreshInfo(
|
||||
add_entity=self.SummonUnit(msg,data.ID)
|
||||
)
|
||||
for data in summon
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
await session.notify(summon_unit)
|
||||
Reference in New Issue
Block a user