public static int GetHireCost(int EntityID) { int result = -1; EntityAliveSDX myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAliveSDX; if (myEntity) { result = GetIntValue(EntityID, "HireCost"); } if (result == -1) { result = 1000; } return(result); }
public static ItemValue GetHireCurrency(int EntityID) { ItemValue result = ItemClass.GetItem("casinoCoin", false); EntityAliveSDX myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAliveSDX; if (myEntity) { result = GetItemValue(EntityID, "HireCurrency"); } if (result.IsEmpty()) { result = ItemClass.GetItem("casinoCoin", true); } return(result); }
public static int GetIntValue(int EntityID, String strProperty) { int result = -1; EntityAliveSDX myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAliveSDX; if (myEntity) { EntityClass entityClass = EntityClass.list[myEntity.entityClass]; if (entityClass.Properties.Values.ContainsKey(strProperty)) { result = int.Parse(entityClass.Properties.Values[strProperty]); } } return(result); }
public static float GetFloatValue(int EntityID, String strProperty) { float result = -1; EntityAliveSDX myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAliveSDX; if (myEntity) { EntityClass entityClass = EntityClass.list[myEntity.entityClass]; if (entityClass.Properties.Values.ContainsKey(strProperty)) { result = StringParsers.ParseFloat(entityClass.Properties.Values[strProperty], 0, -1, NumberStyles.Any); } } return(result); }
public static bool CheckForBuff(int EntityID, String strBuff) { bool result = false; EntityAliveSDX myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAliveSDX; if (myEntity == null) { return(result); } if (myEntity.Buffs.HasBuff(strBuff)) { result = true; } return(result); }
public static Orders GetCurrentOrder(int EntityID) { Orders currentOrder = Orders.Wander; EntityAliveSDX myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAliveSDX; if (myEntity) { //DisplayLog(" GetCurrentOrder(): This is an Entity AliveSDX"); if (myEntity.Buffs.HasCustomVar("CurrentOrder")) { //DisplayLog("GetCurrentOrder(): Entity has an Order: " + (Orders)myEntity.Buffs.GetCustomVar("CurrentOrder")); currentOrder = (Orders)myEntity.Buffs.GetCustomVar("CurrentOrder"); } } return(currentOrder); }
// This loops through all the targets, refreshing the quest. // <triggered_effect trigger="onSelfBuffStart" action="PumpQuestSDX, Mods" target="self" /> public override void Execute(MinEventParams _params) { for (int j = 0; j < this.targets.Count; j++) { EntityAliveSDX entity = this.targets[j] as EntityAliveSDX; if (entity != null) { for (int k = 0; k < entity.QuestJournal.quests.Count; k++) { for (int l = 0; l < entity.QuestJournal.quests[k].Objectives.Count; l++) { entity.QuestJournal.quests[k].Objectives[l].Refresh(); } } } } }
static bool Prefix(EntityAlive __instance) { // Check if this feature is enabled. if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) { return(true); } // If a door is found, try to open it. If it returns false, start attacking it. EntityAliveSDX myEntity = __instance as EntityAliveSDX; if (myEntity) { myEntity.RestoreSpeed(); } return(true); }
public override bool GetBindingValue(ref string value, BindingItem binding) { EntityPlayer player = base.xui.playerUI.entityPlayer; if (player == null) { return(false); } int entityID = 0; if (player.Buffs.HasCustomVar("CurrentNPC")) { entityID = (int)player.Buffs.GetCustomVar("CurrentNPC"); } if (entityID == 0) { return(false); } string fieldName = binding.FieldName; if (fieldName != null) { if (fieldName == "respondentname") { EntityAliveSDX myEntity = player.world.GetEntity(entityID) as EntityAliveSDX; if (myEntity) { if (EntityUtilities.GetHireCost(entityID) <= 0) { value = myEntity.EntityName; } else { value = myEntity.EntityName;// + " ( Hire for " + myEntity.GetHireCost() + " " + myEntity.GetHireCurrency().ItemClass.Name + " )"; } return(true); } value = ((!(base.xui.Dialog.Respondent != null)) ? string.Empty : Localization.Get(base.xui.Dialog.Respondent.EntityName, string.Empty)); return(true); } } return(false); }
public override bool CheckRequirement(EntityPlayer player) { int entityID = 0; if (player.Buffs.HasCustomVar("CurrentNPC")) { entityID = (int)player.Buffs.GetCustomVar("CurrentNPC"); } if (entityID == 0) { return(false); } EntityAliveSDX myEntity = player.world.GetEntity(entityID) as EntityAliveSDX; if (myEntity != null) { string text2; EntityClass entityClass = EntityClass.list[myEntity.entityClass]; for (int x = 1; x < 20; x++) { string text = EntityClass.PropAITask + x; if (entityClass.Properties.Values.ContainsKey(text)) { if (entityClass.Properties.Values.TryGetString(text, out text2) || text2.Length > 0) { if (text2.Contains(base.Value)) { return(true); } continue; } } else { return(false); } } } return(false); }
public virtual bool ConfigureTargetEntity() { if (this.entityTarget != null) { return(true); } this.NearbyEntities.Clear(); if (this.entityAliveSDX == null) { if (this.theEntity is EntityAliveSDX) { this.entityAliveSDX = (this.theEntity as EntityAliveSDX); } else { DisplayLog(" Not an EntityAliveSDX"); return(false); } } DisplayLog(" ConfigureTargetEntity()"); // Search in the bounds are to try to find the most appealing entity to follow. Bounds bb = new Bounds(this.theEntity.position, new Vector3(30f, 20f, 30f)); this.theEntity.world.GetEntitiesInBounds(typeof(EntityAlive), bb, this.NearbyEntities); for (int i = this.NearbyEntities.Count - 1; i >= 0; i--) { EntityAlive x = (EntityAlive)this.NearbyEntities[i]; if (x != this.theEntity) { // Check the entity against the incentives if (entityAliveSDX.CheckIncentive(this.lstIncentives, x)) { DisplayLog(" Found my Target: " + x.EntityName); this.entityTarget = x; return(true); } } } this.entityTarget = null; return(false); }
public static bool ConsumeProduct(int EntityID, ItemValue item) { bool result = false; EntityAliveSDX myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAliveSDX; if (!myEntity) { return(false); } // No Item, no consumption if (item == null) { return(false); } DisplayLog(" ConsumeProduct() " + item.ItemClass.GetItemName()); ItemClass original = myEntity.inventory.holdingItem; myEntity.inventory.SetBareHandItem(item); ItemAction itemAction = myEntity.inventory.holdingItem.Actions[0]; if (itemAction != null) { myEntity.Attack(true); DisplayLog("ConsumeProduct(): Hold Item has Action0. Executing.."); itemAction.ExecuteAction(myEntity.inventory.holdingItemData.actionData[0], true); //// We want to consume the food, but the consumption of food isn't supported on the non-players, so just fire off the buff /// DisplayLog("ConsumeProduct(): Trigger Events"); myEntity.FireEvent(MinEventTypes.onSelfPrimaryActionEnd); myEntity.FireEvent(MinEventTypes.onSelfHealedSelf); myEntity.SetInvestigatePosition(Vector3.zero, 0); } DisplayLog(" ConsumeProduct(): Restoring hand item"); myEntity.inventory.SetBareHandItem(ItemClass.GetItem(original.Name, false)); return(result); }
public override void Execute(MinEventParams _params) { EntityAliveSDX entity = _params.Self as EntityAliveSDX; if (entity == null) { return; } if (hide) { entity.SendOnMission(true); } else { entity.SendOnMission(false); } }
public void CheckSurroundingEntities(EntityAliveSDX questNPC, EntityPlayer player) { List <Entity> NearbyEntities = new List <Entity>(); Bounds bb = new Bounds(questNPC.position, new Vector3(questNPC.GetSeeDistance(), 20f, questNPC.GetSeeDistance())); questNPC.world.GetEntitiesInBounds(typeof(EntityAliveSDX), bb, NearbyEntities); for (int i = NearbyEntities.Count - 1; i >= 0; i--) { EntityAliveSDX x = (EntityAliveSDX)NearbyEntities[i]; if (x != questNPC && x.IsAlive()) { if (x.Buffs.HasCustomVar("Leader") && x.Buffs.GetCustomVar("Leader") == (float)questNPC.entityId) { EntityUtilities.SetOwner(x.entityId, player.entityId); } } } }
public override bool CheckRequirement(EntityPlayer player) { LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal); // The respondent is an EntityNPC, and we don't have that. Check for the patch scripted otherEntitySDX. Entity respondent = uiforPlayer.xui.Dialog.Respondent; if (respondent == null) { respondent = uiforPlayer.xui.Dialog.otherEntitySDX; } if (respondent != null) { EntityAliveSDX myEntity = player.world.GetEntity(respondent.entityId) as EntityAliveSDX; if (myEntity != null) { bool isTame = false; if (base.Value.EqualsCaseInsensitive("not")) { isTame = !myEntity.isTame(player); } else { isTame = myEntity.isTame(player); } if (isTame) { if (myEntity.PatrolCoordinates.Count > 0) { return(true); } else { return(false); } } return(isTame); } } return(false); }
public static bool CheckIncentive(int EntityID, List <String> lstIncentives, EntityAlive entity) { bool result = false; EntityAliveSDX myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAliveSDX; if (myEntity == null) { return(result); } foreach (String strIncentive in lstIncentives) { // Check if the entity that is looking at us has the right buff for us to follow. if (myEntity.Buffs.HasBuff(strIncentive)) { result = true; } // Check if there's a cvar for that incentive, such as $Mother or $Leader. if (myEntity.Buffs.HasCustomVar(strIncentive)) { // DisplayLog(" Incentive: " + strIncentive + " Value: " + this.Buffs.GetCustomVar(strIncentive)); if ((int)myEntity.Buffs.GetCustomVar(strIncentive) == entity.entityId) { result = true; } } if (entity) { // Then we check if the control mechanism is an item being held. if (entity.inventory.holdingItem.Name == strIncentive) { result = true; } } // if we are true here, it means we found a match to our entity. if (result) { break; } } return(result); }
public override bool CheckRequirement(EntityPlayer player) { int entityID = 0; if (player.Buffs.HasCustomVar("CurrentNPC")) { entityID = (int)player.Buffs.GetCustomVar("CurrentNPC"); } if (entityID == 0) { return(false); } EntityAliveSDX myEntity = player.world.GetEntity(entityID) as EntityAliveSDX; if (myEntity != null) { bool isTame = false; if (base.Value.EqualsCaseInsensitive("not")) { isTame = !EntityUtilities.isTame(entityID, player); } else { isTame = EntityUtilities.isTame(entityID, player); } if (isTame) { if (myEntity.PatrolCoordinates.Count > 0) { return(true); } else { return(false); } } return(isTame); } return(false); }
// <reward type="GiveNPCSDX, Mods" id="entityGroup" /> // Spawns in an entity from the group to be your NPC // <reward type="GiveNPCSDX, Mods" /> // Hires the current NPC public override void GiveReward(EntityPlayer player) { if (string.IsNullOrEmpty(base.ID)) { EntityAliveSDX questNPC = GameManager.Instance.World.Entities.dict[base.OwnerQuest.QuestGiverID] as EntityAliveSDX; if (questNPC) { questNPC.SetOwner(player as EntityPlayerLocal); } else { Debug.Log(" NPC not Found."); } } else // Try to spawn in a new NPC from the NPC Group { SpawnFromGroup(base.ID, player); } }
public override void GiveReward(EntityPlayer player) { Quest quest = QuestClass.CreateQuest(base.ID); if (base.OwnerQuest != null) { quest.PreviousQuest = GetQuest(base.OwnerQuest.ID).Name; } if (GameManager.Instance.World.Entities.dict.ContainsKey(base.OwnerQuest.SharedOwnerID)) { EntityAliveSDX questEntity = GameManager.Instance.World.Entities.dict[base.OwnerQuest.SharedOwnerID] as EntityAliveSDX; if (questEntity == null) { return; } questEntity.QuestJournal.AddQuest(quest); } }
public static ItemValue GetItemValue(int EntityID, String strProperty) { ItemValue result = ItemClass.GetItem("casinoCoin", false); EntityAliveSDX myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAliveSDX; if (myEntity) { EntityClass entityClass = EntityClass.list[myEntity.entityClass]; if (entityClass.Properties.Values.ContainsKey(strProperty)) { result = ItemClass.GetItem(entityClass.Properties.Values[strProperty], false); } if (result.IsEmpty()) { result = ItemClass.GetItem("casinoCoin", false); } } return(result); }
public override void Execute(MinEventParams _params) { if (!SingletonMonoBehaviour <ConnectionManager> .Instance.IsServer) { return; } for (int j = 0; j < this.targets.Count; j++) { EntityAliveSDX entity = this.targets[j] as EntityAliveSDX; if (entity) { int EntityID = entity.entityClass; // If the group is set, then use it. if (!string.IsNullOrEmpty(this.strSpawnGroup)) { int ClassID = 0; EntityID = EntityGroups.GetRandomFromGroup(this.strSpawnGroup, ref ClassID); } Vector3 transformPos; entity.world.GetRandomSpawnPositionMinMaxToPosition(entity.position, 2, 6, 2, true, out transformPos, false); Entity NewEntity = EntityFactory.CreateEntity(EntityID, transformPos, entity.rotation); if (NewEntity) { NewEntity.SetSpawnerSource(EnumSpawnerSource.StaticSpawner); GameManager.Instance.World.SpawnEntityInWorld(NewEntity); Debug.Log("An entity was created: " + NewEntity.ToString()); if (NewEntity is EntityAliveSDX) { Debug.Log("Setting Mother ID to Baby: " + entity.entityId + " for " + NewEntity.entityId); (NewEntity as EntityAliveSDX).Buffs.SetCustomVar("Mother", entity.entityId, true); } } else { Debug.Log(" Could not Spawn baby for: " + entity.EntityName + " : " + entity.entityId); } } } }
public override void PerformAction(EntityPlayer player) { LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal); // The respondent is an EntityNPC, and we don't have that. Check for the patch scripted otherEntitySDX. Entity respondent = uiforPlayer.xui.Dialog.Respondent; if (respondent == null) { respondent = uiforPlayer.xui.Dialog.otherEntitySDX; } if (respondent != null) { EntityAliveSDX myEntity = player.world.GetEntity(respondent.entityId) as EntityAliveSDX; if (myEntity != null) { myEntity.ExecuteCMD(base.ID, player); } } }
public override void OnOpen() { if (base.xui.Dialog.Respondent != null) { EntityAliveSDX myEntity = base.xui.Dialog.Respondent as EntityAliveSDX; if (myEntity == null) { myEntity = base.xui.Dialog.otherEntitySDX as EntityAliveSDX; } if (myEntity) { if (myEntity.isTame(base.xui.playerUI.entityPlayer)) { return; } } } base.OnOpen(); base.RefreshBindings(false); }
// This will search for a mother entity to see it can satisfy its thirst from its mother, rather than a traditional water block. public virtual float GetEntityWater() { if (this.theEntity.Buffs.HasCustomVar("Mother")) { float MotherID = this.theEntity.Buffs.GetCustomVar("Mother"); EntityAliveSDX MotherEntity = this.theEntity.world.GetEntity((int)MotherID) as EntityAliveSDX; if (MotherEntity) { DisplayLog(" My Mother is: " + MotherEntity.EntityName); if (MotherEntity.Buffs.HasCustomVar("MilkLevel")) { DisplayLog("Heading to mommy"); float MilkLevel = MotherEntity.Buffs.GetCustomVar("MilkLevel"); this.theEntity.SetInvestigatePosition(this.theEntity.world.GetEntity((int)MotherID).position, 60); return(MilkLevel); } } } return(0f); }
public static void ProcessConsumables(int EntityID) { EntityAliveSDX myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAliveSDX; if (myEntity == null) { return; } float foodAmount = GetCVarValue(EntityID, "$foodAmountAdd"); if (foodAmount > 0.5f) { myEntity.Health += Utils.Fastfloor(foodAmount); foodAmount -= 0.5f; } if (myEntity.Health > myEntity.GetMaxHealth()) { myEntity.Health = myEntity.GetMaxHealth(); } }
public static bool CheckProperty(int EntityID, string Property) { EntityAliveSDX myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAliveSDX; if (myEntity == null) { return(false); } EntityClass entityClass = EntityClass.list[myEntity.entityClass]; if (entityClass.Properties.Values.ContainsKey(Property)) { return(true); } if (entityClass.Properties.Classes.ContainsKey(Property)) { return(true); } return(false); }
public static bool isEntityThirsty(int EntityID) { bool result = false; EntityAliveSDX myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAliveSDX; if (myEntity) { List <String> lstBuffs = ConfigureEntityClass(EntityID, "ThirstyBuffs"); if (lstBuffs.Count == 0) { lstBuffs.AddRange(new string[] { "buffStatusThirsty2", "buffStatusThirsty1" }); } result = CheckIncentive(EntityID, lstBuffs, null); } if (result) // Really spammy if its false { DisplayLog(" Is Entity Thirsty? " + result); } return(result); }
public static bool Hire(int EntityID, EntityPlayerLocal _player) { DisplayLog("Hire()"); bool result = false; EntityAliveSDX myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAliveSDX; if (myEntity == null) { return(result); } DisplayLog("Hire(): I have an entity"); LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(_player as EntityPlayerLocal); if (uiforPlayer) { DisplayLog("Hire(): I have a player."); DisplayLog(" The Player wants to hire me for " + GetHireCost(EntityID) + " " + GetHireCurrency(EntityID)); if (uiforPlayer.xui.PlayerInventory.GetItemCount(GetHireCurrency(EntityID)) >= GetHireCost(EntityID)) { DisplayLog(" The Player has enough currency: " + uiforPlayer.xui.PlayerInventory.GetItemCount(GetHireCurrency(EntityID))); // Create the stack of currency ItemStack stack = new ItemStack(GetHireCurrency(EntityID), GetHireCost(EntityID)); DisplayLog(" Removing Item: " + stack.ToString()); uiforPlayer.xui.PlayerInventory.RemoveItems(new ItemStack[] { stack }, 1); // Add the stack of currency to the NPC, and set its orders. //myEntity.bag.AddItem(stack); SetLeaderAndOwner(EntityID, _player.entityId); return(true); } else { GameManager.ShowTooltipWithAlert(_player, "You cannot afford me. I want " + GetHireCost(EntityID) + " " + GetHireCurrency(EntityID), "ui_denied"); } } return(false); }
static bool Prefix(EntityAlive __instance) { // Check if this feature is enabled. if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) { return(true); } // Check if there's a door in our way, then open it. if (__instance.GetAttackTarget() == null) { // If it's an animal, don't let them attack blocks EntityAliveFarmingAnimalSDX animal = __instance as EntityAliveFarmingAnimalSDX; if (animal) { if (__instance.GetAttackTarget() == null) { return(false); } } // If a door is found, try to open it. If it returns false, start attacking it. EntityAliveSDX myEntity = __instance as EntityAliveSDX; if (myEntity) { if (myEntity.OpenDoor()) { return(true); } } } if (__instance.GetAttackTarget() != null) { __instance.RotateTo(__instance.GetAttackTarget(), 30f, 30f); } return(true); }
private void BtnConfirmHireInformation_OnPressed(XUiController _sender, OnPressEventArgs _onPressEventArgs) { LocalPlayerUI uiforPlayer = base.xui.playerUI; // The respondent is an EntityNPC, and we don't have that. Check for the patch scripted otherEntitySDX. Entity respondent = uiforPlayer.xui.Dialog.Respondent; if (respondent == null) { respondent = uiforPlayer.xui.Dialog.otherEntitySDX; } if (respondent != null) { EntityAliveSDX myEntity = uiforPlayer.entityPlayer.world.GetEntity(respondent.entityId) as EntityAliveSDX; if (myEntity != null) { myEntity.SetOwner(uiforPlayer.entityPlayer as EntityPlayerLocal); } } base.xui.playerUI.windowManager.Close(this.windowGroup.ID); }