public override void AI() { if (RepairMode) { RepairTimer--; npc.dontTakeDamage = true; } if (RepairTimer <= 0) { RepairMode = false; npc.dontTakeDamage = false; } if (Body != null && Body.Reseting) { if (Main.netMode != 1) { npc.life = 0; npc.checkDead(); npc.netUpdate = true; killedbyplayer = false; Body.Reseting = false; } return; } Vector2 vectorCenter = npc.Center; if (Body == null) { NPC npcBody = Main.npc[(int)npc.ai[0]]; if (npcBody.type == mod.NPCType("Infinity")) { Body = (Infinity)npcBody.modNPC; } handType = (int)npc.ai[1]; npc.localAI[3] = 30 * handType; //so they start at different rotation points Vector2 point = GetVariance(false); customAI[1] = point.X; customAI[2] = point.Y; npc.netUpdate = true; } if (Body.npc.active && npc.timeLeft < 10) { npc.timeLeft = 10; } if (!Body.npc.active) { if (Main.netMode != 1) //force a kill to prevent 'ghost hands' { npc.life = 0; npc.checkDead(); npc.netUpdate = true; killedbyplayer = false; } return; } if (!Body.npc.active) { if (npc.timeLeft > 10) { npc.timeLeft = 10; } killedbyplayer = false; return; } npc.TargetClosest(); Player targetPlayer = Main.player[npc.target]; if (targetPlayer == null || !targetPlayer.active || targetPlayer.dead) { targetPlayer = null; //deliberately set to null } if (Main.netMode != 1) { customAI[0]++; int aiTimerFire = (npc.whoAmI % 3 == 0 ? 250 : npc.whoAmI % 2 == 0 ? 250 : 200); //aiTimerFire is different per head by using whoAmI (which is usually different) if (leftHand) { aiTimerFire += 60; } if (customAI[0] >= 150 && customAI[3] == 0) //pick random spot to move head to { npc.damage = damageIdle; Vector2 movementVector = GetVariance(); ChargeAttack = false; customAI[0] = 0; customAI[1] = movementVector.X; customAI[2] = movementVector.Y; npc.netUpdate = true; customAI[3] = (Main.rand.Next(3) == 0 ? 1 : 0); //wether or not to charge } else if (targetPlayer != null && customAI[0] >= aiTimerFire) //get ready to charge player { Charging = true; chargeTimer += 1; if (chargeTimer >= chargeTime) //actually charge player { ChargeAttack = true; Vector2 diff = targetPlayer.Center - npc.Center; //diff = (Vector2.Normalize(diff) * 120); if (Vector2.Distance(npc.Center + diff, npc.Center) > 2000f) //point is too far away from the body { diff = GetVariance(false); } else { npc.damage = damageCharging; } customAI[0] = 0f; customAI[1] = diff.X; customAI[2] = diff.Y; chargeTimer = 0; } } } //random rotation code if (npc.frame.Y == 0 && !ChargeAttack && !Charging) { npc.localAI[3] += Main.rand.Next(3); if (npc.localAI[3] > 150) { npc.rotation += MathHelper.Lerp(0.3f, 0.005f, npc.rotation / ((float)Math.PI * 2)); if (npc.rotation >= ((float)Math.PI * 2)) { npc.localAI[3] = 0; npc.rotation = 0f; } } else { npc.rotation = 0f; } } else { npc.localAI[3] = 0; if (targetPlayer != null && !ChargeAttack) { npc.velocity = (targetPlayer.Center - npc.Center); npc.velocity = Vector2.Normalize(npc.velocity) * 0.005f; } npc.rotation = BaseUtility.RotationTo(npc.Center, npc.Center + npc.velocity); } Vector2 nextTarget = Body.npc.Center + new Vector2(customAI[1], customAI[2]); if (Vector2.Distance(nextTarget, npc.Center) < 60f) { if (ChargeAttack) { npc.velocity *= 0.5f; //slow WAY the f**k down if (Main.netMode != 1) { ChargeAttack = false; Vector2 point = GetVariance(false); customAI[1] = point.X; customAI[2] = point.Y; npc.netUpdate = true; } } npc.velocity *= 0.9f; if (Math.Abs(npc.velocity.X) < 0.05f) { npc.velocity.X = 0f; } if (Math.Abs(npc.velocity.Y) < 0.05f) { npc.velocity.Y = 0f; } } else { npc.velocity = Vector2.Normalize(nextTarget - npc.Center); npc.velocity *= (ChargeAttack ? 18f : 8f); } npc.position += (Body.npc.oldPos[0] - Body.npc.position); npc.spriteDirection = -1; }
public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { Texture2D SFrame1 = Main.npcTexture[npc.type]; Texture2D SFrame2 = mod.GetTexture("NPCs/Bosses/Infinity/IZSpawn2"); Texture2D SFrame3 = mod.GetTexture("NPCs/Bosses/Infinity/IZSpawn3"); Texture2D SFrame4 = mod.GetTexture("NPCs/Bosses/Infinity/IZSpawn4"); Texture2D SFrame5 = mod.GetTexture("NPCs/Bosses/Infinity/IZSpawn5"); Texture2D SFrame6 = mod.GetTexture("NPCs/Bosses/Infinity/IZSpawn6"); npc.frame = BaseDrawing.GetFrame(Frame, 171, 210, 0, 0); Rectangle darkFrame = BaseDrawing.GetFrame(0, 171, 210, 0, 0); Texture2D drawTexture = (spawnState == 0 ? SFrame1 : spawnState == 1 ? SFrame2 : spawnState == 2 ? SFrame3 : spawnState == 3 ? SFrame4 : spawnState == 4 ? SFrame5 : SFrame6); Texture2D infinityTex = mod.GetTexture("NPCs/Bosses/Infinity/IZShadow"); npc.position.Y += 72; if (StartTimer <= 0) { BaseDrawing.DrawTexture(spriteBatch, infinityTex, 0, npc.position + new Vector2(0f, npc.gfxOffY), npc.width, npc.height, 3f, npc.rotation, npc.spriteDirection, 7, darkFrame, Color.Black); BaseDrawing.DrawTexture(spriteBatch, drawTexture, 0, npc.position + new Vector2(0f, npc.gfxOffY), npc.width, npc.height, 3f, npc.rotation, npc.spriteDirection, 7, npc.frame, Infinity.GetGlowAlpha(true)); } npc.position.Y -= 72; return(false); }