public static void Kill(Player player, double damage, int hitDirection, bool pvp, PlayerDeathReason damageSource) { foreach (ModPlayer modPlayer in player.modPlayers) { modPlayer.Kill(damage, hitDirection, pvp, damageSource); } }
public override void ToStream(Stream stream, bool includeHeader = true) { /* * Length and ID headers get written in the base packet class. */ if (includeHeader) { base.ToStream(stream, includeHeader); } /* * Always make sure to not close the stream when serializing. * * It is up to the caller to decide if the underlying stream * gets closed. If this is a network stream we do not want * the regressions of unconditionally closing the TCP socket * once the payload of data has been sent to the client. */ using (BinaryWriter br = new BinaryWriter(stream, new System.Text.UTF8Encoding(), leaveOpen: true)) { br.Write(PlayerId); br.Write(PlayerDeathReason); if (FromPlayerIndex != -1) { PlayerDeathReason = PlayerDeathReason.SetBit(0, true); br.Write(FromPlayerIndex); } if (FromNpcIndex != -1) { PlayerDeathReason = PlayerDeathReason.SetBit(1, true); br.Write(FromNpcIndex); } if (FromProjectileIndex != -1) { PlayerDeathReason = PlayerDeathReason.SetBit(2, true); br.Write(FromProjectileIndex); } if (FromOther != 254) { PlayerDeathReason = PlayerDeathReason.SetBit(3, true); br.Write(FromOther); } if (FromProjectileType != 0) { PlayerDeathReason = PlayerDeathReason.SetBit(4, true); br.Write(FromProjectileType); } if (FromItemType != 0) { PlayerDeathReason = PlayerDeathReason.SetBit(5, true); br.Write(FromItemType); } if (FromItemPrefix != 0) { PlayerDeathReason = PlayerDeathReason.SetBit(6, true); br.Write(FromItemPrefix); } if (FromCustomReason != null) { PlayerDeathReason = PlayerDeathReason.SetBit(7, true); br.Write(FromCustomReason); } br.Write(Damage); br.Write(HitDirection); br.Write(Flags); br.Write(CooldownCounter); } }
public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { if (blessedMedalion && damage > player.statLife && Main.rand.Next(100) < 30) { player.NinjaDodge(); return(false); } int dodgeRng = Main.rand.Next(100); //Main.NewText(dodgeChance); if (dodgeRng < dodgeChance && dodgeRng < 80) { player.immune = true; player.immuneTime = 80; if (player.longInvince) { player.immuneTime += 40; } if (dodgeDamageBoost) { damageBoostFromDodge = true; } if (dodgeImmuneBoost) { player.immuneTime += 60; } for (int i = 0; i < player.hurtCooldowns.Length; i++) { player.hurtCooldowns[i] = player.immuneTime; } for (int j = 0; j < 100; j++) { int num = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 31, 0f, 0f, 100, default(Color), 2f); Dust expr_A4_cp_0 = Main.dust[num]; expr_A4_cp_0.position.X = expr_A4_cp_0.position.X + (float)Main.rand.Next(-20, 21); Dust expr_CB_cp_0 = Main.dust[num]; expr_CB_cp_0.position.Y = expr_CB_cp_0.position.Y + (float)Main.rand.Next(-20, 21); Main.dust[num].velocity *= 0.4f; Main.dust[num].scale *= 1f + (float)Main.rand.Next(40) * 0.01f; Main.dust[num].shader = GameShaders.Armor.GetSecondaryShader(player.cWaist, player); if (Main.rand.Next(2) == 0) { Main.dust[num].scale *= 1f + (float)Main.rand.Next(40) * 0.01f; Main.dust[num].noGravity = true; } } int num2 = Gore.NewGore(new Vector2(player.position.X + (float)(player.width / 2) - 24f, player.position.Y + (float)(player.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[num2].scale = 1.5f; Main.gore[num2].velocity.X = (float)Main.rand.Next(-50, 51) * 0.01f; Main.gore[num2].velocity.Y = (float)Main.rand.Next(-50, 51) * 0.01f; Main.gore[num2].velocity *= 0.4f; num2 = Gore.NewGore(new Vector2(player.position.X + (float)(player.width / 2) - 24f, player.position.Y + (float)(player.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[num2].scale = 1.5f; Main.gore[num2].velocity.X = 1.5f + (float)Main.rand.Next(-50, 51) * 0.01f; Main.gore[num2].velocity.Y = 1.5f + (float)Main.rand.Next(-50, 51) * 0.01f; Main.gore[num2].velocity *= 0.4f; num2 = Gore.NewGore(new Vector2(player.position.X + (float)(player.width / 2) - 24f, player.position.Y + (float)(player.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[num2].scale = 1.5f; Main.gore[num2].velocity.X = -1.5f - (float)Main.rand.Next(-50, 51) * 0.01f; Main.gore[num2].velocity.Y = 1.5f + (float)Main.rand.Next(-50, 51) * 0.01f; Main.gore[num2].velocity *= 0.4f; num2 = Gore.NewGore(new Vector2(player.position.X + (float)(player.width / 2) - 24f, player.position.Y + (float)(player.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[num2].scale = 1.5f; Main.gore[num2].velocity.X = 1.5f + (float)Main.rand.Next(-50, 51) * 0.01f; Main.gore[num2].velocity.Y = -1.5f - (float)Main.rand.Next(-50, 51) * 0.01f; Main.gore[num2].velocity *= 0.4f; num2 = Gore.NewGore(new Vector2(player.position.X + (float)(player.width / 2) - 24f, player.position.Y + (float)(player.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[num2].scale = 1.5f; Main.gore[num2].velocity.X = -1.5f - (float)Main.rand.Next(-50, 51) * 0.01f; Main.gore[num2].velocity.Y = -1.5f - (float)Main.rand.Next(-50, 51) * 0.01f; Main.gore[num2].velocity *= 0.4f; if (player.whoAmI == Main.myPlayer) { NetMessage.SendData(62, -1, -1, null, player.whoAmI, 1f, 0f, 0f, 0, 0, 0); } return(false); } if (damageSource.SourceProjectileType == mod.ProjectileType("SnowFlake")) { damageSource = PlayerDeathReason.ByCustomReason(player.name + " was driven to extintion by climate change!"); // change death message } if (damageSource.SourceProjectileType == mod.ProjectileType("DinoBomb") || damageSource.SourceProjectileType == mod.ProjectileType("DinoBombExplosion")) { damageSource = PlayerDeathReason.ByCustomReason(player.name + " was driven to extintion by dino bomb"); // change death message } if (damageSource.SourceProjectileType == mod.ProjectileType("TankCannonBall") || damageSource.SourceProjectileType == mod.ProjectileType("TankCannonBallExplosion")) { damageSource = PlayerDeathReason.ByCustomReason(player.name + " was driven to extintion by triceratank's cannon"); // change death message } if (damageSource.SourceProjectileType == mod.ProjectileType("MeteorFall")) { damageSource = PlayerDeathReason.ByCustomReason(player.name + " was driven to extintion by meteor!"); // change death message } if (damageSource.SourceProjectileType == mod.ProjectileType("MeteorLaunch")) { damageSource = PlayerDeathReason.ByCustomReason(player.name + " was driven to extintion by meteor!"); // change death message } if (damageSource.SourceNPCIndex >= 0 && Main.npc[damageSource.SourceNPCIndex].type == mod.NPCType("TheGreatTyrannosaurus")) { damageSource = PlayerDeathReason.ByCustomReason(player.name + " was driven to extintion by The Great Tyrannosaurus!"); } if (damageSource.SourceNPCIndex >= 0 && Main.npc[damageSource.SourceNPCIndex].type == mod.NPCType("Triceratank")) { damageSource = PlayerDeathReason.ByCustomReason(player.name + " was driven to extintion by Triceratank"); } if (damageSource.SourceNPCIndex >= 0 && Main.npc[damageSource.SourceNPCIndex].type == mod.NPCType("Utah")) { damageSource = PlayerDeathReason.ByCustomReason(player.name + " was driven to extintion by Utah"); } if (damageSource.SourceNPCIndex >= 0 && Main.npc[damageSource.SourceNPCIndex].type == mod.NPCType("Velocichopper")) { damageSource = PlayerDeathReason.ByCustomReason(player.name + " was driven to extintion by Velocichopper"); } if (Metronome && killCount != 0) { CombatText.NewText(player.getRect(), Color.DarkRed, "Reset!", true, false); } if (gemRegen) { regenTimer = 0; } killCount = 0; return(true); }
//public override bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) //{ //} public override void Kill(double damage, int hitDirection, bool pvp, PlayerDeathReason damageSource) { Point playerPosition = player.position.ToTileCoordinates(); int x = playerPosition.X; int y = playerPosition.Y + 4; int startX = x; bool isClearForTombstone = isTileCoordinateClear(x, y); // Check left and right 15 squares, then up one and repeat 15 times int movesY = 0; while (!isClearForTombstone && movesY++ < 15) { x = startX; isClearForTombstone = isTileCoordinateClear(x, y); int movesX = 0; while (!isClearForTombstone && movesX++ < 15) { x = startX - movesX; if (x < 0) { x = 0; } isClearForTombstone = isTileCoordinateClear(x, y); if (!isClearForTombstone) { x = startX + movesX; if (x > Main.maxTilesX) { x = Main.maxTilesX - 1; } isClearForTombstone = isTileCoordinateClear(x, y); } } if (!isClearForTombstone) { y--; if (y < 0) { y = 0; } } } if (!isClearForTombstone) { // Revert to normal death Main.NewText("Unable to place tombstone1. Reverting to normal death.", 255, 100, 100); base.Kill(damage, hitDirection, pvp, damageSource); return; } if (!WorldGen.PlaceTile(x, y, TileID.Tombstones, false, true, 1, 7)) { // Revert to normal death Main.NewText("Unable to place tombstone2. Reverting to normal death.", 255, 100, 100); base.Kill(damage, hitDirection, pvp, damageSource); return; } int sign = Sign.ReadSign(x, y, true); if (sign >= 0) { Sign.TextSign(sign, player.name + "'s Stuff"); } Point tombStonePosition = new Point(x, y); PlayerDeathInventory previousInventory = null; if (playerDeathInventoryMap.TryGetValue(tombStonePosition, out previousInventory)) { int oldItemValue = previousInventory.getValue(); int newItemValue = 0; for (int i = 0; i < player.inventory.Length; i++) { newItemValue += player.inventory[i].value; } for (int i = 0; i < player.armor.Length; i++) { newItemValue += player.armor[i].value; } for (int i = 0; i < player.miscEquips.Length; i++) { newItemValue += player.miscEquips[i].value; } // Remove previous inventory only if new death was more valuable if (newItemValue < oldItemValue) { Main.NewText("Previous more valuable death at same position, not overwriting. Reverting to normal death.", 255, 100, 100); base.Kill(damage, hitDirection, pvp, damageSource); return; } Main.NewText("Previous less valuable death at same position, overwriting.", 255, 100, 100); playerDeathInventoryMap.Remove(tombStonePosition); } Item[] deathInventory = new Item[player.inventory.Length]; Item[] deathArmor = new Item[player.armor.Length]; Item[] deathDye = new Item[player.dye.Length]; Item[] deathMiscEquips = new Item[player.miscEquips.Length]; Item[] deathMiscDyes = new Item[player.miscDyes.Length]; //INVENTORY for (int i = 0; i < player.inventory.Length; i++) { //put inventory into separate list deathInventory[i] = player.inventory[i]; player.inventory[i] = new Item(); } //ARMOR - SOCIAL for (int i = 0; i < player.armor.Length; i++) { //put armor into separate list deathArmor[i] = player.armor[i]; player.armor[i] = new Item(); } //DYES for (int i = 0; i < player.dye.Length; i++) { //put dye into separate list deathDye[i] = player.dye[i]; player.dye[i] = new Item(); } //EQUIPMENT for (int i = 0; i < player.miscEquips.Length; i++) { //put equipment into separate list deathMiscEquips[i] = player.miscEquips[i]; player.miscEquips[i] = new Item(); } //EQUIPMENT - DYE for (int i = 0; i < player.miscDyes.Length; i++) { //put equipment dye into separate list deathMiscDyes[i] = player.miscDyes[i]; player.miscDyes[i] = new Item(); } PlayerDeathInventory playerDeathInventory = new PlayerDeathInventory(deathInventory, deathArmor, deathDye, deathMiscEquips, deathMiscDyes); playerDeathInventoryMap.Add(tombStonePosition, playerDeathInventory); Main.NewText("Inventory saved in tombstone at " + pointToText(tombStonePosition)); base.Kill(damage, hitDirection, pvp, damageSource); }
public static bool PreHurt(Player player, bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { bool flag = true; foreach (ModPlayer modPlayer in player.modPlayers) { if (!modPlayer.PreHurt(pvp, quiet, ref damage, ref hitDirection, ref crit, ref customDamage, ref playSound, ref genGore, ref damageSource)) { flag = false; } } return flag; }
//////////////// public override bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { if (!LivesConfig.Instance.Enabled) { base.PreKill(damage, hitDirection, pvp, ref playSound, ref genGore, ref damageSource); } this.DeathHappened(pvp); return(base.PreKill(damage, hitDirection, pvp, ref playSound, ref genGore, ref damageSource)); }
public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { player.AddBuff(mod.BuffType("DetectHurt"), 1); if (race.UsesCustomHurtSound) { playSound = false; } return(race.PreHurt(player, pvp, quiet, ref damage, ref hitDirection, ref crit, ref customDamage, ref playSound, ref genGore, ref damageSource)); }
public virtual bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { return true; }
public override bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { if (heroLives > 0) { heroLives--; if (Main.netMode == 1) { ModPacket packet = mod.GetPacket(); packet.Write((byte)ExampleModMessageType.HeroLives); packet.Write(player.whoAmI); packet.Write(heroLives); packet.Send(); } if (heroLives > 0) { player.statLife = player.statLifeMax2; player.HealEffect(player.statLifeMax2); player.immune = true; player.immuneTime = player.longInvince ? 180 : 120; for (int k = 0; k < player.hurtCooldowns.Length; k++) { player.hurtCooldowns[k] = player.longInvince ? 180 : 120; } Main.PlaySound(SoundID.Item29, player.position); reviveTime = 60; return(false); } } if (healHurt > 0 && damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) { damageSource = PlayerDeathReason.ByCustomReason(" was dissolved by holy powers"); } return(true); }
/// <summary> /// Calculates the amount of damage dealt to a player after factoring in their defense stats. /// </summary> public static double GetHurtDamage(PvPPlayer damagedPlayer, int damage) { damagedPlayer.TPlayer.stealth = 1f; int damage1 = damage; double dmg = Main.CalculatePlayerDamage(damage1, damagedPlayer.TPlayer.statDefense); if (dmg >= 1.0) { dmg = (int)((1.0 - damagedPlayer.TPlayer.endurance) * dmg); if (dmg < 1.0) { dmg = 1.0; } if (damagedPlayer.TPlayer.ConsumeSolarFlare()) { dmg = (int)(0.7 * dmg); if (dmg < 1.0) { dmg = 1.0; } } if (damagedPlayer.TPlayer.beetleDefense && damagedPlayer.TPlayer.beetleOrbs > 0) { dmg = (int)((1.0 - 0.15f * damagedPlayer.TPlayer.beetleOrbs) * dmg); damagedPlayer.TPlayer.beetleOrbs = damagedPlayer.TPlayer.beetleOrbs - 1; if (dmg < 1.0) { dmg = 1.0; } } if (damagedPlayer.TPlayer.defendedByPaladin) { if (damagedPlayer.TPlayer.whoAmI != Main.myPlayer) { if (Main.player[Main.myPlayer].hasPaladinShield) { Player player = Main.player[Main.myPlayer]; if (player.team == damagedPlayer.TPlayer.team && damagedPlayer.TPlayer.team != 0) { float num1 = player.Distance(damagedPlayer.TPlayer.Center); bool flag3 = num1 < 800.0; if (flag3) { for (int index = 0; index < (int)byte.MaxValue; ++index) { if (index != Main.myPlayer && Main.player[index].active && (!Main.player[index].dead && !Main.player[index].immune) && (Main.player[index].hasPaladinShield && Main.player[index].team == damagedPlayer.TPlayer.team && Main.player[index].statLife > Main.player[index].statLifeMax2 * 0.25)) { float num2 = Main.player[index].Distance(damagedPlayer.TPlayer.Center); if ((double)num1 > num2 || num1 == num2 && index < Main.myPlayer) { flag3 = false; break; } } } } if (flag3) { int damage2 = (int)(dmg * 0.25); dmg = (int)(dmg * 0.75); player.Hurt(PlayerDeathReason.LegacyEmpty(), damage2, 0); } } } } else { bool flag3 = false; for (int index = 0; index < (int)byte.MaxValue; ++index) { if (index != Main.myPlayer && Main.player[index].active && (!Main.player[index].dead && !Main.player[index].immune) && Main.player[index].hasPaladinShield && Main.player[index].team == damagedPlayer.TPlayer.team && Main.player[index].statLife > Main.player[index].statLifeMax2 * 0.25) { flag3 = true; break; } } if (flag3) { dmg = (int)(dmg * 0.75); } } } } return(dmg); }
public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { if (constantDamage > 0 || percentDamage > 0f) { int damageFromPercent = (int)(player.statLifeMax2 * percentDamage); damage = Math.Max(constantDamage, damageFromPercent); customDamage = true; } else if (defenseEffect >= 0f) { if (Main.expertMode) { defenseEffect *= 1.5f; } damage -= (int)(player.statDefense * defenseEffect); if (damage < 0) { damage = 1; } customDamage = true; } constantDamage = 0; percentDamage = 0f; defenseEffect = -1f; return(base.PreHurt(pvp, quiet, ref damage, ref hitDirection, ref crit, ref customDamage, ref playSound, ref genGore, ref damageSource)); }
public override bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { bool b = base.PreKill(damage, hitDirection, pvp, ref playSound, ref genGore, ref damageSource); foreach (VitriBuff buff in buffs) { buff.PreKill(this, damage, hitDirection, pvp, ref playSound, ref genGore, ref damageSource); } return(b); }
public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { bool b = base.PreHurt(pvp, quiet, ref damage, ref hitDirection, ref crit, ref customDamage, ref playSound, ref genGore, ref damageSource); foreach (VitriBuff buff in buffs) { if (!buff.PreHurt(this, pvp, quiet, ref damage, ref hitDirection, ref crit, ref customDamage, ref playSound, ref genGore, ref damageSource)) { b = false; } } return(b); }
public static bool OnPlayerKillMe(Player player, PlayerDeathReason damageSource, double dmg, int hitDirection, bool pvp) { var ret = false; foreach (var plugin in loadedPlugins.OfType<IPluginPlayerKillMe>()) ret = plugin.OnPlayerKillMe(player, damageSource, dmg, hitDirection, pvp) || ret; return ret; }
public override bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { MrPlagueRaceInfo = false; if (race.UsesCustomDeathSound) { playSound = false; } return(race.PreKill(player, mod, damage, hitDirection, pvp, ref playSound, ref genGore, ref damageSource)); }
public virtual void Kill(double damage, int hitDirection, bool pvp, PlayerDeathReason damageSource) { }
public override void ProcessTriggers(TriggersSet triggersSet) { if (player.itemAnimation == 0 && player.itemTime == 0 && player.reuseDelay == 0) { // Saves what the item selected was then switches to the hotkey item and uses it if (Fargowiltas.CustomKey.JustPressed) { oldSelected = player.selectedItem; player.selectedItem = 40; player.controlUseItem = true; isReuse = player.HeldItem.autoReuse; player.HeldItem.autoReuse = true; player.releaseUseItem = true; } // Switches back to the old item (has some big ol jank) if (Fargowiltas.CustomKey.JustReleased) { player.controlUseItem = false; player.releaseUseItem = false; player.HeldItem.autoReuse = isReuse; player.selectedItem = oldSelected; } } if (Fargowiltas.RodKey.JustPressed && hasRod) { // .5 second cd if (rodCD == 0 && Main.myPlayer == player.whoAmI) { Vector2 targetPos; targetPos.X = Main.MouseWorld.X; targetPos.Y = (player.gravDir == -1f) ? Main.MouseWorld.Y : Main.MouseWorld.Y - player.height; targetPos.X -= player.width / 2; if (targetPos.X > 50f && targetPos.X < (Main.maxTilesX * 16 - 50) && targetPos.Y > 50f && targetPos.Y < (Main.maxTilesY * 16 - 50)) { int tileX = (int)(targetPos.X / 16f); int tileY = (int)(targetPos.Y / 16f); if ((Main.tile[tileX, tileY].wall != WallID.LihzahrdBrickUnsafe || tileY <= Main.worldSurface || NPC.downedPlantBoss) && !Collision.SolidCollision(targetPos, player.width, player.height)) { player.Teleport(targetPos, 1); NetMessage.SendData(MessageID.Teleport, -1, -1, null, 0, player.whoAmI, targetPos.X, targetPos.Y, 1); if (player.chaosState) { player.statLife -= player.statLifeMax2 / 7; PlayerDeathReason damageSource = PlayerDeathReason.ByOther(13); if (Main.rand.NextBool(2)) { damageSource = PlayerDeathReason.ByOther(player.Male ? 14 : 15); } if (player.statLife <= 0) { player.KillMe(damageSource, 1d, 0); } player.lifeRegenCount = 0; player.lifeRegenTime = 0; } player.AddBuff(BuffID.ChaosState, 360); if (Fargowiltas.ModLoaded["FargowiltasSouls"]) { Fargos(); } rodCD = 30; } } } } if (Fargowiltas.HomeKey.JustPressed && hasMirror && mirrorCD == 0) { if (Main.rand.NextBool(2)) { Dust.NewDust(player.position, player.width, player.height, 15, 0f, 0f, 150, Color.White, 1.1f); } for (int i = 0; i < 70; ++i) { Dust.NewDust(player.position, player.width, player.height, 15, (float)(player.velocity.X * 0.5), (float)(player.velocity.Y * 0.5), 150, Color.White, 1.5f); } player.grappling[0] = -1; player.grapCount = 0; for (int i = 0; i < Main.maxProjectiles; ++i) { if (Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].aiStyle == 7) { Main.projectile[i].Kill(); } } Main.PlaySound(SoundID.Item6, player.Center); player.Spawn(); for (int i = 0; i < 70; ++i) { Dust.NewDust(player.position, player.width, player.height, 15, 0.0f, 0.0f, 150, Color.White, 1.5f); } mirrorCD = 120; } }
public bool OnPlayerKillMe(Player player, PlayerDeathReason damageSource, double dmg, int hitDirection, bool pvp) { return mode == Mode.God || mode == Mode.DemiGod; }
// TODO Change this in favor of auto checking. public override bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { List <NPC> activeBosses = new List <NPC>(); bool isGolemAlive = false; foreach (NPC npc in Main.npc) { if (npc.boss && npc.active) { activeBosses.Add(npc); } if (npc.type == NPCID.Golem) { isGolemAlive = true; } } if (zenkaiCharm && !zenkaiCharmActive && !player.HasBuff(mod.BuffType("ZenkaiCooldown"))) { player.statLife = 50; player.HealEffect(50); player.AddBuff(mod.BuffType("ZenkaiBuff"), 300); return(false); } if (eliteSaiyanBonus && !zenkaiCharmActive && !player.HasBuff(mod.BuffType("ZenkaiCooldown"))) { int healamount = (player.statLifeMax + player.statLifeMax2); player.statLife += healamount; player.HealEffect(healamount); player.AddBuff(mod.BuffType("ZenkaiBuff"), 600); return(false); } TransformationDefinition transformation = GetCurrentTransformation(); if (transformation != null) { transformation.OnPlayerPreKill(this, activeBosses, damage, hitDirection, pvp, ref playSound, ref genGore, ref damageSource); } if (activeBosses.Count > 0 && !SSJ1Achived && player.whoAmI == Main.myPlayer && NPC.downedBoss3) { if (rageCurrent >= 3) { overallFormUnlockChance = 1; } else { formUnlockChance = 20; } if (Main.rand.Next(overallFormUnlockChance) == 0) { Main.NewText("The humiliation of failing drives you mad.", Color.Yellow); player.statLife = player.statLifeMax2 / 2; player.HealEffect(player.statLifeMax2 / 2); TransformationDefinitionManager.LSSJDefinition.TryUnlock(this); isTransforming = true; SSJTransformation(); SelectedTransformation = TransformationDefinitionManager.SSJ1Definition; TransformationDefinitionManager.SSJ1Definition.TryUnlock(this); rageCurrent = 0; EndTransformations(); return(false); } } if (activeBosses.Count > 0 && SSJ1Achived && !SSJ2Achieved && player.whoAmI == Main.myPlayer && !IsLegendary() && NPC.downedMechBossAny && (IsTransformedInto(TransformationDefinitionManager.SSJ1Definition) || IsTransformedInto(TransformationDefinitionManager.SSJ2Definition) || IsTransformedInto(TransformationDefinitionManager.SSJ3Definition) && PlayerTransformations[TransformationDefinitionManager.SSJ1Definition].Mastery >= 1)) { Main.NewText("The rage of failing once more dwells deep within you.", Color.Red); player.statLife = player.statLifeMax2 / 2; player.HealEffect(player.statLifeMax2 / 2); TransformationDefinitionManager.SSJ2Definition.Unlock(this); isTransforming = true; SSJ2Transformation(); SelectedTransformation = TransformationDefinitionManager.SSJ2Definition; EndTransformations(); rageCurrent = 0; return(false); } if (activeBosses.Count > 0 && SSJ1Achived && !LSSJAchieved && player.whoAmI == Main.myPlayer && IsLegendary() && NPC.downedMechBossAny && player.HasBuff(TransformationDefinitionManager.SSJ1Definition.GetBuffId()) && PlayerTransformations[TransformationDefinitionManager.SSJ1Definition].Mastery >= 1) { Main.NewText("Your rage is overflowing, you feel something rise up from deep inside.", Color.Green); player.statLife = player.statLifeMax2 / 2; player.HealEffect(player.statLifeMax2 / 2); TransformationDefinitionManager.LSSJDefinition.Unlock(this); isTransforming = true; LSSJTransformation(); SelectedTransformation = TransformationDefinitionManager.LSSJDefinition; EndTransformations(); rageCurrent = 0; return(false); } if (isGolemAlive && SSJ1Achived && SSJ2Achieved && !SSJ3Achieved && !IsLegendary() && player.whoAmI == Main.myPlayer && player.HasBuff(TransformationDefinitionManager.SSJ2Definition.GetBuffId()) && PlayerTransformations[TransformationDefinitionManager.SSJ2Definition].Mastery >= 1) { Main.NewText("The ancient power of the Lihzahrds seeps into you, causing your power to become unstable.", Color.Orange); player.statLife = player.statLifeMax2 / 2; player.HealEffect(player.statLifeMax2 / 2); TransformationDefinitionManager.SSJ3Definition.Unlock(this); isTransforming = true; SSJ3Transformation(); SelectedTransformation = TransformationDefinitionManager.SSJ3Definition; EndTransformations(); rageCurrent = 0; return(false); } if (immortalityRevivesLeft > 0) { int healamount = (player.statLifeMax + player.statLifeMax2); player.statLife += healamount; player.HealEffect(healamount); immortalityRevivesLeft -= 1; return(false); } if (activeBosses.Count > 0 && player.whoAmI == Main.myPlayer) { rageCurrent += 1; return(true); } return(true); }
internal static void KillMeEnd(global::Terraria.Player player, PlayerDeathReason damageSource, double dmg, int hitDirection, bool pvp, string deathText) => Hooks.Player.PostKillMe?.Invoke(player, damageSource, dmg, hitDirection, pvp, deathText);
public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { // i frames during transformation if (isTransforming) { return(false); } // PLACE DAMAGE CANCELLING EFFECTS HERE. // handle blocking damage reductions switch (blockState) { case 1: return(false); // damage negated case 2: damage /= 3; break; case 3: damage /= 2; break; } // handle chlorophyte regen if (chlorophyteHeadPieceActive && !player.HasBuff(mod.BuffType("ChlorophyteRegen"))) { player.AddBuff(mod.BuffType("ChlorophyteRegen"), 180); } // handle ki enhancer "reserves" buff if (goblinKiEnhancer && !player.HasBuff(mod.BuffType("EnhancedReserves"))) { player.AddBuff(mod.BuffType("EnhancedReserves"), 180); } // black diamond ki bonus if (blackDiamondShell) { int i = Main.rand.Next(10, 100); AddKi(i, false, false); CombatText.NewText(new Rectangle((int)player.position.X, (int)player.position.Y, player.width, player.height), new Color(51, 204, 255), i, false, false); } // increment current mastery if applicable, for damage taken. HandleDamageReceivedMastery(damage); return(true); }
public override bool CanUseItem(Item item, Player player) { FargoPlayer modPlayer = player.GetModPlayer <FargoPlayer>(); if (item.type == ItemID.PumpkinPie && player.statLife != player.statLifeMax2 && player.HasBuff(BuffID.PotionSickness)) { return(false); } if (item.magic && player.GetModPlayer <FargoPlayer>().ReverseManaFlow) { player.Hurt(PlayerDeathReason.ByCustomReason(player.name + " was destroyed by their own magic."), (item.mana * 4) + item.damage, 0); player.immune = false; player.immuneTime = 0; } if (modPlayer.Infinity && !modPlayer.Eternity && (item.useAmmo != AmmoID.None || item.mana > 0 || item.consumable)) { modPlayer.InfinityCounter++; if (modPlayer.InfinityCounter >= 4) { modPlayer.InfinityHurt(); } } //non weapons and weapons with no ammo begone if (item.damage <= 0 || !player.HasAmmo(item, true) || (item.mana > 0 && player.statMana < item.mana)) { return(true); } if (modPlayer.BorealEnchant && ++modPlayer.BorealCount >= 4) { modPlayer.BorealCount = 0; if (Soulcheck.GetValue("Boreal Snowball Support")) { Vector2 velocity = Vector2.Normalize(Main.MouseWorld - player.Center) * item.shootSpeed * .75f; int p = Projectile.NewProjectile(player.Center, velocity, ProjectileID.SnowBallFriendly, (int)(item.damage * .5f), 1, Main.myPlayer); if (p != 1000 && (player.ZoneSnow || modPlayer.WoodForce)) { FargoGlobalProjectile.SplitProj(Main.projectile[p], 5); } } } if (modPlayer.AdditionalAttacks && modPlayer.AdditionalAttacksTimer <= 0) { modPlayer.AdditionalAttacksTimer = 60; Vector2 position = player.Center; Vector2 velocity = Vector2.Normalize(Main.MouseWorld - position); if (modPlayer.CelestialRune && Soulcheck.GetValue("Celestial Rune Support")) { if (item.melee) //fireball { Main.PlaySound(SoundID.Item34, position); for (int i = 0; i < 3; i++) { Projectile.NewProjectile(position, velocity.RotatedByRandom(Math.PI / 6) * Main.rand.NextFloat(6f, 10f), mod.ProjectileType("CelestialRuneFireball"), (int)(50f * player.meleeDamage), 9f, player.whoAmI); } } if (item.ranged) //lightning { float ai1 = Main.rand.Next(100); Vector2 vel = Vector2.Normalize(velocity.RotatedByRandom(Math.PI / 4)) * 7f; Projectile.NewProjectile(position, vel, mod.ProjectileType("CelestialRuneLightningArc"), (int)(50f * player.rangedDamage), 1f, player.whoAmI, velocity.ToRotation(), ai1); } if (item.magic) //ice mist { Projectile.NewProjectile(position, velocity * 4.25f, mod.ProjectileType("CelestialRuneIceMist"), (int)(50f * player.magicDamage), 4f, player.whoAmI); } if (item.thrown) //ancient vision { Projectile.NewProjectile(position, velocity * 16f, mod.ProjectileType("CelestialRuneAncientVision"), (int)(50f * player.thrownDamage), 0, player.whoAmI); } } if (modPlayer.PumpkingsCape && Soulcheck.GetValue("Pumpking's Cape Support")) { if (item.melee) //flaming jack { float distance = 2000f; int target = -1; for (int i = 0; i < 200; i++) { if (Main.npc[i].active && Main.npc[i].CanBeChasedBy()) { float newDist = Main.npc[i].Distance(player.Center); if (newDist < distance) { distance = newDist; target = i; } } } if (target != -1) { Projectile.NewProjectile(position, velocity * 8f, ProjectileID.FlamingJack, (int)(75f * player.meleeDamage), 7.5f, player.whoAmI, target, 0f); } } if (item.ranged) //jack o lantern { Projectile.NewProjectile(position, velocity * 11f, ProjectileID.JackOLantern, (int)(95f * player.rangedDamage), 8f, player.whoAmI); } if (item.magic) //bat scepter { for (int i = 0; i < 3; i++) { Vector2 newVel = velocity * 10f; newVel.X += Main.rand.Next(-35, 36) * 0.02f; newVel.Y += Main.rand.Next(-35, 36) * 0.02f; Projectile.NewProjectile(position, newVel, ProjectileID.Bat, (int)(45f * player.magicDamage), 3f, player.whoAmI); } } } } if (Fargowiltas.Instance.ThoriumLoaded) { ThoriumCanUse(player, item); } return(true); }
public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { if (zellariumBody && Main.rand.Next(10) == 0) { return(false); } return(base.PreHurt(pvp, quiet, ref damage, ref hitDirection, ref crit, ref customDamage, ref playSound, ref genGore, ref damageSource)); }
public override bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { if (player.HasBuff(mod.BuffType("DinoPox"))) { damageSource = PlayerDeathReason.ByCustomReason(player.name + " was driven to extintion by diseaese!"); } return(true); }
public override bool Shoot(Player player) { player.Hurt(PlayerDeathReason.ByCustomReason(player.name + " ate themselves"), item.damage, 0); player.AddBuff(BuffID.WellFed, 3000); return(false); }
public static bool PreHurt(Player player, bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { bool flag = true; foreach (ModPlayer modPlayer in player.modPlayers) { if (!modPlayer.PreHurt(pvp, quiet, ref damage, ref hitDirection, ref crit, ref customDamage, ref playSound, ref genGore, ref damageSource)) { flag = false; } } return(flag); }
public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { List <IHandleOnPlayerPreHurt> items = player.GetItemsByType <IHandleOnPlayerPreHurt>(); for (int i = 0; i < items.Count; i++) { if (!items[i].OnPlayerPreHurt(this, pvp, quiet, ref damage, ref hitDirection, ref crit, ref customDamage, ref playSound, ref genGore, ref damageSource)) { return(false); } } return(true); }
public override void AI() { if (runOnce) { if (Main.netMode == 0) { time = Main.rand.Next(300, 481); } else { time = Main.rand.Next(300, 481); } projectile.timeLeft = (int)time; runOnce = false; } Player player = Main.player[projectile.owner]; if (projectile.alpha > 0) { projectile.alpha--; } else { projectile.alpha = 0; } if (projectile.timeLeft <= 2) { projectile.alpha = 255; Rectangle myRect = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); Rectangle value = new Rectangle((int)player.position.X, (int)player.position.Y, player.width, player.height); if (myRect.Intersects(value)) { if (player.position.X + (float)(player.width / 2) < projectile.position.X + (float)(projectile.width / 2)) { projectile.direction = -1; } else { projectile.direction = 1; } int num4 = Main.DamageVar((float)projectile.damage); projectile.StatusPlayer(Main.myPlayer); if (Main.expertMode) { player.Hurt(PlayerDeathReason.ByProjectile(mod.NPCType("RuneSpector"), projectile.whoAmI), (int)(num4 * 1.4f), projectile.direction, true, false, false, -1); } else { player.Hurt(PlayerDeathReason.ByProjectile(mod.NPCType("RuneSpector"), projectile.whoAmI), num4, projectile.direction, true, false, false, -1); } } for (int d = 0; d <= 100; d++) { Dust.NewDust(projectile.position, myRect.Width, myRect.Height, mod.DustType("AggroRuneLash")); } } if (projectile.timeLeft <= 70) { projectile.velocity = new Vector2(0, 0); } else { projectile.position.X = player.Center.X - 31; projectile.position.Y = player.Center.Y - 31; projectile.rotation += MathHelper.ToRadians(3); } }
public override bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { // bool baseResult = base.PreKill(damage, hitDirection, pvp, ref playSound, ref genGore, ref damageSource); List <IHandleOnPlayerPreKill> items = new List <IHandleOnPlayerPreKill>(); for (int i = 0; i < items.Count; i++) { if (!items[i].OnPlayerPreKill(this, ref damage, ref hitDirection, ref pvp, ref playSound, ref genGore, ref damageSource)) { return(false); } } return(true); }
public static bool OnPlayerHurt(Player player, PlayerDeathReason damageSource, int damage, int hitDirection, bool pvp, bool quiet, bool crit, int cooldownCounter, out double result) { result = 0.0; var ret = false; foreach (var plugin in loadedPlugins.OfType<IPluginPlayerHurt>()) { double temp; if (plugin.OnPlayerHurt(player, damageSource, damage, hitDirection, pvp, quiet, crit, cooldownCounter, out temp)) { ret = true; result = temp; } } return ret; }
public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { if (goldified) { damageSource = PlayerDeathReason.ByCustomReason(player.name + " died solid as a gold bar"); playSound = false; Main.PlaySound(SoundID.Item37, player.position); } return(base.PreHurt(pvp, quiet, ref damage, ref hitDirection, ref crit, ref customDamage, ref playSound, ref genGore, ref damageSource)); }
internal static bool HurtBegin(ref double returnValue, global::Terraria.Player player, ref PlayerDeathReason damageSource, ref int Damage, ref int hitDirection, ref bool pvp, ref bool quiet, ref string deathText, ref bool Crit, ref int cooldownCounter) { var res = Hooks.Player.Hurt?.Invoke(ref returnValue, player, ref damageSource, ref Damage, ref hitDirection, ref pvp, ref quiet, ref deathText, ref Crit, ref cooldownCounter); if (res.HasValue) return res.Value == HookResult.Continue; return true; }
private bool PreHurtKnockback(Player player, bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { if (Equipped(player) && damage > player.statLifeMax2 * 0.1f) { float magnitude = 1 + player.statLife / damage * 4; Array.ForEach(Main.npc, (npc) => { if (npc.active && Helper.IsTargetValid(npc) && !npc.friendly && Vector2.Distance(npc.Center, player.MountedCenter) < 250) { Vector2 vel = Vector2.Normalize(npc.Center - player.position) * magnitude * npc.knockBackResist; if (npc.noGravity) { npc.velocity += vel; } else { npc.HitEffect(player.Center.X < npc.Center.X ? -1 : 1, 0); player.ApplyDamageToNPC(npc, 0, magnitude * 0.8f * (1 + (1 - npc.knockBackResist)), player.Center.X < npc.Center.X ? 1 : -1, false); } for (int i = 0; i < 6; ++i) { Dust.NewDust(npc.position, 22, 22, ModContent.DustType <Dusts.GlassGravity>(), vel.RotatedByRandom(0.05f).X * 0.5f, vel.RotatedByRandom(0.05f).Y * 0.5f); Dust.NewDust(npc.position, 22, 22, ModContent.DustType <Content.Dusts.Air>()); } } }); } return(true); }
public virtual bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { return true; }
public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { if (GodModeService.Enabled) { return false; } return true; }
public bool OnPlayerHurt(Player player, PlayerDeathReason damageSource, int damage, int hitDirection, bool pvp, bool quiet, bool crit, int cooldownCounter, out double result) { result = 0.0; return mode == Mode.God; }
public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { if (signutTrans) { playSound = false; } if (cloudTrans) { playSound = false; } if (classicTrans) { playSound = false; } if (sandTrans) { playSound = false; } return(base.PreHurt(pvp, quiet, ref damage, ref hitDirection, ref crit, ref customDamage, ref playSound, ref genGore, ref damageSource)); }
public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { if (damageSource.SourceOtherIndex == 0) { if (dunking) { //damage = 0; } } return(base.PreHurt(pvp, quiet, ref damage, ref hitDirection, ref crit, ref customDamage, ref playSound, ref genGore, ref damageSource)); }
public static bool PreKill(Player player, double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { bool flag = true; foreach (ModPlayer modPlayer in player.modPlayers) { if (!modPlayer.PreKill(damage, hitDirection, pvp, ref playSound, ref genGore, ref damageSource)) { flag = false; } } return flag; }
public override bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { if (damageSource.SourceOtherIndex == 0) { damageSource = PlayerDeathReason.ByCustomReason(" FELL HARD"); } if (damageSource.SourceOtherIndex == 8) { damageSource = PlayerDeathReason.ByCustomReason(" was dissolved by holy powers"); } return(true); }
internal static bool KillMeBegin(global::Terraria.Player player, ref PlayerDeathReason damageSource, ref double dmg, ref int hitDirection, ref bool pvp, ref string deathText) { var res = Hooks.Player.PreKillMe?.Invoke(player, ref damageSource, ref dmg, ref hitDirection, ref pvp, ref deathText); if (res.HasValue) return res.Value == HookResult.Continue; return true; }
public override bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { if (player.HasItem(mod.ItemType("OmegaHealingPotion")) && !player.HasBuff(BuffID.PotionSickness)) { player.ConsumeItem(mod.ItemType("OmegaHealingPotion")); player.immune = true; player.AddBuff(BuffID.PotionSickness, 7200); player.immuneTime = 180; if (player.statLife + 450 < player.statLifeMax2) { player.statLife += 450; player.HealEffect(450); } else { player.HealEffect(player.statLifeMax2 - player.statLife); player.statLife = player.statLifeMax2; } return(false); } if (secondlife == true && lifeCounter == lifeCounterMax) { player.statLife = ((int)player.statLifeMax2 / 10) * lifeQuality; player.HealEffect((int)player.statLifeMax2 / 10 * lifeQuality); player.immune = true; player.immuneTime = 200; lifeCounter = 0; return(false); } else { return(true); } }