public virtual void ShootAtTarget(GuardJobInstance instance, ref NPCBase.NPCState state)
 {
     if (state.Inventory.TryRemove(GuardSettings.ShootItem))
     {
         if (GuardSettings.OnShootAudio != null)
         {
             AudioManager.SendAudio(instance.Position.Vector, GuardSettings.OnShootAudio);
         }
         if (GuardSettings.OnHitAudio != null)
         {
             AudioManager.SendAudio(instance.Target.PositionToAimFor, GuardSettings.OnHitAudio);
         }
         UnityEngine.Vector3 start         = instance.Position.Add(0, 1, 0).Vector;
         UnityEngine.Vector3 end           = instance.Target.PositionToAimFor;
         UnityEngine.Vector3 dirNormalized = (end - start).normalized;
         ServerManager.SendParticleTrail(start + dirNormalized * 0.15f, end - dirNormalized * 0.15f, Pipliz.Random.NextFloat(1.5f, 2.5f));
         instance.Target.OnHit(GuardSettings.Damage, instance.NPC, ModLoader.OnHitData.EHitSourceType.NPC);
         state.SetIndicator(new IndicatorState(GuardSettings.CooldownShot, GuardSettings.ShootItem[0].Type));
         if (GuardSettings.OnShootResultItem.item.Type > 0 && Pipliz.Random.NextDouble(0.0, 1.0) <= (double)GuardSettings.OnShootResultItem.chance)
         {
             instance.Owner.Stockpile.Add(GuardSettings.OnShootResultItem.item);
         }
     }
     else
     {
         var items             = GuardSettings.ShootItem.Select(i => new StoredItem(i.Type, i.Amount * 50)).ToArray();
         var getitemsfromCrate = new GetItemsFromCrateGoal(instance, JobSettings, this, items);
         JobSettings.SetGoal(instance, new PutItemsInCrateGoal(Job, JobSettings, getitemsfromCrate, state.Inventory.Inventory), ref state);
         state.Inventory.Add(items);
     }
 }
Exemple #2
0
 public virtual void ShootAtTarget(GuardJobInstance instance, ref NPCBase.NPCState state)
 {
     if (state.Inventory.TryRemove(GuardSettings.ShootItem))
     {
         if (GuardSettings.OnShootAudio != null)
         {
             AudioManager.SendAudio(instance.Position.Vector, GuardSettings.OnShootAudio);
         }
         if (GuardSettings.OnHitAudio != null)
         {
             AudioManager.SendAudio(instance.Target.PositionToAimFor, GuardSettings.OnHitAudio);
         }
         UnityEngine.Vector3 start         = instance.Position.Add(0, 1, 0).Vector;
         UnityEngine.Vector3 end           = instance.Target.PositionToAimFor;
         UnityEngine.Vector3 dirNormalized = (end - start).normalized;
         ServerManager.SendParticleTrail(start + dirNormalized * 0.15f, end - dirNormalized * 0.15f, Pipliz.Random.NextFloat(1.5f, 2.5f));
         instance.Target.OnHit(GuardSettings.Damage, instance.NPC, ModLoader.OnHitData.EHitSourceType.NPC);
         state.SetIndicator(new IndicatorState(GuardSettings.CooldownShot, GuardSettings.ShootItem[0].Type));
         if (GuardSettings.OnShootResultItem.item.Type > 0 && Pipliz.Random.NextDouble(0.0, 1.0) <= (double)GuardSettings.OnShootResultItem.chance)
         {
             state.Inventory.Add(GuardSettings.OnShootResultItem.item);
         }
     }
     else
     {
         Shop(instance, ref state);
     }
 }
Exemple #3
0
 public GuardGoal(GuardJobInstance job, PandaGuardJobSettings settings)
 {
     GuardJob      = job;
     Job           = job;
     GuardSettings = settings;
     CurrentGuards.Add(this);
 }
 static void Postfix(GuardJobSettings __instance, GuardJobInstance instance, ref NPCBase.NPCState state)
 {
     // Log.WriteWarning("GuardJobSettingsHookShootAtTarget::Postfix");
     npc = null;
 }
 static void Postfix(GuardJobSettings __instance, GuardJobInstance instance, ref NPCBase.NPCState state)
 {
     DebugLog.Write(MethodBase.GetCurrentMethod().DeclaringType + "::" + MethodBase.GetCurrentMethod().Name);
     npc = null;
 }