Ejemplo n.º 1
0
 public static void Evaluate(CompAbilityUserMight casterComp, TMAbilityDef abilitydef, PawnAbility ability, MightPower power, out bool success)
 {
     success = false;
     if (casterComp.Stamina.CurLevel >= abilitydef.staminaCost && ability.CooldownTicksLeft <= 0)
     {
         Pawn            caster           = casterComp.Pawn;
         LocalTargetInfo jobTarget        = TM_Calc.FindNearbyFighter(caster, (int)(abilitydef.MainVerb.range * 1.5f), false);
         float           distanceToTarget = (jobTarget.Cell - caster.Position).LengthHorizontal;
         if (distanceToTarget < (abilitydef.MainVerb.range * 1.5f) && jobTarget != null && jobTarget.Thing != null && jobTarget.Thing is Pawn)
         {
             Pawn targetPawn = jobTarget.Thing as Pawn;
             CompAbilityUserMight targetPawnComp = targetPawn.GetComp <CompAbilityUserMight>();
             if (targetPawn.CurJobDef.joyKind != null || targetPawn.CurJobDef == JobDefOf.Wait_Wander || targetPawn.CurJobDef == JobDefOf.GotoWander)
             {
                 if (targetPawn.IsColonist && targetPawnComp.MightUserLevel < casterComp.MightUserLevel && caster.relations.OpinionOf(targetPawn) >= 0)
                 {
                     Job job = ability.GetJob(AbilityContext.AI, jobTarget);
                     caster.jobs.TryTakeOrderedJob(job);
                     success = true;
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 public static void EvaluateMinRange(CompAbilityUserMight casterComp, TMAbilityDef abilitydef, PawnAbility ability, MightPower power, float minRange, out bool success)
 {
     success = false;
     if (casterComp.Stamina.CurLevel >= abilitydef.staminaCost && ability.CooldownTicksLeft <= 0)
     {
         Pawn            caster    = casterComp.Pawn;
         LocalTargetInfo jobTarget = TM_Calc.FindNearbyEnemy(caster, (int)(abilitydef.MainVerb.range * .9f));
         if (jobTarget != null && jobTarget.Thing != null && abilitydef == TorannMagicDefOf.TM_AntiArmor)
         {
             Pawn targetPawn = jobTarget.Thing as Pawn;
             if (targetPawn.RaceProps.IsFlesh)
             {
                 jobTarget = null;
             }
         }
         float distanceToTarget = (jobTarget.Cell - caster.Position).LengthHorizontal;
         if (jobTarget != null && jobTarget.Thing != null && (distanceToTarget > minRange && distanceToTarget < (abilitydef.MainVerb.range * .9f)) && TM_Calc.HasLoSFromTo(caster.Position, jobTarget, caster, 0, abilitydef.MainVerb.range))
         {
             Job job = ability.GetJob(AbilityContext.AI, jobTarget);
             job.endIfCantShootTargetFromCurPos = true;
             caster.jobs.TryTakeOrderedJob(job);
             success = true;
         }
     }
 }
Ejemplo n.º 3
0
 public static void Evaluate(CompAbilityUserMight casterComp, TMAbilityDef abilitydef, PawnAbility ability, MightPower power, out bool success)
 {
     success = false;
     EvaluateMinRange(casterComp, abilitydef, ability, power, 3f, out success);
 }
Ejemplo n.º 4
0
 public static void Evaluate(CompAbilityUserMight mightComp, TMAbilityDef abilitydef, PawnAbility ability, MightPower power, int minTargetCount, int radiusAround, IntVec3 evaluatedCenter, bool hostile, out bool success)
 {
     success = false;
     if (mightComp.Stamina.CurLevel >= abilitydef.staminaCost && ability.CooldownTicksLeft <= 0)
     {
         Pawn        caster     = mightComp.Pawn;
         List <Pawn> targetList = TM_Calc.FindPawnsNearTarget(caster, radiusAround, evaluatedCenter, hostile);
         if (targetList != null)
         {
             LocalTargetInfo jobTarget = null;
             if (targetList.Count >= minTargetCount && (abilitydef == TorannMagicDefOf.TM_BladeSpin))
             {
                 jobTarget = caster;
             }
             if (jobTarget != null && jobTarget.Thing != caster)
             {
                 float distanceToTarget = (jobTarget.Cell - caster.Position).LengthHorizontal;
             }
             if (jobTarget != null && jobTarget.Thing != null)
             {
                 Job job = ability.GetJob(AbilityContext.AI, jobTarget);
                 caster.jobs.TryTakeOrderedJob(job);
                 success = true;
             }
         }
     }
 }
Ejemplo n.º 5
0
 public static void TryExecute(CompAbilityUserMight casterComp, TMAbilityDef abilitydef, PawnAbility ability, MightPower power, LocalTargetInfo target, int minRange, out bool success)
 {
     success = false;
     if (casterComp.Stamina.CurLevel >= abilitydef.staminaCost && ability.CooldownTicksLeft <= 0)
     {
         Pawn            caster           = casterComp.Pawn;
         LocalTargetInfo jobTarget        = target;
         float           distanceToTarget = (jobTarget.Cell - caster.Position).LengthHorizontal;
         if (distanceToTarget > minRange && distanceToTarget < (abilitydef.MainVerb.range * .9f) && jobTarget != null && jobTarget.Thing != null && TM_Calc.HasLoSFromTo(caster.Position, jobTarget, caster, 0, abilitydef.MainVerb.range))
         {
             Job job = ability.GetJob(AbilityContext.AI, jobTarget);
             job.endIfCantShootTargetFromCurPos = true;
             caster.jobs.TryTakeOrderedJob(job);
             success = true;
         }
     }
 }
Ejemplo n.º 6
0
        public static void Evaluate(CompAbilityUserMight casterComp, TMAbilityDef abilitydef, PawnAbility ability, MightPower power, float minDistance, out bool success)
        {
            success = false;
            Pawn            caster       = casterComp.Pawn;
            LocalTargetInfo jobTarget    = caster.CurJob.targetA;
            Thing           carriedThing = null;

            if (caster.CurJob.targetA.Thing != null)               //&& caster.CurJob.def.defName != "Sow")
            {
                if (caster.CurJob.targetA.Thing.Map != caster.Map) //carrying TargetA to TargetB
                {
                    jobTarget    = caster.CurJob.targetB;
                    carriedThing = caster.CurJob.targetA.Thing;
                }
                else if (caster.CurJob.targetB != null && caster.CurJob.targetB.Thing != null && caster.CurJob.def != JobDefOf.Rescue) //targetA using targetB for job
                {
                    if (caster.CurJob.targetB.Thing.Map != caster.Map)                                                                 //carrying targetB to targetA
                    {
                        jobTarget    = caster.CurJob.targetA;
                        carriedThing = caster.CurJob.targetB.Thing;
                    }
                    else if (caster.CurJob.def == JobDefOf.TendPatient)
                    {
                        jobTarget = caster.CurJob.targetB;
                    }
                    else //Getting targetA to carry to TargetB
                    {
                        jobTarget = caster.CurJob.targetA;
                    }
                }
                else
                {
                    jobTarget = caster.CurJob.targetA;
                }
            }
            float   distanceToTarget  = (jobTarget.Cell - caster.Position).LengthHorizontal;
            Vector3 directionToTarget = TM_Calc.GetVector(caster.Position, jobTarget.Cell);

            //Log.Message("" + caster.LabelShort + " job def is " + caster.CurJob.def.defName + " targetA " + caster.CurJob.targetA + " targetB " + caster.CurJob.targetB + " jobTarget " + jobTarget + " at distance " + distanceToTarget + " min distance " + minDistance + " at vector " + directionToTarget);
            if (casterComp.Stamina.CurLevel >= casterComp.ActualStaminaCost(abilitydef) && ability.CooldownTicksLeft <= 0 && distanceToTarget < 200)
            {
                if (distanceToTarget > minDistance && caster.CurJob.locomotionUrgency >= LocomotionUrgency.Jog && caster.CurJob.bill == null)
                {
                    if (distanceToTarget <= abilitydef.MainVerb.range && jobTarget.Cell != default(IntVec3))
                    {
                        //Log.Message("doing blink to thing");
                        DoPhase(caster, jobTarget.Cell, ability, carriedThing);
                        success = true;
                    }
                    else
                    {
                        IntVec3 phaseToCell = caster.Position + (directionToTarget * abilitydef.MainVerb.range).ToIntVec3();
                        //Log.Message("doing partial blink to cell " + blinkToCell);
                        //MoteMaker.ThrowHeatGlow(blinkToCell, caster.Map, 1f);
                        if (phaseToCell.IsValid && phaseToCell.InBounds(caster.Map) && phaseToCell.Walkable(caster.Map) && !phaseToCell.Fogged(caster.Map) && ((phaseToCell - caster.Position).LengthHorizontal < distanceToTarget))
                        {
                            DoPhase(caster, phaseToCell, ability, carriedThing);
                            success = true;
                        }
                    }
                }
            }
        }