protected override bool TryCastShot() { Pawn pawn = this.CasterPawn; IntVec3 targetVariation = this.currentTarget.Cell; targetVariation.x += Mathf.RoundToInt(Rand.Range(-.15f, .15f) * Vector3.Distance(pawn.DrawPos, this.currentTarget.CenterVector3) + Rand.Range(-1f, 1f)); targetVariation.z += Mathf.RoundToInt(Rand.Range(-.15f, .15f) * Vector3.Distance(pawn.DrawPos, this.currentTarget.CenterVector3) + Rand.Range(-1f, 1f)); if (!initialized) { initialized = true; shotcount = GetShotCount(pawn); } Vector3 drawPos = pawn.DrawPos + (TM_Calc.GetVector(pawn.Position, targetVariation) * .5f); MoteMaker.ThrowSmoke(drawPos, pawn.Map, Rand.Range(.4f, .7f)); TM_CopyAndLaunchProjectile.CopyAndLaunchThing(pawn.equipment.Primary.def.Verbs.FirstOrDefault().defaultProjectile, pawn, targetVariation, targetVariation, ProjectileHitFlags.All, pawn.equipment.Primary); shotcount--; if (shotcount <= 0) { initialized = false; } return(shotcount > 0); }
public override void Tick() { if (!initialized) { this.nextSearch = Find.TickManager.TicksGame + Rand.Range(120, 180); this.range = 40 + (4 * pwrVal); initialized = true; } else if (Find.TickManager.TicksGame >= this.nextSearch) { this.nextSearch = Find.TickManager.TicksGame + Rand.Range(120, 180); ScanForTarget(); if (target != null) { if (TM_Calc.HasLoSFromTo(this.Position, target.Position, this, 0, range)) { Projectile_Lightning bolt = ThingMaker.MakeThing(TorannMagicDefOf.Projectile_Lightning, null) as Projectile_Lightning; bolt.pwrVal = pwrVal; bolt.verVal = verVal; TM_CopyAndLaunchProjectile.CopyAndLaunchProjectile(bolt, this, target, target, ProjectileHitFlags.All, null); } } } base.Tick(); }
public override void Tick() { base.Tick(); if (Find.TickManager.TicksGame % 2 == 0 && daggerCount > 0 && this.launcher != null && this.launcher is Pawn) { Pawn caster = this.launcher as Pawn; CompAbilityUserMight comp = caster.TryGetComp <CompAbilityUserMight>(); if (comp != null) { ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if ((comp.MightData.MightPowerSkill_FieldTraining.FirstOrDefault((MightPowerSkill x) => x.label == "TM_FieldTraining_pwr").level >= 12) || (!caster.IsColonist && settingsRef.AIHardMode)) { Projectile_Spinning newProjectile = (Projectile_Spinning)ThingMaker.MakeThing(this.def, null); newProjectile.daggerCount = 0; TM_CopyAndLaunchProjectile.CopyAndLaunchProjectile(newProjectile, caster, this.intendedTarget, this.intendedTarget, ProjectileHitFlags.All, null); this.daggerCount--; } else { daggerCount = 0; } } else { daggerCount = 0; } } }
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 void RefractProjectiles() { float eMissVar = .1f + (.015f * pwrVal); float fMissVar = .05f - (.01f * pwrVal); foreach (var wallPosition in this.wallPositions) { for (int k = 0; k < this.wallPositions.Count; k++) { List <Thing> cellList = wallPosition.GetThingList(this.Map); for (int i = 0; i < cellList.Count; i++) { Thing t = cellList[i]; if (t is Projectile && t.def.defName != "Projectile_Refraction" && !(t is Mote)) { Projectile proj = t as Projectile; IntVec3 projOrigin = Traverse.Create(root: proj).Field(name: "origin").GetValue <Vector3>().ToIntVec3(); if (proj != null && proj.Launcher != null && (proj.Launcher.Faction != null || proj.def.defName == "Projectile_LightLaser") && !proj.def.projectile.flyOverhead && !wallPositions.Contains(projOrigin)) { if (proj.Launcher.Faction != this.caster.Faction) { Vector3 displayEffect = wallPosition.ToVector3Shifted(); displayEffect.x += Rand.Range(-.2f, .2f); displayEffect.z += Rand.Range(-.2f, .2f); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_LightBarrier, displayEffect, this.Map, .4f, .2f, .05f, .2f, 0, 0, 0, 0); IntVec3 targetVec = Traverse.Create(root: proj).Field(name: "destination").GetValue <Vector3>().ToIntVec3(); float targetRange = (this.Position - targetVec).LengthHorizontal; targetVec.x += Mathf.RoundToInt(Rand.Range(-eMissVar, eMissVar) * targetRange); targetVec.z += Mathf.RoundToInt(Rand.Range(-eMissVar, eMissVar) * targetRange); TM_CopyAndLaunchProjectile.CopyAndLaunchThingFromPosition(proj.def, proj.Launcher, wallPosition, this.Map, targetVec, intendedTarget, ProjectileHitFlags.All, null); proj.Destroy(DestroyMode.Vanish); this.wallEnergy -= proj.def.projectile.GetDamageAmount(1f); } else { Vector3 displayEffect = wallPosition.ToVector3Shifted(); displayEffect.x += Rand.Range(-.2f, .2f); displayEffect.z += Rand.Range(-.2f, .2f); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_LightBarrier, displayEffect, this.Map, .4f, .2f, .05f, .2f, 0, 0, 0, 0); IntVec3 targetCell = proj.intendedTarget.Cell; float targetRange = (this.Position - targetCell).LengthHorizontal; LocalTargetInfo initialTarget = proj.intendedTarget; targetCell.x += Mathf.RoundToInt(Rand.Range(-fMissVar, fMissVar) * targetRange); targetCell.z += Mathf.RoundToInt(Rand.Range(-fMissVar, fMissVar) * targetRange); TM_CopyAndLaunchProjectile.CopyAndLaunchThingFromPosition(proj.def, proj.Launcher, wallPosition, this.Map, targetCell, initialTarget, ProjectileHitFlags.All); this.wallEnergy -= proj.def.projectile.GetDamageAmount(1f); } } } } } } }
public void DoAction() { if (solAction == SoLAction.Attacking && (this.curvePoints.Count - 5) <= this.destinationCurvePoint) { if (this.assignedTarget != null && TM_Calc.HasLoSFromTo(base.Position, assignedTarget, this, 0, AttackTarget_MaxRange) && EnergyChance && LightEnergy > 3f) { ActualLightCost(3f); TM_CopyAndLaunchProjectile.CopyAndLaunchThing(TorannMagicDefOf.Projectile_LightLaser, this, this.assignedTarget, this.assignedTarget, ProjectileHitFlags.All, null); } } }
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); } } }
protected override bool TryCastShot() { Pawn pawn = this.CasterPawn; shotcount = GetShotCount(pawn); Vector3 drawPos = pawn.DrawPos + (TM_Calc.GetVector(pawn.Position, this.currentTarget.Cell) * .5f); MoteMaker.ThrowSmoke(drawPos, pawn.Map, Rand.Range(.6f, .8f)); for (int i = 0; i < shotcount; i++) { IntVec3 targetVariation = this.currentTarget.Cell; targetVariation.x += Mathf.RoundToInt(Rand.Range(-.1f, .1f) * Vector3.Distance(pawn.DrawPos, this.currentTarget.CenterVector3)); targetVariation.z += Mathf.RoundToInt(Rand.Range(-.1f, .1f) * Vector3.Distance(pawn.DrawPos, this.currentTarget.CenterVector3)); TM_CopyAndLaunchProjectile.CopyAndLaunchThing(this.verbProps.defaultProjectile, pawn, targetVariation, targetVariation, ProjectileHitFlags.All, pawn.equipment.Primary); } return(this.burstShotsLeft >= 0); }
public static void DoReversal(DamageInfo dinfo, Pawn reflectingPawn) { Thing instigator = dinfo.Instigator; if (instigator is Pawn) { Pawn shooterPawn = instigator as Pawn; if (dinfo.Weapon != null && !dinfo.Weapon.IsMeleeWeapon && dinfo.WeaponBodyPartGroup == null) { TM_CopyAndLaunchProjectile.CopyAndLaunchThing(shooterPawn.equipment.PrimaryEq.PrimaryVerb.verbProps.defaultProjectile, reflectingPawn, instigator, shooterPawn, 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) { TM_CopyAndLaunchProjectile.CopyAndLaunchThing(projectile, reflectingPawn, instigator, turret, ProjectileHitFlags.All, null); } } //GiveReversalJob(dinfo); }
private void DoAoEAttack(IntVec3 center, LocalTargetInfo target) { TM_CopyAndLaunchProjectile.CopyAndLaunchThing(TorannMagicDefOf.Projectile_FogOfTorment, this.Pawn, center, target, ProjectileHitFlags.All, null); this.shouldDoAOEAttack = false; }