12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277 |
- ---
- --- Generated by EmmyLua(https://github.com/EmmyLua)
- --- Created by zhangkai.
- --- DateTime: 2024/7/25 下午8:55
- ---
- MonsterScript = {}
- local this = {}
- ---玩家击杀怪物记录
- local MONSTER_DROP_RECORD = "T$monster_drop_record"
- --全服道具掉落记录(每日清空数据)
- local GLOBAL_ITEM_DROP = "Q$global_item_record"
- ---怪物组掉落记录
- local DECAY_GROUP_RECORD = "T$decay_group_record"
- ---怪物组记录重置时间
- local DECAY_GROUP_REST_TIME = "T$decay_group_rest_time"
- ---怪物首刀信息记录
- local MONSTER_FIRST_ATTACK_INFO = "@monster_first_attack_info"
- ---怪物伤害列表
- local MONSTER_HURT_LIST = "@monster_hurt_list"
- ---道具掉落限制类型
- local ItemLimitType = {
- -- 小时限制
- HOUR = 1,
- -- 天限制
- DAY = 2
- }
- local MonsterType = {
- ---普通怪
- NORMAL = 1
- }
- ---怪物掉落类型
- local DropType = {
- ---无归属
- NOT_OWNER = 0,
- ---最大伤害
- MAX_THREAT = 1,
- ---尾刀(击杀者)
- LAST_ATTACK = 2,
- ---最大伤害
- MAX_HURT = 3,
- ---参与者
- PARTAKE = 4,
- ---获取首刀玩家
- FIRST_ATTACK = 5
- }
- ---怪物仇恨类型
- local ThreatType = {
- ---累计仇恨值越高,优先级越高
- MAX_HATE = 1,
- ---目标对怪物的总伤害越高,优先级越高
- MAX_HURT = 2
- }
- function this.GetMonsterDropRecord(actor)
- local dropRecord = getplaydef(actor, MONSTER_DROP_RECORD)
- if dropRecord == nil then
- dropRecord = {}
- end
- return dropRecord
- end
- function this.SaveMonsterDropRecord(actor, dropRecord)
- setplaydef(actor, MONSTER_DROP_RECORD, dropRecord)
- end
- function this.GetGlobalItemDrop()
- local itemDrop = getsysvar(GLOBAL_ITEM_DROP)
- if itemDrop == nil then
- itemDrop = {}
- end
- return itemDrop
- end
- function this.SaveGlobalItemDrop(itemDrop)
- setsysvar(GLOBAL_ITEM_DROP, itemDrop)
- end
- function this.GetDecayGroupRecord(actor)
- local record = getplaydef(actor, DECAY_GROUP_RECORD)
- if record == nil then
- record = {}
- end
- return record
- end
- function this.SaveDecayGroupRecord(actor, record)
- setplaydef(actor, DECAY_GROUP_RECORD, record)
- end
- function this.GetDecayGroupRestTime(actor)
- local restTime = getplaydef(actor, DECAY_GROUP_REST_TIME)
- if restTime == nil then
- return 0
- end
- return restTime
- end
- function this.SaveDecayGroupRestTime(actor, restTime)
- setplaydef(actor, DECAY_GROUP_REST_TIME, restTime)
- end
- function this.GetMonsterFirstAttack(monsterActor)
- local firstAttackInfo = getplaydef(monsterActor, MONSTER_FIRST_ATTACK_INFO)
- if firstAttackInfo == nil then
- firstAttackInfo = {}
- end
- return firstAttackInfo
- end
- function this.SaveMonsterFirstAttack(monsterActor, firstAttackInfo)
- setplaydef(monsterActor, MONSTER_FIRST_ATTACK_INFO, firstAttackInfo)
- end
- function this.GetMonsterHurtList(monsterActor)
- local hurtList = getplaydef(monsterActor, MONSTER_HURT_LIST)
- if hurtList == nil then
- hurtList = {}
- end
- return hurtList
- end
- function this.SaveMonsterHurtList(monsterActor, hurtList)
- setplaydef(monsterActor, MONSTER_HURT_LIST, hurtList)
- end
- ---获取怪物首刀归属时长限制
- function this.GetMonsterFirstAttackTimeLimit()
- local timeLimit =
- tonumber(
- ConfigDataManager.getTableValue("cfg_global", "value", "id", GlobalConfigId.MONSTER_FIRST_ATTACK_TIME_LIMIT)
- )
- if timeLimit == nil then
- return 0
- end
- return timeLimit
- end
- ---获取怪物最高伤害归属时长限制
- function this.GetMonsterMaxHurtTimeLimit()
- local timeLimit =
- tonumber(
- ConfigDataManager.getTableValue("cfg_global", "value", "id", GlobalConfigId.MONSTER_MAX_HURT_TIME_LIMIT)
- )
- if timeLimit == nil then
- return 0
- end
- return timeLimit
- end
- ---怪物死亡触发
- function MonsterScript.MonsterDieTrigger(monsterActor, dieParam)
- local success, errorInfo = xpcall(this.MonsterDieTrigger, debug.traceback, monsterActor, dieParam)
- gameDebug.assertPrint(success, "怪物死亡触发事件异常:", monsterActor, dieParam, errorInfo)
- end
- ---怪物死亡触发的功能
- function this.MonsterDieTrigger(monsterActor, dieParam)
- local mapId = tonumber(dieParam["mapid"])
- local monsterCfgId = tonumber(dieParam["monstercfg"])
- local killerId = tonumber(dieParam["killer"])
- local mongenCfgId = tonumber(dieParam["mongencfg"])
- local maxHurtRid = tonumber(dieParam["maxhurt"])
- local ownerId = tonumber(dieParam["owner"])
- --更新怪物复活时间
- MonsterScript.updateMonsterReliveTime(monsterActor, monsterCfgId)
- local killerActor = getactor(killerId, mapId)
- local ownerActor = getactor(ownerId, mapId)
- local type = getbaseinfo(monsterActor, "mapobjecttype")
- if type == MapObjectType.PET then
- --宠物死亡
- Pet.PetDie(monsterActor, monsterCfgId)
- return
- end
- if (killerId == nil or killerId == 0) and (ownerId == nil or ownerId == 0) then
- error("怪物死亡触发事件参数异常, killId、ownerId为空:", monsterActor, dieParam)
- return
- end
- if killerId == nil or killerId == 0 or killerActor == nil then
- killerActor = ownerActor
- end
- --更新黄金任务
- GoldTask.UpdateTaskProgress(killerActor, monsterCfgId)
- --更新boss悬赏
- BossBounty.KillMonster(killerActor, monsterCfgId)
- --更新开服首杀
- OpenServerAct.UpdateFirstKill(killerActor, maxHurtRid, 0, monsterCfgId)
- --更新黄金首杀
- GoldFirstKill.UpdateTaskProgress(killerActor, monsterCfgId)
- --更新大天使福利任务
- AngelBenefit.UpdateTaskProgress(killerActor, AngelBenefit.TASK_TYPE.MONSTER, monsterCfgId)
- --更新诸神降临活动数据
- GodsDescended.monsterDie(monsterActor, ownerActor, monsterCfgId)
- --更新圣域BOSS数据
- SanctuaryBoss.monsterDie(monsterActor)
- --更新猎魔勋章数据
- MonsterHunt.MonsterDie(ownerId, monsterCfgId)
- --触发任务目标刷新
- this.TriggerMonsterDieTaskGoal(monsterActor, killerActor, monsterCfgId, mongenCfgId)
- end
- ---更新怪物死亡任务目标
- function this.TriggerMonsterDieTaskGoal(monsterActor, actor, monsterCfgId, mongenCfgId)
- local owner = this.GetFirstAttack(monsterActor, actor)
- TaskHandler.TriggerTaskGoal(owner, TaskTargetType.KILL_LEVEL_MONSTER, monsterCfgId)
- -- 触发任务目标
- local cfg_map_id = getbaseinfo(actor, "mapid")
- local param = {
- [1] = monsterCfgId,
- [2] = cfg_map_id,
- [3] = mongenCfgId
- }
- TaskHandler.TriggerTaskGoal(owner, TaskTargetType.KILL_TYPE_MONSTER, param)
- TaskHandler.TriggerTaskGoal(actor, TaskTargetType.LAST_KILL_MONSTER, param)
- TaskHandler.TriggerTaskGoal(owner, TaskTargetType.FIRST_ATTACK_MONSTER, param)
- end
- ---获取首刀玩家
- function this.GetFirstAttack(monsterActor, killer)
- local owner = nil
- --改为首刀归属
- local firstAttack = this.GetMonsterFirstAttack(monsterActor)
- if not table.isNullOrEmpty(firstAttack) then
- local mapId = getbaseinfo(killer, "unimapid")
- owner = getactor(firstAttack["rid"], mapId)
- end
- if owner == nil then
- owner = killer
- end
- return owner
- end
- function MonsterScript.updateMonsterReliveTime(monsterActor, monsterCfgId)
- local success, errorInfo = xpcall(this.updateMonsterReliveTime, debug.traceback, monsterActor, monsterCfgId)
- gameDebug.assertPrint(success, "怪物死亡更新复活时间异常:", monsterActor, monsterCfgId, errorInfo)
- end
- --- 更新怪物复活时间
- function this.updateMonsterReliveTime(monsterActor, monsterCfgId)
- local ai = ConfigDataManager.getTableValue("cfg_monster", "ai", "id", monsterCfgId)
- if ai == nil then
- error("updateMonsterReliveTime cfg_monster表ai字段为空 monsterCfgId:" .. monsterCfgId)
- return
- end
- local aiConfig = ConfigDataManager.getById("cfg_monster_ai", ai)
- if aiConfig == nil then
- error("updateMonsterReliveTime cfg_monster_ai为nil id:" .. ai)
- return
- end
- local reliveType = tonumber(aiConfig["relivetype"])
- --local str = aiConfig['relivedelay']
- if reliveType == 4 then
- local str = aiConfig["reliveservicetime"]
- if string.isNullOrEmpty(str) then
- return
- end
- -- 1#50|3#100|6#150
- local strShuXian = string.split(str, "|")
- --local serverOpenDays1 = tonumber(getserveropendays(monsterActor))
- local serverOpenDays = getbaseinfo(monsterActor, "serveropendays")
- local cfg = {}
- for _, v in pairs(strShuXian) do
- local strJinHao = string.split(v, "#")
- local day = tonumber(strJinHao[1])
- if tonumber(serverOpenDays) >= day then
- cfg = strJinHao
- end
- end
- if table.isNullOrEmpty(cfg) then
- error("updateMonsterReliveTime 未找到匹配的数据 开服天数:" .. tostring(serverOpenDays) .. ",reliveDelay字段内容:" .. str)
- return
- end
- local cfgTime = tonumber(cfg[2])
- local curTime = tonumber(getbaseinfo(monsterActor, "now"))
- local reliveTime = curTime + cfgTime
- setmonsterrelivetime(monsterActor, reliveTime)
- --jprint("复活时间:" , reliveTime,",怪物信息:" , monsterActor,",开服天数:",serverOpenDays, ",当前时间:", curTime,",配置时间:", cfgTime, ",配置:", cfg, ",str:", str)
- end
- end
- ---怪物掉落道具
- function MonsterScript.MonsterDieCulDrop(monsterActor, dieParam)
- local success, dropResult = xpcall(this.MonsterDieCulDrop, debug.traceback, monsterActor, dieParam)
- if not success then
- gameDebug.assertPrint(success, "怪物死亡掉落执行异常:", dropResult, "参数", monsterActor, dieParam)
- return nil
- end
- return dropResult
- end
- function this.MonsterDieCulDrop(monsterActor, dieParam)
- local mapId = tonumber(dieParam["mapid"])
- local monsterCfgId = tonumber(dieParam["monstercfg"])
- local killerId = tonumber(dieParam["killer"])
- local killerActor = getactor(killerId, mapId)
- local owner = this.GetFirstAttack(monsterActor, killerActor)
- local itemDecay, itemGroupDecay = this.GetDecayCfg(owner, monsterCfgId)
- --jprint("获取掉落衰减配置:", itemDecay,itemGroupDecay)
- local dropRecord = this.GetMonsterDropRecord(owner)
- local allDropCfg = this.GetAllDropCfg(owner, monsterCfgId, dropRecord, itemGroupDecay)
- if table.isNullOrEmpty(allDropCfg) then
- return nil
- end
- --掉落道具结果
- local dropResult = {}
- --全服道具掉落记录
- local globalItemDrop = this.GetGlobalItemDrop()
- --先检查重置记录
- this.CheckDropItemReset(globalItemDrop)
- --计算掉落结果
- this.GetDropResult(
- dieParam,
- owner,
- monsterActor,
- allDropCfg,
- globalItemDrop,
- dropRecord,
- dropResult,
- itemDecay,
- false
- )
- --保存掉落记录
- this.SaveMonsterDropRecord(owner, dropRecord)
- --更新衰减组记录
- this.RecordDecayGroupCount(owner, monsterCfgId)
- --jprint("怪物掉落记录:", dropRecord)
- --清理怪物伤害列表、首刀信息
- this.ClearMonsterAttackInfo(monsterActor)
- if table.isNullOrEmpty(dropResult) then
- return
- end
- --保存道具记录
- this.SaveGlobalItemDrop(globalItemDrop)
- -- 特权BOSS奖励弹窗
- PrivilegeBoss.resRewardPanel(owner, monsterCfgId, mapId, dropResult)
- return dropResult
- end
- ---清理怪物伤害列表、首刀信息
- function this.ClearMonsterAttackInfo(monsterActor)
- this.SaveMonsterFirstAttack(monsterActor, nil)
- this.SaveMonsterHurtList(monsterActor, nil)
- end
- ---获取所有掉落组配置
- function this.GetAllDropCfg(actor, monsterCfgId, dropRecord, itemGroupDecayCfg)
- local mGroupList = ConfigDataManager.getTableValue("cfg_monster", "mgroup", "id", monsterCfgId)
- if string.isNullOrEmpty(mGroupList) then
- return nil
- end
- local groupArray = string.split(mGroupList, "#")
- local monsterLv = tonumber(ConfigDataManager.getTableValue("cfg_monster", "level", "id", monsterCfgId))
- local killerLv = tonumber(getbaseinfo(actor, "level"))
- --衰减配置
- local decayCfg = 0
- local mDecayGroup = ConfigDataManager.getTableValue("cfg_monster", "mdecaygroup", "id", monsterCfgId)
- if not string.isNullOrEmpty(mDecayGroup) then
- decayCfg = tonumber(mDecayGroup)
- end
- local dropGroupList = {}
- --玩家掉落加成倍率
- local bonusRate = this.GetRoleBonusRate(actor, monsterCfgId)
- for _, mGroup in pairs(groupArray) do
- local group = tonumber(mGroup)
- local dropTimes = dropRecord[group]
- if dropTimes == nil then
- dropTimes = 0
- end
- local startCount = dropTimes + 1
- local dropCfgList = this.GetDropCfgList(killerLv, monsterLv, group, startCount, bonusRate, itemGroupDecayCfg)
- --此处不判空后续要计次
- dropGroupList[group] = dropCfgList
- end
- return dropGroupList
- end
- ---获取角色综合加成倍率
- function this.GetRoleBonusRate(actor, monsterCfgId)
- local bonusRate = 1
- -- --三倍收益倍率
- -- local tripleRate = TripleIncome.GetRate(actor)
- -- --属性倍率
- -- local attrRate = this.GetAttrDropRate(actor)
- -- bonusRate = tripleRate * attrRate
- --jprint("获取玩家掉落倍率:", bonusRate, tripleRate,attrRate)
- return bonusRate
- end
- ---获取属性倍率
- function this.GetAttrDropRate(actor)
- local attrRate = tonumber(getattrinfo(actor, "propdropincrease"))
- if attrRate == nil then
- return 1
- end
- return 1 + attrRate
- end
- ---获取一个掉落组中的配置列表
- function this.GetDropCfgList(killerLv, monsterLv, group, dropTimes, roleRate, itemGroupDecayCfg)
- local cfgList = ConfigDataManager.getTable("cfg_boss_drop", "mgroup", group)
- if table.isNullOrEmpty(cfgList) then
- return nil
- end
- local dropCfgList = {}
- for _, dropBossCfg in pairs(cfgList) do
- local dropParam = this.GetDropCfg(killerLv, monsterLv, dropBossCfg, dropTimes, roleRate, itemGroupDecayCfg)
- if not table.isNullOrEmpty(dropParam) then
- local dropCfgId = tonumber(dropBossCfg["id"])
- dropCfgList[dropCfgId] = dropParam
- end
- end
- return dropCfgList
- end
- ---获取一个掉落配置
- function this.GetDropCfg(killerLv, monsterLv, dropCfg, dropTimes, roleRate, itemGroupDecayCfg)
- local numLimit = string.split(dropCfg["dropnum"], "#")
- local min = tonumber(numLimit[1])
- local max = tonumber(numLimit[2])
- if dropTimes < min or dropTimes > max then
- return nil
- end
- local dropRate = this.CulDropRate(killerLv, monsterLv, dropCfg, roleRate)
- local extractNum = tonumber(dropCfg["extractnum"])
- local itemGroup = dropCfg["itemgroup"]
- if string.isNullOrEmpty(itemGroup) then
- local randomGroupCfg = dropCfg["itemgrouprandom"]
- local tableName, addExtract = this.GetRandomItemGroup(randomGroupCfg, dropRate, itemGroupDecayCfg)
- if addExtract ~= nil and addExtract > 0 then
- itemGroup = tableName
- extractNum = extractNum * addExtract
- end
- end
- if string.isNullOrEmpty(itemGroup) then
- return nil
- end
- local dropParam = {
- id = tonumber(dropCfg["id"]),
- table_name = itemGroup,
- extract_times = extractNum,
- rate = dropRate
- }
- return dropParam
- end
- ---获取配置的随机道具组
- function this.GetRandomItemGroup(randomGroupCfg, dropRate, itemGroupDecayCfg)
- if string.isNullOrEmpty(randomGroupCfg) then
- return nil
- end
- local itemGroupCfg = string.split(randomGroupCfg, "#")
- local tableName = itemGroupCfg[1]
- ---随机概率万分比
- local probabilityCfg = tonumber(itemGroupCfg[2])
- local percent = 10000
- local extractNum = 0
- local decayRate = this.GetItemGroupDecayRate(tableName, itemGroupDecayCfg)
- local realProbability = probabilityCfg * dropRate * decayRate
- --jprint("随机掉落组配置:", tableName,dropRate,decayRate, realProbability)
- if realProbability >= percent then
- extractNum = math.floor(realProbability / percent)
- realProbability = math.fmod(realProbability, percent)
- end
- local randomNum = math.random(1, percent)
- if randomNum <= realProbability then
- extractNum = extractNum + 1
- end
- --jprint("随机掉落组配置:", tableName, extractNum,realProbability)
- return tableName, extractNum
- end
- function this.GetItemGroupDecayRate(tableName, itemGroupDecayCfg)
- if table.isNullOrEmpty(itemGroupDecayCfg) then
- return 1
- end
- for tableNames, rate in pairs(itemGroupDecayCfg) do
- if string.contains(tableNames, tableName) then
- return rate
- end
- end
- return 1
- end
- ---计算最终掉落倍率
- function this.CulDropRate(killerLv, monsterLv, dropCfg, roleRate)
- local finalRate = roleRate
- local lvDecaySign = dropCfg["decaysign"]
- --掉落等级衰减
- finalRate = this.CulLevelRate(killerLv, monsterLv, lvDecaySign, finalRate)
- return finalRate
- end
- ---获取配置掉落概率
- function this.GetLevelRateCfg(killerLv, monsterLv, decayCfg)
- local roleSection = string.split(decayCfg["rolesection"], "#")
- local roleLvMin = tonumber(roleSection[1])
- local roleLvMax = tonumber(roleSection[2])
- if killerLv < roleLvMin or killerLv > roleLvMax then
- return nil
- end
- local monsterSection = string.split(decayCfg["monstersection"], "#")
- local monsterLvMin = tonumber(monsterSection[1])
- local monsterLvMax = tonumber(monsterSection[2])
- if monsterLv < monsterLvMin or monsterLv > monsterLvMax then
- return nil
- end
- return tonumber(decayCfg["dropdecayrate"])
- end
- function this.CulLevelRate(killerLv, monsterLv, decaySign, roleRate)
- local cfgList = ConfigDataManager.getTable("cfg_boss_dropDecay", "decaysign", decaySign)
- if table.isNullOrEmpty(cfgList) then
- return roleRate
- end
- for _, decayCfg in pairs(cfgList) do
- local rateCfg = this.GetLevelRateCfg(killerLv, monsterLv, decayCfg)
- if rateCfg ~= nil then
- return roleRate * (rateCfg / 10000)
- end
- end
- return roleRate
- end
- ---计算掉落结果
- function this.GetDropResult(
- dieParam,
- actor,
- monsterActor,
- allDropCfg,
- globalItemDrop,
- dropRecord,
- dropResult,
- itemDecay,
- gm)
- --随机道具
- for dropGroup, dropCfgList in pairs(allDropCfg) do
- local dropCount = dropRecord[dropGroup]
- if dropCount == nil then
- dropCount = 0
- end
- if not table.isNullOrEmpty(dropCfgList) then
- for dropCfgId, dropCfg in pairs(dropCfgList) do
- this.CulDropItem(
- dieParam,
- actor,
- monsterActor,
- dropCfg,
- dropCount,
- globalItemDrop,
- dropResult,
- itemDecay,
- gm
- )
- end
- end
- --记录掉落次数
- dropRecord[dropGroup] = dropCount + 1
- end
- end
- function this.CulDropItem(dieParam, actor, monsterActor, dropCfg, dropCount, globalItemDrop, dropResult, itemDecay, gm)
- local extractTimes = dropCfg.extract_times
- --按配置次数随机
- for i = 1, extractTimes do
- this.RandomDropItem(
- dieParam,
- actor,
- monsterActor,
- dropCfg,
- dropCount,
- globalItemDrop,
- dropResult,
- itemDecay,
- gm
- )
- end
- end
- ---随机掉落道具
- function this.RandomDropItem(
- dieParam,
- actor,
- monsterActor,
- dropCfg,
- dropCount,
- globalItemDrop,
- dropResult,
- itemDecay,
- gm)
- local tableName = dropCfg.table_name
- local bossDropCfgId = dropCfg.id
- local dropRate = dropCfg.rate
- local dropRet = culdroptablebyname(actor, tableName, dropRate, dropCount, itemDecay)
- if dropRet == false or table.isNullOrEmpty(dropRet) then
- return
- end
- --掉落道具数量
- local dropItem = this.GetDropItem(dropRet, globalItemDrop)
- if table.isNullOrEmpty(dropItem) then
- return
- end
- --掉落道具
- if gm == false then
- local firstAttack = tonumber(getbaseinfo(actor, "rid"))
- local mapId = tonumber(dieParam["mapid"])
- local mainOwner, owners = this.SettingOwners(monsterActor, dieParam, bossDropCfgId, firstAttack)
- local ret = monsterdiedroptomap(monsterActor, mapId, bossDropCfgId, dropItem, mainOwner, owners)
- if ret == false or ret == nil then
- return
- end
- end
- --记录道具抽取次数
- this.MergeDropItem(dropItem, globalItemDrop, dropResult)
- end
- ---计算掉落归属
- function this.SettingOwners(monsterActor, dieParam, bossDropCfgId, firstAttack)
- local owners = {}
- local mainOwner = firstAttack
- local mapId = tonumber(dieParam["mapid"])
- local dropType = tonumber(ConfigDataManager.getTableValue("cfg_boss_drop", "droptype", "id", bossDropCfgId))
- if dropType == DropType.NOT_OWNER then
- return mainOwner, owners
- elseif dropType == DropType.MAX_THREAT then
- local maxThreat = tonumber(dieParam["maxthreat"])
- mainOwner = maxThreat
- elseif dropType == DropType.LAST_ATTACK then
- local killerId = tonumber(dieParam["killer"])
- mainOwner = killerId
- elseif dropType == DropType.MAX_HURT then
- local maxHurtRid = this.GetMaxHurtPlayer(monsterActor)
- if maxHurtRid ~= nil and maxHurtRid > 0 then
- mainOwner = maxHurtRid
- end
- elseif dropType == DropType.PARTAKE then
- local threatList = dieParam["threatlist"]
- this.AddOwners(owners, threatList)
- elseif dropType == DropType.FIRST_ATTACK then
- mainOwner = firstAttack
- end
- table.insert(owners, mainOwner)
- --添加队友
- local ownerActor = getactor(mainOwner, mapId)
- local memberRids = Team.GetAllMemberRids(ownerActor)
- this.AddOwners(owners, memberRids)
- return mainOwner, owners
- end
- function this.AddOwners(owners, ridList)
- if table.isNullOrEmpty(ridList) then
- return
- end
- for _, rid in pairs(ridList) do
- if not table.contains(owners, rid) then
- table.insert(owners, rid)
- end
- end
- end
- ---获取实际掉落的道具
- function this.GetDropItem(dropRet, globalItemDrop)
- if table.isNullOrEmpty(dropRet) then
- return nil
- end
- local itemList = {}
- for itemCfgId, itemCount in pairs(dropRet) do
- local realCount = this.GetRealDropCount(itemCfgId, itemCount, globalItemDrop)
- if realCount > 0 then
- itemList[itemCfgId] = realCount
- end
- end
- return itemList
- end
- ---合并掉落道具
- function this.MergeDropItem(dropItem, globalItemDrop, dropResult)
- --记录道具抽取次数
- for itemCfgId, timeCount in pairs(dropItem) do
- --全服道具记录(无限制不记录)
- this.UpdateItemDropRecord(itemCfgId, timeCount, globalItemDrop)
- --怪物掉落结果
- this.MergeItemRecord(itemCfgId, timeCount, dropResult)
- end
- end
- ---更新限制道具掉落数量
- function this.UpdateItemDropRecord(itemCfgId, timeCount, globalItemDrop)
- --小时记录
- local hourLimit = ConfigDataManager.getTableValue("cfg_item", "droplimithour", "id", itemCfgId)
- if not string.isNullOrEmpty(hourLimit) and tonumber(hourLimit) > 0 then
- this.MergeItemDropRecord(itemCfgId, timeCount, globalItemDrop, ItemLimitType.HOUR)
- end
- --每日记录
- local dayLimit = ConfigDataManager.getTableValue("cfg_item", "droplimitday", "id", itemCfgId)
- if not string.isNullOrEmpty(dayLimit) and tonumber(dayLimit) > 0 then
- this.MergeItemDropRecord(itemCfgId, timeCount, globalItemDrop, ItemLimitType.DAY)
- end
- end
- function this.MergeItemDropRecord(itemCfgId, timeCount, globalItemDrop, limitType)
- local record = globalItemDrop[limitType]
- if record == nil then
- local nowTime = tonumber((getbaseinfo("nowsec")))
- record = {
- item_record = {},
- reset_time = nowTime
- }
- end
- this.MergeItemRecord(itemCfgId, timeCount, record.item_record)
- globalItemDrop[limitType] = record
- --jprint("更新每日道具记录,",record)
- end
- function this.MergeItemRecord(itemCfgId, timeCount, itemRecord)
- local recordCount = itemRecord[itemCfgId]
- if recordCount == nil then
- recordCount = 0
- end
- itemRecord[itemCfgId] = recordCount + timeCount
- end
- ---获取道具实际掉落数量
- function this.GetRealDropCount(itemCfgId, itemCount, globalItemDrop)
- local realCount = itemCount
- --小时限制
- local hourLimit = ConfigDataManager.getTableValue("cfg_item", "droplimithour", "id", itemCfgId)
- if not string.isNullOrEmpty(hourLimit) and tonumber(hourLimit) then
- local hourRecord = globalItemDrop[ItemLimitType.HOUR]
- local dropCount = this.CanDropCount(itemCfgId, itemCount, hourRecord, tonumber(hourLimit))
- realCount = math.min(dropCount, realCount)
- end
- --每日限制
- local dayLimit = ConfigDataManager.getTableValue("cfg_item", "droplimitday", "id", itemCfgId)
- if not string.isNullOrEmpty(dayLimit) and tonumber(dayLimit) and realCount > 0 then
- local dayRecord = globalItemDrop[ItemLimitType.DAY]
- local dropCount = this.CanDropCount(itemCfgId, itemCount, dayRecord, tonumber(dayLimit))
- realCount = math.min(dropCount, realCount)
- end
- return realCount
- end
- ---获取可掉落数量
- function this.CanDropCount(itemCfgId, itemCount, record, dropLimit)
- if table.isNullOrEmpty(record) or table.isNullOrEmpty(record.item_record) then
- return math.min(dropLimit, itemCount)
- end
- local recordCount = 0
- if record.item_record[itemCfgId] ~= nil then
- recordCount = record.item_record[itemCfgId]
- end
- local canDrop = dropLimit - recordCount
- return math.min(canDrop, itemCount)
- end
- ---检查掉落记录重置
- function this.CheckDropItemReset(globalItemDrop)
- if table.isNullOrEmpty(globalItemDrop) then
- return
- end
- local nowTime = tonumber((getbaseinfo("nowsec")))
- for limitType, typeRecord in pairs(globalItemDrop) do
- local resetTime = typeRecord.reset_time
- local flush = this.TryResetItemRecord(resetTime, nowTime, limitType)
- if flush then
- typeRecord.item_record = {}
- typeRecord.reset_time = nowTime
- end
- end
- end
- ---重置掉落记录
- function this.TryResetItemRecord(resetTime, nowSec, limitType)
- --每天重置
- if limitType == ItemLimitType.DAY then
- if not TimeUtil.isSameDay(nowSec, resetTime) then
- return true
- end
- end
- --小时重置
- if limitType == ItemLimitType.HOUR then
- if not TimeUtil.isSameHour4Sec(nowSec, resetTime) then
- return true
- end
- end
- return false
- end
- ---记录怪物组
- function this.RecordDecayGroupCount(actor, monsterCfgId)
- local mDecayGroup = ConfigDataManager.getTableValue("cfg_monster", "mdecaygroup", "id", monsterCfgId)
- if string.isNullOrEmpty(mDecayGroup) or tonumber(mDecayGroup) == 0 then
- return
- end
- local decayGroup = tonumber(mDecayGroup)
- local decayRecord = this.GetDecayGroupRecord(actor)
- local oldCount = decayRecord[decayGroup]
- if oldCount == nil then
- oldCount = 0
- end
- decayRecord[decayGroup] = oldCount + 1
- this.SaveDecayGroupRecord(actor, decayRecord)
- --jprint("保存怪物组衰减次数",decayRecord)
- end
- ---获取衰减配置
- function this.GetDecayCfg(actor, monsterCfgId)
- local mDecayGroup = ConfigDataManager.getTableValue("cfg_monster", "mdecaygroup", "id", monsterCfgId)
- if string.isNullOrEmpty(mDecayGroup) or tonumber(mDecayGroup) == 0 then
- return nil
- end
- local decayGroup = tonumber(mDecayGroup)
- local decayRecord = this.GetDecayGroupRecord(actor)
- local nowTime = tonumber((getbaseinfo("nowsec")))
- local resetTime = this.GetDecayGroupRestTime(actor)
- local sameDay = true
- if resetTime > 0 then
- sameDay = TimeUtil.isSameDayWithNum(nowTime, resetTime, 5)
- else
- sameDay = false
- end
- if not sameDay then
- --重置衰减记录
- decayRecord = {}
- this.SaveDecayGroupRestTime(actor, nowTime)
- this.SaveDecayGroupRecord(actor, decayRecord)
- --jprint("衰减记录重置",decayRecord)
- end
- local oldCount = decayRecord[decayGroup]
- if oldCount == nil then
- oldCount = 0
- end
- local itemDecay = {}
- local groupDecay = {}
- this.GetDecayGroup(decayGroup, oldCount + 1, itemDecay, groupDecay)
- return itemDecay, groupDecay
- end
- function this.GetDecayGroup(decayGroup, recordCount, itemDecay, groupDecay)
- local allCfgList = ConfigDataManager.getTable("cfg_boss_numdecay", "mdecaygroup", decayGroup)
- if table.isNullOrEmpty(allCfgList) then
- return nil
- end
- for _, decayCfg in pairs(allCfgList) do
- this.GetDecayCfgParam(decayCfg, recordCount, itemDecay, groupDecay)
- end
- end
- function this.GetDecayCfgParam(decayCfg, recordCount, itemDecay, groupDecay)
- local limitArray = string.split(decayCfg["monstersection"], "#")
- local minLimit = tonumber(limitArray[1])
- local maxLimit = tonumber(limitArray[2])
- if recordCount < minLimit or recordCount > maxLimit then
- return nil
- end
- local decayRate = tonumber(decayCfg["dropdecayrate"]) / 10000
- if not string.isNullOrEmpty(decayCfg["item"]) then
- local itemCfgId = tonumber(decayCfg["item"])
- itemDecay[itemCfgId] = decayRate
- end
- if not string.isNullOrEmpty(decayCfg["itemgroup"]) then
- local itemGroup = decayCfg["itemgroup"]
- groupDecay[itemGroup] = decayRate
- end
- end
- ---获取怪物经验衰减倍率
- function MonsterScript.GetExpDecayRate(actor, monsterCfgId)
- local decaySign = ConfigDataManager.getTableValue("cfg_monster", "decaysign", "id", monsterCfgId)
- if string.isNullOrEmpty(decaySign) or tonumber(decaySign) == 0 then
- return 1
- end
- local allDecayCfg = ConfigDataManager.getTable("cfg_boss_dropdecay", "decaysign", decaySign)
- if table.isNullOrEmpty(allDecayCfg) then
- return 1
- end
- local monsterLv = tonumber(ConfigDataManager.getTableValue("cfg_monster", "level", "id", monsterCfgId))
- local roleLv = tonumber(getbaseinfo(actor, "level"))
- for _, decayCfg in pairs(allDecayCfg) do
- local rate = this.GetExpDecayCfg(roleLv, monsterLv, decayCfg)
- if rate ~= nil then
- return rate
- end
- end
- return 1
- end
- function this.GetExpDecayCfg(roleLv, monsterLv, decayCfg)
- local roleSection = string.split(decayCfg["rolesection"], "#")
- local roleLvMin = tonumber(roleSection[1])
- local roleLvMax = tonumber(roleSection[2])
- if roleLv < roleLvMin or roleLv > roleLvMax then
- return nil
- end
- local monsterSection = string.split(decayCfg["monstersection"], "#")
- local monsterLvMin = tonumber(monsterSection[1])
- local monsterLvMax = tonumber(monsterSection[2])
- if monsterLv < monsterLvMin or monsterLv > monsterLvMax then
- return nil
- end
- return tonumber(decayCfg["dropdecayrate"]) / 10000
- end
- ---gm掉落测试
- ------@param actor table 玩家对象
- -----@param monsterCfgId number 怪物配置id
- -----@param killNum number 击杀数量
- -----@param isSum boolean 掉落是否汇总
- function gmmonsterdroptest(actor, isSum, monster, count)
- if monster == nil or tonumber(monster) < 1 then
- return
- end
- if count == nil or tonumber(count) < 1 then
- return
- end
- local monsterCfgId = tonumber(monster)
- local killNum = tonumber(count)
- local dropResult = {}
- for i = 1, killNum do
- local dropRet = this.GmDropTest(actor, monsterCfgId)
- if dropRet ~= nil then
- for itemCfgId, itemCount in pairs(dropRet) do
- this.MergeItemRecord(itemCfgId, itemCount, dropResult)
- end
- end
- end
- if table.isNullOrEmpty(dropResult) then
- tipinfo(actor, "未掉落道具")
- return
- end
- local monsterName = ConfigDataManager.getTableValue("cfg_monster", "name", "id", monsterCfgId)
- local title = "掉落测试:击杀" .. killNum .. "只" .. monsterName
- local content = this.GetDropStringContent(dropResult, isSum)
- sendmail(actor, title, content, nil)
- end
- function this.GetDropStringContent(dropResult, isSum)
- if table.isNullOrEmpty(dropResult) then
- return "未掉落道具"
- end
- local resultStr = {}
- for itemCfgId, itemCount in pairs(dropResult) do
- local itemName = ConfigDataManager.getTableValue("cfg_item", "name", "id", itemCfgId)
- local itemStr = itemName .. ":" .. itemCount
- if itemStr then
- table.insert(resultStr, itemStr)
- end
- end
- return table.concat(resultStr, " |")
- end
- function this.GmDropTest(actor, monsterCfgId)
- local itemDecay, itemGroupDecay = this.GetDecayCfg(actor, monsterCfgId)
- --jprint("获取掉落衰减配置:", itemDecay,itemGroupDecay)
- local dropRecord = this.GetMonsterDropRecord(actor)
- local allDropCfg = this.GetAllDropCfg(actor, monsterCfgId, dropRecord, itemGroupDecay)
- if table.isNullOrEmpty(allDropCfg) then
- return nil
- end
- --掉落道具结果
- local dropResult = {}
- --全服道具掉落记录
- local globalItemDrop = this.GetGlobalItemDrop()
- --先检查重置记录
- this.CheckDropItemReset(globalItemDrop)
- --计算掉落结果
- this.GetDropResult(nil, actor, nil, allDropCfg, globalItemDrop, dropRecord, dropResult, itemDecay, true)
- --保存掉落记录
- this.SaveMonsterDropRecord(actor, dropRecord)
- --更新衰减组记录
- this.RecordDecayGroupCount(actor, monsterCfgId)
- --jprint("怪物掉落记录:", dropRecord)
- if table.isNullOrEmpty(dropResult) then
- return nil
- end
- --保存道具记录
- this.SaveGlobalItemDrop(globalItemDrop)
- --jprint("全服道具限制记录:", globalItemDrop)
- --jprint("掉落结果:", dropResult)
- return dropResult
- end
- --被攻击时触发
- function MonsterScript.OnUnderAttack(targetActor, fightParam)
- --this.OnUnderAttack(targetActor,fightParam)
- this.UpdateMonsterAttackInfo(targetActor, fightParam)
- end
- function this.OnUnderAttack(actor, fightParam)
- local type = getbaseinfo(actor, "mapobjecttype")
- if type ~= MapObjectType.MONSTER and type ~= MapObjectType.PET then
- return
- end
- --local monInfo = getmonsterinfo(actor)
- --local monsterId = monInfo["cfgid"]
- monsterId = fightParam["targetcfgid"]
- local aiId = ConfigDataManager.getTableValue("cfg_monster", "ai", "id", monsterId)
- local beattackTime = ConfigDataManager.getTableValue("cfg_monster_ai", "beattacktime", "id", aiId)
- jprint("怪物被攻击时设置休眠时间", monsterId, aiId, beattackTime)
- setsleeptime(actor, beattackTime)
- end
- ---更新怪物受击信息
- function this.UpdateMonsterAttackInfo(targetActor, fightParam)
- local targetType = tonumber(fightParam["targettype"])
- if targetType ~= MapObjectType.MONSTER then
- return
- end
- local playerActor = nil
- local casterType = tonumber(fightParam["castertype"])
- if casterType == MapObjectType.PLAYER then
- playerActor = fightParam["caster"]
- end
- if casterType == MapObjectType.PET or casterType == MapObjectType.PARTNER then
- local masterId = tonumber(fightParam["masterid"])
- if masterId == nil or masterId == 0 then
- return
- end
- local mapId = tonumber(fightParam["mapid"])
- playerActor = getactor(masterId, mapId)
- end
- if playerActor == nil then
- return
- end
- local maxHurtRid = this.UpdateHurtList(targetActor, playerActor, fightParam)
- this.TryUpdateMonsterFirstAttackInfo(targetActor, playerActor, fightParam, maxHurtRid)
- end
- ---尝试更新怪物首刀归属
- function this.TryUpdateMonsterFirstAttackInfo(monsterActor, playerActor, fightParam, maxHurtRid)
- local rid = tonumber(getbaseinfo(playerActor, "rid"))
- local nowTime = tonumber((getbaseinfo("nowsec")))
- local firstAttackInfo = this.GetMonsterFirstAttack(monsterActor)
- local timeLimit = this.GetMonsterFirstAttackTimeLimit()
- local updateFirstAttack = true
- local oldMaxHurt = nil
- if not table.isNullOrEmpty(firstAttackInfo) then
- local attackTime = tonumber(firstAttackInfo["attack_time"])
- local roleId = tonumber(firstAttackInfo["rid"])
- oldMaxHurt = tonumber(firstAttackInfo["max_hurt"])
- if rid ~= roleId and attackTime + timeLimit > nowTime then
- updateFirstAttack = false
- end
- end
- --更新首刀记录
- if updateFirstAttack then
- firstAttackInfo["rid"] = rid
- firstAttackInfo["attack_time"] = nowTime
- end
- --更新最大伤害玩家
- local maxHurtChange = false
- if maxHurtRid > 0 and maxHurtRid ~= oldMaxHurt then
- firstAttackInfo["max_hurt"] = maxHurtRid
- maxHurtChange = true
- end
- --jprint("更新怪物首刀归属", targetActor,rid)
- local monsterCfgId = tonumber(fightParam["targetcfgid"])
- local send = this.NeedSendOwnerMsg(monsterCfgId)
- local isMaxHurt = this.IsMaxHurtTarget(monsterCfgId)
- if send then
- local msgTime = tonumber(firstAttackInfo["msg_time"])
- if maxHurtChange or msgTime == nil or nowTime - msgTime >= timeLimit then
- --发送首刀归属信息
- local endTime = nowTime + timeLimit
- local maxHurtId = 0
- if isMaxHurt == true then
- maxHurtId = maxHurtRid
- rid = 0
- end
- local ownerInfo = {
- target = monsterActor,
- owner = rid,
- endTime = endTime,
- maxHurt = maxHurtId
- }
- this.SendFirstAttackOwnerMsg(nil, monsterActor, ownerInfo)
- --保存发送时间
- firstAttackInfo["msg_time"] = nowTime
- end
- end
- --保存首刀归属记录
- this.SaveMonsterFirstAttack(monsterActor, firstAttackInfo)
- end
- ---怪物进入视野
- function MonsterScript.MonsterEnterView(actor, monsterActor, monsterCfgId)
- local send = this.NeedSendOwnerMsg(monsterCfgId)
- if not send then
- return
- end
- this.SendFirstAttackOwnerMsg(actor, monsterActor)
- end
- ---是否通知客户端归属信息
- function this.NeedSendOwnerMsg(monsterCfgId)
- local monsterType = tonumber(ConfigDataManager.getTableValue("cfg_monster", "type", "id", monsterCfgId))
- if monsterType == nil or monsterType == MonsterType.NORMAL then
- return false
- end
- return true
- end
- ---发送首刀归属信息
- function this.SendFirstAttackOwnerMsg(actor, targetActor, ownerInfo)
- --只发生boss归属
- if ownerInfo == nil then
- ownerInfo = this.GetFirstAttackOwner(targetActor)
- end
- --jprint("发送首刀归属信息", ownerInfo)
- if actor == nil then
- sendrefluamsg(targetActor, LuaMessageIdToClient.RES_MONSTER_FIRST_ATTACK_OWNER_CHANGE, ownerInfo)
- else
- sendluamsg(actor, LuaMessageIdToClient.RES_MONSTER_FIRST_ATTACK_OWNER_CHANGE, ownerInfo)
- end
- end
- ---获取首刀归属信息
- function this.GetFirstAttackOwner(targetActor)
- local firstAttackInfo = this.GetMonsterFirstAttack(targetActor)
- local rid = 0
- local endTime = 0
- if not table.isNullOrEmpty(firstAttackInfo) then
- rid = tonumber(firstAttackInfo["rid"])
- endTime = tonumber(firstAttackInfo["attack_time"])
- end
- if endTime > 0 then
- local timeLimit = this.GetMonsterFirstAttackTimeLimit()
- endTime = endTime + timeLimit
- end
- local maxHurtRid = 0
- local monsterInfo = getmonsterinfo(targetActor)
- if not table.isNullOrEmpty(monsterInfo) then
- local monsterCfgId = monsterInfo["cfgid"]
- local isMaxHurt = this.IsMaxHurtTarget(monsterCfgId)
- if isMaxHurt == true then
- maxHurtRid = this.GetMaxHurtPlayer(targetActor, nil)
- rid = 0
- end
- end
- local ownerInfo = {
- target = targetActor,
- owner = rid,
- endTime = endTime,
- maxHurt = maxHurtRid
- }
- return ownerInfo
- end
- ---更新伤害列表
- function this.UpdateHurtList(monsterActor, playerActor, fightParam)
- local targetHurt = tonumber(fightParam["targethurt"])
- if targetHurt == nil or targetHurt < 0 then
- return 0
- end
- local hurtList = MonsterScript.GetHurtList(monsterActor)
- local rid = tonumber(getbaseinfo(playerActor, "rid"))
- local oldHurt = 0
- if not table.isNullOrEmpty(hurtList) then
- if hurtList[rid] ~= nil then
- oldHurt = hurtList[rid]
- end
- end
- hurtList[rid] = targetHurt + oldHurt
- this.SaveMonsterHurtList(monsterActor, hurtList)
- return this.GetMaxHurtPlayer(monsterActor, hurtList)
- end
- ---获取最大伤害玩家
- ---@param hurtList table 伤害列表
- function this.GetMaxHurtPlayer(monsterActor, hurtList)
- if table.isNullOrEmpty(hurtList) then
- hurtList = MonsterScript.GetHurtList(monsterActor)
- end
- if table.isNullOrEmpty(hurtList) then
- return 0
- end
- local maxHurt = 0
- local maxRid = 0
- for rid, hurt in pairs(hurtList) do
- if hurt > maxHurt then
- maxHurt = hurt
- maxRid = rid
- end
- end
- return maxRid
- end
- function MonsterScript.GetHurtList(monsterActor)
- local hurtList = this.GetMonsterHurtList(monsterActor)
- if table.isNullOrEmpty(hurtList) then
- return hurtList
- end
- local mapId = getbaseinfo(monsterActor, "unimapid")
- local removeList = {}
- for rid, hurt in pairs(hurtList) do
- local isRemove = this.needRemoveHurt(rid, mapId)
- if isRemove == true then
- table.insert(removeList, rid)
- end
- end
- if not table.isNullOrEmpty(removeList) then
- for _, rid in pairs(removeList) do
- hurtList[rid] = nil
- end
- this.SaveMonsterHurtList(monsterActor, hurtList)
- end
- return hurtList
- end
- ---是否需要移除伤害
- function this.needRemoveHurt(rid, monsterMapId)
- local playerActor = getactor(rid)
- if playerActor == nil then
- return true
- end
- local mapId = getbaseinfo(playerActor, "unimapid") or getplayermaininfo(playerActor)["mapid"]
- if mapId == nil or mapId ~= monsterMapId then
- return true
- end
- playerActor = getactor(rid, mapId)
- local dead = isdead(playerActor)
- if dead == nil or dead == true then
- return true
- end
- return false
- end
- ---移除伤害列表玩家
- function MonsterScript.RemoveHurtListRid(monsterActor, rid)
- if monsterActor == nil or rid == nil then
- return
- end
- local hurtList = this.GetMonsterHurtList(monsterActor)
- if table.isNullOrEmpty(hurtList) then
- return
- end
- hurtList[rid] = nil
- this.SaveMonsterHurtList(monsterActor, hurtList)
- this.SendFirstAttackOwnerMsg(nil, monsterActor)
- end
- ---仇恨目标是否为最大伤害
- function this.IsMaxHurtTarget(monsterCfgId)
- local threatType = tonumber(ConfigDataManager.getTableValue("cfg_monster_ai", "hate", "id", monsterCfgId))
- if threatType == nil then
- return false
- end
- if threatType == ThreatType.MAX_HURT then
- return true
- end
- return false
- end
|