SetAttackerInfo() public method

public SetAttackerInfo ( int attackId, bool isKiller, bool isNormalAttack, bool isCritical, int hpDamage, int npDamage ) : void
attackId int
isKiller bool
isNormalAttack bool
isCritical bool
hpDamage int
npDamage int
return void
Beispiel #1
0
        internal void ImpactDamage(int srcObjId, int targetId, int impactId, int seq)
        {
            EntityInfo targetObj = m_Scene.EntityManager.GetEntityInfo(targetId);
            EntityInfo srcObj    = m_Scene.EntityManager.GetEntityInfo(srcObjId);

            if (null != targetObj && !targetObj.IsDead())
            {
                ImpactInfo impactInfo = targetObj.GetSkillStateInfo().GetImpactInfoBySeq(seq);
                if (null != impactInfo && impactId == impactInfo.ImpactId)
                {
                    TableConfig.Skill cfg = impactInfo.ConfigData;
                    int   targetType      = impactInfo.TargetType;
                    float damage          = impactInfo.DamageData.Damage;
                    int   addShield       = impactInfo.DamageData.AddShield;
                    int   hpRecover       = impactInfo.DamageData.HpRecover;

                    if (hpRecover != 0)
                    {
                        targetObj.SetHp(Operate_Type.OT_Relative, (int)impactInfo.DamageData.HpRecover);
                        targetObj.SetAttackerInfo(srcObjId, false, true, false, -impactInfo.DamageData.HpRecover, 0);
                    }
                    if (addShield != 0)
                    {
                        targetObj.SetShield(Operate_Type.OT_Relative, impactInfo.DamageData.AddShield);
                    }
                    if ((targetType == (int)SkillTargetType.Enemy || targetType == (int)SkillTargetType.RandEnemy) && damage != 0)
                    {
                        if (targetObj.EntityType == (int)EntityTypeEnum.Tower)
                        {
                            if (null != srcObj && srcObj.NormalSkillId != impactInfo.SkillId)
                            {
                                //技能打塔不产生伤害
                                return;
                            }
                        }
                        bool isKiller = false;
                        if (targetObj.Shield >= damage)
                        {
                            targetObj.SetShield(Operate_Type.OT_Relative, -(int)damage);
                        }
                        else if (targetObj.Shield > 0)
                        {
                            int leftDamage = (int)damage - targetObj.Shield;
                            targetObj.SetShield(Operate_Type.OT_Absolute, 0);
                            targetObj.SetHp(Operate_Type.OT_Relative, -(int)leftDamage);
                            if (targetObj.Hp <= 0)
                            {
                                isKiller = true;
                            }
                        }
                        else
                        {
                            targetObj.SetHp(Operate_Type.OT_Relative, -(int)damage);
                            if (targetObj.Hp <= 0)
                            {
                                isKiller = true;
                            }
                        }
                        if (isKiller)
                        {
                            targetObj.GetCombatStatisticInfo().AddDeadCount(1);
                            if (null != srcObj)
                            {
                                EntityInfo killer = srcObj;
                                if (killer.SummonerId > 0)
                                {
                                    killer = m_Scene.EntityManager.GetEntityInfo(killer.SummonerId);
                                }
                                if (targetObj.EntityType == (int)EntityTypeEnum.Tower)
                                {
                                    killer.GetCombatStatisticInfo().AddKillTowerCount(1);
                                }
                                else if (targetObj.EntityType == (int)EntityTypeEnum.Hero)
                                {
                                    killer.GetCombatStatisticInfo().AddKillHeroCount(1);
                                    killer.GetCombatStatisticInfo().AddMultiKillCount(1);
                                }
                                else
                                {
                                    killer.GetCombatStatisticInfo().AddKillNpcCount(1);
                                }
                            }
                        }
                        targetObj.SetAttackerInfo(srcObjId, isKiller, true, false, (int)damage, 0);
                    }
                }
            }
        }
Beispiel #2
0
        public void ImpactDamage(int srcObjId, int targetId, int impactId, int seq, bool isFinal)
        {
            if (!PluginFramework.Instance.IsBattleScene)
            {
                return;
            }
            EntityViewModel view    = GetEntityViewById(targetId);
            EntityViewModel srcView = GetEntityViewById(srcObjId);

            if (null != view && null != view.Entity && null != view.Actor)
            {
                EntityInfo targetObj = view.Entity;
                EntityInfo srcObj    = null;
                if (null != srcView && null != srcView.Entity)
                {
                    srcObj = srcView.Entity;
                }
                if (null != targetObj && !view.Entity.IsDeadSkillCasting())
                {
                    ImpactInfo impactInfo = targetObj.GetSkillStateInfo().GetImpactInfoBySeq(seq);
                    if (null != impactInfo && impactId == impactInfo.ImpactId)
                    {
                        EntityInfo ownerObj = GetRootSummoner(srcObj);
                        int        ownerId  = 0;
                        if (null != ownerObj)
                        {
                            ownerId = ownerObj.GetId();
                        }
                        int addsc = impactInfo.DamageData.AddSc;
                        int adduc = impactInfo.DamageData.AddUc;

                        int index = impactInfo.CurDamageCount;
                        ++impactInfo.CurDamageCount;
                        int  multiple  = impactInfo.DamageData.GetMultiple(index);
                        int  damage    = impactInfo.DamageData.GetDamage(index);
                        long hitrate   = 0;
                        long critrate  = 0;
                        long blockrate = 0;
                        long phyDamage = 0;
                        long magDamage = 0;

                        hitrate   = AttrCalculator.Calc(targetObj.SceneContext, impactInfo.SenderProperty, targetObj.ActualProperty, "hitrate");
                        critrate  = AttrCalculator.Calc(targetObj.SceneContext, impactInfo.SenderProperty, targetObj.ActualProperty, "critrate");
                        blockrate = AttrCalculator.Calc(targetObj.SceneContext, impactInfo.SenderProperty, targetObj.ActualProperty, "blockrate");
                        long rnd        = Helper.Random.Next();
                        long critonoff  = 0;
                        long blockonoff = 0;
                        if (rnd <= critrate)
                        {
                            critonoff = 1;
                        }
                        else if (rnd > critrate && rnd <= critrate + blockrate)
                        {
                            blockonoff = 1;
                        }
                        impactInfo.DamageData.IsCritical = critonoff > 0;
                        impactInfo.DamageData.IsBlock    = blockonoff > 0;
                        phyDamage = AttrCalculator.Calc(targetObj.SceneContext, impactInfo.SenderProperty, targetObj.ActualProperty, "phydamage", multiple, damage, critonoff, blockonoff);
                        magDamage = AttrCalculator.Calc(targetObj.SceneContext, impactInfo.SenderProperty, targetObj.ActualProperty, "magdamage", multiple, damage, critonoff, blockonoff);

                        damage = (int)(phyDamage + magDamage);
                        if (damage < 0)
                        {
                            damage = 0;
                        }
                        int  vampire  = impactInfo.DamageData.GetVampire(index);
                        bool isKiller = false;
                        if (targetObj.Shield >= damage)
                        {
                            targetObj.Shield -= (int)damage;
                        }
                        else if (targetObj.Shield > 0)
                        {
                            int leftDamage = (int)damage - targetObj.Shield;
                            targetObj.Shield = 0;
                            if (targetObj.GetId() == PluginFramework.Instance.LeaderID && targetObj.Hp <= leftDamage)
                            {
                                //队长不死,demo专用代码
                            }
                            else
                            {
                                targetObj.Hp -= (int)leftDamage;
                                if (targetObj.Hp <= 0)
                                {
                                    isKiller = true;
                                }
                            }
                        }
                        else
                        {
                            if (targetObj.GetId() == PluginFramework.Instance.LeaderID && targetObj.Hp <= damage)
                            {
                                //队长不死,demo专用代码
                            }
                            else
                            {
                                targetObj.Hp -= (int)damage;
                                if (targetObj.Hp <= 0)
                                {
                                    isKiller = true;
                                }
                            }
                        }
                        if (isKiller)
                        {
                            targetObj.GetCombatStatisticInfo().AddDeadCount(1);
                            if (null != srcObj)
                            {
                                EntityInfo killer = srcObj;
                                if (killer.SummonerId > 0)
                                {
                                    EntityViewModel npcViewModel = GetEntityViewById(killer.SummonerId);
                                    if (null != npcViewModel)
                                    {
                                        killer = npcViewModel.Entity;
                                    }
                                }
                                if (targetObj.EntityType == (int)EntityTypeEnum.Tower)
                                {
                                    killer.GetCombatStatisticInfo().AddKillTowerCount(1);
                                }
                                else if (targetObj.EntityType == (int)EntityTypeEnum.Hero)
                                {
                                    killer.GetCombatStatisticInfo().AddKillHeroCount(1);
                                    killer.GetCombatStatisticInfo().AddMultiKillCount(1);
                                }
                                else
                                {
                                    killer.GetCombatStatisticInfo().AddKillNpcCount(1);
                                }
                            }
                        }
                        targetObj.SetAttackerInfo(srcObjId, isKiller, true, false, (int)damage, 0);
                    }
                }
            }
        }
Beispiel #3
0
        internal void ImpactDamage(int srcObjId, int targetId, int impactId, int seq, bool isFinal)
        {
            if (ClientModule.Instance.IsRoomScene)
            {
                return;
            }
            EntityViewModel view    = GetEntityViewById(targetId);
            EntityViewModel srcView = GetEntityViewById(srcObjId);

            if (null != view && null != view.Entity && null != view.Actor)
            {
                EntityInfo entity = view.Entity;
                EntityInfo srcNpc = null;
                if (null != srcView && null != srcView.Entity)
                {
                    srcNpc = srcView.Entity;
                }
                ImpactInfo impactInfo = entity.GetSkillStateInfo().GetImpactInfoBySeq(seq);
                if (null != impactInfo && impactId == impactInfo.ImpactId)
                {
                    TableConfig.Skill cfg = impactInfo.ConfigData;
                    int   targetType      = impactInfo.TargetType;
                    float damage          = impactInfo.DamageData.Damage;
                    int   addShield       = impactInfo.DamageData.AddShield;
                    int   hpRecover       = impactInfo.DamageData.HpRecover;

                    if (hpRecover != 0)
                    {
                        entity.SetHp(Operate_Type.OT_Relative, (int)impactInfo.DamageData.HpRecover);
                        entity.SetAttackerInfo(srcObjId, false, true, false, -impactInfo.DamageData.HpRecover, 0);
                    }
                    if (addShield != 0)
                    {
                        entity.SetShield(Operate_Type.OT_Relative, impactInfo.DamageData.AddShield);
                    }
                    if ((targetType == (int)SkillTargetType.Enemy || targetType == (int)SkillTargetType.RandEnemy) && damage != 0)
                    {
                        if (entity.EntityType == (int)EntityTypeEnum.Tower)
                        {
                            if (null != srcNpc && srcNpc.NormalSkillId != impactInfo.SkillId)
                            {
                                //技能打塔不产生伤害
                                return;
                            }
                        }
                        bool isKiller = false;
                        if (entity.Shield >= damage)
                        {
                            entity.SetShield(Operate_Type.OT_Relative, -(int)damage);
                        }
                        else if (entity.Shield > 0)
                        {
                            int leftDamage = (int)damage - entity.Shield;
                            entity.SetShield(Operate_Type.OT_Absolute, 0);
                            if (entity.GetId() == ClientModule.Instance.LeaderID && entity.Hp <= leftDamage)
                            {
                                //队长不死,demo专用代码
                            }
                            else
                            {
                                entity.SetHp(Operate_Type.OT_Relative, -(int)leftDamage);
                                if (entity.Hp <= 0)
                                {
                                    isKiller = true;
                                }
                            }
                        }
                        else
                        {
                            if (entity.GetId() == ClientModule.Instance.LeaderID && entity.Hp <= damage)
                            {
                                //队长不死,demo专用代码
                            }
                            else
                            {
                                entity.SetHp(Operate_Type.OT_Relative, -(int)damage);
                                if (entity.Hp <= 0)
                                {
                                    isKiller = true;
                                }
                            }
                        }
                        if (isKiller)
                        {
                            entity.GetCombatStatisticInfo().AddDeadCount(1);
                            if (null != srcNpc)
                            {
                                EntityInfo killer = srcNpc;
                                if (killer.SummonerId > 0)
                                {
                                    EntityViewModel npcViewModel = GetEntityViewById(killer.SummonerId);
                                    if (null != npcViewModel)
                                    {
                                        killer = npcViewModel.Entity;
                                    }
                                }
                                if (entity.EntityType == (int)EntityTypeEnum.Tower)
                                {
                                    killer.GetCombatStatisticInfo().AddKillTowerCount(1);
                                }
                                else if (entity.EntityType == (int)EntityTypeEnum.Hero)
                                {
                                    killer.GetCombatStatisticInfo().AddKillHeroCount(1);
                                    killer.GetCombatStatisticInfo().AddMultiKillCount(1);
                                }
                                else
                                {
                                    killer.GetCombatStatisticInfo().AddKillNpcCount(1);
                                }
                            }
                        }
                        entity.SetAttackerInfo(srcObjId, isKiller, true, false, (int)damage, 0);
                    }
                }
            }
        }