瀏覽代碼

【优化】日志 & 随从攻击距离判断

meijun 3 年之前
父節點
當前提交
88d58dc72b

+ 1 - 1
Common/CommonAI/Zone/Formula/IFormulas.cs

@@ -258,7 +258,7 @@ namespace CommonAI.Zone.Formula
 		bool IsInPVP();        
         bool IsInPVE();
         //设置玩家战斗状态
-        void SetCombatState(BattleStatus value, byte reason = 0);
+        void SetCombatState(BattleStatus value, byte reason = 0, string pvpTriggerID = "");
         //是否是队友
         bool IsAllies(IVirtualUnit target, bool includeSelf = true, bool onlyForTeam = false);
         //Instance行为调用virtual

+ 29 - 24
XmdsCommonServer/Plugin/Units/XmdsInstancePet.cs

@@ -25,11 +25,14 @@ namespace XmdsCommonServer.Plugin.Units
 
         private InstanceUnit mCurAtkUnit = null;
 
+		//跟随最大距离的平方
+		private float mMaxFollowDistance = 10;
+
         public XmdsInstancePet(InstanceZone zone, UnitInfo info, string name, int force, int level)
             : base(zone, info, name, force, level)
         {
-
-        }
+			this.mMaxFollowDistance = (float)Math.Pow(Templates.CFG.PET_FOLLOW_DISTANCE_MAX, 2);
+		}
 
         public override bool IsActive
         {
@@ -464,29 +467,31 @@ namespace XmdsCommonServer.Plugin.Units
             //两圆相切.
             var atkr = this.GetSkillAttackRange(skillrange);
 
-            if (Collider.Object_HitBody_TouchRound(target, this.X, this.Y, atkr))
-            {
-                return true;
-            }
-            else if(this.SummonerUnit != null)
+			if (Collider.Object_HitBody_TouchRound(target, this.X, this.Y, atkr))
+			{
+				return true;
+			}
+			else if (this.SummonerUnit != null && target != null)
             {
-                //宠物可以离开宿主的最大范围.
-                float da = (float)Math.Pow(Templates.CFG.PET_FOLLOW_DISTANCE_MAX, 2);
-
-                CommonLang.Geometry.Vector2 v1 = new CommonLang.Geometry.Vector2(this.X, this.Y);
-                CommonLang.Geometry.Vector2 v2 = new CommonLang.Geometry.Vector2(target.X, target.Y);
-                //方向.
-                CommonLang.Geometry.Vector2 dir = (v2 - v1);
-                dir.Normalize();
-                var pos = v2 - dir * (atkr * target.BodyHitSize);
-                float rd = CMath.getDistanceSquare(pos.X, pos.Y, this.SummonerUnit.X, this.SummonerUnit.Y);
-
-                //在范围内.
-                if (rd < da)
-                {
-                    ret = true;
-                }
-            }
+				////宠物可以离开宿主的最大范围.
+				//float da = (float)Math.Pow(Templates.CFG.PET_FOLLOW_DISTANCE_MAX, 2);
+
+				//CommonLang.Geometry.Vector2 v1 = new CommonLang.Geometry.Vector2(this.X, this.Y);
+				//CommonLang.Geometry.Vector2 v2 = new CommonLang.Geometry.Vector2(target.X, target.Y);
+				////方向.
+				//CommonLang.Geometry.Vector2 dir = (v2 - v1);
+				//dir.Normalize();
+				//var pos = v2 - dir * (atkr * target.BodyHitSize);
+				//float rd = CMath.getDistanceSquare(pos.X, pos.Y, this.SummonerUnit.X, this.SummonerUnit.Y);
+
+				////在范围内.
+				//if (rd < da)
+				//{
+				//    ret = true;
+				//}
+				ret = CMath.getDistanceSquare(target.X, target.Y, this.SummonerUnit.X, this.SummonerUnit.Y) < this.mMaxFollowDistance;
+
+			}
 
             return ret;
         }

+ 1 - 1
XmdsCommonServer/Plugin/XmdsSkillTemplate/DamageCalculator/XmdsDamageCalculator.cs

@@ -44,7 +44,7 @@ namespace XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator
 		private const float Coefficient_Artifact = 1.1f;
 
 		//随从受伤K系数
-		private static readonly float PET_HIT_DAMAGE_K = 4.0f;
+		private static readonly float PET_HIT_DAMAGE_K = 2.0f;
 
         //万分比.
         public static float PERER = 10000.0f;

+ 11 - 11
XmdsCommonServer/Plugin/XmdsVirtual/XmdsVirtual.cs

@@ -980,7 +980,7 @@ namespace XmdsCommonServer.Plugin
             get { return mInCombatState; }
         }
 
-        public virtual void SetCombatState(BattleStatus value, byte reason = 0)
+        public virtual void SetCombatState(BattleStatus value, byte reason = 0, String pvpTriggerPlayerId = "")
         {
             // 只有在空闲状态才允许设置技能展示状态
             if (value == BattleStatus.ReadyBattle && mInCombatState != BattleStatus.None)
@@ -1017,7 +1017,12 @@ namespace XmdsCommonServer.Plugin
                     }
                 }
             }
-        }
+
+			if(mInCombatState == BattleStatus.PVP)
+			{
+				this.mPvpTriggerPlayerId = pvpTriggerPlayerId;
+			}			
+		}
 
         public bool IsInPVP()
         {
@@ -1118,13 +1123,8 @@ namespace XmdsCommonServer.Plugin
 
         protected virtual void ChangeCombatStateFromAtk(XmdsVirtual target)
         {
-            var s = BattleStatus.PVE;
-			if (target.IsPlayerUnit())
-			{
-				s = BattleStatus.PVP;
-				this.mPvpTriggerPlayerId = target.mUnit.PlayerUUID;
-			}
-            SetCombatState(s);
+            var s = target.IsPlayerUnit() ? BattleStatus.PVP : BattleStatus.PVE;
+            SetCombatState(s, 0, target.mUnit.PlayerUUID);
         }
 
         protected virtual void CombatStateConnect(BattleStatus status, byte reason)
@@ -1383,7 +1383,7 @@ namespace XmdsCommonServer.Plugin
                             UnderAttackCheck(attacker);
                         }
 
-                        SetCombatState(v);
+                        SetCombatState(v, 0, attacker.mUnit.PlayerUUID);
                         //坐骑状态下检查受击影响.
                         MountOnHitCheck(attacker);
                         //判断异常状态(击倒击飞).
@@ -1424,7 +1424,7 @@ namespace XmdsCommonServer.Plugin
                             UnderAttackCheck(attacker);
                         }
 
-                        SetCombatState(s);
+                        SetCombatState(s, 0, attacker.mUnit.PlayerUUID);
                     }
 
                     //攻击者进度战斗状态.

+ 1 - 1
XmdsCommonServer/Plugin/XmdsVirtual/XmdsVirtual_Monster.cs

@@ -174,7 +174,7 @@ namespace XmdsCommonServer.Plugin
             }
         }
 
-        public override void SetCombatState(BattleStatus value, byte reason = 0)
+        public override void SetCombatState(BattleStatus value, byte reason = 0, string pvpTriggerID = "")
         {
             //怪物强制为PVE状态.
             if (value == BattleStatus.PVP)

+ 7 - 3
XmdsVSPlugins/XmdsCommonSkill/Plugin/Skills/Warrior/Warrior_110500.cs

@@ -98,11 +98,15 @@ namespace XmdsCommonSkill.Plugin.Skills.Warrior
 		private float OnHandleHitOther(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source,
 			ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
 		{
+			//int timeIndex = Math.Min((int)((CommonLang.CUtils.localTimeMS - damageStartTime) / 1000), mIsHit.Length);
 			int timeIndex = (int)((CommonLang.CUtils.localTimeMS - damageStartTime) / 1000);
-			if(timeIndex < 0 || timeIndex >= mIsHit.Length)
+			if (timeIndex < 0 || timeIndex >= mIsHit.Length)
 			{
-				if(timeIndex > 6)
-					log.Error("Warrior_110500获取时间索引异常:" + attacker.mUnit.PlayerUUID + ", " + timeIndex  + ", "+ damageStartTime + ", " + CommonLang.CUtils.localTimeMS);
+				if(timeIndex > 7)
+				{
+					log.Error("Warrior_110500获取时间索引异常:" + attacker.mUnit.PlayerUUID + ", " + timeIndex + ", " + attacker.mUnit.Parent.GetSceneID());
+				}
+									
 				return damage;
 			}
 

+ 1 - 1
XmdsVSPlugins/XmdsCommonSkill/Plugin/base/JSGPlayerCardSkillBase.cs

@@ -118,7 +118,7 @@ namespace XmdsCommonSkill.Plugin.CardSkill
 				InstanceUnit hateUnit = launcher.GetHateSystem().GetHated();
 				if(hateUnit == null)
 				{
-					log.Error("JSGCardSkillBase unitLaunchSpell launch_null 3: " + spellID + ", CardSkillID: " + this.SkillID);
+					//log.Error("JSGCardSkillBase unitLaunchSpell launch_null 3: " + spellID + ", CardSkillID: " + this.SkillID);
 					return;
 				}