public void Launch(Thing launcher, Vector3 origin, LocalTargetInfo targ, Thing flyingThing, DamageInfo?newDamageInfo = null)
        {
            //Despawn the object to fly
            if (flyingThing.Spawned)
            {
                flyingThing.DeSpawn();
            }

            this.launcher    = launcher;
            this.origin      = origin;
            impactDamage     = newDamageInfo;
            this.flyingThing = flyingThing;
            if (targ.Thing != null)
            {
                assignedTarget = targ.Thing;
            }
            destination   = targ.Cell.ToVector3Shifted() + new Vector3(Rand.Range(-0.3f, 0.3f), 0f, Rand.Range(-0.3f, 0.3f));
            ticksToImpact = StartingTicksToImpact;
        }
Ejemplo n.º 2
0
        public void Launch(Thing launcher, Vector3 origin, LocalTargetInfo targ, Thing flyingThing, DamageInfo?newDamageInfo = null)
        {
            Hediff invul = new Hediff();

            invul.def      = TorannMagicDefOf.TM_HediffInvulnerable;
            invul.Severity = 5;
            bool spawned = flyingThing.Spawned;

            pawn = launcher as Pawn;
            pawn.health.AddHediff(invul, null, null);
            comp = pawn.GetComp <CompAbilityUserMagic>();
            pwr  = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_ValiantCharge.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_ValiantCharge_pwr");
            ver  = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_ValiantCharge.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_ValiantCharge_ver");
            ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
            pwrVal = pwr.level;
            verVal = ver.level;
            if (settingsRef.AIHardMode && !pawn.IsColonistPlayerControlled)
            {
                pwrVal = 3;
                verVal = 3;
            }
            if (spawned)
            {
                flyingThing.DeSpawn();
            }
            //
            ModOptions.Constants.SetPawnInFlight(true);
            //
            this.launcher     = launcher;
            this.origin       = origin;
            this.impactDamage = newDamageInfo;
            this.flyingThing  = flyingThing;
            bool flag = targ.Thing != null;

            if (flag)
            {
                this.assignedTarget = targ.Thing;
            }
            this.destination   = targ.Cell.ToVector3Shifted() + new Vector3(Rand.Range(-0.3f, 0.3f), 0f, Rand.Range(-0.3f, 0.3f));
            this.ticksToImpact = this.StartingTicksToImpact;
            this.Initialize();
        }
Ejemplo n.º 3
0
        static void Prefix(DamageInfo?dinfo, Pawn_HealthTracker __instance, Pawn ___pawn)
        {
            if (__instance.Dead || !___pawn.PsiTracker().Activated || dinfo == null || dinfo.Value.Amount < 1e-4)
            {
                return;
            }

            var instigator = dinfo?.Instigator as Pawn;

            if (ShouldBeDead(__instance, ___pawn))
            {
                ___pawn.PsiTracker().TriggerAlmostDead(instigator);
                return;
            }

            if (ShouldBeDowned(__instance))
            {
                ___pawn.PsiTracker().TriggerAlmostDead(instigator);
            }
        }
Ejemplo n.º 4
0
 /// Nothing should happen.
 public override void PostAdd(DamageInfo?dinfo)
 {
     if (Part == null)
     {
         Log.Error("Part is null. It should be set before PostAdd for " + def + ".");
         return;
     }
     pawn.health.RestorePart(Part, this, false);
     temporarilyRemovedParts.Clear();
     for (var i = 0; i < Part.parts.Count; i++)
     {
         var hediff_MissingPart =
             (Hediff_MissingPart)HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, pawn, null);
         hediff_MissingPart.IsFresh    = false;
         hediff_MissingPart.lastInjury = null;
         hediff_MissingPart.Part       = Part.parts[i];
         pawn.health.hediffSet.AddDirect(hediff_MissingPart, null);
         temporarilyRemovedParts.Add(hediff_MissingPart);
     }
 }
 public void AddHediff(Hediff hediff, BodyPartRecord part = null, DamageInfo?dinfo = null, DamageWorker.DamageResult result = null)
 {
     if (part != null)
     {
         hediff.Part = part;
     }
     this.hediffSet.AddDirect(hediff, dinfo, result);
     this.CheckForStateChange(dinfo, hediff);
     if (this.pawn.RaceProps.hediffGiverSets != null)
     {
         for (int i = 0; i < this.pawn.RaceProps.hediffGiverSets.Count; i++)
         {
             HediffGiverSetDef hediffGiverSetDef = this.pawn.RaceProps.hediffGiverSets[i];
             for (int j = 0; j < hediffGiverSetDef.hediffGivers.Count; j++)
             {
                 hediffGiverSetDef.hediffGivers[j].OnHediffAdded(this.pawn, hediff);
             }
         }
     }
 }
Ejemplo n.º 6
0
        public static bool WasKilledByHunter(Pawn pawn, DamageInfo?dinfo)
        {
            if (!dinfo.HasValue)
            {
                return(false);
            }
            Pawn pawn2 = dinfo.Value.Instigator as Pawn;

            if (pawn2 == null || pawn2.CurJob == null)
            {
                return(false);
            }
            JobDriver_Hunt jobDriver_Hunt = pawn2.jobs.curDriver as JobDriver_Hunt;

            if (jobDriver_Hunt != null)
            {
                return(jobDriver_Hunt.Victim == pawn);
            }
            return(false);
        }
        public void LaunchNoThing(IntVec3 launcher, Vector3 origin, LocalTargetInfo targ, Thing flyingThing, DamageInfo?newDamageInfo = null)
        {
            //Log.Message("launching object");
            bool spawned = flyingThing.Spawned;

            //this.pawn = launcher as Pawn;
            if (spawned)
            {
                flyingThing.DeSpawn();
            }
            this.launcher.Position = launcher;              //Bench
            this.trueOrigin        = origin;                //Bench
            this.trueDestination   = targ.Cell.ToVector3(); // Factory
            this.impactDamage      = newDamageInfo;
            this.flyingThing       = flyingThing;
            bool flag = targ.Thing != null;

            if (flag)
            {
                this.assignedTarget = targ.Thing;
            }
            this.speed  = this.speed * this.force;
            this.origin = origin;
            if (this.curveVariance > 0 && this.curvePoints.Count == 0)
            {
                CalculateCurvePoints(this.trueOrigin, this.trueDestination, this.curveVariance);
                this.destinationCurvePoint++;
                this.destination = this.curvePoints[this.destinationCurvePoint];
            }
            else if (this.curveVariance > 0 && this.curvePoints.Count > 0)
            {
                this.destinationCurvePoint++;
                this.destination = this.curvePoints[this.destinationCurvePoint];
            }
            else
            {
                this.destination = this.trueDestination;
            }
            this.ticksToImpact = this.StartingTicksToImpact;
            this.Initialize();
        }
 private static bool Prefix(Pawn_HealthTracker __instance, Pawn ___pawn, DamageInfo?dinfo, Hediff hediff, Caravan caravan)
 {
     if (DisableKilledEffect)
     {
         if (!___pawn.IsEmptySleeve())
         {
             TaggedString taggedString = "";
             taggedString = (dinfo.HasValue ? "AlteredCarbon.SleveOf".Translate() + dinfo.Value.Def.deathMessage
                             .Formatted(___pawn.LabelShortCap, ___pawn.Named("PAWN")) : ((hediff == null)
                                         ? "AlteredCarbon.PawnDied".Translate(___pawn.LabelShortCap, ___pawn.Named("PAWN"))
                                         : "AlteredCarbon.PawnDiedBecauseOf".Translate(___pawn.LabelShortCap, hediff.def.LabelCap,
                                                                                       ___pawn.Named("PAWN"))));
             taggedString = taggedString.AdjustedFor(___pawn);
             TaggedString label = "AlteredCarbon.SleeveDeath".Translate() + ": " + ___pawn.LabelShortCap;
             Find.LetterStack.ReceiveLetter(label, taggedString, LetterDefOf.NegativeEvent, ___pawn);
         }
         DisableKilledEffect = false;
         return(false);
     }
     return(true);
 }
Ejemplo n.º 9
0
 public void AdvancedLaunch(Thing launcher, ThingDef effectMote, int moteFrequencyTicks, float curveAmount,
                            int variancePoints, bool shouldSpin, Vector3 origin, LocalTargetInfo targ, Thing flyingThing,
                            int flyingSpeed, bool isExplosion, int attackFrequency, float attackRadius, int _impactDamage,
                            float _impactRadius, DamageDef damageType, DamageInfo?newDamageInfo = null)
 {
     explosionDamage      = _impactDamage;
     isExplosive          = isExplosion;
     impactRadius         = _impactRadius;
     impactDamageType     = damageType;
     this.attackFrequency = attackFrequency;
     this.attackRadius    = attackRadius;
     moteFrequency        = moteFrequencyTicks;
     moteDef             = effectMote;
     curveVariance       = curveAmount;
     this.variancePoints = variancePoints;
     spinning            = shouldSpin;
     speed       = flyingSpeed;
     curvePoints = new List <Vector3>();
     curvePoints.Clear();
     Launch(launcher, origin, targ, flyingThing, newDamageInfo);
 }
Ejemplo n.º 10
0
        public override bool Trigger(Pawn pawn, DamageInfo?dinfo)
        {
            if (pawn == null)
            {
                return(false);
            }

            if (killedThings.Contains(pawn.GetUniqueLoadID()))
            {
                return(false);
            }

            if (dinfo?.Instigator?.def != RFDefOf.RF_Coilgun)
            {
                return(false);
            }

            bool result = base.Trigger(pawn, dinfo);

            return(result);
        }
Ejemplo n.º 11
0
        public override void Kill(DamageInfo?dinfo, Hediff exactCulprit = null)
        {
            if (IsSuicideBomber)
            {
                bombTickingInterval = -1f;
                bombWillGoOff       = false;
                hasTankyShield      = -1f;

                var def = ThingDef.Named("Apparel_BombVest");
                Drawer.renderer.graphics.apparelGraphics.RemoveAll(record => record.sourceApparel?.def == def);

                Map.GetComponent <TickManager>()?.AddExplosion(Position);
            }

            if (isToxicSplasher)
            {
                DropStickyGoo();
            }

            base.Kill(dinfo, exactCulprit);
        }
        public override void PostAdd(DamageInfo?dinfo)
        {
            if (base.Part == null)
            {
                Log.Error("Part is null. It should be set before PostAdd for " + this.def + ".", false);
                return;
            }

            this.pawn.health.RestorePart(base.Part, this, false);
            for (int i = 0; i < base.Part.parts.Count; i++)
            {
                if (base.Part.Index == 1)
                {
                    Hediff_MissingPart hediff_MissingPart = (Hediff_MissingPart)HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, this.pawn, null);
                    hediff_MissingPart.IsFresh    = true;
                    hediff_MissingPart.lastInjury = HediffDefOf.SurgicalCut;
                    hediff_MissingPart.Part       = base.Part.parts[i];
                    this.pawn.health.hediffSet.AddDirect(hediff_MissingPart, null, null);
                }
            }
        }
        /// <summary>
        /// Comps the post post add.
        /// </summary>
        /// <param name="dinfo">The dinfo.</param>
        public override void CompPostPostAdd(DamageInfo?dinfo)
        {
            base.CompPostPostAdd(dinfo);

            if (!PMUtilities.MutagenicDiseasesEnabled)
            {
                return;
            }

            var hasBuildup = Pawn.health?.hediffSet?.hediffs?.Any(h => h is MutagenicBuildup) == true;

            if (!hasBuildup)
            {
                return;
            }

            _shouldRemove = true;
            var hDef = HediffMaker.MakeHediff(MorphTransformationDefOf.PM_MutagenicInfection, Pawn, parent.Part);

            Pawn.health.AddHediff(hDef);
        }
Ejemplo n.º 14
0
        public void NotifyPlayerOfKilled(DamageInfo?dinfo, Hediff hediff, Caravan caravan)
        {
            string empty = string.Empty;

            empty = (dinfo.HasValue ? dinfo.Value.Def.deathMessage.Formatted(pawn.LabelShort.CapitalizeFirst(), pawn.Named("PAWN")) : ((hediff == null) ? "PawnDied".Translate(pawn.LabelShort.CapitalizeFirst(), pawn.Named("PAWN")) : "PawnDiedBecauseOf".Translate(pawn.LabelShort.CapitalizeFirst(), hediff.def.LabelCap, pawn.Named("PAWN"))));
            empty = empty.AdjustedFor(pawn);
            if (pawn.Faction == Faction.OfPlayer)
            {
                string label = "Death".Translate() + ": " + pawn.LabelShortCap;
                if (pawn.Name != null && !pawn.Name.Numerical && pawn.RaceProps.Animal)
                {
                    label = label + " (" + pawn.KindLabel + ")";
                }
                pawn.relations.CheckAppendBondedAnimalDiedInfo(ref empty, ref label);
                Find.LetterStack.ReceiveLetter(label, empty, LetterDefOf.Death, pawn);
            }
            else
            {
                Messages.Message(empty, pawn, MessageTypeDefOf.PawnDeath);
            }
        }
Ejemplo n.º 15
0
 public void Notify_PawnLost(Pawn pawn, PawnLostCondition cond, DamageInfo?dinfo = null)
 {
     if (this.ownedPawns.Contains(pawn))
     {
         this.RemovePawn(pawn);
         if (cond == PawnLostCondition.IncappedOrKilled || cond == PawnLostCondition.MadePrisoner)
         {
             this.numPawnsLostViolently++;
         }
         this.curJob.Notify_PawnLost(pawn, cond);
         if (this.lordManager.lords.Contains(this))
         {
             if (this.ownedPawns.Count == 0 && !this.CanExistWithoutPawns)
             {
                 this.lordManager.RemoveLord(this);
             }
             else
             {
                 this.curLordToil.Notify_PawnLost(pawn, cond);
                 TriggerSignal signal = default(TriggerSignal);
                 signal.type      = TriggerSignalType.PawnLost;
                 signal.thing     = pawn;
                 signal.condition = cond;
                 if (dinfo.HasValue)
                 {
                     signal.dinfo = dinfo.Value;
                 }
                 this.CheckTransitionOnSignal(signal);
             }
         }
         return;
     }
     Log.Error(string.Concat(new object[]
     {
         "Lord lost pawn ",
         pawn,
         " it didn't have. Condition=",
         cond
     }), false);
 }
        public override void CompPostPostAdd(DamageInfo?dinfo)
        {
            if (Pawn == null ||
                Pawn.Spawned == false ||
                Pawn.Map == null ||
                Pawn.Dead ||
                Pawn.IsColonist == false ||
                Pawn.health == null ||
                Pawn.health.hediffSet == null ||
                parent == null ||
                parent.Part == null ||
                parent.Part.def == null)
            {
                return;
            }

            if (parent.Part.def.IsSolid(parent.Part, Pawn.health.hediffSet.hediffs))
            {
                return;
            }
            if (Pawn.health.hediffSet.PartOrAnyAncestorHasDirectlyAddedParts(parent.Part))
            {
                return;
            }

            var h = GenDate.TicksPerHour;

            var ticks = ZombieSettings.Values.hoursInfectionIsUnknown * h;

            infectionKnownDelay = GenTicks.TicksAbs + ticks;

            if (Rand.Chance(ZombieSettings.Values.zombieBiteInfectionChance))
            {
                ticks = ZombieSettings.Values.hoursInfectionIsTreatable * h;
                infectionStartTime = GenTicks.TicksAbs + ticks;

                ticks            = ZombieSettings.Values.hoursInfectionPersists * h;
                infectionEndTime = infectionStartTime + ticks;
            }
        }
Ejemplo n.º 17
0
 public void Notify_MemberDied(Pawn member, DamageInfo?dinfo, bool wasWorldPawn, Map map)
 {
     if (this.IsPlayer)
     {
         return;
     }
     if (!wasWorldPawn && !PawnGenerator.IsBeingGenerated(member) && Current.ProgramState == ProgramState.Playing && map != null && map.IsPlayerHome && !this.HostileTo(Faction.OfPlayer))
     {
         if (dinfo.HasValue && dinfo.Value.Category == DamageInfo.SourceCategory.Collapse)
         {
             float num  = member.RaceProps.body.corePart.def.GetMaxHealth(member) * 1.3f * 0.5f * -1f;
             bool  flag = this.AffectGoodwillWith(Faction.OfPlayer, num);
             if (flag && MessagesRepeatAvoider.MessageShowAllowed("FactionRelationAdjustmentCrushed-" + this.Name, 5f))
             {
                 Messages.Message("MessageFactionPawnCrushed".Translate(new object[]
                 {
                     this.Name,
                     Mathf.RoundToInt(num)
                 }), member, MessageTypeDefOf.NegativeEvent);
             }
         }
         else if (dinfo.HasValue && (dinfo.Value.Instigator == null || dinfo.Value.Instigator.Faction == null))
         {
             float num2 = member.RaceProps.body.corePart.def.GetMaxHealth(member) * 1.3f * 0.1f * -1f;
             if (this.AffectGoodwillWith(Faction.OfPlayer, num2))
             {
                 Messages.Message("MessageFactionPawnLost".Translate(new object[]
                 {
                     this.Name,
                     member.NameStringShort,
                     Mathf.RoundToInt(num2)
                 }), member, MessageTypeDefOf.NegativeEvent);
             }
         }
     }
     if (member == this.leader)
     {
         this.Notify_LeaderDied();
     }
 }
Ejemplo n.º 18
0
        // TaleUtility.Notify_PawnDied(this, dinfo);
        public static void Pre_Notify_PawnDied(ref Pawn victim, ref DamageInfo?dinfo)
        {
            if (victim.Spawned && victim.Map != null)
            {
                List <Thing> thingList = victim.Position.GetThingList(victim.Map);
                for (int i = 0; i < thingList.Count; i++)
                {
                    Pawn pawn = thingList[i] as Pawn;

                    Building_MeatHook Building_MeatHook = thingList[i] as Building_MeatHook;
                    if (Building_MeatHook != null)
                    {
                        if (Building_MeatHook.hangedman == victim)
                        {
                            Building_MeatHook.hangedman = null;
                            Building_MeatHook.killcount++;
                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 19
0
        public override void PostAdd(DamageInfo?dinfo)
        {
            base.PostAdd(dinfo);

            oldGraphics = pawn.Drawer.renderer.graphics;
            oldShadow   = GetShadowGraphic(pawn.Drawer.renderer);
            pawn.Drawer.renderer.graphics = new PawnGraphicSet_Invisible(pawn);
            ShadowData shadowData = new ShadowData();

            shadowData.volume = new Vector3(0, 0, 0);
            shadowData.offset = new Vector3(0, 0, 0);
            SetShadowGraphic(pawn.Drawer.renderer, new Graphic_Shadow(shadowData));
            //pawn.Drawer.renderer.graphics.ResolveAllGraphics();


            pawn.stances.CancelBusyStanceHard();
            if (lastCarried != null && lastCarried == pawn.carryTracker.CarriedThing)
            {
                lastCarriedGraphic = pawn.carryTracker.CarriedThing.Graphic;
                SetGraphicInt(pawn.carryTracker.CarriedThing, new Graphic_Invisible());
            }
        }
        public override void PostAdd(DamageInfo?dinfo)
        {
            base.PostAdd(dinfo);
            this.gender = pawn.gender;
            if (ACUtils.ACTracker.stacksRelationships != null)
            {
                this.stackGroupID = ACUtils.ACTracker.stacksRelationships.Count + 1;
            }
            else
            {
                this.stackGroupID = 0;
            }
            var emptySleeveHediff = pawn.health.hediffSet.GetFirstHediffOfDef(AlteredCarbonDefOf.AC_EmptySleeve);

            if (emptySleeveHediff != null)
            {
                pawn.health.RemoveHediff(emptySleeveHediff);
            }

            ACUtils.ACTracker.RegisterPawn(pawn);
            ACUtils.ACTracker.TryAddRelationships(pawn);
        }
Ejemplo n.º 21
0
        public override void PostAdd(DamageInfo?dinfo)
        {
            base.PostAdd(dinfo);

            foreach (var v in def.skills)
            {
                SkillRecord rec = pawn.skills.GetSkill(v.skill);
                if (rec == null)
                {
                    return;
                }

                if (v.setTo != -1)
                {
                    rec.Level = v.setTo;
                }
                else
                {
                    rec.Notify_SkillDisablesChanged();
                }
            }
        }
Ejemplo n.º 22
0
    private int ApplyArmourRating(int damage, DamageType type)
    {
        var        armourRatings  = equipment.ArmourResistances;
        DamageInfo?relevantRating = armourRatings.FirstOrDefault(p => p.DamageType == type);

        if (relevantRating.HasValue)
        {
            var armourEffective = UnityEngine.Random.Range(0.0f, 1.0f) < armourEffectiveness;
            var armourBlocked   = UnityEngine.Random.Range(0.0f, 1.0f) < armourBlockChance;

            if (armourBlocked)
            {
                damage = 0;
            }
            else if (armourEffective)
            {
                damage = Mathf.Max(0, damage - relevantRating.Value.Value);
            }
        }

        return(damage);
    }
Ejemplo n.º 23
0
        public static bool PreFix(Pawn victim, DamageInfo?dinfo, PawnDiedOrDownedThoughtsKind thoughtsKind)
        {
            try
            {
                if (!PawnGenerator.IsBeingGenerated(victim) && Current.ProgramState == ProgramState.Playing)
                {
                    // This is the main redirection for our patches
                    switch (thoughtsKind)
                    {
                    case PawnDiedOrDownedThoughtsKind.Downed:
                        // There is potential here, simply wasted.
                        return(false);

                    case PawnDiedOrDownedThoughtsKind.Died:
                        // Let's see if this works; I hope it does.
                        // It works.
                        Handler_PawnDied.HandlePawnDied(victim, dinfo);
                        return(false);

                    case PawnDiedOrDownedThoughtsKind.BanishedToDie:
                        Handler_PawnBanished.HandlePawnBanished(victim, true);
                        return(false);

                    case PawnDiedOrDownedThoughtsKind.Banished:
                        Handler_PawnBanished.HandlePawnBanished(victim, false);
                        return(false);

                    default:
                        throw new InvalidOperationException();
                    }
                }
            }
            catch (Exception arg)
            {
                Log.Error("[V1024-DESYNC] Could not give thought, falling back to vanilla thought-giving procedures: " + arg, false);
            }

            return(true);
        }
        public void NotifyPlayerOfKilled(DamageInfo?dinfo, Hediff hediff, Caravan caravan)
        {
            TaggedString taggedString = "";

            taggedString = (dinfo.HasValue ? dinfo.Value.Def.deathMessage.Formatted(pawn.LabelShortCap, pawn.Named("PAWN")) : ((hediff == null) ? "PawnDied".Translate(pawn.LabelShortCap, pawn.Named("PAWN")) : "PawnDiedBecauseOf".Translate(pawn.LabelShortCap, hediff.def.LabelCap, pawn.Named("PAWN"))));
            Quest quest = null;

            if (pawn.IsBorrowedByAnyFaction())
            {
                foreach (QuestPart_LendColonistsToFaction item in QuestUtility.GetAllQuestPartsOfType <QuestPart_LendColonistsToFaction>())
                {
                    if (item.LentColonistsListForReading.Contains(pawn))
                    {
                        taggedString += "\n\n" + "LentColonistDied".Translate(pawn.Named("PAWN"), item.lendColonistsToFaction.Named("FACTION"));
                        quest         = item.quest;
                        break;
                    }
                }
            }
            taggedString = taggedString.AdjustedFor(pawn);
            if (pawn.Faction == Faction.OfPlayer)
            {
                TaggedString label = "Death".Translate() + ": " + pawn.LabelShortCap;
                if (caravan != null)
                {
                    Messages.Message("MessageCaravanDeathCorpseAddedToInventory".Translate(pawn.Named("PAWN")), caravan, MessageTypeDefOf.PawnDeath);
                }
                if (pawn.Name != null && !pawn.Name.Numerical && pawn.RaceProps.Animal)
                {
                    label += " (" + pawn.KindLabel + ")";
                }
                pawn.relations.CheckAppendBondedAnimalDiedInfo(ref taggedString, ref label);
                Find.LetterStack.ReceiveLetter(label, taggedString, LetterDefOf.Death, pawn, null, quest);
            }
            else
            {
                Messages.Message(taggedString, pawn, MessageTypeDefOf.PawnDeath);
            }
        }
Ejemplo n.º 25
0
            public static void Listener(Pawn ___pawn, DamageInfo?dinfo, Hediff hediff)
            {
                try {
                    // Deconnexion of Is surrogate android used et que appartenant au joueur ====>>>> POUR eviter les problemes de reminescence fantome de surrogates d'autres factions dans des Lord qui reste a cause du fait que le MakeDown les enleves de la liste mais le disconnect va essayer de relancer un CONNECT (dans le cadre des surrogates externes)
                    if (___pawn.IsSurrogateAndroid(true) && ___pawn.Faction.IsPlayer)
                    {
                        //Obtention controlleur
                        CompAndroidState cas = ___pawn.ATCompState;
                        if (cas == null)
                        {
                            return;
                        }

                        //Arret du mode de control chez le controller
                        CompSurrogateOwner cso = cas.surrogateController.ATCompSurrogateOwner;
                        cso.stopControlledSurrogate(null);
                    }
                }
                catch (Exception e) {
                    Log.Message("[ATPP] Pawn_HealthTracker.MakeDowned : " + e.Message + " - " + e.StackTrace);
                }
            }
Ejemplo n.º 26
0
        public void Launch(Thing launcher, Vector3 origin, LocalTargetInfo targ, Thing flyingThing, DamageInfo?newDamageInfo = null)
        {
            if (Find.Selector.FirstSelectedObject == launcher)
            {
                this.isSelected = true;
            }

            bool spawned = flyingThing.Spawned;

            pawn = launcher as Pawn;
            this.oldjobTarget = pawn.CurJob.targetA.Thing;
            //Log.Message("pre leap target is " + this.oldjobTarget.LabelShort);
            CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>();

            this.effVal = comp.MightData.MightPowerSkill_PsionicAugmentation.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PsionicAugmentation_eff").level;
            if (spawned)
            {
                flyingThing.DeSpawn();
            }
            //
            ModOptions.Constants.SetPawnInFlight(true);
            //
            this.origin       = origin;
            this.trueOrigin   = origin;
            this.impactDamage = newDamageInfo;
            this.flyingThing  = flyingThing;
            bool flag = targ.Thing != null;

            if (flag)
            {
                this.assignedTarget = targ.Thing;
            }
            this.trueDestination = targ.Cell.ToVector3Shifted();
            this.direction       = GetVector(this.trueOrigin.ToIntVec3(), targ.Cell);
            this.trueAngle       = (Quaternion.AngleAxis(90, Vector3.up) * this.direction).ToAngleFlat();
            this.destination     = targ.Cell.ToVector3Shifted();
            this.ticksToImpact   = this.StartingTicksToImpact;
            this.Initialize();
        }
 public override void CompPostPostAdd(DamageInfo?dinfo)
 {
     base.CompPostPostAdd(dinfo);
     if (Pawn.CurrentBed() == null && MyPos != null && MyMap != null && Pawn.Spawned)
     {
         //    Log.Message(string.Format("(Pawn.CurrentBed() == null && MyPos != null && MyMap != null && Pawn.Spawned) == {0}", (Pawn.CurrentBed() == null && MyPos != null && MyMap != null && Pawn.Spawned)));
         Rot4  rot   = Rotlist.RandomElement();
         Thing thing = ThingMaker.MakeThing(MyCocoonDef);
         GenSpawn.Spawn(thing, MyPos, MyMap, rot, WipeMode.Vanish, false);
         Building_XenomorphCocoon thing2 = ((Building_XenomorphCocoon)thing);
         if (this.Pawn.IsPrisoner)
         {
             thing2.ForPrisoners = true;
         }
         this.Pawn.jobs.Notify_TuckedIntoBed(thing2);
         this.Pawn.mindState.Notify_TuckedIntoBed();
     }
     if (!PlayerKnowledgeDatabase.IsComplete(XenomorphConceptDefOf.RRY_Concept_Cocoons) && Pawn.IsColonist)
     {
         LessonAutoActivator.TeachOpportunity(XenomorphConceptDefOf.RRY_Concept_Cocoons, OpportunityType.Critical);
     }
 }
            public static void Listener(Pawn victim, DamageInfo?dinfo)
            {
                try
                {
                    if (victim.IsSurrogateAndroid())
                    {
                        Utils.insideKillFuncSurrogate = true;
                    }
                    //Deconnecte le tué
                    Utils.GCATPP.disconnectUser(victim);
                    //Log.Message("YOU KILLED "+__instance.LabelCap);
                    //Is surrogate android used ?
                    if (victim.IsSurrogateAndroid(true))
                    {
                        //Obtention controlleur
                        CompAndroidState cas = victim.TryGetComp <CompAndroidState>();
                        if (cas == null)
                        {
                            return;
                        }

                        //Arret du mode de control chez le controller
                        CompSurrogateOwner cso = cas.surrogateController.TryGetComp <CompSurrogateOwner>();
                        cso.stopControlledSurrogate(victim);
                    }
                    //Log.Message("YOU KILLED END");
                    Utils.insideKillFuncSurrogate = false;
                }
                catch (Exception e)
                {
                    Log.Message("[ATPP] TaleUtility.Notify_PawnDied(Error) : " + e.Message + " - " + e.StackTrace);

                    if (victim.IsSurrogateAndroid())
                    {
                        Utils.insideKillFuncSurrogate = false;
                    }
                }
            }
        public void Launch(Thing launcher, Vector3 origin, LocalTargetInfo targ, Thing flyingThing,
                           DamageInfo?newDamageInfo = null)
        {
            Initialize();
            var spawned = flyingThing.Spawned;

            pawn = launcher as Pawn;
            if (spawned)
            {
                flyingThing.DeSpawn();
            }

            this.launcher    = launcher;
            this.origin      = origin;
            impactDamage     = newDamageInfo;
            this.flyingThing = flyingThing;

            var comp = pawn?.GetComp <CompWizardry>();

            if (comp != null && comp.SecondTarget != null)
            {
                if (comp.SecondTarget.Thing != null)
                {
                    destination    = comp.SecondTarget.Thing.Position.ToVector3Shifted();
                    assignedTarget = comp.SecondTarget.Thing;
                }
                else
                {
                    destination = comp.SecondTarget.CenterVector3;
                }
            }
            else
            {
                destination = targ.Cell.ToVector3Shifted();
            }

            ticksToImpact = StartingTicksToImpact;
        }
Ejemplo n.º 30
0
        // Token: 0x060010C8 RID: 4296 RVA: 0x0005FC00 File Offset: 0x0005DE00
        public override void CompPostPostAdd(DamageInfo?dinfo)
        {
            /*
             * if (this.parent.IsPermanent())
             * {
             *      this.ticksUntilIrradiate = -2;
             *      return;
             * }
             * if (this.parent.Part.def.IsSolid(this.parent.Part, base.Pawn.health.hediffSet.hediffs))
             * {
             *      this.ticksUntilIrradiate = -2;
             *      return;
             * }
             * if (base.Pawn.health.hediffSet.PartOrAnyAncestorHasDirectlyAddedParts(this.parent.Part))
             * {
             *      this.ticksUntilIrradiate = -2;
             *      return;
             * }
             */
            float num = this.Props.infectionChance;

            /*
             * if (base.Pawn.RaceProps.Animal)
             * {
             *      num *= 0.1f;
             * }
             */
            /*
             * if (Rand.Value <= num)
             * {
             *      this.ticksUntilInfect = HealthTuning.InfectionDelayRange.RandomInRange;
             *      return;
             * }
             */
            this.ticksUntilIrradiate = HealthTuning.InfectionDelayRange.RandomInRange;
            return;
            //	this.ticksUntilIrradiate = -2;
        }