protected override bool TryCastShot()
        {
            bool flag = false;

            this.TargetsAoE.Clear();
            this.UpdateTargets();
            int  shotsPerBurst = this.ShotsPerBurst;
            bool flag2         = this.UseAbilityProps.AbilityTargetCategory != AbilityTargetCategory.TargetAoE && this.TargetsAoE.Count > 1;

            if (flag2)
            {
                this.TargetsAoE.RemoveRange(0, this.TargetsAoE.Count - 1);
            }
            bool flag3 = this.UseAbilityProps.mustHaveTarget && this.TargetsAoE.Count == 0;
            bool result;

            if (flag3)
            {
                Messages.Message("AU_NoTargets".Translate(), MessageTypeDefOf.RejectInput, true);
                this.Ability.Notify_AbilityFailed(true);
                result = false;
            }
            else
            {
                for (int i = 0; i < this.TargetsAoE.Count; i++)
                {
                    bool abilitySucceeded = true;
                    if (TargetsAoE[i].Thing != null && TargetsAoE[i].Thing is Pawn targetPawn && targetPawn.RaceProps.Humanlike)
                    {
                        abilitySucceeded = SemblanceUtility.UnlockAura(targetPawn, "LetterTextUnlockAuraPyrrha");
                    }
Beispiel #2
0
 public override void CompTick()
 {
     base.CompTick();
     if (Pawn.health.hediffSet.HasHediff(RWBYDefOf.RWBY_AuraStolen))
     {
         return;
     }
     if (hiddenSemblance == null)
     {
         GenerateHiddenSemblance();
     }
     if (IsInitialized)
     {
         aura.Tick();
     }
     else
     {
         if (auraAutoUnlock >= 0)
         {
             auraAutoUnlock--;
         }
         if (auraAutoUnlock == 0)
         {
             SemblanceUtility.UnlockAura(AbilityUser, "LetterTextUnlockAuraAuto");
         }
     }
 }
Beispiel #3
0
        public void GenerateHiddenSemblance()
        {
            if (AbilityUser.relations.RelatedPawns.Any(p => p.relations.Children.Contains(AbilityUser) && p.story.traits.HasTrait(RWBYDefOf.Semblance_Weiss)) || AbilityUser.relations.Children.Any(c => c.story.traits.HasTrait(RWBYDefOf.Semblance_Weiss)))
            {
                hiddenSemblance = RWBYDefOf.Semblance_Weiss;
                return;
            }
            List <TraitDef> traitDefs = new List <TraitDef>();

            foreach (SkillRecord skillRecord in AbilityUser.skills.skills)
            {
                if (skillRecord.passion == Passion.Minor)
                {
                    traitDefs.AddRange(SemblanceUtility.GetSemblancesForPassion(skillRecord.def));
                }
                else if (skillRecord.passion == Passion.Major)
                {
                    traitDefs.AddRange(SemblanceUtility.GetSemblancesForPassion(skillRecord.def));
                    traitDefs.AddRange(SemblanceUtility.GetSemblancesForPassion(skillRecord.def));
                }
            }
            traitDefs.RemoveAll(t => AbilityUser.WorkTagIsDisabled(t.requiredWorkTags));
            if (traitDefs.Count == 0)
            {
                hiddenSemblance = SemblanceUtility.semblanceList.FindAll(s => !AbilityUser.WorkTagIsDisabled(s.requiredWorkTags)).RandomElement(); // should never be empty, as there are Semblances without required workTags
            }
            else
            {
                List <TraitDef>            allPossibleTraits = traitDefs.Distinct().ToList();
                Dictionary <TraitDef, int> keyValuePairs     = new Dictionary <TraitDef, int>();
                foreach (TraitDef traitDef in traitDefs)
                {
                    if (keyValuePairs.ContainsKey(traitDef))
                    {
                        keyValuePairs[traitDef]++;
                    }
                    else
                    {
                        keyValuePairs.Add(traitDef, 1);
                    }
                }
                int             highestCount       = keyValuePairs.Values.ToList().OrderByDescending(i => i).First();
                List <TraitDef> mostMatchingTraits = new List <TraitDef>();
                foreach (KeyValuePair <TraitDef, int> keyValuePair in keyValuePairs)
                {
                    if (keyValuePair.Value == highestCount)
                    {
                        mostMatchingTraits.Add(keyValuePair.Key);
                    }
                }
                hiddenSemblance = mostMatchingTraits.RandomElement();
            }
        }
Beispiel #4
0
 public bool TryUnlockSemblanceWith(SkillDef skillDef, bool forceUnlock = false)
 {
     if (forceUnlock)
     {
         return(SemblanceUtility.UnlockSemblance(AbilityUser, hiddenSemblance, "LetterTextUnlockSemblanceGeneral"));
     }
     if (SemblanceUtility.GetSemblancesForPassion(skillDef).Contains(hiddenSemblance))
     {
         return(SemblanceUtility.UnlockSemblance(AbilityUser, hiddenSemblance, "LetterTextUnlock" + hiddenSemblance.defName.Replace("_", "")));
     }
     return(false);
 }
Beispiel #5
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map         map          = (Map)parms.target;
            List <Pawn> injuredPawns = map.PlayerPawnsForStoryteller.ToList().FindAll(p => p.RaceProps.Humanlike && p.health.hediffSet.hediffs.Any(a => a.GetType().Equals(typeof(Hediff_Injury)) && ((Hediff_Injury)a).TendableNow(true)));

            injuredPawns.RemoveAll(p => p.health.hediffSet.HasHediff(RWBYDefOf.RWBY_AuraStolen));
            List <Pawn> pawnsWithoutAura = injuredPawns.FindAll(p => !p.story.traits.HasTrait(RWBYDefOf.RWBY_Aura) && !SemblanceUtility.semblanceList.Any(s => p.story.traits.HasTrait(s)));

            if (pawnsWithoutAura.Count == 0)
            {
                return(false);
            }
            Pawn pawnWithoutAura = pawnsWithoutAura.RandomElement();

            return(SemblanceUtility.UnlockAura(pawnWithoutAura, "LetterTextUnlockAuraHurt"));
        }
Beispiel #6
0
        protected override bool TryCastShot()
        {
            bool flag = false;

            this.TargetsAoE.Clear();
            this.UpdateTargets();
            int  shotsPerBurst = this.ShotsPerBurst;
            bool flag2         = this.UseAbilityProps.AbilityTargetCategory != AbilityTargetCategory.TargetAoE && this.TargetsAoE.Count > 1;

            if (flag2)
            {
                this.TargetsAoE.RemoveRange(0, this.TargetsAoE.Count - 1);
            }
            bool flag3 = this.UseAbilityProps.mustHaveTarget && this.TargetsAoE.Count == 0;
            bool result;

            if (flag3)
            {
                Messages.Message("AU_NoTargets".Translate(), MessageTypeDefOf.RejectInput, true);
                this.Ability.Notify_AbilityFailed(true);
                result = false;
            }
            else
            {
                for (int i = 0; i < this.TargetsAoE.Count; i++)
                {
                    bool abilitySucceeded = true;
                    if (TargetsAoE[i].Cell.GetThingList(CasterPawn.Map) != null && TargetsAoE[i].Cell.GetThingList(CasterPawn.Map).Find(t => SemblanceUtility.PyrrhaMagnetismCanAffect(t)) is ThingWithComps thingWithComps && !MassUtility.WillBeOverEncumberedAfterPickingUp(CasterPawn, thingWithComps, 1))
                    {
                        thingWithComps.DeSpawn();
                        abilitySucceeded = CasterPawn.inventory.GetDirectlyHeldThings().TryAdd(thingWithComps);
                    }
Beispiel #7
0
        protected override bool TryCastShot()
        {
            bool flag = false;

            this.TargetsAoE.Clear();
            this.UpdateTargets();
            int  shotsPerBurst = this.ShotsPerBurst;
            bool flag2         = this.UseAbilityProps.AbilityTargetCategory != AbilityTargetCategory.TargetAoE && this.TargetsAoE.Count > 1;

            if (flag2)
            {
                this.TargetsAoE.RemoveRange(0, this.TargetsAoE.Count - 1);
            }
            bool flag3 = this.UseAbilityProps.mustHaveTarget && this.TargetsAoE.Count == 0;
            bool result;

            if (flag3)
            {
                Messages.Message("AU_NoTargets".Translate(), MessageTypeDefOf.RejectInput, true);
                this.Ability.Notify_AbilityFailed(true);
                result = false;
            }
            else
            {
                for (int i = 0; i < this.TargetsAoE.Count; i++)
                {
                    bool abilitySucceeded = true;
                    foreach (Thing thing in CasterPawn.Map.spawnedThings)
                    {
                        if (CasterPawn.Position.DistanceTo(thing.Position) <= this.verbProps.range && SemblanceUtility.PyrrhaMagnetismCanAffect(thing))
                        {
                            if (thing is Pawn pawn && !pawn.HostileTo(CasterPawn))
                            {
                                Thought_Memory thought_Memory = (Thought_Memory)ThoughtMaker.MakeThought(RWBYDefOf.RWBY_PyrrhaHurtFriendly);
                                pawn.needs.mood.thoughts.memories.TryGainMemory(thought_Memory);
                            }
                            DamageInfo dinfo1 = new DamageInfo(DamageDefOf.EMP, 1f, 0f, -1f, CasterPawn, null, CasterPawn.def, DamageInfo.SourceCategory.ThingOrUnknown, thing);
                            dinfo1.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside);
                            Vector3 direction1 = (thing.Position - CasterPawn.Position).ToVector3();
                            dinfo1.SetAngle(direction1);
                            thing.TakeDamage(dinfo1);

                            DamageInfo dinfo2 = new DamageInfo(DamageDefOf.Blunt, 200f, 0f, -1f, CasterPawn, null, CasterPawn.def, DamageInfo.SourceCategory.ThingOrUnknown, thing);
                            dinfo2.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside);
                            Vector3 direction2 = (thing.Position - CasterPawn.Position).ToVector3();
                            dinfo2.SetAngle(direction2);
                            thing.TakeDamage(dinfo2);
                        }
                    }

                    if (abilitySucceeded)
                    {
                        flag = true;
                    }
                }
                this.PostCastShot(flag, out flag);
                bool postSucceed = !flag;
                if (postSucceed)
                {
                    this.Ability.Notify_AbilityFailed(this.UseAbilityProps.refundsPointsAfterFailing);
                }
                result = flag;
            }
            return(result);
        }