From a451e68aed69b3c936d4afe50a0cf3c43680e90c Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 27 十月 2025 11:01:10 +0800
Subject: [PATCH] 302 【公会】BOSS讨伐-服务端(Taofa命令增加添加家成员讨伐数据)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/CreateFamily.py |   44 +++++++++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Taofa.py        |   67 ++++++++--------
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Family.py       |    6 +
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFamilyTaofa.py |   72 ++++++++++++++++++
 4 files changed, 154 insertions(+), 35 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/CreateFamily.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/CreateFamily.py
index 7d3c042..bf69db3 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/CreateFamily.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/CreateFamily.py
@@ -37,6 +37,7 @@
         GameWorld.DebugAnswer(curPlayer, "输出仙盟列表: CreatFamily pl [条数 从第x名]")
         GameWorld.DebugAnswer(curPlayer, "输出仙盟明细: CreatFamily pf 仙盟ID")
         GameWorld.DebugAnswer(curPlayer, "添加假申请人: CreatFamily j [申请数 仙盟ID]")
+        GameWorld.DebugAnswer(curPlayer, "添加本盟成员: CreatFamily m 人数 [仙盟ID]")
         return
     
     value1 = gmList[0]
@@ -56,6 +57,10 @@
         __addFackRequestJoin(curPlayer, gmList)
         return
     
+    if value1 == "m":
+        __addFackMember(curPlayer, gmList)
+        return
+    
     creatCount = value1
     if creatCount <= 0:
         __delFackFamily(curPlayer)
@@ -63,6 +68,45 @@
     __createFackFamily(curPlayer, gmList)
     return
 
+def __addFackMember(curPlayer, gmList):
+    memCnt = gmList[1] if len(gmList) > 1 else 1
+    familyID = gmList[2] if len(gmList) > 2 else curPlayer.GetFamilyID()
+    
+    familyMgr = DBDataMgr.GetFamilyMgr()
+    curFamily = familyMgr.FindFamily(familyID)
+    if not curFamily:
+        GameWorld.DebugAnswer(curPlayer, "没有该仙盟: %s" % familyID)
+        return
+    
+    MemberMax = PlayerFamily.GetFamilySetting(curFamily.GetLV(), "MemberMax")
+    if curFamily.GetCount() >= MemberMax:
+        GameWorld.DebugAnswer(curPlayer, "成员已满: %s" % MemberMax)
+        return
+    memCnt = min(memCnt, MemberMax - curFamily.GetCount())
+    
+    fackIDStart = 0
+    for i in range(0, familyMgr.GetCount()):
+        family = familyMgr.GetAt(i)
+        for index in xrange(family.GetCount()):
+            member = family.GetAt(index)
+            memID = member.GetPlayerID()
+            if memID > ShareDefine.FackPlayerIDMax:
+                continue
+            fackIDStart = max(memID, fackIDStart)
+            
+    addCnt = 0
+    for i in range(memCnt):
+        fackID = fackIDStart + i + 1
+        if fackID >= ShareDefine.FackPlayerIDMax:
+            break
+        PlayerFamily.DoPlayerJionFamily(curFamily, fackID, None, broadcastFamilyChange=False)
+        addCnt += 1
+        
+    familyMgr.Sort()
+    PlayerFamily.Sync_FamilyInfo(curPlayer)
+    GameWorld.DebugAnswer(curPlayer, "增加成员数:%s, 总成员:%s" % (addCnt, curFamily.GetCount()))
+    return
+
 def __addFackRequestJoin(curPlayer, gmList):
     reqCnt = gmList[1] if len(gmList) > 1 else 1
     familyID = gmList[2] if len(gmList) > 2 else curPlayer.GetFamilyID()
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Family.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Family.py
index 7dd7dcd..3842ea6 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Family.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Family.py
@@ -16,6 +16,7 @@
 #-------------------------------------------------------------------------------
 
 import GameWorld
+import CreateFamily
 import IpyGameDataPY
 import PlayerFamilyEmblem
 import PlayerFamily
@@ -29,6 +30,7 @@
         GameWorld.DebugAnswer(curPlayer, "设置等级: Family lv 等级 经验")
         GameWorld.DebugAnswer(curPlayer, "设置徽章: Family e 徽章ID [剩余时间秒]")
         GameWorld.DebugAnswer(curPlayer, "设置离开: Family l 主动离开次数 被踢次数 上次是否主动  离开多久了")
+        GameWorld.DebugAnswer(curPlayer, "添加成员: Family m 人数 [仙盟ID]")
         GameWorld.DebugAnswer(curPlayer, "创建仙盟相关使用命令: CreateFamily")
         return
     
@@ -72,5 +74,9 @@
         GameWorld.DebugAnswer(curPlayer, "添加徽章(%s)到期:%s" % (emblemID, GameWorld.ChangeTimeNumToStr(endTime)))
         return
     
+    elif value == "m":
+        CreateFamily.OnExec(curPlayer, msgList)
+        return
+    
     PlayerFamily.Sync_FamilyInfo(curPlayer)
     return
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Taofa.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Taofa.py
index e4405c1..e1c3150 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Taofa.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Taofa.py
@@ -17,8 +17,9 @@
 
 import ChConfig
 import GameWorld
+import ShareDefine
+import CreateFamily
 import PlayerControl
-import PlayerFamilyZhenbaoge
 import PlayerFamilyTaofa
 import PlayerFamily
 import DBDataMgr
@@ -36,8 +37,7 @@
         GameWorld.DebugAnswer(curPlayer, "设置宝箱领取: Taofa b 已领取宝箱 未领取")
         GameWorld.DebugAnswer(curPlayer, "设置宝箱时间: Taofa t 几秒前统计的")
         GameWorld.DebugAnswer(curPlayer, "设置宝箱贡献: Taofa g 已贡献宝箱 [累计伤害 历史伤害]")
-        #GameWorld.DebugAnswer(curPlayer, "新增成员讨伐: Taofa m 人数 [每人攻击次数 怒气次数 伤害值A 到B]")
-        #GameWorld.DebugAnswer(curPlayer, "AB值没有填则按常规砍价价格计算")
+        GameWorld.DebugAnswer(curPlayer, "增加成员讨伐: Taofa m 人数 [伤害值A 到B 怒攻概率]")
         GameWorld.DebugAnswer(curPlayer, "创建仙盟相关使用命令: CreateFamily")
         return
     
@@ -70,8 +70,7 @@
     
     # 新增成员讨伐
     if value1 == "m":
-        memCnt = msgList[1] if len(msgList) > 1 else 0
-        GameWorld.DebugAnswer(curPlayer, "成员讨伐:%s" % (memCnt))
+        __AddMemTaofaAtk(curPlayer, curFamily, msgList)
         return
     
     elif value1 == "a":
@@ -121,40 +120,38 @@
     PlayerFamilyTaofa.SyncTaofaInfo(curPlayer)
     return
 
-    #添加假砍价
-    gActionData = PlayerFamilyZhenbaoge.GetZhenbaogeActionData(familyID, PlayerFamilyZhenbaoge.ActionGlobalID)
-    if not gActionData:
-        GameWorld.DebugAnswer(curPlayer, "请先重置珍宝阁")
-        return
+def __AddMemTaofaAtk(curPlayer, curFamily, msgList):
+    #新增成员讨伐: Taofa m 人数 [伤害值A 到B]
     
-    familyAction = DBDataMgr.GetFamilyActionMgr().GetFamilyAction(familyID, PlayerFamilyZhenbaoge.ActionType)
-    actionCount = familyAction.Count()
+    GameWorld.DebugAnswer(curPlayer, "---------- %s" % GameWorld.GetCurrentDataTimeStr())
+    memCnt = msgList[1] if len(msgList) > 1 else curFamily.GetCount()
+    hurtTotalA = msgList[2] if len(msgList) > 2 else 0
+    hurtTotalB = msgList[3] if len(msgList) > 3 else hurtTotalA
+    angerRate = msgList[4] if len(msgList) > 4 else 5000
+    hurtTotalB = max(hurtTotalA, hurtTotalB)
     
-    fackCount = value1
-    randValue1 = msgList[1] if len(msgList) > 1 else 0
-    randValue2 = msgList[2] if len(msgList) > 2 else 0
-    syncActionDataList = [gActionData]
-    startFackID = 1000 + actionCount
-    FakeName = GameWorld.GbkToCode("假名字")
-    for fackID in range(startFackID, startFackID + fackCount):
+    if curFamily.GetCount() <= memCnt:
+        addMemCnt = memCnt - curFamily.GetCount() + 1
+        GameWorld.DebugAnswer(curPlayer, "添加缺少成员: %s" % addMemCnt)
+        CreateFamily.OnExec(curPlayer, ["m", addMemCnt])
+        GameWorld.DebugAnswer(curPlayer, "当前总成员数: %s" % curFamily.GetCount())
         
-        playerID = fackID
-        playerName = "%s%s" % (FakeName, fackID)
-        
-        if randValue1 and randValue2 and randValue1 <= randValue2:     
-            cutPrice = random.randint(randValue1, randValue2)
-        else:
-            cutPrice = PlayerFamilyZhenbaoge.CalcCutPrice(curFamily, gActionData, playerID)
-            
-        if not cutPrice:
+    actionDataList = []
+    for index in range(curFamily.GetCount()):
+        if memCnt <= 0:
+            break
+        member = curFamily.GetAt(index)
+        memID = member.GetPlayerID()
+        if memID >= ShareDefine.RealPlayerIDStart:
+            # 不包括真实玩家
             continue
+        memCnt -= 1
+        hurtValue = random.randint(hurtTotalA, hurtTotalB)
+        isAnger = GameWorld.CanHappen(angerRate) # 概率设置为怒气攻击
         
-        actionData = PlayerFamilyZhenbaoge.AddCutPrice(familyID, playerID, playerName, cutPrice, gActionData, False)
-        syncActionDataList.append(actionData)
-        nowPrice = PlayerFamilyZhenbaoge.GetFAPriceFinal(gActionData)
-        GameWorld.DebugAnswer(curPlayer, "砍价人次:%s,砍价:%s,现价:%s" % (fackID % 1000, cutPrice, nowPrice))
+        actionData = PlayerFamilyTaofa.GMAddMemTaofaAtk(curPlayer, curFamily, memID, hurtValue, isAnger)
+        actionDataList.append(actionData)
         
-    PlayerFamily.SendFamilyAction(syncActionDataList)
-    nowPrice = PlayerFamilyZhenbaoge.GetFAPriceFinal(gActionData)
-    GameWorld.DebugAnswer(curPlayer, "添加假砍价数:%s,总砍价数:%s,当前价格:%s" % (fackCount, familyAction.Count() - 1, nowPrice))
+    PlayerFamilyTaofa.RefreshPlayerAwardBoxCnt(curFamily)
+    PlayerFamily.SendFamilyAction(actionDataList)
     return
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFamilyTaofa.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFamilyTaofa.py
index b79fb12..fb43f53 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFamilyTaofa.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFamilyTaofa.py
@@ -478,6 +478,78 @@
     SyncTaofaInfo(curPlayer)
     return
 
+def GMAddMemTaofaAtk(curPlayer, curFamily, playerID, hurtValue, isAnger):
+    ## GM添加假的讨伐数据
+    
+    familyID = curFamily.GetID()
+    familyAction = DBDataMgr.GetFamilyActionMgr().GetFamilyAction(familyID, ActionType)
+    actionData = familyAction.GetActionDataByValue1(playerID, True)
+    
+    faAtkCnt = GetFAAtkCount(actionData)
+    faContribBoxCnt = GetFAContribBoxCnt(actionData)
+    faHurtTotal = GetFAHurtTotal(actionData) + GetFAHurtTotalEx(actionData) * ChConfig.Def_PerPointValue
+    
+    atkType = AtkType_Normal
+    calcHurtCnt = 1 # 计算伤害次数
+    if isAnger:
+        atkType = AtkType_Anger # 怒气攻击
+        calcHurtCnt = IpyGameDataPY.GetFuncCfg("FamilyTaofaAtk", 5)
+        
+    hurtTotal = 0 # 本次总伤害
+    for _ in range(calcHurtCnt):
+        hurtTotal += hurtValue
+        
+    atkTime = int(time.time())
+    faAtkCnt += calcHurtCnt
+    
+    # 计算贡献盒子数
+    boxAwardHurtList = IpyGameDataPY.GetFuncEvalCfg("FamilyTaofaBox", 1)
+    contribBoxMax = min(IpyGameDataPY.GetFuncCfg("FamilyTaofaBox", 2), 1000) # 可贡献的最大箱子数
+    finalAwardHurt = boxAwardHurtList[-1] # 最后一档最大伤害值
+    loopNeedHurt = (finalAwardHurt - boxAwardHurtList[-2]) if len(boxAwardHurtList) > 1 else finalAwardHurt # 最后一档所需伤害值
+    
+    # 原总贡献盒子数
+    boxContribCnt = 0
+    for needHurt in boxAwardHurtList:
+        if faHurtTotal < needHurt:
+            break
+        boxContribCnt += 1
+    if faHurtTotal > finalAwardHurt:
+        loopHurtTotal = faHurtTotal - finalAwardHurt
+        loopContribBoxCnt = loopHurtTotal / loopNeedHurt
+        boxContribCnt = min(boxContribCnt + loopContribBoxCnt, contribBoxMax)
+        
+    # 新总宝箱盒子数
+    faHurtTotal += hurtTotal
+    updContribBoxCnt = 0
+    for needHurt in boxAwardHurtList:
+        if faHurtTotal < needHurt:
+            break
+        updContribBoxCnt += 1
+    if faHurtTotal > finalAwardHurt:
+        loopHurtTotal = faHurtTotal - finalAwardHurt
+        loopContribBoxCnt = loopHurtTotal / loopNeedHurt
+        updContribBoxCnt = min(updContribBoxCnt + loopContribBoxCnt, contribBoxMax)
+        
+    addContribCnt = 0
+    if updContribBoxCnt > boxContribCnt:
+        addContribCnt = updContribBoxCnt - boxContribCnt
+        faContribBoxCnt += addContribCnt
+        
+    GameWorld.DebugAnswer(curPlayer, "讨伐ID:%s,伤:%s,箱:%s/%s,怒:%s" % (playerID, hurtValue, addContribCnt, updContribBoxCnt, int(isAnger)))
+    
+    # 更新Action记录
+    SetFAAtkTime(actionData, atkTime)
+    SetFAAtkCount(actionData, faAtkCnt)
+    SetFAHurtTotal(actionData, faHurtTotal % ChConfig.Def_PerPointValue)
+    SetFAHurtTotalEx(actionData, faHurtTotal / ChConfig.Def_PerPointValue)
+    SetFAContribBoxCnt(actionData, faContribBoxCnt)
+    atkList = actionData.GetUserDict().get("atkList", [])
+    atkList.append([atkTime, addContribCnt, hurtTotal, atkType])
+    actionData.GetUserDict().update({"atkList":atkList})
+    
+    return actionData
+
 def GetTaofaBoxAward(curPlayer):
     boxUnGetCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTaofaBoxUnGetCnt)
     if not boxUnGetCnt:

--
Gitblit v1.8.0