public static void ApplyWeaponMod(TPlayer player, int id) { IPlayer pl = player.User.GetPlayer(); switch (id) { case 1: { pl.GiveWeaponItem(WeaponItem.LAZER); break; } case 2: { WeaponItem first = pl.CurrentPrimaryWeapon.WeaponItem; WeaponItem second = pl.CurrentSecondaryWeapon.WeaponItem; if (ExtraAmmoWeapon.Contains(first)) { pl.GiveWeaponItem(first); } if (ExtraAmmoWeapon.Contains(second)) { pl.GiveWeaponItem(second); } break; } case 3: { WeaponItem first = pl.CurrentPrimaryWeapon.WeaponItem; WeaponItem second = pl.CurrentSecondaryWeapon.WeaponItem; WeaponItem thrown = pl.CurrentThrownItem.WeaponItem; if (ExtraExplosiveWeapon.Contains(first)) { pl.GiveWeaponItem(first); } if (ExtraExplosiveWeapon.Contains(second)) { pl.GiveWeaponItem(second); } if (ExtraExplosiveWeapon.Contains(thrown)) { pl.GiveWeaponItem(thrown); } break; } case 4: { WeaponItem first = pl.CurrentPrimaryWeapon.WeaponItem; WeaponItem second = pl.CurrentSecondaryWeapon.WeaponItem; if (ExtraHeavyAmmoWeapon.Contains(first)) { pl.GiveWeaponItem(first); player.HasExtraHeavyAmmo = true; DebugLogger.DebugOnlyDialogLog("player.HasExtraHeavyAmmo = " + player.HasExtraHeavyAmmo); } if (ExtraHeavyAmmoWeapon.Contains(second)) { pl.GiveWeaponItem(second); player.HasExtraHeavyAmmo = true; DebugLogger.DebugOnlyDialogLog("player.HasExtraHeavyAmmo = " + player.HasExtraHeavyAmmo); } break; } case 5: { if (player.PrimaryWeapon != null) { player.PrimaryWeapon.DNAProtection = true; player.PrimaryWeapon.TeamDNA = player.Team; } else if (player.SecondaryWeapon != null) { player.SecondaryWeapon.DNAProtection = true; player.SecondaryWeapon.TeamDNA = player.Team; } break; } case 6: { if (player.PrimaryWeapon != null && pl.CurrentPrimaryWeapon.WeaponItem != WeaponItem.FLAMETHROWER) { RifleWeaponItem first = pl.CurrentPrimaryWeapon; int[] ammo = CalculateSpecialAmmoPrimary(first); pl.SetCurrentPrimaryWeaponAmmo(ammo[0], ammo[1], ProjectilePowerup.Bouncing); pl.GiveWeaponItem(first.WeaponItem); } else if (player.SecondaryWeapon != null) { HandgunWeaponItem second = pl.CurrentSecondaryWeapon; int[] ammo = CalculateSpecialAmmoSecondary(second); pl.SetCurrentSecondaryWeaponAmmo(ammo[0], ammo[1], ProjectilePowerup.Bouncing); pl.GiveWeaponItem(second.WeaponItem); } break; } case 7: { if (player.PrimaryWeapon != null && pl.CurrentPrimaryWeapon.WeaponItem != WeaponItem.FLAMETHROWER) { RifleWeaponItem first = pl.CurrentPrimaryWeapon; int[] ammo = CalculateSpecialAmmoPrimary(first); pl.SetCurrentPrimaryWeaponAmmo(ammo[0], ammo[1], ProjectilePowerup.Fire); pl.GiveWeaponItem(first.WeaponItem); } else if (player.SecondaryWeapon != null) { HandgunWeaponItem second = pl.CurrentSecondaryWeapon; int[] ammo = CalculateSpecialAmmoSecondary(second); pl.SetCurrentSecondaryWeaponAmmo(ammo[0], ammo[1], ProjectilePowerup.Fire); pl.GiveWeaponItem(second.WeaponItem); } break; } } }
public void Update() { if (!IsActive()) { return; } for (int i = 0; i < Equipment.Count; i++) { if (Equipment[i].Id == 0) { Equipment.RemoveAt(i); i--; } else { Equipment[i].Update(this); } } IPlayer pl = null; if (User != null) { pl = User.GetPlayer(); } if (pl != null && (pl.RemovalInitiated || pl.IsRemoved)) { pl = null; } if (pl != null && pl.GetProfile().Name == "CPU") { pl.Remove(); ActiveStatus = false; return; } if (pl != null) { Position = pl.GetWorldPosition(); WeaponTrackingUpdate(false); var heavyWeapon = pl.CurrentPrimaryWeapon.WeaponItem; if (ExtraHeavyAmmoWeapon.Contains(heavyWeapon) && pl.CurrentPrimaryWeapon.CurrentAmmo < (pl.CurrentPrimaryWeapon.MaxTotalAmmo / 2) && HasExtraHeavyAmmo) { pl.GiveWeaponItem(heavyWeapon); HasExtraHeavyAmmo = false; } } if (pl != null && Status >= 0) { if (Status == 0) { StatusDisplay.SetWorldPosition(Position + new Vector2(0, 37)); } else { StatusDisplay.SetWorldPosition(Position + new Vector2(0, 15)); } pl.SetNametagVisible(InSmoke <= 0); bool wasBleeding = Bleeding; IPlayerStatistics stat = pl.Statistics; float lastHp = Hp; if (ProjectileDamageTaken < stat.TotalProjectileDamageTaken) { float ch = stat.TotalProjectileDamageTaken - ProjectileDamageTaken; ProjectileDamageTaken = stat.TotalProjectileDamageTaken; //ch *= ProjectileDamageFactor * Armor.ProjectileDamageFactor; if (InSmoke > 0) { ch *= 0.25f; } if (ch < Armor.MaxProjectileDamageCut && ch > Armor.MaxProjectileDamage) { ch = Armor.MaxProjectileDamage; } if (ch >= StartBleedingProjectile) { Bleeding = true; } Hp -= ch; if (InSmoke <= 0) { BreakWeapon(false); } } if (MeleeDamageTaken < stat.TotalMeleeDamageTaken) { float ch = stat.TotalMeleeDamageTaken - MeleeDamageTaken; MeleeDamageTaken = stat.TotalMeleeDamageTaken; //ch *= MeleeDamageFactor * Armor.MeleeDamageFactor; if (ch > Armor.MaxMeleeDamage) { ch = Armor.MaxMeleeDamage; } if (ch >= StartBleedingMelee) { Bleeding = true; } Hp -= ch; } if (ExplosionDamageTaken < stat.TotalExplosionDamageTaken) { float ch = stat.TotalExplosionDamageTaken - ExplosionDamageTaken; ExplosionDamageTaken = stat.TotalExplosionDamageTaken; //ch *= ExplosionDamageFactor * Armor.ExplosionDamageFactor; if (ch >= StartBleedingProjectile) { Bleeding = true; } Hp -= ch; BreakWeapon(true); } if (FallDamageTaken < stat.TotalFallDamageTaken) { float ch = stat.TotalFallDamageTaken - FallDamageTaken; FallDamageTaken = stat.TotalFallDamageTaken; //ch *= FallDamageFactor * Armor.FallDamageFactor; Hp -= ch; } if (Armor.FireProtect) { if (pl.IsBurning) { pl.ClearFire(); } } else { if (pl.IsBurning) { pl.SetMaxFire(); } if (FireDamageTaken < stat.TotalFireDamageTaken) { float ch = stat.TotalFireDamageTaken - FireDamageTaken; FireDamageTaken = stat.TotalFireDamageTaken; //ch *= FireDamageFactor * Armor.FireDamageFactor; Hp -= ch; } } if (Bleeding) { if (!wasBleeding && Hp > 0) { GlobalGame.PlayEffect("CFTXT", pl.GetWorldPosition(), "BLEEDING"); } if (pl.IsSprinting || pl.IsRolling || pl.IsDiving || pl.IsClimbing || pl.IsMeleeAttacking || pl.IsKicking || pl.IsJumpKicking || pl.IsJumpAttacking) { Hp -= HardBleeding; } else { Hp -= EasyBleeding; } if (JumpCount < stat.TotalJumps) { int ch = stat.TotalJumps - JumpCount; Hp -= ch * JumpBleeding; } if (BleedingEffectTimer == 0) { Vector2 effPos = pl.GetWorldPosition(); effPos.Y += 6; GlobalGame.PlayEffect("BLD", effPos); BleedingEffectTimer = BleedingEffectPeriod; } if (BleedingEffectTimer > 0) { BleedingEffectTimer--; } } if (IsDiving && !pl.IsDiving) { IsDiving = false; if (DiveTime >= 45) { float diff = DiveHeight - pl.GetWorldPosition().Y; diff -= MinDivingHeight * DivingDamageFactor * FallDamageFactor; if (diff > 0) { Hp -= diff; } } } else if (!IsDiving && pl.IsDiving) { IsDiving = true; DiveTime = 0; DiveHeight = pl.GetWorldPosition().Y; } else if (IsDiving && pl.IsDiving) { DiveTime++; } if (IsAdrenaline) { float ch = (lastHp - Hp) * AdrenalineDamageFactor; DelayedDamage += (lastHp - Hp) - ch; Hp = lastHp - ch; } else if (DelayedDamage > 0) { if (DamageDelaySpeed > DelayedDamage) { Hp -= DelayedDamage; DelayedDamage = 0; } else { Hp -= DamageDelaySpeed; DelayedDamage -= DamageDelaySpeed; } } WeaponItem heavyWeapon = pl.CurrentPrimaryWeapon.WeaponItem; if (heavyWeapon == WeaponItem.M60 || heavyWeapon == WeaponItem.GRENADE_LAUNCHER || heavyWeapon == WeaponItem.BAZOOKA || heavyWeapon == WeaponItem.SNIPER || Armor.Heavy) { IsSlow = true; } else { IsSlow = false; } if (IsSlow) { PlayerModifiers mods = pl.GetModifiers(); mods.MaxEnergy = 0; mods.MeleeStunImmunity = 1; mods.EnergyRechargeModifier = 0; if (Armor.Heavy) { mods.SizeModifier = 1.15f; } pl.SetModifiers(mods); } if (IsSlow && ((heavyWeapon == WeaponItem.M60 || heavyWeapon == WeaponItem.GRENADE_LAUNCHER || heavyWeapon == WeaponItem.BAZOOKA || heavyWeapon == WeaponItem.SNIPER) && Armor.Heavy)) { PlayerModifiers mods = pl.GetModifiers(); mods.MaxEnergy = 0; mods.MeleeStunImmunity = 1; mods.EnergyRechargeModifier = 0; mods.RunSpeedModifier = 0.5f; mods.MeleeForceModifier = 2f; mods.SizeModifier = 2.6f; pl.SetModifiers(mods); if (pl.IsRolling || pl.IsDiving) { Vector2 vel = pl.GetLinearVelocity() / 3; vel.Y = 0; pl.SetWorldPosition(Position - vel); if (SlowEffectTimer == 0) { SlowEffectTimer = -1; } } if (SlowTimer == 0 && pl.IsSprinting) { SlowTimer = 4; if (SlowEffectTimer == 0) { SlowEffectTimer = -1; } } if (SlowTimer <= 2) { pl.SetInputEnabled(true); } else { pl.SetInputEnabled(false); } if (SlowEffectTimer == -1) { GlobalGame.PlayEffect("CFTXT", pl.GetWorldPosition(), "TOO HEAVY"); SlowEffectTimer = 100; } if (SlowEffectTimer > 0) { SlowEffectTimer--; } if (SlowTimer > 0) { SlowTimer--; } } else if (!pl.IsInputEnabled) { pl.SetInputEnabled(true); } JumpCount = stat.TotalJumps; if (Status == 0) { if (StunTime > 0 && Status != 4) { Status = 4; pl.Kill(); } if (Hp > 0 && StunTime <= 0) { pl.SetHealth(pl.GetMaxHealth() * Hp / 100.0f); //if (Hp < lastHp) pl.SetHealth(99 + GlobalRandom.Next(100) / 100.0f); //else pl.SetHealth(100); if (pl.IsWalking && !pl.IsManualAiming && !pl.IsClimbing && !pl.IsLedgeGrabbing && !pl.IsInMidAir && !pl.IsRolling) { if (CurrentEquipment < Equipment.Count) { Equipment[CurrentEquipment].Use(this); } } else if (Equipment.Count > 1 && pl.CurrentWeaponDrawn == WeaponItemType.NONE) { if (pl.IsMeleeAttacking || pl.IsJumpAttacking) { CurrentEquipment = 0; } else if (pl.IsKicking || pl.IsJumpKicking) { CurrentEquipment = 1; } } } else if (Hp <= 0) { if (!IsActive()) { Status = -1; } else if (!pl.IsBurning || Armor.FireProtect) { int rnd = GlobalRandom.Next(0, 100); Bleeding = false; if (rnd < OvercomeChance) { Hp = OvercomeHealth; Status = 3; } else if (rnd < AliveChance) { Hp = StableHealth; Status = 2; } else if (rnd < DyingChance) { Hp = DyingHealth; Status = 1; } else { Status = -1; } pl.Kill(); } else { Status = -1; pl.Kill(); } } } else if (Status == 1 || Status == 2 || Status == 3) { if (pl.IsBurnedCorpse && !Armor.FireProtect) { Hp = 0; } if (Hp <= 0) { Status = -1; } else if (Hp <= DyingHealth) { Status = 1; } else if (Hp <= StableHealth) { Status = 2; } else if (Hp <= ReviveHealth) { Status = 3; } } if (Status == 0) { StatusDisplay.SetTextColor(Color.White); } else { if (Team == PlayerTeam.Team1) { StatusDisplay.SetTextColor(new Color(128, 128, 255)); } else { StatusDisplay.SetTextColor(new Color(255, 128, 128)); } } if (Status == 0) { if (CurrentEquipment < Equipment.Count && InSmoke <= 0) { StatusDisplay.SetText(Equipment[CurrentEquipment].GetName()); } else { StatusDisplay.SetText(""); } } else if (Status == 1) { StatusDisplay.SetText("DYING"); Hp -= DyingSpeed; } else if (Status == 2) { StatusDisplay.SetText("STABLE"); } else if (Status == 3) { StatusDisplay.SetText("OVERCOMING"); Hp += OvercomeSpeed; } else if (Status == 4) { StatusDisplay.SetText("STUN"); StunTime--; } if (Status == 3 && Hp >= ReviveHealth) { Revive(Hp); } else if (Status == 4 && StunTime <= 0) { Revive(Hp, Bleeding); } } else if (pl == null && Status >= 0) { Status = -1; } if (InSmoke > 0) { InSmoke--; } if (Status == -1) { Status = -2; OnDead(); StatusDisplay.SetText(""); } }