コード例 #1
0
        public void CalculateDirection(LogicVector2 pos)
        {
            LogicVector2 nextPath = this.m_path[this.m_path.Size() - 1];

            pos.m_x = nextPath.m_x - this.m_position.m_x;
            pos.m_y = nextPath.m_y - this.m_position.m_y;

            this.m_direction = pos.GetAngle();
        }
コード例 #2
0
        public override void SubTick()
        {
            base.SubTick();

            this.m_areaShieldSpeed = 0;

            bool isInAreaShield   = false;
            int  damagePercentage = 100;

            if (this.m_myTeam == 1)
            {
                LogicVector2 areaShield = new LogicVector2();

                if (this.m_level.GetAreaShield(this.GetMidX(), this.GetMidY(), areaShield))
                {
                    this.m_areaShieldSpeed = areaShield.m_x;

                    isInAreaShield   = true;
                    damagePercentage = 0;
                }
            }

            if (this.m_targetReached)
            {
                if (this.m_damageTime > 0)
                {
                    this.UpdateDamage(damagePercentage);
                }
            }
            else
            {
                if (this.m_targetGroups)
                {
                    if (this.m_target != null && this.m_groups != null)
                    {
                        LogicCombatComponent combatComponent = this.m_groups.GetCombatComponent();

                        if (combatComponent != null && !combatComponent.IsInRange(this.m_target))
                        {
                            this.m_target = null;
                        }
                    }
                }

                if (isInAreaShield)
                {
                    this.m_areaShieldDelay = LogicMath.Min(this.m_areaShieldDelay + 16, 200);
                }
                else if (this.m_areaShieldDelay > 0)
                {
                    this.m_areaShieldDelay = LogicMath.Max(this.m_areaShieldDelay - 4, 0);
                }

                if (this.m_areaShieldDelay == 0)
                {
                    if (this.m_target != null && this.m_target.GetMovementComponent() != null)
                    {
                        this.m_targetPosition.Set(this.m_target.GetMidX() * 8, this.m_target.GetMidY() * 8);
                        this.m_targetPosition.Add(this.m_unk168);
                    }
                }
                else if (this.m_target != null && this.m_target.GetMovementComponent() != null)
                {
                    int x = this.m_unk168.m_x + this.m_target.GetMidX() * 8;
                    int y = this.m_unk168.m_y + this.m_target.GetMidY() * 8;

                    LogicVector2 tmp1 = new LogicVector2(x - this.m_unk276.m_x, y - this.m_unk276.m_y);
                    LogicVector2 tmp2 = new LogicVector2(this.m_unk152.m_x, this.m_unk152.m_y);

                    int length1 = tmp1.Normalize(512);
                    int length2 = tmp2.Normalize(512);

                    int angle1 = tmp1.GetAngle();
                    int angle2 = tmp2.GetAngle();

                    if (LogicMath.Abs(LogicMath.NormalizeAngle180(angle1 - angle2)) <= 30)
                    {
                        this.m_targetPosition.m_x += LogicMath.Clamp(x - this.m_targetPosition.m_x, length1 / -500, length1 / 500);
                        this.m_targetPosition.m_y += LogicMath.Clamp(y - this.m_targetPosition.m_y, length1 / -500, length1 / 500);
                    }
                    else
                    {
                        this.m_target = null;
                    }
                }

                this.m_unk144.m_x = this.m_targetPosition.m_x - this.m_unk276.m_x;
                this.m_unk144.m_y = this.m_targetPosition.m_y - this.m_unk276.m_y;

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

                if (distance * distance >= this.m_unk144.GetDistanceSquaredTo(0, 0))
                {
                    this.TargetReached(damagePercentage);
                }
                else
                {
                    this.m_unk152.m_x = this.m_unk144.m_x;
                    this.m_unk152.m_y = this.m_unk144.m_y;

                    this.m_unk144.Normalize(distance);

                    this.m_unk276.m_x += this.m_unk144.m_x;
                    this.m_unk276.m_y += this.m_unk144.m_y;

                    this.SetPositionXY(this.m_unk276.m_x >> 3, this.m_unk276.m_y >> 3);

                    this.m_unk160.m_x = this.m_unk144.m_x >> 3;
                    this.m_unk160.m_y = this.m_unk144.m_y >> 3;
                }

                if (this.m_shockwavePushStrength > 0)
                {
                    this.UpdateShockwavePush(this.m_myTeam, this.m_flyingTarget ? 0 : 1);
                }

                if (this.m_penetrating)
                {
                    this.UpdatePenetrating(damagePercentage);
                }

                this.m_travelTime += 16;
            }
        }
コード例 #3
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);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        public void PushTrap(LogicVector2 position, int time, int id, bool ignorePrevPush, bool verifyPushPosition)
        {
            if (this.m_pushTime <= 0 || ignorePrevPush)
            {
                if (this.m_parent != null && this.m_parent.GetJump() <= 0 && !this.m_parent.GetParent().IsHero())
                {
                    LogicGameObject parent = this.m_parent.GetParent();

                    if (!parent.IsHero())
                    {
                        if (id != 0 && !ignorePrevPush)
                        {
                            int idx = -1;

                            for (int k = 0; k < 3; k++)
                            {
                                if (this.m_preventsPushId[k] == id)
                                {
                                    return;
                                }

                                if (this.m_preventsPushTime[k] == 0)
                                {
                                    idx = k;
                                }
                            }

                            if (idx == -1)
                            {
                                return;
                            }

                            this.m_preventsPushId[idx]   = id;
                            this.m_preventsPushTime[idx] = 1500;
                        }

                        this.m_pushTime     = time;
                        this.m_pushInitTime = time;
                        this.m_pushBackStartPosition.m_x = this.m_position.m_x;
                        this.m_pushBackStartPosition.m_y = this.m_position.m_y;
                        this.m_pushBackEndPosition.m_x   = this.m_position.m_x + position.m_x;
                        this.m_pushBackEndPosition.m_y   = this.m_position.m_y + position.m_y;

                        if (verifyPushPosition)
                        {
                            int pushBackEndPositionX = this.m_pushBackEndPosition.m_x;
                            int pushBackEndPositionY = this.m_pushBackEndPosition.m_y;

                            if (LogicMath.Max(LogicMath.Abs(position.m_x), LogicMath.Abs(position.m_y)) != 0)
                            {
                                LogicTileMap tileMap = parent.GetLevel().GetTileMap();

                                if (!tileMap.IsPassablePathFinder(pushBackEndPositionX >> 8, pushBackEndPositionY >> 8))
                                {
                                    LogicVector2 pos = new LogicVector2();
                                    LogicRandom  rnd = new LogicRandom(pushBackEndPositionX + pushBackEndPositionY);

                                    tileMap.GetNearestPassablePosition(pushBackEndPositionX + rnd.Rand(512) - 256,
                                                                       pushBackEndPositionY + rnd.Rand(512) - 256, pos, 2048);

                                    pushBackEndPositionX = pos.m_x;
                                    pushBackEndPositionY = pos.m_y;
                                }

                                if (!tileMap.IsPassablePathFinder(pushBackEndPositionX >> 8, pushBackEndPositionY >> 8))
                                {
                                    Debugger.Warning("PushTrap->ended on inmovable");
                                }
                            }

                            this.m_pushBackEndPosition.m_x = pushBackEndPositionX;
                            this.m_pushBackEndPosition.m_y = pushBackEndPositionY;
                        }

                        this.m_ignorePush = verifyPushPosition;

                        int angle = position.GetAngle();
                        this.m_direction = angle + (angle <= 180 ? 180 : -180);
                    }
                }
            }
        }
コード例 #5
0
        public void PushBack(LogicVector2 position, int speed, int unk1, int id, bool ignoreWeight, bool gravity)
        {
            if (speed > 0 && this.m_pushTime <= 0)
            {
                if (this.m_parent != null && this.m_parent.GetJump() <= 0 && !this.m_parent.GetParent().IsHero())
                {
                    if (id != 0)
                    {
                        int idx = -1;

                        for (int k = 0; k < 3; k++)
                        {
                            if (this.m_preventsPushId[k] == id)
                            {
                                return;
                            }

                            if (this.m_preventsPushTime[k] == 0)
                            {
                                idx = k;
                            }
                        }

                        if (idx == -1)
                        {
                            return;
                        }

                        this.m_preventsPushId[idx]   = id;
                        this.m_preventsPushTime[idx] = 1500;
                    }

                    LogicGameObject     parent = this.m_parent.GetParent();
                    LogicGameObjectData data   = parent.GetData();

                    int housingSpace = 1;

                    if (data.GetDataType() == LogicDataType.CHARACTER)
                    {
                        housingSpace = ((LogicCombatItemData)data).GetHousingSpace();

                        if (housingSpace >= 4 && !ignoreWeight)
                        {
                            return;
                        }
                    }

                    int pushForce = 256;

                    if (100 / unk1 != 0)
                    {
                        pushForce = 256 / (100 / unk1);
                    }

                    if (gravity)
                    {
                        pushForce = (LogicMath.Min(speed, 5000) << 8) / 5000 / housingSpace;
                    }

                    int rndX         = parent.Rand(100) & 0x7F;
                    int rndY         = parent.Rand(200) & 0x7F;
                    int pushBackX    = rndX + position.m_x - 0x3F;
                    int pushBackY    = rndY + position.m_y - 0x3F;
                    int pushBackTime = (1000 * pushForce) >> 8;

                    this.m_pushTime     = pushBackTime;
                    this.m_pushInitTime = pushBackTime;
                    this.m_ignorePush   = false;
                    this.m_pushBackStartPosition.m_x = this.m_position.m_x;
                    this.m_pushBackStartPosition.m_y = this.m_position.m_y;

                    pushForce *= 2;

                    this.m_pushBackEndPosition.m_x = this.m_position.m_x + ((pushForce * pushBackX) >> 8);
                    this.m_pushBackEndPosition.m_y = this.m_position.m_y + ((pushForce * pushBackY) >> 8);

                    int angle     = position.GetAngle();
                    int direction = angle <= 180 ? 180 : -180;

                    this.m_direction = direction + angle;
                }
            }
        }