public virtual bool TakeDamage(WIMaterialType materialType, Vector3 damagePoint, float attemptedDamage, Vector3 attemptedForce, string damageSource, out float actualDamage, out bool isDead) { actualDamage = attemptedDamage; isDead = false; State.TotalDamage += actualDamage; if (HasPlayerFocus) { GUIHud.Get.ShowProgressBar(Colors.Get.GeneralHighlightColor, Colors.Darken(Colors.Get.GenericNeutralValue), NormalizedDamage); } if (State.SpawnOnDamaage && State.TotalDamage >= State.SpawnDamageMinimum) //reset { State.TotalDamage = 0f; //spawn a thing WorldItem worlditem = null; if (WorldItems.CloneRandomFromCategory(State.SpawnCategory, ParentChunk.AboveGroundGroup, out worlditem)) { //spit it out at the player Vector3 direction = (Player.Local.Position - damagePoint).normalized * 5f; worlditem.tr.parent = ParentChunk.AboveGroundGroup.transform; worlditem.tr.position = damagePoint; worlditem.Props.Local.FreezeOnStartup = false; worlditem.Props.Local.Transform.CopyFrom(worlditem.tr); worlditem.Initialize(); worlditem.SetMode(WIMode.World); worlditem.ApplyForce(direction, damagePoint); FXManager.Get.SpawnFX(worlditem.tr, "DrawAttentionToItem"); worlditem.GetOrAdd <DespawnOnPlayerLeave>(); } } return(true); }
public void OnPlayerUseWorldItemSecondary(object secondaryResult) { WIListResult dialogResult = secondaryResult as WIListResult; switch (dialogResult.SecondaryResult) { case "Drink": if (!CanBuyDrink) { if (gBartenderSpeech == null) { gBartenderSpeech = new Speech(); } gBartenderSpeech.Text = "That's enough for one night, {lad/lass}."; worlditem.Get <Talkative>().SayDTS(gBartenderSpeech); } else { if (Player.Local.Inventory.InventoryBank.TryToRemove(PricePerDrink)) { Profile.Get.CurrentGame.Character.Rep.GainGlobalReputation(1); //spawn a cup and put some mead in it WorldItem cup = null; if (WorldItems.CloneRandomFromCategory("BartenderCups", WIGroups.Get.World, out cup)) { cup.Initialize(); LiquidContainer container = null; if (cup.Is <LiquidContainer>(out container)) { container.State.Contents.CopyFrom(BartenderDrinkContents); container.State.Contents.InstanceWeight = container.State.Capacity; } //try to equip it in the player's hands Player.Local.Inventory.TryToEquip(cup); } State.NumTimesBoughtDrink++; State.NumTimesBoughtDrinkTonight++; State.LastTimeBoughtDrink = WorldClock.AdjustedRealTime; } } break; case "Round": if (Player.Local.Inventory.InventoryBank.TryToRemove(PricePerRound)) { if (gBartenderSpeech == null) { gBartenderSpeech = new Speech(); } gBartenderSpeech.Text = "Looks like this round's on {PlayerFirstName}!"; worlditem.Get <Talkative>().SayDTS(gBartenderSpeech); Profile.Get.CurrentGame.Character.Rep.GainGlobalReputation(5); State.NumTimesBoughtRound++; State.LastTimeBoughtRound = WorldClock.AdjustedRealTime; } break; default: break; } }