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)); }
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); } } } } }
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); }
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!"); }
public virtual void ModifyHitNPC(VNPC npc, NPC target, ref int damage, ref float knockback, ref bool crit) { }
public virtual void PostDraw(VNPC npc, SpriteBatch batch, Color drawColor) { }
public virtual bool PreDraw(VNPC npc, SpriteBatch batch, Color drawColor) { return(true); }
public virtual void PostAI(VNPC npc) { }
public virtual void AI(VNPC npc) { }
public virtual bool PreAI(VNPC npc) { return(true); }
public virtual bool PreNPCLoot(VNPC npc) { return(true); }
public virtual void UpdateLifeRegen(VNPC npc, ref int damage) { }
public override void UpdateLifeRegen(VNPC npc, ref int damage) { npc.npc.lifeRegen += 25; }
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)); }
public virtual void ModifyHitPlayer(VNPC npc, Player target, ref int damage, ref bool crit) { }
public virtual void ResetEffects(VNPC npc) { }
public virtual void NPCLoot(VNPC npc) { }