示例#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();
                    }
                }
            }
        }
示例#2
0
        public void SetUpgradeLevel(int upgLevel)
        {
            this.m_upgradeLevel = upgLevel;

            LogicCharacterData     data = this.GetCharacterData();
            LogicHitpointComponent hitpointComponent = this.GetHitpointComponent();
            LogicCombatComponent   combatComponent   = this.GetCombatComponent();

            int hp = data.GetHitpoints(upgLevel);
            int damagePercentage = 100;

            if (data.GetScaleByTH())
            {
                LogicAvatar avatar = this.m_level.GetHomeOwnerAvatar();

                if (hitpointComponent != null && hitpointComponent.GetTeam() == 0)
                {
                    avatar = this.m_level.GetVisitorAvatar();
                }

                int tmp1 = 700 * avatar.GetTownHallLevel() / (LogicDataTables.GetTownHallLevelCount() - 1);

                damagePercentage = tmp1 / 10 + 30;
                hp = damagePercentage * hp / 100;

                if (damagePercentage * hp < 200)
                {
                    hp = 1;
                }

                if (tmp1 < -289)
                {
                    damagePercentage = 1;
                }
            }

            hitpointComponent.SetMaxHitpoints(hp);
            hitpointComponent.SetHitpoints(data.GetHitpoints(upgLevel));
            hitpointComponent.SetDieEffect(data.GetDieEffect(upgLevel), data.GetDieEffect2(upgLevel));

            if (combatComponent != null)
            {
                combatComponent.SetAttackValues(data.GetAttackerItemData(upgLevel), damagePercentage);
            }

            if (this.m_childrens != null)
            {
                for (int i = 0; i < this.m_childrens.Size(); i++)
                {
                    this.m_childrens[i].SetUpgradeLevel(upgLevel);
                }
            }

            if (this.IsHero())
            {
                LogicHeroData heroData = (LogicHeroData)this.m_data;
                LogicAvatar   avatar   = this.m_level.GetHomeOwnerAvatar();

                if (hitpointComponent.GetTeam() == 0)
                {
                    avatar = this.m_level.GetVisitorAvatar();
                }

                this.m_flying = heroData.IsFlying(avatar.GetHeroMode(heroData));
                this.GetMovementComponent().SetFlying(this.m_flying);
            }

            if (data.GetAutoMergeDistance() > 0)
            {
                this.m_autoMergeTime = 2000;
            }

            int speed = data.GetSpeed();

            if (data.GetSpecialAbilityLevel(this.m_upgradeLevel) > 0 &&
                data.GetSpecialAbilityType() == LogicCharacterData.SPECIAL_ABILITY_TYPE_SPEED_BOOST)
            {
                speed = speed * data.GetSpecialAbilityAttribute(this.m_upgradeLevel) / 100;
            }

            this.GetMovementComponent().SetSpeed(speed);
        }