Exemplo n.º 1
0
        protected Toil GetToilPlayTheGuitar()
        {
            int tickCounter = 0;

            Toil toil = new Toil()
            {
                initAction = () =>
                {
                    tickCounter = Rand.Range(35, 50);
                    MoteDualAttached moteAttached = (MoteDualAttached)ThingMaker.MakeThing(Util_CampfireParty.Mote_Guitar);
                    moteAttached.Attach(this.pawn);
                    GenSpawn.Spawn(moteAttached, this.pawn.Position);
                    this.pawn.Drawer.rotator.FaceCell(this.pawn.Position + new IntVec3(0, 0, -1));
                },
                tickAction = () =>
                {
                    tickCounter--;
                    if (tickCounter <= 0)
                    {
                        tickCounter = Rand.Range(35, 50);
                        MoteMaker.MakeColonistActionOverlay(this.pawn, Util_CampfireParty.Mote_MusicNote);
                    }
                    // Gain some joy.
                    this.pawn.needs.joy.GainJoy(this.CurJob.def.joyGainRate * 0.000144f, Util_CampfireParty.JoyKindDefOf_Social);
                    this.pawn.Drawer.rotator.FaceCell(this.pawn.Position + new IntVec3(0, 0, -1));
                },
                defaultDuration     = 240,
                defaultCompleteMode = ToilCompleteMode.Delay
            };

            return(toil);
        }
Exemplo n.º 2
0
        // Token: 0x06000005 RID: 5 RVA: 0x00002327 File Offset: 0x00000527
        protected override IEnumerable <Toil> MakeNewToils()
        {
            var actor = GetActor();

            this.FailOn(() => actor.Dead || actor.Downed || !actor.Spawned);
            yield return(new Toil
            {
                atomicWithPrevious = true,
                defaultCompleteMode = ToilCompleteMode.Instant,
                initAction = delegate
                {
                    if (pawn.IsColonist)
                    {
                        MoteMaker.MakeColonistActionOverlay(pawn, ThingDefOf.Mote_ColonistFleeing);
                    }
                }
            });

            yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell));
        }
Exemplo n.º 3
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            //this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            this.FailOn(delegate
            {
                return(pawn == Victim);
            });
            this.FailOn(delegate
            {
                return(BloodMaster.CurBloodPoints == 0);
            });
            this.FailOnAggroMentalState(TargetIndex.A);

            yield return(Toils_Reserve.Reserve(TargetIndex.A));

            var  newDomitor = GetActor();
            var  toil       = newDomitor?.Faction == TargetA.Thing?.Faction ? Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch) : Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);
            Toil gotoToil   = toil;

            yield return(gotoToil);

            Toil grappleToil = new Toil()
            {
                initAction = delegate
                {
                    MoteMaker.MakeColonistActionOverlay(newDomitor, ThingDefOf.Mote_ColonistAttacking);

                    workLeft = BaseFeedTime;
                    Pawn victim = TargetA.Thing as Pawn;
                    if (victim != null)
                    {
                        if (newDomitor.InAggroMentalState || victim.InAggroMentalState || victim.Faction != newDomitor.Faction)
                        {
                            int grappleBonus = newDomitor is PawnTemporary ? 100 : 0;
                            if (!JecsTools.GrappleUtility.TryGrapple(newDomitor, victim, grappleBonus))
                            {
                                this.EndJobWith(JobCondition.Incompletable);
                                PawnUtility.ForceWait(newDomitor, (int)(BaseFeedTime * 0.15f));
                                return;
                            }
                        }
                        if (newDomitor.IsVampire())
                        {
                            //VampireBiteUtility.MakeNew(GetActor(), GetActor()); //Actor opens their own wound.
                            victim.stances.stunner.StunFor((int)BaseFeedTime, newDomitor);
                        }
                    }
                }
            };

            yield return(grappleToil);

            Toil feedToil = new Toil()
            {
                tickAction = delegate
                {
                    //try
                    //{
                    if (TargetA.Thing is Pawn victim && victim.Spawned && !victim.Dead)
                    {
                        workLeft--;
                        VampireWitnessUtility.HandleWitnessesOf(this.job.def, newDomitor, victim);
//                            if (victim?.needs?.mood?.thoughts?.memories != null)
//                            {
//                                var victimThoughtDef = VampDefOf.ROMV_IDrankVitae;
//                                Thought_Memory victimThought = null;
//                                if (victimThoughtDef != null) victimThought = (Thought_Memory)ThoughtMaker.MakeThought(victimThoughtDef);
//                                if (victimThought != null)
//                                {
//                                    victim.needs.mood.thoughts.memories.TryGainMemory(victimThought);
//                                }
//                            }
                        if (workLeft <= 0f)
                        {
                            if (newDomitor?.VampComp() is CompVampire v && v.IsVampire && newDomitor.Faction == Faction.OfPlayer)
                            {
                                MoteMaker.ThrowText(newDomitor.DrawPos, newDomitor.Map, "XP +" + 15);
                                v.XP += 15;
                            }
                            workLeft = BaseFeedTime;
                            MoteMaker.MakeColonistActionOverlay(newDomitor, ThingDefOf.Mote_ColonistAttacking);

                            if (!victim.IsGhoul())
                            {
                                CompThrall.InitializeGhoul(newDomitor);
                            }
                            else
                            {
                                CompThrall.ThrallData.TryAdjustBondStage(newDomitor, 1);
                            }
                            BloodMaster.TransferBloodTo(1, BloodThrall, true, true);
                            GhoulUtility.GiveVitaeEffects(victim, newDomitor);
                            //VampireBiteUtility.CleanBite(GetActor(), GetActor());
                            this.ReadyForNextToil();
                        }
                    }
Exemplo n.º 4
0
        public static IEnumerable <Toil> MakeFeedToils(JobDriver thisDriver, Pawn actor, LocalTargetInfo TargetA, float workLeft, Action effect, Func <Pawn, Pawn, bool> stopCondition)
        {
            yield return(Toils_Reserve.Reserve(TargetIndex.A));

            Toil gotoToil = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);

            yield return(gotoToil);

            Toil grappleToil = new Toil()
            {
                initAction = delegate
                {
                    MoteMaker.MakeColonistActionOverlay(actor, ThingDefOf.Mote_ColonistAttacking);

                    workLeft = JobDriver_Feed.BaseFeedTime;
                    Pawn victim = (Pawn)TargetA.Thing;
                    if (victim != null)
                    {
                        if (victim.InAggroMentalState || victim.Faction != actor.Faction)
                        {
                            if (!JecsTools.GrappleUtility.CanGrapple(actor, victim))
                            {
                                thisDriver.EndJobWith(JobCondition.Incompletable);
                            }
                        }
                        GenClamor.DoClamor(actor, 10f, ClamorDefOf.Harm);
                        if (!AllowFeeding(actor, victim))
                        {
                            actor.jobs.EndCurrentJob(JobCondition.Incompletable);
                        }
                        if (actor?.VampComp()?.Bloodline?.bloodlineHediff?.CompProps <HediffCompProperties_VerbGiver>()?.verbs is List <VerbProperties> verbProps)
                        {
                            if (actor?.VerbTracker?.AllVerbs is List <Verb> verbs)
                            {
                                if (verbs.Find(x => verbProps.Contains(x.verbProps)) is Verb_MeleeAttack v)
                                {
                                    victim.TakeDamage(new DamageInfo(v.verbProps.meleeDamageDef, v.verbProps.meleeDamageBaseAmount, 0, -1, actor));
                                }
                            }
                        }
                        victim.stances.stunner.StunFor((int)BaseFeedTime);
                    }
                }
            };

            yield return(grappleToil);

            Toil feedToil = new Toil()
            {
                tickAction = delegate
                {
                    Pawn victim = (Pawn)TargetA.Thing;
                    if (victim == null || !victim.Spawned || victim.Dead)
                    {
                        thisDriver.ReadyForNextToil();
                    }
                    workLeft--;

                    if (workLeft <= 0f)
                    {
                        if (actor?.VampComp() is CompVampire v && v.IsVampire && actor.Faction == Faction.OfPlayer)
                        {
                            MoteMaker.ThrowText(actor.DrawPos, actor.Map, "XP +" + 15);
                            v.XP += 15;
                        }
                        workLeft = BaseFeedTime;
                        MoteMaker.MakeColonistActionOverlay(actor, ThingDefOf.Mote_ColonistAttacking);
                        effect();
                        if ((victim.HostileTo(actor.Faction) || victim.IsPrisoner) && !JecsTools.GrappleUtility.CanGrapple(actor, victim))
                        {
                            thisDriver.EndJobWith(JobCondition.Incompletable);
                        }

                        if (!stopCondition(actor, victim))
                        {
                            thisDriver.ReadyForNextToil();
                        }
                        else
                        {
                            if (victim != null && !victim.Dead)
                            {
                                victim.stances.stunner.StunFor((int)BaseFeedTime);
                                PawnUtility.ForceWait((Pawn)TargetA.Thing, (int)BaseFeedTime, actor);
                            }
                        }
                    }
                },
        public static IEnumerable <Toil> MakeFeedToils(JobDef job, JobDriver thisDriver, Pawn actor, LocalTargetInfo TargetA, ThoughtDef victimThoughtDef, ThoughtDef actorThoughtDef, float workLeft, Action effect, Func <Pawn, Pawn, bool> stopCondition, bool needsGrapple = true, bool cleansWound = true, bool neverGiveUp = false)
        {
            yield return(Toils_Reserve.Reserve(TargetIndex.A));

            Toil gotoToil = actor?.Faction == TargetA.Thing?.Faction && (!actor.InAggroMentalState && !((Pawn)TargetA.Thing).InAggroMentalState) ? Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch) : Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);

            yield return(gotoToil);

            Toil grappleToil = new Toil()
            {
                initAction = delegate
                {
                    MoteMaker.MakeColonistActionOverlay(actor, ThingDefOf.Mote_ColonistAttacking);

                    workLeft = BaseFeedTime;
                    Pawn victim = TargetA.Thing as Pawn;
                    if (victim != null)
                    {
//                        if (!AllowFeeding(actor, victim))
//                        {
//                            actor.jobs.EndCurrentJob(JobCondition.Incompletable);
//                        }
                        if (actor.InAggroMentalState || victim.InAggroMentalState || victim.Faction != actor.Faction)
                        {
                            if (needsGrapple)
                            {
                                int grappleBonus = actor is PawnTemporary ? 100 : 0;
                                if (!JecsTools.GrappleUtility.TryGrapple(actor, victim, grappleBonus))
                                {
                                    thisDriver.EndJobWith(JobCondition.Incompletable);
                                    PawnUtility.ForceWait(actor, (int)(BaseFeedTime * 0.15f));
                                    return;
                                }
                            }
                        }
                        if (actor.IsVampire())
                        {
                            VampireBiteUtility.MakeNew(actor, victim);
                        }
                        victim.stances.stunner.StunFor((int)BaseFeedTime, actor);
                    }
                }
            };

            yield return(grappleToil);

            Toil feedToil = new Toil()
            {
                tickAction = delegate
                {
                    //try
                    //{
                    if (TargetA.Thing is Pawn victim && victim.Spawned && !victim.Dead)
                    {
                        workLeft--;
                        VampireWitnessUtility.HandleWitnessesOf(job, actor, victim);
                        if (victim?.needs?.mood?.thoughts?.memories != null)
                        {
                            Thought_Memory victimThought = null;
                            if (victimThoughtDef != null)
                            {
                                victimThought = (Thought_Memory)ThoughtMaker.MakeThought(victimThoughtDef);
                            }
                            if (victimThought != null)
                            {
                                victim.needs.mood.thoughts.memories.TryGainMemory(victimThought);
                            }
                        }
                        if (actor?.needs?.mood?.thoughts?.memories != null)
                        {
                            Thought_Memory actorThought = null;
                            if (actorThoughtDef != null)
                            {
                                actorThought = (Thought_Memory)ThoughtMaker.MakeThought(actorThoughtDef);
                            }
                            if (actorThought != null)
                            {
                                actor.needs.mood.thoughts.memories.TryGainMemory(actorThought);
                            }
                        }


                        if (workLeft <= 0f)
                        {
                            if (actor?.VampComp() is CompVampire v && v.IsVampire && actor.Faction == Faction.OfPlayer)
                            {
                                MoteMaker.ThrowText(actor.DrawPos, actor.Map, "XP +" + 15);
                                v.XP    += 15;
                                workLeft = BaseFeedTime;
                                MoteMaker.MakeColonistActionOverlay(actor, ThingDefOf.Mote_ColonistAttacking);
                            }

                            effect();
                            if (victim != null && !victim.Dead && needsGrapple)
                            {
                                int victimBonus = (victim.VampComp() is CompVampire victimVampComp) ? -victimVampComp.Generation + 14 : 0;
                                int actorBonus  = 0;
                                if (actor?.VampComp() is CompVampire v2 && v2.IsVampire)
                                {
                                    actorBonus = -v2.Generation + 14;
                                }
                                if (!JecsTools.GrappleUtility.TryGrapple(actor, victim, actorBonus, victimBonus))
                                {
                                    thisDriver.EndJobWith(JobCondition.Incompletable);
                                }
                            }

                            if (!stopCondition(actor, victim))
                            {
                                thisDriver.ReadyForNextToil();
                                if (actor.IsVampire() && cleansWound)
                                {
                                    VampireBiteUtility.CleanBite(actor, victim);
                                }
                            }
                            else
                            {
                                if (victim != null && !victim.Dead)
                                {
                                    victim.stances.stunner.StunFor((int)BaseFeedTime, actor);
                                    PawnUtility.ForceWait((Pawn)TargetA.Thing, (int)BaseFeedTime, actor);
                                }
                            }
                        }
                    }