public override void AI() { if (Fired) { projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; if (type < ProjectileID.Count) { projectile.type = type; projectile.VanillaAI(); projectile.type = ID; } else { ProjectileLoader.GetProjectile(type)?.AI(); } if (projectile.Center.Y + projectile.velocity.Y < Main.offLimitBorderTiles * 16) { projectile.Kill(); Orion_Star.t = type; for (int i = 0; i < 3; i++) { Projectile.NewProjectile(projectile.Center.X + Main.rand.NextFloat(-8, 8) * 16, Main.offLimitBorderTiles * 16, Main.rand.NextFloat(-5, 5), 25, Orion_Star.ID, 250, 10f, projectile.owner); } } } else { Main.player[projectile.owner].GetModPlayer <EpikPlayer>().nextHeldProj = projectile.whoAmI; Main.player[projectile.owner].heldProj = projectile.whoAmI; } }
public override void Kill(int timeLeft) { if (type > ProjectileID.Count) { ProjectileLoader.GetProjectile(type)?.Kill(timeLeft); } }
private void AddBuffToTheEnemy(Projectile proj, NPC npc) { switch (proj.type) { case ProjectileID.Stinger: case ProjectileID.PoisonSeedPlantera: case ProjectileID.SalamanderSpit: if (Main.rand.Next(2) == 0) { npc.AddBuff(BuffID.Poisoned, Main.rand.Next(300) + 300); } break; case 436: //混乱 if (Main.rand.Next(3) > 1) { npc.AddBuff(31, 300); } break; case ProjectileID.CursedFlameHostile: case ProjectileID.EyeFire: if (Main.rand.Next(3) == 0) { npc.AddBuff(BuffID.CursedInferno, 420); } break; case ProjectileID.GoldenShowerHostile: npc.AddBuff(BuffID.Ichor, 420); break; case ProjectileID.FireArrow: if (Main.rand.Next(3) == 0) { npc.AddBuff(BuffID.OnFire, 420); } break; case ProjectileID.DD2BetsyFlameBreath: npc.AddBuff(BuffID.OnFire, 600); break; case ProjectileID.Fireball: if (Main.rand.Next(2) == 0) { npc.AddBuff(BuffID.OnFire, 300 + Main.rand.Next(120)); } break; } if (proj.GetGlobalProjectile <ProjectileOwnerGProj>().OwnerWMI == EvE.EnemyA) { ProjectileLoader.OnHitPlayer(proj, Main.player[EvE.FakePlayer2], 1, false); } else if (proj.GetGlobalProjectile <ProjectileOwnerGProj>().OwnerWMI == EvE.EnemyB) { ProjectileLoader.OnHitPlayer(proj, Main.player[EvE.FakePlayer1], 1, false); } }
public static bool IsBadType(HologramMode mode, int type) { switch (mode) { case HologramMode.NPC: if (type < NPCLoader.NPCCount) { return(false); } //type < Main.npcTexture.Length return(NPCLoader.GetNPC(type) == null); case HologramMode.Item: if (type < ItemLoader.ItemCount) { return(false); } //type < Main.itemTexture.Length return(ItemLoader.GetItem(type) == null); case HologramMode.Projectile: if (type < ProjectileLoader.ProjectileCount) { return(false); } //type < Main.projectileTexture.Length return(ProjectileLoader.GetProjectile(type) == null); case HologramMode.Gore: return(type < 0 || type >= ModGore.GoreCount); //return Main.goreTexture[type] == null; default: throw new ModHelpersException("Invalid hologram type"); } }
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { if (type > ProjectileID.Count) { ProjectileLoader.GetProjectile(type)?.ModifyHitNPC(target, ref damage, ref knockback, ref crit, ref hitDirection); } }
private void EmitUngrapplePlatformDelegate(Projectile proj) { Player player = Main.player[proj.owner]; int numHooks = 3; //time to replicate retarded vanilla hardcoding, wheee if (proj.type == 165) { numHooks = 8; } if (proj.type == 256) { numHooks = 2; } if (proj.type == 372) { numHooks = 2; } if (proj.type == 652) { numHooks = 1; } if (proj.type >= 646 && proj.type <= 649) { numHooks = 4; } //end vanilla zoink ProjectileLoader.NumGrappleHooks(proj, player, ref numHooks); if (player.grapCount > numHooks) { Main.projectile[player.grappling.OrderBy(n => (Main.projectile[n].active ? 0 : 999999) + Main.projectile[n].timeLeft).ToArray()[0]].Kill(); } }
public override bool PreKill(int timeLeft) { if (type > ProjectileID.Count) { return(ProjectileLoader.GetProjectile(type)?.PreKill(timeLeft) ?? true); } projectile.type = type; return(true); }
private bool hitAndAttachProjectile(NPC npc) { if (!npc.active || npc.immortal || npc.dontTakeDamage || (npc.friendly && !(npc.type == NPCID.Guide && Main.player[projectile.owner].killGuide) && !(npc.type == NPCID.Clothier && Main.player[projectile.owner].killClothier)) ) { if (npc.type != NPCID.TargetDummy) { return(false); } } bool?b = NPCLoader.CanBeHitByProjectile(npc, projectile); if (b.HasValue && !b.Value) { return(false); } b = ProjectileLoader.CanHitNPC(projectile, npc); if (b.HasValue && !b.Value) { return(false); } b = PlayerHooks.CanHitNPCWithProj(projectile, npc); if (b.HasValue && !b.Value) { return(false); } npcIndex = (short)npc.whoAmI; npc.GetGlobalNPC <FishGlobalNPC>(mod).isHooked++; if (Main.player[projectile.owner].GetModPlayer <FishPlayer>(mod).seals) { npc.GetGlobalNPC <FishGlobalNPC>(mod).isSealed++; } projectile.Center = npc.Center; updatePos = false; if (Main.netMode != 0) { /* * ModPacket pk = mod.GetPacket(); * pk.Write((byte)2); * pk.Write((ushort)(projectile.whoAmI)); * pk.Write(npcIndex); * pk.Write(projectile.ai[0]); * pk.Send();*/ NetMessage.SendData(27, -1, -1, null, projectile.whoAmI, 0f, 0f, 0f, 0, 0, 0); } /* if(projectile.damage > 0) * { * //Main.NewText("Entered npc " + npcIndex + " into bobber " + projectile.whoAmI + " from player " + projectile.owner + ";"); * damageNPC(npc); * }*/ return(true); }
public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) { if (type > ProjectileID.Count) { ProjectileLoader.GetProjectile(type)?.PreDraw(spriteBatch, lightColor); } projectile.type = ID; spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.Transform); }
private bool hitAndAttachProjectile(Player p) { if (!attatchesToAllies && (!p.hostile || p.team == Main.player[projectile.owner].team)) { return(false); } if (!attatchesToEnemies && (p.hostile && p.team != Main.player[projectile.owner].team)) { return(false); } bool?b = PlayerHooks.CanHitPvpWithProj(projectile, p); if (b.HasValue && !b.Value) { return(false); } b = ProjectileLoader.CanHitPvp(projectile, p); if (b.HasValue && !b.Value) { return(false); } npcIndex = (short)(p.whoAmI + Main.npc.Length); FishPlayer fOwner = Main.player[projectile.owner].GetModPlayer <FishPlayer>(mod); p.GetModPlayer <FishPlayer>(mod).isHooked++; if (fOwner.seals) { p.GetModPlayer <FishPlayer>(mod).isSealed++; } projectile.Center = p.Center; updatePos = false; if (Main.netMode != 0) { /* * ModPacket pk = mod.GetPacket(); * pk.Write((byte)2); * pk.Write((ushort)(projectile.whoAmI)); * pk.Write(npcIndex); * pk.Write(projectile.ai[0]); * pk.Send();*/ NetMessage.SendData(27, -1, -1, null, projectile.whoAmI, 0f, 0f, 0f, 0, 0, 0); } /* if(projectile.damage > 0) * { * damagePlayer(p); * }*/ return(true); }
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { projectile.type = type; spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, EpikV2.starlightShader.Shader, Main.Transform); if (type > ProjectileID.Count) { return(ProjectileLoader.GetProjectile(type)?.PreDraw(spriteBatch, lightColor) ?? true); } return(true); }
private float GrappleRange(int type) { if (vanillaGrappleRanges.ContainsKey(type)) { return(vanillaGrappleRanges[type]); } if (type > ProjectileID.Count) { return(ProjectileLoader.GetProjectile(type).GrappleRange()); } return(0); }
public static void InitializeAllContentLoaders(ContentManager content) { TextureLoader.Initialize(content); FontLoader.Initialize(content); CharmLoader.Initialize(content); CreatureLoader.Initialize(content); ProjectileLoader.Initialize(content); ShieldLoader.Initialize(content); TileLoader.Initialize(content); UserInterfaceLoader.Initialize(content); WeaponLoader.Initialize(content); }
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { if (type > ProjectileID.Count) { ProjectileLoader.GetProjectile(type)?.ModifyHitNPC(target, ref damage, ref knockback, ref crit, ref hitDirection); } if (projectile.aiStyle == 0) { crit = true; float crt = Main.player[projectile.owner].rangedCrit / 100f; damage += (int)(damage * crt); } }
/// <summary> /// Calculates simple collision with NPCs, and manages two sets of collections pertaining to them so that damage related code runs properly. /// <para>Requires persistent collections for hitTargets and foundTargets, and the method to be called in any AI hook only once (per tick).</para> /// <para>This method only works on several assumptions:</para> /// <para>* local immunity is used, so that the first contact is a guaranteed hit</para> /// <para>* it uses generic "damage through contact" code, and not special laser code (last prism)</para> /// </summary> /// <param name="projectile">The projectile</param> /// <param name="hitTargets">The collection of NPC indexes it has already hit and should be excluded</param> /// <param name="foundTargets">The collection of NPC indexes from the last method call to then add to hitTargets</param> /// <param name="max">The amount of NPCs it can hit before killing itself</param> /// <param name="condition">Custom condition to check for the NPC before setting it as a suitable target. If null, counts as true.</param> /// <returns>True if target count is atleast max (which kills itself)</returns> public static bool HandleChaining(this Projectile projectile, ICollection <int> hitTargets, ICollection <int> foundTargets, int max, Func <NPC, bool> condition = null) { //Applies foundTargets from the last call to hitTargets foreach (var f in foundTargets) { if (!hitTargets.Contains(f)) { //If check can be removed here, but left in in case of debugging/additional method hitTargets.Add(f); } } foundTargets.Clear(); //Seek suitable targets the projectile collides with for (int i = 0; i < Main.maxNPCs; i++) { NPC npc = Main.npc[i]; if (!npc.active || npc.dontTakeDamage || projectile.friendly && npc.townNPC) //The only checks that truly prevent damage. No chaseable or immortal, those can still be hit { continue; } //Simple code instead of complicated recreation of vanilla+modded collision code here (which only runs clientside, but this has to be all-side) //Hitbox has to be for "next update cycle" because AI (where this should be called) runs before movement updates, which runs before damaging takes place Rectangle hitbox = new Rectangle((int)(projectile.position.X + projectile.velocity.X), (int)(projectile.position.Y + projectile.velocity.Y), projectile.width, projectile.height); ProjectileLoader.ModifyDamageHitbox(projectile, ref hitbox); if (!projectile.Colliding(hitbox, npc.Hitbox)) //Intersecting hitboxes + special checks. Safe to use all-side, lightning aura uses it { continue; } if (condition != null && !condition(npc)) { //If custom condition returns false continue; } foundTargets.Add(i); } if (hitTargets.Count >= max) { projectile.Kill(); return(true); } return(false); }
public override void AI() { projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; if (type < ProjectileID.Count) { projectile.type = type; projectile.VanillaAI(); projectile.type = ID; } else { ProjectileLoader.GetProjectile(type)?.AI(); } }
private void damagePlayer(Player p) { if (Main.netMode != 1 && projectile.damage > 0) { FishPlayer owner = Main.player[projectile.owner].GetModPlayer <FishPlayer>(mod); int dmg = (int)Math.Round(projectile.damage * (owner.bobberDamage + escalationBonus(owner))); dmg = Main.DamageVar(dmg); if (dmg < 1) { dmg = 1; } bool crit = Main.rand.Next(100) < owner.bobberCrit + Main.player[projectile.owner].inventory[Main.player[projectile.owner].selectedItem].crit; ProjectileLoader.ModifyHitPvp(projectile, p, ref dmg, ref crit); PlayerHooks.ModifyHitPvpWithProj(projectile, p, ref dmg, ref crit); Main.player[projectile.owner].OnHit(p.Center.X, p.Center.Y, p); /* if (crit) * { * dmg *= 2; * }*/ dmg = (int)p.Hurt(PlayerDeathReason.ByProjectile(projectile.owner, projectile.whoAmI), dmg, projectile.direction, true, false, crit, -1); if (Main.netMode == 2) { ModPacket pk = mod.GetPacket(); pk.Write((byte)3); pk.Write(dmg); pk.Send(projectile.owner, -1); } else { if (Main.player[projectile.owner].accDreamCatcher) { Main.player[projectile.owner].addDPS(dmg); } } ProjectileLoader.OnHitPvp(projectile, p, dmg, crit); PlayerHooks.OnHitPvpWithProj(projectile, p, dmg, crit); if (Main.netMode != 0) { NetMessage.SendPlayerHurt(p.whoAmI, PlayerDeathReason.ByProjectile(projectile.owner, projectile.whoAmI), dmg, projectile.direction, crit, true, 0, -1, -1); } } }
/// <summary> /// Gets a (human readable) unique key (as segments) from a given projectile type. /// </summary> /// <param name="projType"></param> /// <returns></returns> public static Tuple <string, string> GetUniqueKeySegs(int projType) { if (projType < 0 || projType >= ProjectileLoader.ProjectileCount) { throw new ArgumentOutOfRangeException("Invalid type: " + projType); } if (projType < ProjectileID.Count) { return(Tuple.Create("Terraria", ProjectileID.Search.GetName(projType))); } var modProjectile = ProjectileLoader.GetProjectile(projType); return(Tuple.Create(modProjectile.mod.Name, modProjectile.Name)); }
public override void PostSetupContent() { List <int> tempList = new List <int>(); for (int i = Main.maxProjectileTypes; i < ProjectileLoader.ProjectileCount; i++) { ModProjectile mProj = ProjectileLoader.GetProjectile(i); if (mProj != null && mProj.mod.Name == "AssortedCrazyThings" && mProj.GetType().Name.StartsWith("CuteSlime")) { tempList.Add(mProj.projectile.type); } } ACTPetsWithSmallVerticalHitbox = tempList.ToArray(); Array.Sort(ACTPetsWithSmallVerticalHitbox); }
private void DrawProjectileDamageHitboxes() { for (int i = 0; i < 1000; i++) { Projectile projectile = Main.projectile[i]; if (projectile.active) { Rectangle hitbox = projectile.getRect(); ProjectileLoader.ModifyDamageHitbox(projectile, ref hitbox); hitbox.Offset((int)-Main.screenPosition.X, (int)-Main.screenPosition.Y); hitbox = Main.ReverseGravitySupport(hitbox); Main.spriteBatch.Draw(Main.magicPixel, hitbox, Color.OrangeRed * 0.6f); } } }
public override void AddRecipeGroups() { // Automatically register MinionModels var item = new Item(); var projectile = new Projectile(); for (int i = ItemID.Count; i < ItemLoader.ItemCount; i++) { item = ItemLoader.GetItem(i).item; if (item.buffType > 0 && item.shoot >= ProjectileID.Count) { projectile = ProjectileLoader.GetProjectile(item.shoot).projectile; if (projectile.minionSlots > 0) { // Avoid automatic support for manually supported if (!SupportedMinions.Any(x => x.ItemID == i || x.ProjectileIDs.Contains(projectile.type) || x.BuffID == item.buffType)) { AddMinion(new MinionModel(item.type, item.buffType, projectile.type)); } } } } SupportedMinionsFinalized = true; var itemList = new List <int>(); foreach (MinionModel minion in SupportedMinions) { itemList.Add(minion.ItemID); } foreach (int type in ModdedSummonerWeaponsWithExistingBuff) { itemList.Add(type); } ModdedSummonerWeaponsWithExistingBuff = null; var group = new RecipeGroup(() => Language.GetTextValue("LegacyMisc.37") + " Minion Staff", itemList.ToArray()); RecipeGroup.RegisterGroup("SummonersAssociation:MinionStaffs", group); group = new RecipeGroup(() => Language.GetTextValue("LegacyMisc.37") + " Magic Mirror", new int[] { ItemID.MagicMirror, ItemID.IceMirror }); RecipeGroup.RegisterGroup("SummonersAssociation:MagicMirrors", group); }
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { if (type < ProjectileID.Count) { projectile.type = type; projectile.StatusNPC(target.whoAmI); projectile.type = ID; switch (type) { case ProjectileID.HolyArrow: case ProjectileID.HellfireArrow: Projectile.NewProjectileDirect(projectile.Center, Vector2.Zero, type, projectile.damage, projectile.knockBack, projectile.owner).Kill(); break; } } else { ProjectileLoader.GetProjectile(type)?.OnHitNPC(target, damage, knockback, crit); } }
public override void AI() { OreEffect(); if (projectile.velocity.X > 0) { projectile.direction = 1; } else { projectile.direction = -1; } bool flag = false; Vector2 velocity = Collision.TileCollision(projectile.position, projectile.velocity, projectile.width, projectile.height, true, true, 1);; if (velocity != projectile.velocity) { flag = true; } if (flag && ProjectileLoader.OnTileCollide(projectile, projectile.velocity)) { rotationspeed -= .021f; } if (rotationspeed <= 0 || (projectile.velocity.X == 0)) { projectile.Kill(); rotationspeed = 0f; } projectile.rotation += rotationspeed * projectile.direction; for (int m = projectile.oldPos.Length - 1; m > 0; m--) { projectile.oldPos[m] = projectile.oldPos[m - 1]; } projectile.oldPos[0] = projectile.position; }
public override void PostDraw(Color lightColor) { //TODO Generic glowmask draw, maybe generalize method Player player = Main.player[Projectile.owner]; int offsetY = 0; int offsetX = 0; Texture2D glowmaskTexture = glowmask.Value; float originX = (glowmaskTexture.Width - Projectile.width) * 0.5f + Projectile.width * 0.5f; ProjectileLoader.DrawOffset(Projectile, ref offsetX, ref offsetY, ref originX); SpriteEffects spriteEffects = SpriteEffects.None; if (Projectile.spriteDirection == -1) { spriteEffects = SpriteEffects.FlipHorizontally; } if (Projectile.ownerHitCheck && player.gravDir == -1f) { if (player.direction == 1) { spriteEffects = SpriteEffects.FlipHorizontally; } else if (player.direction == -1) { spriteEffects = SpriteEffects.None; } } Vector2 drawPos = new Vector2(Projectile.position.X - Main.screenPosition.X + originX + offsetX, Projectile.position.Y - Main.screenPosition.Y + Projectile.height / 2 + Projectile.gfxOffY); Rectangle sourceRect = glowmaskTexture.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); Color glowColor = new Color(255, 255, 255, 255) * 0.7f * Projectile.Opacity; Vector2 drawOrigin = new Vector2(originX, Projectile.height / 2 + offsetY); Main.EntitySpriteDraw(glowmaskTexture, drawPos, sourceRect, glowColor, Projectile.rotation, drawOrigin, Projectile.scale, spriteEffects, 0); }
protected override List <DefinitionOptionElement <ProjectileDefinition> > GetPassedOptionElements() { var passed = new List <DefinitionOptionElement <ProjectileDefinition> >(); foreach (var option in options) { // Should this be the localized projectile name? if (Lang.GetProjectileName(option.type).Value.IndexOf(chooserFilter.CurrentString, StringComparison.OrdinalIgnoreCase) == -1) { continue; } string modname = option.definition.mod; if (option.type > ProjectileID.Count) { modname = ProjectileLoader.GetProjectile(option.type).Mod.DisplayName; // or internal name? } if (modname.IndexOf(chooserFilterMod.CurrentString, StringComparison.OrdinalIgnoreCase) == -1) { continue; } passed.Add(option); } return(passed); }
public WeaponFactory() { weaponSprites = WeaponLoader.GetInstance(); projectileSprites = ProjectileLoader.GetInstance(); }
public void Damage(Projectile projectile) { if (projectile.aiStyle == 31 || projectile.aiStyle == 32 || (projectile.type == 434 && projectile.localAI[0] != 0f) || ((projectile.aiStyle == 137 && projectile.ai[0] != 0f)) || projectile.aiStyle == 138) { return; } if (projectile.aiStyle == 93 && projectile.ai[0] != 0f && projectile.ai[0] != 2f) { return; } if (projectile.aiStyle == 10 && projectile.localAI[1] == -1f) { return; } if (Main.projPet[projectile.type] && projectile.type != 266 && projectile.type != 407 && projectile.type != 317 && (projectile.type != 388 || projectile.ai[0] != 2f) && (projectile.type < 390 || projectile.type > 392) && (projectile.type < 393 || projectile.type > 395) && (projectile.type != 533 || projectile.ai[0] < 6f || projectile.ai[0] > 8f) && (projectile.type < 625 || projectile.type > 628) && !ProjectileLoader.MinionContactDamage(projectile)) { return; } if (!ProjectileLoader.CanDamage(projectile)) { return; } Rectangle myRect = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); if (projectile.type == 85 || projectile.type == 101) { int num = 30; myRect.X -= num; myRect.Y -= num; myRect.Width += num * 2; myRect.Height += num * 2; } if (projectile.type == 188) { int num2 = 20; myRect.X -= num2; myRect.Y -= num2; myRect.Width += num2 * 2; myRect.Height += num2 * 2; } if (projectile.aiStyle == 29) { int num3 = 4; myRect.X -= num3; myRect.Y -= num3; myRect.Width += num3 * 2; myRect.Height += num3 * 2; } ProjectileLoader.ModifyDamageHitbox(projectile, ref myRect); if (projectile.damage > 0) { for (int i = 0; i < 200; i++) { if (Main.npc[i].active && !Main.npc[i].dontTakeDamage) { bool?flag2 = ProjectileLoader.CanHitNPC(projectile, Main.npc[i]); if (flag2 == null || flag2.Value) { bool?flag3 = NPCLoader.CanBeHitByProjectile(Main.npc[i], projectile); if (flag3 == null || flag3.Value) { bool flag5 = (flag2 != null && flag2.Value) || (flag3 != null && flag3.Value); if (projectile.hostile && !projectile.friendly && CheckForHit(projectile, Main.npc[i]) && !Main.npc[i].dontTakeDamage && Main.npc[i].immune[255] == 0) //重点判定 { bool flag6 = false; if (projectile.type == 11 && (Main.npc[i].type == NPCID.CorruptBunny || Main.npc[i].type == NPCID.CorruptGoldfish)) { flag6 = true; } else if (projectile.type == 31 && Main.npc[i].type == NPCID.Antlion) { flag6 = true; } if (flag5) { flag6 = false; } else if (Main.npc[i].trapImmune && projectile.trap) { flag6 = true; } else if (Main.npc[i].immortal && projectile.npcProj) { flag6 = true; } if (!flag6 && (Main.npc[i].noTileCollide || !projectile.ownerHitCheck || projectile.CanHit(Main.npc[i]))) { bool flag7; if (Main.npc[i].type == NPCID.SolarCrawltipedeTail) { Rectangle rect = Main.npc[i].getRect(); int num5 = 8; rect.X -= num5; rect.Y -= num5; rect.Width += num5 * 2; rect.Height += num5 * 2; flag7 = projectile.Colliding(myRect, rect); } else { flag7 = projectile.Colliding(myRect, Main.npc[i].getRect()); } if (flag7) { if (Main.npc[i].reflectingProjectiles && projectile.CanReflect()) { Main.npc[i].ReflectProjectile(projectile.whoAmI); return; } int num6 = projectile.damage; num6 *= EvE.config.ProjDamageMultiplier; /* * if (Main.npc[i].HasBuff(ModContent.BuffType<FerventAdoration2>())) //易损增加友伤 * { * num6 = projectile.damage * 5; * } */ if (projectile.type > 0 && ProjectileID.Sets.StardustDragon[projectile.type]) { float num7 = (projectile.scale - 1f) * 100f; num7 = Utils.Clamp(num7, 0f, 50f); num6 = (int)(num6 * (1f + num7 * 0.23f)); } int num8 = Main.DamageVar(num6); bool flag8 = !projectile.npcProj && !projectile.trap; if (projectile.trap && NPCID.Sets.BelongsToInvasionOldOnesArmy[Main.npc[i].type]) { num8 /= 2; } if ((projectile.type == 400 || projectile.type == 401 || projectile.type == 402) && Main.npc[i].type >= NPCID.EaterofWorldsHead && Main.npc[i].type <= NPCID.EaterofWorldsTail) { num8 = (int)(num8 * 0.65); if (projectile.penetrate > 1) { projectile.penetrate--; } } if (projectile.type == 710) { Point origin = projectile.Center.ToTileCoordinates(); if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(12), new GenCondition[] { new Conditions.IsSolid() }), out _)) { num8 = (int)(num8 * 1.5f); } } if (projectile.type == 504) { float num9 = (60f - projectile.ai[0]) / 2f; projectile.ai[0] += num9; } if (projectile.aiStyle == 3 && projectile.type != 301) { if (projectile.ai[0] == 0f) { projectile.velocity.X = -projectile.velocity.X; projectile.velocity.Y = -projectile.velocity.Y; projectile.netUpdate = true; } projectile.ai[0] = 1f; } else if (projectile.type == 582) { if (projectile.ai[0] != 0f) { projectile.direction *= -1; } } else if (projectile.type == 624) { float num10 = 1f; if (Main.npc[i].knockBackResist > 0f) { num10 = 1f / Main.npc[i].knockBackResist; } projectile.knockBack = 4f * num10; if (Main.npc[i].Center.X < projectile.Center.X) { projectile.direction = 1; } else { projectile.direction = -1; } } else if (projectile.aiStyle == 16) { if (projectile.timeLeft > 3) { projectile.timeLeft = 3; } if (Main.npc[i].position.X + Main.npc[i].width / 2 < projectile.position.X + projectile.width / 2) { projectile.direction = -1; } else { projectile.direction = 1; } } else if (projectile.aiStyle == 68) { if (projectile.timeLeft > 3) { projectile.timeLeft = 3; } if (Main.npc[i].position.X + Main.npc[i].width / 2 < projectile.position.X + (float)(projectile.width / 2)) { projectile.direction = -1; } else { projectile.direction = 1; } } else if (projectile.aiStyle == 50) { if (Main.npc[i].position.X + Main.npc[i].width / 2 < projectile.position.X + projectile.width / 2) { projectile.direction = -1; } else { projectile.direction = 1; } } if (projectile.type == 598 || projectile.type == 636 || projectile.type == 614) { projectile.ai[0] = 1f; projectile.ai[1] = i; projectile.velocity = (Main.npc[i].Center - projectile.Center) * 0.75f; projectile.netUpdate = true; } if (projectile.type >= 511 && projectile.type <= 513) { projectile.timeLeft = 0; } if (projectile.type == 659) { projectile.timeLeft = 0; } if (projectile.type == 524) { projectile.netUpdate = true; projectile.ai[0] += 50f; } if ((projectile.type == 688 || projectile.type == 689 || projectile.type == 690) && Main.npc[i].type != NPCID.DungeonGuardian && Main.npc[i].defense < 999) { num8 += Main.npc[i].defense / 2; } if (projectile.aiStyle == 39) { if (projectile.ai[1] == 0f) { projectile.ai[1] = i + 1; projectile.netUpdate = true; } } if (projectile.type == 41 && projectile.timeLeft > 1) { projectile.timeLeft = 1; } bool flag9 = false; if (projectile.aiStyle == 93) { if (projectile.ai[0] == 0f) { projectile.ai[1] = 0f; int num14 = -i - 1; projectile.ai[0] = num14; projectile.velocity = Main.npc[i].Center - projectile.Center; } if (projectile.ai[0] == 2f) { num8 = (int)(num8 * 1.35); } else { num8 = (int)(num8 * 0.15); } } if (Main.expertMode) { if ((projectile.type == 30 || projectile.type == 28 || projectile.type == 29 || projectile.type == 470 || projectile.type == 517 || projectile.type == 588 || projectile.type == 637) && Main.npc[i].type >= NPCID.EaterofWorldsHead && Main.npc[i].type <= NPCID.EaterofWorldsTail) { num8 /= 5; } if (projectile.type == 280 && ((Main.npc[i].type >= NPCID.TheDestroyer && Main.npc[i].type <= NPCID.TheDestroyerTail) || Main.npc[i].type == NPCID.Probe)) { num8 = (int)(num8 * 0.75); } } if (Main.netMode != NetmodeID.Server && Main.npc[i].type == NPCID.CultistBoss && projectile.type >= 0 && ProjectileID.Sets.Homing[projectile.type]) { num8 = (int)(num8 * 0.75f); } if (projectile.type == 323 && (Main.npc[i].type == NPCID.VampireBat || Main.npc[i].type == NPCID.Vampire)) { num8 *= 10; } if (projectile.type == 294) { projectile.damage = (int)(projectile.damage * 0.8); } if (projectile.type == 261) { float num21 = (float)Math.Sqrt(projectile.velocity.X * projectile.velocity.X + projectile.velocity.Y * projectile.velocity.Y); if (num21 < 1f) { num21 = 1f; } num8 = (int)(num8 * num21 / 8f); } float num22 = projectile.knockBack; int hitDirection = projectile.direction; ProjectileLoader.ModifyHitNPC(projectile, Main.npc[i], ref num8, ref num22, ref flag9, ref hitDirection); NPCLoader.ModifyHitByProjectile(Main.npc[i], projectile, ref num8, ref num22, ref flag9, ref hitDirection); //PlayerHooks.ModifyHitNPCWithProj(projectile, Main.npc[i], ref num8, ref num22, ref flag9, ref hitDirection); AddBuffToTheEnemy(projectile, Main.npc[i]); projectile.StatusNPC(i); if (projectile.type == 317) { projectile.ai[1] = -1f; projectile.netUpdate = true; } int num23; if (flag8) { num23 = (int)Main.npc[i].StrikeNPC(num8, num22, hitDirection, flag9, false, false); } else { num23 = (int)Main.npc[i].StrikeNPCNoInteraction(num8, num22, hitDirection, flag9, false, false); } if (Main.netMode != NetmodeID.SinglePlayer) { if (flag9) { NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, i, num8, num22, projectile.direction, 1, 0, 0); } else { NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, i, num8, num22, projectile.direction, 0, 0, 0); } } if (projectile.type >= 390 && projectile.type <= 392) { projectile.localAI[1] = 20f; } if (projectile.usesIDStaticNPCImmunity) { Main.npc[i].immune[255] = 0; Projectile.perIDStaticNPCImmunity[projectile.type][i] = Main.GameUpdateCount + (uint)projectile.idStaticNPCHitCooldown; } else if (projectile.type == 434) { projectile.numUpdates = 0; } else if (projectile.type == 632) { Main.npc[i].immune[255] = 5; } else if (projectile.type == 514) { Main.npc[i].immune[255] = 1; } else if (projectile.type == 595) { Main.npc[i].immune[255] = 5; } else if (projectile.type >= 625 && projectile.type <= 628) { Main.npc[i].immune[255] = 6; } else if (projectile.type == 286) { Main.npc[i].immune[255] = 5; } else if (projectile.type == 514) { Main.npc[i].immune[255] = 3; } else if (projectile.type == 443) { Main.npc[i].immune[255] = 8; } else if (projectile.type >= 424 && projectile.type <= 426) { Main.npc[i].immune[255] = 5; } else if (projectile.type == 634 || projectile.type == 635) { Main.npc[i].immune[255] = 5; } else if (projectile.type == 659) { Main.npc[i].immune[255] = 5; } else if (projectile.type == 246) { Main.npc[i].immune[255] = 7; } else if (projectile.type == 249) { Main.npc[i].immune[255] = 7; } else if (projectile.type == 190) { Main.npc[i].immune[255] = 8; } else if (projectile.type == 409) { Main.npc[i].immune[255] = 6; } else if (projectile.type == 407) { Main.npc[i].immune[255] = 20; } else if (projectile.type == 311) { Main.npc[i].immune[255] = 7; } else if (projectile.type == 582) { Main.npc[i].immune[255] = 7; if (projectile.ai[0] != 1f) { projectile.ai[0] = 1f; projectile.netUpdate = true; } } else { if (projectile.type == 661) { projectile.localNPCImmunity[i] = 8; Main.npc[i].immune[255] = 0; } else if (projectile.usesLocalNPCImmunity && projectile.localNPCHitCooldown != -2) { Main.npc[i].immune[255] = 0; projectile.localNPCImmunity[i] = projectile.localNPCHitCooldown; } else //if (projectile.penetrate != 1) //反真伤 { Main.npc[i].immune[255] = 10; } } if (projectile.type == 710) { BetsySharpnel(projectile, i); } ProjectileLoader.OnHitNPC(projectile, Main.npc[i], num23, num22, flag9); NPCLoader.OnHitByProjectile(Main.npc[i], projectile, num23, num22, flag9); //PlayerHooks.OnHitNPCWithProj(projectile, Main.npc[i], num23, num22, flag9); if (projectile.penetrate > 0) { projectile.penetrate--; //防止没了 if (projectile.penetrate == 0) { break; } } if (projectile.aiStyle == 7) { projectile.ai[0] = 1f; projectile.damage = 0; projectile.netUpdate = true; } else if (projectile.aiStyle == 13) { projectile.ai[0] = 1f; projectile.netUpdate = true; } else if (projectile.aiStyle == 69) { projectile.ai[0] = 1f; projectile.netUpdate = true; } else if (projectile.type == 638 || projectile.type == 639 || projectile.type == 640) { projectile.localNPCImmunity[i] = -1; Main.npc[i].immune[255] = 0; projectile.damage = (int)(projectile.damage * 0.96); } else if (projectile.type == 617) { projectile.localNPCImmunity[i] = 8; Main.npc[i].immune[255] = 0; } else if (projectile.type == 656) { projectile.localNPCImmunity[i] = 8; Main.npc[i].immune[255] = 0; projectile.localAI[0] += 1f; } else if (projectile.type == 618) { projectile.localNPCImmunity[i] = 20; Main.npc[i].immune[255] = 0; } else if (projectile.type == 642) { projectile.localNPCImmunity[i] = 10; Main.npc[i].immune[255] = 0; } else if (projectile.type == 611 || projectile.type == 612) { projectile.localNPCImmunity[i] = 6; Main.npc[i].immune[255] = 4; } else if (projectile.type == 645) { projectile.localNPCImmunity[i] = -1; Main.npc[i].immune[255] = 0; if (projectile.ai[1] != -1f) { projectile.ai[0] = 0f; projectile.ai[1] = -1f; projectile.netUpdate = true; } } projectile.numHits++; if (projectile.type == 697) { if (projectile.ai[0] >= 42f) { projectile.localAI[1] = 1f; } } else if (projectile.type == 699) { SummonMonkGhast(projectile); } else if (projectile.type == 706) { projectile.damage = (int)(projectile.damage * 0.95f); } } } } } } } } } }
private void damageNPC(NPC npc) { if (Main.netMode != 1 && projectile.damage > 0 && (!((npc.immortal || npc.dontTakeDamage) && npc.type != NPCID.TargetDummy))) { FishPlayer owner = Main.player[projectile.owner].GetModPlayer <FishPlayer>(mod); int dmg = (int)Math.Round(projectile.damage * owner.bobberDamage); dmg = Main.DamageVar(dmg); if (dmg < 1) { dmg = 1; } int num18 = Item.NPCtoBanner(npc.BannerID()); if (num18 >= 0) { Main.player[projectile.owner].lastCreatureHit = num18; if (Main.netMode != 2 && Main.player[projectile.owner].NPCBannerBuff[num18]) { if (Main.expertMode) { dmg *= 2; } else { dmg = (int)((double)dmg * 1.5); } } } float knockback = projectile.knockBack; bool crit = Main.rand.Next(100) < owner.bobberCrit + Main.player[projectile.owner].inventory[Main.player[projectile.owner].selectedItem].crit; int dir = 0; ProjectileLoader.ModifyHitNPC(projectile, npc, ref dmg, ref knockback, ref crit, ref dir); NPCLoader.ModifyHitByProjectile(npc, projectile, ref dmg, ref knockback, ref crit, ref dir); PlayerHooks.ModifyHitNPCWithProj(projectile, npc, ref dmg, ref knockback, ref crit, ref dir); /*if (crit) * { * dmg *= 2; * }*/ Main.player[projectile.owner].OnHit(npc.Center.X, npc.Center.Y, npc); if (Main.player[projectile.owner].armorPenetration > 0) { dmg += npc.checkArmorPenetration(Main.player[projectile.owner].armorPenetration); } int num25 = (int)npc.StrikeNPC(dmg, knockback, dir, crit, false, false); if (Main.netMode == 2) { ModPacket pk = mod.GetPacket(); pk.Write((byte)3); pk.Write(num25); pk.Send(projectile.owner, -1); } else { if (Main.player[projectile.owner].accDreamCatcher) { Main.player[projectile.owner].addDPS(num25); } } if (Main.netMode != 0) { NetMessage.SendData(28, -1, -1, null, npc.whoAmI, (float)dmg, knockback, (float)dir, crit? 1:0, 0, 0); } ProjectileLoader.OnHitNPC(projectile, npc, num25, knockback, crit); NPCLoader.OnHitByProjectile(npc, projectile, num25, knockback, crit); PlayerHooks.OnHitNPCWithProj(projectile, npc, num25, knockback, crit); } }
public override bool?CanBeHitByProjectile(Projectile projectile) { Player player = Main.player[projectile.owner]; if ((projectile.owner == (int)npc.target) || (player.heldProj != projectile.whoAmI) || !(ProjectileLoader.CanHitPvp(projectile, Main.player[npc.target]) && PlayerHooks.CanHitPvpWithProj(projectile, Main.player[npc.target]))) { return(false); } return(base.CanBeHitByProjectile(projectile)); }
public ShieldFactory() { shieldLoader = ShieldLoader.GetInstance(); projectileLoader = ProjectileLoader.GetInstance(); }