Example #1
0
        public override bool PreNPCLoot(VNPC npc)         // @TODO weighted money rates
        {
            WeightedRandom <double> wr = new WeightedRandom <double>();

            wr.Add(0.5, 30f);
            wr.Add(1, 50f);
            wr.Add(1.5, 15f);
            wr.Add(2, 5f);
            npc.npc.value = (int)(npc.npc.value * wr.Get());
            return(base.PreNPCLoot(npc));
        }
Example #2
0
        internal static void ApplyAllBuffs()
        {
            // Add cached projectile buffs to their owner
            for (int i = 0; i < Main.projectile.Length; i++)
            {
                if (Main.projectile[i].active && Main.projectile[i].minion)
                {
                    ProjCache.GetData(Main.projectile[i]).ApplyBuffs();
                }
            }

            // Then activate both npcs and players together
            for (int i = 0; i < Main.npc.Length; i++)
            {
                if (i < 255 && Main.player[i].active)
                {
                    int pid = VPlayer.GetData(Main.player[i]).GlobalID;
                    if (AllPlayerBuffers.TryGetValue(pid, out Dictionary <string, int> pbuffer) &&
                        AllPlayerBuffs.TryGetValue(pid, out Dictionary <string, int> playerbuffs))
                    {
                        playerbuffs.Clear();
                        playerbuffs.AddRange(pbuffer);
                        pbuffer.Clear();

                        if (!Main.player[i].dead && !Main.player[i].ghost)
                        {
                            foreach ((string buff, int duration) in playerbuffs)
                            {
                                int vanilla = TranslateVanilla(buff);
                                Main.player[i].AddBuff(vanilla != -1 ? vanilla : TranslateVitri(buff).Type, duration);
                            }
                        }
                    }
                }

                if (Main.npc[i].active)
                {
                    int nid = VNPC.GetData(Main.npc[i]).GlobalID;
                    if (AllNPCBuffers.TryGetValue(nid, out Dictionary <string, int> nbuffer) &&
                        AllNPCBuffs.TryGetValue(nid, out Dictionary <string, int> npcbuffs))
                    {
                        npcbuffs.Clear();
                        npcbuffs.AddRange(nbuffer);
                        nbuffer.Clear();

                        foreach ((string buff, int duration) in npcbuffs)
                        {
                            int vanilla = TranslateVanilla(buff);
                            Main.npc[i].AddBuff(vanilla != -1 ? vanilla : TranslateVitri(buff).Type, duration);
                        }
                    }
                }
            }
        }
Example #3
0
        public static bool HasBuff(this NPC npc, string buffname)
        {
            buffname = buffname.ToLower();
            int id = VNPC.GetData(npc).GlobalID;

            if (AllNPCBuffs.TryGetValue(id, out Dictionary <string, int> map))
            {
                return(map.ContainsKey(buffname));
            }

            if (AllNPCBuffers.TryGetValue(id, out Dictionary <string, int> map2))
            {
                return(map2.ContainsKey(buffname));
            }

            return(false);
        }
Example #4
0
        public static void AddBuff(this NPC npc, string buffname, int duration = 2)
        {
            buffname = buffname.ToLower();
            int id = VNPC.GetData(npc).GlobalID;

            if (AllNPCBuffers.TryGetValue(id, out Dictionary <string, int> map))
            {
                if (!map.ContainsKey(buffname))
                {
                    int       vanilla = TranslateVanilla(buffname);
                    VitriBuff vitri   = TranslateVitri(buffname);

                    if ((vanilla != -1 && !npc.buffImmune[vanilla]) ||
                        (vitri != null && !npc.buffImmune[vitri.Type]))
                    {
                        map.Add(buffname, duration);
                    }
                }

                return;
            }

            throw new KeyNotFoundException($"Error in BuffCache.AddBuff: '{npc.FullName}' was not given a buff cache!");
        }
Example #5
0
 public virtual void ModifyHitNPC(VNPC npc, NPC target, ref int damage, ref float knockback, ref bool crit)
 {
 }
Example #6
0
 public virtual void PostDraw(VNPC npc, SpriteBatch batch, Color drawColor)
 {
 }
Example #7
0
 public virtual bool PreDraw(VNPC npc, SpriteBatch batch, Color drawColor)
 {
     return(true);
 }
Example #8
0
 public virtual void PostAI(VNPC npc)
 {
 }
Example #9
0
 public virtual void AI(VNPC npc)
 {
 }
Example #10
0
 public virtual bool PreAI(VNPC npc)
 {
     return(true);
 }
Example #11
0
 public virtual bool PreNPCLoot(VNPC npc)
 {
     return(true);
 }
Example #12
0
 public virtual void UpdateLifeRegen(VNPC npc, ref int damage)
 {
 }
Example #13
0
 public override void UpdateLifeRegen(VNPC npc, ref int damage)
 {
     npc.npc.lifeRegen += 25;
 }
Example #14
0
 public override bool PreAI(VNPC npc)
 {
     npc.npc.AddBuff(Terraria.ID.BuffID.OnFire, 2);
     npc.npc.AddBuff(Terraria.ID.BuffID.Burning, 2);
     return(base.PreAI(npc));
 }
Example #15
0
 public virtual void ModifyHitPlayer(VNPC npc, Player target, ref int damage, ref bool crit)
 {
 }
Example #16
0
 public virtual void ResetEffects(VNPC npc)
 {
 }
Example #17
0
 public virtual void NPCLoot(VNPC npc)
 {
 }