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) { x.SetOwner(player as EntityPlayerLocal); } } } }
// <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); } }
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); }