找回密码
 register
搜索
查看: 24|回复: 0

洱海月 70级一品堂剧情李秋水/天山童姥名字错误的问题修复

[复制链接]
  • 打卡等级:本地老炮
  • 打卡总天数:553
  • 打卡月天数:14
  • 打卡总奖励:550
  • 最近打卡:2026-07-14 06:29:25
Waylee 发表于 2026-7-5 10:40 | 显示全部楼层 |阅读模式 | Google Chrome | Windows 10

马上注册,查看网站隐藏内容!!

您需要 登录 才可以下载或查看,没有账号?register

×

问题位置:

服务端:
\ubuntu\tlbb\services\scripts\event\jvqing\yipin_01.lua

对应剧情:

一品堂剧情任务:一笑人间万事
死亡 NPC:
- 一品死亡童姥 -> 天山童姥
- 一品死亡李秋水 -> 李秋水

问题原因

死亡模型是通过怪物模板创建的,模板本身名字是“一品死亡童姥 / 一品死亡李秋水”。

正确做法是在服务端脚本创建 NPC 后,调用:

self:SetCharacterName(newMonst, "天山童姥")
self:SetCharacterName(newMonst, "李秋水")

进行运行时改名。

正确写法

创建死亡模型后,立即设置名字:

local newMonst = self:LuaFnCreateMonster(491, 20, 25, 1, 0, -1)
local obj = self.scene:get_obj_by_id(newMonst)
if obj then
    self:SetUnitReputationID(selfId, newMonst, 0)
    self:SetMonsterFightWithNpcFlag(newMonst, 0)
    self:SetNPCAIType(newMonst, 3)
    self:SetCharacterName(newMonst, "天山童姥")
    self:SetHp(newMonst, 1)
    self:LuaFnSendSpecificImpactToUnit(selfId, newMonst, newMonst, 44, 2)
end

李秋水同理:

local newMonst = self:LuaFnCreateMonster(492, 22, 27, 1, 0, -1)
local obj = self.scene:get_obj_by_id(newMonst)
if obj then
    self:SetUnitReputationID(selfId, newMonst, 0)
    self:SetMonsterFightWithNpcFlag(newMonst, 0)
    self:SetNPCAIType(newMonst, 3)
    self:SetCharacterName(newMonst, "李秋水")
    self:SetHp(newMonst, 1)
    self:LuaFnSendSpecificImpactToUnit(selfId, newMonst, newMonst, 44, 2)
end

避免闪烁的关键

不要在遍历怪物列表时边删边创建同名 NPC。

错误风险写法:

for ii = 1, nMonsterNum do
    local nMonsterId = self:GetMonsterObjID(ii)
    if self:GetName(nMonsterId) == "天山童姥" then
        self:LuaFnDeleteMonster(nMonsterId)
        local newMonst = self:LuaFnCreateMonster(...)
        self:SetCharacterName(newMonst, "天山童姥")
    end
end

因为新创建的 NPC 也叫“天山童姥”,可能被同一轮逻辑再次匹配,导致反复删除/创建,表现为 NPC 一闪一闪。

正确写法是先记录旧对象 ID:

local oldTonglao
local oldLiqiushui

local nMonsterNum = self:GetMonsterCount()
for ii = 1, nMonsterNum do
    local nMonsterId = self:GetMonsterObjID(ii)

    if self:GetName(nMonsterId) == "天山童姥" then
        oldTonglao = nMonsterId
    elseif self:GetName(nMonsterId) == "李秋水" then
        oldLiqiushui = nMonsterId
    end
end

然后在循环外删除并重建:

if oldTonglao then
    self:LuaFnDeleteMonster(oldTonglao)
    local newMonst = self:LuaFnCreateMonster(491, 20, 25, 1, 0, -1)
    self:SetCharacterName(newMonst, "天山童姥")
end
您需要登录后才可以回帖 登录 | register

本版积分规则

QQ|手机版|雪舞知识库 ( 浙ICP备15015590号-1 | 萌ICP备20232229号|浙公网安备33048102000118号 )|天天打卡

GMT+8, 2026-7-14 10:12 , Processed in 0.069886 second(s), 29 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表