public void WallRemoved()
        {
            LogicArrayList <LogicComponent> components = this.m_parent.GetComponentManager().GetComponents(LogicComponentType.MOVEMENT);

            for (int i = 0; i < components.Size(); i++)
            {
                LogicCombatComponent combatComponent = components[i].GetParent().GetCombatComponent();

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

                    if (target.IsWall())
                    {
                        combatComponent.ForceNewTarget();
                    }
                }
            }
        }
        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();
            }
        }
Esempio n. 3
0
        public override void SubTick()
        {
            base.SubTick();

            LogicSpellData data = this.GetSpellData();

            if (!this.m_preDeployEffectPlayed)
            {
                this.GetListener().PlayEffect(data.GetPreDeployEffect(this.m_upgradeLevel));
                this.m_preDeployEffectPlayed = true;
            }

            if (++this.m_deployTime >= data.GetDeployTimeMS() * 60 / 1000)
            {
                if (!this.m_deployed)
                {
                    this.GetListener().PlayEffect(this.m_team != 0 && data.GetEnemyDeployEffect(this.m_upgradeLevel) != null
                                                      ? data.GetEnemyDeployEffect(this.m_upgradeLevel)
                                                      : data.GetDeployEffect(this.m_upgradeLevel), this.m_playEffectOffsetX, this.m_playEffectOffsetY);

                    this.m_deployEffect2Cooldown = data.GetDeployEffect2Delay();

                    if (this.m_deployEffect2Cooldown <= 0)
                    {
                        this.GetListener().PlayEffect(data.GetDeployEffect2(this.m_upgradeLevel), this.m_playEffectOffsetX, this.m_playEffectOffsetY);
                        this.m_deployEffect2Cooldown = 0;
                    }

                    this.m_deployed = true;
                }

                if (++this.m_chargingTime >= (data.GetChargingTimeMS() * 60 / 1000) +
                    this.m_chargingCount * (data.GetTimeBetweenHitsMS(this.m_upgradeLevel) * 60 / 1000) &&
                    this.m_chargingCount < data.GetNumberOfHits(this.m_upgradeLevel))
                {
                    this.CalculateRandomOffset(this.m_chargingCount);
                    this.GetListener().PlayTargetedEffect(data.GetChargingEffect(this.m_upgradeLevel), this, this.m_randomOffset);
                    ++this.m_chargingCount;
                }

                if (++this.m_hitTime >= (data.GetHitTimeMS() * 60 / 1000) +
                    this.m_hitCount * (data.GetTimeBetweenHitsMS(this.m_upgradeLevel) * 60 / 1000) &&
                    this.m_hitCount < data.GetNumberOfHits(this.m_upgradeLevel))
                {
                    this.CalculateRandomOffset(this.m_hitCount);
                    this.GetListener().PlayTargetedEffect(data.GetHitEffect(this.m_upgradeLevel), this, this.m_randomOffset);

                    int randomRadiusX = 0;
                    int randomRadiusY = 0;

                    if (!data.GetRandomRadiusAffectsOnlyGfx())
                    {
                        randomRadiusX = this.m_randomOffset.m_x;
                        randomRadiusY = this.m_randomOffset.m_y;
                    }

                    int damage = data.GetDamage(this.m_upgradeLevel);

                    if (damage != 0 && data.IsScaleByTownHall())
                    {
                        int scaledDamage = damage * (700 * this.m_level.GetPlayerAvatar().GetTownHallLevel() / (LogicDataTables.GetTownHallLevelCount() - 1) / 10 + 30) / 100;

                        damage = 1;

                        if (scaledDamage > 0)
                        {
                            damage = scaledDamage;
                        }
                    }

                    if (damage != 0 && data.GetRadius(this.m_upgradeLevel) > 0)
                    {
                        int areaDamageX = randomRadiusX + this.GetMidX();
                        int areaDamageY = randomRadiusY + this.GetMidY();
                        int preferredTargetDamagePercent = 100 * data.GetPreferredTargetDamageMod();

                        if (data.GetTroopsOnly())
                        {
                            this.m_level.AreaDamage(0, areaDamageX, areaDamageY, data.GetRadius(this.m_upgradeLevel), damage, data.GetPreferredTarget(),
                                                    preferredTargetDamagePercent, null, this.m_team, null, 2, 2, 0, true, damage < 0, data.GetHeroDamageMultiplier(),
                                                    data.GetMaxUnitsHit(this.m_upgradeLevel), null, data.GetDamageTHPercent(), data.GetPauseCombatComponentMs());
                        }
                        else
                        {
                            this.m_level.AreaDamage(0, areaDamageX, areaDamageY, data.GetRadius(this.m_upgradeLevel), damage, data.GetPreferredTarget(),
                                                    preferredTargetDamagePercent, null, this.m_team, null, 2, 1, 0, true, damage < 0, data.GetHeroDamageMultiplier(),
                                                    data.GetMaxUnitsHit(this.m_upgradeLevel), null, data.GetDamageTHPercent(), data.GetPauseCombatComponentMs());
                        }
                    }

                    if (data.GetDuplicateHousing(this.m_upgradeLevel) != 0 && data.GetRadius(this.m_upgradeLevel) > 0)
                    {
                        this.SelectDuplicableCharacters();
                        this.DuplicateCharacter();
                    }

                    if ((data.GetBuildingDamagePermil(this.m_upgradeLevel) != 0 || data.GetTroopDamagePermil(this.m_upgradeLevel) != 0) && data.GetRadius(this.m_upgradeLevel) > 0)
                    {
                        this.ApplyDamagePermil(randomRadiusX + this.GetMidX(), randomRadiusY + this.GetMidY(), 0, this.m_team, 0, 2, 1, 0,
                                               data.GetTroopDamagePermil(this.m_upgradeLevel) < 0);
                    }

                    if (data.GetPoisonDamage(this.m_upgradeLevel) != 0 && data.GetRadius(this.m_upgradeLevel) > 0)
                    {
                        int areaDamageX  = randomRadiusX + this.GetMidX();
                        int areaDamageY  = randomRadiusY + this.GetMidY();
                        int poisonDamage = data.GetPoisonDamage(this.m_upgradeLevel);

                        if (data.GetTroopsOnly())
                        {
                            this.m_level.AreaPoison(0, areaDamageX, areaDamageY, data.GetRadius(this.m_upgradeLevel), data.GetPoisonDamage(this.m_upgradeLevel), null,
                                                    0, null, this.m_team, null, data.GetPoisonAffectAir() ? 2 : 1, 2, 0, poisonDamage < 0, data.GetHeroDamageMultiplier(),
                                                    data.GetPoisonIncreaseSlowly());
                        }
                        else
                        {
                            this.m_level.AreaPoison(0, areaDamageX, areaDamageY, data.GetRadius(this.m_upgradeLevel), data.GetPoisonDamage(this.m_upgradeLevel), null,
                                                    0, null, this.m_team, null, data.GetPoisonAffectAir() ? 2 : 1, 1, 0, poisonDamage < 0, data.GetHeroDamageMultiplier(),
                                                    data.GetPoisonIncreaseSlowly());
                        }
                    }

                    if (data.GetSpeedBoost(this.m_upgradeLevel) != 0 || data.GetAttackSpeedBoost(this.m_upgradeLevel) != 0)
                    {
                        this.m_level.AreaBoost(randomRadiusX + this.GetMidX(), randomRadiusY + this.GetMidY(), data.GetRadius(this.m_upgradeLevel),
                                               data.GetSpeedBoost(this.m_upgradeLevel), data.GetSpeedBoost2(this.m_upgradeLevel), data.GetDamageBoostPercent(this.m_upgradeLevel),
                                               data.GetAttackSpeedBoost(this.m_upgradeLevel), 60 * data.GetBoostTimeMS(this.m_upgradeLevel) / 1000,
                                               data.GetBoostDefenders() ? this.m_team != 1 ? 1 : 0 : this.m_team, data.GetBoostLinkedToPoison());
                    }

                    if (data.GetJumpBoostMS(this.m_upgradeLevel) != 0)
                    {
                        if (this.m_team == 0)
                        {
                            this.m_level.AreaJump(randomRadiusX + this.GetMidX(), randomRadiusY + this.GetMidY(), data.GetRadius(this.m_upgradeLevel),
                                                  data.GetJumpBoostMS(this.m_upgradeLevel), data.GetJumpHousingLimit(this.m_upgradeLevel), this.m_team);

                            if (this.m_hitCount == 0)
                            {
                                if (LogicDataTables.GetGlobals().UseWallWeightsForJumpSpell())
                                {
                                    int numberOfHits      = data.GetNumberOfHits(this.m_upgradeLevel);
                                    int timeBetweenHitsMS = data.GetTimeBetweenHitsMS(this.m_upgradeLevel);
                                    int radius            = data.GetRadius(this.m_upgradeLevel);
                                    int jumpTime          = numberOfHits * timeBetweenHitsMS - LogicDataTables.GetGlobals().GetForgetTargetTime();

                                    LogicArrayList <LogicGameObject> buildings = this.GetGameObjectManager().GetGameObjects(LogicGameObjectType.BUILDING);

                                    for (int i = 0; i < buildings.Size(); i++)
                                    {
                                        LogicBuilding building = (LogicBuilding)buildings[i];

                                        if (building.IsWall() && building.IsAlive())
                                        {
                                            int distanceX = this.GetMidX() - building.GetMidX();
                                            int distanceY = this.GetMidY() - building.GetMidY();

                                            if (LogicMath.Abs(distanceX) < radius &&
                                                LogicMath.Abs(distanceY) < radius &&
                                                distanceX * distanceX + distanceY * distanceY < (uint)(radius * radius))
                                            {
                                                building.SetHitWallDelay(jumpTime);
                                            }
                                        }
                                    }

                                    this.m_level.GetTileMap().GetPathFinder().InvalidateCache();

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

                                    for (int i = 0; i < components.Size(); i++)
                                    {
                                        LogicMovementComponent movementComponent = (LogicMovementComponent)components[i];
                                        LogicGameObject        parent            = movementComponent.GetParent();
                                        LogicCombatComponent   combatComponent   = parent.GetCombatComponent();

                                        if (combatComponent != null && combatComponent.GetTarget(0) != null)
                                        {
                                            if (combatComponent.GetTarget(0).IsWall())
                                            {
                                                combatComponent.ForceNewTarget();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (data.GetShrinkReduceSpeedRatio() != 0 || data.GetShrinkHitpointsRatio() != 0)
                    {
                        this.m_level.AreaShrink(randomRadiusX + this.GetMidX(), randomRadiusY + this.GetMidY(), data.GetRadius(this.m_upgradeLevel),
                                                data.GetShrinkReduceSpeedRatio(),
                                                data.GetShrinkHitpointsRatio(), 1000 * LogicDataTables.GetGlobals().GetShrinkSpellDurationSeconds() / 64, this.m_team);
                    }

                    if (data.GetFreezeTimeMS(this.m_upgradeLevel) != 0)
                    {
                        this.m_level.AreaFreeze(randomRadiusX + this.GetMidX(), randomRadiusY + this.GetMidY(), data.GetRadius(this.m_upgradeLevel),
                                                60 * data.GetFreezeTimeMS(this.m_upgradeLevel) / 1000, this.m_team);
                    }

                    if (data.GetBuildingDamageBoostPercent(this.m_upgradeLevel) != 0)
                    {
                        this.m_level.AreaBoost(randomRadiusX + this.GetMidX(), randomRadiusY + this.GetMidY(), data.GetRadius(this.m_upgradeLevel),
                                               data.GetBuildingDamageBoostPercent(this.m_upgradeLevel), 0, 60 * data.GetBoostTimeMS(this.m_upgradeLevel) / 1000);
                    }

                    if (data.GetSummonTroop() != null)
                    {
                        this.SpawnSummon(randomRadiusX + this.GetMidX(), randomRadiusY + this.GetMidY());
                    }

                    if (data.GetSpawnObstacle() != null)
                    {
                        this.SpawnObstacle(randomRadiusX + this.GetMidX(), randomRadiusY + this.GetMidY(), 5);
                    }

                    if (data.GetExtraHealthPermil(this.m_upgradeLevel) != 0)
                    {
                        this.ApplyExtraHealthPermil(randomRadiusX + this.GetMidX(), randomRadiusY + this.GetMidY(), data.GetRadius(this.m_upgradeLevel), this.m_team,
                                                    data.GetExtraHealthPermil(this.m_upgradeLevel), data.GetExtraHealthMin(this.m_upgradeLevel),
                                                    data.GetExtraHealthMax(this.m_upgradeLevel),
                                                    data.GetHitTimeMS() + 64, 2);
                    }

                    if (data.GetInvulnerabilityTime(this.m_upgradeLevel) != 0)
                    {
                        this.m_level.AreaShield(randomRadiusX + this.GetMidX(), randomRadiusY + this.GetMidY(), data.GetRadius(this.m_upgradeLevel),
                                                data.GetInvulnerabilityTime(this.m_upgradeLevel), this.m_team);
                    }

                    if (++this.m_hitCount >= data.GetNumberOfHits(this.m_upgradeLevel))
                    {
                        this.m_hitsCompleted = true;
                        this.m_level.UpdateBattleStatus();
                    }
                }
            }
        }