• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Terraria.NPC类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Terraria.NPC的典型用法代码示例。如果您正苦于以下问题:C# NPC类的具体用法?C# NPC怎么用?C# NPC使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NPC类属于Terraria命名空间,在下文中一共展示了NPC类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OnHitNPC

 public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
 {
     if (Main.rand.Next(8) == 0)
     {
         target.AddBuff(BuffID.Confused, 240, true);
     }
 }
开发者ID:ColinAV516,项目名称:Spirit-Mod,代码行数:7,代码来源:TaoP.cs


示例2: OnHitByNPC

 public virtual void OnHitByNPC(NPC npc, int damage, bool crit)
 {
     if (Main.rand.Next(4) == 0)
     {
         npc.AddBuff(BuffID.ShadowFlame, 200, true);
     }
 }
开发者ID:ColinAV516,项目名称:Spirit-Mod,代码行数:7,代码来源:DuskHood.cs


示例3: OnHitNPC

		public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
		{
			if (Main.rand.Next(2) == 0)
			{
				target.AddBuff(mod.BuffType("EtherealFlames"), 300);
			}
		}
开发者ID:DrakoGlyph,项目名称:tModLoader,代码行数:7,代码来源:Wisp.cs


示例4: OnHitNPC

        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            if (Main.rand.Next(10) == 0) // 10% chance to inflict slow on an enemy.
                target.AddBuff(BuffID.Slow, 5);

            base.OnHitNPC(target, damage, knockback, crit);
        }
开发者ID:Eldrazi,项目名称:Gyrolite,代码行数:7,代码来源:Streambolt.cs


示例5: NPCLoot

 public override void NPCLoot(NPC npc)
 {
     if (npc.type == NPCID.Plantera)
     {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ThornbloomKnife"), Main.rand.Next(40, 60));
     }
 }
开发者ID:ColinAV516,项目名称:Spirit-Mod,代码行数:7,代码来源:NPCHook.cs


示例6: ModifyHitNPC

        public override void ModifyHitNPC(Player player, NPC target, ref int damage, ref float knockBack, ref bool crit)
        {
            Vector2 loc = player.itemLocation;
            loc.Y -= 20;

            Random rand = new Random();
            int r = rand.Next(0, 6);

            if (r == 0)
            {
                for (int i = 0; i < 9; i++)
                {
                    Dust.NewDust(loc, 50, 30, mod.DustType("Garnsworddust"), 0.0F, 0.0F, 0, default(Color), 4.5F);
                }

                damage += (int) (damage * 0.4);

                int healamount = (int)(damage * 0.33);
                player.HealEffect(healamount, true);

                if (player.statLife + healamount <= (player.statLifeMax + player.statLifeMax2))
                {
                    player.statLife += healamount;
                }
                else
                {
                    player.statLife = (player.statLifeMax + player.statLifeMax2);
                }
            }
        }
开发者ID:Garnetty97,项目名称:Garnmod,代码行数:30,代码来源:Garnsword.cs


示例7: OnHitNPC

 public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
 {
     if(Main.rand.Next(2) == 0)
     {
         target.AddBuff(BuffID.OnFire, 500);
     }
 }
开发者ID:rpetit3-fun,项目名称:terraria-plus-one,代码行数:7,代码来源:FieryGreatswordPlusOne.cs


示例8: DamageNPC

        /// <summary>
        /// When an <see cref="NPC" /> is damaged by the <see cref="Projectile" />.
        /// </summary>
        /// <param name="n">The <see cref="NPC" /> that got damaged.</param>
        /// <param name="dir">In which direction the <see cref="NPC"/> got hit.</param>
        /// <param name="dmg">The damage dealt to the <see cref="NPC" />.</param>
        /// <param name="kb">The knockback the <see cref="NPC" /> wil receive.</param>
        /// <param name="crit">Wether it was a critical hit or not.</param>
        /// <param name="cMult">The damage multiplier of a critical hit.</param>
        public override void DamageNPC(NPC n, int dir, ref int dmg, ref float kb, ref bool crit, ref float cMult)
        {
            base.DamageNPC(n, dir, ref dmg, ref kb, ref crit, ref cMult);

            if (Main.rand.Next(3) == 0)
                n.AddBuff(20, 300);
        }
开发者ID:RainbowDashGaming,项目名称:Terraria-Avalon-MODIFIED,代码行数:16,代码来源:Sporalash+Ball.cs


示例9: OnHitNPC

 public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit)
 {
     if(!target.boss)
     {
     target.velocity.Y -= 5;
     }
 }
开发者ID:ColinAV516,项目名称:EnergyMod,代码行数:7,代码来源:SoaringBat.cs


示例10: OnHitNPC

 public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
 {
     if (Main.rand.Next(0) == 0)
     {
         target.AddBuff(mod.BuffType("ElectrifiedV2"), 540, true);
     }
 }
开发者ID:ColinAV516,项目名称:Spirit-Mod,代码行数:7,代码来源:TeslaSpikeProjectile.cs


示例11: OnHitNPC

 public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
 {
     target.AddBuff(BuffID.OnFire, 10);
     target.AddBuff(BuffID.Electrified, 3);
     target.AddBuff(BuffID.Venom, 5);
     target.AddBuff(BuffID.CursedInferno, 4);
 }
开发者ID:MountainDrew8,项目名称:CalamityMod,代码行数:7,代码来源:CataclysmicTerrorBlade.cs


示例12: CanHitNPC

 //in Terraria.Projectile.Damage for damaging NPCs before flag2 is checked... just check the patch files
 internal static bool? CanHitNPC(Projectile projectile, NPC target)
 {
     bool? flag = null;
     foreach (GlobalProjectile globalProjectile in globalProjectiles)
     {
         bool? canHit = globalProjectile.CanHitNPC(projectile, target);
         if (canHit.HasValue && !canHit.Value)
         {
             return false;
         }
         if (canHit.HasValue)
         {
             flag = canHit.Value;
         }
     }
     if (IsModProjectile(projectile))
     {
         bool? canHit = projectile.modProjectile.CanHitNPC(target);
         if (canHit.HasValue && !canHit.Value)
         {
             return false;
         }
         if (canHit.HasValue)
         {
             flag = canHit.Value;
         }
     }
     return flag;
 }
开发者ID:Phantom139,项目名称:tModLoader,代码行数:30,代码来源:ProjectileLoader.cs


示例13: CanHitNPC

 //in Terraria.Player.ItemCheck before checking whether npc type can be hit add
 //  bool? modCanHit = ItemLoader.CanHitNPC(item, this, Main.npc[num292]);
 //  if(modCanHit.HasValue && !modCanHit.Value) { continue; }
 //in if statement afterwards add || (modCanHit.HasValue && modCanHit.Value)
 internal static bool? CanHitNPC(Item item, Player player, NPC target)
 {
     bool? flag = null;
     foreach (GlobalItem globalItem in globalItems)
     {
         bool? canHit = globalItem.CanHitNPC(item, player, target);
         if (canHit.HasValue && !canHit.Value)
         {
             return false;
         }
         if (canHit.HasValue)
         {
             flag = canHit.Value;
         }
     }
     if (IsModItem(item))
     {
         bool? canHit = item.modItem.CanHitNPC(player, target);
         if (canHit.HasValue && !canHit.Value)
         {
             return false;
         }
         if (canHit.HasValue)
         {
             flag = canHit.Value;
         }
     }
     return flag;
 }
开发者ID:guyde2011,项目名称:tModLoader,代码行数:33,代码来源:ItemLoader.cs


示例14: NPCLoot

 public override void NPCLoot(NPC npc)
 {
     if (Main.player[Main.myPlayer].ZoneSnow && Main.rand.Next(5) == 3)
     {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("IceEssense"), 1);
     }
 }
开发者ID:ColinAV516,项目名称:Spirit-Mod,代码行数:7,代码来源:IceEssense.cs


示例15: OnHitNPC

		public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
		{
			if (Main.rand.Next(10) == 0)
			{
				target.AddBuff(BuffID.OnFire, 180, false);
			}
		}
开发者ID:DrakoGlyph,项目名称:tModLoader,代码行数:7,代码来源:MoltenDrill.cs


示例16: NPCLoot

 public override void NPCLoot(NPC npc)
 {
     if (npc.lifeMax > 5 && npc.value > 0f)
     {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ExampleItem"));
     }
 }
开发者ID:Evarenis,项目名称:tModLoader,代码行数:7,代码来源:ExampleItemDrop.cs


示例17: OnHitNPC

 public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
 {
     if (Main.rand.Next(25) == 0)
     {
         target.AddBuff(BuffID.BrokenArmor, 200, true);
     }
 }
开发者ID:ColinAV516,项目名称:Spirit-Mod,代码行数:7,代码来源:IronShurikenProjectile.cs


示例18: OnHitNPC

 public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
 {
     if (Main.rand.Next(2) == 0)
     {
         target.AddBuff(BuffID.CursedInferno, 60, false);
     }
 }
开发者ID:ColinAV516,项目名称:Spirit-Mod,代码行数:7,代码来源:PestilantShurikenProjectile.cs


示例19: OnStrikeNpc

 public static bool OnStrikeNpc(NPC npc, ref int damage, ref float knockback, ref int hitdirection, ref bool crit, ref bool noEffect, ref double retdamage)
 {
     if (NpcHooks.StrikeNpc == null)
     {
         return false;
     }
     NpcStrikeEventArgs npcStrikeEventArgs = new NpcStrikeEventArgs
     {
         Npc = npc,
         Damage = damage,
         KnockBack = knockback,
         HitDirection = hitdirection,
         Critical = crit,
         NoEffect = noEffect,
         ReturnDamage = retdamage
     };
     NpcHooks.StrikeNpc(npcStrikeEventArgs);
     crit = npcStrikeEventArgs.Critical;
     damage = npcStrikeEventArgs.Damage;
     knockback = npcStrikeEventArgs.KnockBack;
     hitdirection = npcStrikeEventArgs.HitDirection;
     noEffect = npcStrikeEventArgs.NoEffect;
     retdamage = npcStrikeEventArgs.ReturnDamage;
     return npcStrikeEventArgs.Handled;
 }
开发者ID:Icehawk78,项目名称:TerrariaAPI-Server,代码行数:25,代码来源:NpcHooks.cs


示例20: BossBag

 //in Terraria.NPC.DropBossBags after if statements setting bag type call
 //  NPCLoader.BossBag(this, ref num);
 internal static void BossBag(NPC npc, ref int bagType)
 {
     if (IsModNPC(npc))
     {
         bagType = npc.modNPC.bossBag;
     }
 }
开发者ID:Phantom139,项目名称:tModLoader,代码行数:9,代码来源:NPCLoader.cs



注:本文中的Terraria.NPC类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Terraria.Player类代码示例发布时间:2022-05-26
下一篇:
C# Terraria.Main类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap