Ejemplo n.º 1
0
        public static void GetNonMissChance_PostFix(Verb_MeleeAttack __instance, LocalTargetInfo target, ref float __result)
        {
            //if (target.Thing != null && target.Thing is Pawn)
            //{
            Pawn attacker = __instance.CasterPawn;

            if (attacker != null)
            {
                Pawn_EquipmentTracker pawn_EquipmentTracker = attacker.equipment;
                if (pawn_EquipmentTracker != null)
                {
                    foreach (ThingWithComps thingWithComps in pawn_EquipmentTracker.AllEquipmentListForReading)
                    {
                        if (thingWithComps != null)
                        {
                            if (thingWithComps.def.IsMeleeWeapon)
                            {
                                if (thingWithComps.def.defName.Contains("SWSaber_"))
                                {
                                    CompForceUser compForce = attacker.TryGetComp <CompForceUser>();
                                    if (compForce == null)
                                    {
                                        __result = 0.5f;
                                    }
                                    else if (!compForce.IsForceUser)
                                    {
                                        __result = 0.5f;
                                    }
                                    else
                                    {
                                        float newAccuracy = (float)(__result / 2);

                                        int accuracyPoints = compForce.ForceSkillLevel("PJ_LightsaberAccuracy");
                                        if (accuracyPoints > 0)
                                        {
                                            for (int i = 0; i < accuracyPoints; i++)
                                            {
                                                newAccuracy += 0.2f;
                                            }
                                        }
                                        __result = newAccuracy;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            //}
        }
Ejemplo n.º 2
0
        public static void TakeDamage_PreFix(Thing __instance, ref DamageInfo dinfo)
        {
            if (dinfo.Instigator != null)
            {
                Pawn attacker = dinfo.Instigator as Pawn;
                if (attacker != null)
                {
                    Pawn_EquipmentTracker pawn_EquipmentTracker = attacker.equipment;
                    if (pawn_EquipmentTracker != null)
                    {
                        foreach (ThingWithComps thingWithComps in pawn_EquipmentTracker.AllEquipmentListForReading)
                        {
                            if (thingWithComps != null)
                            {
                                if (thingWithComps.def.IsMeleeWeapon)
                                {
                                    if (thingWithComps.def.defName.Contains("SWSaber_"))
                                    {
                                        CompForceUser compForce = attacker.TryGetComp <CompForceUser>();
                                        if (compForce == null)
                                        {
                                            dinfo.SetAmount(10);
                                        }
                                        else if (!compForce.IsForceUser)
                                        {
                                            dinfo.SetAmount(10);
                                        }
                                        else
                                        {
                                            int newDamage = (int)(dinfo.Amount / 2);

                                            int offensePoints = compForce.ForceSkillLevel("PJ_LightsaberOffense");
                                            if (offensePoints > 0)
                                            {
                                                for (int i = 0; i < offensePoints; i++)
                                                {
                                                    newDamage += (int)(dinfo.Amount / 5);
                                                }
                                            }
                                            dinfo.SetAmount(newDamage);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }