Beispiel #1
0
        public override void NPCLoot(NPC npc)
        {
            if (HaveModifier(NPCModifier.Cluster) && !HaveBufferProperty("clustered"))
            {
                int clusterRN = Mathf.RandomInt(4, 8);
                for (int i = 0; i < clusterRN; i++)
                {
                    NPCUtils.SpawnSized(npc, specialBuffer);
                }
            }

            if (npc.damage == 0)
            {
                return;
            }
            if (npc.townNPC)
            {
                return;
            }

            Player player = Array.Find(Main.player, p => p.active);

            if (Main.netMode == 0)
            {
                player = Main.LocalPlayer; //if local , well it's simple
            }
            else if (Main.player[npc.target].active)
            {
                player = Main.player[npc.target];
            }
            else
            {
                return;
            }
            int XPToDrop = NPCUtils.GetExp(npc);

            if (npc.rarity > 0)
            {
                XPToDrop = (int)(XPToDrop * 1.5f);
            }
            if (npc.boss)
            {
                XPToDrop = XPToDrop * 2;
                WorldManager.OnBossDefeated(npc);
            }

            XPToDrop = Mathf.CeilInt(XPToDrop * Config.gpConfig.XpMultiplier);

            int xplevel = level + tier;

            if (!Config.gpConfig.XPReduction)
            {
                xplevel = int.MaxValue;
            }
            MPPacketHandler.SendXPPacket(mod, XPToDrop, xplevel);
            if (Main.netMode == 0)
            {
                player.GetModPlayer <RPGPlayer>().AddXp(XPToDrop, xplevel);
            }
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        public override void ModifyHitPlayer(Projectile projectile, Player target, ref int damage, ref bool crit)
        {
            //int projectilelevel = (int)((WorldManager.GetWorldLevelMultiplier(Config.NPCConfig.NPCProjectileDamageLevel)+ WorldManager.GetWorldAdditionalLevel()) * Config.NPCConfig.NpclevelMultiplier );
            int projectilelevel = Mathf.CeilInt(20 + WorldManager.GetWorldAdditionalLevel());

            /*
             * debug
             * Main.NewText("projectile base level : " + Config.NPCConfig.NPCProjectileDamageLevel);
             * Main.NewText("World Day : " + WorldManager.Day);
             * Main.NewText("projectile day level : " + WorldManager.GetWorldLevelMultiplier(Config.NPCConfig.NPCProjectileDamageLevel));
             * Main.NewText("projectile World level : " + WorldManager.GetWorldAdditionalLevel());
             * Main.NewText("npc level multiplier : " + Config.NPCConfig.NpclevelMultiplier);
             *
             * Main.NewText("projectile level : " + (int)(WorldManager.GetWorldLevelMultiplier(Config.NPCConfig.NPCProjectileDamageLevel) * Config.NPCConfig.NpclevelMultiplier));
             * Main.NewText("projectile base damage : " + projectile.damage);
             * Main.NewText("projectile damage multiplier : " + Mathf.Pow(1 + projectilelevel * 0.02f, 0.95f) * Config.NPCConfig.NpcDamageMultiplier);
             */

            // damage = Mathf.HugeCalc(Mathf.FloorInt(projectile.damage *(1 + projectilelevel * 0.05f) * Config.NPCConfig.NpcDamageMultiplier), projectile.damage);
            if (Main.npc.Any(n => n.whoAmI < Main.maxNPCs && n.active && n.boss))
            {
                damage = Mathf.HugeCalc(Mathf.FloorInt(projectile.damage * (0.3f + projectilelevel * 0.01f + Config.NPCConfig.NPCProjectileDamageLevel * 0.01f) * Config.NPCConfig.NpcDamageMultiplier), projectile.damage);
            }
            else
            {
                damage = Mathf.HugeCalc(Mathf.FloorInt(projectile.damage * (0.45f + projectilelevel * 0.025f + Config.NPCConfig.NPCProjectileDamageLevel * 0.01f) * Config.NPCConfig.NpcDamageMultiplier), projectile.damage);
            }
            //damage = Mathf.HugeCalc(Mathf.FloorInt(projectile.damage *(1 + WorldManager.GetMaximumAscend() * 0.031f) * Config.NPCConfig.NpcDamageMultiplier), projectile.damage);
        }
Beispiel #4
0
        //Tier are bonus level either random or from world
        public static int GetTier(NPC npc, int baselevel)
        {
            if (baselevel < 0)
            {
                baselevel = 0;
            }
            int rand = Mathf.RandomInt(0, 4 + Mathf.CeilInt(baselevel * 0.1f));

            return(Mathf.HugeCalc(rand + GetWorldTier(npc, baselevel + rand), -1));
        }
Beispiel #5
0
        public override void ModifyHitNPC(Projectile projectile, NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
        {
            if (projectile.npcProj)
            {
                //int projectilelevel = (int)(WorldManager.GetWorldLevelMultiplier(Config.NPCConfig.NPCProjectileDamageLevel) * Config.NPCConfig.NpclevelMultiplier);
                int projectilelevel = Mathf.CeilInt(20 + WorldManager.GetWorldAdditionalLevel());

                // damage = Mathf.HugeCalc(Mathf.FloorInt(projectile.damage * Mathf.Pow(1 + projectilelevel * 0.02f, 0.95f)* Config.NPCConfig.NpcDamageMultiplier), projectile.damage);
                damage = Mathf.HugeCalc(Mathf.FloorInt(projectile.damage * Mathf.Pow(1 + projectilelevel * 0.015f, 0.95f) * Config.NPCConfig.NpcDamageMultiplier), projectile.damage);
            }
        }
Beispiel #6
0
        static public int GetModCount(Rarity rarity, Item item)
        {
            float count = 1;

            switch (rarity)
            {
            case Rarity.Broken:
            case Rarity.Imperfect:
                count = 0;
                break;

            case Rarity.Inferior:
                count = 0.5f;
                break;

            case Rarity.Superior:
                count = 1;
                break;

            case Rarity.Rare:
                count = 1.5f;
                break;

            case Rarity.MasterPiece:
                count = 2;
                break;

            case Rarity.Epic:
                count = 2.5f;
                break;

            case Rarity.Legendary:
                count = 3f;
                break;

            case Rarity.Mythical:
                count = 3.5f;
                break;
            }
            if (WorldManager.ascended)
            {
                count *= 2;
            }
            if (item.accessory)
            {
                count -= 1;
                count *= 0.5f;
            }
            else if (item.damage > 0)
            {
                count *= 0.5f;
            }
            return(Mathf.CeilInt(Mathf.Clamp(count, 0, 5)));
        }
Beispiel #7
0
        public static NPC SetSizeStat(NPC npc, string size)
        {
            if (size == "Growther")
            {
                size = (string)npc.GetGlobalNPC <ARPGGlobalNPC>().GetBufferProperty("GrowtherStep");
            }

            if (size == "Normal")
            {
                return(npc);
            }
            if (size == "Mini")
            {
                npc.lifeMax = Mathf.CeilInt(npc.lifeMax * NPCSizeStats[size][0]);
                if (npc.damage > 0)
                {
                    npc.damage = Mathf.CeilInt(npc.damage * NPCSizeStats[size][1]);
                }
                if (npc.defense > 0)
                {
                    npc.defense = Mathf.CeilInt(npc.defense * NPCSizeStats[size][2]);
                }
            }
            else
            {
                npc.lifeMax = Mathf.HugeCalc(Mathf.CeilInt(npc.lifeMax * NPCSizeStats[size][0]), npc.lifeMax);
                if (npc.damage > 0)
                {
                    npc.damage = Mathf.HugeCalc(Mathf.CeilInt(npc.damage * NPCSizeStats[size][1]), npc.damage);
                }
                if (npc.defense > 0)
                {
                    npc.defense = Mathf.HugeCalc(Mathf.CeilInt(npc.defense * NPCSizeStats[size][2]), npc.defense);
                }
            }


            npc.scale *= NPCSizeStats[size][3];

            npc.life = npc.lifeMax;

            return(npc);
        }
Beispiel #8
0
        public override void ModifyHitPlayer(NPC npc, Player target, ref int damage, ref bool crit)
        {
            if (HaveModifier(NPCModifier.Vampire))
            {
                npc.life = Mathf.Clamp(Mathf.CeilInt(damage * 0.5f), npc.life, npc.lifeMax);
            }

            if (HaveModifier(NPCModifier.ArmorBreaker))
            {
                int def = target.statDefense;
                if (damage < def)
                {
                    damage = Mathf.RoundInt(def + damage * 0.3f);
                }
                else if (damage > def + damage * 0.3f)
                {
                    damage += Mathf.RoundInt(def * 0.3f);
                }
            }

            base.ModifyHitPlayer(npc, target, ref damage, ref crit);
        }
Beispiel #9
0
        public static int GetMaxLevel(NPC npc)
        {
            //  int maxLevel = Mathf.CeilInt(WorldManager.PlayerLevel + Config.NPCConfig.LimitNPCGrowthValue + (float)WorldManager.PlayerLevel * Config.NPCConfig.LimitNPCGrowthPercent * 0.01f);
            int maxLevel = Mathf.CeilInt(20 + WorldManager.GetWorldAdditionalLevel());

            Random rand = new Random();

            if (npc.boss)
            {
                maxLevel += rand.Next(10, 25);
            }
            else
            {
                maxLevel = rand.Next(maxLevel - 7, maxLevel + 3);
            }

            if (maxLevel < 1)
            {
                maxLevel = 1;
            }
            return(maxLevel);
        }
        private void GenerateTree()
        {
            int        NodeGoal   = Mathf.CeilInt(Mathf.Pow(m_ItemSource.baseCap / 3f, 0.95) * 1.25f);
            List <int> IDS        = ItemNodeAtlas.GetAvailibleNodeList(m_ItemSource, false);
            int        yPos       = 0; //skilltree will allways goes down
            int        minbranche = MINBRANCH;

            minbranche = Mathf.Clamp(Mathf.FloorInt(MINBRANCH + m_ItemSource.GetCapLevel() * 0.02f), MINBRANCH, MAXBRANCH);
            int           brancheAmm = Mathf.RandomInt(minbranche, MAXBRANCH);
            List <Branch> Branches   = new List <Branch>
            {
                new Branch(),
                new Branch(),
                new Branch()
            };

            //branches placement :
            // 3 1 0 2 4
            int     brancheID  = 0;
            bool    emptyLevel = true;
            int     connectionBranch;
            Vector2 pos;

            for (int i = 0; i < NodeGoal; i++)
            {
                //20% chance to add a new branches
                if (Mathf.RandomInt(0, 5) >= 4 && Branches.Count < brancheAmm)
                {
                    Branches.Add(new Branch());
                }


                //Used to init the first node

                if (i == 0)
                {
                    Branches[0].Add(AddNewRandomNode(-1, new Vector2(0, 0), IDS, false));
                    yPos++;
                    emptyLevel = true;
                }
                else
                {
                    //if we reached all branches, then we goes to the layer
                    if (brancheID >= Branches.Count)
                    {
                        emptyLevel = true;
                        brancheID  = 0;
                        yPos++;
                    }
                    if (Mathf.RandomInt(0, 5) < 4 || (brancheID == Branches.Count - 1 && emptyLevel))
                    {
                        emptyLevel = false;

                        connectionBranch = brancheID;

                        if (Branches[brancheID].IsEmpty())
                        {
                            connectionBranch = Branch.GetRandomNearbyBranches(brancheID, Branches.Count, Branches, true);
                        }
                        else if (Mathf.RandomInt(0, 5) >= 4)
                        {
                            connectionBranch = Branch.GetRandomNearbyBranches(brancheID, Branches.Count, Branches, true);
                        }



                        pos = new Vector2(Branch.GetPosition(brancheID), yPos * 100);



                        int a = HaveNodeAtPos(pos);
                        if (a > 0)
                        {
                            m_nodeList[a].AddNeightboor(Branches[brancheID].GetLastandBefore());
                        }
                        else
                        {
                            Branches[brancheID].Add(AddNewRandomNode(Branches[connectionBranch].GetLastandBefore(), pos, IDS, false));
                        }

                        //add neightboor
                        if (Mathf.RandomInt(0, 5) >= 4)
                        {
                            connectionBranch = Branch.GetRandomNearbyBranches(brancheID, Branches.Count, Branches, true);
                            int id = Branches[connectionBranch].GetLastandBefore();
                            if (!m_nodeList[Branches[brancheID].GetLast()].GetNeighboor.Contains(id))
                            {
                                m_nodeList[Branches[brancheID].GetLast()].AddNeightboor(id);
                            }
                        }
                    }
                    //Go through all the node one by one
                    brancheID += 1;
                }
            }
            BuildConnection();
            m_nodeList[0].UnlockStep(3);
        }
        public static ItemSkillTree ConvertToTree(string save, ItemUpdate source, int evoPoint, int AscPoint)
        {
            string[]      nodeListSave;
            string[]      nodeDetails;
            ItemSkillTree tree = new ItemSkillTree();

            nodeListSave      = save.Split(';');
            tree.m_ItemSource = source;
            string[] a;
            ItemNode bufferNode;

            foreach (string nodeSave in nodeListSave)
            {
                bufferNode  = null;
                nodeDetails = nodeSave.Split('|');
                if (nodeDetails.Length != 8)
                {
                    AnotherRpgMod.Instance.Logger.Error(source.ItemName);
                    AnotherRpgMod.Instance.Logger.Error("Item tree corrupted, reseting tree");
                    AnotherRpgMod.Instance.Logger.Error(nodeSave);
                    tree = new ItemSkillTree();
                    tree.MaxEvolutionPoints = evoPoint;
                    tree.MaxAscendPoints    = AscPoint;
                    tree.Init(source);
                    tree.Reset(true);
                    tree.EvolutionPoints = tree.MaxEvolutionPoints;
                    tree.AscendPoints    = tree.MaxAscendPoints;

                    if (tree.AscendPoints > 0)
                    {
                        tree.ExtendTree(Mathf.Clamp(Mathf.CeilInt(Mathf.Pow(source.baseCap / 3f, 0.95)), 5, 99) * tree.AscendPoints);
                    }
                    return(tree);
                }

                bufferNode = (ItemNode)ItemNodeAtlas.GetCorrectNode(int.Parse(nodeDetails[0]));

                a = nodeDetails[6].Split(':');
                bufferNode.Init(tree, tree.GetSize, int.Parse(nodeDetails[4]), int.Parse(nodeDetails[5]), new Vector2(int.Parse(a[0]), int.Parse(a[1])));

                //Ignore it if there is no neighboor
                if (nodeDetails[1] != "")
                {
                    a = nodeDetails[1].Split(':');
                    foreach (string neightboor in a)
                    {
                        bufferNode.AddNeightboor(int.Parse(neightboor));
                    }
                }
                bufferNode.ForceLockNode(int.Parse(nodeDetails[2]));
                bufferNode.SetLevel = int.Parse(nodeDetails[3]);


                if (nodeDetails[7] != "")
                {
                    bufferNode.LoadValue(nodeDetails[7]);
                }
                tree.AddNode(bufferNode);
            }

            return(tree);
        }
Beispiel #12
0
        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");
                            }
                        }
                    }
                }
            }
        }
Beispiel #13
0
        public static NPC SizeShiftMult(NPC npc, string size)
        {
            if (size == "Mini")
            {
                npc.lifeMax = Mathf.HugeCalc(Mathf.CeilInt(npc.lifeMax / NPCSizeStats["Mini"][0]), npc.lifeMax);
                if (npc.damage > 0)
                {
                    npc.damage = Mathf.HugeCalc(Mathf.CeilInt(npc.damage / NPCSizeStats["Mini"][1]), npc.damage);
                }
                if (npc.defense > 0)
                {
                    npc.defense = Mathf.HugeCalc(Mathf.CeilInt(npc.defense / NPCSizeStats["Mini"][2]), npc.defense);
                }

                npc.scale /= NPCSizeStats["Mini"][3];
            }
            else if (size == "Normal")
            {
                npc.lifeMax = Mathf.HugeCalc(Mathf.CeilInt(npc.lifeMax * NPCSizeStats["Giant"][0]), npc.lifeMax);
                if (npc.damage > 0)
                {
                    npc.damage = Mathf.HugeCalc(Mathf.CeilInt(npc.damage * NPCSizeStats["Giant"][1]), npc.damage);
                }
                if (npc.defense > 0)
                {
                    npc.defense = Mathf.HugeCalc(Mathf.CeilInt(npc.defense * NPCSizeStats["Giant"][2]), npc.defense);
                }

                npc.scale *= NPCSizeStats["Giant"][3];
            }
            else if (size == "Giant")
            {
                npc.lifeMax = Mathf.HugeCalc(Mathf.CeilInt((npc.lifeMax / NPCSizeStats["Giant"][0]) * NPCSizeStats["Colossus"][0]), npc.lifeMax);
                if (npc.damage > 0)
                {
                    npc.damage = Mathf.HugeCalc(Mathf.CeilInt((npc.damage / NPCSizeStats["Giant"][1]) * NPCSizeStats["Colossus"][1]), npc.damage);
                }
                if (npc.defense > 0)
                {
                    npc.defense = Mathf.HugeCalc(Mathf.CeilInt((npc.defense / NPCSizeStats["Giant"][2]) * NPCSizeStats["Colossus"][2]), npc.defense);
                }

                npc.scale *= NPCSizeStats["Colossus"][3] / NPCSizeStats["Giant"][3];
            }
            else if (size == "Colossus")
            {
                npc.lifeMax = Mathf.HugeCalc(Mathf.CeilInt((npc.lifeMax / NPCSizeStats["Colossus"][0]) * NPCSizeStats["Titan"][0]), npc.lifeMax);
                if (npc.damage > 0)
                {
                    npc.damage = Mathf.HugeCalc(Mathf.CeilInt((npc.damage / NPCSizeStats["Colossus"][1]) * NPCSizeStats["Titan"][1]), npc.damage);
                }
                if (npc.defense > 0)
                {
                    npc.defense = Mathf.HugeCalc(Mathf.CeilInt((npc.defense / NPCSizeStats["Colossus"][2]) * NPCSizeStats["Titan"][2]), npc.defense);
                }

                npc.scale *= NPCSizeStats["Titan"][3] / NPCSizeStats["Colossus"][3];
            }

            return(npc);
        }
Beispiel #14
0
 public static int GetExp(NPC npc)
 {
     return(Mathf.CeilInt(Math.Pow(npc.lifeMax / 8 + npc.damage * 1.2 + npc.defense * 1.7f, 0.9f)));
 }
Beispiel #15
0
 public int XpForLevel()
 {
     return(Mathf.CeilInt(Mathf.Pow(level * 0.04f, 0.75f)) + 1);
 }