Ejemplo n.º 1
0
        // Token: 0x06000035 RID: 53 RVA: 0x000031C0 File Offset: 0x000013C0
        protected override void UpdateEnemyTarget(Pawn pawn)
        {
            MentalState_Fighter state = (MentalState_Fighter)pawn.MentalState;
            Pawn pawnTarget           = state.otherPawn;

            pawn.mindState.enemyTarget = pawnTarget;
            Find.TickManager.slower.SignalForceNormalSpeed();
        }
Ejemplo n.º 2
0
        // Token: 0x06000056 RID: 86 RVA: 0x00003870 File Offset: 0x00001A70
        private void startFightingState(Fighter f)
        {
            f.p.mindState.enemyTarget = this.getOtherFighter(f).p;
            f.p.jobs.StopAll(false);
            f.p.mindState.mentalStateHandler.Reset();
            MentalStateHandler mentalStateHandler = f.p.mindState.mentalStateHandler;
            MentalStateDef     ArenaFighting      = MentalStateDefOfArena.Fighter;
            Pawn           pawn      = f.p;
            MentalStateDef stateDef  = ArenaFighting;
            Pawn           otherPawn = this.getOtherFighter(f).p;

            mentalStateHandler.TryStartMentalState(stateDef, "", false, false, null, true);
            MentalState_Fighter mentalState = f.p.MentalState as MentalState_Fighter;

            mentalState.otherPawn = this.getOtherFighter(f).p;
            mentalState.bellRef   = this;
        }
Ejemplo n.º 3
0
        // Token: 0x06000031 RID: 49 RVA: 0x00002C44 File Offset: 0x00000E44
        protected override Job TryGiveJob(Pawn pawn)
        {
            MentalState_Fighter state = (MentalState_Fighter)pawn.MentalState;
            Pawn          pawnTarget  = state.otherPawn;
            Building_Bell bellRef     = state.bellRef;
            Job           result;
            Fighter       fighterTarget = bellRef.getFighter(pawnTarget);

            if (!fighterTarget.isInFight || (double)Rand.Value < 0.5)
            {
                result = new Job(JobDefOf.Wait_Combat)
                {
                    expiryInterval = 10
                };
            }
            else
            {
                if (pawn.TryGetAttackVerb(null, false) == null)
                {
                    result = null;
                }
                else
                {
                    ThingWithComps primary = pawn.equipment != null ? pawn.equipment.Primary : null;
                    if (bellRef.currentState == Building_Bell.State.fight && pawn.equipment != null && primary == null)
                    {
                        List <Thing> suitableWeapons = new List <Thing>();
                        foreach (IntVec3 c in bellRef.GetComp <CompBell>().ValidCells)
                        {
                            List <Thing> thingList = c.GetThingList(bellRef.Map);
                            for (int i = 0; i < thingList.Count; i++)
                            {
                                Thing t     = thingList[i];
                                bool  flag8 = t.def.IsWeapon && !suitableWeapons.Contains(t) && t.Spawned && pawn.CanReserve(t, 1, -1, null, false);
                                if (flag8)
                                {
                                    suitableWeapons.Add(t);
                                }
                            }
                        }
                        Thing weapon      = null;
                        int   maxDistance = 9999;
                        foreach (Thing t2 in suitableWeapons)
                        {
                            if ((t2.Position - pawn.Position).LengthManhattan < maxDistance)
                            {
                                weapon      = t2;
                                maxDistance = (t2.Position - pawn.Position).LengthManhattan;
                            }
                        }
                        if (weapon != null)
                        {
                            return(new Job(JobDefOf.Equip, weapon));
                        }
                    }
                    if (pawnTarget == null || !pawn.CanReach(pawnTarget, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                    {
                        result = new Job(JobDefOf.Wait);
                    }
                    else
                    {
                        pawn.mindState.enemyTarget = pawnTarget;
                        pawn.mindState.enemyTarget = pawnTarget;
                        this.UpdateEnemyTarget(pawn);
                        Thing enemyTarget = pawn.mindState.enemyTarget;

                        if (enemyTarget == null)
                        {
                            result = null;
                        }
                        else
                        {
                            bool allowManualCastWeapons = !pawn.IsColonist;
                            Verb verb = pawn.TryGetAttackVerb(enemyTarget, allowManualCastWeapons);
                            if (verb == null)
                            {
                                result = null;
                            }
                            else
                            {
                                bool isMeleeAttack = verb.verbProps.IsMeleeAttack;
                                if (isMeleeAttack || pawnTarget.Downed)
                                {
                                    result = this.MeleeAttackJob(enemyTarget);
                                    result.killIncappedTarget = bellRef.toDeath;
                                }
                                else
                                {
                                    if ((
                                            CoverUtility.CalculateOverallBlockChance(pawn, enemyTarget.Position, pawn.Map) > 0.01f &&
                                            pawn.Position.Standable(pawn.Map) &&
                                            verb.CanHitTarget(enemyTarget)
                                            ) || (
                                            (pawn.Position - enemyTarget.Position).LengthHorizontalSquared < 25 &&
                                            verb.CanHitTarget(enemyTarget)
                                            ))
                                    {
                                        result = new Job(JobDefOf.AttackStatic, pawnTarget)
                                        {
                                            maxNumMeleeAttacks = 1,
                                            expiryInterval     = Rand.Range(420, 900),
                                            canBash            = true
                                        };
                                    }
                                    else
                                    {
                                        IntVec3 intVec;
                                        if (!this.TryFindShootingPosition(pawn, out intVec))
                                        {
                                            result = null;
                                        }
                                        else
                                        {
                                            if (intVec == pawn.Position)
                                            {
                                                result = new Job(JobDefOf.AttackStatic, pawnTarget)
                                                {
                                                    maxNumMeleeAttacks = 1,
                                                    expiryInterval     = Rand.Range(420, 900),
                                                    canBash            = true
                                                };
                                            }
                                            else
                                            {
                                                result = new Job(JobDefOf.Goto, intVec)
                                                {
                                                    expiryInterval        = JobGiver_AIFightEnemy.ExpiryInterval_ShooterSucceeded.RandomInRange,
                                                    checkOverrideOnExpire = true
                                                };
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }