Beispiel #1
0
 private void NPC_VanillaHitEffect(On.Terraria.NPC.orig_VanillaHitEffect orig, NPC self, int hitDirection, double dmg)
 {
     if (!TimeStopped || TimeStopStockOwner(self))
     {
         orig.Invoke(self, hitDirection, dmg);
     }
     else
     {
         TBARGlobalNPC.Get(self).AccumulatedDamage += (int)dmg;
         self.life += (int)dmg;
     }
 }
Beispiel #2
0
        public static TBARBuff ExtendForNpc <T>(NPC target, int duration) where T : TBARBuff
        {
            TBARGlobalNPC globalNPC = TBARGlobalNPC.Get(target);

            TBARBuff buff = globalNPC.CustomBuffs.Find(x => x is T);

            if (buff != null)
            {
                buff.Duration += duration;
            }

            return(buff);
        }
Beispiel #3
0
        public static TBARBuff AddToNpc <T>(NPC target, int duration, Entity inflictor = null, BuffAddStyle style = BuffAddStyle.Default) where T : TBARBuff
        {
            TBARGlobalNPC globalNPC = TBARGlobalNPC.Get(target);

            TBARBuff buff = (TBARBuff)Activator.CreateInstance(typeof(T));

            if (inflictor != null)
            {
                buff.Owner = inflictor;
            }

            buff.Initialize();
            buff.Duration = duration;

            TBARBuff temp = null;

            switch (style)
            {
            case BuffAddStyle.Default:
                globalNPC.CustomBuffs.Add(buff);
                break;

            case BuffAddStyle.Replace:
                temp = globalNPC.CustomBuffs.Find(x => x is T);

                if (temp != null)
                {
                    globalNPC.CustomBuffs.Remove(temp);
                }

                globalNPC.CustomBuffs.Add(buff);
                break;

            case BuffAddStyle.Extend:
                temp = globalNPC.CustomBuffs.Find(x => x is T);

                if (temp != null)
                {
                    temp.Duration += duration;
                    return(temp);
                }
                else
                {
                    globalNPC.CustomBuffs.Add(buff);
                }
                break;
            }

            return(buff);
        }
Beispiel #4
0
        public static TBARBuff ExtendForNpcIf <T>(NPC target, int duration, Predicate <TBARBuff> predicate) where T : TBARBuff
        {
            TBARGlobalNPC globalNPC = TBARGlobalNPC.Get(target);

            predicate += x => x is T;

            TBARBuff buff = globalNPC.CustomBuffs.Find(predicate);

            if (buff != null)
            {
                buff.Duration += duration;
            }

            return(buff);
        }
Beispiel #5
0
 public override void Update(NPC npc, ref int buffIndex)
 {
     TBARGlobalNPC.Get(npc).RedBinded = true;
     TBARGlobalNPC.Get(npc).Shocked   = true;
 }