Exemple #1
0
        public override bool FollowTarget(NPCInstance npc, RoleActor target)
        {
            if (!base.FollowTarget(npc, target))
            {
                return(false);
            }

            Vector3 standPos = target.GetSurroundPosition(npc.GetPosition(), (int)npc.mCastSpellDistance, npc.Id);

            if (!Util.PassableForMod(npc.HostMap.Navigator, standPos))
            {
                if (!Util.PassableForMod(npc.HostMap.Navigator, target.GetPosition()))
                {
                    return(false);
                }
                standPos = target.GetPosition();
            }

            if (!npc.MoveTo(standPos))
            {
                return(false);
            }

            npc.ChangeState(eNPCState.FollowTarget);

            return(true);
        }
Exemple #2
0
        public override void OnCastSpell()
        {
            if (!mIsCanAttack)
            {
                return;
            }
            if (IsMoving)
            {
                return;
            }

            RoleActor target = GetTarget(mAttackTarget);

            if (null == target || !target.CanBeAttacked())
            {
                ChangeState(eNPCState.Idle);
                return;
            }
            //if (Spell(mCurrentSpellID, target) == eSkillResult.OK)
            eSkillResult ret = eSkillResult.OK;

            if (CastSpell(mCurrentSpellID, mAttackTarget, ref ret))
            {
                mCurrSpellNode++;
                ChangeState(eNPCState.WaitCoolDown);
            }
        }
Exemple #3
0
        public bool CreateFashionToBag(RoleActor role, int templateId)
        {
            Item item   = Item.DangerousCreateItemById(role, templateId, 1);
            bool result = this.AutoAddItem(item);

            return(result);
        }
Exemple #4
0
        public void DropItems(UInt16 dropId, RoleActor picker)
        {
            if (dropId == UInt16.MaxValue)
            {
                //这里缺省掉落
                dropId = GetItemDropper();
            }

//             var dropper = CSCommon.Data.Item.DropTemplateManager.Instance.GetDropper(dropId);
//             if (dropper != null)
//             {
//
//                 var items = ServerCommon.Planes.Bag.Item.DangerouseDropItems(picker,dropper);
//
//                 foreach (var item in items)
//                 {
//                     var fromPos = GetPosition();
//                     var dropPos = GetPosition();
//                     //这里应该在附近随机找能掉落物品的位置
//                     float radius = 2.0f;
//                     dropPos.X += (GetRandomUnit() * 2.0F - 1.0f) * radius;
//                     dropPos.Z += (GetRandomUnit() * 2.0F - 1.0f) * radius;
//                     dropPos.Y = mHostMap.GetAltitude(dropPos.X, dropPos.Z);
//
//                 }
//             }
        }
Exemple #5
0
        public virtual void OnRoleEnterMap(RoleActor role)
        {
            var loc     = role.GetPosition();
            var mapCell = GetMapCell(loc.X, loc.Z);

            mapCell.AddRole(role);
        }
Exemple #6
0
        /// <summary>
        /// 实际选择目标
        /// </summary>
        public override bool SelectTarget(RoleActor caster, SkillActive skill, ref List <RoleActor> targets)
        {
            if (!base.SelectTarget(caster, skill, ref targets))
            {
                return(false);
            }

            List <RoleActor> roleList   = new List <RoleActor>();
            UInt32           actorTypes = (1 << (Int32)eActorGameType.Player) | (1 << (Int32)eActorGameType.Npc) | (1 << (Int32)eActorGameType.PlayerImage);
            var pos = caster.GetPosition();

            if (!caster.HostMap.TourRoles(ref pos, skill.RangeMax, actorTypes, roleList))
            {
                return(false);
            }

            foreach (var tar in roleList)
            {
                if (Util.DistanceH(tar.GetPosition(), caster.GetPosition()) <= skill.RangeMax)
                {
                    targets.Add(tar);
                }
            }

            return(true);
        }
Exemple #7
0
        //Dictionary<ulong, TriggerProcessData_Server> mProcessDatas = new Dictionary<ulong, TriggerProcessData_Server>();
        // delta为检测范围调整阈值
        public eRet_EnterTrigger TryDoTrigger(RoleActor actor, RPC.RPCForwardInfo fwd, float delta = 1.0f)
        {
            if (!Enable)
            {
                return(eRet_EnterTrigger.NotEnable);
            }

            if (actor == null)
            {
                return(eRet_EnterTrigger.ActorIsNull);
            }

            if (!IsPositionIn(actor.GetPosition().X, actor.GetPosition().Z, delta))
            {
                return(eRet_EnterTrigger.NotInArea);
            }

            var player = actor as PlayerInstance;

            if (player == null)
            {
                return(eRet_EnterTrigger.ActorIsNotPlayer);
            }
            if (TriggerData == null)
            {
                return(eRet_EnterTrigger.NotFindData);
            }

            player.JumpToMap((ushort)TriggerData.mapId, TriggerData.targetX, 0, TriggerData.targetZ, fwd);
            return(eRet_EnterTrigger.EnterMap);
        }
Exemple #8
0
        public void RemoveRole(RoleActor role)
        {
            RoleDictionary.Remove(role.Id);
            role.HostMapCell = null;

            if (role is PlayerInstance)
            {
                Players.Remove(role as PlayerInstance);
            }
            else
            {
                switch (role.GameType)
                {
                case eActorGameType.Npc:
                    NPCs.Remove(role as NPCInstance);
                    break;

                case eActorGameType.PlayerImage:
                    Images.Remove(role as PlayerImage);
                    break;

//                     case CSCommon.Component.eActorGameType.EffectNpc:
//                         EffectNpcs.Remove(role);
//                         break;
                //case CSCommon.Component.eActorGameType.DropedItem:
                //    DropedItems.Remove(role as DropedItem.DropedItemRole);
                //    break;
//                     case CSCommon.Component.eActorGameType.GatherItem:
//                         GatherItems.Remove(role as Gather.GatherItem);
//                         break;
                default:
                    break;
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// 得到仇恨列表里仇恨值最大的可攻击对象
        /// </summary>
        public ulong GetFirstEnmityCanHit()
        {
            RoleActor target = GetTarget(mMaxEnmityObjID);

            if (null != target && target.CanBeAttacked())
            {
                return(mMaxEnmityObjID);
            }

            int tmp = 0;

            target = null;
            for (var i = 0; i < mEnmityList.Count(); i++)
            {
                EnmityInfo ite = mEnmityList[i];
                if (ite.mEnmityValue > tmp)
                {
                    RoleActor r = GetTarget(ite.playerID);
                    if (null != r && r.CanBeAttacked())
                    {
                        target = r;
                    }
                }
            }
            if (null == target)
            {
                return(0);
            }

            return(target.Id);
        }
Exemple #10
0
        /// <summary>
        /// 实际选择目标
        /// </summary>
        public override bool SelectTarget(RoleActor caster, SkillActive skill, ref List <RoleActor> targets)
        {
            if (!base.SelectTarget(caster, skill, ref targets))
            {
                return(false);
            }

            List <RoleActor> roleList   = new List <RoleActor>();
            UInt32           actorTypes = (1 << (Int32)eActorGameType.Player) | (1 << (Int32)eActorGameType.Npc) | (1 << (Int32)eActorGameType.PlayerImage);
            var pos = caster.GetPosition();

            if (!caster.HostMap.TourRoles(ref pos, skill.RangeMax, actorTypes, roleList))
            {
                return(false);
            }

            foreach (var tar in roleList)
            {
                Vector3 dir      = Util.DirToVector(caster.GetDirection());
                Vector3 toTarDir = tar.GetPosition() - caster.GetPosition();
                float   angle    = Util.Angle(dir, toTarDir);
                if (Math.Abs(angle) <= 90 &&
                    Math.Abs(tar.GetPosition().X - caster.GetPosition().X) <= skill.SkillData.selparam1 / 2 &&
                    Math.Abs(tar.GetPosition().Z - caster.GetPosition().Z) <= skill.SkillData.selparam2)
                {
                    targets.Add(tar);
                }
            }

            return(true);
        }
Exemple #11
0
 public bool FollowTarget(RoleActor player) //追击
 {
     if (null == mLogic)
     {
         return(false);
     }
     return(mLogic.FollowTarget(this, player));
 }
Exemple #12
0
        /// <summary>
        /// 检查技能条件
        /// </summary>
        public virtual bool CheckSkillCondition(RoleActor actor, SkillActive skill)
        {
            if (null == actor || null == skill)
            {
                return(false);
            }

            return(true);
        }
Exemple #13
0
        /// <summary>
        /// 技能预先选择目标(玩家点击目标)
        /// </summary>
        public virtual bool PreSelectTarget(RoleActor actor, SkillActive skill, RoleActor target)
        {
            if (null == actor || null == skill)
            {
                return(false);
            }

            return(true);
        }
        public virtual bool SkillConsume(RoleActor actor, SkillActive skill)
        {
            if (null == actor || null == skill)
            {
                return(false);
            }

            return(true);
        }
Exemple #15
0
        /// <summary>
        /// 结束回调
        /// </summary>
        public virtual bool OnEnd(RoleActor target, SkillActive skill)
        {
            if (null == target || null == skill)
            {
                return(false);
            }

            return(true);
        }
Exemple #16
0
        public void DestroyFromDB(RoleActor role)
        {
            sbyte destroy = 1;

            //以后这里要根据物品重要程度决定是否真实从数据库删除
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            ServerCommon.H_RPCRoot.smInstance.HGet_DataServer(pkg).DelItem(pkg, role.Id, ItemData.ItemId, destroy);
            pkg.DoCommand(IPlanesServer.Instance.DataConnect, RPC.CommandTargetType.DefaultType);
        }
        /// <summary>
        /// 实际选择目标
        /// </summary>
        public virtual bool SelectTarget(RoleActor caster, SkillActive skill, ref List <RoleActor> targets)
        {
            if (null == caster || null == skill)
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// 检查目标是否有效
        /// </summary>
        public virtual bool TargetFilter(RoleActor caster, SkillActive skill, RoleActor target, eRelationType relation)
        {
            if (null == caster || null == skill || null == target)
            {
                return(false);
            }

            return(true);
        }
Exemple #19
0
        /// <summary>
        /// 结束回调
        /// </summary>
        public override bool OnEnd(RoleActor target, SkillActive skill)
        {
            if (!base.OnEnd(target, skill))
            {
                return(false);
            }

            return(true);
        }
Exemple #20
0
        /// <summary>
        /// 检查目标是否有效
        /// </summary>
        public override bool TargetFilter(RoleActor caster, SkillActive skill, RoleActor target, eRelationType relation)
        {
            if (!base.TargetFilter(caster, skill, target, relation))
            {
                return(false);
            }

            return(true);
        }
Exemple #21
0
        public override bool SelectTarget(NPCInstance npc)
        {
            if (!base.SelectTarget(npc))
            {
                return(false);
            }

            RoleActor target = npc.GetTarget(npc.mAttackTarget);

            return(npc.FollowTarget(target));
        }
Exemple #22
0
 /// <summary>
 /// 初始化攻击对象
 /// </summary>
 public void Init(SkillActive skill, RoleActor target)
 {
     mSkill    = skill;
     mTarget   = target;
     mOwner    = skill.Owner;
     mKilled   = false;
     mHitType  = eHitType.Hit;
     mDamageHP = 0;
     mDamageMP = 0;
     mHatred   = 0;
 }
 public override eMapAttackRule CanAttack(RoleActor atk, RoleActor def)
 {
     if (atk.Camp == def.Camp)
     {
         return(eMapAttackRule.AtkNO);
     }
     else
     {
         return(eMapAttackRule.AtkOK);
     }
 }
Exemple #24
0
        /// <summary>
        /// 技能预先选择目标(玩家点击目标)
        /// </summary>
        public override bool PreSelectTarget(RoleActor actor, SkillActive skill, RoleActor target)
        {
            if (!base.PreSelectTarget(actor, skill, target))
            {
                return(false);
            }

            skill.mTargetId = actor.Id;

            return(true);
        }
Exemple #25
0
        int mTourRolesCount;    //计算最大广播人数
        public void SendPkg2Clients(RoleActor ignore, SlimDX.Vector3 pos, RPC.PackageWriter pkg)
        {
            //这个range是以pos为中心广播多大范围内的玩家
            UInt32 actorTypes = (1 << (Int32)eActorGameType.Player);
            var    arg        = new PkgSender();

            arg.Pkg         = pkg;
            arg.IgnoreRole  = ignore;
            mTourRolesCount = 0;
            TourRoles(ref pos, RPC.RPCNetworkMgr.Sync2ClientRange, actorTypes, this.OnVisitRole_SendPkg2Client, arg);
        }
Exemple #26
0
 public void InitBag(RoleActor role, UInt16 size, List <CSCommon.Data.ItemData> items)
 {
     mHostRole = role;
     mBagSize  = size;
     mItems    = new Item[mBagSize];
     foreach (var i in items)
     {
         var    item  = Item.DangerousCreateItem(role, i, false);
         UInt16 index = item.Position;
         this[index] = item;
     }
 }
Exemple #27
0
 public override void OnKillActor(RoleActor actor)
 {
     base.OnKillActor(actor);
     if (actor is NPCInstance)
     {
         var npc = actor as NPCInstance;
         GainExp(npc.AttriData.exp);
         _ChangeMoney(eCurrenceType.Gold, CSCommon.Data.eMoneyChangeType.KillMonster, 10);
         //TaskManager.mCurTask.KillMonster(npc.NPCData.TemplateId, 1);
         //CheckCopy(npc.NPCData.TemplateId.ToString());
         //mRecordMgr.CheckAchieve(eAchieveType.KillMonster, npc.NPCData.TemplateId.ToString());
     }
 }
Exemple #28
0
 public void InitBag(RoleActor owner, List <SkillData> skills)
 {
     mOwner = owner;
     this.clear();
     foreach (var i in skills)
     {
         if (false == CreateSkillToBag(i.TemplateId, i.Level))
         {
             Log.Log.Login.Print("InitBag skill error, owner{0}skillid{1}", owner.Id, i.TemplateId);
             continue;
         }
     }
 }
Exemple #29
0
        bool OnTellClientPlayer(RoleActor role, object arg)
        {
            var list = arg as List <RoleActor>;

            if (list.Count >= RPC.RPCNetworkMgr.Sync2ClientPlayersCountWhenEnterMap)
            {
                return(false);
            }

            list.Add(role);

            return(true);
        }
Exemple #30
0
        public override bool CanAttack(RoleActor target)
        {
            if (!base.CanAttack(target))
            {
                return(false);
            }

            if (HostMap.CanAttack(this, target) == eMapAttackRule.AtkOK)
            {
                return(true);
            }

            if (NPCData.Template.type == (byte)eNpcType.Npc)
            {
                return(false);
            }

            if (target is NPCInstance)
            {
                var npc = target as NPCInstance;
                if (npc.NPCData.Template.type == (byte)eNpcType.Npc)
                {
                    return(false);
                }

                if (target.Camp == eCamp.None)
                {
                    return(false);
                }
            }
            else if (target is PlayerInstance)
            {
                if (target.Camp != this.Camp)
                {
                    return(true);
                }

                if (this.Camp == eCamp.None)
                {
                    return(true);
                }
            }

            if (target.Camp == this.Camp)
            {
                return(false);
            }


            return(true);
        }