public override void Tick() { if (!initialized) { this.nextSearch = Find.TickManager.TicksGame + Rand.Range(280, 320); initialized = true; } if (Find.TickManager.TicksGame >= this.nextSearch) { this.nextSearch = Find.TickManager.TicksGame + Rand.Range(280, 320); if (defensive) { Pawn e = TM_Calc.FindNearbyEnemy(this.Position, this.Map, this.Faction, 20, 0); if (e != null && TM_Calc.HasLoSFromTo(this.Position, e, this, 0, 20)) { Projectile firebolt = ThingMaker.MakeThing(ThingDef.Named("Projectile_Firebolt"), null) as Projectile; TM_CopyAndLaunchProjectile.CopyAndLaunchProjectile(firebolt, this, e, e, ProjectileHitFlags.All, null); } } if (buffWarm) { List <Pawn> pList = TM_Calc.FindAllPawnsAround(this.Map, this.Position, 7, this.Faction, true); if (pList != null && pList.Count > 0) { for (int i = 0; i < pList.Count; i++) { Pawn p = pList[i]; if (p.health != null && p.health.hediffSet != null) { HealthUtility.AdjustSeverity(p, TorannMagicDefOf.TM_WarmHD, 0.18f); } } } } if (boostJoy) { List <Pawn> pList = TM_Calc.FindAllPawnsAround(this.Map, this.Position, 7, this.Faction, true); if (pList != null && pList.Count > 0) { for (int i = 0; i < pList.Count; i++) { Pawn p = pList[i]; if (p.needs != null && p.needs.joy != null) { Need joy = p.needs.TryGetNeed(NeedDefOf.Joy); if (joy != null) { joy.CurLevel += Rand.Range(.01f, .02f); } } } } } } base.Tick(); }
public override void CompPostTick(ref float severityAdjustment) { base.CompPostTick(ref severityAdjustment); bool flag = base.Pawn != null; if (flag) { if (initializing) { initializing = false; this.Initialize(); } } if (Find.TickManager.TicksGame >= this.nextLightningTick && comp != null) { if (canCastLightning || comp?.MagicData.MagicPowerSkill_Cantrips.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Cantrips_ver").level >= 13) { canCastLightning = true; this.nextLightningTick = Find.TickManager.TicksGame + Rand.Range(400, 800); if (this.Pawn.Drafted && !this.Pawn.Downed && this.Pawn.Map != null && this.Pawn.Spawned) { Pawn e = TM_Calc.FindNearbyEnemy(this.Pawn.Position, this.Pawn.Map, this.Pawn.Faction, 24, 0); if (e != null && TM_Calc.HasLoSFromTo(this.Pawn.Position, e, this.Pawn, 0, 25)) { Projectile lightning = ThingMaker.MakeThing(ThingDef.Named("Laser_LightningBolt"), null) as Projectile; TM_CopyAndLaunchProjectile.CopyAndLaunchProjectile(lightning, this.Pawn, e, e, ProjectileHitFlags.All, null); } } } } if (this.glower != null && glower.parent != null && comp != null) { if (this.Pawn != null && this.Pawn.Map != null) { if (oldPos != default(IntVec3)) { this.Pawn.Map.mapDrawer.MapMeshDirty(oldPos, MapMeshFlag.Things); this.Pawn.Map.glowGrid.DeRegisterGlower(glower); } if ((this.Pawn.Map.skyManager.CurSkyGlow < 0.7f || this.Pawn.Position.Roofed(Pawn.Map)) && !comp.mageLightSet) { this.Pawn.Map.mapDrawer.MapMeshDirty(this.Pawn.Position, MapMeshFlag.Things); oldPos = this.Pawn.Position; this.Pawn.Map.glowGrid.RegisterGlower(glower); } } } else { initializing = false; this.Initialize(); } }
public static void DoReversalRandomTarget(DamageInfo dinfo, Pawn reflectingPawn, float minRange, float maxRange) { Thing instigator = dinfo.Instigator; if (instigator is Pawn) { Pawn shooterPawn = instigator as Pawn; if (dinfo.Weapon != null && !dinfo.Weapon.IsMeleeWeapon && dinfo.WeaponBodyPartGroup == null) { Pawn randomTarget = null; randomTarget = TM_Calc.FindNearbyEnemy(reflectingPawn, (int)maxRange); if (randomTarget != null) { TM_CopyAndLaunchProjectile.CopyAndLaunchThing(shooterPawn.equipment.PrimaryEq.PrimaryVerb.verbProps.defaultProjectile, reflectingPawn, randomTarget, randomTarget, ProjectileHitFlags.All, null); } } } if (instigator is Building) { Building turret = instigator as Building; ThingDef projectile = null; if (turret.def.building.turretGunDef != null) { ThingDef turretGun = turret.def.building.turretGunDef; for (int i = 0; i < turretGun.Verbs.Count; i++) { if (turretGun.Verbs[i].defaultProjectile != null) { projectile = turretGun.Verbs[i].defaultProjectile; } } } if (projectile != null) { Thing target = null; if ((turret.Position - reflectingPawn.Position).LengthHorizontal <= maxRange) { target = turret; } else { target = TM_Calc.FindNearbyEnemy(reflectingPawn, (int)maxRange); } TM_CopyAndLaunchProjectile.CopyAndLaunchThing(projectile, reflectingPawn, target, target, ProjectileHitFlags.All, null); } } }
public void TickAction() { Pawn victim = TM_Calc.FindNearbyEnemy(this.Pawn, 2); if (victim != null) { TM_Action.DamageEntities(victim, null, Rand.Range(4, 6), DamageDefOf.Burn, this.Pawn); TM_MoteMaker.ThrowFlames(victim.DrawPos, victim.Map, Rand.Range(.1f, .4f)); } if (Rand.Chance(.2f)) { TM_Action.DamageEntities(this.Pawn, null, Rand.Range(3, 5), 5f, DamageDefOf.Burn, this.Pawn); TM_MoteMaker.ThrowFlames(this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .2f)); } }
public void SearchForTargets(IntVec3 center, float radius) { if (faction == null) { faction = Faction.OfPlayer; } Pawn target = TM_Calc.FindNearbyEnemy(center, Map, faction, radius, 0f); if (target != null) { CellRect cellRect = CellRect.CenteredOn(target.Position, 2); cellRect.ClipInsideMap(base.Map); DrawStrike(center, target.Position.ToVector3()); for (int k = 0; k < Rand.Range(1, 5); k++) { IntVec3 randomCell = cellRect.RandomCell; GenExplosion.DoExplosion(randomCell, base.Map, Rand.Range(.4f, .8f), TMDamageDefOf.DamageDefOf.TM_Lightning, this.launcher, Mathf.RoundToInt(Rand.Range(4, 6)), 0, SoundDefOf.Thunder_OnMap, null, null, null, null, 0f, 1, false, null, 0f, 1, 0.1f, true); } GenExplosion.DoExplosion(target.Position, base.Map, 1f, TMDamageDefOf.DamageDefOf.TM_Lightning, this.launcher, Mathf.RoundToInt(Rand.Range(5, 9) * this.arcaneDmg), 0, SoundDefOf.Thunder_OffMap, null, null, null, null, 0f, 1, false, null, 0f, 1, 0.1f, true); this.lastStrike = this.age; } DrawStrikeFading(); }
public override void CompPostTick(ref float severityAdjustment) { if (base.Pawn != null & base.parent != null && !this.Pawn.Dead) { if (!initialized) { initialized = true; this.Initialize(); } base.CompPostTick(ref severityAdjustment); if (Find.TickManager.TicksGame % 60 == 0 && initialized) { DeterminePsionicHD(); severityAdjustment += (this.Pawn.GetStatValue(StatDefOf.PsychicSensitivity, false) * Rand.Range(.04f, .12f)); if (Find.Selector.FirstSelectedObject == this.Pawn) { HediffStage hediffStage = this.Pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_PsionicHD"), false).CurStage; hediffStage.label = this.parent.Severity.ToString("0.00") + "%"; } Hediff hediff = this.Pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_Artifact_PsionicBoostHD); float maxSev = 100; if (hediff != null) { maxSev += hediff.Severity; } this.parent.Severity = Mathf.Clamp(this.parent.Severity, 0, maxSev); } if (base.Pawn.Spawned && !this.Pawn.Downed && base.Pawn.Map != null && comp != null) { if (this.doPsionicAttack) { this.ticksTillPsionicStrike--; if (this.ticksTillPsionicStrike <= 0) { this.doPsionicAttack = false; if (threat != null && !threat.Destroyed && !threat.Dead && !threat.Downed) { TM_MoteMaker.MakePowerBeamMotePsionic(threat.DrawPos.ToIntVec3(), threat.Map, 2f, 2f, .7f, .1f, .6f); DamageInfo dinfo2 = new DamageInfo(TMDamageDefOf.DamageDefOf.TM_PsionicInjury, Rand.Range(6, 12) * this.Pawn.GetStatValue(StatDefOf.PsychicSensitivity, false) + (2 * VerVal), 0, -1, this.Pawn, null, null, DamageInfo.SourceCategory.ThingOrUnknown, this.threat); this.threat.TakeDamage(dinfo2); } } } if (comp.usePsionicAugmentationToggle && this.Pawn.drafter != null && this.Pawn.CurJob != null) { if (Find.TickManager.TicksGame % 600 == 0 && !this.Pawn.Drafted) { if (this.parent.Severity >= 95 && this.Pawn.CurJob.targetA != null && this.Pawn.CurJob.targetA.Thing != null) { if ((this.Pawn.Position - this.Pawn.CurJob.targetA.Thing.Position).LengthHorizontal > 20 && (this.Pawn.Position - this.Pawn.CurJob.targetA.Thing.Position).LengthHorizontal < 300 && this.Pawn.CurJob.locomotionUrgency >= LocomotionUrgency.Jog && this.Pawn.CurJob.bill == null) { this.parent.Severity -= 10f; if (this.EffVal == 0) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicSpeedHD"), 1f + .02f * this.EffVal); } else if (this.EffVal == 1) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicSpeedHD_I"), 1f + .02f * this.EffVal); } else if (this.EffVal == 2) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicSpeedHD_II"), 1f + .02f * this.EffVal); } else { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicSpeedHD_III"), 1f + .02f * this.EffVal); } for (int i = 0; i < 12; i++) { float direction = Rand.Range(0, 360); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi"), this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction); } comp.MightUserXP += Rand.Range(10, 15); } if ((this.Pawn.Position - this.Pawn.CurJob.targetA.Thing.Position).LengthHorizontal < 2 && (this.Pawn.CurJob.bill != null || this.Pawn.CurJob.def.defName == "Sow" || this.Pawn.CurJob.def.defName == "FinishFrame" || this.Pawn.CurJob.def.defName == "Deconstruct" || this.Pawn.CurJob.def.defName == "Repair" || this.Pawn.CurJob.def.defName == "Clean" || this.Pawn.CurJob.def.defName == "Mine" || this.Pawn.CurJob.def.defName == "SmoothFloor" || this.Pawn.CurJob.def.defName == "SmoothWall" || this.Pawn.CurJob.def.defName == "Harvest" || this.Pawn.CurJob.def.defName == "HarvestDesignated" || this.Pawn.CurJob.def.defName == "CutPlant" || this.Pawn.CurJob.def.defName == "CutPlantDesignated")) { this.parent.Severity -= 12f; if (this.PwrVal == 0) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicManipulationHD"), 1f + .02f * this.PwrVal); } else if (this.PwrVal == 1) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicManipulationHD_I"), 1f + .02f * this.PwrVal); } else if (this.PwrVal == 2) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicManipulationHD_II"), 1f + .02f * this.PwrVal); } else { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicManipulationHD_III"), 1f + .02f * this.PwrVal); } for (int i = 0; i < 12; i++) { float direction = Rand.Range(0, 360); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi"), this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction); } comp.MightUserXP += Rand.Range(10, 15); } } } if (this.parent.Severity >= 20) { if (Find.TickManager.TicksGame % 180 == 0 && (this.Pawn.Drafted || !this.Pawn.IsColonist) && ((this.Pawn.equipment.Primary != null && !this.Pawn.equipment.Primary.def.IsRangedWeapon) || this.Pawn.equipment.Primary == null)) { if (this.Pawn.CurJob.targetA != null && this.Pawn.CurJob.targetA.Thing != null && this.Pawn.CurJob.targetA.Thing is Pawn && this.Pawn.CurJobDef == JobDefOf.AttackMelee) { //Log.Message("performing psionic dash - curjob " + this.Pawn.CurJob); //Log.Message("curjob def " + this.Pawn.CurJob.def.defName); //Log.Message("target " + this.Pawn.CurJob.targetA.Thing); //Log.Message("target range " + (this.Pawn.CurJob.targetA.Thing.Position - this.Pawn.Position).LengthHorizontal); Pawn targetPawn = this.Pawn.CurJob.targetA.Thing as Pawn; float targetDistance = (this.Pawn.Position - targetPawn.Position).LengthHorizontal; if (targetDistance > 3 && targetDistance < (12 + EffVal) && targetPawn.Map != null && !targetPawn.Downed) { for (int i = 0; i < 12; i++) { float direction = Rand.Range(0, 360); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi"), this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction); } FlyingObject_PsionicLeap flyingObject = (FlyingObject_PsionicLeap)GenSpawn.Spawn(ThingDef.Named("FlyingObject_PsionicLeap"), this.Pawn.Position, this.Pawn.Map); flyingObject.Launch(this.Pawn, this.Pawn.CurJob.targetA.Thing, this.Pawn); HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicHD"), -3f); comp.Stamina.CurLevel -= .03f; comp.MightUserXP += Rand.Range(20, 30); } } } if (this.nextPsionicAttack < Find.TickManager.TicksGame && this.Pawn.Drafted && comp.usePsionicMindAttackToggle) { if (this.Pawn.CurJob.def != TorannMagicDefOf.JobDriver_PsionicBarrier && VerVal > 0) { this.threat = TM_Calc.FindNearbyEnemy(this.Pawn, 20 + (2 * verVal)); // GetNearbyTarget(20 + (2 * VerVal)); if (threat != null) { //start psionic attack; ends after delay SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), MaintenanceType.None); TorannMagicDefOf.TM_Implosion.PlayOneShot(info); Effecter psionicAttack = TorannMagicDefOf.TM_GiantExplosion.Spawn(); psionicAttack.Trigger(new TargetInfo(threat.Position, threat.Map, false), new TargetInfo(threat.Position, threat.Map, false)); psionicAttack.Cleanup(); for (int i = 0; i < 12; i++) { float direction = Rand.Range(0, 360); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi"), this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction); } float weaponModifier = 1; if (this.Pawn.equipment.Primary != null) { if (this.Pawn.equipment.Primary.def.IsRangedWeapon) { StatModifier wpnMass = this.Pawn.equipment.Primary.def.statBases.FirstOrDefault((StatModifier x) => x.stat.defName == "Mass"); weaponModifier = Mathf.Clamp(wpnMass.value, .8f, 6); } else //assume melee weapon { StatModifier wpnMass = this.Pawn.equipment.Primary.def.statBases.FirstOrDefault((StatModifier x) => x.stat.defName == "Mass"); weaponModifier = Mathf.Clamp(wpnMass.value, .6f, 4); } } else //unarmed { weaponModifier = .4f; } this.nextPsionicAttack = Find.TickManager.TicksGame + (int)(Mathf.Clamp((600 - (60 * verVal)) * weaponModifier, 120, 900)); float energyCost = Mathf.Clamp((10f - VerVal) * weaponModifier, 2f, 12f); HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicHD"), -energyCost); comp.MightUserXP += Rand.Range(8, 12); this.doPsionicAttack = true; this.ticksTillPsionicStrike = 24; } } } } } } } }
private void ScanForTarget() { //Log.Message("totem has faction " + this.Faction); target = TM_Calc.FindNearbyEnemy(this.Position, this.Map, this.Faction, this.range, 0); }
public override void Tick() { //base.Tick(); if (Manned) { if (!initialized) { comp = mannableComp.ManningPawn.GetComp <CompAbilityUserMight>(); this.verVal = mannableComp.ManningPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_60mmMortar.FirstOrDefault((MightPowerSkill x) => x.label == "TM_60mmMortar_ver").level; this.pwrVal = mannableComp.ManningPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_60mmMortar.FirstOrDefault((MightPowerSkill x) => x.label == "TM_60mmMortar_pwr").level; this.effVal = mannableComp.ManningPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_60mmMortar.FirstOrDefault((MightPowerSkill x) => x.label == "TM_60mmMortar_eff").level; this.mortarTicksToFire = Find.TickManager.TicksGame + (300); this.mortarMaxRange += (verVal * 10); if (verVal >= 3) { this.mortarCount++; } this.mortarAccuracy = mortarAccuracy - (.7f * effVal); this.setTarget = null; this.targetingParameters.canTargetBuildings = true; this.targetingParameters.canTargetPawns = true; this.targetingParameters.canTargetLocations = true; this.initialized = true; } if (!mannableComp.ManningPawn.DestroyedOrNull() && !mannableComp.ManningPawn.Dead && !mannableComp.ManningPawn.Downed) { if (this.mortarTicksToFire < Find.TickManager.TicksGame && this.mortarCount > 0) { this.mortarTicksToFire = Find.TickManager.TicksGame + (60 - (6 * verVal)); LocalTargetInfo target = null; if (this.setTarget != null) { target = setTarget; } else { target = TM_Calc.FindNearbyEnemy(this.Position, this.Map, this.Faction, this.mortarMaxRange, this.mortarMinRange); } if (target != null && target.Cell.IsValid && target.Cell.DistanceToEdge(this.Map) > 5) { bool flag = target.Cell != default(IntVec3); if (flag) { IntVec3 rndTarget = target.Cell; rndTarget.x += Mathf.RoundToInt(Rand.Range(-mortarAccuracy, mortarAccuracy)); rndTarget.z += Mathf.RoundToInt(Rand.Range(-mortarAccuracy, mortarAccuracy)); Thing launchedThing = new Thing() { def = projectileDef }; int arc = 1; if (target.Cell.x >= this.Position.x) { arc = -1; } FlyingObject_Advanced flyingObject = (FlyingObject_Advanced)GenSpawn.Spawn(this.projectileDef, this.Position, this.Map); flyingObject.AdvancedLaunch(this, null, 0, Mathf.Clamp(Rand.Range(50, 60), 0, this.Position.DistanceToEdge(this.Map)), false, this.DrawPos, rndTarget, launchedThing, Rand.Range(35, 40), true, Rand.Range(14 + pwrVal, 20 + (2 * pwrVal)), (3f + (.35f * pwrVal)), DamageDefOf.Bomb, null, arc, true); this.mortarCount--; } SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Position, this.Map, false), MaintenanceType.None); info.pitchFactor = 1.6f; info.volumeFactor = .7f; SoundDef.Named("Mortar_LaunchA").PlayOneShot(info); } } } if (this.mortarCount <= 0) { this.mannableComp.ManningPawn.jobs.EndCurrentJob(JobCondition.Succeeded); this.Destroy(DestroyMode.Vanish); } } else { this.Destroy(DestroyMode.Vanish); } }
public override void Tick() { base.Tick(); //if (!manPawn.DestroyedOrNull() && !manPawn.Dead && !manPawn.Downed && manPawn.Position == this.InteractionCell) if (Manned) { if (!initialized) { comp = mannableComp.ManningPawn.GetComp <CompAbilityUserMagic>(); this.verVal = mannableComp.ManningPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_TechnoTurret.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_TechnoTurret_ver").level; this.pwrVal = mannableComp.ManningPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_TechnoTurret.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_TechnoTurret_pwr").level; this.effVal = mannableComp.ManningPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_TechnoTurret.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_TechnoTurret_eff").level; if (this.verVal >= 5) { this.rocketTicksToFire = 600 - ((verVal - 5) * 20); this.rocketCount = verVal / 5; this.rocketManaCost = .04f - (.001f * this.effVal); } if (this.verVal >= 10) { this.mortarTicksToFire = 900 - ((verVal - 10) * 40); this.mortarMaxRange += (verVal - 10) * 5; this.mortarManaCost = .08f - (.002f * effVal); } this.initialized = true; } if (!mannableComp.ManningPawn.DestroyedOrNull() && !mannableComp.ManningPawn.Dead && !mannableComp.ManningPawn.Downed) { if (this.verVal >= 5 && this.nextRocketFireTick < Find.TickManager.TicksGame && this.TargetCurrentlyAimingAt != null && comp.Mana.CurLevel >= this.rocketManaCost) { if (this.TargetCurrentlyAimingAt.Cell.IsValid && this.TargetCurrentlyAimingAt.Cell.DistanceToEdge(this.Map) > 5 && (this.TargetCurrentlyAimingAt.Cell - this.Position).LengthHorizontal >= this.rocketMinRange) { bool flag = this.TargetCurrentlyAimingAt.Cell != default(IntVec3); if (flag) { Thing launchedThing = new Thing() { def = ThingDef.Named("FlyingObject_RocketSmall") }; FlyingObject_Advanced flyingObject = (FlyingObject_Advanced)GenSpawn.Spawn(ThingDef.Named("FlyingObject_RocketSmall"), this.Position, this.Map); flyingObject.AdvancedLaunch(this, ThingDef.Named("Mote_Smoke"), 1, Rand.Range(5, 25), false, this.DrawPos, this.TargetCurrentlyAimingAt.Cell, launchedThing, Rand.Range(32, 38), true, Mathf.RoundToInt(Rand.Range(22f, 30f) * comp.arcaneDmg), 2, TMDamageDefOf.DamageDefOf.TM_PersonnelBombDD, null); this.rocketCount--; SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Position, this.Map, false), MaintenanceType.None); info.pitchFactor = 1.3f; info.volumeFactor = 1.5f; TorannMagicDefOf.TM_AirWoosh.PlayOneShot(info); } if (rocketCount <= 0) { this.rocketCount = verVal / 5; this.nextRocketFireTick = Find.TickManager.TicksGame + (600 - ((verVal - 5) * 20)); comp.Mana.CurLevel -= this.rocketManaCost; comp.MagicUserXP += Rand.Range(9, 12); } else { this.nextRocketFireTick = Find.TickManager.TicksGame + 20; } } } if (this.verVal >= 10 && this.mortarTicksToFire < Find.TickManager.TicksGame && comp.Mana.CurLevel >= this.mortarManaCost) { this.mortarTicksToFire = Find.TickManager.TicksGame + (900 - ((verVal - 10) * 40)); Pawn target = TM_Calc.FindNearbyEnemy(this.Position, this.Map, this.Faction, this.mortarMaxRange, this.mortarMinRange); if (target != null && target.Position.DistanceToEdge(this.Map) > 8) { bool flag = target.Position != default(IntVec3); if (flag) { for (int i = 0; i < 5; i++) { IntVec3 rndTarget = target.Position; rndTarget.x += Rand.RangeInclusive(-6, 6); rndTarget.z += Rand.RangeInclusive(-6, 6); Projectile newProjectile = (Projectile)GenSpawn.Spawn(ThingDef.Named("Bullet_Shell_TechnoTurretExplosive"), this.Position, this.Map, WipeMode.Vanish); newProjectile.Launch(this, rndTarget, target, ProjectileHitFlags.All, null); } } SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Position, this.Map, false), MaintenanceType.None); info.pitchFactor = 1.3f; info.volumeFactor = .8f; SoundDef.Named("Mortar_LaunchA").PlayOneShot(info); comp.Mana.CurLevel -= this.mortarManaCost; comp.MagicUserXP += Rand.Range(12, 15); } } if (CanExtractShell && MannedByColonist) { CompChangeableProjectile compChangeableProjectile = gun.TryGetComp <CompChangeableProjectile>(); if (!compChangeableProjectile.allowedShellsSettings.AllowedToAccept(compChangeableProjectile.LoadedShell)) { ExtractShell(); } } if (forcedTarget.IsValid && !CanSetForcedTarget) { ResetForcedTarget(); } if (forcedTarget.ThingDestroyed) { ResetForcedTarget(); } if ((powerComp == null || powerComp.PowerOn) && (mannableComp == null || mannableComp.MannedNow) && base.Spawned) { GunCompEq.verbTracker.VerbsTick(); if (!stunner.Stunned && AttackVerb.state != VerbState.Bursting) { if (WarmingUp) { burstWarmupTicksLeft--; if (burstWarmupTicksLeft == 0) { BeginBurst(); } } else { if (burstCooldownTicksLeft > 0) { burstCooldownTicksLeft--; } if (burstCooldownTicksLeft <= 0 && this.IsHashIntervalTick(10)) { TryStartShootSomething(canBeginBurstImmediately: true); } } top.TurretTopTick(); } } else { ResetCurrentTarget(); } } } else { for (int i = 0; i < 4; i++) { Vector3 rndPos = this.DrawPos; rndPos.x += Rand.Range(-.5f, .5f); rndPos.z += Rand.Range(-.5f, .5f); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_SparkFlash"), rndPos, this.Map, Rand.Range(.6f, .8f), .1f, .05f, .05f, 0, 0, 0, Rand.Range(0, 360)); MoteMaker.ThrowSmoke(rndPos, this.Map, Rand.Range(.8f, 1.2f)); rndPos = this.DrawPos; rndPos.x += Rand.Range(-.5f, .5f); rndPos.z += Rand.Range(-.5f, .5f); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_ElectricalSpark"), rndPos, this.Map, Rand.Range(.4f, .7f), .2f, .05f, .1f, 0, 0, 0, Rand.Range(0, 360)); } GenExplosion.DoExplosion(this.Position, this.Map, 1f, DamageDefOf.EMP, this, 0, 0, SoundDefOf.Crunch, null, null, this, null, 0, 0, false, null, 0, 0, 0, false); this.Destroy(DestroyMode.Vanish); } }
public void UpdateAction(SoLAction withAction = SoLAction.Pending) { SoLAction inAction = this.solAction; Vector3 destTarget = this.ExactPosition; this.curveVariance = 0; //Log.Message("action for " + solAction.ToString() + " queued action: " + queuedAction.ToString()); if (queuedAction != SoLAction.Null) { solAction = queuedAction; queuedAction = SoLAction.Null; } if (solAction == SoLAction.Pending || solAction == SoLAction.Goto) { if (this.pawn.GetPosture() == PawnPosture.LayingInBed || this.pawn.CurJobDef == JobDefOf.LayDown) { if (!pawn.Awake() && LightEnergy > 5f) { Action_Sleeping(out destTarget); } //pawn injured? } else if (this.pawn.Drafted) { this.delayCount++; if (LightEnergy > 20 && EnergyChance && this.delayCount > 2) { Pawn p = TM_Calc.FindNearbyEnemy(this.pawn, (int)AttackTarget_ShortRange); if (p != null && TM_Calc.HasLoSFromTo(pawn.Position, p, pawn, 0, AttackTarget_ShortRange)) { Action_AttackCharge(p, out destTarget); queuedAction = SoLAction.Limbo; } else { if (LightEnergy > 30 && this.delayCount > 6) { p = TM_Calc.FindNearbyEnemy(this.pawn.Position, this.pawn.Map, this.pawn.Faction, AttackTarget_MaxRange, AttackTarget_ShortRange); if (p != null && TM_Calc.HasLoSFromTo(pawn.Position, p, pawn, 0, AttackTarget_MaxRange)) { Action_Attack(p, out destTarget); queuedAction = SoLAction.Returning; } else { Action_Hover(out destTarget); } } else { Action_Hover(out destTarget); } } } else { Action_Hover(out destTarget); } } else if (this.pawn.Downed && this.pawn.health.hediffSet.GetInjuriesTendable().Count() > 0 && LightEnergy > 10) { Action_GotoTarget(this.pawn.DrawPos, speed_jog, out destTarget); this.assignedTarget = this.pawn; queuedAction = SoLAction.Guarding; } else if (this.shouldGlow) { this.shouldGlow = false; Action_GotoTarget(this.glowCenter.ToVector3Shifted(), this.speed_jog, out destTarget); queuedAction = SoLAction.Glow; } else if (LightEnergy > 20 && EnergyChance) { Pawn p = TM_Calc.FindNearbyInjuredPawnOther(this.pawn, 10, 10f); this.delayCount++; if (this.delayCount > 1 && p != null && p.Downed && TM_Calc.HasLoSFromTo(this.pawn.Position, p, this.pawn, 0, 10) && p.health.hediffSet.GetInjuriesTendable().Count() > 0) { Action_GotoTarget(p.DrawPos, speed_dash, out destTarget); queuedAction = SoLAction.Guarding; this.assignedTarget = p; } else if (LightEnergy > 60 && EnergyChance) { if (this.delayCount > 2) { p = TM_Calc.FindNearbyPawn(this.pawn, 10); if (p != null && p.needs != null && TM_Calc.HasLoSFromTo(this.pawn.Position, p, this.pawn, 0, 10)) { if ((this.pawn.CurJobDef.joyKind != null || this.pawn.CurJobDef == JobDefOf.Wait_Wander || this.pawn.CurJobDef == JobDefOf.GotoWander) && this.pawn.needs.joy.CurLevelPercentage < .5f) { this.delayCount = 0; Action_JoyBurst(this.pawn.DrawPos, out destTarget); } else if (p.needs.joy != null && (p.CurJobDef.joyKind != null || p.CurJobDef == JobDefOf.Wait_Wander || p.CurJobDef == JobDefOf.GotoWander) && p.needs.joy.CurLevelPercentage < .5f) { this.delayCount = 0; Action_JoyBurst(p.DrawPos, out destTarget); } else if (this.delayCount > 3 && p.needs.mood != null && p.needs.mood.thoughts != null && p.needs.mood.thoughts.memories != null && p.needs.mood.thoughts.memories.GetFirstMemoryOfDef(TorannMagicDefOf.TM_BrightDayTD) == null) { this.delayCount = 0; Action_GotoTarget(p.DrawPos, speed_jog, out destTarget); this.assignedTarget = p; queuedAction = SoLAction.BrightenDay; //action circle target } else { Action_Hover(out destTarget); } } else { Action_Hover(out destTarget); } } else { Action_Hover(out destTarget); } } else { Action_Hover(out destTarget); } } //else if(LightEnergy > 90 && (EnergyChance && EnergyChance && EnergyChance)) //{ // Action_Clean(out destTarget); //} else { this.delayCount = 0; Action_Hover(out destTarget); } } else if (solAction == SoLAction.BrightenDay) { if (this.assignedTarget != null && this.assignedTarget is Pawn) { Pawn p = this.assignedTarget as Pawn; ActualLightCost(6f); p.needs.mood.thoughts.memories.TryGainMemory(TorannMagicDefOf.TM_BrightDayTD); Action_CircleTarget(this.assignedTarget, out destTarget); queuedAction = SoLAction.Returning; } } else if (solAction == SoLAction.Glow) { if (this.glowing) { StopGlow(); } else { DoGlow(); } Action_Return(); } else if (solAction == SoLAction.Returning) { Action_Return(); } else if (solAction == SoLAction.Guarding) { if (LightEnergy > 10 && this.assignedTarget != null && this.assignedTarget is Pawn) { Pawn p = this.assignedTarget as Pawn; if (p.health.hediffSet.GetInjuriesTendable().Count() > 0) { this.ticksToImpact = 300; ActualLightCost(2f); CauterizeWounds(p); queuedAction = SoLAction.Guarding; } else { Action_Hover(out destTarget); } } else { Action_Hover(out destTarget); } } else if (solAction == SoLAction.Limbo) { Action_FromLimbo(out destTarget); } if (solAction != SoLAction.Attacking && solAction != SoLAction.Returning && solAction != SoLAction.Guarding && solAction != SoLAction.Circling) { this.destination = destTarget; this.ticksToImpact = this.StartingTicksToImpact; } //Log.Message("ending update action, new action: " + solAction.ToString() + " speed: " + this.speed + " delay action: " + this.delayCount + " light energy: "+ LightEnergy); if (this.solAction != inAction && this.solAction != SoLAction.Hovering && this.solAction != SoLAction.Sleeping) { this.delayCount = 0; } }
public override void Tick() { if (!initialized) { initialized = true; this.nextSearch = Find.TickManager.TicksGame + Rand.Range(180, 220); } if (Find.TickManager.TicksGame % 8 == 0) { this.matRng++; if (this.matRng >= 4) { matRng = 0; } } if (Find.TickManager.TicksGame >= this.nextSearch) { this.nextSearch = Find.TickManager.TicksGame + Rand.Range(180, 220); if (defensive) { Pawn e = TM_Calc.FindNearbyEnemy(this.Position, this.Map, this.factionInt, 20, 0); if (e != null && TM_Calc.HasLoSFromTo(this.Position, e, this, 0, 20)) { GenExplosion.DoExplosion(e.Position, this.Map, .4f, DamageDefOf.Stun, this, 4, 1f); if (e.RaceProps.IsMechanoid || TM_Calc.IsRobotPawn(e)) { GenExplosion.DoExplosion(e.Position, this.Map, .4f, TMDamageDefOf.DamageDefOf.TM_ElectricalBurn, this, 8, 1f); } } } if (buffShock) { List <Pawn> pList = TM_Calc.FindAllPawnsAround(this.Map, this.Position, 6, this.Faction, true); if (pList != null && pList.Count > 0) { for (int i = 0; i < pList.Count; i++) { Pawn p = pList[i]; if (p.health != null && p.health.hediffSet != null) { HealthUtility.AdjustSeverity(p, TorannMagicDefOf.TM_ShockTherapyHD, 0.12f); } } } } if (buffJolt) { List <Pawn> pList = TM_Calc.FindAllPawnsAround(this.Map, this.Position, 6, this.Faction, true); if (pList != null && pList.Count > 0) { for (int i = 0; i < pList.Count; i++) { Pawn p = pList[i]; if (p.health != null && p.health.hediffSet != null) { HealthUtility.AdjustSeverity(p, TorannMagicDefOf.TM_JoltHD, 0.1f); } } } } } base.Tick(); }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; if (!this.initialized) { this.bloodCircleOuterCells = new List <IntVec3>(); this.bloodCircleOuterCells.Clear(); this.victimHitTick = new List <int>(); this.victimHitTick.Clear(); this.victims = new List <Pawn>(); this.victims.Clear(); this.wolfDmg = new List <float>(); this.wolfDmg.Clear(); caster = this.launcher as Pawn; CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>(); MagicPowerSkill bpwr = comp.MagicData.MagicPowerSkill_BloodGift.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_BloodGift_pwr"); pwrVal = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_BloodMoon.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_BloodMoon_pwr").level; verVal = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_BloodMoon.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_BloodMoon_ver").level; effVal = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_BloodMoon.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_BloodMoon_eff").level; this.arcaneDmg = comp.arcaneDmg; this.arcaneDmg *= 1f + (.1f * bpwr.level); this.attackFrequency *= 1 - (.05f * effVal); this.duration = Mathf.RoundToInt(this.duration + (this.duration * .1f * verVal)); this.angle = Rand.Range(-2f, 2f); this.radius = this.def.projectile.explosionRadius; IntVec3 curCell = base.Position; this.CheckSpawnSustainer(); if (curCell.InBounds(map) && curCell.IsValid) { IEnumerable <IntVec3> cellList = GenRadial.RadialCellsAround(base.Position, this.radius, true); foreach (var cell in cellList) { curCell = cell; if (curCell.InBounds(map) && curCell.IsValid) { this.bloodCircleCells.Add(curCell); } } cellList = GenRadial.RadialCellsAround(base.Position, this.radius + 1, true); List <IntVec3> outerRing = new List <IntVec3>(); foreach (var cell in cellList) { curCell = cell; if (curCell.InBounds(map) && curCell.IsValid) { outerRing.Add(curCell); } } this.bloodCircleOuterCells = outerRing.Except(this.bloodCircleCells).ToList(); } TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_BloodCircle"), base.Position.ToVector3Shifted(), caster.Map, this.radius + 2, this.duration / 60 * .9f, this.duration / 60 * .06f, this.duration / 60 * .08f, Rand.Range(-50, -50), 0, 0, Rand.Range(0, 360)); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_BloodCircle"), base.Position.ToVector3Shifted(), caster.Map, this.radius + 2, this.duration / 60 * .9f, this.duration / 60 * .06f, this.duration / 60 * .08f, Rand.Range(50, 50), 0, 0, Rand.Range(0, 360)); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_BloodCircle"), base.Position.ToVector3Shifted(), caster.Map, this.radius + 2, this.duration / 60 * .9f, this.duration / 60 * .06f, this.duration / 60 * .08f, Rand.Range(-50, 50), 0, 0, Rand.Range(0, 360)); caster.Map.weatherManager.eventHandler.AddEvent(new TM_WeatherEvent_BloodMoon(caster.Map, this.duration, 2f - (this.pwrVal * .1f))); this.initialized = true; } if (this.initialized && this.Map != null && this.age > 15) { if (this.victims.Count > 0) { for (int i = 0; i < this.victims.Count; i++) { if (this.victimHitTick[i] < this.age) { TM_Action.DamageEntities(victims[i], null, Mathf.RoundToInt(Rand.Range(5, 8) * this.wolfDmg[i] * this.arcaneDmg), DamageDefOf.Bite, this.launcher); TM_MoteMaker.ThrowBloodSquirt(victims[i].DrawPos, victims[i].Map, Rand.Range(.6f, 1f)); this.victims.Remove(this.victims[i]); this.victimHitTick.Remove(this.victimHitTick[i]); this.wolfDmg.Remove(this.wolfDmg[i]); } } } if (Find.TickManager.TicksGame % this.bloodFrequency == 0) { Filth filth = (Filth)ThingMaker.MakeThing(ThingDefOf.Filth_Blood); GenSpawn.Spawn(filth, this.bloodCircleOuterCells.RandomElement(), this.Map); } if (this.nextAttack < this.age && !this.caster.DestroyedOrNull() && !this.caster.Dead) { Pawn victim = TM_Calc.FindNearbyEnemy(base.Position, this.Map, this.caster.Faction, this.radius, 0); if (victim != null) { IntVec3 rndPos = victim.Position; while (rndPos == victim.Position) { rndPos = this.bloodCircleCells.RandomElement(); } Vector3 wolf = rndPos.ToVector3Shifted(); Vector3 direction = TM_Calc.GetVector(wolf, victim.DrawPos); float angle = direction.ToAngleFlat(); float fadeIn = .1f; float fadeOut = .25f; float solidTime = .10f; float drawSize = Rand.Range(.7f, 1.2f) + (this.pwrVal * .1f); float velocity = (victim.DrawPos - wolf).MagnitudeHorizontal(); if (angle >= -135 && angle < -45) //north { TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_BloodWolfNorth"), wolf, this.Map, drawSize, solidTime, fadeIn, fadeOut, 0, 2 * velocity, (Quaternion.AngleAxis(90, Vector3.up) * direction).ToAngleFlat(), 0); } else if (angle >= 45 && angle < 135) //south { TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_BloodWolfSouth"), wolf, this.Map, drawSize, solidTime, fadeIn, fadeOut, 0, 2 * velocity, (Quaternion.AngleAxis(90, Vector3.up) * direction).ToAngleFlat(), 0); } else if (angle >= -45 && angle < 45) //east { TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_BloodWolfEast"), wolf, this.Map, drawSize, solidTime, fadeIn, fadeOut, 0, 2 * velocity, (Quaternion.AngleAxis(90, Vector3.up) * direction).ToAngleFlat(), 0); } else //west { TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_BloodWolfWest"), wolf, this.Map, drawSize, solidTime, fadeIn, fadeOut, 0, 2 * velocity, (Quaternion.AngleAxis(90, Vector3.up) * direction).ToAngleFlat(), 0); } int hitDelay = this.age + this.delayTicks; Effecter BloodShieldEffect = TorannMagicDefOf.TM_BloodShieldEffecter.Spawn(); BloodShieldEffect.Trigger(new TargetInfo(wolf.ToIntVec3(), this.Map, false), new TargetInfo(wolf.ToIntVec3(), this.Map, false)); BloodShieldEffect.Cleanup(); this.victims.Add(victim); this.victimHitTick.Add(hitDelay); this.wolfDmg.Add(drawSize); if (Rand.Chance(.1f)) { if (Rand.Chance(.65f)) { SoundInfo info = SoundInfo.InMap(new TargetInfo(wolf.ToIntVec3(), this.Map, false), MaintenanceType.None); SoundDef.Named("TM_DemonCallHigh").PlayOneShot(info); } else { SoundInfo info = SoundInfo.InMap(new TargetInfo(wolf.ToIntVec3(), this.Map, false), MaintenanceType.None); info.pitchFactor = .8f; info.volumeFactor = .8f; SoundDef.Named("TM_DemonPain").PlayOneShot(info); } } } this.nextAttack = this.age + Mathf.RoundToInt(Rand.Range(.4f * (float)this.attackFrequency, .8f * (float)this.attackFrequency)); } } }