// Token: 0x06004BA7 RID: 19367 RVA: 0x002357D4 File Offset: 0x00233BD4
        public override DamageWorker.DamageResult Apply(DamageInfo dinfo, Thing victim)
        {
            Pawn pawn = victim as Pawn;

            if (pawn != null && pawn.Faction == Faction.OfPlayer)
            {
                Find.TickManager.slower.SignalForceNormalSpeedShort();
            }
            Map map = victim.Map;

            dinfo.SetAmount((dinfo.Amount * (1 - victim.GetStatValue(DefDatabase <StatDef> .GetNamed("RRY_AcidResistance")))));
            DamageWorker.DamageResult damageResult = base.Apply(dinfo, victim);
            if (!damageResult.deflected && !dinfo.InstantPermanentInjury)
            {
                //   victim.TryAttachFire(Rand.Range(0.15f, 0.25f));
            }
            if (victim.Destroyed && map != null && pawn == null)
            {
                foreach (IntVec3 c in victim.OccupiedRect())
                {
                    FilthMaker.TryMakeFilth(c, map, ThingDefOf.Filth_Ash, 1);
                }
                if (victim is Plant plant && victim.def.plant.IsTree && plant.LifeStage != PlantLifeStage.Sowing && victim.def != ThingDefOf.BurnedTree)
                {
                    DeadPlant deadPlant = (DeadPlant)GenSpawn.Spawn(ThingDefOf.BurnedTree, victim.Position, map, WipeMode.Vanish);
                    deadPlant.Growth = plant.Growth;
                }
            }
            return(damageResult);
        }
Beispiel #2
0
 public void Launch(Thing launcher, Vector3 origin, LocalTargetInfo usedTarget, LocalTargetInfo intendedTarget, ProjectileHitFlags hitFlags, Thing equipment = null, ThingDef targetCoverDef = null)
 {
     this.launcher       = launcher;
     this.origin         = origin;
     this.usedTarget     = usedTarget;
     this.intendedTarget = intendedTarget;
     this.targetCoverDef = targetCoverDef;
     HitFlags            = hitFlags;
     if (equipment != null)
     {
         equipmentDef           = equipment.def;
         weaponDamageMultiplier = equipment.GetStatValue(StatDefOf.RangedWeapon_DamageMultiplier);
     }
     else
     {
         equipmentDef           = null;
         weaponDamageMultiplier = 1f;
     }
     destination   = usedTarget.Cell.ToVector3Shifted() + Gen.RandomHorizontalVector(0.3f);
     ticksToImpact = Mathf.CeilToInt(StartingTicksToImpact);
     if (ticksToImpact < 1)
     {
         ticksToImpact = 1;
     }
     if (!def.projectile.soundAmbient.NullOrUndefined())
     {
         SoundInfo info = SoundInfo.InMap(this, MaintenanceType.PerTick);
         ambientSustainer = def.projectile.soundAmbient.TrySpawnSustainer(info);
     }
 }
Beispiel #3
0
 public float AdjustedCooldown(Tool tool, Pawn attacker, Thing equipment)
 {
     if (tool != null)
     {
         return(tool.AdjustedCooldown(equipment));
     }
     if (equipment != null && !IsMeleeAttack)
     {
         return(equipment.GetStatValue(StatDefOf.RangedWeapon_Cooldown));
     }
     return(defaultCooldownTime);
 }
Beispiel #4
0
        private float AdjustedAccuracy(VerbProperties.RangeCategory cat, Thing equipment)
        {
            float statValue;

            if (equipment == null)
            {
                switch (cat)
                {
                case VerbProperties.RangeCategory.Touch:
                    statValue = this.accuracyTouch;
                    break;

                case VerbProperties.RangeCategory.Short:
                    statValue = this.accuracyShort;
                    break;

                case VerbProperties.RangeCategory.Medium:
                    statValue = this.accuracyMedium;
                    break;

                case VerbProperties.RangeCategory.Long:
                    statValue = this.accuracyLong;
                    break;

                default:
                    throw new InvalidOperationException();
                }
            }
            else
            {
                StatDef stat = null;
                switch (cat)
                {
                case VerbProperties.RangeCategory.Touch:
                    stat = StatDefOf.AccuracyTouch;
                    break;

                case VerbProperties.RangeCategory.Short:
                    stat = StatDefOf.AccuracyShort;
                    break;

                case VerbProperties.RangeCategory.Medium:
                    stat = StatDefOf.AccuracyMedium;
                    break;

                case VerbProperties.RangeCategory.Long:
                    stat = StatDefOf.AccuracyLong;
                    break;
                }
                statValue = equipment.GetStatValue(stat, true);
            }
            return(statValue);
        }
 public float AdjustedCooldown(Verb ownerVerb, Pawn attacker, Thing equipment)
 {
     if (ownerVerb.tool != null)
     {
         return(ownerVerb.tool.AdjustedCooldown(equipment));
     }
     if (equipment != null && !this.MeleeRange)
     {
         return(equipment.GetStatValue(StatDefOf.RangedWeapon_Cooldown, true));
     }
     return(this.defaultCooldownTime);
 }
Beispiel #6
0
        public float AdjustedMeleeDamageAmount(Thing ownerEquipment, DamageDef damageDef)
        {
            float num = this.power;

            if (ownerEquipment != null)
            {
                num *= ownerEquipment.GetStatValue(StatDefOf.MeleeWeapon_DamageMultiplier, true);
                if (ownerEquipment.Stuff != null && damageDef != null)
                {
                    num *= ownerEquipment.Stuff.GetStatValueAbstract(damageDef.armorCategory.multStat, null);
                }
            }
            return(num);
        }
Beispiel #7
0
        public float AdjustedArmorPenetration(Tool tool, Pawn attacker, Thing equipment, HediffComp_VerbGiver hediffCompSource)
        {
            float num = tool?.armorPenetration ?? meleeArmorPenetrationBase;

            if (num < 0f)
            {
                num = AdjustedMeleeDamageAmount(tool, attacker, equipment, hediffCompSource) * 0.015f;
            }
            else if (equipment != null)
            {
                float statValue = equipment.GetStatValue(StatDefOf.MeleeWeapon_DamageMultiplier);
                num *= statValue;
            }
            return(num);
        }
Beispiel #8
0
        public float AdjustedCooldown(Verb ownerVerb, Pawn attacker, Thing equipment)
        {
            float result;

            if (ownerVerb.tool != null)
            {
                result = ownerVerb.tool.AdjustedCooldown(equipment);
            }
            else if (equipment != null && !this.IsMeleeAttack)
            {
                result = equipment.GetStatValue(StatDefOf.RangedWeapon_Cooldown, true);
            }
            else
            {
                result = this.defaultCooldownTime;
            }
            return(result);
        }
Beispiel #9
0
        private float AdjustedAccuracy(RangeCategory cat, Thing equipment)
        {
            if (equipment == null)
            {
                switch (cat)
                {
                case RangeCategory.Touch:
                    return(accuracyTouch);

                case RangeCategory.Short:
                    return(accuracyShort);

                case RangeCategory.Medium:
                    return(accuracyMedium);

                case RangeCategory.Long:
                    return(accuracyLong);

                default:
                    throw new InvalidOperationException();
                }
            }
            StatDef stat = null;

            switch (cat)
            {
            case RangeCategory.Touch:
                stat = StatDefOf.AccuracyTouch;
                break;

            case RangeCategory.Short:
                stat = StatDefOf.AccuracyShort;
                break;

            case RangeCategory.Medium:
                stat = StatDefOf.AccuracyMedium;
                break;

            case RangeCategory.Long:
                stat = StatDefOf.AccuracyLong;
                break;
            }
            return(equipment.GetStatValue(stat));
        }
        private static void SpawnRandomCaravan()
        {
            int num = GenWorld.MouseTile();

            if (Find.WorldGrid[num].biome.impassable)
            {
                return;
            }
            List <Pawn> list = new List <Pawn>();
            int         num2 = Rand.RangeInclusive(1, 10);

            for (int i = 0; i < num2; i++)
            {
                Pawn pawn = PawnGenerator.GeneratePawn(Faction.OfPlayer.def.basicMemberKind, Faction.OfPlayer);
                list.Add(pawn);
                if (!pawn.WorkTagIsDisabled(WorkTags.Violent) && Rand.Value < 0.9f)
                {
                    ThingDef thingDef = DefDatabase <ThingDef> .AllDefs.Where((ThingDef def) => def.IsWeapon && def.PlayerAcquirable).RandomElementWithFallback();

                    pawn.equipment.AddEquipment((ThingWithComps)ThingMaker.MakeThing(thingDef, GenStuff.RandomStuffFor(thingDef)));
                }
            }
            int num3 = Rand.RangeInclusive(-4, 10);

            for (int j = 0; j < num3; j++)
            {
                Pawn item = PawnGenerator.GeneratePawn(DefDatabase <PawnKindDef> .AllDefs.Where((PawnKindDef d) => d.RaceProps.Animal && d.RaceProps.wildness < 1f).RandomElement(), Faction.OfPlayer);
                list.Add(item);
            }
            Caravan      caravan = CaravanMaker.MakeCaravan(list, Faction.OfPlayer, num, addToWorldPawnsIfNotAlready: true);
            List <Thing> list2   = ThingSetMakerDefOf.DebugCaravanInventory.root.Generate();

            for (int k = 0; k < list2.Count; k++)
            {
                Thing thing = list2[k];
                if (!(thing.GetStatValue(StatDefOf.Mass) * (float)thing.stackCount > caravan.MassCapacity - caravan.MassUsage))
                {
                    CaravanInventoryUtility.GiveThing(caravan, thing);
                    continue;
                }
                break;
            }
        }
Beispiel #11
0
        public float AdjustedMeleeSelectionWeight(Verb ownerVerb, Pawn attacker, Thing equipment)
        {
            float num = this.AdjustedExpectedMeleeDamage(ownerVerb, attacker, equipment) * this.commonality * ((ownerVerb.tool != null) ? ownerVerb.tool.commonality : 1f);

            if (this.IsMeleeAttack && equipment != null)
            {
                return(num);
            }
            if (this.IsMeleeAttack && ownerVerb.tool != null && ownerVerb.tool.alwaysTreatAsWeapon)
            {
                return(num);
            }
            if (this.IsMeleeAttack)
            {
                return(num * 0.3f);
            }
            if (this.meleeShoot)
            {
                return(num * 0.25f / equipment.GetStatValue(StatDefOf.Weapon_Bulk, true));
            }
            return(0f);
        }
Beispiel #12
0
        public static float HitFactorFromShooter(Thing caster, float distance)
        {
            float accRating = (!(caster is Pawn)) ? caster.GetStatValue(StatDefOf.ShootingAccuracyTurret) : caster.GetStatValue(StatDefOf.ShootingAccuracyPawn);

            return(HitFactorFromShooter(accRating, distance));
        }
Beispiel #13
0
 public float AdjustedCooldown(Thing ownerEquipment)
 {
     return(cooldownTime * (ownerEquipment?.GetStatValue(StatDefOf.MeleeWeapon_CooldownMultiplier) ?? 1f));
 }
        public int GetDamageAmount(Thing weapon, StringBuilder explanation = null)
        {
            float weaponDamageMultiplier = weapon?.GetStatValue(StatDefOf.RangedWeapon_DamageMultiplier) ?? 1f;

            return(GetDamageAmount(weaponDamageMultiplier, explanation));
        }
        public int GetDamageAmount(Thing weapon, StringBuilder explanation = null)
        {
            float weaponDamageMultiplier = (weapon == null) ? 1f : weapon.GetStatValue(StatDefOf.RangedWeapon_DamageMultiplier, true);

            return(this.GetDamageAmount(weaponDamageMultiplier, explanation));
        }
 public static float HitFactorFromShooter(Thing caster, float distance)
 {
     return(HitFactorFromShooter((caster is Pawn) ? caster.GetStatValue(StatDefOf.ShootingAccuracyPawn) : caster.GetStatValue(StatDefOf.ShootingAccuracyTurret), distance));
 }
Beispiel #17
0
 public float AdjustedCooldown(Thing ownerEquipment)
 {
     return((float)(this.cooldownTime * ((ownerEquipment != null) ? ownerEquipment.GetStatValue(StatDefOf.MeleeWeapon_CooldownMultiplier, true) : 1.0)));
 }
        public float GetArmorPenetration(Thing weapon, StringBuilder explanation = null)
        {
            float weaponDamageMultiplier = weapon?.GetStatValue(StatDefOf.RangedWeapon_DamageMultiplier) ?? 1f;

            return(GetArmorPenetration(weaponDamageMultiplier, explanation));
        }