public static bool FindPoint(LogicTileMap tileMap, LogicVector2 pos1, LogicVector2 pos2, LogicVector2 pos3, LogicVector2 pos4)
        {
            pos1.Set(pos2.m_x, pos2.m_y);
            pos1.Substract(pos3);

            int length = pos1.GetLength();

            pos1.m_x = (pos1.m_x << 7) / length;
            pos1.m_y = (pos1.m_y << 7) / length;

            pos4.Set(pos3.m_x, pos3.m_y);

            int radius = LogicMath.Clamp(length / 128, 10, 25);

            for (int i = 0; i < radius; i++)
            {
                if (tileMap.IsPassablePathFinder(pos4.m_x >> 8, pos4.m_y >> 8))
                {
                    pos4.m_x = (int)((pos4.m_x & 0xFFFFFF00) | 128);
                    pos4.m_y = (int)((pos4.m_y & 0xFFFFFF00) | 128);

                    return(true);
                }

                pos4.Add(pos1);
            }

            return(false);
        }
Пример #2
0
        public int GetSpeed()
        {
            LogicProjectileData projectileData = this.GetProjectileData();

            if (projectileData.GetFixedTravelTime() != 0)
            {
                LogicVector2 position = new LogicVector2();

                position.m_x = (this.m_targetPosition.m_x - this.m_unk276.m_x) >> 3;
                position.m_y = (this.m_targetPosition.m_y - this.m_unk276.m_y) >> 3;

                int remMS = projectileData.GetFixedTravelTime() - this.m_travelTime;
                int speed = position.GetLength();

                if (remMS <= 0)
                {
                    remMS = 1000;
                    speed = projectileData.GetSpeed();
                }

                return(16 * speed / remMS);
            }

            return((int)(16L * projectileData.GetSpeed() / 1000L));
        }
Пример #3
0
        public int GetShockwaveArcLength()
        {
            LogicVector2 pos = new LogicVector2(this.GetMidX() - (this.m_targetPosition.m_x >> 3), this.GetMidY() - (this.m_targetPosition.m_y >> 3));

            int length          = pos.GetLength();
            int shockwaveLength = this.m_maxAttackRange - length;

            if (shockwaveLength >= this.m_minAttackRange)
            {
                int arcLength         = (this.m_shockwaveArcLength << 9) / 100;
                int expandedArcLength = LogicMath.Clamp(shockwaveLength * arcLength / ((this.m_shockwaveExpandRadius << 9) / 100), 0, arcLength);

                if (expandedArcLength < 0)
                {
                    expandedArcLength = arcLength;
                }

                if (expandedArcLength > arcLength)
                {
                    expandedArcLength = arcLength;
                }

                int calculateArcLength = 18000 * expandedArcLength / (314 * shockwaveLength);

                if (calculateArcLength < 180)
                {
                    return(calculateArcLength);
                }

                return(180);
            }

            return(0);
        }
Пример #4
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);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }