public bool TryToTame(Skill skill) { bool result = false; if (skill.LastSkillValue > StubbornnessTypeToFloat(creature.Template.Props.Stubbornness)) { //this function is called by the Beastmaster skill to verify a context action //it consumes whatever edibles are in the player's hand FoodStuff foodStuff = null; if (Player.Local.Tool.IsEquipped && Player.Local.Tool.worlditem.Is <FoodStuff>(out foodStuff)) { if (Stacks.Can.Stack(foodStuff.worlditem, creature.Template.Props.FavoriteFood)) { Debug.Log("Player has the food we like equipped"); creature.Eat(foodStuff); Tamed tamed = worlditem.GetOrAdd <Tamed>(); tamed.Imprint(Player.Local, WorldClock.AdjustedRealTime, skill.EffectTime, skill.HasBeenMastered); result = true; } } } if (result) { //if we've been tamed then there's no need for this script any more creature.State.Domestication = DomesticatedState.Tamed; creature.RefreshBehavior(); } return(result); }
public void OnCollectiveThoughtStart() { if (mDestroyed) { return; } if (!creature.IsInDen) { creature.CurrentThought.Should(IOIReaction.IgnoreIt); return; } creature.Body.TargetEyeColor = Color.green; //TODO put this somewhere else IItemOfInterest itemOfInterest = creature.CurrentThought.CurrentItemOfInterest; switch (itemOfInterest.IOIType) { case ItemOfInterestType.Player: default: if (creature.Template.StateTemplate.Domestication == DomesticatedState.Domesticated) { creature.CurrentThought.Should(IOIReaction.WatchIt); } else { Tamed tamed = null; if (worlditem.Is <Tamed>(out tamed) && tamed.State.ImprintedPlayer == itemOfInterest.player.ID) { creature.CurrentThought.Should(IOIReaction.IgnoreIt); } else { if (Player.Local.IsCrouching) { creature.CurrentThought.Should(IOIReaction.FleeFromIt); } else if (Player.Local.IsWalking) { creature.CurrentThought.Should(IOIReaction.FleeFromIt, 3); } else if (Player.Local.IsSprinting) { creature.CurrentThought.Should(IOIReaction.FleeFromIt, 4); } else { creature.CurrentThought.Should(IOIReaction.FleeFromIt, 2); } } } break; case ItemOfInterestType.Scenery: creature.CurrentThought.Should(IOIReaction.WatchIt); break; case ItemOfInterestType.WorldItem: if (creature.CurrentThought.CurrentItemOfInterest.worlditem.Is <Creature>() && !creature.Den.BelongsToPack(creature.CurrentThought.CurrentItemOfInterest.worlditem)) { creature.CurrentThought.Should(IOIReaction.FleeFromIt); } break; } }