Beispiel #1
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();
                    }
                }
            }
        }
Beispiel #2
0
        public override int Execute(LogicLevel level)
        {
            if (level.IsReadyForAttack())
            {
                int tileX = this.m_x >> 9;
                int tileY = this.m_y >> 9;

                if (level.GetTileMap().GetTile(tileX, tileY) != null)
                {
                    if (level.GetTileMap().IsPassablePathFinder(this.m_x >> 8, this.m_y >> 8))
                    {
                        if (level.GetTileMap().IsValidAttackPos(tileX, tileY))
                        {
                            LogicClientAvatar playerAvatar = level.GetPlayerAvatar();

                            if (playerAvatar != null)
                            {
                                int unitCount = level.GetVillageType() == 1 ? playerAvatar.GetUnitCountVillage2(this.m_data) : playerAvatar.GetUnitCount(this.m_data);

                                if (unitCount > 0)
                                {
                                    if (level.GetBattleLog() != null)
                                    {
                                        if (!level.GetBattleLog().HasDeployedUnits() && level.GetTotalAttackerHeroPlaced() == 0)
                                        {
                                            level.UpdateLastUsedArmy();
                                        }
                                    }

                                    if (level.GetGameMode().IsInAttackPreparationMode())
                                    {
                                        level.GetGameMode().EndAttackPreparation();
                                    }

                                    LogicCharacter character = LogicPlaceAttackerCommand.PlaceAttacker(playerAvatar, this.m_data, level, this.m_x, this.m_y);

                                    if (character != null && character.HasSpecialAbility())
                                    {
                                        if (this.m_data.GetSpecialAbilityType() == LogicCharacterData.SPECIAL_ABILITY_TYPE_START_RAGE)
                                        {
                                            LogicSpellData specialAbilitySpellData = this.m_data.GetSpecialAbilitySpell();

                                            level.BoostGameObject(character, specialAbilitySpellData.GetSpeedBoost(0), specialAbilitySpellData.GetSpeedBoost2(0),
                                                                  specialAbilitySpellData.GetDamageBoostPercent(0), specialAbilitySpellData.GetAttackSpeedBoost(0),
                                                                  60 * this.m_data.GetSpecialAbilityAttribute(character.GetUpgradeLevel()),
                                                                  specialAbilitySpellData.GetBoostLinkedToPoison());
                                        }
                                        else if (this.m_data.GetSpecialAbilityType() == LogicCharacterData.SPECIAL_ABILITY_TYPE_START_CLOAK)
                                        {
                                            character.SetStealthTime(15 * this.m_data.GetSpecialAbilityAttribute(character.GetUpgradeLevel()));
                                        }
                                    }

                                    return(0);
                                }

                                return(-7);
                            }

                            return(-5);
                        }

                        return(-4);
                    }

                    return(-2);
                }

                return(-3);
            }

            return(-1);
        }