protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); try { Pawn victim = hitThing as Pawn; if (!initialized) { Initialize(map); } int dmg = GetWeaponDmg(this.launcher as Pawn); ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if (victim != null && Rand.Chance(GetWeaponAccuracy(pawn))) { damageEntities(victim, null, dmg, DamageDefOf.Arrow); TM_MoteMaker.ThrowBloodSquirt(victim.DrawPos, victim.Map, 1f); } } catch (NullReferenceException) { // } }
protected override void Impact(Thing hitThing) { Map map = base.Map; Pawn pawn = this.launcher as Pawn; base.Impact(hitThing); ThingDef def = this.def; try { if (pawn != null) { Pawn victim = hitThing as Pawn; CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>(); if (victim != null && comp != null) { TM_Action.DamageEntities(victim, null, GetWeaponDmg(pawn), this.def.projectile.damageDef, pawn); TM_MoteMaker.ThrowBloodSquirt(victim.DrawPos, victim.Map, .8f); } } } catch (NullReferenceException ex) { // } }
protected override DamageWorker.DamageResult ApplyMeleeDamageToTarget(LocalTargetInfo target) { DamageWorker.DamageResult damageResult = new DamageWorker.DamageResult(); DamageInfo dinfo = new DamageInfo(DamageDefOf.Cut, (int)(this.tool.power), 0, (float)-1, this.CasterPawn, null, null, DamageInfo.SourceCategory.ThingOrUnknown); damageResult.hitThing = target.Thing; damageResult.totalDamageDealt = Mathf.Min((float)target.Thing.HitPoints, dinfo.Amount); float angle = (Quaternion.AngleAxis(90, Vector3.up) * GetVector(this.CasterPawn.Position, target.Thing.Position)).ToAngleFlat(); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_ClawSweep"), target.CenterVector3, target.Thing.Map, Rand.Range(1.2f, 1.4f), .15f, .05f, .1f, 0, Rand.Range(.2f, .4f), (angle + Rand.Range(-10, 10)), (angle + Rand.Range(-10, 10))); for (int i = 0; i < 8; i++) { IntVec3 intVec = target.Cell + GenAdj.AdjacentCells[i]; Pawn cleaveVictim = new Pawn(); cleaveVictim = intVec.GetFirstPawn(target.Thing.Map); if (cleaveVictim != null && cleaveVictim.Faction != caster.Faction) { DamageInfo dinfo2 = new DamageInfo(TMDamageDefOf.DamageDefOf.TM_Cleave, (int)(this.tool.power * .6f), 0, (float)-1, this.CasterPawn, null, null, DamageInfo.SourceCategory.ThingOrUnknown); cleaveVictim.TakeDamage(dinfo2); TM_MoteMaker.ThrowBloodSquirt(cleaveVictim.Position.ToVector3Shifted(), cleaveVictim.Map, Rand.Range(.6f, 1f)); TM_MoteMaker.ThrowBloodSquirt(cleaveVictim.Position.ToVector3Shifted(), cleaveVictim.Map, Rand.Range(.6f, 1f)); } } TM_MoteMaker.ThrowBloodSquirt(target.Thing.Position.ToVector3Shifted(), target.Thing.Map, 1.2f); target.Thing.TakeDamage(dinfo); return(damageResult); }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; Pawn victim = hitThing as Pawn; if (!initialized) { Initialize(map); } int dmg = GetWeaponDmg(this.launcher as Pawn, this.def); ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if (!pawn.IsColonist && settingsRef.AIHardMode) { dmg += 12; } if (victim != null && Rand.Chance(GetWeaponAccuracy(pawn))) { damageEntities(victim, null, dmg, DamageDefOf.Arrow); TM_MoteMaker.ThrowBloodSquirt(victim.DrawPos, victim.Map, 1f); } }
protected override DamageWorker.DamageResult ApplyMeleeDamageToTarget(LocalTargetInfo target) { DamageWorker.DamageResult damageResult = new DamageWorker.DamageResult(); DamageInfo dinfo = new DamageInfo(DamageDefOf.Scratch, (int)(this.tool.power), 0, (float)-1, this.CasterPawn, null, null, DamageInfo.SourceCategory.ThingOrUnknown); damageResult.hitThing = target.Thing; damageResult.totalDamageDealt = Mathf.Min((float)target.Thing.HitPoints, dinfo.Amount); for (int i = 0; i < 8; i++) { IntVec3 intVec = target.Cell + GenAdj.AdjacentCells[i]; Pawn cleaveVictim = new Pawn(); cleaveVictim = intVec.GetFirstPawn(target.Thing.Map); if (cleaveVictim != null && cleaveVictim.Faction != caster.Faction) { DamageInfo dinfo2 = new DamageInfo(TMDamageDefOf.DamageDefOf.TM_Cleave, (int)(this.tool.power * .6f), 0, (float)-1, this.CasterPawn, null, null, DamageInfo.SourceCategory.ThingOrUnknown); //damageResult.totalDamageDealt = Mathf.Min((float)cleaveVictim.HitPoints, dinfo2.Amount); cleaveVictim.TakeDamage(dinfo2); MoteMaker.ThrowMicroSparks(cleaveVictim.Position.ToVector3(), target.Thing.Map); TM_MoteMaker.ThrowCrossStrike(cleaveVictim.Position.ToVector3Shifted(), cleaveVictim.Map, .4f); TM_MoteMaker.ThrowBloodSquirt(cleaveVictim.Position.ToVector3Shifted(), cleaveVictim.Map, 1f); } } TM_MoteMaker.ThrowCrossStrike(target.Thing.Position.ToVector3Shifted(), target.Thing.Map, .5f); TM_MoteMaker.ThrowBloodSquirt(target.Thing.Position.ToVector3Shifted(), target.Thing.Map, 1.2f); target.Thing.TakeDamage(dinfo); return(damageResult); }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; Pawn victim = hitThing as Pawn; if (!initialized) { Initialize(map); } ThingWithComps arg_3C_0; int value = 0; if (pawn == null) { arg_3C_0 = null; } else { Pawn_EquipmentTracker expr_eq = pawn.equipment; arg_3C_0 = ((expr_eq != null) ? expr_eq.Primary : null); } ThingWithComps thing; bool flag31 = (thing = arg_3C_0) != null; if (flag31) { value = Mathf.RoundToInt(thing.GetStatValue(StatDefOf.MarketValue)); } int dmg; if (value > 1000) { value -= 1000; dmg = (this.def.projectile.damageAmountBase) + (int)((20 + (value / 120)) * (1 + (.1f * pwr.level) + (.05f * str.level))); } else { dmg = (this.def.projectile.damageAmountBase) + (int)((value / 50) * (1 + (.1f * pwr.level) + (.05f * str.level))); } ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if (!pawn.IsColonistPlayerControlled && settingsRef.AIHardMode) { dmg += 12; } if (victim != null && Rand.Chance(pawn.equipment.Primary.GetStatValue(StatDefOf.AccuracyMedium, true))) { damageEntities(victim, null, dmg, DamageDefOf.Arrow); TM_MoteMaker.ThrowBloodSquirt(victim.DrawPos, victim.Map, 1f); } }
protected override bool TryCastShot() { bool flag = false; MagicPowerSkill bpwr = base.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_BloodGift.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_BloodGift_pwr"); MagicPowerSkill pwr = base.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_BloodForBlood.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_BloodForBlood_pwr"); MagicPowerSkill ver = base.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_BloodForBlood.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_BloodForBlood_ver"); verVal = ver.level; pwrVal = pwr.level; if (base.CasterPawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { MightPowerSkill mpwr = base.CasterPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr"); MightPowerSkill mver = base.CasterPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver"); pwrVal = mpwr.level; verVal = mver.level; } this.arcaneDmg = base.CasterPawn.GetComp <CompAbilityUserMagic>().arcaneDmg; this.arcaneDmg *= 1 + (.1f * bpwr.level); if (this.currentTarget.Thing != null && this.currentTarget.Thing is Pawn) { Pawn victim = this.currentTarget.Thing as Pawn; if (victim.RaceProps.BloodDef != null && victim != this.CasterPawn) { for (int i = 0; i < 4; i++) { TM_MoteMaker.ThrowBloodSquirt(victim.DrawPos, victim.Map, Rand.Range(.6f, .9f)); } HealthUtility.AdjustSeverity(victim, TorannMagicDefOf.TM_BloodForBloodHD, (.5f + (.1f * pwrVal)) * this.arcaneDmg); if (victim.Faction == null && victim.RaceProps != null && victim.RaceProps.Animal && victim.mindState != null) { victim.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Manhunter, null, true, false, null); } HediffComp_BloodForBlood comp = victim.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_BloodForBloodHD, false).TryGetComp <HediffComp_BloodForBlood>(); if (comp != null) { comp.linkedPawn = this.CasterPawn; if (victim.IsColonist && !base.CasterPawn.IsColonist) { TM_Action.SpellAffectedPlayerWarning(victim); } } else { Messages.Message("TM_InvalidTarget".Translate(this.CasterPawn.LabelShort, TorannMagicDefOf.TM_BloodForBlood.label), MessageTypeDefOf.RejectInput); } } else { Messages.Message("TM_InvalidTarget".Translate(this.CasterPawn.LabelShort, TorannMagicDefOf.TM_BloodForBlood.label), MessageTypeDefOf.RejectInput); } } this.PostCastShot(flag, out flag); return(flag); }
public void ConsumeHumanoid(Pawn undead) { TM_MoteMaker.ThrowSiphonMote(undead.Position.ToVector3Shifted(), undead.Map, 1.2f); TM_MoteMaker.ThrowBloodSquirt(undead.Position.ToVector3Shifted(), undead.Map, 1f); TM_MoteMaker.ThrowBloodSquirt(undead.Position.ToVector3Shifted(), undead.Map, 1.2f); TM_MoteMaker.ThrowManaPuff(caster.Position.ToVector3Shifted(), caster.Map, 1f); undead.inventory.DropAllNearPawn(undead.Position, false, true); undead.equipment.DropAllEquipment(undead.Position, false); undead.apparel.DropAll(undead.Position, false); }
public void ConsumeHumanoid(Corpse corpse) { TM_MoteMaker.ThrowSiphonMote(corpse.Position.ToVector3Shifted(), corpse.Map, 1.2f); TM_MoteMaker.ThrowBloodSquirt(corpse.Position.ToVector3Shifted(), corpse.Map, 1f); TM_MoteMaker.ThrowBloodSquirt(corpse.Position.ToVector3Shifted(), corpse.Map, 1.2f); TM_MoteMaker.ThrowManaPuff(caster.Position.ToVector3Shifted(), caster.Map, 1f); Pawn corpsePawn = corpse.InnerPawn; corpsePawn.inventory.DropAllNearPawn(corpse.Position, false, true); corpsePawn.equipment.DropAllEquipment(corpse.Position, false); corpsePawn.apparel.DropAll(corpse.Position, false); }
protected override DamageWorker.DamageResult ApplyMeleeDamageToTarget(LocalTargetInfo target) { DamageWorker.DamageResult damageResult = new DamageWorker.DamageResult(); BodyPartGroupDef bodyPartGroupDef = null; HediffDef hediffDef = null; float num = verbProps.AdjustedMeleeDamageAmount(this, CasterPawn); float armorPenetration = verbProps.AdjustedArmorPenetration(this, CasterPawn); ThingDef source = (base.EquipmentSource == null) ? CasterPawn.def : base.EquipmentSource.def; bodyPartGroupDef = verbProps.AdjustedLinkedBodyPartsGroup(tool); DamageInfo dinfo = new DamageInfo(DamageDefOf.Scratch, num, armorPenetration, -1f, this.CasterPawn, null, source); damageResult.totalDamageDealt = Mathf.Min((float)target.Thing.HitPoints, dinfo.Amount); for (int i = 0; i < 8; i++) { IntVec3 intVec = target.Cell + GenAdj.AdjacentCells[i]; Pawn cleaveVictim = new Pawn(); cleaveVictim = intVec.GetFirstPawn(target.Thing.Map); if (cleaveVictim != null && cleaveVictim.Faction != caster.Faction) { Vector3 direction = (cleaveVictim.Position - CasterPawn.Position).ToVector3(); dinfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside); dinfo.SetWeaponBodyPartGroup(bodyPartGroupDef); dinfo.SetWeaponHediff(hediffDef); dinfo.SetAngle(direction); dinfo.SetAmount(Rand.Range(.8f, 1.2f) * num * .6f); cleaveVictim.TakeDamage(dinfo); FleckMaker.ThrowMicroSparks(cleaveVictim.Position.ToVector3(), target.Thing.Map); TM_MoteMaker.ThrowCrossStrike(cleaveVictim.Position.ToVector3Shifted(), cleaveVictim.Map, 1f); TM_MoteMaker.ThrowBloodSquirt(cleaveVictim.Position.ToVector3Shifted(), cleaveVictim.Map, 1f); } } target.Thing.TakeDamage(dinfo); if (target != null && !target.Thing.DestroyedOrNull()) { base.ApplyMeleeDamageToTarget(target); if (target.Thing.Map != null) { TM_MoteMaker.ThrowCrossStrike(target.Thing.Position.ToVector3Shifted(), target.Thing.Map, .5f); TM_MoteMaker.ThrowBloodSquirt(target.Thing.Position.ToVector3Shifted(), target.Thing.Map, 1.2f); } } return(damageResult); }
public void DoStrike(Thing target) { if (target != null && target is Pawn) { Pawn t = target as Pawn; if (t.Faction == null || (t.Faction != null && t.Faction != this.Pawn.Faction)) { for (int i = 0; i < 4; i++) { if (!t.DestroyedOrNull() && !t.Dead && t.Map != null) { int dmg = shadowStrikeDamage + pwrVal; if (Rand.Chance(shadowStrikeCritChance)) { dmg *= 3; } BodyPartRecord bpr = t.health.hediffSet.GetRandomNotMissingPart(DamageDefOf.Stab, BodyPartHeight.Undefined, BodyPartDepth.Outside); TM_Action.DamageEntities(target, bpr, dmg, Rand.Range(0f, .5f), DamageDefOf.Stab, this.Pawn); Vector3 rndPos = t.DrawPos; rndPos.x += Rand.Range(-.2f, .2f); rndPos.z += Rand.Range(-.2f, .2f); TM_MoteMaker.ThrowBloodSquirt(rndPos, t.Map, Rand.Range(.6f, 1f)); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_CrossStrike, rndPos, t.Map, Rand.Range(.6f, 1f), .4f, 0f, Rand.Range(.2f, .5f), 0, 0, 0, Rand.Range(0, 360)); } } if (!t.DestroyedOrNull() && !t.Dead && !t.Downed) { Job job = new Job(JobDefOf.AttackMelee, t); this.Pawn.jobs.TryTakeOrderedJob(job); } } } HealthUtility.AdjustSeverity(this.Pawn, TorannMagicDefOf.TM_ShadowCloakHD, .2f); HediffComp_Disappears hdComp = this.Pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ShadowCloakHD).TryGetComp <HediffComp_Disappears>(); if (hdComp != null) { hdComp.ticksToDisappear = this.invisDuration; } ApplyHaste(this.Pawn); }
protected override DamageWorker.DamageResult ApplyMeleeDamageToTarget(LocalTargetInfo target) { for (int i = 0; i < 8; i++) { IntVec3 intVec = target.Cell + GenAdj.AdjacentCells[i]; Pawn cleaveVictim = new Pawn(); cleaveVictim = intVec.GetFirstPawn(target.Thing.Map); if (cleaveVictim != null && cleaveVictim.Faction != caster.Faction) { DamageInfo dinfo = new DamageInfo(TMDamageDefOf.DamageDefOf.TM_Cleave, (int)(this.tool.power * .6f), (float)-1, this.CasterPawn, null, null, DamageInfo.SourceCategory.ThingOrUnknown); cleaveVictim.TakeDamage(dinfo); MoteMaker.ThrowMicroSparks(cleaveVictim.Position.ToVector3(), target.Thing.Map); TM_MoteMaker.ThrowCrossStrike(cleaveVictim.Position.ToVector3Shifted(), cleaveVictim.Map, 1f); TM_MoteMaker.ThrowBloodSquirt(cleaveVictim.Position.ToVector3Shifted(), cleaveVictim.Map, 1f); DrawCleaving(cleaveVictim, base.CasterPawn, 10); } } TM_MoteMaker.ThrowCrossStrike(target.Thing.Position.ToVector3Shifted(), target.Thing.Map, 1f); TM_MoteMaker.ThrowBloodSquirt(target.Thing.Position.ToVector3Shifted(), target.Thing.Map, 1f); return(base.ApplyMeleeDamageToTarget(target)); }
protected override void Impact(Thing hitThing) { Map map = base.Map; Pawn pawn = this.launcher as Pawn; base.Impact(hitThing); ThingDef def = this.def; try { if (pawn != null) { Pawn victim = hitThing as Pawn; CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>(); if (victim != null && comp != null && Rand.Chance(.8f)) { TM_Action.DamageEntities(victim, null, this.def.projectile.GetDamageAmount(1, null) * comp.mightPwr, DamageDefOf.Cut, pawn); TM_MoteMaker.ThrowBloodSquirt(victim.DrawPos, victim.Map, .8f); if (comp.MightData.MightPowerSkill_FieldTraining.FirstOrDefault((MightPowerSkill x) => x.label == "TM_FieldTraining_pwr").level >= 3) { if (victim.IsPrisoner || victim.IsColonist) { LegShot(victim, Rand.Range(4, 6), TMDamageDefOf.DamageDefOf.TM_Tranquilizer); LegShot(victim, Rand.Range(4, 6), TMDamageDefOf.DamageDefOf.TM_DisablingShot); } else if (victim.HostileTo(pawn.Faction)) { HealthUtility.AdjustSeverity(victim, TorannMagicDefOf.TM_Poisoned_HD, Rand.Range(2, 4)); } } } } } catch (NullReferenceException) { // } }
public void ConsumeAnimalKind(Corpse corpse) { TM_MoteMaker.ThrowSiphonMote(corpse.Position.ToVector3Shifted(), corpse.Map, .8f); TM_MoteMaker.ThrowBloodSquirt(corpse.Position.ToVector3Shifted(), corpse.Map, 1.5f); TM_MoteMaker.ThrowManaPuff(caster.Position.ToVector3Shifted(), caster.Map, .8f); }
public void ConsumeAnimalKind(Pawn undead) { TM_MoteMaker.ThrowSiphonMote(undead.Position.ToVector3Shifted(), undead.Map, .8f); TM_MoteMaker.ThrowBloodSquirt(undead.Position.ToVector3Shifted(), undead.Map, 1.5f); TM_MoteMaker.ThrowManaPuff(caster.Position.ToVector3Shifted(), caster.Map, .8f); }
public void DrawStrike(IntVec3 center, Vector3 strikePos, Map map) { TM_MoteMaker.ThrowCrossStrike(strikePos, map, 1f); TM_MoteMaker.ThrowBloodSquirt(strikePos, map, 1.5f); }
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)); } } }
protected override IEnumerable <Toil> MakeNewToils() { CompAbilityUserMagic comp = this.pawn.GetComp <CompAbilityUserMagic>(); Toil discordance = new Toil(); Pawn target = this.TargetThingA as Pawn; discordance.initAction = delegate { if (age > duration) { this.EndJobWith(JobCondition.Succeeded); } if (target.DestroyedOrNull()) { this.EndJobWith(JobCondition.Errored); } if (target.Map == null) { this.EndJobWith(JobCondition.Errored); } if (target.Dead) { this.EndJobWith(JobCondition.Succeeded); } Map map = this.pawn.Map; ticksLeftThisToil = 10; headDamageCount = 0; }; discordance.tickAction = delegate { if (Find.TickManager.TicksGame % this.moteFrequency == 0) { TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f)); float angle = Rand.Range(0, 360); ThingDef mote = TorannMagicDefOf.Mote_Psi_Grayscale; TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Psi_Grayscale, this.pawn.DrawPos, this.pawn.Map, Rand.Range(.25f, .6f), .1f, .05f, .05f, 0, Rand.Range(4f, 6f), angle, angle); } if (Find.TickManager.TicksGame % this.discordFrequency == 0) { Vector3 headPos = target.DrawPos; headPos.z += .3f; TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Bolt, headPos, target.Map, .6f, .5f, .1f, .5f, Rand.Range(-10, 10), Rand.Range(.4f, .6f), Rand.Range(-90, 90), Rand.Range(0, 360)); float manaCost = comp.ActualManaCost(TorannMagicDefOf.TM_Discord); if (comp.Mana.CurLevel >= manaCost && !target.DestroyedOrNull() && !target.Dead && target.Map != null) { comp.Mana.CurLevel -= manaCost; float ch = TM_Calc.GetSpellSuccessChance(this.pawn, target, true); if (target.Faction == this.pawn.Faction) { HealthUtility.AdjustSeverity(target, TorannMagicDefOf.TM_DiscordSafeHD, .4f * ch); Hediff hd = target.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_DiscordHD); if (hd != null && hd.Severity > 5) { if (Rand.Chance(.2f)) { TM_Action.DamageEntities(target, null, 6, DamageDefOf.Stun, this.pawn); } } } else { HealthUtility.AdjustSeverity(target, TorannMagicDefOf.TM_DiscordHD, .4f * ch); Hediff hd = target.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_DiscordHD); if (hd != null && hd.Severity > 5) { BodyPartRecord bpr = target.health.hediffSet.GetBrain(); BodyPartRecord head = target.health.hediffSet.GetNotMissingParts().FirstOrDefault((BodyPartRecord x) => x.def == BodyPartDefOf.Head); if (bpr != null) { if (Rand.Chance(.22f * ch)) { for (int i = 0; i < 2; i++) { TM_MoteMaker.ThrowBloodSquirt(headPos, target.Map, Rand.Range(.6f, 1f)); } TM_Action.DamageEntities(target, bpr, Rand.Range(1, 3), 2f, TMDamageDefOf.DamageDefOf.TM_DistortionDD, this.pawn); headDamageCount++; } else if (Rand.Chance((.07f * ch) + (headDamageCount * .3f)) && head != null) { for (int i = 0; i < 3; i++) { TM_MoteMaker.ThrowBloodSquirt(headPos, target.Map, Rand.Range(.6f, 1f)); } for (int i = 0; i < 3; i++) { float moteSize = Rand.Range(.5f, .8f); float solidTime = Rand.Range(.6f, .8f); float fadeOutTime = Rand.Range(.2f, .4f); float velocity = Rand.Range(1.5f, 2.5f); float velocityAngle = Rand.Range(0f, 360f); for (int j = 0; j < 3; j++) { TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_BloodSquirt, headPos, target.Map, moteSize - (.1f * j), solidTime + (.1f * j), 0f, fadeOutTime + (.05f * j), Rand.Range(-50, 50), velocity + (.5f * j), velocityAngle, Rand.Range(0, 360)); } } TM_Action.DamageEntities(target, head, Rand.Range(50, 80), 2f, TMDamageDefOf.DamageDefOf.TM_DistortionDD, this.pawn); } } } } if (target.Dead) { this.age = this.duration; } } else { this.age = this.duration; } } age++; ticksLeftThisToil = Mathf.RoundToInt((float)(duration - age) / (float)duration * 100f); if (age > duration) { this.EndJobWith(JobCondition.Succeeded); } }; discordance.defaultCompleteMode = ToilCompleteMode.Delay; discordance.defaultDuration = this.duration; discordance.WithProgressBar(TargetIndex.A, delegate { if (this.pawn.DestroyedOrNull() || this.pawn.Dead || this.pawn.Downed) { return(1f); } return(1f - ((float)discordance.actor.jobs.curDriver.ticksLeftThisToil / 100)); }, false, 0f); discordance.AddFinishAction(delegate { }); yield return(discordance); }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; Pawn pawn = this.launcher as Pawn; if (!this.initialized) { CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_CorpseExplosion.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_CorpseExplosion_pwr"); MagicPowerSkill ver = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_CorpseExplosion.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_CorpseExplosion_ver"); pwrVal = pwr.level; verVal = ver.level; Initialize(); CellRect cellRect = CellRect.CenteredOn(base.Position, 1); cellRect.ClipInsideMap(map); IntVec3 curCell = cellRect.CenterCell; if (curCell.InBounds(map) && curCell.IsValid) { Pawn undead = curCell.GetFirstPawn(map); bool flag = undead != null && !undead.Dead; if (flag) { if (undead.health.hediffSet.HasHediff(TorannMagicDefOf.TM_UndeadHD)) { this.targetPawn = undead; } if (undead.health.hediffSet.HasHediff(TorannMagicDefOf.TM_UndeadAnimalHD)) { this.targetPawn = undead; } } Thing corpseThing = curCell.GetFirstItem(map); Corpse corpse = null; if (corpseThing != null) { bool validator = corpseThing is Corpse; if (validator) { corpse = corpseThing as Corpse; Pawn corpsePawn = corpse.InnerPawn; if (corpsePawn.RaceProps.IsFlesh) { if (corpsePawn.RaceProps.Humanlike || corpsePawn.RaceProps.Animal) { this.targetCorpse = corpse; } } } } } } if (this.targetPawn != null && !this.targetPawn.Destroyed) { if (this.age == 360) { MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "6", -.5f); } if (this.age == 300) { MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "5", -.5f); } if (this.age == 240) { MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "4", -.5f); } if (this.age == 180) { MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "3", -.5f); } if (this.age == 120) { MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "2", -.5f); } if (this.age == 60) { MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "1", -.5f); } if (this.age == 1) { //explode TM_MoteMaker.ThrowBloodSquirt(this.targetPawn.Position.ToVector3Shifted(), map, 1.2f); TM_MoteMaker.ThrowBloodSquirt(this.targetPawn.Position.ToVector3Shifted(), map, .6f); TM_MoteMaker.ThrowBloodSquirt(this.targetPawn.Position.ToVector3Shifted(), map, .8f); if (this.targetPawn.RaceProps.Humanlike) { this.targetPawn.inventory.DropAllNearPawn(this.targetPawn.Position, false, true); this.targetPawn.equipment.DropAllEquipment(this.targetPawn.Position, false); this.targetPawn.apparel.DropAll(this.targetPawn.Position, false); } GenExplosion.DoExplosion(this.targetPawn.Position, map, this.radius, TMDamageDefOf.DamageDefOf.TM_CorpseExplosion, this.launcher, Mathf.RoundToInt(Rand.Range(18f, 30f) + (5f * pwrVal)), this.def.projectile.soundExplode, def, this.equipmentDef, null, 0f, 01, false, null, 0f, 0, 0.0f, true); if (!this.targetPawn.Destroyed) { this.targetPawn.Destroy(); } } } if (this.targetCorpse != null && !this.targetCorpse.Destroyed) { if (this.age == 360) { MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "6", -.5f); } if (this.age == 300) { MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "5", -.5f); } if (this.age == 240) { MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "4", -.5f); } if (this.age == 180) { MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "3", -.5f); } if (this.age == 120) { MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "2", -.5f); } if (this.age == 60) { MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "1", -.5f); } if (this.age == 1) { //explode TM_MoteMaker.ThrowBloodSquirt(this.targetCorpse.Position.ToVector3Shifted(), map, 1.2f); TM_MoteMaker.ThrowBloodSquirt(this.targetCorpse.Position.ToVector3Shifted(), map, .6f); TM_MoteMaker.ThrowBloodSquirt(this.targetCorpse.Position.ToVector3Shifted(), map, .8f); Pawn corpsePawn = this.targetCorpse.InnerPawn; if (corpsePawn.RaceProps.Humanlike) { corpsePawn.inventory.DropAllNearPawn(this.targetCorpse.Position, false, true); corpsePawn.equipment.DropAllEquipment(this.targetCorpse.Position, false); corpsePawn.apparel.DropAll(this.targetCorpse.Position, false); } GenExplosion.DoExplosion(this.targetCorpse.Position, map, this.radius, TMDamageDefOf.DamageDefOf.TM_CorpseExplosion, this.launcher, Mathf.RoundToInt(Rand.Range(18f, 30f) + (5f * pwrVal)), this.def.projectile.soundExplode, def, this.equipmentDef, null, 0f, 01, false, null, 0f, 0, 0.0f, true); if (!this.targetCorpse.Destroyed) { this.targetCorpse.Destroy(); } } } }
public void DoStrike(Thing target) { if (target != null && target is Pawn) { Pawn t = target as Pawn; if (t.Faction == null || (t.Faction != null && t.Faction != caster.Faction)) { //List<BodyPartRecord> partList = new List<BodyPartRecord>(); //partList.Clear(); //for (int i = 0; i < t.RaceProps.body.AllParts.Count; i++) //{ // BodyPartRecord part = t.RaceProps.body.AllParts[i]; // if (part.depth == BodyPartDepth.Outside) // { // partList.Add(part); // } //} for (int i = 0; i < 4; i++) { if (!t.DestroyedOrNull() && !t.Dead && t.Map != null) { int dmg = Mathf.RoundToInt(this.weaponDamage); if (Rand.Chance(critChance)) { dmg *= 3; } BodyPartRecord bpr = t.health.hediffSet.GetRandomNotMissingPart(DamageDefOf.Stab, BodyPartHeight.Undefined, BodyPartDepth.Outside); TM_Action.DamageEntities(target, bpr, dmg, Rand.Range(0f, .5f), DamageDefOf.Stab, this.caster); Vector3 rndPos = t.DrawPos; rndPos.x += Rand.Range(-.2f, .2f); rndPos.z += Rand.Range(-.2f, .2f); TM_MoteMaker.ThrowBloodSquirt(rndPos, t.Map, Rand.Range(.6f, 1f)); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_CrossStrike, rndPos, t.Map, Rand.Range(.6f, 1f), .4f, 0f, Rand.Range(.2f, .5f), 0, 0, 0, Rand.Range(0, 360)); } } if (!t.DestroyedOrNull() && !t.Dead && !t.Downed && caster.IsColonist) { caster.drafter.Drafted = true; Job job = new Job(JobDefOf.AttackMelee, t); caster.jobs.TryTakeOrderedJob(job, JobTag.DraftedOrder); } } } if (verVal >= 1) { int invisDuration = 120; if (verVal >= 2) { invisDuration = 180; } HealthUtility.AdjustSeverity(caster, TorannMagicDefOf.TM_ShadowCloakHD, .2f); HediffComp_Disappears hdComp = caster.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ShadowCloakHD).TryGetComp <HediffComp_Disappears>(); if (hdComp != null) { hdComp.ticksToDisappear = invisDuration; } } if (verVal >= 3) { int radius = 2; if (verVal >= 5) { radius = 3; } float sev = 1.5f; if (verVal >= 4) { sev = 2.2f; } List <Pawn> targetList = TM_Calc.FindPawnsNearTarget(caster, radius, caster.Position, true); if (targetList != null && targetList.Count > 0) { for (int i = 0; i < targetList.Count; i++) { if (targetList[i].RaceProps.IsFlesh) { HealthUtility.AdjustSeverity(targetList[i], TorannMagicDefOf.TM_NightshadeToxinHD, Rand.Range(.7f * sev, 1.3f * sev)); } } } ThingDef fog = TorannMagicDefOf.Fog_Shadows; fog.gas.expireSeconds.min = 2; fog.gas.expireSeconds.max = 3; GenExplosion.DoExplosion(caster.Position, caster.Map, radius, TMDamageDefOf.DamageDefOf.TM_Toxin, caster, 0, 0, TMDamageDefOf.DamageDefOf.TM_Toxin.soundExplosion, null, null, null, fog, 1f, 1, false, null, 0f, 0, 0.0f, false); for (int i = 0; i < 6; i++) { Vector3 rndPos = caster.DrawPos; rndPos.x += Rand.Range(-.5f, .5f); rndPos.z += Rand.Range(-.5f, .5f); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_ShadowCloud, rndPos, caster.Map, Rand.Range(.6f, 1f), .4f, .05f, Rand.Range(.2f, .5f), Rand.Range(-40, 40), Rand.Range(1, 2f), Rand.Range(0, 360), Rand.Range(0, 360)); } } ApplyHaste(caster); }