Exemple #1
0
    internal static void Execute(object msg, NetConnection conn)
    {
        Msg_RC_ImpactDamage damage_msg = msg as Msg_RC_ImpactDamage;

        if (null != damage_msg)
        {
            EntityInfo entity = PluginFramework.Instance.SceneContext.GetEntityById(damage_msg.role_id);
            if (null != entity)
            {
                int hpDamage     = entity.Hp - damage_msg.hp;
                int energyDamage = entity.Energy - damage_msg.energy;
                entity.Hp -= damage_msg.hp;
                //LogSystem.Info("---set {2} hp to {0}/{1}", entity.Hp, entity.ActualProperty.HpMax, entity.GetId());
                bool isKiller   = false;
                bool isOrdinary = false;
                bool isCritical = false;
                if ((damage_msg.damage_status & (int)Msg_RC_ImpactDamage.Flag.IS_KILLER) != 0)
                {
                    isKiller = true;
                }
                if ((damage_msg.damage_status & (int)Msg_RC_ImpactDamage.Flag.IS_CRITICAL) != 0)
                {
                    isCritical = true;
                }
                if ((damage_msg.damage_status & (int)Msg_RC_ImpactDamage.Flag.IS_ORDINARY) != 0)
                {
                    isOrdinary = true;
                }
                entity.SetAttackerInfo(damage_msg.attacker_id, isKiller, isOrdinary, isCritical, hpDamage, energyDamage);
            }
        }
    }
        private void OnHitRecover(CharacterInfo entity, string attribute, int value)
        {
            LogSys.Log(LOG_TYPE.DEBUG, "---hi recover " + attribute + ":" + value);
            Msg_RC_ImpactDamage bd = new Msg_RC_ImpactDamage();

            bd.role_id     = entity.GetId();
            bd.attacker_id = entity.GetId();
            bd.is_killer   = false;
            bd.is_critical = false;
            bd.is_ordinary = false;
            bd.hp          = 0;
            bd.energy      = 0;
            if (attribute == "HP")
            {
                bd.hp = value;
                entity.SetAttackerInfo(entity.GetId(), 0, false, false, false, value, 0);
            }
            else
            {
                bd.energy = value;
                entity.SetAttackerInfo(entity.GetId(), 0, false, false, false, 0, value);
            }
            for (LinkedListNode <UserInfo> linkNode = entity.UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                UserInfo info = linkNode.Value;
                if (null != info && null != info.CustomData)
                {
                    User u = info.CustomData as User;
                    if (null != u)
                    {
                        u.SendMessage(bd);
                    }
                }
            }
        }
Exemple #3
0
        private void OnDamage(int receiver, int caster, bool isNormalDamage, bool isCritical, int hpDamage, int npDamage)
        {
            if (null != m_Scene && null != m_EntityMgr)
            {
                EntityInfo          npc    = m_EntityMgr.GetEntityInfo(receiver);
                int                 hp     = npc.Hp;
                int                 energy = npc.Energy;
                Msg_RC_ImpactDamage msg    = new Msg_RC_ImpactDamage();
                msg.role_id       = receiver;
                msg.attacker_id   = caster;
                msg.damage_status = 0;
                if (isNormalDamage)
                {
                    msg.damage_status |= (int)Msg_RC_ImpactDamage.Flag.IS_ORDINARY;
                }
                if (isCritical)
                {
                    msg.damage_status |= (int)Msg_RC_ImpactDamage.Flag.IS_CRITICAL;
                }
                if (hp <= 0)
                {
                    msg.damage_status |= (int)Msg_RC_ImpactDamage.Flag.IS_KILLER;
                }
                msg.hp     = hp;
                msg.energy = energy;

                m_Scene.NotifyAllUser(RoomMessageDefine.Msg_RC_ImpactDamage, msg);
            }
        }
Exemple #4
0
    internal static void Execute(object msg, NetConnection conn, NetworkSystem networkSystem)
    {
        Msg_RC_ImpactDamage damage_msg = msg as Msg_RC_ImpactDamage;

        if (null != damage_msg)
        {
        }
    }
        private void OnImpactDamage(CharacterInfo entity, int attackerId, int damage, bool isKiller, bool isCritical, bool isOrdinary)
        {
            if (null != entity)
            {
                Msg_RC_ImpactDamage bd = new Msg_RC_ImpactDamage();
                bd.role_id     = entity.GetId();
                bd.attacker_id = attackerId;
                bd.is_killer   = isKiller;
                bd.is_critical = isCritical;
                bd.is_ordinary = isOrdinary;
                bd.hp          = damage;

                Scene scene = entity.SceneContext.CustomData as Scene;
                if (null != scene)
                {
                    if (entity.IsHaveStoryFlag(StoryListenFlagEnum.Damage))
                    {
                        scene.StorySystem.SendMessage("objdamage", entity.GetId(), attackerId, damage, 0, isCritical ? 1 : 0);
                        NpcInfo npc = entity as NpcInfo;
                        if (null != npc)
                        {
                            scene.StorySystem.SendMessage("npcdamage:" + npc.GetUnitId(), entity.GetId(), attackerId, damage, 0, isCritical ? 1 : 0);
                        }
                    }

                    int estimateDamage = damage;
                    if (isCritical)
                    {
                        estimateDamage /= 2;
                    }
                    if (entity.Hp + estimateDamage <= 0)
                    {
                        scene.TryFireFinalBlow(entity);
                    }
                }

                for (LinkedListNode <UserInfo> linkNode = entity.UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
                {
                    UserInfo info = linkNode.Value;
                    if (null != info && null != info.CustomData)
                    {
                        User u = info.CustomData as User;
                        if (null != u)
                        {
                            u.SendMessage(bd);
                        }
                    }
                }
                entity.SetAttackerInfo(attackerId, 0, isKiller, isOrdinary, isCritical, damage, 0);
            }
        }