public virtual bool TestGameObject(LogicGameObject gameObject)
        {
            if (this.m_gameObjectTypes != null && !this.m_gameObjectTypes[(int)gameObject.GetGameObjectType()])
            {
                return(false);
            }
            if (this.m_ignoreGameObjects != null && this.m_ignoreGameObjects.IndexOf(gameObject) != -1)
            {
                return(false);
            }

            if (this.m_team != -1)
            {
                LogicHitpointComponent hitpointComponent = gameObject.GetHitpointComponent();

                if (hitpointComponent != null)
                {
                    if (hitpointComponent.GetHitpoints() > 0)
                    {
                        bool isEnemy = hitpointComponent.IsEnemyForTeam(this.m_team);

                        if (isEnemy || !this.m_enemyOnly)
                        {
                            return(this.m_enemyOnly || !isEnemy);
                        }
                    }

                    return(false);
                }
            }

            return(true);
        }
Beispiel #2
0
        public void UpdateTargetDamage(LogicGameObject target, int damage)
        {
            if (target != null && !this.m_dummy && target.GetHitpointComponent() != null)
            {
                int totalDamage = damage;

                if (LogicCombatComponent.IsPreferredTarget(this.m_preferredTarget, target))
                {
                    totalDamage = damage * this.m_preferredTargetDamageMod / 100;
                }

                if (totalDamage >= 0 || target.GetData().GetDataType() == LogicDataType.HERO &&
                    (totalDamage = totalDamage * LogicDataTables.GetGlobals().GetHeroHealMultiplier() / 100) > 0 || !target.IsPreventsHealing())
                {
                    if (this.m_damageRadius <= 0)
                    {
                        target.GetHitpointComponent().CauseDamage(totalDamage, this.m_groupsId, this.m_groups);
                    }
                    else
                    {
                        this.m_level.AreaDamage(this.m_groupsId, target.GetMidX(), target.GetMidY(), this.m_damageRadius, damage, this.m_preferredTarget,
                                                this.m_preferredTargetDamageMod, this.m_hitEffect, this.m_myTeam, this.m_unk160, this.m_flyingTarget ? 0 : 1, 0, this.m_pushBack,
                                                this.m_gravity, false, 100, 0, this.m_groups, 100, 0);
                    }
                }

                int slowdownDefensePercent = this.GetProjectileData().GetSlowdownDefensePercent();

                if (slowdownDefensePercent > 0 && target.GetGameObjectType() == LogicGameObjectType.BUILDING)
                {
                    LogicCombatComponent combatComponent = target.GetCombatComponent();

                    if (combatComponent != null)
                    {
                        combatComponent.Boost(100, -slowdownDefensePercent, 120);
                    }
                }
            }
        }
        public void PassEnemyOnly(LogicGameObject gameObject)
        {
            LogicHitpointComponent hitpointComponent = gameObject.GetHitpointComponent();

            if (hitpointComponent != null)
            {
                this.m_team      = hitpointComponent.GetTeam();
                this.m_enemyOnly = true;
            }
            else
            {
                this.m_team = -1;
            }
        }
Beispiel #4
0
        public void UpdatePenetrating(int damageMultiplier)
        {
            LogicVector2 pos1 = new LogicVector2((this.m_targetPosition.m_x >> 3) - this.m_unk248.m_x, (this.m_targetPosition.m_y >> 3) - this.m_unk248.m_y);

            pos1.Normalize(512);

            LogicVector2 pos2 = new LogicVector2(-pos1.m_y, pos1.m_x);

            int distance = ((200 - this.m_areaShieldDelay) * (8 * this.GetSpeed() - 8 * this.m_areaShieldSpeed) / 200 + 8 * this.m_areaShieldSpeed) >> 3;

            LogicArrayList <LogicComponent> components = this.GetComponentManager().GetComponents(LogicComponentType.MOVEMENT);

            for (int i = 0, damage = damageMultiplier * this.m_damage / 100; i < components.Size(); i++)
            {
                LogicMovementComponent component         = (LogicMovementComponent)components[i];
                LogicGameObject        parent            = component.GetParent();
                LogicHitpointComponent hitpointComponent = parent.GetHitpointComponent();

                if (!parent.IsHidden() && hitpointComponent.GetTeam() != this.m_myTeam && hitpointComponent.GetHitpoints() > 0)
                {
                    int distanceX = parent.GetMidX() - this.GetMidX();
                    int distanceY = parent.GetMidY() - this.GetMidY();

                    if (parent.GetGameObjectType() == LogicGameObjectType.CHARACTER)
                    {
                        distanceX += parent.GetWidthInTiles() << 8;
                        distanceY += parent.GetHeightInTiles() << 8;
                    }

                    if ((!component.IsFlying() || this.m_flyingTarget) &&
                        LogicMath.Abs(distanceX) <= this.m_penetratingRadius &&
                        LogicMath.Abs(distanceY) <= this.m_penetratingRadius &&
                        distanceX * distanceX + distanceY * distanceY <= (uint)(this.m_penetratingRadius * this.m_penetratingRadius))
                    {
                        LogicVector2 position = new LogicVector2();

                        if (parent.GetGameObjectType() == LogicGameObjectType.CHARACTER && hitpointComponent.GetMaxHitpoints() <= damage)
                        {
                            int rnd = (byte)this.Rand(parent.GetGlobalID());

                            if (rnd > 170u)
                            {
                                position.Set((pos1.m_x >> 2) + pos2.m_x, (pos1.m_y >> 2) + pos2.m_y);
                            }
                            else
                            {
                                if (rnd > 85)
                                {
                                    position.Set(pos1.m_x, pos1.m_y);
                                }
                                else
                                {
                                    position.Set((pos1.m_x >> 2) - pos2.m_x, (pos1.m_y >> 2) - pos2.m_y);
                                }
                            }

                            if (hitpointComponent.GetInvulnerabilityTime() <= 0)
                            {
                                ((LogicCharacter)parent).Eject(position);
                            }

                            position.Destruct();
                        }
                        else
                        {
                            position.Set(pos1.m_x, pos1.m_y);
                            position.Normalize(distance);

                            if (parent.GetMovementComponent().GetMovementSystem().ManualPushTrap(position, 150, this.m_globalId) || parent.IsHero())
                            {
                                this.UpdateTargetDamage(parent, damage);
                            }
                        }
                    }
                }
            }

            pos1.Destruct();
            pos2.Destruct();
        }
Beispiel #5
0
        public void UpdateShockwavePush(int team, int targetType)
        {
            LogicVector2 position = new LogicVector2(this.GetMidX() - this.m_unk248.m_x, this.GetMidY() - this.m_unk248.m_y);
            int          length   = position.GetLength();

            if (length >= this.m_minAttackRange)
            {
                int maxRangeDistance = length - this.m_maxAttackRange;
                int maxRadius        = length;
                int minRadius        = length - 512;

                if (minRadius < this.m_minAttackRange)
                {
                    minRadius = this.m_minAttackRange;
                }

                uint minRadiusSquared = (uint)(minRadius * minRadius);
                uint maxRadiusSquared = (uint)(maxRadius * maxRadius);

                int boostSpeed         = this.m_speedMod * maxRangeDistance / this.m_maxAttackRange;
                int boostTime          = this.m_statusEffectTime * maxRangeDistance / (16 * this.m_maxAttackRange);
                int shockwaveArcLength = this.GetShockwaveArcLength();

                LogicArrayList <LogicComponent> components = this.GetComponentManager().GetComponents(LogicComponentType.MOVEMENT);
                LogicVector2 pushBackPosition = new LogicVector2();

                for (int i = 0; i < components.Size(); i++)
                {
                    LogicMovementComponent movementComponent = (LogicMovementComponent)components[i];
                    LogicGameObject        parent            = movementComponent.GetParent();
                    LogicHitpointComponent hitpointComponent = parent.GetHitpointComponent();

                    if (!parent.IsHidden())
                    {
                        if (hitpointComponent == null || hitpointComponent.GetTeam() != team)
                        {
                            if (hitpointComponent != null && hitpointComponent.GetParent().IsFlying())
                            {
                                if (targetType == 1)
                                {
                                    continue;
                                }
                            }
                            else if (targetType == 0)
                            {
                                continue;
                            }

                            int distanceX = parent.GetMidX() - this.m_unk248.m_x;
                            int distanceY = parent.GetMidY() - this.m_unk248.m_y;

                            if (LogicMath.Abs(distanceX) <= maxRadius &&
                                LogicMath.Abs(distanceY) <= maxRadius)
                            {
                                int distance = distanceX * distanceX + distanceY * distanceY;

                                if (distance <= maxRadiusSquared && distance >= minRadiusSquared)
                                {
                                    if ((distanceX | distanceY) == 0)
                                    {
                                        distanceX = 1;
                                    }

                                    pushBackPosition.Set(distanceX, distanceY);

                                    int pushBackLength = pushBackPosition.Normalize(512);
                                    int angle          =
                                        LogicMath.Abs(LogicMath.NormalizeAngle180(LogicMath.NormalizeAngle180(pushBackPosition.GetAngle()) -
                                                                                  LogicMath.NormalizeAngle180(this.m_shockwaveAngle)));

                                    if (angle < shockwaveArcLength / 2)
                                    {
                                        int pushBack = 100 * (this.m_maxAttackRange + 256 - pushBackLength) / 512;

                                        if (pushBack > this.m_shockwavePushStrength)
                                        {
                                            pushBack = this.m_shockwavePushStrength;
                                        }

                                        movementComponent.GetMovementSystem().ManualPushBack(pushBackPosition, pushBack, 750, this.m_globalId);

                                        if (boostSpeed != 0)
                                        {
                                            movementComponent.GetMovementSystem().Boost(boostSpeed, boostTime);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }