123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- ---
- --- Generated by EmmyLua(https://github.com/EmmyLua)
- --- Created by zhoutao.
- --- DateTime: 2024/10/28 14:17
- ---
- Player = {}
- --- 改变角色名称
- --- @param actor table 玩家对象
- --- @param msgData table 角色名称
- function Player.changeRoleName(actor, msgData)
- local roleName = msgData["roleName"]
- local isFirstChangeName = getplaydef(actor, PlayerDefKey.player.FIRST_CHANGE_NAME)
- if not string.isNullOrEmpty(isFirstChangeName) then
- local value = ConfigDataManager.getTableValue("cfg_global", "value", "id", GlobalConfigId.CHANGE_NAME_CARD_COST)
- local split = string.split(value, "|")
- local tmps = string.split(split[2], "#")
- local costItemId = tmps[1]
- local costCount = tmps[2]
- if not Bag.checkItem(actor, costItemId, costCount) then
- noticeTip.noticeinfo(actor, StringIdConst.TEXT346)
- return
- end
- if not checkrolename(actor, roleName) then
- jprint("角色名不合法 actor:" .. actor:toString() .. " roleName:" .. roleName)
- return
- end
- -- 从背包中移除指定数量的道具
- removeitemfrombag(actor, costItemId, costCount, 0, 9999, '角色改名')
- changerolename(actor, roleName)
- return
- else
- if not checkrolename(actor, roleName) then
- jprint("角色名不合法 actor:" .. actor:toString() .. " roleName:" .. roleName)
- return
- end
- changerolename(actor, roleName)
- setplaydef(actor, PlayerDefKey.player.FIRST_CHANGE_NAME, 1)
- end
- end
- --- 获取角色是否为首次改名
- --- @param actor table 玩家对象
- function Player.getRoleChangeNameInfo(actor)
- local isFirstChangeName = getplaydef(actor, PlayerDefKey.player.FIRST_CHANGE_NAME)
- sendluamsg(actor, LuaMessageIdToClient.RES_ROLE_IS_FIRST_CHANGE_NAME, isFirstChangeName and 1 or 0)
- end
- function Player.UpdateFightValue(actor)
- --默认战斗力=10*攻击+8*防御+0.25*生命+1400*1%卓越一击倍率+1160*1%幸运一击倍率+4670*1%双倍一击倍率+3400*1%攻速+3400*1%伤害加成
- local maxDC = getattrinfo(actor, "maxDC")
- local armor = getattrinfo(actor, "armor")
- local maxHP = getattrinfo(actor, "maxHP")
- local excellentDamageChance = math.max( getattrinfo(actor, "excellentDamageChance") ,1 )
- local criticalDamageChance = math.max( getattrinfo(actor, "criticalDamageChance"),1 )
- local doubleDamageChance =math.max( getattrinfo(actor, "doubleDamageChance"),1 )
- local attackSpeed = math.max( getattrinfo(actor, "attackSpeed"),1 )
- local damageRate = math.max( getattrinfo(actor, "damageRate"),1 )
- local result = 10 * maxDC + 8 * armor + 0.25 * maxHP + 1400 * excellentDamageChance * 0.01 +
- 1160 * criticalDamageChance * 0.01 +
- 4670 * doubleDamageChance * 0.01 +
- 3400 * attackSpeed * 0.01 + 3400 * damageRate * 0.01
- savefightvalue(actor, result)
- end
|