public void SetLevelTier(int level, int tier, byte rank) { this.level = level; this.tier = tier; Rank = (NPCRank)rank; }
public static NPC SetRankStat(NPC npc, NPCRank rank) { if (rank == NPCRank.Normal) { return(npc); } if (rank == NPCRank.Weak) { npc.lifeMax = Mathf.CeilInt(npc.lifeMax * NPCRankStats[rank][0]); if (npc.damage > 0) { npc.damage = Mathf.CeilInt(npc.damage * NPCRankStats[rank][1]); } if (npc.defense > 0) { npc.defense = Mathf.CeilInt(npc.defense * NPCRankStats[rank][2]); } } else { npc.lifeMax = Mathf.HugeCalc(Mathf.CeilInt(npc.lifeMax * NPCRankStats[rank][0]), npc.lifeMax); if (npc.damage > 0) { npc.damage = Mathf.HugeCalc(Mathf.CeilInt(npc.damage * NPCRankStats[rank][1]), npc.damage); } if (npc.defense > 0) { npc.defense = Mathf.HugeCalc(Mathf.CeilInt(npc.defense * NPCRankStats[rank][2]), npc.defense); } } npc.life = npc.lifeMax; return(npc); }
static public void HandlePacket(BinaryReader reader, int whoAmI) { Message msg = (Message)reader.ReadByte(); Dictionary <DataTag, object> tags = new Dictionary <DataTag, object>(); foreach (DataTag tag in dataTags[msg]) { tags.Add(tag, tag.read(reader)); } switch (msg) { case Message.SyncLevel: RPGPlayer p = Main.player[(int)tags[DataTag.playerId]].GetModPlayer <RPGPlayer>(); if (p.baseName == "") { p.baseName = Main.player[(int)tags[DataTag.playerId]].name; } if ((int)tags[DataTag.playerId] != Main.myPlayer) { if (Main.netMode != NetmodeID.SinglePlayer) { p.SyncLevel((int)tags[DataTag.amount]); } Main.player[(int)tags[DataTag.playerId]].name = p.baseName + " The Lvl." + p.GetLevel() + " " + (string)tags[DataTag.buffer]; } break; case Message.AddXP: Main.LocalPlayer.GetModPlayer <RPGPlayer>().AddXp((int)tags[DataTag.amount], (int)tags[DataTag.level]); break; case Message.SyncNPCSpawn: if (Main.netMode == NetmodeID.MultiplayerClient) { NPC npc = Main.npc[(int)tags[DataTag.npcId]]; if (npc.GetGlobalNPC <ARPGGlobalNPC>() == null) { AnotherRpgMod.Instance.Logger.Info(npc.GivenName); } //npc.SetDefaults(npc.type); if (npc.GetGlobalNPC <ARPGGlobalNPC>().StatsCreated == true) { return; } int tier = (int)tags[DataTag.tier]; int level = (int)tags[DataTag.level]; NPCRank rank = (NPCRank)tags[DataTag.rank]; NPCModifier modifiers = (NPCModifier)tags[DataTag.modifiers]; if (npc == null || npc.GetGlobalNPC <ARPGGlobalNPC>() == null) { return; } AnotherRpgMod.Instance.Logger.Info(npc.GivenOrTypeName + "\nTier : " + tier + " Level : " + level + " rank : " + rank + " Modifier : " + modifiers + " \n Buffer : " + (string)tags[DataTag.buffer]); Dictionary <string, string> bufferStack = Unparse((string)tags[DataTag.buffer]); WorldManager.BossDefeated = (int)tags[DataTag.WorldTier]; npc.GetGlobalNPC <ARPGGlobalNPC>().StatsCreated = true; npc.GetGlobalNPC <ARPGGlobalNPC>().modifier = modifiers; npc.GetGlobalNPC <ARPGGlobalNPC>().SetLevelTier(level, tier, (byte)rank); npc.GetGlobalNPC <ARPGGlobalNPC>().specialBuffer = bufferStack; npc.GetGlobalNPC <ARPGGlobalNPC>().SetStats(npc); npc.GivenName = NPCUtils.GetNpcNameChange(npc, tier, level, rank); //AnotherRpgMod.Instance.Logger.Info("NPC created with id : " + npc.whoAmI); //AnotherRpgMod.Instance.Logger.Info( "Client Side : \n" + npc.GetGivenOrTypeNetName() + "\nLvl." + (npc.GetGlobalNPC<ARPGGlobalNPC>().getLevel + npc.GetGlobalNPC<ARPGGlobalNPC>().getTier) + "\nHealth : " + npc.life + " / " + npc.lifeMax + "\nDamage : " + npc.damage + "\nDef : " + npc.defense + "\nTier : " + npc.GetGlobalNPC<ARPGGlobalNPC>().getRank + "\n\n"); } break; case Message.SyncNPCUpdate: if (Main.netMode == NetmodeID.MultiplayerClient) { NPC npcu = Main.npc[(int)tags[DataTag.npcId]]; if (npcu.lifeMax != (int)tags[DataTag.maxLife] || npcu.life != (int)tags[DataTag.life]) { AnotherRpgMod.Instance.Logger.Warn("DESYNC ERROR SPOTTED FOR : "); AnotherRpgMod.Instance.Logger.Warn(npcu.GivenOrTypeName + "\n" + (int)tags[DataTag.life] + " / " + (int)tags[DataTag.maxLife] + "\n" + npcu.life + " / " + npcu.lifeMax); } Main.npc[(int)tags[DataTag.npcId]].lifeMax = (int)tags[DataTag.maxLife]; Main.npc[(int)tags[DataTag.npcId]].life = (int)tags[DataTag.life]; } break; case Message.Log: if (Main.netMode == NetmodeID.MultiplayerClient) { //ErrorLogger.Log("LOG FROM SERVER"); AnotherRpgMod.Instance.Logger.Info((string)tags[DataTag.buffer]); } break; case Message.AskNpc: if (Main.netMode == NetmodeID.Server) { NPC npc = Main.npc[(int)tags[DataTag.npcId]]; if (npc.GetGlobalNPC <ARPGGlobalNPC>() == null) { return; } int tier = npc.GetGlobalNPC <ARPGGlobalNPC>().getTier; int level = npc.GetGlobalNPC <ARPGGlobalNPC>().getLevel; int rank = npc.GetGlobalNPC <ARPGGlobalNPC>().getRank; Mod mod = AnotherRpgMod.Instance; //MPDebug.Log(mod, "Server Side : \n" + npc.GetGivenOrTypeNetName() + " ID : " + npc.whoAmI + "\nLvl." + (npc.GetGlobalNPC<ARPGGlobalNPC>().getLevel + npc.GetGlobalNPC<ARPGGlobalNPC>().getTier) + "\nHealth : " + npc.life + " / " + npc.lifeMax + "\nDamage : " + npc.damage + "\nDef : " + npc.defense + "\nTier : " + npc.GetGlobalNPC<ARPGGlobalNPC>().getRank + "\n"); SendNpcSpawn(mod, npc, tier, level, npc.GetGlobalNPC <ARPGGlobalNPC>()); } break; } }
public void SetInit(NPC npc) { if (Main.netMode == 2) { Main.npcLifeBytes[npc.type] = 4; //Sadly have to UN-optimise Health of ennemy, because it caused npc to dispear if health was over 128 (for small ) } if (Main.netMode != 1) { if (level < 0) { if (!Config.gpConfig.NPCProgress) { level = 0; tier = 0; } else { level = Mathf.CeilInt(NPCUtils.GetBaseLevel(npc) * Config.gpConfig.NpclevelMultiplier); if (npc.townNPC || (npc.damage == 0)) { tier = Mathf.CeilInt(NPCUtils.GetTierAlly(npc, level) * Config.gpConfig.NpclevelMultiplier); } else if (Config.gpConfig.NPCProgress) { tier = Mathf.CeilInt(NPCUtils.GetTier(npc, level) * Config.gpConfig.NpclevelMultiplier); } } if (!npc.townNPC && !(npc.damage == 0) && (!npc.dontCountMe)) { Rank = NPCUtils.GetRank(level + tier); modifier = NPCUtils.GetModifier(Rank, npc); if (HaveModifier(NPCModifier.Size)) { int maxrng = Main.expertMode ? 50 : 70; int rn = Mathf.RandomInt(0, maxrng); if (npc.boss) { rn += 1; } if (rn < 1) { SetBufferProperty("size", "Growther"); SetBufferProperty("GrowtherStep", "Mini"); } else if (rn < 3) { SetBufferProperty("size", "Titan"); } else if (rn < 6) { SetBufferProperty("size", "Colossus"); } else if (rn < 20) { SetBufferProperty("size", "Giant"); } else { SetBufferProperty("size", "Mini"); } } } } } }
public static NPC SetNPCStats(NPC npc, int level, int tier, NPCRank rank) { if (npc == null) { return(npc); } if (!Config.NPCConfig.NPCProgress) { npc = SetRankStat(npc, rank); npc = SetModifierStat(npc); return(npc); } if (npc.townNPC || npc.damage == 0) { npc.lifeMax = Mathf.HugeCalc(Mathf.FloorInt(npc.lifeMax * (0.5f + (tier + level) * 0.1f)), npc.lifeMax); if (npc.damage > 0) { npc.damage = Mathf.HugeCalc(Mathf.FloorInt(npc.damage * (0.75f + level * 0.03f + tier * 0.06f)), npc.damage); } if (npc.defense > 0) { npc.defense = Mathf.HugeCalc(Mathf.FloorInt(npc.defense * (0.8f + level * 0.012f + tier * 0.02f)), npc.defense); } if (npc.defense < 0) { npc.defense = 0; } if (npc.damage < 0) { npc.damage = 0; } npc.life = npc.lifeMax; return(npc); } else { float power = 1.0f; if (Main.hardMode) { power = 1.1f; } if (NPC.downedPlantBoss) { power = 1.2f; } if (npc.boss) { if (npc.damage > 0) { if (Mathf.HugeCalc(Mathf.FloorInt(npc.damage * (0.35f + level * 0.04f + tier * 0.06f) * Config.NPCConfig.NpcDamageMultiplier * 0.75f), 1) < 250000) { npc.damage = Mathf.HugeCalc(Mathf.FloorInt(npc.damage * (0.35f + level * 0.04f + tier * 0.06f) * Config.NPCConfig.NpcDamageMultiplier * 0.75f), 1); } else { // npc.damage = Mathf.FloorInt(250000 * Mathf.Logx(1 + level * 0.10f + tier * 0.30f, 7.5f) * Config.NPCConfig.NpcDamageMultiplier); npc.damage = Mathf.FloorInt(250000 * Mathf.Logx(1 + level * 0.06f + tier * 0.16f, 7.5f) * Config.NPCConfig.NpcDamageMultiplier); } } // npc.lifeMax = Mathf.HugeCalc(Mathf.FloorInt(Mathf.Pow(npc.lifeMax * (level * 0.05f + tier*0.075), power) *Config.NPCConfig.BossHealthMultiplier* Config.NPCConfig.NpcHealthMultiplier), 1); npc.lifeMax = Mathf.HugeCalc(Mathf.FloorInt(Mathf.Pow(npc.lifeMax * (level * 0.04f + tier * 0.05f), power) * Config.NPCConfig.BossHealthMultiplier * Config.NPCConfig.NpcHealthMultiplier), 1); } else { if (npc.damage > 0) { // npc.damage = Mathf.HugeCalc(Mathf.FloorInt(npc.damage * (0.75f + level * 0.035f + tier * 0.05f) * Config.NPCConfig.NpcDamageMultiplier), 1); npc.damage = Mathf.HugeCalc(Mathf.FloorInt(npc.damage * (0.75f + level * 0.017f + tier * 0.021f) * Config.NPCConfig.NpcDamageMultiplier), 1); } // npc.lifeMax = Mathf.HugeCalc(Mathf.FloorInt(Mathf.Pow(npc.lifeMax * (level * 0.20f + tier * 0.35f), power) * Config.NPCConfig.NpcHealthMultiplier), 1); npc.lifeMax = Mathf.HugeCalc(Mathf.FloorInt(Mathf.Pow(npc.lifeMax * (level * 0.15f + tier * 0.29f), power) * Config.NPCConfig.NpcHealthMultiplier), 1); } npc.value = npc.value * (1 + (level + tier) * 0.001f) * (1 + (int)rank * 0.1f); if (npc.defense > 0) { // npc.defense = Mathf.HugeCalc(Mathf.FloorInt(npc.defense * (1 + level * 0.01f + tier * 0.02f)), npc.defense); if (!NPC.downedPlantBoss) { npc.defense = Mathf.HugeCalc(Mathf.FloorInt(npc.defense * Mathf.Pow(level * 0.2f + tier * 0.2f, power - 0.3f)), npc.defense); } else { npc.defense = Mathf.HugeCalc(Mathf.FloorInt(npc.defense * Mathf.Pow(level * 0.2f + tier * 0.2f, power - 0.25f)), npc.defense); } } if (npc.defense > 5) { npc.defense -= 5; } else { npc.defense = 0; } npc.life = npc.lifeMax; npc = SetRankStat(npc, rank); npc = SetModifierStat(npc); } return(npc); }
public static string GetNpcNameChange(NPC npc, int tier, int level, NPCRank rank) { string name = npc.GivenOrTypeName; if (npc.townNPC) { return(name); } if (name == "") { name = npc.GivenName; } if (name == "") { name = npc.TypeName; } if (name == "") { return(name); } string sufix = " the "; string Prefix = ""; /* * if (Config.gpConfig.NPCProgress) * Prefix+= "Lvl. " + (tier + level) + " "; * if (WorldManager.GetWorldAdditionalLevel() > 0) * Prefix += "(+" + GetWorldTier(npc,level) + ") "; */ switch (rank) { case NPCRank.Weak: Prefix += "Weak "; break; case NPCRank.Alpha: Prefix += "Alpha "; break; case NPCRank.Elite: Prefix += "Elite "; break; case NPCRank.Legendary: Prefix += "Legendary "; break; case NPCRank.Mythical: Prefix += "Mythical "; break; case NPCRank.Godly: Prefix += "Godly "; break; case NPCRank.DIO: Prefix += "Kono Dio Da "; break; } ARPGGlobalNPC anpc = npc.GetGlobalNPC <ARPGGlobalNPC>(); if (anpc.HaveModifier(NPCModifier.Dancer)) { sufix += "Dancing "; } if (anpc.HaveModifier(NPCModifier.Cluster)) { sufix += "Clustered "; } if (anpc.HaveModifier(NPCModifier.Golden)) { sufix += "Golden "; } if (anpc.HaveModifier(NPCModifier.ArmorBreaker)) { sufix += "Armor Breaker "; } if (anpc.HaveModifier(NPCModifier.Berserker)) { sufix += "Berserker "; } if (anpc.HaveModifier(NPCModifier.Vampire)) { sufix += "Vampire "; } if (anpc.HaveModifier(NPCModifier.Size)) { string size = (string)anpc.GetBufferProperty("size"); Prefix += (size + " "); } if (sufix == " the ") { sufix = ""; } return(Prefix + name + sufix); }
public static NPCModifier GetModifier(NPCRank rank, NPC npc) { if (npc.dontCountMe) { return(NPCModifier.None); } if (!Config.NPCConfig.NPCModifier) { return(NPCModifier.None); } if (npc.boss && !Config.NPCConfig.BossModifier) { return(NPCModifier.None); } int maxModifier = 1; switch (rank) { case NPCRank.Weak: return(0); case NPCRank.Normal: maxModifier = (Mathf.Random(0, 3) < 1) ? 0 : 1; break; case NPCRank.Alpha: maxModifier = 1; break; case NPCRank.Elite: maxModifier = (Mathf.Random(0, 3) < 1) ? 1 : 2; break; case NPCRank.Legendary: maxModifier = 2; break; case NPCRank.Mythical: maxModifier = 3; break; case NPCRank.Godly: maxModifier = 4; break; case NPCRank.DIO: maxModifier = (Enum.GetValues(typeof(NPCModifier)) as NPCModifier[]).Length; break; } NPCModifier modifiers = 0; //if npc.aiStyle == 3 List <NPCModifier> modifiersPool = (Enum.GetValues(typeof(NPCModifier)) as NPCModifier[]).ToList(); if (npc.boss) { modifiersPool.Remove(NPCModifier.Size); if (maxModifier == (Enum.GetValues(typeof(NPCModifier)) as NPCModifier[]).Length) { maxModifier -= 1; } if (!Config.NPCConfig.BossClustered) { modifiersPool.Remove(NPCModifier.Cluster); if (maxModifier + 1 == (Enum.GetValues(typeof(NPCModifier)) as NPCModifier[]).Length) { maxModifier -= 1; } } } else if (npc.type == NPCID.EaterofWorldsHead || npc.type == NPCID.EaterofWorldsBody || npc.type == NPCID.EaterofWorldsTail) { modifiersPool.Remove(NPCModifier.Cluster); modifiersPool.Remove(NPCModifier.Size); if (maxModifier == (Enum.GetValues(typeof(NPCModifier)) as NPCModifier[]).Length) { maxModifier -= 2; } } for (int i = 0; i < maxModifier; i++) { NPCModifier modid = AddRandomModifier(modifiersPool); modifiers = modifiers | modid; modifiersPool.Remove(modid); } return(modifiers); }
public static NPC SetNPCStats(NPC npc, int level, int tier, NPCRank rank) { if (npc == null) { return(npc); } if (!Config.NPCConfig.NPCProgress) { npc = SetRankStat(npc, rank); npc = SetModifierStat(npc); return(npc); } if (npc.townNPC || npc.damage == 0) { npc.lifeMax = Mathf.HugeCalc(Mathf.FloorInt(npc.lifeMax * (1 + (tier + level) * 0.1f)), npc.lifeMax); if (npc.damage > 0) { npc.damage = Mathf.HugeCalc(Mathf.FloorInt(npc.damage * Mathf.Pow(1 + level * 0.02f + tier * 0.05f, 0.95f)), npc.damage); } if (npc.defense > 0) { npc.defense = Mathf.HugeCalc(Mathf.FloorInt(npc.defense * (1 + level * 0.012f + tier * 0.02f)), npc.defense); } if (npc.defense < 0) { npc.defense = 0; } if (npc.damage < 0) { npc.damage = 0; } npc.life = npc.lifeMax; return(npc); } else { if (npc.boss) { if (npc.damage > 0) { if (Mathf.HugeCalc(Mathf.FloorInt(npc.damage * Mathf.Pow(0.3f + level * 0.012f + tier * 0.02f, 1.05f) * Config.NPCConfig.NpcDamageMultiplier), 1) < 250000) { npc.damage = Mathf.HugeCalc(Mathf.FloorInt(npc.damage * Mathf.Pow(0.3f + level * 0.012f + tier * 0.02f, 1.05f) * Config.NPCConfig.NpcDamageMultiplier), 1); } else { npc.damage = Mathf.FloorInt(250000 * Mathf.Logx(1 + level * 0.10f + tier * 0.30f, 7.5f) * Config.NPCConfig.NpcDamageMultiplier); } } npc.lifeMax = Mathf.HugeCalc(Mathf.FloorInt(Mathf.Pow(npc.lifeMax * (0.5f + level * 0.02f + tier * 0.03), 1.1f) * Config.NPCConfig.BossHealthMultiplier * Config.NPCConfig.NpcHealthMultiplier), 1); } else { if (npc.damage > 0) { npc.damage = Mathf.HugeCalc(Mathf.FloorInt(npc.damage * Mathf.Pow(0.3f + level * 0.02f + tier * 0.04f, 0.85f) * Config.NPCConfig.NpcDamageMultiplier), 1); } npc.lifeMax = Mathf.HugeCalc(Mathf.FloorInt(npc.lifeMax * (0.2f + level * 0.1f + tier * 0.125f) * Config.NPCConfig.NpcHealthMultiplier), 1); } npc.value = npc.value * (1 + (level + tier) * 0.01f) * Mathf.Clamp((int)rank, 1, 5); if (npc.defense > 0) { npc.defense = Mathf.HugeCalc(Mathf.FloorInt(npc.defense * (1 + level * 0.01f + tier * 0.02f)), npc.defense); } if (npc.defense > 5) { npc.defense -= 5; } else { npc.defense = 0; } npc.life = npc.lifeMax; npc = SetRankStat(npc, rank); npc = SetModifierStat(npc); } return(npc); }