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 override void OnInitialized() { Potions.InitializeAvatar(this); //get our properties if (Mods.Get.Runtime.LoadMod <Potion>(ref Props, "Potion", State.PotionName)) { FoodStuff foodStuff = null; if (worlditem.Is <FoodStuff>(out foodStuff)) { foodStuff.SetProps(Props.EdibleProps); foodStuff.OnEat += OnEat; } } }
public void OnCollectiveThoughtStart() { //get the current item of interest and see how we feel about it if (creature.CurrentThought.HasItemOfInterest && creature.CurrentThought.CurrentItemOfInterest.IOIType == ItemOfInterestType.Player) { //we're interested in the player when they have a piece of food equipped FoodStuff foodStuff = null; if (Player.Local.Tool.IsEquipped && Player.Local.Tool.worlditem.Is <FoodStuff>(out foodStuff)) { //player has something tasty equipped, what is it? if (Stacks.Can.Stack(foodStuff.worlditem, creature.Template.Props.FavoriteFood)) { //player has our favorite food, we're going to watch the player //if it's the same as our favorite food //vote twice to stay put creature.CurrentThought.Should(IOIReaction.WatchIt, 2); } } } }
protected void Drink() { if (mGenericLiquid == null) { if (!WorldItems.GetRandomGenericWorldItemFromCatgeory(State.LiquidCategory, out mGenericLiquid)) { return; } } WorldItem worlditem = null; if (WorldItems.Get.PackPrefab(mGenericLiquid.PackName, mGenericLiquid.PrefabName, out worlditem)) { FoodStuff foodStuff = null; if (worlditem.gameObject.HasComponent <FoodStuff>(out foodStuff)) { FoodStuff.Drink(foodStuff); } } }
public override void OnInitialized() { worlditem.ActiveStateLocked = false; worlditem.ActiveState = WIActiveState.Active; worlditem.ActiveStateLocked = true; Detectable detectable = worlditem.Get <Detectable> (); detectable.OnPlayerDetect += OnPlayerDetect; FoodStuff foodStuff = worlditem.Get <FoodStuff> (); foodStuff.OnEat += OnEat; foodStuff.State.ConsumeOnEat = false; //we'll handle consumption Damageable damageable = worlditem.Get <Damageable> (); damageable.OnDie += OnDie; if (HasBeenPicked) { RefreshPlantProps(); } }
public void OnPlayerUseWorldItemSecondary(object secondaryResult) { WIListResult dialogResult = secondaryResult as WIListResult; switch (dialogResult.SecondaryResult) { case "PourOnSelf": MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, "FillLiquidContainer"); Player.Local.Status.RemoveCondition("BurnedByFire"); Player.Local.Status.AddCondition("Wet"); State.Contents.Clear(); break; case "Drink": WorldItem liquid = null; if (WorldItems.Get.PackPrefab(State.Contents.PackName, State.Contents.PrefabName, out liquid)) //this is tricky - we want to drink it without destroying the prefab { FoodStuff foodstuff = null; if (liquid.Is <FoodStuff>(out foodstuff)) //DON'T consume the foodstuff! { FoodStuff.Drink(foodstuff); State.Contents.InstanceWeight--; GUIManager.PostInfo("Drank 1 " + State.Contents.DisplayName + ", " + State.Contents.InstanceWeight.ToString() + "/" + State.Capacity.ToString() + " left."); } } break; case "Pour Out": //two options here //if we're in the inventory then we want to add our contents to the selected stack //if we're in the world we want to dump it into the world bool playSound = false; if (PrimaryInterface.IsMaximized("Inventory")) { WIStack selectedStack = Player.Local.Inventory.SelectedStack; if (Stacks.Can.Stack(selectedStack, State.Contents)) { WIStackError error = WIStackError.None; for (int i = 0; i < State.Contents.InstanceWeight; i++) { StackItem contents = State.Contents.ToStackItem(); if (!Stacks.Push.Item(selectedStack, contents, ref error)) { break; } else { playSound = true; } } } } else { State.Contents.Clear(); GUIManager.PostInfo("Discarded contents"); if (Player.Local.Surroundings.IsWorldItemInRange) { Flammable flammable = null; if (Player.Local.Surroundings.WorldItemFocus.worlditem.Is <Flammable>(out flammable) && flammable.IsOnFire) { flammable.Extinguish(); } } playSound = true; } if (playSound) { MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, "FillLiquidContainer"); } break; default: break; } }
public static void Eat(FoodStuff foodstuff) { if (foodstuff == null) { return; } FoodStuffProps Props = foodstuff.Props; if (!string.IsNullOrEmpty(Props.ConditionName)) { if (UnityEngine.Random.value <= Props.ConditionChance) { Player.Local.Status.AddCondition(Props.ConditionName); } } PlayerStatusRestore hungerRestore = PlayerStatusRestore.A_None; PlayerStatusRestore healthRestore = PlayerStatusRestore.A_None; PlayerStatusRestore healthReduce = PlayerStatusRestore.A_None; HallucinogenicStrength hallucinogen = HallucinogenicStrength.None; bool wellFed = false; if (Flags.Check((uint)Props.Type, (uint)FoodStuffEdibleType.Edible, Flags.CheckType.MatchAny)) { hungerRestore = Props.HungerRestore; } if (Flags.Check((uint)Props.Type, (uint)FoodStuffEdibleType.Hallucinogen, Flags.CheckType.MatchAny)) { hallucinogen = Props.Hallucinogen; } if (Flags.Check((uint)Props.Type, (uint)FoodStuffEdibleType.Medicinal, Flags.CheckType.MatchAny)) { healthRestore = Props.HealthRestore; } if (Flags.Check((uint)Props.Type, (uint)FoodStuffEdibleType.Poisonous, Flags.CheckType.MatchAny)) { healthReduce = Props.HealthReduce; } if (Flags.Check((uint)Props.Type, (uint)FoodStuffEdibleType.WellFed, Flags.CheckType.MatchAny)) { hungerRestore = PlayerStatusRestore.F_Full; wellFed = true; } Player.Local.Status.ReduceStatus(healthReduce, "Health"); if (foodstuff.Props.IsLiquid) { Player.Local.Status.RestoreStatus(hungerRestore, "Thirst"); } else { Player.Local.Status.RestoreStatus(hungerRestore, "Hunger"); } Player.Local.Status.RestoreStatus(healthRestore, "Health"); if (wellFed) { Player.Local.Status.AddCondition("WellFed"); } MasterAudio.PlaySound(MasterAudio.SoundType.PlayerVoiceMale, Props.EatFoodSound); if (!string.IsNullOrEmpty(Props.CustomStatusKeeperRestore)) { Player.Local.Status.RestoreStatus(Props.CustomRestore, Props.CustomStatusKeeperRestore); } if (!string.IsNullOrEmpty(Props.CustomStatusKeeperReduce)) { Player.Local.Status.RestoreStatus(Props.CustomRestore, Props.CustomStatusKeeperReduce); } if (foodstuff.worlditem != null && !foodstuff.worlditem.IsTemplate) { foodstuff.OnEat.SafeInvoke(); if (foodstuff.State.ConsumeOnEat) { //Debug.Log ("FOODSTUFF: Setting mode to RemovedFromGame"); foodstuff.worlditem.SetMode(WIMode.RemovedFromGame); } } }
public static void Drink(FoodStuff foodstuff) { Eat(foodstuff); }
public void Eat(FoodStuff foodStuff) { MasterAudio.PlaySound(MasterAudio.SoundType.PlayerVoiceMale, worlditem.tr, "EatFoodGeneric"); foodStuff.worlditem.SetMode(WIMode.RemovedFromGame); }