Prechádzať zdrojové kódy

(250717) 新增部分技能; 新增彩色字体; 新增长姓名牌; 新增怪物自定义巡逻; 新增视野盲区障碍物

detopoi 1 rok pred
rodič
commit
6ec38cf803

+ 2 - 0
client_local/frame/obstacle.py

@@ -32,6 +32,8 @@ def load_obstacle(type, name):
         an_obstacle["BLOCK_FLAME"] = obstacle_json["BLOCK_FLAME"]
     if "SLIDE" in obstacle_json.keys():
         an_obstacle["SLIDE"] = obstacle_json["SLIDE"]
+    if "BLOCK_SIGHT" in obstacle_json.keys():
+        an_obstacle["BLOCK_SIGHT"] = obstacle_json["BLOCK_SIGHT"]
     if "BACKGROUND" in obstacle_json.keys():
         an_obstacle["BACKGROUND"] = bool(obstacle_json["BACKGROUND"])
     if "CAN_PUSH" in obstacle_json.keys():

+ 107 - 96
client_local/level/level.py

@@ -105,7 +105,13 @@ def get_player_mask(mask_surface, bgl):
     global _last_light_states
     # 收集当前所有光源状态 (x, y, light)
     curr = []
-    for p in [current_level.me] + current_level.npcs + list(current_level.obstacle_instances.values()):
+    for p in [current_level.me]:
+        if p.light and (not p.is_hide_sight()):
+            curr.append((p.x_pos, p.y_pos, p.light))
+    for p in current_level.npcs:
+        if p.light and (not p.is_hide_sight()):
+            curr.append((p.x_pos, p.y_pos, p.light))
+    for p in current_level.obstacle_instances.values():
         if p.light:
             curr.append((p.x_pos, p.y_pos, p.light))
     curr_key = tuple(curr)
@@ -445,10 +451,9 @@ class Level:
         if not G.SHOW_INPUT:
             G.SHOW_INPUT = True
             self.message_entry = InputEntry()   # 聊天输入框
-            self.ui_instances_top.append(self.message_entry)
         else:
             self.message_entry = InputLevel()   # 聊天输入框
-            self.ui_instances_top.append(self.message_entry)
+        self.ui_instances_top.append(self.message_entry)
         self.blood_bar = BloodBar(self.me)
         self.blood_bar.set_name(self.your_name)
         self.ui_instances_top.append(self.blood_bar)
@@ -507,113 +512,116 @@ class Level:
     def record_achievement(self):
         pass
 
-    def load_district_and_enemies(self):
-        if len(self.npcs) > 0:  # npc还没有被杀光
-            return
-        self.me.district_locked = False  # 解除玩家区域锁
-        if self.district_idx >= len(self.map_json["districts"]):  # 已完成最后一个区域
-            self.district_square = {"x1": 0, "x2": 0, "y1": 0, "y2": 0}
-            self.district_square_grid = {"x1": 0, "x2": 0, "y1": 0, "y2": 0}
-            self.district_all_finished = True
-
-            if self.check_full_achievement() and not G.HAS_RECORD_FULL:
-                G.HAS_RECORD_FULL = True
-                # 构建保存文件的路径
-                user_documents_folder = os.path.expanduser("~\\Documents")  # 获取用户的"文档"文件夹路径
-                qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE")  # 构建QQTPVE文件夹路径
-                os.makedirs(qqtpve_folder, exist_ok=True)  # 确保QQTPVE文件夹存在,如果不存在则创建
-                full_achievements_file_path = os.path.join(qqtpve_folder, "full_achievements.json")  # 构建full_achievements.json文件路径
+    def check_game_achievement(self):
+        if self.check_full_achievement() and not G.HAS_RECORD_FULL:
+            G.HAS_RECORD_FULL = True
+            # 构建保存文件的路径
+            user_documents_folder = os.path.expanduser("~\\Documents")  # 获取用户的"文档"文件夹路径
+            qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE")  # 构建QQTPVE文件夹路径
+            os.makedirs(qqtpve_folder, exist_ok=True)  # 确保QQTPVE文件夹存在,如果不存在则创建
+            full_achievements_file_path = os.path.join(qqtpve_folder, "full_achievements.json")  # 构建full_achievements.json文件路径
+            try:
+                with open(full_achievements_file_path, encoding="utf-8") as file:
+                    encrypted_data = json.load(file)
+            except:
                 try:
-                    with open(full_achievements_file_path, encoding="utf-8") as file:
+                    with open(full_achievements_file_path, encoding="utf-8_sig") as file:
                         encrypted_data = json.load(file)
                 except:
-                    try:
-                        with open(full_achievements_file_path, encoding="utf-8_sig") as file:
-                            encrypted_data = json.load(file)
-                    except:
-                        # 如果文件不存在,创建新的空的achievements.json文件
-                        encrypted_data = {"STAT": []}
-                        with open(full_achievements_file_path, 'w', encoding="utf-8") as file:
-                            json.dump(encrypted_data, file, indent=2)
-                if encrypted_data == {}:
+                    # 如果文件不存在,创建新的空的achievements.json文件
                     encrypted_data = {"STAT": []}
-                # 新的数据
-                new_data = {caesar_encrypt("name"): caesar_encrypt(G.MAP_SET_NAME),
-                            caesar_encrypt("last_map_name"): caesar_encrypt(G.MAP_NAME),
-                            caesar_encrypt("map_order"): int(caesar_encrypt(str(G.CURRENT_LEVEL))),
-                            caesar_encrypt("LV"): int(caesar_encrypt(str(self.me.blood))),
-                            caesar_encrypt("time"): caesar_encrypt(datetime.now().strftime("%Y-%m-%d %H:%M:%S")),
-                            caesar_encrypt("game_time_min"): int(caesar_encrypt(str(self.map_time//60))),
-                            caesar_encrypt("game_time_sec"): int(caesar_encrypt(str(self.map_time%60)))}
-                # 添加新的加密数据
-                encrypted_data["STAT"].append(new_data)
-                with open(full_achievements_file_path, 'w') as file:
-                    json.dump(encrypted_data, file, indent=2)
-
-            if self.check_achievement() and G.CURRENT_LEVEL==G.TOTAL_LEVEL and not G.HAS_RECORD:
-                G.HAS_RECORD = True
-                sound_player.playWin("PlayerWin")
-                # 构建保存文件的路径
-                user_documents_folder = os.path.expanduser("~\\Documents")  # 获取用户的"文档"文件夹路径
-                qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE")  # 构建QQTPVE文件夹路径
-                os.makedirs(qqtpve_folder, exist_ok=True)  # 确保QQTPVE文件夹存在,如果不存在则创建
-                achievements_file_path = os.path.join(qqtpve_folder, "achievements.json")  # 构建achievements.json文件路径
-                monster_stats_file_path = os.path.join(qqtpve_folder, "monster_stats.json")  # 构建json文件路径
+                    with open(full_achievements_file_path, 'w', encoding="utf-8") as file:
+                        json.dump(encrypted_data, file, indent=2)
+            if encrypted_data == {}:
+                encrypted_data = {"STAT": []}
+            # 新的数据
+            new_data = {
+                caesar_encrypt("name"): caesar_encrypt(G.MAP_SET_NAME),
+                caesar_encrypt("last_map_name"): caesar_encrypt(G.MAP_NAME),
+                caesar_encrypt("map_order"): int(caesar_encrypt(str(G.CURRENT_LEVEL))),
+                caesar_encrypt("LV"): int(caesar_encrypt(str(self.me.blood))),
+                caesar_encrypt("time"): caesar_encrypt(datetime.now().strftime("%Y-%m-%d %H:%M:%S")),
+                caesar_encrypt("game_time_min"): int(caesar_encrypt(str(self.map_time//60))),
+                caesar_encrypt("game_time_sec"): int(caesar_encrypt(str(self.map_time%60)))
+            }
+            # 添加新的加密数据
+            encrypted_data["STAT"].append(new_data)
+            with open(full_achievements_file_path, 'w') as file:
+                json.dump(encrypted_data, file, indent=2)
+
+        if self.check_achievement() and G.CURRENT_LEVEL == G.TOTAL_LEVEL and not G.HAS_RECORD:
+            G.HAS_RECORD = True
+            sound_player.playWin("PlayerWin")
+            # 构建保存文件的路径
+            user_documents_folder = os.path.expanduser("~\\Documents")  # 获取用户的"文档"文件夹路径
+            qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE")  # 构建QQTPVE文件夹路径
+            os.makedirs(qqtpve_folder, exist_ok=True)  # 确保QQTPVE文件夹存在,如果不存在则创建
+            achievements_file_path = os.path.join(qqtpve_folder, "achievements.json")  # 构建achievements.json文件路径
+            monster_stats_file_path = os.path.join(qqtpve_folder, "monster_stats.json")  # 构建json文件路径
 
+            try:
+                with open(achievements_file_path, encoding="utf-8") as file:
+                    encrypted_data = json.load(file)
+            except:
                 try:
-                    with open(achievements_file_path, encoding="utf-8") as file:
+                    with open(achievements_file_path, encoding="utf-8_sig") as file:
                         encrypted_data = json.load(file)
                 except:
-                    try:
-                        with open(achievements_file_path, encoding="utf-8_sig") as file:
-                            encrypted_data = json.load(file)
-                    except:
-                        # 如果文件不存在,创建新的空的achievements.json文件
-                        encrypted_data = {"STAT": []}
-                        with open(achievements_file_path, 'w', encoding="utf-8") as file:
-                            json.dump(encrypted_data, file, indent=2)
-                if encrypted_data == {}:
+                    # 如果文件不存在,创建新的空的achievements.json文件
                     encrypted_data = {"STAT": []}
-                # 新的数据
-                new_data = {caesar_encrypt("name"): caesar_encrypt(G.MAP_SET_NAME),
-                            caesar_encrypt("last_map_name"): caesar_encrypt(G.MAP_NAME),
-                            caesar_encrypt("LV"): int(caesar_encrypt(str(self.me.blood))),
-                            caesar_encrypt("time"): caesar_encrypt(datetime.now().strftime("%Y-%m-%d %H:%M:%S")),
-                            caesar_encrypt("game_time_min"): int(caesar_encrypt(str(self.map_time//60))),
-                            caesar_encrypt("game_time_sec"): int(caesar_encrypt(str(self.map_time%60))),
-                            caesar_encrypt("remain_blood"): int(caesar_encrypt(str(self.me.remain_blood)))}
-                try:
-                    # 添加新的加密数据
-                    encrypted_data["STAT"].append(new_data)
-                    with open(achievements_file_path, 'w') as file:
+                    with open(achievements_file_path, 'w', encoding="utf-8") as file:
                         json.dump(encrypted_data, file, indent=2)
-                except:
-                    pass
+            if encrypted_data == {}:
+                encrypted_data = {"STAT": []}
+            # 新的数据
+            new_data = {caesar_encrypt("name"): caesar_encrypt(G.MAP_SET_NAME),
+                        caesar_encrypt("last_map_name"): caesar_encrypt(G.MAP_NAME),
+                        caesar_encrypt("LV"): int(caesar_encrypt(str(self.me.blood))),
+                        caesar_encrypt("time"): caesar_encrypt(datetime.now().strftime("%Y-%m-%d %H:%M:%S")),
+                        caesar_encrypt("game_time_min"): int(caesar_encrypt(str(self.map_time//60))),
+                        caesar_encrypt("game_time_sec"): int(caesar_encrypt(str(self.map_time%60))),
+                        caesar_encrypt("remain_blood"): int(caesar_encrypt(str(self.me.remain_blood)))}
+            try:
+                # 添加新的加密数据
+                encrypted_data["STAT"].append(new_data)
+                with open(achievements_file_path, 'w') as file:
+                    json.dump(encrypted_data, file, indent=2)
+            except:
+                pass
 
+            try:
+                with open(monster_stats_file_path, encoding="utf-8") as file:
+                    self.encrypted_data_m = json.load(file)
+            except:
                 try:
-                    with open(monster_stats_file_path, encoding="utf-8") as file:
+                    with open(monster_stats_file_path, encoding="utf-8_sig") as file:
                         self.encrypted_data_m = json.load(file)
                 except:
-                    try:
-                        with open(monster_stats_file_path, encoding="utf-8_sig") as file:
-                            self.encrypted_data_m = json.load(file)
-                    except:
-                        # 如果文件不存在,创建新的空的json文件
-                        self.encrypted_data_m = {"STAT": []}
-                        with open(monster_stats_file_path, 'w', encoding="utf-8") as file:
-                            json.dump(self.encrypted_data_m, file, indent=2)
-                if self.encrypted_data_m == {}:
+                    # 如果文件不存在,创建新的空的json文件
                     self.encrypted_data_m = {"STAT": []}
-
-                try:
-                    for data in G.MONSTER_RECORD_LIST:
-                        self.encrypted_data_m["STAT"].append(data)
-                    with open(monster_stats_file_path, 'w') as file:
+                    with open(monster_stats_file_path, 'w', encoding="utf-8") as file:
                         json.dump(self.encrypted_data_m, file, indent=2)
-                    G.MONSTER_RECORD_LIST = []
-                except:
-                    G.MONSTER_RECORD_LIST = []
+            if self.encrypted_data_m == {}:
+                self.encrypted_data_m = {"STAT": []}
+
+            try:
+                for data in G.MONSTER_RECORD_LIST:
+                    self.encrypted_data_m["STAT"].append(data)
+                with open(monster_stats_file_path, 'w') as file:
+                    json.dump(self.encrypted_data_m, file, indent=2)
+                G.MONSTER_RECORD_LIST = []
+            except:
+                G.MONSTER_RECORD_LIST = []
 
+    def load_district_and_enemies(self):
+        if len(self.npcs) > 0:  # npc还没有被杀光
+            return
+        self.me.district_locked = False  # 解除玩家区域锁
+        if self.district_idx >= len(self.map_json["districts"]):  # 已完成最后一个区域
+            self.district_square = {"x1": 0, "x2": 0, "y1": 0, "y2": 0}
+            self.district_square_grid = {"x1": 0, "x2": 0, "y1": 0, "y2": 0}
+            self.district_all_finished = True
+            self.check_game_achievement()
             return
         self.district_idx += 1
         a_district = self.map_json["districts"][self.district_idx - 1]
@@ -634,7 +642,11 @@ class Level:
                 self.ghosts.remove(g)
         for n in a_district["npcs"]:
             # 载入新区域的npc
-            self.npcs.append(Npc(n["name"], (n["x"], n["y"])))
+            patrol = n.get("patrol", None)
+            if patrol is not None:
+                self.npcs.append(Npc(n["name"], (n["x"], n["y"]), patrol_path=patrol))
+            else:
+                self.npcs.append(Npc(n["name"], (n["x"], n["y"])))
         for district in self.map_json["districts"][self.district_idx-1:]:
             x1, y1, x2, y2 = district["square"]["x1"], district["square"]["y1"], district["square"]["x2"], district["square"]["y2"]
             for point in self.poison_dic.keys():
@@ -650,7 +662,6 @@ class Level:
                 del self.poison_dic[point]
 
     def update(self, screen: pygame.Surface):
-
         # a = pygame.time.get_ticks()
         self.current_time = pygame.time.get_ticks()
 
@@ -926,7 +937,7 @@ class Level:
                 self.scroll_y_pos = scroll_y_old - MAX_DIST
                 self.obstacle_instances_need_to_update = True
         # 限制滚动范围
-        if self.scroll_x_pos> self.scroll_x_pos_max:
+        if self.scroll_x_pos > self.scroll_x_pos_max:
             self.scroll_x_pos = self.scroll_x_pos_max
         if self.scroll_y_pos > self.scroll_y_pos_max:
             self.scroll_y_pos = self.scroll_y_pos_max

+ 72 - 0
client_local/skill/machine_skill.py

@@ -406,6 +406,78 @@ class BigTimeStop(Skill):
                     self.effect_instances.append(an_effect)
 
 
+
+# 中时间静止500伤
+class MediumTimeStop(Skill):
+
+    def __init__(self, user, to, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.loaded = True
+        self.flag_thunder_down = True  # 300ms
+        self.flag_thunder_explode = True  # 400ms
+
+    def load(self):
+        super().load()
+        self.effect_instances.append(
+            EffectInstance("thunder_charge", self.user, False, self.user.effects_front)
+        )
+        sound_player.play("launch")
+        self.user.rooted_for(1600)
+        self.user.align_xy()
+
+    def update(self):
+        super().update()
+        if self.current_time - self.skill_time_init > 2000:
+            for e in self.effect_instances:
+                e.state = EffectState.DEAD
+            self.kill()
+
+        if self.current_time - self.skill_time_init > 1000 and self.flag_thunder_down:
+            self.flag_thunder_down = False
+            for x in range(self.user_x - 2, self.user_x + 3):
+                for y in range(self.user_y - 2, self.user_y + 3):
+                    an_effect = EffectInstance("thunder_down", self.user, False, self.user.effects_front)
+                    an_effect.x_pos = x * G.GAME_SQUARE + G.HALF_GAME_SQUARE
+                    an_effect.y_pos = y * G.GAME_SQUARE + G.HALF_GAME_SQUARE
+                    self.effect_instances.append(an_effect)
+
+        if self.current_time - self.skill_time_init > 1300 and self.flag_thunder_explode:
+            self.flag_thunder_explode = False
+            me = level.current_level.me
+            for x in range(self.user_x - 2, self.user_x + 3):
+                for y in range(self.user_y - 2, self.user_y + 3):
+                    an_effect = EffectInstance("thunder_explode", self.user, False, self.user.effects_front)
+                    an_effect.x_pos = x * G.GAME_SQUARE + G.HALF_GAME_SQUARE
+                    an_effect.y_pos = y * G.GAME_SQUARE + G.HALF_GAME_SQUARE
+                    self.effect_instances.append(an_effect)
+                    if me.x == x and me.y == y:
+                        self.dizzy_rooted_effect = EffectInstance("reverse", self.to, True, self.to.effects_front)
+                        self.to.try_damage(500)
+                        self.to.rooted_for(2500)
+                        sound_player.play("cry")
+            self.user.rooted -= 1
+            sound_player.play("crash")
+            sound_player.play("explode2")
+
+        if self.loaded:
+            # 显示火焰提示与npc施法阵
+            self.loaded = False
+            self.user.rooted += 1
+            self.user.align_xy()
+            self.effect_instances.append(
+                EffectInstance("violent", self.user, False, level.current_level.effects_behind)
+            )
+            self.effect_instances.append(
+                EffectInstance("violent", self.user, False, level.current_level.effects_behind)
+            )
+            for x in range(self.user_x - 2, self.user_x + 3):
+                for y in range(self.user_y - 2, self.user_y + 3):
+                    an_effect = EffectInstance("thunder_trap", self.user, False, level.current_level.effects_behind)
+                    an_effect.set_xy(x, y)
+                    self.effect_instances.append(an_effect)
+
+
+
 # 反向5s(非直接使用的技能)
 class Reverse5s(Skill):
 

+ 23 - 0
client_local/skill/parametric2_skill.py

@@ -276,6 +276,29 @@ class CustomMessage(Skill):
 
 
 
+# 发送消息({"sender": "me", "text": "hello world", "colour": (r,g,b)})
+class CustomColourfulMessage(Skill):
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.load = False
+        self.sender = params.get("sender", "??")
+        self.text = params.get("text", "??")
+        self.colour = tuple(params.get("colour", [255, 255, 255]))
+
+    def update(self):
+        super().update()
+        if not self.load:
+            self.load = True
+            level.current_level.message_entry.new_message(sender=self.sender, message=self.text, colour=self.colour)
+            self.kill()
+
+
+
+
+
+
+
+
 
 # 困在水泡里([输入哈希(如{"U":2, "D":2, "L":2, "R":2}), 破裂伤害])
 class CustomInBubble(Skill):

+ 25 - 0
client_local/skill/parametric_skill.py

@@ -3273,5 +3273,30 @@ class KillAllExcept(Skill):
 
 
 
+# 杀掉指定地点怪物
+class KillMonsterInCustomPosition(Skill):
+
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.trigger = True
+        self.point = (params.get("x", 0), params.get("y", 0))
+
+    def load(self):
+        super().load()
+
+    def update(self):
+        super().update()
+        if self.trigger:
+            self.trigger = False
+            for npc in self.to:
+                if (npc.x, npc.y) == self.point:
+                    npc.remain_blood = -1
+                    npc.die()
+
+        if self.current_time - self.skill_time_init > 200:
+            self.kill()
+            return
+
+
 
 

+ 3 - 0
client_local/skill/skill_map.py

@@ -101,6 +101,7 @@ skill_map = {
     "EnergyShield": {"skill": EnergyShield, "target": None, "param": None, "effect": "cl"},
     "TimeStop": {"skill": TimeStop, "target": "me", "param": None, "effect": "cl"},
     "BigTimeStop": {"skill": BigTimeStop, "target": "me", "param": None, "effect": "cl"},
+    "MediumTimeStop": {"skill": MediumTimeStop, "target": "me", "param": None, "effect": "cl"},
     "TimeExplode": {"skill": TimeExplode, "target": "me", "param": None, "effect": "cl"},
     "ReversePoisonFogExplode": {"skill": ReversePoisonFogExplode, "target": "me", "param": None, "effect": "cl"},
     "PoisonFog1000x5": {"skill": PoisonFog1000x5, "target": "me", "param": None, "effect": "cl"},
@@ -281,11 +282,13 @@ skill_map = {
     "CustomModeSwitch": {"skill": CustomModeSwitch, "target": None, "param": True, "effect": "self"},
     "DirectPointSpawn": {"skill": DirectPointSpawn, "target": "me", "param": True, "effect": "self"},
     "KillAllExcept": {"skill": KillAllExcept, "target": "npcs", "param": True, "effect": "self"},
+    "KillMonsterInCustomPosition": {"skill": KillMonsterInCustomPosition, "target": "npcs", "param": True, "effect": "self"},
     "CustomMoveDirection": {"skill": CustomMoveDirection, "target": "npcs", "param": True, "effect": "self"},
     "CustomOnGridBasedSkill": {"skill": CustomOnGridBasedSkill, "target": "me", "param": True, "effect": "self"},
     "CustomChaseMonster": {"skill": CustomChaseMonster, "target": "npcs", "param": True, "effect": "self"},
     "CustomMonsterTargetedSword5x5": {"skill": CustomMonsterTargetedSword5x5, "target": "npcs", "param": True, "effect": "self"},
     "CustomMessage": {"skill": CustomMessage, "target": "me", "param": True, "effect": "self"},
+    "CustomColourfulMessage": {"skill": CustomColourfulMessage, "target": "me", "param": True, "effect": "self"},
     "CustomWaterBubbleDistanceAttack": {"skill": CustomWaterBubbleDistanceAttack, "target": "me", "param": True, "effect": "self"},
     "CustomGroupSourceWaterFlow": {"skill": CustomGroupSourceWaterFlow, "target": "me", "param": True, "effect": "cl"},
     "CustomGroupDirectionLaserFireBall": {"skill": CustomGroupDirectionLaserFireBall, "target": "me", "param": True, "effect": "cl"},

+ 108 - 24
client_local/sprite/npc.py

@@ -23,6 +23,29 @@ user_documents_folder = os.path.expanduser("~\\Documents")  # 获取用户的"
 qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE")  # 构建QQTPVE文件夹路径
 os.makedirs(qqtpve_folder, exist_ok=True)  # 确保QQTPVE文件夹存在,如果不存在则创建
 monster_stats_file_path = os.path.join(qqtpve_folder, "monster_stats.json")  # 构建json文件路径
+name_card_img_dict = dict()
+
+
+def init_name_card_img_dict():
+    global name_card_img_dict
+    if name_card_img_dict != dict():
+        return
+    name_card_img_dict = {
+        "blue":   load_png("res/img/ui/game/misc171.png").convert_alpha(),
+        "red":    load_png("res/img/ui/game/misc169.png").convert_alpha(),
+        "purple": load_png("res/img/ui/game/misc170.png").convert_alpha(),
+        "green":  load_png("res/img/ui/game/misc172.png").convert_alpha(),
+        "blue_long":   load_png("res/img/ui/game/misc171_long.png").convert_alpha(),
+        "red_long":    load_png("res/img/ui/game/misc169_long.png").convert_alpha(),
+        "purple_long": load_png("res/img/ui/game/misc170_long.png").convert_alpha(),
+        "green_long":  load_png("res/img/ui/game/misc172_long.png").convert_alpha(),
+    }
+
+
+def get_name_card_img(colour: str, length: int):
+    if length >= 88:
+        return name_card_img_dict[f"{colour}_long"]
+    return name_card_img_dict[colour]
 
 
 def caesar_encrypt(text, k=3):
@@ -52,7 +75,7 @@ def render_digit(screen, number, x_pos, y_pos, alpha, offset=0):
 
 class Npc(Player, Throwable):
 
-    def __init__(self, npc_name, xy, color=C.CHARACTER_RED):
+    def __init__(self, npc_name, xy, color=C.CHARACTER_RED, patrol_path=None):
         super(Npc, self).__init__(npc_name, xy, color)
         self.npc_json = None
         self.chs_name = None  # Npc中文名
@@ -67,6 +90,15 @@ class Npc(Player, Throwable):
         self.refresh = 0
         self.original_speed = 0
 
+        self.has_patrol = False
+        self.patrol_path = patrol_path
+        if self.patrol_path is not None:
+            self.has_patrol = True
+            self.patrol_nodes_num = len(self.patrol_path)
+            self.current_patrol_node = 0
+            self.patrol_last_wait_time = 0
+            self.is_patrol_switch = True
+
         self.is_dead = False
         self.is_ghost = False  # 幽灵模式
         self.fake_blood = 0
@@ -86,7 +118,7 @@ class Npc(Player, Throwable):
         self.chasing_monster = False
         self.chasing_monster_target = None
         self.recal_chasing_monster = False
-        self.chasing_point = (1,1)
+        self.chasing_point = (1, 1)
         self.imitating = False
         self.combo_num = 1
         self.is_combo_target = False
@@ -104,14 +136,15 @@ class Npc(Player, Throwable):
         self.chase_path = None  # Npc追踪路径
         self.npc_skill_time = pygame.time.get_ticks()  # npc施放技能时的时刻 设为成员变量是为了统一多个技能的时间
         self.is_skill_init = False
-        self.chs_name_bg = load_png(r"res/img/ui/game/misc171.png")  # Npc姓名牌背景
+        init_name_card_img_dict()
+        self.chs_name_bg = name_card_img_dict["blue"]  # Npc姓名牌背景
+        self.name_bg_x_offset = 40
         # self.chs_name_bg = pygame.image.load("res/img/ui/game/misc171.png").convert_alpha()  # Npc姓名牌背景
         self.blood_bar = None
         self.blood_bar_pos = 0
         self.profile = None
         # self.head_cx = -100000
         # self.head_cy = -100000
-
         self.chs_name_font = pygame.font.Font("res/font/simsun.ttc", 13)  # Npc姓名牌字体
         self.chs_name_text = None  # Npc姓名牌前景文字
         self.chs_name_text_shadow = None  # Npc姓名牌背景文字
@@ -127,10 +160,13 @@ class Npc(Player, Throwable):
 
     def load_npc(self, npc_name, color):
         # 加载npc的json文件
-        self.npc_json = load_json("game/npc/" + npc_name + ".json")
+        self.npc_json = load_json(f"game/npc/{npc_name}.json")
         self.chs_name = self.npc_json["chs_name"]
+        self.chs_name_bg = get_name_card_img("blue", self.chs_name_font.size(self.chs_name)[0])
+        if self.chs_name_font.size(self.chs_name)[0] >= 88:
+            self.name_bg_x_offset = 61
         self.blood = self.npc_json["blood"]
-        self.light = self.npc_json.get("light",self.light)
+        self.light = self.npc_json.get("light", self.light)
         if "self_damage_blood" in self.npc_json.keys():
             self.self_damage_blood = self.npc_json["self_damage_blood"]
         self.speed = (self.npc_json["speed"] * G.GAME_SQUARE) / 1000
@@ -143,7 +179,7 @@ class Npc(Player, Throwable):
         if "elite" in self.npc_json.keys():
             if self.npc_json["elite"]:
                 try:
-                    self.chs_name_bg = load_png("res/img/ui/game/misc170.png")
+                    self.chs_name_bg = get_name_card_img("purple", self.chs_name_font.size(self.chs_name)[0])
                     # self.chs_name_bg = pygame.image.load("res/img/ui/game/misc170.png").convert_alpha()  # Npc姓名牌背景
                 except:
                     pass
@@ -151,14 +187,14 @@ class Npc(Player, Throwable):
             if self.npc_json["boss"]:
                 self.boss_mode = True
                 try:
-                    self.chs_name_bg = load_png("res/img/ui/game/misc169.png")
+                    self.chs_name_bg = get_name_card_img("red", self.chs_name_font.size(self.chs_name)[0])
                     # self.chs_name_bg = pygame.image.load("res/img/ui/game/misc169.png").convert_alpha()  # Npc姓名牌背景
                 except:
                     pass
         if "ally" in self.npc_json.keys():
             if self.npc_json["ally"]:
                 try:
-                    self.chs_name_bg = load_png("res/img/ui/game/misc172.png")
+                    self.chs_name_bg = get_name_card_img("green", self.chs_name_font.size(self.chs_name)[0])
                     # self.chs_name_bg = pygame.image.load("res/img/ui/game/misc172.png").convert_alpha()  # Npc姓名牌背景
                 except:
                     pass
@@ -258,21 +294,24 @@ class Npc(Player, Throwable):
         # 初始化时刻小于0.3s
         if current_time - self.npc_time_init < 300:
             return
-         # 随机运动时间
-        if (current_time - self.last_motion) >= 50 * self.last_random:
-            if self.speed >= (5.8 * G.GAME_SQUARE) / 1000:
-                self.last_random = random.randint(5, 15)
-            if 0 <= (current_time % 1200) <= 300 or (random.randint(1, 100) >= 85):
-                self.last_motion = current_time
-                if random.randint(1, 100) >= 25:
-                    motion = self.idx_motion[random.randint(0, 3)]
-                    self.set_motion(motion)
+        if self.has_patrol:
+            self.patrol()
+        else:
+            # 随机运动时间
+            if (current_time - self.last_motion) >= 50 * self.last_random:
+                if self.speed >= (5.8 * G.GAME_SQUARE) / 1000:
+                    self.last_random = random.randint(5, 15)
+                if 0 <= (current_time % 1200) <= 300 or (random.randint(1, 100) >= 85):
+                    self.last_motion = current_time
+                    if random.randint(1, 100) >= 25:
+                        motion = self.idx_motion[random.randint(0, 3)]
+                        self.set_motion(motion)
+                    else:
+                        self.set_motion(self.orientation)
                 else:
                     self.set_motion(self.orientation)
             else:
                 self.set_motion(self.orientation)
-        else:
-            self.set_motion(self.orientation)
         # 技能初始时间更新
         for i in range(len(self.skill_names)):
             # 游荡状态下,技能初始时间永远等于当前时刻加init值
@@ -281,11 +320,57 @@ class Npc(Player, Throwable):
         # 检测与玩家的距离
         me: Hero = level.current_level.me
         if me.district_locked and me.state == PlayerState.NORMAL:
-            if abs(me.x_pos - self.x_pos) < self.resent_dist and abs(me.y_pos - self.y_pos) < self.resent_dist:
-                # 如果玩家活着、已进入区域锁,并且距离小于临界值 则产生玩家仇恨
+            if abs(me.x_pos - self.x_pos) < self.resent_dist and abs(me.y_pos - self.y_pos) < self.resent_dist and not me.is_hide_sight():
+                # 如果玩家活着、已进入区域锁,并且距离小于临界值 且不被障碍阻碍视野 则产生玩家仇恨
                 self.resentful = True
                 level.current_level.recal_npc_paths = True
 
+    def patrol(self):
+        current_node = self.patrol_path[self.current_patrol_node]  # e.g. ["stop",5000]
+        if current_node[0] == "stop":
+            if self.is_patrol_switch:
+                self.is_patrol_switch = False
+                self.patrol_last_wait_time = pygame.time.get_ticks()
+            if pygame.time.get_ticks() - self.patrol_last_wait_time >= current_node[1]:
+                self.current_patrol_node = (self.current_patrol_node + 1) % self.patrol_nodes_num
+                self.is_patrol_switch = True
+                level.current_level.recal_npc_paths = True
+                self.set_motion()
+                return
+            return
+        else:
+            now = (self.x, self.y)
+            target = (current_node[1][0], current_node[1][1])
+            if now == target:
+                self.current_patrol_node = (self.current_patrol_node + 1) % self.patrol_nodes_num
+                self.chase_path.clear()
+                self.is_patrol_switch = True
+                self.set_motion()
+                return
+            if self.is_patrol_switch or level.current_level.recal_npc_paths:
+                if self.is_patrol_switch:
+                    self.is_patrol_switch = False
+                self.chase_path = aStar.cal_path(
+                    now, target,
+                    (level.current_level.district_square_grid["x1"], level.current_level.district_square_grid["y1"]),
+                    (level.current_level.district_square_grid["x2"], level.current_level.district_square_grid["y2"]),
+                    is_ghost=self.is_ghost
+                )
+            if now in self.chase_path.keys():
+                _next = self.chase_path[now]
+                if _next is None:
+                    self.set_motion()
+                elif _next[0] > self.x:
+                    self.set_motion("R")
+                elif _next[1] < self.y:
+                    self.set_motion("U")
+                elif _next[0] < self.x:
+                    self.set_motion("L")
+                elif _next[1] > self.y:
+                    self.set_motion("D")
+            else:
+                self.set_motion()
+
     def chase_hero(self):
         if (not self.resentful and not self.mocking) or self.friendly or self.imitating or (self.speed == 0 and self.original_speed == 0):
             return
@@ -299,7 +384,6 @@ class Npc(Player, Throwable):
             self.set_motion()
             return
         now = (self.x, self.y)
-        path_map = level.current_level.path_map
         # 如果重新计算路径标志为True则重新追踪玩家
         if level.current_level.recal_npc_paths:
             self.chase_path = aStar.cal_path(
@@ -598,7 +682,7 @@ class Npc(Player, Throwable):
         super().draw(screen)
         if G.DISPLAY_NPC_NAME_CARD and self.chs_name_show:
             self.chs_name_bg.set_alpha(self.temporary_alpha)
-            screen.blit(self.chs_name_bg, (self.x_pos - 40, self.y_pos - 100))
+            screen.blit(self.chs_name_bg, (self.x_pos - self.name_bg_x_offset, self.y_pos - 100))
             self.chs_name_text_shadow.set_alpha(self.temporary_alpha)
             screen.blit(self.chs_name_text_shadow, (self.x_pos + 3 - self.chs_name_text_half_width, self.y_pos - 95))
             self.chs_name_text.set_alpha(self.temporary_alpha)

+ 26 - 20
client_local/sprite/obstacle_instance.py

@@ -18,24 +18,26 @@ from datetime import datetime
 # 配置logging基础配置并设置日志级别为INFO
 # logging.basicConfig(filename='OBSTACLE_SKILL.log', level=logging.INFO)
 
-giftsDefault = {'item_blue_gem': 0.05,
-                     'item_book': 0.6,
-                     'item_bottle': 0.7,
-                     'item_cabbage': 0.8,
-                     'item_cucumber': 0.8,
-                     'item_drop': 0.6,
-                     'item_grape': 0.6,
-                     'item_green_gem': 0.05,
-                     'item_herb': 0.6,
-                     'item_knife': 0.5,
-                     'item_paper': 0.5,
-                     'item_pearl': 0.4,
-                     'item_plume': 0.6,
-                     'item_red_gem': 0.1,
-                     'item_rice_paper': 0.5,
-                     'item_wood': 0.5,
-                     'item_yellow_gem': 0.05,
-                     'item_yellow_vegetable': 0.7}
+giftsDefault = {
+    'item_blue_gem': 0.05,
+    'item_book': 0.6,
+    'item_bottle': 0.7,
+    'item_cabbage': 0.8,
+    'item_cucumber': 0.8,
+    'item_drop': 0.6,
+    'item_grape': 0.6,
+    'item_green_gem': 0.05,
+    'item_herb': 0.6,
+    'item_knife': 0.5,
+    'item_paper': 0.5,
+    'item_pearl': 0.4,
+    'item_plume': 0.6,
+    'item_red_gem': 0.1,
+    'item_rice_paper': 0.5,
+    'item_wood': 0.5,
+    'item_yellow_gem': 0.05,
+    'item_yellow_vegetable': 0.7
+}
 
 
 def custom_deepcopy(item):
@@ -86,6 +88,7 @@ class ObstacleInstance(Updatable):
         self.type_num = 0
         self.current_type = -1
         self.last_type_switch_time = 0
+        self.block_sight = False
 
         self.setup()
         self.effects_behind = list()
@@ -130,6 +133,9 @@ class ObstacleInstance(Updatable):
             if "PUSH_TIME" in self.obstacle.keys():
                 self.push_time = int(self.obstacle["PUSH_TIME"])
 
+        if "BLOCK_SIGHT" in self.obstacle.keys():
+            self.block_sight = int(self.obstacle["BLOCK_SIGHT"])
+
         if "CONTACT" in self.obstacle.keys():
             self.contact_damage = int(self.obstacle["CONTACT"])
 
@@ -212,13 +218,13 @@ class ObstacleInstance(Updatable):
                         self.setup()
             elif direction == 'L':
                 if (self.x - 1, self.y) not in self.obstacle_instances_dict and len(level.current_level.get_bomb_instance(self.x - 1, self.y)) == 0:
-                    if self.x-1>=0:
+                    if self.x-1 >= 0:
                         self.uninstall()
                         self.x -= 1
                         self.setup()
             elif direction == 'D':
                 if (self.x, self.y + 1) not in self.obstacle_instances_dict and len(level.current_level.get_bomb_instance(self.x, self.y + 1)) == 0:
-                    if self.y+1<G.CURRENT_MAP_HEIGHT:
+                    if self.y+1 < G.CURRENT_MAP_HEIGHT:
                         self.uninstall()
                         self.y += 1
                         self.setup()

+ 1 - 2
client_local/sprite/player.py

@@ -211,7 +211,7 @@ class Player(updatable.Updatable):
     def load_character(self, character_name, color, decorations: dict, is_ghost=False):
         # 加载角色character
 
-        character_json = load_json("game/frame/character/" + character_name + ".json")
+        character_json = load_json(f"game/frame/character/{character_name}.json")
         if "HEAD_POS" in character_json.keys():
             self.head_cx, self.head_cy = character_json["HEAD_POS"][0], character_json["HEAD_POS"][1]
         # self.light = character_json.get("LIGHT", self.light)
@@ -817,7 +817,6 @@ class Player(updatable.Updatable):
             for s in self.skill_instances:
                 self.skill_instances.remove(s)
 
-
     def get_y(self):
         # return self.y + 0.1
         return self.y_pos/40

+ 13 - 0
client_local/sprite/updatable.py

@@ -64,6 +64,19 @@ class Updatable(pygame.sprite.Sprite):
                 ret = True
         return ret
 
+    def is_hide_sight(self):
+        ret = False
+        ois = level.current_level.obstacle_instances
+        # if (self.x, self.y) in ois.keys():
+        #     an_obstacle = ois[(self.x, self.y)]
+        #     if an_obstacle.block_sight:
+        #         self.blank_img()
+        #         ret = True
+        if (self.x, self.y) in ois.keys():
+            if ois[(self.x, self.y)].block_sight:
+                ret = True
+        return ret
+
     def blank_img(self):
         # 清空image
         self.image = pygame.Surface((1, 1), pygame.SRCALPHA, 32)

+ 9 - 1
client_local/ui/game/game_top.py

@@ -1,12 +1,20 @@
+import os
 import pygame
+import pygame.freetype as freetype
 from client_local.ui.ui import UIInstance
 
+Current_Path = os.getcwd()
+FONT_PATH = Current_Path + r"\res\font\simsun.ttc"
+# FONT_PATH = Current_Path + r"\res\font\hk4e_zh-cn.ttf"
+# FONT_PATH = Current_Path + r"\res\font\SourceHanSerif-VF.ttc"
+# FONT_PATH = "Arial"
+
 
 class GameTop(UIInstance):
 
     def __init__(self):
         super().__init__("game", "gameTop")
-        self.font = pygame.font.Font("res/font/simsun.ttc", 16)
+        self.font = pygame.font.Font(FONT_PATH, 16)
         self.rend = self.font.render("v20250712", True, (0, 196, 255))
 
     def draw(self, screen: pygame.Surface):

+ 6 - 6
client_local/ui/game/message_input.py

@@ -22,14 +22,14 @@ _font_small = freetype.Font(FONT_PATH, 12)
 
 
 class Message:
-    def __init__(self, sender: str, text: str, duration_ms: int = 20000):
+    def __init__(self, sender: str, text: str, duration_ms: int = 20000, colour: tuple = (255, 255, 255)):
         self.sender = sender
         self.text = text
         self.start = pygame.time.get_ticks()
         self.duration = duration_ms
         content = f"{sender}:{text}" if text else sender
         self.shadow_surf, _ = _font_small.render(content, fgcolor=(0, 0, 0))
-        self.text_surf, _ = _font_small.render(content, fgcolor=(255, 255, 255))
+        self.text_surf, _ = _font_small.render(content, fgcolor=colour)
 
     def expired(self) -> bool:
         return pygame.time.get_ticks() - self.start > self.duration
@@ -148,8 +148,8 @@ class InputEntry(pygame.sprite.Sprite):
             screen.blit(msg.shadow_surf, (x0 + 1, y0 - dy + 1))
             screen.blit(msg.text_surf, (x0, y0 - dy))
 
-    def new_message(self, sender='', message=''):
-        self.messages.insert(0, Message(sender, message))
+    def new_message(self, sender='', message='', colour=(255, 255, 255)):
+        self.messages.insert(0, Message(sender, message, colour=colour))
         if len(self.messages) > self.max_msgs:
             self.messages.pop()
         self.last_msg_time = time.time()
@@ -186,8 +186,8 @@ class InputLevel(pygame.sprite.Sprite):
             screen.blit(msg.shadow_surf, (x0 + 1, y0 - dy + 1))
             screen.blit(msg.text_surf, (x0, y0 - dy))
 
-    def new_message(self, sender='', message=''):
-        self.messages.insert(0, Message(sender, message))
+    def new_message(self, sender='', message='', colour=(255, 255, 255)):
+        self.messages.insert(0, Message(sender, message, colour=colour))
         if len(self.messages) > self.max_msgs:
             self.messages.pop()
         self.last_msg_time = time.time()