public override void EditSpawnPool(IDictionary <int, float> pool, NPCSpawnInfo spawnInfo) { PokeModBlue.originalSpawnPool = pool; List <int> keys = new List <int>(pool.Keys); foreach (int key in keys) { // All NPCs Spawn if (PokeModBlue.pokeSpawns == 1) { pool[key] = PokeModBlue.originalSpawnPool[key]; continue; } // Only Mod NPCs Spawn if (PokeModBlue.pokeSpawns == 2) { ModNPC modNPC = NPCLoader.GetNPC(key); if (modNPC != null) { pool[key] = PokeModBlue.originalSpawnPool[key]; } else { pool[key] = 0f; } continue; } // Only Normal NPCs Spawn if (PokeModBlue.pokeSpawns == 3) { ModNPC modNPC = NPCLoader.GetNPC(key); if (modNPC != null) { pool[key] = 0f; } else { pool[key] = PokeModBlue.originalSpawnPool[key]; } continue; } // Only Pokemon Spawn if (PokeModBlue.pokeSpawns == 4) { PokemonNPC pokemonNPC = NPCLoader.GetNPC(key) as PokemonNPC; if (pokemonNPC != null) { pool[key] = PokeModBlue.originalSpawnPool[key]; } else { pool[key] = 0f; } continue; } } }
public override void HandlePacket(BinaryReader reader, int whoAmI) { PokeModMessageType msgType = (PokeModMessageType)reader.ReadByte(); switch (msgType) { // This message sent by the player when they load to initialize the custom Pokemon Weapon Data for all players case PokeModMessageType.SetPokemonWeaponData: break; case PokeModMessageType.SummonPokemon: int npc = NPC.NewNPC(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); Main.npc[npc].releaseOwner = reader.ReadByte(); Main.npc[npc].life = reader.ReadInt32(); PokemonNPC pokemon = Main.npc[npc].modNPC as PokemonNPC; if (pokemon != null) { PokemonWeapon pokemonWeapon = Main.player[Main.npc[npc].releaseOwner].inventory[Main.player[Main.npc[npc].releaseOwner].selectedItem].modItem as PokemonWeapon; if (pokemonWeapon != null) { pokemon.pokemon = pokemonWeapon; } } break; default: ErrorLogger.Log("PokeMod: Unknown Message type: " + msgType); break; } }
public override bool PreAI() { if (summonPokemon != null) { if (summonPokemon.npc.life < 1 && pokemonOneDefeated == false) { pokemonOneDefeated = true; combatTextNum = CombatText.NewText(new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height), PokemonText, "Brock sends out Onix!", false, false); if (Main.netMode == 2 && combatTextNum != 100) { CombatText combatText = Main.combatText[combatTextNum]; NetMessage.SendData(81, -1, -1, combatText.text, (int)combatText.color.PackedValue, combatText.position.X, combatText.position.Y, 0f, 0, 0, 0); } int summonNPC = NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("Onix")); summonPokemon = Main.npc[summonNPC].modNPC as PokemonNPC; summonPokemon.level = 14; } else if (summonPokemon.npc.life < 1 && pokemonTwoDefeated == false) { pokemonTwoDefeated = true; summonPokemon = null; // reset pokemonOneDefeated = false; pokemonTwoDefeated = false; } } return(base.PreAI()); }
public void SummonPokemon(Player player, Vector2 position) { if (Main.netMode == 0) { int npc = NPC.NewNPC((int)position.X, (int)position.Y, (int)item.makeNPC); PokemonNPC pokemon = Main.npc[npc].modNPC as PokemonNPC; if (pokemon != null) { pokemon.pokemon = Main.player[item.owner].inventory[Main.player[item.owner].selectedItem].modItem as PokemonWeapon; } Main.npc[npc].releaseOwner = (byte)player.whoAmI; Main.npc[npc].life = currentHP; } else if (Main.netMode == 1) { /* * // commented out for now as it causes pokemon to reset their stats until I sync the items as well * ModPacket packet = mod.GetPacket(); * packet.Write((byte)PokeModMessageType.SummonPokemon); * packet.Write((int)position.X); * packet.Write((int)position.Y); * packet.Write((int)item.makeNPC); * packet.Write((byte)player.whoAmI); * packet.Write((int)currentHP); * packet.Write((int)Main.player[item.owner].selectedItem); * packet.Send(); */ } if (ModLoader.GetMod("PokeModBlueSounds") != null) { Main.PlaySound(SoundLoader.customSoundType, -1, -1, ModLoader.GetMod("PokeModBlueSounds").GetSoundSlot(SoundType.Custom, "Sounds/Custom/id" + ((int)id).ToString())); } summoned = true; /* * PokePlayer modPlayer = (PokePlayer)player.GetModPlayer(mod, "PokePlayer"); * // need to put a limiter on this, max 1 per item * if (player.HasBuff(mod.BuffType(Name + "Buff")) < 0 && player.itemTime == 0 && player.itemAnimation > 0 && player.controlUseItem) * { * } */ }
private void TimerEventProcessor(object sender, ElapsedEventArgs e) { if (loop == 0) { combatTextNum = CombatText.NewText(new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height), PokemonText, "Set?", false, false); if (Main.netMode == 2 && combatTextNum != 100) { CombatText combatText = Main.combatText[combatTextNum]; NetMessage.SendData(81, -1, -1, combatText.text, (int)combatText.color.PackedValue, combatText.position.X, combatText.position.Y, 0f, 0, 0, 0); } } else if (loop == 1) { combatTextNum = CombatText.NewText(new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height), PokemonText, "Go!", false, false); if (Main.netMode == 2 && combatTextNum != 100) { CombatText combatText = Main.combatText[combatTextNum]; NetMessage.SendData(81, -1, -1, combatText.text, (int)combatText.color.PackedValue, combatText.position.X, combatText.position.Y, 0f, 0, 0, 0); } } else if (loop == 2) { combatTextNum = CombatText.NewText(new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height), PokemonText, "Brock sends out Geodude!", false, false); if (Main.netMode == 2 && combatTextNum != 100) { CombatText combatText = Main.combatText[combatTextNum]; NetMessage.SendData(81, -1, -1, combatText.text, (int)combatText.color.PackedValue, combatText.position.X, combatText.position.Y, 0f, 0, 0, 0); } int summonNPC = NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("Geodude")); summonPokemon = Main.npc[summonNPC].modNPC as PokemonNPC; summonPokemon.level = 12; timer.Stop(); timer.Dispose(); } loop++; }
public override void ModifyHitNPC(NPC npc, NPC target, ref int damage, ref float knockback, ref bool crit) { // target is actually your Pokemon // npc is the npc that is hitting your Pokemon // this says let your Pokemon hit first, and if they kill the enemy take no damage // will need to update this to check each Pokemon's speed stat when both are Pokemon and letting the winner strike first if (target.modNPC != null) { PokemonNPC targetPokemon; targetPokemon = target.modNPC as PokemonNPC; if (targetPokemon != null) { PokemonNPC npcPokemon; npcPokemon = npc.modNPC as PokemonNPC; if (npcPokemon != null) { int direction; if (npc.position.X > target.position.X) { direction = 1; } else { direction = -1; } float effectiveness = PokemonNPC.getTypeEffectiveness(targetPokemon.getTypeI(), npcPokemon.getTypeI(), npcPokemon.getTypeII()); int npcdamage = (int)(target.damage * effectiveness); if (effectiveness < 1 && effectiveness > 0) { combatTextNum = CombatText.NewText(new Rectangle((int)npc.position.X + 150 * direction, (int)npc.position.Y, npc.width, npc.height), PokemonNPC.PokemonText, "It's not very effective...", false, false); if (Main.netMode == 2 && combatTextNum != 100) { CombatText combatText = Main.combatText[combatTextNum]; NetMessage.SendData(81, -1, -1, combatText.text, (int)combatText.color.PackedValue, combatText.position.X, combatText.position.Y, 0f, 0, 0, 0); } } else if (effectiveness > 1) { combatTextNum = CombatText.NewText(new Rectangle((int)npc.position.X + 150 * direction, (int)npc.position.Y, npc.width, npc.height), PokemonNPC.PokemonText, "It's super effective!", false, false); if (Main.netMode == 2 && combatTextNum != 100) { CombatText combatText = Main.combatText[combatTextNum]; NetMessage.SendData(81, -1, -1, combatText.text, (int)combatText.color.PackedValue, combatText.position.X, combatText.position.Y, 0f, 0, 0, 0); } } else if (effectiveness == 0) { combatTextNum = CombatText.NewText(new Rectangle((int)npc.position.X + 150 * direction, (int)npc.position.Y, npc.width, npc.height), PokemonNPC.PokemonText, "It doesn't affect " + npc.name + "...", false, false); if (Main.netMode == 2 && combatTextNum != 100) { CombatText combatText = Main.combatText[combatTextNum]; NetMessage.SendData(81, -1, -1, combatText.text, (int)combatText.color.PackedValue, combatText.position.X, combatText.position.Y, 0f, 0, 0, 0); } } npc.StrikeNPC(npcdamage, 1.0f, target.direction); } else { npc.StrikeNPC(target.damage, 1.0f, target.direction); } } } }
// add exp points calculated from how strong the pokemon defeated was public void AddExperience(PokemonNPC npc) { if (level < 100) { // see http://bulbapedia.bulbagarden.net/wiki/Experience#Experience_gain_in_battle for formula float a = 1f; float b = (float)npc.EXPV; float e = 1f; //float f = 1f; //used in flat level xp formula, not in scaled xp from gen V float L = (float)npc.level; float Lp = (float)level; float p = 1f; float s = 1f; float t = (originalTrainer == Main.player[Main.myPlayer].name) ? 1f : 1.5f; float v = (level < EvolveLevel) ? 1f : 1.2f; experience += (int)((((a * b * L) / (5f * s)) * (((float)Math.Pow(((2f * L) + 10), 2.5f)) / ((float)Math.Pow((L + Lp + 10), 2.5f)))) * t * e * p); } //add EV's as well List <KeyValuePair <int, string> > list = npc.EV_Worth; foreach (KeyValuePair <int, string> kvp in list) { if (kvp.Value == "MHP") { if (HPEV + (byte)kvp.Key < HPEV) { HPEV = 255; } else { HPEV += (byte)kvp.Key; } } else if (kvp.Value == "Atk") { if (AtkEV + (byte)kvp.Key < AtkEV) { AtkEV = 255; } else { AtkEV = (byte)kvp.Key; } } else if (kvp.Value == "Def") { if (DefEV + (byte)kvp.Key < DefEV) { DefEV = 255; } else { DefEV = (byte)kvp.Key; } } else if (kvp.Value == "SpA") { if (SpAEV + (byte)kvp.Key < SpAEV) { SpAEV = 255; } else { SpAEV = (byte)kvp.Key; } } else if (kvp.Value == "SpD") { if (SpDEV + (byte)kvp.Key < SpDEV) { SpDEV = 255; } else { SpDEV = (byte)kvp.Key; } } else if (kvp.Value == "Spe") { if (SpeEV + (byte)kvp.Key < SpeEV) { SpeEV = 255; } else { SpeEV = (byte)kvp.Key; } } } CheckLevelUp(); SetToolTip(); }