private void DamageAddChicken(ObjNPC npc) { var leftHp = npc.Attr.GetDataValue(eAttributeType.HpNow); var sumHp = npc.Attr.GetDataValue(eAttributeType.HpMax); var curIndex = (int)Math.Floor((float)(sumHp - leftHp) * 10 / sumHp); bool isNewHurt = hurtRate.Add(curIndex); if (isNewHurt && curIndex - bigCheckenDamage > 0) { int D_value = curIndex - bigCheckenDamage; //checken bigCheckenDamage = curIndex; if (curIndex == 10) //buff { var v2 = new Vector2(npc.GetPosition().X + MyRandom.Random(-randomNum, randomNum), npc.GetPosition().Y + MyRandom.Random(-randomNum, randomNum)); int itemId = int.Parse(BuffGroup[MyRandom.Random(0, BuffGroup.Length)]); DropItem(itemId, v2); } for (int i = 0; i < D_value; i++) { var vt = new Vector2(npc.GetPosition().X + MyRandom.Random(-randomNum, randomNum), npc.GetPosition().Y + MyRandom.Random(-randomNum, randomNum)); CreateDropItem(4, new List <ulong>(), 0, 29001, 1, vt); } } if (leftHp <= 0) { bigCheckenDamage = 0; hurtRate.Clear(); } }
public override void OnEnterCombat(ObjNPC npc) { npc.BornPosition = npc.GetPosition(); npc.BornDirection = npc.GetDirection(); //保存下进入战斗时的位置,距离这个位置太远了就要回家 mBackPosition = npc.GetPosition(); //获得目标 var enemy = npc.Scene.FindCharacter(npc.LastEnemyId); if (null != enemy) { npc.TurnFaceTo(enemy.GetPosition()); } npc.BroadcastDirection(); //保存普攻数据 if (-1 != npc.NormalSkillId) { mTableNormalSkill = Table.GetSkill(npc.NormalSkillId); //计算普攻技能距离 mSkillDistance = SkillManager.GetSkillDistance((SkillTargetType)mTableNormalSkill.TargetType, mTableNormalSkill.TargetParam); //上来先来个cd,要不攻击者一攻击怪一瞬间怪就反击 GenNextNormalAttackTime(); } mNoMoveTime = 0; }
public override void OnEnterCombat(ObjNPC npc) { base.OnEnterCombat(npc); npc.BornPosition = npc.GetPosition(); npc.BornDirection = npc.GetDirection(); //保存下进入战斗时的位置,距离这个位置太远了就要回家 mBackPosition = npc.GetPosition(); }
private ObjCharacter GetCanAttack(ObjNPC npc) { if (mLastEnemy == null || mLastEnemy.IsDead() || !mLastEnemy.Active) { ObjCharacter temp = null; var maxDis = 9999999.0f; foreach (var pair in npc.Scene.mObjDict) { var t = pair.Value as ObjCharacter; if (t == null) { continue; } if (t.IsDead() || !t.Active) { continue; } if (!mAddList.Contains(t.TypeId)) { continue; } var dis = (npc.GetPosition() - t.GetPosition()).LengthSquared(); if (dis < maxDis) { temp = t; maxDis = dis; } } return(temp); } return(mLastEnemy); }
protected ObjCharacter ScanEnemy(ObjNPC npc, float distance) { if (null == npc) { return(null); } if (null == npc.Zone) { return(null); } var sq = distance * distance; ObjCharacter target = null; var objs = npc.Zone.EnumAllVisibleObj(); foreach (var obj in objs) { if (null == obj) { continue; } if (obj.ObjId == npc.ObjId) { continue; } if (!obj.IsCharacter()) { continue; } var character = obj as ObjCharacter; if (null == character) { continue; } if (character.IsDead()) { continue; } if (!npc.IsMyEnemy(character)) { continue; } var temp = (npc.GetPosition() - character.GetPosition()).LengthSquared(); if (temp <= sq) { target = character; sq = temp; } } return(target); }
private void FindNpcEnemy(ObjNPC npc, float dist = 10) { try { if (npc != null) { float distSqr = dist * dist; foreach (ObjBase o in npc.Zone.EnumAllVisibleObj()) { try { if (!(o is ObjNPC)) { continue; } var obj = o as ObjNPC; if (!obj.Active) { continue; } if (obj.GetObjType() != ObjType.NPC) { continue; } if (!obj.IsVisibleTo(npc)) { continue; } if (obj.mCamp == npc.mCamp) { continue; } if ((obj.GetPosition() - npc.GetPosition()).LengthSquared() > distSqr) { continue; } npc.EnterState(BehaviorState.Combat); npc.PushHatre(obj, 1); npc.AddEnemy(obj.ObjId); obj.AddEnemy(npc.ObjId); } catch { } } } } catch { } }
//回家 public override void OnEnterGoHome(ObjNPC npc) { base.OnEnterGoHome(npc); if ((npc.GetPosition() - npc.BornPosition).LengthSquared() < 0.01f) { npc.EnterState(BehaviorState.Idle); return; } // 30 秒后如果还没有回去,强制拉回去,并开始idle TimeToReset = DateTime.Now.AddSeconds(30); npc.MoveTo(npc.BornPosition); }
public override void OnTickCombat(ObjNPC npc, float delta) { if (!npc.CanSkill()) { return; } //判断敌人是否存在 var enemy = GetCanAttack(npc); if (null == enemy) { npc.EnterState(BehaviorState.GoHome); return; } var WillskillId = npc.NormalSkillId; //GetCanDoSkill(npc);//npc.NormalSkillId; var mTableWillskill = Table.GetSkill(WillskillId); if (mTableWillskill == null) { return; } mSkillDistance = SkillManager.GetSkillDistance((SkillTargetType)mTableWillskill.TargetType, mTableWillskill.TargetParam); //跟着敌人打 if ((npc.GetPosition() - enemy.GetPosition()).Length() > mSkillDistance) { var diffDis = mSkillDistance - 1.0f; if (diffDis < 0) { diffDis = 0; } npc.MoveTo(enemy.GetPosition(), diffDis); } else { npc.TurnFaceTo(enemy.GetPosition()); if (npc.IsMoving()) { npc.StopMove(); } if (DateTime.Now >= mNextNormalAttackTime) { var reCodes = npc.MustSkill(ref WillskillId, enemy); //npc.UseSkill(ref skillId, enemy); //if (reCodes == ErrorCodes.OK) //{ // PushSkillCd(npc, WillskillId); //} } } }
public override void OnTickGoHome(ObjNPC npc, float delta) { if (!npc.IsMoving()) { if ((npc.BornPosition - npc.GetPosition()).LengthSquared() < 1.5f) { npc.EnterState(BehaviorState.Idle); } else { npc.MoveTo(npc.BornPosition); } } }
//战斗 public override void OnEnterCombat(ObjNPC npc) { ChangeAi(npc, npc.TableNpc.mAI); //先停止移动 if (npc.IsMoving()) { npc.StopMove(); } //保存下进入战斗时的位置,距离这个位置太远了就要回家 mBackPosition = npc.GetPosition(); //获得目标 var enemy = npc.Scene.FindCharacter(npc.LastEnemyId); if (null != enemy) { npc.TurnFaceTo(enemy.GetPosition()); } //保存普攻数据 if (-1 != npc.TableAI.CommonSkill) { mTableNormalSkill = Table.GetSkill(npc.TableAI.CommonSkill); //计算普攻技能距离 mSkillDistance = SkillManager.GetSkillDistance((SkillTargetType)mTableNormalSkill.TargetType, mTableNormalSkill.TargetParam); //上来先来个cd,要不攻击者一攻击怪一瞬间怪就反击 var milliseconds = mTableNormalSkill.Cd <= 0 ? 3000 : mTableNormalSkill.Cd; mNextNormalAttackTime = DateTime.Now + TimeSpan.FromMilliseconds(milliseconds); } CombatTime = 0; for (var i = 0; i != 4; ++i) { if (npc.TableAI.SpecialSkill[i] == -1) { continue; } PushSkillCd(npc, npc.TableAI.SpecialSkill[i], npc.TableAI.InitCd[i]); } }
public override void OnTickGoHome(ObjNPC npc, float delta) { if (!npc.IsMoving()) { if ((npc.BornPosition - npc.GetPosition()).LengthSquared() < 1.5f) { npc.EnterState(BehaviorState.Idle); } else { npc.MoveTo(npc.BornPosition, 1); } } if (DateTime.Now > TimeToReset) { npc.SetPosition(npc.BornPosition); npc.EnterState(BehaviorState.Idle); TimeToReset = TimeToReset.AddYears(100); } }
public override void OnTickGoHome(ObjNPC npc, float delta) { var retinue = npc as ObjRetinue; if (retinue == null) { return; } if (retinue.Owner == null) { return; } if (!npc.IsMoving()) { if ((npc.BornPosition - npc.GetPosition()).LengthSquared() < 1.5f) { npc.EnterState(BehaviorState.Idle); } else { npc.MoveTo(retinue.Owner.GetPosition(), 1); } } }
public override void OnTickCombat(ObjNPC npc, float delta) { var retinue = npc as ObjRetinue; if (retinue == null) { return; } if (retinue.Owner == null || retinue.Owner.Scene == null) { retinue.Scene.LeaveScene(retinue); return; } var myPos = retinue.GetPosition(); var ownerPos = retinue.Owner.GetPosition(); if (mNextNormalAttackTime > DateTime.Now) { return; } var distance = (myPos - ownerPos).LengthSquared(); //if (distance > 400) //{ // var diff = GetRandomPostion(); // diff += ownerPos; // npc.SetCheckPostion(diff); // //retinue.MoveTo(ownerPos, 2); // npc.EnterState(BehaviorState.GoHome); // return; //} if (distance > 64) { retinue.MoveTo(ownerPos, 2); return; //var p = myPos + Vector2.Normalize(ownerPos - myPos) * 2; //retinue.MoveTo(p); } var tag = retinue.Owner.Scene.GetObstacleValue(ownerPos.X, ownerPos.Y); if (tag == SceneObstacle.ObstacleValue.Walkable) //自身在安全区禁止攻击 { return; } var enemyTarget = GetEnemyCharacter(retinue); if (enemyTarget == null) { npc.EnterState(BehaviorState.GoHome); return; } if (enemyTarget.GetObjType() == ObjType.PLAYER) { tag = enemyTarget.Scene.GetObstacleValue(ownerPos.X, ownerPos.Y); if (tag == SceneObstacle.ObstacleValue.Walkable) //对方在安全区禁止攻击 { return; } } LastTargetId = enemyTarget.ObjId; var WillskillId = GetCanDoSkill(npc); //npc.NormalSkillId; var mTableWillskill = Table.GetSkill(WillskillId); if (mTableWillskill == null) { return; } mSkillDistance = SkillManager.GetSkillDistance((SkillTargetType)mTableWillskill.TargetType, mTableWillskill.TargetParam); //跟着敌人打 if ((npc.GetPosition() - enemyTarget.GetPosition()).Length() > mSkillDistance) { npc.MoveTo(enemyTarget.GetPosition(), mSkillDistance - 0.3f); } else { if (npc.IsMoving()) { npc.StopMove(); } if (npc.UseSkill(ref WillskillId, enemyTarget) == ErrorCodes.OK) { //int cd = mTableNormalSkill.Cd; //if (cd < mTableNormalSkill.CommonCd) //{ // cd = mTableNormalSkill.CommonCd; //} //int milliseconds = cd <= 0 ? DEFAULT_NORMAL_ATTACK_INTERVAL_MILLISECONDS : cd; //mNextNormalAttackTime = DateTime.Now + TimeSpan.FromMilliseconds(milliseconds); PushSkillCd(npc, WillskillId); } } }
public override void OnTickCombat(ObjNPC npc, float delta) { var enemyTarget = GetEnemyCharacter(npc); if (enemyTarget == null) { npc.EnterState(BehaviorState.Idle); return; } if (!npc.CanMove()) { return; } NextSkill = FindFreeSkill(npc, enemyTarget); if (NextSkill == -1) { return; } var tbSkill = Table.GetSkill(NextSkill); if (tbSkill == null) { return; } if ((SkillTargetType)tbSkill.TargetType == SkillTargetType.SELF || (eCampType)tbSkill.CampType == eCampType.Team) { if (npc.IsMoving()) { npc.StopMove(); } if (npc.CanSkill()) { LastTargetId = enemyTarget.ObjId; SelectLastTarger = true; npc.TurnFaceTo(enemyTarget.GetPosition()); npc.UseSkill(ref NextSkill, npc); } return; } mSkillDistance = SkillManager.GetSkillDistance((SkillTargetType)tbSkill.TargetType, tbSkill.TargetParam); //跟着敌人打 if ((npc.GetPosition() - enemyTarget.GetPosition()).Length() > mSkillDistance) { npc.MoveTo(enemyTarget.GetPosition(), mSkillDistance - 0.1f); } else { if (npc.IsMoving()) { npc.StopMove(); } if (npc.CanSkill()) { LastTargetId = enemyTarget.ObjId; SelectLastTarger = true; npc.TurnFaceTo(enemyTarget.GetPosition()); npc.UseSkill(ref NextSkill, enemyTarget); } } }
private ObjCharacter GetCanAttack(ObjNPC npc) { if (mLastEnemy != null && mLastEnemy.Active && !mLastEnemy.IsDead() && npc.Zone.ObjDict.ContainsKey(mLastEnemy.ObjId)) { return(mLastEnemy); } if (MyTargetObjList.Count == 0) { foreach (var pair in npc.Scene.mObjDict) { if (!pair.Value.IsCharacter()) { continue; } var t = pair.Value as ObjCharacter; if (t.IsDead() || !t.Active) { continue; } if (!mAddList.Contains(t.TypeId)) { continue; } MyTargetObjList.Add(t.ObjId); } } var e = npc.Zone.EnumAllVisiblePlayer(); foreach (var objPlayer in e) { if (!MyTargetObjList.Contains(objPlayer.ObjId)) { MyTargetObjList.Add(objPlayer.ObjId); } } ObjCharacter temp = null; var maxDis = 9999999.0f; for (int i = 0; i < MyTargetObjList.Count;) { var objId = MyTargetObjList[i]; var target = npc.Scene.FindObj(objId); if (null == target) { MyTargetObjList.RemoveAt(i); continue; } var enemy = target as ObjCharacter; if (enemy.IsDead() || !enemy.Active) { MyTargetObjList.RemoveAt(i); continue; } var dis = (npc.GetPosition() - enemy.GetPosition()).LengthSquared(); if (dis < maxDis) { temp = enemy; maxDis = dis; } i++; } mLastEnemy = temp; return(temp ?? mLastEnemy); }
public override void OnTickCombat(ObjNPC npc, float delta) { CombatTime += 500; if (!npc.CanSkill()) { return; } //判断是否需要状态转换 var nextAi = CheckStateChange(npc); ChangeAi(npc, nextAi); //判断敌人是否存在 var enemy = GetAttackTarget(npc); if (null == enemy) { npc.EnterState(BehaviorState.GoHome); return; } //判断敌人是否有效 if (enemy.IsDead() || !enemy.Active) { npc.EnterState(BehaviorState.GoHome); return; } //判断是否太远了 var dis = (npc.GetPosition() - mBackPosition).Length(); if (npc.TableNpc.MaxCombatDistance > 0 && dis >= npc.TableNpc.MaxCombatDistance) { npc.EnterState(BehaviorState.GoHome); return; } var WillskillId = GetCanDoSkill(npc); //npc.NormalSkillId; var mTableWillskill = Table.GetSkill(WillskillId); if (mTableWillskill == null) { return; } switch ((SkillTargetType)mTableWillskill.TargetType) { case SkillTargetType.SELF: { if (DateTime.Now >= mNextNormalAttackTime) { var reCodes = npc.MustSkill(ref WillskillId, npc); //npc.UseSkill(ref skillId, enemy); if (reCodes == ErrorCodes.OK) { PushSkillCd(npc, WillskillId); } return; } mTableWillskill = Table.GetSkill(npc.TableAI.CommonSkill); if (mTableWillskill == null) { return; } } break; case SkillTargetType.SINGLE: break; case SkillTargetType.CIRCLE: break; case SkillTargetType.SECTOR: break; case SkillTargetType.RECT: break; case SkillTargetType.TARGET_CIRCLE: break; case SkillTargetType.TARGET_RECT: break; case SkillTargetType.TARGET_SECTOR: break; default: break; } mSkillDistance = SkillManager.GetSkillDistance((SkillTargetType)mTableWillskill.TargetType, mTableWillskill.TargetParam); //跟着敌人打 if ((npc.GetPosition() - enemy.GetPosition()).Length() > mSkillDistance) { var diffDis = mSkillDistance - 1.0f; if (diffDis < 0) { diffDis = 0; } npc.MoveTo(enemy.GetPosition(), diffDis); } else { npc.TurnFaceTo(enemy.GetPosition()); if (npc.IsMoving()) { npc.StopMove(); } if (DateTime.Now >= mNextNormalAttackTime) { var reCodes = npc.MustSkill(ref WillskillId, enemy); //npc.UseSkill(ref skillId, enemy); if (reCodes == ErrorCodes.OK) { PushSkillCd(npc, WillskillId); } } } }
public override void OnTickCombat(ObjNPC npc, float delta) { CombatTime += 500; if (!npc.CanSkill()) { return; } //判断是否需要状态转换 var nextAi = CheckStateChange(npc); ChangeAi(npc, nextAi); //判断敌人是否存在 var enemy = GetAttackTarget(npc); if (null == enemy || enemy.IsDead() || !enemy.Active) { npc.EnterState(BehaviorState.Idle); npc.SetDirection(npc.BornDirection); npc.BroadcastDirection(); npc.RemoveMeFromOtherEnemyList(); npc.ClearEnemy(); return; } var WillskillId = GetCanDoSkill(npc); //npc.NormalSkillId; var mTableWillskill = Table.GetSkill(WillskillId); if (mTableWillskill == null) { return; } switch ((SkillTargetType)mTableWillskill.TargetType) { case SkillTargetType.SELF: { if (DateTime.Now >= mNextNormalAttackTime) { var reCodes = npc.MustSkill(ref WillskillId, npc); //npc.UseSkill(ref skillId, enemy); if (reCodes == ErrorCodes.OK) { PushSkillCd(npc, WillskillId); } return; } mTableWillskill = Table.GetSkill(npc.TableAI.CommonSkill); if (mTableWillskill == null) { return; } } break; case SkillTargetType.SINGLE: break; case SkillTargetType.CIRCLE: break; case SkillTargetType.SECTOR: break; case SkillTargetType.RECT: break; case SkillTargetType.TARGET_CIRCLE: break; case SkillTargetType.TARGET_RECT: break; case SkillTargetType.TARGET_SECTOR: break; default: break; } mSkillDistance = SkillManager.GetSkillDistance((SkillTargetType)mTableWillskill.TargetType, mTableWillskill.TargetParam); //跟着敌人打 if ((npc.GetPosition() - enemy.GetPosition()).Length() > mSkillDistance) { npc.SetDirection(npc.BornDirection); npc.BroadcastDirection(); } else { npc.TurnFaceTo(enemy.GetPosition()); if (DateTime.Now >= mNextNormalAttackTime) { var reCodes = npc.MustSkill(ref WillskillId, enemy); //npc.UseSkill(ref skillId, enemy); if (reCodes == ErrorCodes.OK) { PushSkillCd(npc, WillskillId); } } } }
public void Seperate(ObjNPC _this, ObjCharacter enemy, float dist) { if (ObjNPC.PreCalculatedClockwiseRotation == null) { CalculateRotation(); } var move = false; ObjCharacter npc; // 如果人很多的话,减小距离 var d = 2 * Math.PI * dist / enemy.EnemyList.Count; var t = Math.Min(d * d, 0.25f); var s = 0; var i = 0; for (; i < enemy.EnemyList.Count; i++) { var npcId = enemy.EnemyList[i]; if (npcId == _this.ObjId) { break; } npc = _this.Scene.FindCharacter(npcId); if (npc == null) { enemy.EnemyList.RemoveAt(i); --i; continue; } var distSqr = (npc.GetPosition() - _this.GetPosition()).LengthSquared(); if (distSqr < 1) { if (distSqr < t) { move = true; } s++; } } if (s >= 36) { // 怪实在太多了,随便找个地方给他吧 s = MyRandom.Random(3); } if (move) { var pos = _this.GetPosition(); var p = (pos - enemy.GetPosition()); //顺时针旋转 if (_this.ObjId % 2 == 0) { var x = Vector2.Dot(p, ObjNPC.PreCalculatedClockwiseRotation[2 * s]); var y = Vector2.Dot(p, ObjNPC.PreCalculatedClockwiseRotation[2 * s + 1]); pos = enemy.GetPosition() + new Vector2(x, y); } else { var x = Vector2.Dot(p, ObjNPC.PreCalculatedCounterClockwiseRotation[2 * s]); var y = Vector2.Dot(p, ObjNPC.PreCalculatedCounterClockwiseRotation[2 * s + 1]); pos = enemy.GetPosition() + new Vector2(x, y); } if (enemy.Scene.ValidPosition(pos)) { _this.SetPosition(pos); } } }
public override void OnTickCombat(ObjNPC npc, float delta) { if (npc.TableAI.Id == MieShiBuildingAI) { if (!npc.CanSkill()) { return; } if (!npc.CanSkill()) { return; } //判断敌人是否存在 var enemy = GetCanAttack(npc); if (null == enemy) { npc.EnterState(BehaviorState.GoHome); return; } var WillskillId = npc.NormalSkillId; //GetCanDoSkill(npc);//npc.NormalSkillId; var mTableWillskill = Table.GetSkill(WillskillId); if (mTableWillskill == null) { return; } mSkillDistance = SkillManager.GetSkillDistance((SkillTargetType)mTableWillskill.TargetType, mTableWillskill.TargetParam); //跟着敌人打 if ((npc.GetPosition() - enemy.GetPosition()).Length() > mSkillDistance) { var diffDis = mSkillDistance - 1.0f; if (diffDis < 0) { diffDis = 0; } npc.MoveTo(enemy.GetPosition(), diffDis); } else { npc.TurnFaceTo(enemy.GetPosition()); if (npc.IsMoving()) { npc.StopMove(); } if (DateTime.Now >= mNextNormalAttackTime) { var reCodes = npc.MustSkill(ref WillskillId, enemy); //npc.UseSkill(ref skillId, enemy); //if (reCodes == ErrorCodes.OK) //{ // PushSkillCd(npc, WillskillId); //} } } } else { PatrolTime += 500; //判断是否需要状态转换 if (!bAIChange) { var nextAi = CheckToStateChange(npc); if (nextAi > -1) { Logger.Warn("======================ChangeAi============================[179] {0}", npc.mTypeId); ChangeAi(npc, nextAi); bAIChange = true; return; } } base.OnTickCombat(npc, delta); } }
public override void OnTickCombat(ObjNPC npc, float delta) { ObjCharacter enemy = null; //判断敌人是否存在 if (npc.TableAI == null) { enemy = npc.GetMaxHatre(); } else { enemy = GetAttackTarget(npc); } //判断敌人是否存在 if (null == enemy) { npc.EnterState(BehaviorState.GoHome); return; } //判断敌人是否有效 if (enemy.IsDead() || !enemy.Active) { npc.EnterState(BehaviorState.GoHome); return; } //判断是否太远了 var dis = (npc.GetPosition() - mBackPosition).Length(); if (npc.TableNpc.MaxCombatDistance > 0 && dis >= npc.TableNpc.MaxCombatDistance) { npc.EnterState(BehaviorState.GoHome); return; } //如果有普通 if (null != mTableNormalSkill) { //跟着敌人打 if ((npc.GetPosition() - enemy.GetPosition()).Length() <= mSkillDistance) { npc.TurnFaceTo(enemy.GetPosition()); if (npc.IsMoving()) { GenNextNormalAttackTime(100); npc.StopMove(); } if (DateTime.Now >= mNextNormalAttackTime) { npc.Seperate(enemy, mSkillDistance / 3); var skillId = npc.NormalSkillId; npc.UseSkill(ref skillId, enemy); GenNextNormalAttackTime(); mNoMoveTime = 0; //攻击了一次就把自己站在原地的累计时间清空 } } else { var targetPos = npc.CalculatePostionToEnemy(enemy, mSkillDistance / 3); if (MoveResult.CannotReach == npc.MoveTo(targetPos)) { //如果长时间无法到达目的地说明卡怪了, 就回去 mNoMoveTime += delta; if (mNoMoveTime >= MAX_NO_MOVE_TIME) { npc.EnterState(BehaviorState.GoHome); } } else { mNoMoveTime = 0; } } } }
//触发掉落 public void MonsterKill(ObjNPC npc, ulong killer) { var tbNpc = Table.GetNpcBase(npc.TypeId); if (tbNpc == null) { Logger.Error("MonsterKill Type={0}", npc.TypeId); return; } var scene = npc.Scene; var GiveExp = new Dictionary <ObjCharacter, int>(); var playerList = npc.GetExpList(GiveExp); if (playerList == null) { return; } if (playerList.Count < 1) { return; } //分经验 foreach (var i in GiveExp) { var player = i.Key as ObjPlayer; if (player != null) { var giveExp = 0; if (tbNpc.IsDynamicExp == 1) { var refExp = i.Key.Attr._ExpRef; if (tbNpc.ExpMultiple > 2) { refExp = (tbNpc.ExpMultiple + i.Key.Attr._ExpRef - 10000); } giveExp = (int) (tbNpc.DynamicExpRatio / 10000.0f * Table.GetLevelData(player.GetLevel()).DynamicExp *refExp / 10000); } else { if (tbNpc.ExpMultiple < 2) { giveExp = i.Value * i.Key.Attr._ExpRef / 10000; } else { giveExp = (int)(1.0 * i.Value * (tbNpc.ExpMultiple + i.Key.Attr._ExpRef - 10000) / 10000); } } var addCount = AutoActivityManager.GetActivity(1020); if (addCount > 1) { if (tbNpc.Id >= 210000 && tbNpc.Id <= 213104) { giveExp = giveExp * addCount; } } giveExp = (int)(giveExp * player.GetAdditionExp()); float fExp = player.Attr.ExpAdd / 10000.0f; giveExp = (int)(giveExp * fExp); if (player.Scene != null) { player.Scene.OnPlayerPickUp(player.ObjId, (int)eResourcesType.ExpRes, giveExp); } CoroutineFactory.NewCoroutine(MonsterKillMessageToLogic, i.Key.ObjId, npc.TypeId, giveExp, scene.TypeId).MoveNext(); //攻击装备耐久相关 player.TryDelAttackEquipDurable(); } } var dropId = tbNpc.DropId; if (scene.SpecialDrop != -1 && tbNpc.Spare != -1) { var tbSU = Table.GetSkillUpgrading(tbNpc.Spare); dropId = tbSU.GetSkillUpgradingValue(scene.SpecialDrop); } if (dropId == -1) { return; } var Droplist = new Dictionary <int, int>(); //特殊掉落 { List <int> list; if (Drop.SpecialDropForNewCharacter.TryGetValue(tbNpc.Id, out list)) { var id = list[0]; var character = CharacterManager.Instance.GetCharacterControllerFromMemroy(killer); if (character != null) { var ex = character.mDbData.SpecialDrop; if (!BitFlag.GetLow(ex, id)) { Droplist.Clear(); var dropid = list[character.TypeId + 1]; DropMother(dropid, Droplist); if (Droplist.Count > 0) { ex = BitFlag.LongSetFlag(ex, id); character.mDbData.SpecialDrop = ex; character.MarkDbDirty(); } foreach (var i in Droplist) { scene.CreateDropItem(tbNpc.BelongType, new List <ulong> { character.ObjId }, 0, i.Key, i.Value, npc.GetPosition()); } Droplist.Clear(); } } } } //节日掉落 { var dropIds = tbNpc.SpecialDrops; var yunyingIds = tbNpc.YunYingIds; for (int i = 0; i < yunyingIds.Count; i++) { var tbOperationActivity = Table.GetOperationActivity(yunyingIds[i]); if (null == tbOperationActivity) { continue; } if (!(System.DateTime.Now >= System.DateTime.Parse(tbOperationActivity.openTime) && System.DateTime.Now <= System.DateTime.Parse(tbOperationActivity.closeTime))) { continue; } if (i >= dropIds.Count) { continue; } Droplist.Clear(); DropMother(dropIds[i], Droplist); var character = CharacterManager.Instance.GetCharacterControllerFromMemroy(killer); if (character != null) { foreach (var dropitem in Droplist) { scene.CreateDropItem(tbNpc.BelongType, new List <ulong> { character.ObjId }, 0, dropitem.Key, dropitem.Value, npc.GetPosition()); //Logger.Warn("holidaydrop: [{0},{1}]", dropitem.Key, dropitem.Value); } Droplist.Clear(); } } } //分掉落物品 switch (tbNpc.BelongType) { case 0: //队内自由拾取 { DropMother(dropId, Droplist); var ownerList = new List <ulong>(); foreach (var character in playerList) { if (character != null && tbNpc.LimitFlag > 0) { if (character.GetObjType() == ObjType.PLAYER) { var p = character as ObjPlayer; if (p != null) { Dict_int_int_Data data = new Dict_int_int_Data(); data.Data.Add(tbNpc.LimitFlag, 1); p.SendExDataChange(data); } } } ownerList.Add(character.ObjId); } foreach (var i in Droplist) { scene.CreateDropItem(tbNpc.BelongType, ownerList, playerList[0].GetTeamId(), i.Key, i.Value, npc.GetPosition()); } } break; case 1: //队内伤害拾取 { DropMother(dropId, Droplist); var ownerList = new List <ulong>(); if (playerList[0].GetTeamId() == 0) { ownerList.Add(playerList[0].ObjId); var p = playerList[0] as ObjPlayer; if (p != null) { Dict_int_int_Data data = new Dict_int_int_Data(); data.Data.Add(tbNpc.LimitFlag, 1); p.SendExDataChange(data); } } else { var maxHatre = 0; ObjCharacter maxCharacter = null; foreach (var character in playerList) { var nh = npc.GetNowHatre(character); if (nh > maxHatre) { maxHatre = nh; maxCharacter = character; } } //ObjCharacter maxCharacter = npc.GetMaxHatreByTeam(playerList[0].GetTeamId()); if (maxCharacter == null) { ownerList.Add(playerList[0].ObjId); maxCharacter = playerList[0]; } else { ownerList.Add(maxCharacter.ObjId); } if (maxCharacter.GetObjType() == ObjType.PLAYER) { var p = maxCharacter as ObjPlayer; if (p != null) { Dict_int_int_Data data = new Dict_int_int_Data(); data.Data.Add(tbNpc.LimitFlag, 1); p.SendExDataChange(data); } } } foreach (var i in Droplist) { scene.CreateDropItem(tbNpc.BelongType, ownerList, playerList[0].GetTeamId(), i.Key, i.Value, npc.GetPosition()); } } break; case 2: //队内分别拾取 { foreach (var character in playerList) { if (npc.Scene == null || character.Scene == null) { continue; } if (npc.Scene.Guid != character.Scene.Guid) { continue; } Droplist.Clear(); DropMother(dropId, Droplist); foreach (var i in Droplist) { scene.CreateDropItem(tbNpc.BelongType, new List <ulong> { character.ObjId }, 0, i.Key, i.Value, npc.GetPosition()); } if (character.GetObjType() == ObjType.PLAYER) { var p = character as ObjPlayer; if (p != null) { Dict_int_int_Data data = new Dict_int_int_Data(); data.Data.Add(tbNpc.LimitFlag, 1); p.SendExDataChange(data); } } } } break; case 3: //所有人分别拾取 { var Hatres = npc.GetAllHatre(); foreach (var hatre in Hatres) { if (!(hatre.Key is ObjPlayer)) { continue; } if (npc.Scene == null || hatre.Key.Scene == null) { continue; } if (npc.Scene.Guid != hatre.Key.Scene.Guid) { continue; } Droplist.Clear(); DropMother(dropId, Droplist); foreach (var i in Droplist) { scene.CreateDropItem(tbNpc.BelongType, new List <ulong> { hatre.Key.ObjId }, 0, i.Key, i.Value, npc.GetPosition()); } if (hatre.Key.GetObjType() == ObjType.PLAYER) { var p = hatre.Key as ObjPlayer; if (p != null) { Dict_int_int_Data data = new Dict_int_int_Data(); data.Data.Add(tbNpc.LimitFlag, 1); p.SendExDataChange(data); } } } } break; case 4: //所有人自由拾取 { Droplist.Clear(); DropMother(dropId, Droplist); var addCount = AutoActivityManager.GetActivity(1010); if (addCount > 1) { if (npc.TableNpc.Id >= 65000 && npc.TableNpc.Id < 65005) { for (var i = 1; i < addCount; i++) { DropMother(dropId, Droplist); } } } foreach (var i in Droplist) { scene.CreateDropItem(tbNpc.BelongType, new List <ulong>(), 0, i.Key, i.Value, npc.GetPosition()); } } break; } }