瀏覽代碼

【需求】MMO-21029:增加战斗服伤害输出模块

meijun 3 年之前
父節點
當前提交
32571416b3

+ 42 - 22
Common/CommonAI/Zone/Helper/Statistic.cs

@@ -33,6 +33,8 @@ namespace CommonAI.Zone.Instance.Helper
             return ret;
         }
 
+        public abstract void Reset();
+
         //------------------------------------------------------------------------------------
         /// <summary>
         /// 死亡次数
@@ -69,17 +71,17 @@ namespace CommonAI.Zone.Instance.Helper
         /// </summary>
         public abstract long PlayerHealing { get; }
 
-		/// <summary>
-		/// 连斩信息
-		/// </summary>
-		public abstract long preKillTime { get; set; }
-		public abstract short continueKills { get; set; }
+        /// <summary>
+        /// 连斩信息
+        /// </summary>
+        public abstract long preKillTime { get; set; }
+        public abstract short continueKills { get; set; }
 
-		/// <summary>
-		/// 总共杀死特定类型单位数量
-		/// </summary>
-		/// <param name="type"></param>
-		public abstract int GetKillUnitCount(UnitInfo.UnitType type);
+        /// <summary>
+        /// 总共杀死特定类型单位数量
+        /// </summary>
+        /// <param name="type"></param>
+        public abstract int GetKillUnitCount(UnitInfo.UnitType type);
 
         //------------------------------------------------------------------------------------
 
@@ -116,12 +118,12 @@ namespace CommonAI.Zone.Instance.Helper
         //------------------------------------------------------------------------------------
         internal void LogDamage(IUnitStatistic attacker, int reduceHP)
         {
-            if (reduceHP >0 && this.Owner.CurrentHP < reduceHP)
+            if (reduceHP > 0 && this.Owner.CurrentHP < reduceHP)
             {
                 reduceHP = this.Owner.CurrentHP;
             }
 
-            if(reduceHP <0 && this.Owner.MaxHP - this.Owner.CurrentHP < -reduceHP )
+            if (reduceHP < 0 && this.Owner.MaxHP - this.Owner.CurrentHP < -reduceHP)
             {
                 reduceHP = this.Owner.CurrentHP - this.Owner.MaxHP;
             }
@@ -140,7 +142,7 @@ namespace CommonAI.Zone.Instance.Helper
         //------------------------------------------------------------------------------------
 
     }
-    
+
     //------------------------------------------------------------------------------------
 
     public class UnitStatistic : IUnitStatistic
@@ -154,9 +156,9 @@ namespace CommonAI.Zone.Instance.Helper
         private long m_TotalHealing = 0;
         private long m_PlayerHealing = 0;
 
-		//联展信息
-		private long m_preKillTime = 0;
-		private short m_continueKills = 0;
+        //联展信息
+        private long m_preKillTime = 0;
+        private short m_continueKills = 0;
 
         private Dictionary<UnitInfo.UnitType, int> m_KillUnitCountMap = new Dictionary<UnitInfo.UnitType, int>();
 
@@ -164,6 +166,24 @@ namespace CommonAI.Zone.Instance.Helper
         {
         }
 
+        public override void Reset()
+        {
+            this.m_DeadCount = 0;
+            this.m_KillPlayerCount = 0;
+            this.m_KillUnitCount = 0;
+            this.m_SelfDamage = 0;
+            this.m_TotalDamage = 0;
+            this.m_PlayerDamage = 0;
+            this.m_TotalHealing = 0;
+            this.m_PlayerHealing = 0;
+
+            //联展信息
+            this.m_preKillTime = 0;
+            this.m_continueKills = 0;
+
+            this.m_KillUnitCountMap.Clear();
+        }
+
         public override int DeadCount { get { return m_DeadCount; } }
         public override int KillPlayerCount { get { return m_KillPlayerCount; } }
         public override int KillUnitCount { get { return m_KillUnitCount; } }
@@ -174,13 +194,13 @@ namespace CommonAI.Zone.Instance.Helper
         public override long PlayerHealing { get { return m_PlayerHealing; } }
 
 
-		/// <summary>
-		/// 连斩信息
-		/// </summary>
-		public override long preKillTime { get { return m_preKillTime; } set { m_preKillTime = value; } }
-		public override short continueKills { get { return m_continueKills; } set { m_continueKills = value; } }
+        /// <summary>
+        /// 连斩信息
+        /// </summary>
+        public override long preKillTime { get { return m_preKillTime; } set { m_preKillTime = value; } }
+        public override short continueKills { get { return m_continueKills; } set { m_continueKills = value; } }
 
-		public override int GetKillUnitCount(UnitInfo.UnitType type)
+        public override int GetKillUnitCount(UnitInfo.UnitType type)
         {
             int ret = 0;
             if (m_KillUnitCountMap.TryGetValue(type, out ret))

+ 12 - 12
Common/CommonAI/Zone/Instance/InstancePlayer.cs

@@ -637,18 +637,18 @@ namespace CommonAI.Zone.Instance
         protected virtual void doGetStatisticRequest(UnitGetStatisticRequest req)
         {
             UnitGetStatisticResponse resp = new UnitGetStatisticResponse();
-            if (req.RequestObjectsID != null)
-            {
-                for (int i = 0; i < req.RequestObjectsID.Length; i++)
-                {
-                    InstanceUnit u = Parent.getUnit(req.RequestObjectsID[i]);
-                    if (u != null)
-                    {
-                        var data = u.Statistic.ToUnitStatisticData();
-                        resp.Statistics.Put(req.RequestObjectsID[i], data);
-                    }
-                }
-            }
+            //if (req.RequestObjectsID != null)
+            //{
+            //    for (int i = 0; i < req.RequestObjectsID.Length; i++)
+            //    {
+            //        InstanceUnit u = Parent.getUnit(req.RequestObjectsID[i]);
+            //        if (u != null)
+            //        {
+            //            var data = u.Statistic.ToUnitStatisticData();
+            //            resp.Statistics.Put(req.RequestObjectsID[i], data);
+            //        }
+            //    }
+            //}
             Parent.sendActorResponse(this, req, resp);
         }
 

+ 17 - 21
Common/CommonAI/Zone/Instance/InstanceUnit.cs

@@ -785,10 +785,9 @@ namespace CommonAI.Zone.Instance
                 source.Begin(this);
                 int reduceHP = mFormula.OnHit(attacker, source, this);
 
-                // 统计 //
-                this.Statistic.LogDamage(attacker.Statistic, reduceHP);
+                // 统计 //                
 				reduceHP = this.AddHP(-reduceHP, attacker, !source.OutSendEvent, source);
-                
+                //this.Statistic.LogDamage(attacker.Statistic, reduceHP);
 
                 AttackProp attack = source.Attack;
                 // Post Event //
@@ -1063,25 +1062,20 @@ namespace CommonAI.Zone.Instance
                 return 0;
             }
 
-			if (attacker != null)
-			{
-				if (hp < 0 && !IngoreHealEffect)
-				{
-					int healedEffect = this.Virtual.GetHealedEffect();
-					int healEffect = (attacker.Virtual.GetUnitPro() == XmdsUnitPro.Priest) ? attacker.Virtual.GetHealEffect() : 0;
-					if (healedEffect != 0 || healEffect != 0)
-					{
-						hp = CUtils.CastInt(hp * (1 + healEffect * 0.0001) * (1 + healedEffect * 0.0001));
-					}
-				}
-
-				this.Statistic.LogDamage(attacker.Statistic, hp);
-			}
-
 			//2. 针对有发送者的伤害来源
 			if(attacker != null)
-			{				
-				if (hp < 0)
+			{
+                if (hp < 0 && !IngoreHealEffect)
+                {
+                    int healedEffect = this.Virtual.GetHealedEffect();
+                    int healEffect = (attacker.Virtual.GetUnitPro() == XmdsUnitPro.Priest) ? attacker.Virtual.GetHealEffect() : 0;
+                    if (healedEffect != 0 || healEffect != 0)
+                    {
+                        hp = CUtils.CastInt(hp * (1 + healEffect * 0.0001) * (1 + healedEffect * 0.0001));
+                    }
+                }
+
+                if (hp < 0)
 				{
 					//2.1 传递加血事件
 					int finalHP = hp;
@@ -1105,7 +1099,9 @@ namespace CommonAI.Zone.Instance
 						petUnit.PetShareDamage(petShareDmg, this);
 					}
 				}
-			}
+
+                this.Statistic.LogDamage(attacker.Statistic, hp);
+            }
 			
             this.DoAddHP(-hp);
             

+ 2 - 2
XmdsServerCS/XmdsServerEdgeJS/Zone/XmdsManagerICE.cs

@@ -674,11 +674,11 @@ namespace XmdsServerEdgeJS.Zone
             }
         }
 
-        public override void getPlayerStatistic_async(AMD_XmdsManager_getPlayerStatistic cb__, string playerId, Current current__)
+        public override void getPlayerStatistic_async(AMD_XmdsManager_getPlayerStatistic cb__, string instanceId, string playerId, int flag, Current current__)
         {
             try
             {
-                ZoneServiceICE.InstanceICE.r2b_request_getPlayerStatistic(playerId,
+                ZoneServiceICE.InstanceICE.r2b_request_getPlayerStatistic(instanceId, playerId, flag, 
                      (ret) => { cb__.ice_response(Json.Encode(ret)); },
                      (err) => { cb__.ice_exception(err); }
                      );

+ 46 - 19
XmdsServerCS/XmdsServerEdgeJS/Zone/ZoneServiceICE.cs

@@ -1412,31 +1412,58 @@ namespace XmdsServerEdgeJS.Zone
             }
         }
 
-        public void r2b_request_getPlayerStatistic(string playerId, Action<int> cb, Action<Exception> err)
+        public void r2b_request_getPlayerStatistic(string instanceId, string playerId, int flag, Action<dynamic> cb, Action<Exception> err)
         {
-            var player = getPlayer(playerId);
-            if (player != null)
+            try
             {
-                //player.Node.QueueTaskAsync(() =>
-                //{
-                InstancePlayer insPlayer = player.BindingActor;
-                dynamic ret = new
+                var node = getZoneNode(instanceId);
+                var player = getPlayer(playerId);
+                if (player != null && node != null)
                 {
-                    totalDamage = insPlayer.Statistic.TotalDamage,
-                    totalHealing = insPlayer.Statistic.TotalHealing,
-                    killPlayerCount = insPlayer.Statistic.KillPlayerCount,
-                    killUnitCount = insPlayer.Statistic.KillUnitCount,
-                    deadCount = insPlayer.Statistic.DeadCount
-                };
-                cb(ret);
-                //});
+                    if (flag == 0)
+                    {
+                        node.Node.ForEachPlayers((client) =>
+                        {
+                            var insPlayer = client.Actor;
+                            if (insPlayer != null)
+                            {
+                                insPlayer.Statistic.Reset();
+                            }
+                        });
+                        cb(null);
+                        return;
+                    }
+                    else
+                    {
+                        dynamic statistic = new Dictionary<string, dynamic>();
+                        node.Node.ForEachPlayers((client) =>
+                        {
+                            var insPlayer = client.Actor;
+                            if (insPlayer != null)
+                            {
+                                statistic[insPlayer.PlayerUUID] = new
+                                {
+                                    totalDamage = insPlayer.Statistic.TotalDamage,
+                                    totalHealing = insPlayer.Statistic.TotalHealing,
+                                    killPlayerCount = insPlayer.Statistic.KillPlayerCount,
+                                    killUnitCount = insPlayer.Statistic.KillUnitCount,
+                                    deadCount = insPlayer.Statistic.DeadCount
+                                };
+                            }
+                        });
+                        cb(statistic);
+                        return;
+                    }
+                }
             }
-            else
+            catch(Exception e)
             {
-                log.Error("r2b_request_getPlayerStatistic: PlayerNotExistException: playerId =" + playerId);
-                cb(0);
-                return;
+                log.Error("r2b_request_getPlayerStatistic catch: " + playerId + ", " + instanceId + ", " + flag + ", " + e);
             }
+
+            string notifyMsg = "r2b_request_getPlayerStatistic error: " + playerId + ", " + instanceId + ", " + flag;
+            log.Error(notifyMsg);
+            cb(notifyMsg);
         }
 
         public void r2b_request_getInstanceStatistic(string instanceId, Action<dynamic> cb, Action<Exception> err)

+ 33 - 27
XmdsServerCS/XmdsServerEdgeJS/generated/XmdsManager.cs

@@ -2808,17 +2808,17 @@ namespace Xmds
 
         void end_autoBattle(Ice.AsyncResult r__);
 
-        string getPlayerStatistic(string playerId);
+        string getPlayerStatistic(string instanceId, string playerId, int flag);
 
-        string getPlayerStatistic(string playerId, _System.Collections.Generic.Dictionary<string, string> ctx__);
+        string getPlayerStatistic(string instanceId, string playerId, int flag, _System.Collections.Generic.Dictionary<string, string> ctx__);
 
-        Ice.AsyncResult<Xmds.Callback_XmdsManager_getPlayerStatistic> begin_getPlayerStatistic(string playerId);
+        Ice.AsyncResult<Xmds.Callback_XmdsManager_getPlayerStatistic> begin_getPlayerStatistic(string instanceId, string playerId, int flag);
 
-        Ice.AsyncResult<Xmds.Callback_XmdsManager_getPlayerStatistic> begin_getPlayerStatistic(string playerId, _System.Collections.Generic.Dictionary<string, string> ctx__);
+        Ice.AsyncResult<Xmds.Callback_XmdsManager_getPlayerStatistic> begin_getPlayerStatistic(string instanceId, string playerId, int flag, _System.Collections.Generic.Dictionary<string, string> ctx__);
 
-        Ice.AsyncResult begin_getPlayerStatistic(string playerId, Ice.AsyncCallback cb__, object cookie__);
+        Ice.AsyncResult begin_getPlayerStatistic(string instanceId, string playerId, int flag, Ice.AsyncCallback cb__, object cookie__);
 
-        Ice.AsyncResult begin_getPlayerStatistic(string playerId, _System.Collections.Generic.Dictionary<string, string> ctx__, Ice.AsyncCallback cb__, object cookie__);
+        Ice.AsyncResult begin_getPlayerStatistic(string instanceId, string playerId, int flag, _System.Collections.Generic.Dictionary<string, string> ctx__, Ice.AsyncCallback cb__, object cookie__);
 
         string end_getPlayerStatistic(Ice.AsyncResult r__);
 
@@ -3025,7 +3025,7 @@ namespace Xmds
 
         void autoBattle_async(Xmds.AMD_XmdsManager_autoBattle cb__, string instanceId, string playerId, bool enable, Ice.Current current__);
 
-        void getPlayerStatistic_async(Xmds.AMD_XmdsManager_getPlayerStatistic cb__, string playerId, Ice.Current current__);
+        void getPlayerStatistic_async(Xmds.AMD_XmdsManager_getPlayerStatistic cb__, string instanceId, string playerId, int flag, Ice.Current current__);
 
         void getInstanceStatistic_async(Xmds.AMD_XmdsManager_getInstanceStatistic cb__, string instanceId, Ice.Current current__);
 
@@ -3131,7 +3131,7 @@ namespace Xmds
 
         void autoBattle_async(Xmds.AMD_XmdsManager_autoBattle cb__, string instanceId, string playerId, bool enable);
 
-        void getPlayerStatistic_async(Xmds.AMD_XmdsManager_getPlayerStatistic cb__, string playerId);
+        void getPlayerStatistic_async(Xmds.AMD_XmdsManager_getPlayerStatistic cb__, string instanceId, string playerId, int flag);
 
         void getInstanceStatistic_async(Xmds.AMD_XmdsManager_getInstanceStatistic cb__, string instanceId);
 
@@ -4490,20 +4490,20 @@ namespace Xmds
             return end_getPlayerSkillCDTime(begin_getPlayerSkillCDTime(playerId, context__, explicitCtx__, true, null, null));
         }
 
-        public string getPlayerStatistic(string playerId)
+        public string getPlayerStatistic(string instanceId, string playerId, int flag)
         {
-            return this.getPlayerStatistic(playerId, null, false);
+            return this.getPlayerStatistic(instanceId, playerId, flag, null, false);
         }
 
-        public string getPlayerStatistic(string playerId, _System.Collections.Generic.Dictionary<string, string> ctx__)
+        public string getPlayerStatistic(string instanceId, string playerId, int flag, _System.Collections.Generic.Dictionary<string, string> ctx__)
         {
-            return this.getPlayerStatistic(playerId, ctx__, true);
+            return this.getPlayerStatistic(instanceId, playerId, flag, ctx__, true);
         }
 
-        private string getPlayerStatistic(string playerId, _System.Collections.Generic.Dictionary<string, string> context__, bool explicitCtx__)
+        private string getPlayerStatistic(string instanceId, string playerId, int flag, _System.Collections.Generic.Dictionary<string, string> context__, bool explicitCtx__)
         {
             checkTwowayOnly__(__getPlayerStatistic_name);
-            return end_getPlayerStatistic(begin_getPlayerStatistic(playerId, context__, explicitCtx__, true, null, null));
+            return end_getPlayerStatistic(begin_getPlayerStatistic(instanceId, playerId, flag, context__, explicitCtx__, true, null, null));
         }
 
         public string getZoneRegions(string instanceId)
@@ -6431,24 +6431,24 @@ namespace Xmds
             }
         }
 
-        public Ice.AsyncResult<Xmds.Callback_XmdsManager_getPlayerStatistic> begin_getPlayerStatistic(string playerId)
+        public Ice.AsyncResult<Xmds.Callback_XmdsManager_getPlayerStatistic> begin_getPlayerStatistic(string instanceId, string playerId, int flag)
         {
-            return begin_getPlayerStatistic(playerId, null, false, false, null, null);
+            return begin_getPlayerStatistic(instanceId, playerId, flag, null, false, false, null, null);
         }
 
-        public Ice.AsyncResult<Xmds.Callback_XmdsManager_getPlayerStatistic> begin_getPlayerStatistic(string playerId, _System.Collections.Generic.Dictionary<string, string> ctx__)
+        public Ice.AsyncResult<Xmds.Callback_XmdsManager_getPlayerStatistic> begin_getPlayerStatistic(string instanceId, string playerId, int flag, _System.Collections.Generic.Dictionary<string, string> ctx__)
         {
-            return begin_getPlayerStatistic(playerId, ctx__, true, false, null, null);
+            return begin_getPlayerStatistic(instanceId, playerId, flag, ctx__, true, false, null, null);
         }
 
-        public Ice.AsyncResult begin_getPlayerStatistic(string playerId, Ice.AsyncCallback cb__, object cookie__)
+        public Ice.AsyncResult begin_getPlayerStatistic(string instanceId, string playerId, int flag, Ice.AsyncCallback cb__, object cookie__)
         {
-            return begin_getPlayerStatistic(playerId, null, false, false, cb__, cookie__);
+            return begin_getPlayerStatistic(instanceId, playerId, flag, null, false, false, cb__, cookie__);
         }
 
-        public Ice.AsyncResult begin_getPlayerStatistic(string playerId, _System.Collections.Generic.Dictionary<string, string> ctx__, Ice.AsyncCallback cb__, object cookie__)
+        public Ice.AsyncResult begin_getPlayerStatistic(string instanceId, string playerId, int flag, _System.Collections.Generic.Dictionary<string, string> ctx__, Ice.AsyncCallback cb__, object cookie__)
         {
-            return begin_getPlayerStatistic(playerId, ctx__, true, false, cb__, cookie__);
+            return begin_getPlayerStatistic(instanceId, playerId, flag, ctx__, true, false, cb__, cookie__);
         }
 
         private const string __getPlayerStatistic_name = "getPlayerStatistic";
@@ -6481,7 +6481,7 @@ namespace Xmds
             }
         }
 
-        private Ice.AsyncResult<Xmds.Callback_XmdsManager_getPlayerStatistic> begin_getPlayerStatistic(string playerId, _System.Collections.Generic.Dictionary<string, string> ctx__, bool explicitContext__, bool synchronous__, Ice.AsyncCallback cb__, object cookie__)
+        private Ice.AsyncResult<Xmds.Callback_XmdsManager_getPlayerStatistic> begin_getPlayerStatistic(string instanceId, string playerId, int flag, _System.Collections.Generic.Dictionary<string, string> ctx__, bool explicitContext__, bool synchronous__, Ice.AsyncCallback cb__, object cookie__)
         {
             checkAsyncTwowayOnly__(__getPlayerStatistic_name);
             IceInternal.TwowayOutgoingAsync<Xmds.Callback_XmdsManager_getPlayerStatistic> result__ =  getTwowayOutgoingAsync<Xmds.Callback_XmdsManager_getPlayerStatistic>(__getPlayerStatistic_name, getPlayerStatistic_completed__, cookie__);
@@ -6493,7 +6493,9 @@ namespace Xmds
             {
                 result__.prepare(__getPlayerStatistic_name, Ice.OperationMode.Normal, ctx__, explicitContext__, synchronous__);
                 IceInternal.BasicStream os__ = result__.startWriteParams(Ice.FormatType.DefaultFormat);
+                os__.writeString(instanceId);
                 os__.writeString(playerId);
+                os__.writeInt(flag);
                 result__.endWriteParams();
                 result__.invoke();
             }
@@ -9144,12 +9146,12 @@ namespace Xmds
 
         public abstract void autoBattle_async(Xmds.AMD_XmdsManager_autoBattle cb__, string instanceId, string playerId, bool enable, Ice.Current current__);
 
-        public void getPlayerStatistic_async(Xmds.AMD_XmdsManager_getPlayerStatistic cb__, string playerId)
+        public void getPlayerStatistic_async(Xmds.AMD_XmdsManager_getPlayerStatistic cb__, string instanceId, string playerId, int flag)
         {
-            getPlayerStatistic_async(cb__, playerId, Ice.ObjectImpl.defaultCurrent);
+            getPlayerStatistic_async(cb__, instanceId, playerId, flag, Ice.ObjectImpl.defaultCurrent);
         }
 
-        public abstract void getPlayerStatistic_async(Xmds.AMD_XmdsManager_getPlayerStatistic cb__, string playerId, Ice.Current current__);
+        public abstract void getPlayerStatistic_async(Xmds.AMD_XmdsManager_getPlayerStatistic cb__, string instanceId, string playerId, int flag, Ice.Current current__);
 
         public void getInstanceStatistic_async(Xmds.AMD_XmdsManager_getInstanceStatistic cb__, string instanceId)
         {
@@ -10206,13 +10208,17 @@ namespace Xmds
         {
             Ice.ObjectImpl.checkMode__(Ice.OperationMode.Normal, current__.mode);
             IceInternal.BasicStream is__ = inS__.startReadParams();
+            string instanceId;
             string playerId;
+            int flag;
+            instanceId = is__.readString();
             playerId = is__.readString();
+            flag = is__.readInt();
             inS__.endReadParams();
             AMD_XmdsManager_getPlayerStatistic cb__ = new _AMD_XmdsManager_getPlayerStatistic(inS__);
             try
             {
-                obj__.getPlayerStatistic_async(cb__, playerId, current__);
+                obj__.getPlayerStatistic_async(cb__, instanceId, playerId, flag, current__);
             }
             catch(_System.Exception ex__)
             {