public override void CreateReferences() { base.CreateReferences(); this.m_width = this.GetIntegerValue("Width", 0); this.m_height = this.GetIntegerValue("Height", 0); this.m_upgradeLevelCount = this.m_row.GetBiggestArraySize(); this.m_buildCost = new int[this.m_upgradeLevelCount]; this.m_rearmCost = new int[this.m_upgradeLevelCount]; this.m_townHallLevel = new int[this.m_upgradeLevelCount]; this.m_strenghtWeight = new int[this.m_upgradeLevelCount]; this.m_damage = new int[this.m_upgradeLevelCount]; this.m_damageRadius = new int[this.m_upgradeLevelCount]; this.m_ejectHousingLimit = new int[this.m_upgradeLevelCount]; this.m_numSpawns = new int[this.m_upgradeLevelCount]; this.m_constructionTimes = new int[this.m_upgradeLevelCount]; this.m_projectileData = new LogicProjectileData[this.m_upgradeLevelCount]; for (int i = 0; i < this.m_upgradeLevelCount; i++) { this.m_buildCost[i] = this.GetClampedIntegerValue("BuildCost", i); this.m_rearmCost[i] = this.GetClampedIntegerValue("RearmCost", i); this.m_townHallLevel[i] = LogicMath.Max(this.GetClampedIntegerValue("TownHallLevel", i) - 1, 0); this.m_strenghtWeight[i] = this.GetClampedIntegerValue("StrengthWeight", i); this.m_damage[i] = LogicGamePlayUtil.DPSToSingleHit(this.GetClampedIntegerValue("Damage", i), 1000); this.m_damageRadius[i] = (this.GetClampedIntegerValue("DamageRadius", i) << 9) / 100; this.m_ejectHousingLimit[i] = this.GetIntegerValue("EjectHousingLimit", i); this.m_numSpawns[i] = this.GetClampedIntegerValue("NumSpawns", i); this.m_constructionTimes[i] = 86400 * this.GetClampedIntegerValue("BuildTimeD", i) + 3600 * this.GetClampedIntegerValue("BuildTimeH", i) + 60 * this.GetClampedIntegerValue("BuildTimeM", i) + this.GetClampedIntegerValue("BuildTimeS", i); this.m_projectileData[i] = LogicDataTables.GetProjectileByName(this.GetValue("Projectile", i), this); } this.m_preferredTargetData = LogicDataTables.GetCharacterByName(this.GetValue("PreferredTarget", 0), this); this.m_preferredTargetDamageMod = this.GetIntegerValue("PreferredTargetDamageMod", 0); if (this.m_preferredTargetDamageMod == 0) { this.m_preferredTargetDamageMod = 100; } this.m_buildResourceData = LogicDataTables.GetResourceByName(this.GetValue("BuildResource", 0), this); if (this.m_buildResourceData == null) { Debugger.Error("build resource is not defined for trap: " + this.GetName()); } this.m_ejectVictims = this.GetBooleanValue("EjectVictims", 0); this.m_actionFrame = 1000 * this.GetIntegerValue("ActionFrame", 0) / 24; this.m_pushback = this.GetIntegerValue("Pushback", 0); this.m_doNotScalePushByDamage = this.GetBooleanValue("DoNotScalePushByDamage", 0); this.m_effectData = LogicDataTables.GetEffectByName(this.GetValue("Effect", 0), this); this.m_effect2Data = LogicDataTables.GetEffectByName(this.GetValue("Effect2", 0), this); this.m_effectBrokenData = LogicDataTables.GetEffectByName(this.GetValue("EffectBroken", 0), this); this.m_damageEffectData = LogicDataTables.GetEffectByName(this.GetValue("DamageEffect", 0), this); this.m_pickUpEffectData = LogicDataTables.GetEffectByName(this.GetValue("PickUpEffect", 0), this); this.m_placingEffectData = LogicDataTables.GetEffectByName(this.GetValue("PlacingEffect", 0), this); this.m_appearEffectData = LogicDataTables.GetEffectByName(this.GetValue("AppearEffect", 0), this); this.m_toggleAttackModeEffectData = LogicDataTables.GetEffectByName(this.GetValue("ToggleAttackModeEffect", 0), this); this.m_triggerRadius = (this.GetIntegerValue("TriggerRadius", 0) << 9) / 100; this.m_directionCount = this.GetIntegerValue("DirectionCount", 0); this.m_spell = LogicDataTables.GetSpellByName(this.GetValue("Spell", 0), this); this.m_airTrigger = this.GetBooleanValue("AirTrigger", 0); this.m_groundTrigger = this.GetBooleanValue("GroundTrigger", 0); this.m_healerTrigger = this.GetBooleanValue("HealerTrigger", 0); this.m_speedMod = this.GetIntegerValue("SpeedMod", 0); this.m_damageMod = this.GetIntegerValue("DamageMod", 0); this.m_durationMS = this.GetIntegerValue("DurationMS", 0); this.m_hitDelayMS = this.GetIntegerValue("HitDelayMS", 0); this.m_hitCount = this.GetIntegerValue("HitCnt", 0); this.m_minTriggerHousingLimit = this.GetIntegerValue("MinTriggerHousingLimit", 0); this.m_spawnedCharGroundData = LogicDataTables.GetCharacterByName(this.GetValue("SpawnedCharGround", 0), this); this.m_spawnedCharAirData = LogicDataTables.GetCharacterByName(this.GetValue("SpawnedCharAir", 0), this); this.m_timeBetweenSpawnsMS = this.GetIntegerValue("TimeBetweenSpawnsMs", 0); this.m_spawnInitialDelayMS = this.GetIntegerValue("SpawnInitialDelayMs", 0); this.m_throwDistance = this.GetIntegerValue("ThrowDistance", 0); this.m_hasAltMode = this.GetBooleanValue("HasAltMode", 0); this.m_enableByCalendar = this.GetBooleanValue("EnabledByCalendar", 0); if (this.m_enableByCalendar) { if (this.m_upgradeLevelCount > 1) { Debugger.Error("Temporary traps should not have upgrade levels!"); } } }
public void CreateReferences(CSVRow row, LogicData data, int idx) { this.m_row = row; this.m_data = data; this.m_index = idx; this.m_pushBack = row.GetClampedIntegerValue("PushBack", idx); this.m_airTargets = row.GetClampedBooleanValue("AirTargets", idx); this.m_groundTargets = row.GetClampedBooleanValue("GroundTargets", idx); this.m_altAttackMode = row.GetClampedBooleanValue("AltAttackMode", idx); this.m_damage = 100 * row.GetClampedIntegerValue("Damage", idx); int dps = row.GetClampedIntegerValue("DPS", idx); int attackSpeed = row.GetClampedIntegerValue("AttackSpeed", idx); int altDps = row.GetClampedIntegerValue("AltDPS", idx); int altAttackSpeed = row.GetClampedIntegerValue("AltAttackSpeed", idx); if (this.m_altAttackMode && altAttackSpeed == 0) { altAttackSpeed = attackSpeed; } int cooldownOverride = row.GetClampedIntegerValue("CoolDownOverride", idx); if (cooldownOverride == 0) { int tmp = (int)(((dps | this.m_damage) >> 31) & 0xFFFFFAEC) + 1500; if (attackSpeed > tmp) { cooldownOverride = attackSpeed - tmp; } } this.m_prepareSpeed = row.GetClampedIntegerValue("PrepareSpeed", idx); this.m_attackSpeed = attackSpeed - cooldownOverride; this.m_altAttackSpeed = altAttackSpeed - cooldownOverride; this.m_cooldownOverride = cooldownOverride; this.m_damageMulti = 100 * row.GetClampedIntegerValue("DamageMulti", idx); this.m_damageLvl2 = 100 * row.GetClampedIntegerValue("DamageLv2", idx); this.m_damageLvl3 = 100 * row.GetClampedIntegerValue("DamageLv3", idx); this.m_altDamage = this.m_damage; if (dps != 0) { if (altDps == 0) { altDps = dps; } this.m_damage = LogicGamePlayUtil.DPSToSingleHit(dps, this.m_attackSpeed + this.m_cooldownOverride); this.m_altDamage = LogicGamePlayUtil.DPSToSingleHit(altDps, this.m_altAttackSpeed + this.m_cooldownOverride); this.m_damageMulti = LogicGamePlayUtil.DPSToSingleHit(row.GetClampedIntegerValue("DPSMulti", idx), this.m_attackSpeed + this.m_cooldownOverride); this.m_damageLvl2 = LogicGamePlayUtil.DPSToSingleHit(row.GetClampedIntegerValue("DPSLv2", idx), this.m_attackSpeed + this.m_cooldownOverride); this.m_damageLvl3 = LogicGamePlayUtil.DPSToSingleHit(row.GetClampedIntegerValue("DPSLv3", idx), this.m_attackSpeed + this.m_cooldownOverride); } this.m_hitEffectData = LogicDataTables.GetEffectByName(row.GetClampedValue("HitEffect", idx), data); this.m_hitEffect2Data = LogicDataTables.GetEffectByName(row.GetClampedValue("HitEffect2", idx), data); this.m_hitEffectActiveData = LogicDataTables.GetEffectByName(row.GetClampedValue("HitEffectActive", idx), data); this.m_attackRange = (row.GetClampedIntegerValue("AttackRange", idx) << 9) / 100; this.m_damageRadius = (row.GetClampedIntegerValue("DamageRadius", idx) << 9) / 100; this.m_attackEffectData = LogicDataTables.GetEffectByName(row.GetClampedValue("AttackEffect", idx), data); this.m_altAttackEffectData = LogicDataTables.GetEffectByName(row.GetClampedValue("AttackEffectAlt", idx), data); this.m_ammoCount = row.GetClampedIntegerValue("AmmoCount", idx); this.m_attackEffect2Data = LogicDataTables.GetEffectByName(row.GetClampedValue("AttackEffect2", idx), data); this.m_attackEffectLv2Data = LogicDataTables.GetEffectByName(row.GetClampedValue("AttackEffectLv2", idx), data); this.m_attackEffectLv3Data = LogicDataTables.GetEffectByName(row.GetClampedValue("AttackEffectLv3", idx), data); this.m_transitionEffectLv2Data = LogicDataTables.GetEffectByName(row.GetClampedValue("TransitionEffectLv2", idx), data); this.m_transitionEffectLv3Data = LogicDataTables.GetEffectByName(row.GetClampedValue("TransitionEffectLv3", idx), data); this.m_altNumMultiTargets = row.GetClampedIntegerValue("AltNumMultiTargets", idx); this.m_switchTimeLv2 = row.GetClampedIntegerValue("Lv2SwitchTime", idx); this.m_switchTimeLv3 = row.GetClampedIntegerValue("Lv3SwitchTime", idx); this.m_statusEffectTime = row.GetClampedIntegerValue("StatusEffectTime", idx); this.m_speedMod = row.GetClampedIntegerValue("SpeedMod", idx); this.m_altAttackRange = (row.GetClampedIntegerValue("AltAttackRange", idx) << 9) / 100; this.m_projectileData = LogicDataTables.GetProjectileByName(row.GetClampedValue("Projectile", idx), data); this.m_altProjectileData = LogicDataTables.GetProjectileByName(row.GetClampedValue("AltProjectile", idx), data); this.m_shockwavePushStrength = row.GetClampedIntegerValue("ShockwavePushStrength", idx); this.m_hitSpellData = LogicDataTables.GetSpellByName(row.GetClampedValue("HitSpell", idx), data); this.m_hitSpellLevel = row.GetClampedIntegerValue("HitSpellLevel", idx); this.m_damage2 = 100 * row.GetClampedIntegerValue("Damage2", idx); this.m_damage2Radius = (row.GetClampedIntegerValue("Damage2Radius", idx) << 9) / 100; this.m_damage2Delay = row.GetClampedIntegerValue("Damage2Delay", idx); this.m_damage2Min = 100 * row.GetClampedIntegerValue("Damage2Min", idx); this.m_damage2FalloffStart = (row.GetClampedIntegerValue("Damage2FalloffStart", idx) << 9) / 100; this.m_damage2FalloffEnd = (row.GetClampedIntegerValue("Damage2FalloffStart", idx) << 9) / 100; if (this.m_damage2FalloffEnd < this.m_damage2FalloffStart) { Debugger.Error("Building " + row.GetName() + " has falloff end less than falloff start!"); } if (this.m_damage2FalloffEnd > this.m_damage2Radius) { Debugger.Error("Building " + row.GetName() + " has falloff end greater than the damage radius!"); } this.m_preAttackEffectData = LogicDataTables.GetEffectByName(row.GetClampedValue("PreAttackEffect", idx), data); this.m_becomesTargetableEffectData = LogicDataTables.GetEffectByName(row.GetClampedValue("BecomesTargetableEffect", idx), data); this.m_increasingDamage = row.GetClampedBooleanValue("IncreasingDamage", idx); this.m_preventsHealing = row.GetClampedBooleanValue("PreventsHealing", idx); this.m_alternatePickNewTargetDelay = row.GetClampedIntegerValue("AlternatePickNewTargetDelay", idx); this.m_shockwaveArcLength = row.GetClampedIntegerValue("ShockwaveArcLength", idx); this.m_shockwaveExpandRadius = row.GetClampedIntegerValue("ShockwaveExpandRadius", idx); this.m_targetingConeAngle = row.GetClampedIntegerValue("TargetingConeAngle", idx); this.m_penetratingProjectile = row.GetClampedBooleanValue("PenetratingProjectile", idx); this.m_penetratingRadius = (row.GetClampedIntegerValue("PenetratingRadius", idx) << 9) / 100; this.m_penetratingExtraRange = (row.GetClampedIntegerValue("PenetratingExtraRange", idx) << 9) / 100; this.m_targetGroups = row.GetClampedBooleanValue("TargetGroups", idx); this.m_fightWithGroups = row.GetClampedBooleanValue("FightWithGroups", idx); this.m_targetGroupsRadius = (row.GetClampedIntegerValue("TargetGroupsRadius", idx) << 9) / 100; this.m_targetGroupsRange = (row.GetClampedIntegerValue("TargetGroupsRange", idx) << 9) / 100; this.m_targetGroupsMinWeight = row.GetClampedIntegerValue("TargetGroupsMinWeight", idx); this.m_wakeUpSpace = row.GetClampedIntegerValue("WakeUpSpace", idx); this.m_wakeUpSpeed = row.GetClampedIntegerValue("WakeUpSpeed", idx); this.m_preferredTargetData = LogicDataTables.GetCharacterByName(row.GetClampedValue("PreferredTarget", idx), data); this.m_preferredTargetDamageMod = row.GetClampedIntegerValue("PreferredTargetDamageMod", idx); this.m_preferredTargetNoTargeting = row.GetClampedBooleanValue("PreferredTargetNoTargeting", idx); this.m_altAirTargets = row.GetClampedBooleanValue("AltAirTargets", idx); this.m_altGroundTargets = row.GetClampedBooleanValue("AltGroundTargets", idx); this.m_altMultiTargets = row.GetClampedBooleanValue("AltMultiTargets", idx); this.m_minAttackRange = (row.GetClampedIntegerValue("MinAttackRange", idx) << 9) / 100; if (this.m_preferredTargetData == null) { this.m_preferredTargetData = LogicDataTables.GetBuildingClassByName(row.GetClampedValue("PreferedTargetBuildingClass", idx), data); if (this.m_preferredTargetData == null) { this.m_preferredTargetData = LogicDataTables.GetBuildingByName(row.GetClampedValue("PreferedTargetBuilding", idx), data); } this.m_preferredTargetDamageMod = row.GetClampedIntegerValue("PreferedTargetDamageMod", idx); if (this.m_preferredTargetDamageMod == 0) { this.m_preferredTargetDamageMod = 100; } } this.m_summonTroopCount = row.GetClampedIntegerValue("SummonTroopCount", idx); this.m_summonCooldown = row.GetClampedIntegerValue("SummonCooldown", idx); this.m_summonEffectData = LogicDataTables.GetEffectByName(row.GetClampedValue("SummonEffect", idx), data); this.m_summonLimit = row.GetClampedIntegerValue("SummonLimit", idx); this.m_summonTroopData = LogicDataTables.GetCharacterByName(row.GetClampedValue("SummonTroop", idx), data); this.m_spawnOnAttack = row.GetClampedBooleanValue("SpawnOnAttack", idx); this.m_hideEffectData = LogicDataTables.GetEffectByName(row.GetClampedValue("HideEffect", idx), data); this.m_rageProjectileData = LogicDataTables.GetProjectileByName(row.GetClampedValue("RageProjectile", idx), data); this.m_projectileBounces = row.GetClampedIntegerValue("ProjectileBounces", idx); this.m_selfAsAoeCenter = row.GetClampedBooleanValue("SelfAsAoeCenter", idx); if (this.m_damage2Delay > this.m_cooldownOverride + this.m_attackSpeed) { Debugger.Error(row.GetName() + " has Damage2Delay greater than the attack speed!"); } if (this.m_ammoCount > 0 && (this.m_attackSpeed & 63) != 0) { Debugger.Error(string.Format("Invalid attack speed {0} (must be multiple of 64)", this.m_attackSpeed)); } this.m_burstCount = row.GetClampedIntegerValue("BurstCount", idx); this.m_burstDelay = row.GetClampedIntegerValue("BurstDelay", idx); this.m_altBurstCount = row.GetClampedIntegerValue("AltBurstCount", idx); this.m_altBurstDelay = row.GetClampedIntegerValue("AltBurstDelay", idx); this.m_dummyProjectileCount = row.GetClampedIntegerValue("DummyProjectileCount", idx); this.m_attackEffectSharedData = LogicDataTables.GetEffectByName(row.GetClampedValue("AttackEffectShared", idx), data); this.m_chainAttackDistance = row.GetClampedIntegerValue("ChainAttackDistance", idx); this.m_newTargetAttackDelay = row.GetClampedIntegerValue("NewTargetAttackDelay", idx); if (this.m_newTargetAttackDelay > 0) { this.m_newTargetAttackDelay = LogicMath.Clamp(attackSpeed - this.m_newTargetAttackDelay, 0, attackSpeed); } }