コード例 #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);
            }
        }
コード例 #2
0
        public override bool CheckDead(NPC npc)
        {
            if (HaveBufferProperty("GrowtherStep"))
            {
                switch (GetBufferProperty("GrowtherStep"))
                {
                case "Mini":
                    SetBufferProperty("GrowtherStep", "Normal");
                    break;

                case "Normal":
                    SetBufferProperty("GrowtherStep", "Giant");
                    break;

                case "Giant":
                    SetBufferProperty("GrowtherStep", "Colossus");
                    break;

                case "Colossus":
                    SetBufferProperty("GrowtherStep", "Titan");
                    break;

                case "Titan":
                    return(false);
                }
                npc      = NPCUtils.SizeShiftMult(npc, GetBufferProperty("GrowtherStep"));
                npc.life = npc.lifeMax;
                MPPacketHandler.SendNpcUpdate(mod, npc);
                //NetMessage.SendData(23, -1, -1, null, npc.whoAmI);
            }
            return(true);
        }
コード例 #3
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");
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        public override void PostAI(NPC npc)
        {
            Effect(npc);
            if (npc.dontTakeDamage && dontTakeDamageTime > 0)
            {
                dontTakeDamageTime -= NPCUtils.DELTATIME;
                if (dontTakeDamageTime <= 0)
                {
                    npc.dontTakeDamage = false;
                    dontTakeDamageTime = 0;
                }
            }

            if (!StatsCreated && Main.netMode != 1)
            {
                StatsCreated = true;
                SetInit(npc);
                SetStats(npc);
                //MPDebug.Log(mod,"Server Side : \n"+ npc.GetGivenOrTypeNetName()+ " ID : "+ npc.whoAmI + "\nLvl."+ (getLevel+getTier)+"\nHealth : " + npc.life + " / " + npc.lifeMax + "\nDamage : " + npc.damage + "\nDef : " + npc.defense + "\nTier : " + getRank + "\n");
                MPPacketHandler.SendNpcSpawn(mod, npc, tier, level, this);
                //NetMessage.SendData(23, -1, -1, null, npc.whoAmI);

                npc.GivenName = NPCUtils.GetNpcNameChange(npc, tier, level, Rank);
            }

            if (Main.netMode == 1)
            {
                if (!StatsFrame0)
                {
                    StatsFrame0 = true;
                }

                else if (!StatsCreated)
                {
                    StatsCreated = true;
                    MPPacketHandler.AskNpcInfo(mod, npc);
                }
            }



            if (Main.netMode != 1)
            {
                debuffDamage += NPCUtils.UpdateDOT(npc);
                int applydamage = 0;

                if (debuffDamage > 0)
                {
                    applydamage    = Mathf.FloorInt(debuffDamage);
                    debuffDamage  -= applydamage;
                    npc.life      -= applydamage;
                    npc.lifeRegen -= applydamage;
                    if (npc.life <= 0)
                    {
                        npc.checkDead();
                    }
                }


                if (HaveModifier(NPCModifier.Berserker))
                {
                    npc.damage = Mathf.RoundInt((float)baseDamage * (2 - ((float)npc.life / (float)npc.lifeMax)));
                }

                //MPPacketHandler.SendNpcUpdate(mod,npc);
            }
        }
コード例 #5
0
 public void SetStats(NPC npc)
 {
     npc        = NPCUtils.SetNPCStats(npc, level, tier, Rank);
     baseDamage = npc.damage;
 }