| | |
| | |
|
| | | # 切换守护
|
| | | def ChangeGuard(curPlayer, tick):
|
| | | # 检查过背包中无守护则不再执行
|
| | | if curPlayer.GetDictByKey("AutoCGuardID") == 1:
|
| | | return
|
| | | |
| | | curGuardID = 0 # 装备的守护ID
|
| | | itemIDList = IpyGameDataPY.GetFuncEvalCfg('AutoUseGuardian', 1)
|
| | | guardItem = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip).GetAt(ShareDefine.retGuard)
|
| | | # 1。 守护存在,判断是否最优先守护
|
| | | if ItemCommon.CheckItemCanUse(guardItem) and ItemCommon.CheckItemCanUseByExpireTime(guardItem):
|
| | | curGuardID = guardItem.GetItemTypeID()
|
| | | if curGuardID == itemIDList[0]:
|
| | | # 最高优先级
|
| | | return
|
| | | if curPlayer.GetDictByKey("AutoCGuardID") == 2:
|
| | | # 当前背包最高
|
| | | return
|
| | | |
| | |
|
| | | findItemList = []
|
| | | curPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
|
| | | |
| | | # 找到背包中优先级最高的守护物品
|
| | | for i in range(0, curPack.GetCount()):
|
| | | item = curPack.GetAt(i)
|
| | | |
| | | if not ItemCommon.CheckItemCanUse(item):
|
| | | continue
|
| | | |
| | | if item.GetItemTypeID() not in itemIDList:
|
| | | continue
|
| | | |
| | | if not ItemCommon.CheckItemCanUseByExpireTime(item):
|
| | | # 背包有不过期的物品
|
| | | continue
|
| | | |
| | | findItemList.append(item)
|
| | | |
| | | if not findItemList:
|
| | | curPlayer.SetDict("AutoCGuardID", 1) # 设置无可替换的标志
|
| | | return
|
| | | |
| | | findItemList.sort(cmp=SortGuard)
|
| | | if curGuardID in itemIDList and itemIDList.index(curGuardID) <= itemIDList.index(findItemList[0].GetItemTypeID()):
|
| | | # 当前装备最高,减少遍历
|
| | | curPlayer.SetDict("AutoCGuardID", 2)
|
| | | return
|
| | | |
| | |
|
| | | #---执行玩家换装逻辑---
|
| | | ChEquip.DoPlayerEquipItem(curPlayer, findItemList[0], ShareDefine.retGuard, tick)
|
| | | curPlayer.SetDict("AutoCGuardID", 0)
|
| | | return #新版本不需要切换
|
| | | # # 检查过背包中无守护则不再执行
|
| | | # if curPlayer.GetDictByKey("AutoCGuardID") == 1:
|
| | | # return
|
| | | # |
| | | # curGuardID = 0 # 装备的守护ID
|
| | | # itemIDList = IpyGameDataPY.GetFuncEvalCfg('AutoUseGuardian', 1)
|
| | | # guardItem = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip).GetAt(ShareDefine.retGuard1)
|
| | | # # 1。 守护存在,判断是否最优先守护
|
| | | # if ItemCommon.CheckItemCanUse(guardItem) and ItemCommon.CheckItemCanUseByExpireTime(guardItem):
|
| | | # curGuardID = guardItem.GetItemTypeID()
|
| | | # if curGuardID == itemIDList[0]:
|
| | | # # 最高优先级
|
| | | # return
|
| | | # if curPlayer.GetDictByKey("AutoCGuardID") == 2:
|
| | | # # 当前背包最高
|
| | | # return
|
| | | # |
| | | #
|
| | | # findItemList = []
|
| | | # curPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
|
| | | # |
| | | # # 找到背包中优先级最高的守护物品
|
| | | # for i in range(0, curPack.GetCount()):
|
| | | # item = curPack.GetAt(i)
|
| | | # |
| | | # if not ItemCommon.CheckItemCanUse(item):
|
| | | # continue
|
| | | # |
| | | # if item.GetItemTypeID() not in itemIDList:
|
| | | # continue
|
| | | # |
| | | # if not ItemCommon.CheckItemCanUseByExpireTime(item):
|
| | | # # 背包有不过期的物品
|
| | | # continue
|
| | | # |
| | | # findItemList.append(item)
|
| | | # |
| | | # if not findItemList:
|
| | | # curPlayer.SetDict("AutoCGuardID", 1) # 设置无可替换的标志
|
| | | # return
|
| | | # |
| | | # findItemList.sort(cmp=SortGuard)
|
| | | # if curGuardID in itemIDList and itemIDList.index(curGuardID) <= itemIDList.index(findItemList[0].GetItemTypeID()):
|
| | | # # 当前装备最高,减少遍历
|
| | | # curPlayer.SetDict("AutoCGuardID", 2)
|
| | | # return
|
| | | # |
| | | #
|
| | | # #---执行玩家换装逻辑---
|
| | | # ChEquip.DoPlayerEquipItem(curPlayer, findItemList[0], ItemCommon.GetEquipPackIndex(findItemList[0]), tick)
|
| | | # curPlayer.SetDict("AutoCGuardID", 0)
|
| | | return
|
| | |
|
| | |
|