//public override void SetDefaults() public override void SafeSetDefaults() { item.damage = 30; item.ranged = true; item.width = 24; item.height = 16; item.scale = 0.8f; item.useTime = 9; item.useAnimation = 9; item.useStyle = 5; item.noMelee = true; item.knockBack = 5.5f; item.value = 20000; item.rare = 2; item.UseSound = mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/MissileSound"); item.autoReuse = false; item.shoot = mod.ProjectileType("MissileShot"); item.shootSpeed = 8f; item.crit = 3; MGlobalItem mi = item.GetGlobalItem <MGlobalItem>(); mi.statMissiles = 5; mi.maxMissiles = 5; }
public override void Kill(int timeLeft) { Player O = Main.player[projectile.owner]; MGlobalItem mi = O.inventory[O.selectedItem].GetGlobalItem <MGlobalItem>(); mi.seekerCharge = 0; }
void setTexture(MGlobalItem mi) { if (texture != "") { string alt = ""; if (MetroidMod.UseAltWeaponTextures) { alt = "_alt"; } mi.itemTexture = mod.GetTexture("Items/weapons/missileTextures" + alt + "/" + texture); } else { if (MetroidMod.UseAltWeaponTextures) { mi.itemTexture = ModContent.GetTexture(altTexture); } else { mi.itemTexture = Main.itemTexture[item.type]; } } if (mi.itemTexture != null) { item.width = mi.itemTexture.Width; item.height = mi.itemTexture.Height; } }
public override void UpdateEffects(Player player) { MPlayer mp = player.GetModPlayer <MPlayer>(); if (player.miscEquips[3].type == mod.ItemType("MorphBall")) { mBall = (MorphBall)player.miscEquips[3].modItem; } else { mBall = null; } int sb = mod.ItemType("SpiderBallAddon"); int bb = mod.ItemType("BoostBallAddon"); mp.morphBall = true; mp.MorphBallBasic(player); if (mBall != null) { if (!mBall.ballMods[0].IsAir) { MGlobalItem drillMItem = mBall.ballMods[0].GetGlobalItem <MGlobalItem>(); mp.Drill(player, drillMItem.drillPower); } if (!mBall.ballMods[1].IsAir) { MGlobalItem bombMItem = mBall.ballMods[1].GetGlobalItem <MGlobalItem>(); mp.bombDamage = (int)(player.rangedDamage * bombMItem.bombDamage); mp.Bomb(player); } if (!mBall.ballMods[2].IsAir) { MGlobalItem pbMItem = mBall.ballMods[2].GetGlobalItem <MGlobalItem>(); mp.PowerBomb(player, pbMItem.powerBombType); } if (mBall.ballMods[3].type == sb) { mp.SpiderBall(player); } else { mp.spiderball = false; } if (mBall.ballMods[4].type == bb) { mp.BoostBall(player); } else { mp.boostCharge = 0; mp.boostEffect = 0; } } }
public override bool CanUseItem(Player player) { MGlobalItem mi = item.GetGlobalItem <MGlobalItem>(); if (player.whoAmI == Main.myPlayer && item.type == Main.mouseItem.type) { return(false); } return(player.whoAmI == Main.myPlayer && mi.statMissiles > 0); }
public override bool?PrefixChance(int pre, UnifiedRandom rand) { MGlobalItem mi = item.GetGlobalItem <MGlobalItem>(); if (mi.ballSlotType >= 0 || mi.addonSlotType >= 0 || mi.missileSlotType >= 0) { return(false); } return(true); }
public void MiniGunShoot(Player player, Item item, Projectile Lead, int projType, int damage, float knockBack, string sound) { if (comboTime <= 0) { soundInstance = Main.PlaySound(SoundLoader.customSoundType, (int)player.Center.X, (int)player.Center.Y, mod.GetSoundSlot(SoundType.Custom, "Sounds/" + sound)); if (soundInstance != null) { soundInstance.Volume *= 1f - 0.25f * (scalePlus / 20f); } float spray = 1f * (scalePlus / 20f); float scaleFactor2 = 14f; for (int i = 0; i < miniGunAmt; i++) { float rot = Lead.velocity.ToRotation() + (float)Angle.ConvertToRadians(Main.rand.Next(18) * 10) - (float)Math.PI / 2f; Vector2 vector3 = Lead.Center + rot.ToRotationVector2() * 7f * spray; Vector2 vector5 = Vector2.Normalize(Lead.velocity) * scaleFactor2; vector5 = vector5.RotatedBy((Main.rand.NextDouble() * 0.12 - 0.06) * spray, default(Vector2)); if (float.IsNaN(vector5.X) || float.IsNaN(vector5.Y)) { vector5 = -Vector2.UnitY; } int proj = Projectile.NewProjectile(vector3.X, vector3.Y, vector5.X, vector5.Y, projType, damage, knockBack, player.whoAmI, 0f, 0f); Main.projectile[proj].ai[0] = Lead.whoAmI; MProjectile mProj = (MProjectile)Main.projectile[proj].modProjectile; mProj.waveDir = waveDir; } waveDir *= -1; comboTime = useTimeMax; useTimeMax = Math.Max(useTimeMax - miniRateIncr, comboUseTime); MGlobalItem mi = item.GetGlobalItem <MGlobalItem>(); if (miniCostNum == 0) { mi.statMissiles -= 1; } miniCostNum++; if (miniCostNum > miniGunCostReduct) { miniCostNum = 0; } } else { comboTime--; } scalePlus = Math.Min(scalePlus + (2f / useTimeMax), 20f); ChargeLead chLead = (ChargeLead)Lead.modProjectile; chLead.extraScale = 0.3f * (scalePlus / 20f); }
public override void SafeSetDefaults() { base.SafeSetDefaults(); item.damage = 24; item.value = 7500; item.rare = 3; item.createTile = mod.TileType("FireBombTile"); MGlobalItem mItem = item.GetGlobalItem <MGlobalItem>(); mItem.bombType = mod.ProjectileType("FireBomb"); }
public override bool PreDrawInInventory(SpriteBatch sb, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) { MGlobalItem mi = item.GetGlobalItem <MGlobalItem>(); Texture2D tex = Main.itemTexture[item.type]; this.setTexture(mi); if (mi.itemTexture != null) { tex = mi.itemTexture; } sb.Draw(tex, position, new Rectangle?(new Rectangle(0, 0, tex.Width, tex.Height)), drawColor, 0f, origin, scale, SpriteEffects.None, 0f); return(false); }
public void SetCondition() { this.condition = delegate(Item addonItem) { Mod mod = ModLoader.GetMod("MetroidMod"); if (addonItem.modItem != null && addonItem.modItem.mod == mod) { MGlobalItem mItem = addonItem.GetGlobalItem <MGlobalItem>(); return(addonItem.type <= 0 || mItem.addonSlotType == this.addonSlotType); } return(addonItem.type <= 0 || (addonItem.modItem != null && addonItem.modItem.mod == mod)); }; }
public override bool OnPickup(Player player) { for (int i = 0; i < player.inventory.Length; i++) { if (player.inventory[i].type == mod.ItemType("MissileLauncher")) { MGlobalItem mi = player.inventory[i].GetGlobalItem <MGlobalItem>(); mi.statMissiles += item.stack; } } Main.PlaySound(7, (int)player.position.X, (int)player.position.Y, 1); CombatText.NewText(new Rectangle((int)player.position.X, (int)player.position.Y, player.width, player.height), Color.White, item.stack, false, false); return(false); }
public void DrawSeekerTargets(SpriteBatch sb) { Mod mod = ModLoader.GetMod(UIParameters.MODNAME); Player P = Main.player[Main.myPlayer]; MPlayer mp = P.GetModPlayer <MPlayer>(); Item item = P.inventory[P.selectedItem]; if (item.type == mod.ItemType("MissileLauncher")) { MGlobalItem mi = item.GetGlobalItem <MGlobalItem>(); if (mi.numSeekerTargets > 0) { tRot += 0.05f; for (int i = 0; i < mi.seekerTarget.Length; i++) { if (mi.seekerTarget[i] > -1) { int frame = 0; bool flag = true; for (int j = 0; j < mi.seekerTarget.Length; j++) { if (i != j) { if (mi.seekerTarget[i] == mi.seekerTarget[j]) { flag = false; frame += 1; } } else { flag = true; } } if (flag) { NPC npc = Main.npc[mi.seekerTarget[i]]; Texture2D tTex = mod.GetTexture("Gore/Targeting_retical"); Color color = new Color(255, 255, 255, 10); int height = tTex.Height / 5; int yFrame = height * frame; sb.Draw(tTex, npc.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, yFrame, tTex.Width, height)), color, tRot, new Vector2((float)tTex.Width / 2f, (float)height / 2f), npc.scale * 1.5f, SpriteEffects.None, 0f); } } } } } }
public override TagCompound Save() { TagCompound tag = new TagCompound(); for (int i = 0; i < missileMods.Length; ++i) { tag.Add("missileItem" + i, ItemIO.Save(missileMods[i])); } MGlobalItem mi = item.GetGlobalItem <MGlobalItem>(); tag.Add("statMissiles", mi.statMissiles); tag.Add("maxMissiles", mi.maxMissiles); return(tag); }
public override void Load(TagCompound tag) { try { missileMods = new Item[MetroidMod.missileSlotAmount]; for (int i = 0; i < missileMods.Length; i++) { Item item = tag.Get <Item>("missileItem" + i); missileMods[i] = item; } MGlobalItem mi = this.item.GetGlobalItem <MGlobalItem>(); mi.statMissiles = tag.GetInt("statMissiles"); mi.maxMissiles = tag.GetInt("maxMissiles"); } catch {} }
public override bool PreDrawInWorld(SpriteBatch sb, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) { MGlobalItem mi = item.GetGlobalItem <MGlobalItem>(); Texture2D tex = Main.itemTexture[item.type]; this.setTexture(mi); if (mi.itemTexture != null) { tex = mi.itemTexture; } float num5 = (float)(item.height - tex.Height); float num6 = (float)(item.width / 2 - tex.Width / 2); sb.Draw(tex, new Vector2(item.position.X - Main.screenPosition.X + (float)(tex.Width / 2) + num6, item.position.Y - Main.screenPosition.Y + (float)(tex.Height / 2) + num5 + 2f), new Rectangle?(new Rectangle(0, 0, tex.Width, tex.Height)), alphaColor, rotation, new Vector2((float)(tex.Width / 2), (float)(tex.Height / 2)), scale, SpriteEffects.None, 0f); return(false); }
public override void SetDefaults() { item.width = 18; item.height = 18; item.maxStack = 1; item.value = 220000; item.rare = 4; item.useTurn = true; item.autoReuse = true; item.useAnimation = 15; item.useTime = 15; item.useStyle = 1; MGlobalItem mItem = item.GetGlobalItem <MGlobalItem>(); mItem.ballSlotType = 0; mItem.drillPower = 200; }
public override void SetDefaults() { item.width = 28; item.height = 28; item.maxStack = 1; item.value = 11000; item.rare = 3; item.useTurn = true; item.autoReuse = true; item.useAnimation = 15; item.useTime = 10; item.useStyle = 1; item.consumable = true; item.createTile = mod.TileType("BoostBallTile"); MGlobalItem mItem = item.GetGlobalItem <MGlobalItem>(); mItem.ballSlotType = 4; }
public override void SetDefaults() { item.width = 10; item.height = 14; item.maxStack = 1; item.value = 2500; item.rare = 4; item.useTurn = true; item.autoReuse = true; item.useAnimation = 15; item.useTime = 10; item.useStyle = 1; item.consumable = true; item.createTile = mod.TileType("PhazonBeamTile"); MGlobalItem mItem = item.GetGlobalItem <MGlobalItem>(); mItem.addonSlotType = 0; }
public override void SetDefaults() { item.width = 10; item.height = 14; item.maxStack = 1; item.value = 2500; item.rare = 4; /*item.useTurn = true; * item.autoReuse = true; * item.useAnimation = 15; * item.useTime = 10; * item.useStyle = 1; * item.consumable = true; * item.createTile = mod.TileType("SpazerComboAddonTile");*/ MGlobalItem mItem = item.GetGlobalItem <MGlobalItem>(); mItem.missileSlotType = 0; }
public override void SetDefaults() { item.width = 32; item.height = 32; item.maxStack = 1; item.value = 30000; item.rare = 4; item.useTurn = true; item.autoReuse = true; item.useAnimation = 15; item.useTime = 10; item.useStyle = 1; item.consumable = true; item.createTile = mod.TileType("PowerBombTile"); MGlobalItem mItem = item.GetGlobalItem <MGlobalItem>(); mItem.ballSlotType = 2; mItem.powerBombType = mod.ProjectileType("PowerBomb"); }
public override void SetDefaults() { item.width = 32; item.height = 32; item.maxStack = 50; item.useTurn = true; item.autoReuse = true; item.useAnimation = 15; item.rare = 4; item.value = 2500; item.useTime = 10; item.useStyle = 1; item.consumable = true; item.createTile = mod.TileType("MissileExpansionTile"); MGlobalItem mItem = item.GetGlobalItem <MGlobalItem>(); mItem.missileSlotType = 2; }
public override void SetDefaults() { item.width = 10; item.height = 14; item.maxStack = 1; item.value = 2500; item.rare = 4; item.useTurn = true; item.autoReuse = true; item.useAnimation = 15; item.useTime = 10; item.useStyle = 1; item.consumable = true; item.createTile = mod.TileType("IceBeamV2Tile"); MGlobalItem mItem = item.GetGlobalItem <MGlobalItem>(); mItem.addonSlotType = 1; mItem.addonDmg = 2.25f; mItem.addonHeat = 0.5f; mItem.addonSpeed = -0.3f; }
public override void SetDefaults() { item.width = 10; item.height = 14; item.maxStack = 1; item.value = 2500; item.rare = 4; /*item.useTurn = true; * item.autoReuse = true; * item.useAnimation = 15; * item.useTime = 10; * item.useStyle = 1; * item.consumable = true; * item.createTile = mod.TileType("FlamethrowerTile");*/ MGlobalItem mItem = item.GetGlobalItem <MGlobalItem>(); mItem.missileSlotType = 0; mItem.addonChargeDmg = 1f; mItem.addonMissileCost = 10; mItem.addonMissileDrain = 5; }
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { MGlobalItem mi = item.GetGlobalItem <MGlobalItem>(); if (isCharge) { int ch = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, mod.ProjectileType("ChargeLead"), damage, knockBack, player.whoAmI); ChargeLead cl = (ChargeLead)Main.projectile[ch].modProjectile; cl.ChargeUpSound = chargeUpSound; cl.ChargeTex = chargeTex; cl.DustType = dustType; cl.DustColor = dustColor; cl.LightColor = lightColor; cl.ShotSound = shotSound; cl.ChargeShotSound = chargeShotSound; cl.projectile.netUpdate = true; cl.missile = true; cl.comboSound = comboSound; cl.noSomersault = noSomersault; cl.aimSpeed = leadAimSpeed; chargeLead = ch; return(false); } else if (isSeeker) { int ch = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, mod.ProjectileType("SeekerMissileLead"), damage, knockBack, player.whoAmI); chargeLead = ch; return(false); } else { mi.statMissiles -= 1; Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/" + shotSound), player.position); } return(true); }
public override void UpdateInventory(Player P) { MGlobalItem mi = item.GetGlobalItem <MGlobalItem>(); MPlayer mp = P.GetModPlayer <MPlayer>(); int ic = mod.ItemType("IceMissileAddon"); int sm = mod.ItemType("SuperMissileAddon"); int icSm = mod.ItemType("IceSuperMissileAddon"); int st = mod.ItemType("StardustMissileAddon"); int ne = mod.ItemType("NebulaMissileAddon"); int se = mod.ItemType("SeekerMissileAddon"); Item slot1 = missileMods[0]; Item slot2 = missileMods[1]; Item exp = missileMods[2]; int damage = 30; useTime = 9; shot = "MissileShot"; chargeShot = ""; shotSound = "MissileSound"; chargeShotSound = "SuperMissileSound"; chargeUpSound = ""; chargeTex = ""; dustType = 0; dustColor = default(Color); lightColor = Color.White; texture = ""; comboKnockBack = item.knockBack; isSeeker = (slot1.type == se); isCharge = (!slot1.IsAir && !isSeeker); isHeldCombo = 0; chargeCost = 5; comboSound = 0; comboDrain = 5f; noSomersault = false; useFlameSounds = false; useVortexSounds = false; isShotgun = false; shotgunAmt = 5; isMiniGun = false; miniRateIncr = 2; miniGunCostReduct = 2; miniGunAmt = 1; comboUseTime = 4; comboCostUseTime = 12; comboShotAmt = 1; leadAimSpeed = 0f; mi.maxMissiles = 5 + (5 * exp.stack); if (mi.statMissiles > mi.maxMissiles) { mi.statMissiles = mi.maxMissiles; } // Default Combos if (slot2.type == sm) { shot = "SuperMissileShot"; } else if (slot2.type == ic) { shot = "IceMissileShot"; } else if (slot2.type == icSm) { shot = "IceSuperMissileShot"; } else if (slot2.type == st) { shot = "StardustMissileShot"; } else if (slot2.type == ne) { shot = "NebulaMissileShot"; } int wb = mod.ItemType("WavebusterAddon"); int icSp = mod.ItemType("IceSpreaderAddon"); int sp = mod.ItemType("SpazerComboAddon"); int ft = mod.ItemType("FlamethrowerAddon"); int pl = mod.ItemType("PlasmaMachinegunAddon"); int nv = mod.ItemType("NovaComboAddon"); int di = mod.ItemType("DiffusionMissileAddon"); // Charge Combos if (slot1.type == wb) { isHeldCombo = 1; comboSound = 1; noSomersault = true; chargeShot = "WavebusterShot"; chargeUpSound = "ChargeStartup_Wave"; chargeTex = "ChargeLead_WaveV2"; dustType = 62; lightColor = MetroidMod.waveColor2; comboKnockBack = 0f; texture = "Wavebuster_Item"; } if (slot1.type == icSp) { chargeShot = "IceSpreaderShot"; chargeShotSound = "IceSpreaderSound"; chargeUpSound = "ChargeStartup_Ice"; chargeTex = "ChargeLead_Ice"; dustType = 59; lightColor = MetroidMod.iceColor; texture = "IceSpreader_Item"; } if (slot1.type == sp) { isShotgun = true; chargeShot = shot; chargeUpSound = "ChargeStartup_Power"; chargeTex = "ChargeLead_Spazer"; dustType = 64; lightColor = MetroidMod.powColor; texture = "SpazerCombo_Item"; } if (slot1.type == ft) { isHeldCombo = 2; comboSound = 1; noSomersault = true; useFlameSounds = true; chargeShot = "FlamethrowerShot"; chargeUpSound = "ChargeStartup_PlasmaRed"; chargeTex = "ChargeLead_PlasmaRed"; dustType = 6; lightColor = MetroidMod.plaRedColor; texture = "Flamethrower_Item"; } if (slot1.type == pl) { isHeldCombo = 2; comboSound = 2; noSomersault = true; isMiniGun = true; chargeShot = "PlasmaMachinegunShot"; chargeShotSound = "PlasmaMachinegunSound"; chargeUpSound = "ChargeStartup_Power"; chargeTex = "ChargeLead_PlasmaGreen"; dustType = 61; lightColor = MetroidMod.plaGreenColor; texture = "PlasmaMachinegun_Item"; } if (slot1.type == nv) { isHeldCombo = 1; comboSound = 1; noSomersault = true; leadAimSpeed = 0.85f; chargeShot = "NovaLaserShot"; chargeUpSound = "ChargeStartup_Nova"; chargeTex = "ChargeLead_Nova"; dustType = 75; lightColor = MetroidMod.novColor; texture = "NovaLaser_Item"; } if (slot1.type == di) { chargeShot = "DiffusionMissileShot"; chargeUpSound = "ChargeStartup_Power"; chargeTex = "ChargeLead_PlasmaRed"; dustType = 6; lightColor = MetroidMod.plaRedColor; texture = "DiffusionMissile_Item"; if (slot2.type == ic || slot2.type == icSm) { chargeShot = "IceDiffusionMissileShot"; chargeUpSound = "ChargeStartup_Ice"; chargeTex = "ChargeLead_Ice"; dustType = 135; lightColor = MetroidMod.iceColor; } if (slot2.type == st) { chargeShot = "StardustDiffusionMissileShot"; chargeUpSound = "ChargeStartup_Ice"; chargeTex = "ChargeLead_Stardust"; dustType = 87; lightColor = MetroidMod.iceColor; } if (slot2.type == ne) { chargeShot = "NebulaDiffusionMissileShot"; chargeUpSound = "ChargeStartup_Wave"; chargeTex = "ChargeLead_Nebula"; dustType = 255; lightColor = MetroidMod.waveColor; } } if (isSeeker) { texture = "SeekerMissile_Item"; } int sd = mod.ItemType("StardustComboAddon"); int nb = mod.ItemType("NebulaComboAddon"); int vt = mod.ItemType("VortexComboAddon"); int sl = mod.ItemType("SolarComboAddon"); if (slot1.type == sd) { chargeShot = "StardustComboShot"; chargeShotSound = "IceSpreaderSound"; chargeUpSound = "ChargeStartup_Ice"; chargeTex = "ChargeLead_Stardust"; dustType = 87; lightColor = MetroidMod.iceColor; texture = "StardustCombo_Item"; } if (slot1.type == nb) { isHeldCombo = 1; comboSound = 1; noSomersault = true; chargeShot = "NebulaComboShot"; chargeUpSound = "ChargeStartup_Wave"; chargeTex = "ChargeLead_Nebula"; dustType = 255; lightColor = MetroidMod.waveColor; texture = "NebulaCombo_Item"; } if (slot1.type == vt) { isHeldCombo = 2; comboSound = 2; noSomersault = true; comboUseTime = 10; comboShotAmt = 3; useVortexSounds = true; chargeShot = "VortexComboShot"; chargeShotSound = "PlasmaMachinegunSound"; chargeUpSound = "ChargeStartup_Power"; chargeTex = "ChargeLead_Vortex"; dustType = 229; lightColor = MetroidMod.lumColor; texture = "VortexCombo_Item"; } if (slot1.type == sl) { isHeldCombo = 1; comboSound = 1; noSomersault = true; leadAimSpeed = 0.9f; chargeShot = "SolarLaserShot"; chargeUpSound = "ChargeStartup_PlasmaRed"; chargeTex = "ChargeLead_SolarCombo"; dustType = 6; lightColor = MetroidMod.plaRedColor; texture = "SolarCombo_Item"; } if (!slot1.IsAir) { MGlobalItem mItem = slot1.GetGlobalItem <MGlobalItem>(); chargeMult = mItem.addonChargeDmg; //chargeCost = (int)((float)mItem.addonMissileCost * mp.missileCost); //comboDrain = (float)mItem.addonMissileDrain * mp.missileCost; chargeCost = mItem.addonMissileCost; comboDrain = mItem.addonMissileDrain; } comboCostUseTime = (int)Math.Round(60.0 / (double)comboDrain); float addonDmg = 0f; float addonSpeed = 0f; if (!slot2.IsAir) { MGlobalItem mItem = slot2.GetGlobalItem <MGlobalItem>(); addonDmg = mItem.addonDmg; addonSpeed = mItem.addonSpeed; } finalDmg = (int)Math.Round((double)((float)damage * (1f + addonDmg))); float shotsPerSecond = (60f / useTime) * (1f + addonSpeed); useTime = (int)Math.Max(Math.Round(60.0 / (double)shotsPerSecond), 2); item.damage = finalDmg; item.useTime = useTime; item.useAnimation = useTime; item.shoot = mod.ProjectileType(shot); item.UseSound = null; //mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/"+shotSound); item.shootSpeed = 8f; item.reuseDelay = 0; item.mana = 0; item.knockBack = 5.5f; item.scale = 0.8f; item.crit = 3; item.value = 20000; item.rare = 2; item.Prefix(item.prefix); /*if(texture != "") * { * string alt = ""; * if(MetroidMod.UseAltWeaponTextures) * { * alt = "_alt"; * } * mi.itemTexture = mod.GetTexture("Items/weapons/missileTextures"+alt+"/"+texture); * } * else * { * if(MetroidMod.UseAltWeaponTextures) * { * mi.itemTexture = ModContent.GetTexture(altTexture); * } * else * { * mi.itemTexture = Main.itemTexture[item.type]; * } * } * * if(mi.itemTexture != null) * { * item.width = mi.itemTexture.Width; * item.height = mi.itemTexture.Height; * }*/ }
public override void HoldItem(Player player) { if (player.whoAmI == Main.myPlayer) { MPlayer mp = player.GetModPlayer <MPlayer>(); MGlobalItem mi = item.GetGlobalItem <MGlobalItem>(); int chCost = (int)((float)chargeCost * mp.missileCost); comboCostUseTime = (int)Math.Round(60.0 / (double)(comboDrain * mp.missileCost)); isCharge &= (mi.statMissiles >= chCost || (isHeldCombo > 0 && initialShot)); item.autoReuse = (isCharge || isSeeker); if (isCharge) { if (!mp.ballstate && !mp.shineActive && !player.dead && !player.noItems) { Vector2 oPos = player.RotatedRelativePoint(player.MountedCenter, true); float MY = Main.mouseY + Main.screenPosition.Y; float MX = Main.mouseX + Main.screenPosition.X; if (player.gravDir == -1f) { MY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY; } float targetrotation = (float)Math.Atan2((MY - oPos.Y), (MX - oPos.X)); Vector2 velocity = targetrotation.ToRotationVector2() * item.shootSpeed; float dmgMult = chargeMult; int damage = player.GetWeaponDamage(item); if (player.controlUseItem && chargeLead != -1 && Main.projectile[chargeLead].active && Main.projectile[chargeLead].owner == player.whoAmI && Main.projectile[chargeLead].type == mod.ProjectileType("ChargeLead")) { if (mp.statCharge < MPlayer.maxCharge) { mp.statCharge = Math.Min(mp.statCharge + 1, MPlayer.maxCharge); } if (isHeldCombo > 0) { if (mi.statMissiles > 0) { if (mp.statCharge >= MPlayer.maxCharge) { if (isMiniGun) { this.MiniGunShoot(player, item, Main.projectile[chargeLead], mod.ProjectileType(chargeShot), (int)((float)damage * dmgMult), comboKnockBack, chargeShotSound); } else { if (comboTime <= 0) { for (int i = 0; i < comboShotAmt; i++) { int proj = Projectile.NewProjectile(oPos.X, oPos.Y, velocity.X, velocity.Y, mod.ProjectileType(chargeShot), (int)((float)damage * dmgMult), comboKnockBack, player.whoAmI); Main.projectile[proj].ai[0] = chargeLead; } comboTime = comboUseTime; } if (isHeldCombo == 2 && comboTime > 0) { comboTime--; } } if (!initialShot) { if (useFlameSounds || useVortexSounds) { int type = mod.ProjectileType("FlamethrowerLead"); if (useVortexSounds) { type = mod.ProjectileType("VortexComboLead"); } int proj = Projectile.NewProjectile(oPos.X, oPos.Y, velocity.X, velocity.Y, type, 0, 0, player.whoAmI); Main.projectile[proj].ai[0] = chargeLead; } mi.statMissiles = Math.Max(mi.statMissiles - chCost, 0); initialShot = true; } if (comboCostUseTime > 0) { //if(comboCostTime <= 0) if (comboCostTime > comboCostUseTime) { mi.statMissiles = Math.Max(mi.statMissiles - 1, 0); //comboCostTime = comboCostUseTime; comboCostTime = 0; } else { //comboCostTime--; comboCostTime++; } } } } else { Main.projectile[chargeLead].Kill(); } } } else { if (isHeldCombo <= 0 || mp.statCharge < MPlayer.maxCharge) { if (mp.statCharge >= MPlayer.maxCharge && mi.statMissiles >= chCost) { if (isShotgun) { for (int i = 0; i < shotgunAmt; i++) { int k = i - (shotgunAmt / 2); Vector2 shotGunVel = Vector2.Normalize(velocity) * (item.shootSpeed + 4f); double rot = Angle.ConvertToRadians(4.0 * k); shotGunVel = shotGunVel.RotatedBy(rot, default(Vector2)); if (float.IsNaN(shotGunVel.X) || float.IsNaN(shotGunVel.Y)) { shotGunVel = -Vector2.UnitY; } int chargeProj = Projectile.NewProjectile(oPos.X, oPos.Y, shotGunVel.X, shotGunVel.Y, mod.ProjectileType(chargeShot), (int)((float)damage * dmgMult), item.knockBack, player.whoAmI); } } else { int chargeProj = Projectile.NewProjectile(oPos.X, oPos.Y, velocity.X, velocity.Y, mod.ProjectileType(chargeShot), (int)((float)damage * dmgMult), item.knockBack, player.whoAmI); } mi.statMissiles -= chCost; } else if (mp.statCharge > 0) { int shotProj = Projectile.NewProjectile(oPos.X, oPos.Y, velocity.X, velocity.Y, mod.ProjectileType(shot), damage, item.knockBack, player.whoAmI); mi.statMissiles -= 1; } } if (chargeLead == -1 || !Main.projectile[chargeLead].active || Main.projectile[chargeLead].owner != player.whoAmI || Main.projectile[chargeLead].type != mod.ProjectileType("ChargeLead")) { mp.statCharge = 0; } comboTime = 0; comboCostTime = 0; scalePlus = 0f; initialShot = false; } } else if (!mp.ballstate) { mp.statCharge = 0; comboTime = 0; comboCostTime = 0; scalePlus = 0f; initialShot = false; } } else { mp.statCharge = 0; comboTime = 0; comboCostTime = 0; scalePlus = 0f; initialShot = false; } if (targetingDelay > 0) { targetingDelay--; } if (isSeeker && !mp.ballstate && !mp.shineActive && !player.dead && !player.noItems) { Vector2 oPos = player.RotatedRelativePoint(player.MountedCenter, true); float MY = Main.mouseY + Main.screenPosition.Y; float MX = Main.mouseX + Main.screenPosition.X; if (player.gravDir == -1f) { MY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY; } Rectangle mouse = new Rectangle((int)MX - 1, (int)MY - 1, 2, 2); float targetrotation = (float)Math.Atan2((MY - oPos.Y), (MX - oPos.X)); Vector2 velocity = targetrotation.ToRotationVector2() * item.shootSpeed; int damage = player.GetWeaponDamage(item); if (player.controlUseItem && chargeLead != -1 && Main.projectile[chargeLead].active && Main.projectile[chargeLead].owner == player.whoAmI && Main.projectile[chargeLead].type == mod.ProjectileType("SeekerMissileLead")) { if (mi.seekerCharge < MGlobalItem.seekerMaxCharge) { mi.seekerCharge = Math.Min(mi.seekerCharge + 1, MGlobalItem.seekerMaxCharge); } else { for (int i = 0; i < Main.maxNPCs; i++) { NPC npc = Main.npc[i]; if (npc.active && npc.chaseable && !npc.dontTakeDamage && !npc.friendly) // && !npc.immortal) { Rectangle npcRect = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); bool flag = false; for (int j = 0; j < mi.seekerTarget.Length; j++) { if (mi.seekerTarget[j] == npc.whoAmI) { flag = true; } } if (mouse.Intersects(npcRect) && mi.seekerTarget[targetNum] <= -1 && (targetingDelay <= 0 || !flag /*prevTarget != npc.whoAmI*/) && mi.statMissiles > mi.numSeekerTargets) { mi.seekerTarget[targetNum] = npc.whoAmI; targetNum++; if (targetNum > 4) { targetNum = 0; } targetingDelay = 40; Main.PlaySound(SoundLoader.customSoundType, (int)oPos.X, (int)oPos.Y, mod.GetSoundSlot(SoundType.Custom, "Sounds/SeekerLockSound")); } } } int num = 10; while (mi.seekerTarget[targetNum] > -1 && num > 0) { targetNum++; if (targetNum > 4) { targetNum = 0; } num--; } mi.numSeekerTargets = 0; for (int i = 0; i < mi.seekerTarget.Length; i++) { if (mi.seekerTarget[i] > -1) { mi.numSeekerTargets++; if (!Main.npc[mi.seekerTarget[i]].active) { mi.seekerTarget[i] = -1; } } } } } else { if (mi.seekerCharge >= MGlobalItem.seekerMaxCharge && mi.numSeekerTargets > 0) { for (int i = 0; i < mi.seekerTarget.Length; i++) { if (mi.seekerTarget[i] > -1) { int shotProj = Projectile.NewProjectile(oPos.X, oPos.Y, velocity.X, velocity.Y, mod.ProjectileType(shot), damage, item.knockBack, player.whoAmI); MProjectile mProj = (MProjectile)Main.projectile[shotProj].modProjectile; mProj.seekTarget = mi.seekerTarget[i]; mProj.seeking = true; mProj.projectile.netUpdate2 = true; mi.statMissiles = Math.Max(mi.statMissiles - 1, 0); } } Main.PlaySound(SoundLoader.customSoundType, (int)oPos.X, (int)oPos.Y, mod.GetSoundSlot(SoundType.Custom, "Sounds/SeekerMissileSound")); } else if (mi.seekerCharge > 0) { int shotProj = Projectile.NewProjectile(oPos.X, oPos.Y, velocity.X, velocity.Y, mod.ProjectileType(shot), damage, item.knockBack, player.whoAmI); Main.PlaySound(SoundLoader.customSoundType, (int)oPos.X, (int)oPos.Y, mod.GetSoundSlot(SoundType.Custom, "Sounds/" + shotSound)); mi.statMissiles -= 1; } if (chargeLead == -1 || !Main.projectile[chargeLead].active || Main.projectile[chargeLead].owner != player.whoAmI || Main.projectile[chargeLead].type != mod.ProjectileType("SeekerMissileLead")) { mi.seekerCharge = 0; } mi.numSeekerTargets = 0; for (int k = 0; k < mi.seekerTarget.Length; k++) { mi.seekerTarget[k] = -1; } targetNum = 0; targetingDelay = 0; } } else { mi.seekerCharge = 0; mi.numSeekerTargets = 0; for (int k = 0; k < mi.seekerTarget.Length; k++) { mi.seekerTarget[k] = -1; } targetNum = 0; targetingDelay = 0; } } }
public MissileUI() { Mod mod = ModLoader.GetMod(UIParameters.MODNAME); Player P = Main.player[Main.myPlayer]; missileButton = new UIButton(new Vector2(250, 292), new Vector2(44, 44), delegate() { MissileUIOpen = !MissileUIOpen; }, null, mod.GetTexture("Textures/Buttons/MissileUIButton"), mod.GetTexture("Textures/Buttons/MissileUIButton_Hover"), mod.GetTexture("Textures/Buttons/MissileUIButton_Click")); UIPanel panel = new UIPanel(new Vector2(250, 350), new Vector2(220, 210), null); for (int i = 0; i < missileSlot.Length; i++) { int k = i; missileSlot[i] = new UIItemSlot(new Vector2(10, 10 + i * 58), panel, delegate(Item item) { if (item.modItem != null && item.modItem.mod == mod) { MGlobalItem mItem = item.GetGlobalItem <MGlobalItem>(); return(item.type <= 0 || mItem.missileSlotType == k); } return(item.type <= 0 || (item.modItem != null && item.modItem.mod == mod)); }); } for (int i = 0; i < label.Length; i++) { string slotText = "Charge"; if (i == 1) { slotText = "Primary"; } label[i] = new UILabel(new Vector2(68, 24 + i * 58), Main.fontMouseText, new Vector2(200, 52), Color.White, Color.Black, delegate() { return(slotText); }, panel); } expansionSlot = new UIItemSlot(new Vector2(10, 150), panel, delegate(Item item) { return(item.type <= 0 || item.type == mod.ItemType("MissileExpansion")); }); expansionLabel = new UILabel(new Vector2(68, 164), Main.fontMouseText, new Vector2(200, 52), Color.White, Color.Black, delegate() { return("Missile Expansion"); }, panel); for (int i = 0; i < missileSlot.Length; i++) { panel.children.Add(missileSlot[i]); } for (int i = 0; i < label.Length; i++) { panel.children.Add(label[i]); } panel.children.Add(expansionSlot); panel.children.Add(expansionLabel); missileUIObj = panel; }
public BeamUI() { Mod mod = ModLoader.GetMod(UIParameters.MODNAME); beamButton = new UIButton(new Vector2(250, 292), new Vector2(44, 44), delegate() { BeamUIOpen = !BeamUIOpen; }, null, mod.GetTexture("Textures/Buttons/BeamUIButton"), mod.GetTexture("Textures/Buttons/BeamUIButton_Hover"), mod.GetTexture("Textures/Buttons/BeamUIButton_Click")); UIPanel panel = new UIPanel(new Vector2(250, 350), new Vector2(174, 304), null); for (int i = 0; i < beamSlot.Length; i++) { int k = i; beamSlot[i] = new UIItemSlot(new Vector2(10, 10 + i * 58), panel, delegate(Item item) { if (item.modItem != null && item.modItem.mod == mod) { MGlobalItem mItem = item.GetGlobalItem <MGlobalItem>(); return(item.type <= 0 || mItem.addonSlotType == k); } return(item.type <= 0 || (item.modItem != null && item.modItem.mod == mod)); }); beamSlot[i].item = new Item(); beamSlot[i].item.TurnToAir(); } for (int i = 0; i < label.Length; i++) { string slotText = "Charge"; if (i == 1) { slotText = "Secondary"; } if (i == 2) { slotText = "Utility"; } if (i == 3) { slotText = "Primary A"; } if (i == 4) { slotText = "Primary B"; } Color color = Color.White; label[i] = new UILabel(new Vector2(68, 24 + i * 58), Main.fontMouseText, new Vector2(250, 52), color, Color.Black, delegate() { return(slotText); }, panel); } comboError = new UILabel(new Vector2(184, 68), Main.fontMouseText, new Vector2(1500, 300), Color.Red, Color.Black, delegate() { return(""); }, panel); psuedoScrewButton = new UIButton(new Vector2(194, 10), new Vector2(44, 44), delegate() { psEnabled = !psEnabled; }, panel, mod.GetTexture("Textures/Buttons/PsuedoScrewUIButton"), mod.GetTexture("Textures/Buttons/PsuedoScrewUIButton_Hover"), mod.GetTexture("Textures/Buttons/PsuedoScrewUIButton_Click")); for (int i = 0; i < beamSlot.Length; i++) { panel.children.Add(beamSlot[i]); } for (int i = 0; i < label.Length; i++) { panel.children.Add(label[i]); } panel.children.Add(comboError); panel.children.Add(psuedoScrewButton); beamUIObj = panel; }
public void DrawChargeBar(SpriteBatch sb) { Mod mod = ModLoader.GetMod(UIParameters.MODNAME); Player P = Main.player[Main.myPlayer]; MPlayer mp = P.GetModPlayer <MPlayer>(); Item item = P.inventory[P.selectedItem]; if (P.whoAmI == Main.myPlayer && P.active && !P.dead && !P.ghost) { Texture2D texBar = mod.GetTexture("Gore/ChargeBar"), texBarBorder = mod.GetTexture("Gore/ChargeBarBorder"), texBarBorder2 = mod.GetTexture("Gore/ChargeBarBorder2"); if (item.type == mod.ItemType("PowerBeam") || item.type == mod.ItemType("MissileLauncher") || mp.ballstate) { int ch = (int)mp.statCharge, chMax = (int)MPlayer.maxCharge; int pb = (int)mp.statPBCh, pbMax = (int)MPlayer.maxPBCh; float x = 22, y = 78 + z; int times = (int)Math.Ceiling(texBar.Height / 2f); float chpercent = chMax == 0 ? 0f : 1f * ch / chMax; float pbpercent = pbMax == 0 ? 0f : 1f * pb / pbMax; int w = (int)(Math.Floor(texBar.Width / 2f * chpercent) * 2); int w2 = (int)(Math.Floor(texBar.Width / 2f * pbpercent) * 2); Color c = chpercent < 1f ? new Color(chR, chG, chB) : Color.Gold; Color p = pbpercent < 1f ? Color.Crimson : Color.Gray; chStyle = chpercent <= 0f ? 0 : (chpercent <= .5f ? 1 : (chpercent <= .75f ? 2 : (chpercent <= .99f ? 3 : 0))); float offsetX = 2, offsetY = 2; sb.Draw(texBarBorder2, new Vector2(x, y), new Rectangle(0, 0, texBarBorder2.Width, texBarBorder2.Height), Color.White); if (pb > 0) { for (int i = 0; i < times; i++) { int ww = w2 - (i * 2); if (ww > 0) { sb.Draw(texBar, new Vector2(x + offsetX, y + offsetY + i * 2), new Rectangle(0, i * 2, ww, 2), p); } } } if (ch > 9) { for (int i = 0; i < times; i++) { int ww = w - (i * 2); if (ww > 0) { sb.Draw(texBar, new Vector2(x + offsetX, y + offsetY + i * 2), new Rectangle(0, i * 2, ww, 2), c); } } } if (mp.hyperColors > 0) { sb.Draw(texBar, new Vector2(x + offsetX, y + offsetY), new Rectangle(0, 0, texBar.Width, texBar.Height), new Color(mp.r, mp.g, mp.b)); } sb.Draw(texBarBorder, new Vector2(x, y), new Rectangle(0, 0, texBarBorder.Width, texBarBorder.Height), Color.White); if (item.type == mod.ItemType("MissileLauncher")) { MGlobalItem mi = item.GetGlobalItem <MGlobalItem>(); int num = Math.Min(mi.statMissiles, mi.maxMissiles); string text = num.ToString("000"); Vector2 vect = Main.fontMouseText.MeasureString(text); Color color = new Color((int)((byte)((float)Main.mouseTextColor)), (int)((byte)((float)Main.mouseTextColor)), (int)((byte)((float)Main.mouseTextColor)), (int)((byte)((float)Main.mouseTextColor))); sb.DrawString(Main.fontMouseText, text, new Vector2(x + 38 - (vect.X / 2), y), color, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } } if (item.type == mod.ItemType("PowerBeam") || mp.shineDirection != 0 || mp.shineActive) { Texture2D overheatBar = mod.GetTexture("Gore/OverheatBar"), overheatBorder = mod.GetTexture("Gore/OverheatBorder"); int ovh = (int)Math.Min(mp.statOverheat, mp.maxOverheat), ovhMax = (int)mp.maxOverheat; float x2 = 22, y2 = 120 + z; int times2 = (int)Math.Ceiling(overheatBar.Height / 2f); float ovhpercent = ovhMax == 0 ? 0f : 1f * ovh / ovhMax; int wo = (int)(Math.Floor(overheatBar.Width * ovhpercent)); Color colorheat = new Color((int)((byte)((float)Main.mouseTextColor)), (int)((byte)((float)Main.mouseTextColor * 0.25f)), (int)((byte)((float)Main.mouseTextColor * 0.1f)), (int)((byte)((float)Main.mouseTextColor))); Color o = ovhpercent < 1f ? Color.Gold : colorheat; sb.Draw(overheatBorder, new Vector2(x2, y2), new Rectangle(0, 0, overheatBorder.Width, overheatBorder.Height), Color.White); if (ovh > 0) { for (int i = 0; i < times2; i++) { int ww = wo - (i * 2); if (ww > 0 && ovh <= ovhMax) { sb.Draw(overheatBar, new Vector2(x2 + 6, y2 + 2 + i * 2), new Rectangle(0, i * 2, ww, 2), o); } } } string text = (int)Math.Round((double)mp.statOverheat) + "/" + ovhMax; Vector2 vect = Main.fontMouseText.MeasureString(text); Color color = new Color((int)((byte)((float)Main.mouseTextColor)), (int)((byte)((float)Main.mouseTextColor)), (int)((byte)((float)Main.mouseTextColor)), (int)((byte)((float)Main.mouseTextColor))); sb.DrawString(Main.fontMouseText, text, new Vector2(x2 + 2, y2 + overheatBorder.Height + 2), color, 0f, default(Vector2), 0.75f, SpriteEffects.None, 0f); } int num4 = (int)((float)30 % 255); if (chStyle == 1) { chG += num4; if (chG >= 255) { chG = 255; chStyle++; } chR -= num4; if (chR <= 0) { chR = 0; } } else if (chStyle == 2) { chB += num4; if (chB >= 255) { chB = 255; chStyle++; } chG -= num4; if (chG <= 196) { chG = 196; } } else if (chStyle == 3) { chR += num4; if (chR >= 255) { chR = 255; chStyle = 0; } chB -= num4; if (chB <= 0) { chB = 0; } if (chB <= 196) { chG -= num4; if (chG <= 0) { chG = 0; } } } else if (chStyle == 0 || mp.statCharge <= 0) { chR = 255; chG = 0; chB = 0; } } }
public BallUI() { Mod mod = ModLoader.GetMod(UIParameters.MODNAME); Player P = Main.player[Main.myPlayer]; ballButton = new UIButton(new Vector2(200, 292), new Vector2(44, 44), delegate() { BallUIOpen = !BallUIOpen; }, null, mod.GetTexture("Textures/Buttons/MorphBallUIButton"), mod.GetTexture("Textures/Buttons/MorphBallUIButton_Hover"), mod.GetTexture("Textures/Buttons/MorphBallUIButton_Click")); UIPanel panel = new UIPanel(new Vector2(200, 350), new Vector2(150, 310), null); for (int i = 0; i < ballSlot.Length; i++) { int k = i; ballSlot[i] = new UIItemSlot(new Vector2(10, 10 + i * 58), panel, delegate(Item item) { if (item.modItem != null && item.modItem.mod == mod) { MGlobalItem mItem = item.GetGlobalItem <MGlobalItem>(); return(item.type <= 0 || mItem.ballSlotType == k); } return(item.type <= 0 || (item.modItem != null && item.modItem.mod == mod)); }); } for (int i = 0; i < label.Length; i++) { string slotText = "Drill"; if (i == 1) { slotText = "Weapon"; } if (i == 2) { slotText = "Special"; } if (i == 3) { slotText = "Utility"; } if (i == 4) { slotText = "Boost"; } Color color = Color.White; label[i] = new UILabel(new Vector2(68, 24 + i * 58), Main.fontMouseText, new Vector2(200, 52), color, Color.Black, delegate() { return(slotText); }, panel); } for (int i = 0; i < ballSlot.Length; i++) { panel.children.Add(ballSlot[i]); } for (int i = 0; i < label.Length; i++) { panel.children.Add(label[i]); } ballUIObj = panel; }