Beispiel #1
0
        public void SetInitialPosition(LogicGameObject groups, int x, int y)
        {
            this.m_groups   = groups;
            this.m_groupsId = groups != null?groups.GetGlobalID() : 0;

            this.m_unk144.m_x = this.m_targetPosition.m_x - 8 * x;
            this.m_unk144.m_y = this.m_targetPosition.m_y - 8 * y;

            this.m_unk144.Normalize((this.GetProjectileData().GetStartOffset() << 9) / 100);
            this.SetInitialPosition(this.m_unk144.m_x + x, this.m_unk144.m_y + y);

            this.m_unk160.m_x = 0;
            this.m_unk160.m_y = 0;
            this.m_unk248.m_x = this.GetX();
            this.m_unk248.m_y = this.GetY();
            this.m_unk276.m_x = this.GetX() * 8;
            this.m_unk276.m_y = this.GetY() * 8;
            this.m_unk152.m_x = this.m_targetPosition.m_x - this.m_unk276.m_x;
            this.m_unk152.m_y = this.m_targetPosition.m_y - this.m_unk276.m_y;

            this.m_targetGroups = false;

            if (this.m_groups != null && this.m_groups.GetGameObjectType() == LogicGameObjectType.BUILDING)
            {
                LogicCombatComponent combatComponent = this.m_groups.GetCombatComponent();

                if (combatComponent != null && combatComponent.GetAttackerItemData().GetTargetGroups())
                {
                    this.m_targetGroups = true;
                }
            }
        }
        public virtual void GetChecksum(ChecksumHelper checksum, bool includeGameObjects)
        {
            if (includeGameObjects)
            {
                checksum.StartObject("LogicGameObject");

                checksum.WriteValue("type", (int)this.GetGameObjectType());
                checksum.WriteValue("globalID", this.m_globalId);
                checksum.WriteValue("dataGlobalID", this.m_data.GetGlobalID());
                checksum.WriteValue("x", this.GetX());
                checksum.WriteValue("y", this.GetY());
                checksum.WriteValue("seed", this.m_seed);

                LogicHitpointComponent hitpointComponent = this.GetHitpointComponent();

                if (hitpointComponent != null)
                {
                    checksum.WriteValue("m_hp", hitpointComponent.GetHitpoints());
                    checksum.WriteValue("m_maxHP", hitpointComponent.GetMaxHitpoints());
                }

                LogicCombatComponent combatComponent = this.GetCombatComponent();

                if (combatComponent != null)
                {
                    LogicGameObject target = combatComponent.GetTarget(0);

                    if (target != null)
                    {
                        checksum.WriteValue("target", target.GetGlobalID());
                    }
                }

                checksum.EndObject();
            }
        }
Beispiel #3
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();
        }