public void AttackThing(IItemOfInterest itemOfInterest) { if (Profile.Get.CurrentGame.Difficulty.IsDefined("NoHostileCreatures")) { return; } Body.EyeMode = BodyEyeMode.Hostile; Hostile hostile = null; if (!worlditem.Is <Hostile> (out hostile)) { hostile = worlditem.GetOrAdd <Hostile> (); //copy the properties quickly Reflection.CopyProperties(Template.HostileTemplate, hostile.State); //copy the attacks directly hostile.TerritoryBase = Den; hostile.State.Attack1 = ObjectClone.Clone <AttackStyle> (Template.HostileTemplate.Attack1); hostile.State.Attack2 = ObjectClone.Clone <AttackStyle> (Template.HostileTemplate.Attack2); hostile.OnAttack1Start += OnAttack1; hostile.OnAttack2Start += OnAttack2; hostile.OnWarn += OnWarn; hostile.OnCoolOff += OnCoolOff; } if (!hostile.HasPrimaryTarget || hostile.PrimaryTarget != itemOfInterest) { hostile.PrimaryTarget = itemOfInterest; } hostile.RefreshAttackSettings(); Body.Animator.Idling = false; }
public bool AttackThingAction(IItemOfInterest itemOfInterest) { bool result = false; Hostile hostile = null; if (!worlditem.Is <Hostile> (out hostile)) { hostile = worlditem.GetOrAdd <Hostile> (); //copy the properties quickly Reflection.CopyProperties(Template.HostileTemplate, hostile.State); //copy the attacks directly hostile.TerritoryBase = TerritoryBase; hostile.State.Attack1 = ObjectClone.Clone <AttackStyle> (Template.HostileTemplate.Attack1); hostile.State.Attack2 = ObjectClone.Clone <AttackStyle> (Template.HostileTemplate.Attack2); hostile.OnAttack1Start += OnAttack1; hostile.OnAttack2Start += OnAttack2; hostile.OnWarn += OnWarn; hostile.OnCoolOff += OnCoolOff; result = true; } if (!hostile.HasPrimaryTarget || hostile.PrimaryTarget != itemOfInterest) { hostile.PrimaryTarget = itemOfInterest; result = true; } animator.Idling = false; animator.WeaponMode = CharacterWeaponMode.BareHands; return(false); }
public bool SurvivalHostileDeaggro(double timeStamp) { if (!Player.Local.Surroundings.HasHostiles) { Hostile hostile = null; if (worlditem.Is <Hostile> (out hostile)) { hostile.Finish(); } } return(true); }
protected IEnumerator OnPlayerLeaveCamp() { for (int i = 0; i < SpawnedBandits.Count; i++) { Hostile hostile = null; if (SpawnedBandits [i].worlditem.Is <Hostile> (out hostile)) { hostile.Finish(); } yield return(null); } yield break; }
public bool SurvivalHostileAggro(double timeStamp) { if (Player.Local.Surroundings.HasHostiles) { Hostile hostile = worlditem.GetOrAdd <Hostile> (); if (!hostile.HasPrimaryTarget) { //we're not currently attacking anything //so attack the first thing that's attacking the player IHostile target = Player.Local.Surroundings.Hostiles [0]; hostile.PrimaryTarget = target.hostile; } } return(true); }