public void CreateProjectile(LogicProjectileData data) { LogicTrapData trapData = this.GetTrapData(); LogicVector2 position = new LogicVector2(); LogicArrayList <LogicGameObject> characters = this.GetGameObjectManager().GetGameObjects(LogicGameObjectType.CHARACTER); LogicGameObject closestGameObject = null; for (int i = 0, minDistance = 0; i < characters.Size(); i++) { LogicCharacter character = (LogicCharacter)characters[i]; LogicHitpointComponent hitpointComponent = character.GetHitpointComponent(); if (hitpointComponent != null && hitpointComponent.GetTeam() == 0) { if (character.IsFlying() && character.IsAlive()) { int housingSpace = character.GetCharacterData().GetHousingSpace(); if (housingSpace >= trapData.GetMinTriggerHousingLimit() && character.GetChildTroops() == null) { if (trapData.GetHealerTrigger() || character.GetCombatComponent() == null || !character.GetCombatComponent().IsHealer()) { position.m_x = character.GetPosition().m_x - this.GetMidX(); position.m_y = character.GetPosition().m_y - this.GetMidY(); int lengthSquared = position.GetLengthSquared(); if (minDistance == 0 || lengthSquared < minDistance) { minDistance = lengthSquared; closestGameObject = character; } } } } } } position.Destruct(); if (closestGameObject != null) { LogicProjectile projectile = (LogicProjectile)LogicGameObjectFactory.CreateGameObject(data, this.m_level, this.m_villageType); projectile.SetInitialPosition(null, this.GetMidX(), this.GetMidY()); projectile.SetTarget(this.GetMidX(), this.GetMidY(), 0, closestGameObject, data.GetRandomHitPosition()); projectile.SetDamage(trapData.GetDamage(this.m_upgLevel)); projectile.SetDamageRadius(trapData.GetDamageRadius(this.m_upgLevel)); projectile.SetPushBack(trapData.GetPushback(), !trapData.GetDoNotScalePushByDamage()); projectile.SetMyTeam(1); projectile.SetHitEffect(trapData.GetDamageEffect(), null); this.GetGameObjectManager().AddGameObject(projectile, -1); } }
public void ApplyExtraHealthPermil(int x, int y, int radius, int team, int extraHealthPermil, int extraHealthMin, int extraHealthMax, int time, int targetType) { LogicArrayList <LogicComponent> components = this.GetComponentManager().GetComponents(LogicComponentType.HITPOINT); for (int i = 0; i < components.Size(); i++) { LogicHitpointComponent hitpointComponent = (LogicHitpointComponent)components[i]; LogicGameObject parent = hitpointComponent.GetParent(); if (!parent.IsHidden() && hitpointComponent.GetHitpoints() != 0 && hitpointComponent.GetTeam() == team) { LogicMovementComponent movementComponent = parent.GetMovementComponent(); if (movementComponent != null) { if (parent.GetGameObjectType() == LogicGameObjectType.CHARACTER) { LogicCharacter character = (LogicCharacter)parent; if (character.GetCharacterData().GetAuraSpell(character.GetUpgradeLevel()) == this.m_data) { continue; } } if (parent.IsFlying()) { if (targetType != 1) { continue; } } else if (targetType == 0) { continue; } int distanceX = x - parent.GetMidX(); int distanceY = y - parent.GetMidY(); if (LogicMath.Abs(distanceX) <= radius && LogicMath.Abs(distanceY) <= radius && distanceX * distanceX + distanceY * distanceY < (uint)(radius * radius)) { int hp = hitpointComponent.GetOriginalHitpoints() + LogicMath.Clamp(extraHealthPermil * hitpointComponent.GetOriginalHitpoints() / 1000, 100 * extraHealthMin, 100 * extraHealthMax); if (hp >= hitpointComponent.GetMaxHitpoints()) { hitpointComponent.SetExtraHealth(hp, time); } } } } } }
public void PassEnemyOnly(LogicGameObject gameObject) { LogicHitpointComponent hitpointComponent = gameObject.GetHitpointComponent(); if (hitpointComponent != null) { this.m_team = hitpointComponent.GetTeam(); this.m_enemyOnly = true; } else { this.m_team = -1; } }
public override void DeathEvent() { LogicHitpointComponent hitpointComponent = this.GetHitpointComponent(); LogicCharacterData data = this.GetCharacterData(); if (hitpointComponent != null && hitpointComponent.GetTeam() == 1 && !this.IsHero() && !data.IsSecondaryTroop() && this.m_level.GetVillageType() == 0 && this.m_allianceUnit) { LogicAvatar homeOwnerAvatar = this.m_level.GetHomeOwnerAvatar(); homeOwnerAvatar.RemoveAllianceUnit(data, this.m_upgradeLevel); homeOwnerAvatar.GetChangeListener().AllianceUnitRemoved(data, this.m_upgradeLevel); } if (data.GetSpecialAbilityType() != LogicCharacterData.SPECIAL_ABILITY_TYPE_RESPAWN_AS_CANNON || data.GetSpecialAbilityLevel(this.m_upgradeLevel) <= 0) { if (data.GetSpecialAbilityType() == LogicCharacterData.SPECIAL_ABILITY_TYPE_SPAWN_UNITS) { if (data.GetSpecialAbilityLevel(this.m_upgradeLevel) > 0) { this.CheckSpawning(null, data.GetSpecialAbilityAttribute(this.m_upgradeLevel), 0, 0); } } else if (data.GetSecondaryTroop() != null) { this.CheckSpawning(null, 0, 0, 0); } } else if (!this.m_ejected) { this.CheckSpawning(LogicDataTables.GetCharacterByName("MovingCannonSecondary", null), 1, data.GetSpecialAbilityAttribute(this.m_upgradeLevel), 500); } this.AddTombstoneIfNeeded(); if (this.m_parent != null) { this.m_parent.RemoveChildren(this); this.m_parent = null; } base.DeathEvent(); }
public void ApplyDamagePermil(int x, int y, int unk1, int team, int unk2, int targetType, int damageType, int unk3, bool healing) { LogicSpellData spellData = this.GetSpellData(); int radius = spellData.GetRadius(this.m_upgradeLevel); int troopDamagePermil = spellData.GetTroopDamagePermil(this.m_upgradeLevel); int buildingDamagePermil = spellData.GetBuildingDamagePermil(this.m_upgradeLevel); int executeHealthPermil = spellData.GetExecuteHealthPermil(this.m_upgradeLevel); int damagePermilMin = spellData.GetDamagePermilMin(this.m_upgradeLevel); int preferredTargetDamageMod = spellData.GetPreferredTargetDamageMod(); int preferredDamagePermilMin = spellData.GetPreferredDamagePermilMin(this.m_upgradeLevel); LogicData preferredTarget = spellData.GetPreferredTarget(); LogicVector2 pushBackPosition = new LogicVector2(); LogicArrayList <LogicComponent> components = this.GetComponentManager().GetComponents(LogicComponentType.HITPOINT); int tmp = troopDamagePermil + 2 * buildingDamagePermil; for (int i = 0; i < components.Size(); i++) { LogicHitpointComponent hitpointComponent = (LogicHitpointComponent)components[i]; LogicGameObject parent = hitpointComponent.GetParent(); if (!parent.IsHidden() && hitpointComponent.GetHitpoints() != 0) { if (hitpointComponent.GetTeam() == team) { if (tmp > 0 || tmp < 0 && parent.IsPreventsHealing()) { continue; } } else if (tmp < 0) { continue; } if (damageType == 2 && parent.GetGameObjectType() != LogicGameObjectType.CHARACTER) { continue; } int parentX; int parentY; LogicMovementComponent movementComponent = parent.GetMovementComponent(); if (movementComponent != null || parent.IsFlying()) { if (parent.IsFlying()) { if (targetType == 1) { continue; } } else if (targetType == 0) { continue; } parentX = parent.GetMidX(); parentY = parent.GetMidY(); } else { int posX = parent.GetX(); int posY = parent.GetY(); parentX = LogicMath.Clamp(x, posX, posX + (parent.GetWidthInTiles() << 9)); parentY = LogicMath.Clamp(y, posY, posY + (parent.GetHeightInTiles() << 9)); } int distanceX = x - parentX; int distanceY = y - parentY; if (LogicMath.Abs(distanceX) <= radius && LogicMath.Abs(distanceY) <= radius && distanceX * distanceX + distanceY * distanceY < (uint)(radius * radius)) { if (damageType == 1 && parent.GetGameObjectType() == LogicGameObjectType.BUILDING) { LogicBuilding building = (LogicBuilding)parent; if (building.GetResourceStorageComponentComponent() != null && !building.GetBuildingData().IsTownHall() && !building.GetBuildingData().IsTownHallVillage2()) { parent.SetDamageTime(10); continue; } } if (parent.GetGameObjectType() == LogicGameObjectType.BUILDING || parent.GetGameObjectType() == LogicGameObjectType.CHARACTER) { int dataDamagePermil = parent.GetGameObjectType() == LogicGameObjectType.BUILDING ? buildingDamagePermil : troopDamagePermil; if (dataDamagePermil != 0) { int permil = 10 * hitpointComponent.GetMaxHitpoints() * dataDamagePermil / 10000; if (10 * hitpointComponent.GetMaxHitpoints() * dataDamagePermil <= -10000) { if (parent.IsHero()) { permil = LogicDataTables.GetGlobals().GetHeroHealMultiplier() * permil / 100; } } bool isPreferredTarget = LogicCombatComponent.IsPreferredTarget(preferredTarget, parent); int numberOfHits = spellData.GetNumberOfHits(this.m_upgradeLevel); int completePermil = hitpointComponent.GetDamagePermilCount() / spellData.GetNumberOfHits(this.m_upgradeLevel); int calculateDamage = isPreferredTarget ? permil / (completePermil + 1) + preferredTargetDamageMod * hitpointComponent.GetMaxHitpoints() / (100 * numberOfHits) * completePermil * completePermil : permil / (2 * completePermil + 1); int permilMin = isPreferredTarget ? preferredDamagePermilMin : damagePermilMin; int damage = hitpointComponent.GetMaxHitpoints() * permilMin / 10000; if (calculateDamage >= damage) { damage = calculateDamage; } if (executeHealthPermil > 0 && 1000 * (hitpointComponent.GetHitpoints() - damage) <= executeHealthPermil) { damage = hitpointComponent.GetHitpoints(); } hitpointComponent.CauseDamagePermil(damage); if (healing) { // Listener. } if ((distanceX | distanceX) == 0) { distanceX = 1; } pushBackPosition.m_x = -distanceX; pushBackPosition.m_y = -distanceY; pushBackPosition.Normalize(512); if (unk3 > 0 && movementComponent != null) { movementComponent.GetMovementSystem().PushBack(pushBackPosition, damage, unk3, 0, false, true); } } } } } } }
public void SelectDuplicableCharacters() { if (this.m_duplicableCharacters == null) { this.m_duplicableCharacters = new LogicArrayList <LogicGameObject>(20); } if (this.m_duplicateCharacters == null) { this.m_duplicateCharacters = new LogicArrayList <LogicGameObject>(20); } int radius = this.GetSpellData().GetRadius(this.m_upgradeLevel); 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(); if (parent.GetGameObjectType() == LogicGameObjectType.CHARACTER) { LogicCharacter character = (LogicCharacter)parent; LogicCharacterData characterData = character.GetCharacterData(); LogicHitpointComponent hitpointComponent = character.GetHitpointComponent(); if (hitpointComponent != null && hitpointComponent.GetTeam() == 0 && character.IsAlive() && !character.IsHero() && characterData.GetHousingSpace() <= this.m_duplicateHousingSpace) { int distanceX = character.GetPosition().m_x - this.GetMidX(); int distanceY = character.GetPosition().m_y - this.GetMidY(); if (LogicMath.Abs(distanceX) <= radius && LogicMath.Abs(distanceY) <= radius && distanceX * distanceX + distanceY * distanceY < (uint)(radius * radius)) { int idx = -1; for (int j = 0, size = this.m_duplicableCharacters.Size(); j < size; j++) { if (this.m_duplicableCharacters[j] == character) { idx = j; break; } } if (idx == -1) { this.m_duplicateCharacterData = characterData; this.m_duplicateCharacterUpgradeLevel = character.GetUpgradeLevel(); this.m_duplicableCharacters.Add(character); // Listener. } } } } } }
private void SimulateEndAttackState() { LogicLevel level = this.m_logicGameMode.GetLevel(); LogicGameObjectManager gameObjectManager = level.GetGameObjectManager(); LogicArrayList <LogicGameObject> characterList = gameObjectManager.GetGameObjects(LogicGameObjectType.CHARACTER); LogicArrayList <LogicGameObject> projectileList = gameObjectManager.GetGameObjects(LogicGameObjectType.PROJECTILE); LogicArrayList <LogicGameObject> spellList = gameObjectManager.GetGameObjects(LogicGameObjectType.SPELL); LogicArrayList <LogicGameObject> alliancePortalList = gameObjectManager.GetGameObjects(LogicGameObjectType.ALLIANCE_PORTAL); this.m_logicWatch.Start(); while (!this.m_logicGameMode.IsBattleOver()) { bool canStopBattle = !this.m_logicGameMode.GetConfiguration().GetBattleWaitForProjectileDestruction() || projectileList.Size() == 0; for (int i = 0; i < characterList.Size(); i++) { LogicCharacter character = (LogicCharacter)characterList[i]; LogicHitpointComponent hitpointComponent = character.GetHitpointComponent(); if (hitpointComponent != null && hitpointComponent.GetTeam() == 0) { LogicAttackerItemData data = character.GetAttackerItemData(); if (data.GetDamage(0, false) > 0 && (hitpointComponent.GetHitpoints() > 0 || this.m_logicGameMode.GetConfiguration().GetBattleWaitForDieDamage() && character.GetWaitDieDamage())) { canStopBattle = false; } } } for (int i = 0; i < spellList.Size(); i++) { LogicSpell spell = (LogicSpell)spellList[i]; if (!spell.GetHitsCompleted() && (spell.GetSpellData().IsDamageSpell() || spell.GetSpellData().GetSummonTroop() != null)) { canStopBattle = false; } } for (int i = 0; i < alliancePortalList.Size(); i++) { LogicAlliancePortal alliancePortal = (LogicAlliancePortal)alliancePortalList[i]; if (alliancePortal.GetBunkerComponent().GetTeam() == 0 && !alliancePortal.GetBunkerComponent().IsEmpty()) { canStopBattle = false; } } bool isEnded = canStopBattle || this.m_logicWatch.ElapsedMilliseconds >= 10000; if (isEnded) { LogicEndCombatCommand logicEndCombatCommand = new LogicEndCombatCommand(); logicEndCombatCommand.SetExecuteSubTick(this.m_logicGameMode.GetLevel().GetLogicTime().GetTick()); this.m_logicGameMode.GetCommandManager().AddCommand(logicEndCombatCommand); } this.m_logicGameMode.UpdateOneSubTick(); if (isEnded) { break; } } this.m_logicWatch.Reset(); if (!this.m_logicGameMode.IsBattleOver()) { this.m_logicGameMode.SetBattleOver(); } if (this.m_liveReplayId != null) { this.UpdateLiveReplay(this.m_logicGameMode.GetLevel().GetLogicTime().GetTick(), null); } }
public override void Tick() { base.Tick(); LogicCharacterData data = this.GetCharacterData(); if (!this.IsAlive()) { if (!this.IsHero()) { int dieDamageDelay = this.GetCharacterData().GetDieDamageDelay(); int prevDieTime = this.m_dieTime; this.m_dieTime += 64; if (dieDamageDelay >= prevDieTime && dieDamageDelay < this.m_dieTime && (!this.m_duplicate || this.m_duplicateLifeTime >= 0)) { this.CheckDieDamage(data.GetDieDamage(this.m_upgradeLevel), data.GetDieDamageRadius()); this.m_level.UpdateBattleStatus(); } } this.m_spawnTime = 0; this.m_spawnIdleTime = 0; if (this.m_auraSpell != null) { this.GetGameObjectManager().RemoveGameObject(this.m_auraSpell); this.m_auraSpell = null; } if (this.m_abilitySpell != null) { this.GetGameObjectManager().RemoveGameObject(this.m_abilitySpell); this.m_abilitySpell = null; } if (this.m_retributionSpell != null) { this.GetGameObjectManager().RemoveGameObject(this.m_retributionSpell); this.m_retributionSpell = null; } } else { if (data.GetLoseHpPerTick() > 0) { this.m_loseHpTime += 64; if (this.m_loseHpTime > data.GetLoseHpInterval()) { LogicHitpointComponent hitpointComponent = this.GetHitpointComponent(); if (hitpointComponent != null) { hitpointComponent.CauseDamage(100 * data.GetLoseHpPerTick(), this.m_globalId, this); // Listener. } this.m_loseHpTime = 0; } } if (data.GetAttackCount(this.m_upgradeLevel) > 0 && this.GetCombatComponent() != null && this.GetHitpointComponent() != null && this.GetCombatComponent().GetHitCount() >= data.GetAttackCount(this.m_upgradeLevel)) { this.GetHitpointComponent().Kill(); } this.m_spawnTime = LogicMath.Max(this.m_spawnTime - 64, 0); this.m_spawnIdleTime = LogicMath.Max(this.m_spawnIdleTime - 64, 0); if (this.m_spawnTime == 0 && this.m_hasSpawnDelay) { this.m_spawnIdleTime = LogicMath.Max(10, data.GetSpawnIdle()); this.m_hasSpawnDelay = false; } if (data.GetBoostedIfAlone() || data.GetSpecialAbilityType() == LogicCharacterData.SPECIAL_ABILITY_TYPE_RAGE_ALONE && this.GetSpecialAbilityAvailable()) { if (++this.m_rageAloneTime >= 5) { this.m_level.AreaBoostAlone(this, 6); this.m_rageAloneTime = 0; } } if (this.IsHero()) { LogicHeroData heroData = (LogicHeroData)data; if (this.m_abilityTime > 0) { if (heroData.GetAbilityAttackCount(this.m_upgradeLevel) > 0 && this.GetCombatComponent().GetHitCount() >= this.m_abilityAttackCount) { Debugger.HudPrint("Hero ability: No more attacks left!"); this.m_abilityTime = 0; this.m_abilityTriggerTime = 0; this.m_activationTime = 0; } else { if (++this.m_abilityTriggerTime >= 5) { this.m_abilityTime -= 1; this.m_abilityTriggerTime = 0; this.m_level.AreaAbilityBoost(this, 5); } } } if (this.m_abilityCooldown > 0) { this.m_abilityCooldown -= 1; } if (this.m_abilitySpell != null && this.m_abilitySpell.GetHitsCompleted()) { this.GetGameObjectManager().RemoveGameObject(this.m_abilitySpell); this.m_abilitySpell = null; } } if (this.m_auraSpell == null || this.m_auraSpell.GetHitsCompleted()) { if (this.m_auraSpell != null) { this.GetGameObjectManager().RemoveGameObject(this.m_auraSpell); this.m_auraSpell = null; } if (data.GetAuraSpell(this.m_upgradeLevel) != null) { LogicHitpointComponent hitpointComponent = this.GetHitpointComponent(); if (hitpointComponent != null && hitpointComponent.GetTeam() == 0) { this.m_auraSpell = (LogicSpell)LogicGameObjectFactory.CreateGameObject(data.GetAuraSpell(this.m_upgradeLevel), this.m_level, this.m_villageType); this.m_auraSpell.SetUpgradeLevel(data.GetAuraSpellLevel(this.m_upgradeLevel)); this.m_auraSpell.SetInitialPosition(this.GetX(), this.GetY()); this.m_auraSpell.AllowDestruction(false); this.m_auraSpell.SetTeam(hitpointComponent.GetTeam()); this.GetGameObjectManager().AddGameObject(this.m_auraSpell, -1); } } } if (!this.m_retributionSpellCreated) { if (data.GetRetributionSpell(this.m_upgradeLevel) != null) { LogicHitpointComponent hitpointComponent = this.GetHitpointComponent(); if (hitpointComponent.GetHitpoints() <= hitpointComponent.GetMaxHitpoints() * data.GetRetributionSpellTriggerHealth(this.m_upgradeLevel) / 100) { this.m_retributionSpellCreated = true; this.m_retributionSpell = (LogicSpell)LogicGameObjectFactory.CreateGameObject(data.GetRetributionSpell(this.m_upgradeLevel), this.m_level, this.m_villageType); this.m_retributionSpell.SetUpgradeLevel(data.GetRetributionSpellLevel(this.m_upgradeLevel)); this.m_retributionSpell.SetPositionXY(this.GetX(), this.GetY()); this.m_retributionSpell.AllowDestruction(false); this.m_retributionSpell.SetTeam(hitpointComponent.GetTeam()); this.GetGameObjectManager().AddGameObject(this.m_retributionSpell, -1); } } } if (this.m_activationTimeState == 2) { this.m_activationTime -= 64; if (this.m_activationTime < 0) { this.m_activationTimeState = 0; this.m_activationTime = 0; } } else if (this.m_activationTimeState == 1) { this.m_activationTime -= 64; if (this.m_activationTime < 0) { this.m_activationTimeState = 2; this.m_activationTime = ((LogicHeroData)this.m_data).GetActiveDuration(); } } } this.CheckSummons(); if (this.IsAlive()) { if (data.GetAutoMergeDistance() > 0) { this.m_autoMergeTime = LogicMath.Max(this.m_autoMergeTime - 64, 0); } if (data.GetInvisibilityRadius() > 0) { this.m_level.AreaInvisibility(this.GetMidX(), this.GetMidY(), data.GetInvisibilityRadius(), 4, this.GetHitpointComponent().GetTeam()); } if (data.GetHealthReductionPerSecond() > 0) { this.GetHitpointComponent().CauseDamage(100 * data.GetHealthReductionPerSecond() / 15, 0, this); } } if (this.m_duplicate) { if (this.m_duplicateLifeTime-- <= 0) { LogicHitpointComponent hitpointComponent = this.GetHitpointComponent(); if (hitpointComponent != null) { hitpointComponent.SetHitpoints(0); this.m_level.UpdateBattleStatus(); } } } }
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); }
public void CheckDieDamage(int damage, int radius) { LogicCharacterData data = (LogicCharacterData)this.m_data; if (data.GetSpecialAbilityType() == LogicCharacterData.SPECIAL_ABILITY_TYPE_DIE_DAMAGE) { if (data.GetSpecialAbilityLevel(this.m_upgradeLevel) <= 0) { return; } } if (damage > 0 && radius > 0) { LogicHitpointComponent hitpointComponent = this.GetHitpointComponent(); if (hitpointComponent != null) { this.m_level.AreaDamage(0, this.GetX(), this.GetY(), radius, damage, null, 0, null, hitpointComponent.GetTeam(), null, 1, 0, 0, true, false, 100, 0, this, 100, 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(); }
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); } } } } } } } } }