/// <summary> /// Launches a projectile from player to target /// </summary> public WorldObject LaunchProjectile(WorldObject weapon, WorldObject ammo, WorldObject target, out float time) { var proj = WorldObjectFactory.CreateNewWorldObject(ammo.WeenieClassId); proj.ProjectileSource = this; proj.ProjectileTarget = target; proj.ProjectileLauncher = weapon; var matchIndoors = Location.Indoors == target.Location.Indoors; var origin = matchIndoors ? Location.ToGlobal() : Location.Pos; origin.Z += Height; var dest = matchIndoors ? target.Location.ToGlobal() : target.Location.Pos; dest.Z += target.Height / GetAimHeight(target); var speed = 35.0f; // TODO: get correct speed var dir = GetDir2D(origin, dest); origin += dir * 2.0f; var velocity = GetProjectileVelocity(target, origin, dir, dest, speed, out time); proj.Velocity = velocity; proj.Location = matchIndoors ? Location.FromGlobal(origin) : new Position(Location.Cell, origin, Location.Rotation); if (!matchIndoors) { proj.Location.LandblockId = new LandblockId(proj.Location.GetCell()); } SetProjectilePhysicsState(proj, target); var result = LandblockManager.AddObject(proj); if (proj.PhysicsObj == null) { return(null); } var player = this as Player; var pkStatus = player?.PlayerKillerStatus ?? PlayerKillerStatus.Creature; proj.EnqueueBroadcast(new GameMessagePublicUpdatePropertyInt(proj, PropertyInt.PlayerKillerStatus, (int)pkStatus)); proj.EnqueueBroadcast(new GameMessageScript(proj.Guid, ACE.Entity.Enum.PlayScript.Launch, 0f)); // detonate point-blank projectiles immediately /*var radsum = target.PhysicsObj.GetRadius() + proj.PhysicsObj.GetRadius(); * var dist = Vector3.Distance(origin, dest); * if (dist < radsum) * { * Console.WriteLine($"Point blank"); * proj.OnCollideObject(target); * }*/ return(proj); }
private List <WorldObject> CreatePayoutCoinStacks(int amount) { const uint coinWeenieId = 273; var coinStacks = new List <WorldObject>(); while (amount > 0) { var currencyStack = WorldObjectFactory.CreateNewWorldObject(coinWeenieId); // payment contains a max stack if (currencyStack.MaxStackSize <= amount) { currencyStack.SetStackSize(currencyStack.MaxStackSize); coinStacks.Add(currencyStack); amount -= currencyStack.MaxStackSize.Value; } else // not a full stack { currencyStack.SetStackSize(amount); coinStacks.Add(currencyStack); amount -= amount; } } return(coinStacks); }
/// <summary> /// Spawns the semi-randomized monsters scattered around the outdoors<para /> /// This will be called from a separate task from our constructor. Use thread safety when interacting with this landblock. /// </summary> private void SpawnEncounters() { // get the encounter spawns for this landblock var encounters = DatabaseManager.World.GetCachedEncountersByLandblock(Id.Landblock); foreach (var encounter in encounters) { var wo = WorldObjectFactory.CreateNewWorldObject(encounter.WeenieClassId); if (wo == null) { continue; } var xPos = encounter.CellX * 24.0f; var yPos = encounter.CellY * 24.0f; var pos = new Physics.Common.Position(); pos.ObjCellID = (uint)(Id.Landblock << 16) | 1; pos.Frame = new Physics.Animation.AFrame(new Vector3(xPos, yPos, 0), Quaternion.Identity); pos.adjust_to_outside(); pos.Frame.Origin.Z = _landblock.GetZ(pos.Frame.Origin); wo.Location = new Position(pos.ObjCellID, pos.Frame.Origin, pos.Frame.Orientation); actionQueue.EnqueueAction(new ActionEventDelegate(() => { AddWorldObject(wo); })); } }
public House(uint slumlord_id, Player player) { Player = player; var house = new HouseData(); var instance = DatabaseManager.World.GetLandblockInstanceByGuid(slumlord_id); if (instance == null) { return; } house.Position = new Position(instance.ObjCellId, instance.OriginX, instance.OriginY, instance.OriginZ, instance.AnglesX, instance.AnglesY, instance.AnglesZ, instance.AnglesW); house.Type = HouseType.Cottage; var SlumLord = (SlumLord)WorldObjectFactory.CreateNewWorldObject(instance.WeenieClassId); if (SlumLord == null) { Console.WriteLine($"House constructor({slumlord_id:X8}): couldn't build slumlord"); return; } house.SetBuyItems(SlumLord.GetBuyItems()); house.SetRentItems(SlumLord.GetRentItems()); house.BuyTime = (uint)(player.HousePurchaseTimestamp ?? 0); house.RentTime = GetRentTimestamp(); HouseData = house; }
public void GenerateWieldList_CreateObject(BiotaPropertiesCreateList item, bool useRNG) { var wo = WorldObjectFactory.CreateNewWorldObject(item.WeenieClassId); if (wo != null) { if (item.Palette > 0) { wo.PaletteTemplate = item.Palette; } if (!useRNG && item.Shade > 0) { wo.Shade = item.Shade; } //TryAddToInventory(wo); if (wo.ValidLocations != null) { var equipped = TryWieldObject(wo, (EquipMask)wo.ValidLocations); //Console.WriteLine($"{Name} tried to equip {wo.Name}, result {equipped}"); } } }
/// <summary> /// Launches a projectile from player to target /// </summary> public WorldObject LaunchProjectile(WorldObject weapon, WorldObject ammo, WorldObject target, Vector3 origin, Quaternion orientation, Vector3 velocity) { var player = this as Player; if (!velocity.IsValid()) { if (player != null) { player.SendWeenieError(WeenieError.YourAttackMisfired); } return(null); } var proj = WorldObjectFactory.CreateNewWorldObject(ammo.WeenieClassId); proj.ProjectileSource = this; proj.ProjectileTarget = target; proj.ProjectileLauncher = weapon; proj.Location = new Position(Location.ObjCellID, origin, orientation, false, Location.Instance); SetProjectilePhysicsState(proj, target, velocity); var success = LandblockManager.AddObject(proj); if (!success || proj.PhysicsObj == null) { if (!proj.HitMsg && player != null) { player.Session.Network.EnqueueSend(new GameMessageSystemChat("Your missile attack hit the environment.", ChatMessageType.Broadcast)); } return(null); } if (!IsProjectileVisible(proj)) { proj.OnCollideEnvironment(); return(null); } var pkStatus = player?.PlayerKillerStatus ?? PlayerKillerStatus.Creature; proj.EnqueueBroadcast(new GameMessagePublicUpdatePropertyInt(proj, PropertyInt.PlayerKillerStatus, (int)pkStatus)); proj.EnqueueBroadcast(new GameMessageScript(proj.Guid, PlayScript.Launch, 0f)); // detonate point-blank projectiles immediately /*var radsum = target.PhysicsObj.GetRadius() + proj.PhysicsObj.GetRadius(); * var dist = Vector3.Distance(origin, dest); * if (dist < radsum) * { * Console.WriteLine($"Point blank"); * proj.OnCollideObject(target); * }*/ return(proj); }
private List <WorldObject> SpendCurrency(uint amount, WeenieType type) { if (CoinValue - amount >= 0) { List <WorldObject> currency = new List <WorldObject>(); currency.AddRange(GetInventoryItemsOfTypeWeenieType(type)); currency = currency.OrderBy(o => o.Value).ToList(); List <WorldObject> cost = new List <WorldObject>(); uint payment = 0; WorldObject changeobj = WorldObjectFactory.CreateNewWorldObject(273); uint change = 0; foreach (WorldObject wo in currency) { if (payment + wo.StackSize.Value <= amount) { // add to payment payment = payment + (uint)wo.StackSize.Value; cost.Add(wo); } else if (payment + wo.StackSize.Value > amount) { // add payment payment = payment + (uint)wo.StackSize.Value; cost.Add(wo); // calculate change if (payment > amount) { change = payment - amount; // add new change object. changeobj.StackSize = (ushort)change; wo.StackSize -= (ushort)change; } break; } else if (payment == amount) { break; } } // destroy all stacks of currency required / sale foreach (WorldObject wo in cost) { TryConsumeFromInventoryWithNetworking(wo); } // if there is change - readd - do this at the end to try to prevent exploiting if (change > 0) { TryCreateInInventoryWithNetworking(changeobj); } UpdateCurrencyClientCalculations(WeenieType.Coin); return(cost); } return(null); }
// ******************************************************************* OLD CODE BELOW ******************************** // ******************************************************************* OLD CODE BELOW ******************************** // ******************************************************************* OLD CODE BELOW ******************************** // ******************************************************************* OLD CODE BELOW ******************************** // ******************************************************************* OLD CODE BELOW ******************************** // ******************************************************************* OLD CODE BELOW ******************************** // ******************************************************************* OLD CODE BELOW ******************************** public void GenerateWieldList() { foreach (var item in Biota.BiotaPropertiesCreateList.Where(x => x.DestinationType == (int)DestinationType.Wield)) { var wo = WorldObjectFactory.CreateNewWorldObject(item.WeenieClassId); if (wo != null) { if (item.Palette > 0) { wo.PaletteTemplate = item.Palette; } if (item.Shade > 0) { wo.Shade = item.Shade; } if (wo.ValidLocations != null) { TryEquipObject(wo, (int)wo.ValidLocations.Value); } } } //if (EquippedObjects != null) // UpdateBaseAppearance(); todo see CalculateObjDesc() }
public List <WorldObject> GetCreateList(DestinationType type) { var items = new List <WorldObject>(); foreach (var item in Biota.BiotaPropertiesCreateList.Where(x => x.DestinationType == (int)type)) { var wo = WorldObjectFactory.CreateNewWorldObject(item.WeenieClassId); if (item.Palette > 0) { wo.PaletteTemplate = item.Palette; } if (item.Shade > 0) { wo.Shade = item.Shade; } if (item.StackSize > 0) { wo.SetStackSize(item.StackSize); } items.Add(wo); } return(items); }
public WorldObject CreateWieldedTreasure(TreasureWielded item) { var wo = WorldObjectFactory.CreateNewWorldObject(item.WeenieClassId); if (wo == null) { return(null); } if (item.PaletteId > 0) { wo.PaletteTemplate = (int)item.PaletteId; } if (item.Shade > 0) { wo.Shade = item.Shade; } if (item.StackSize > 0) { var stackSize = item.StackSize; var hasVariance = item.StackSizeVariance > 0; if (hasVariance) { var minStack = (int)Math.Max(Math.Round(item.StackSize * item.StackSizeVariance), 1); var maxStack = item.StackSize; stackSize = ThreadSafeRandom.Next(minStack, maxStack); } wo.SetStackSize(stackSize); } return(wo); }
public static void HandleSplits(Session session, params string[] parameters) { HashSet <uint> splitsTest = new HashSet <uint>() { 237, 300, 690, 20630, 20631, 37155, 31198 }; ActionChain chain = new ActionChain(); chain.AddAction(session.Player, () => { foreach (uint weenieId in splitsTest) { WorldObject loot = WorldObjectFactory.CreateNewWorldObject(weenieId); var valueEach = loot.Value / loot.StackSize; loot.StackSize = loot.MaxStackSize; loot.Value = loot.StackSize * valueEach; loot.ContainerId = session.Player.Guid.Full; loot.Placement = 0; session.Player.AddToInventory(loot); session.Player.TrackObject(loot); session.Network.EnqueueSend( new GameMessagePutObjectInContainer(session, session.Player.Guid, loot, 0), new GameMessageUpdateInstanceId(loot.Guid, session.Player.Guid, PropertyInstanceId.Container)); } }); chain.EnqueueChain(); }
public static void HandleInv(Session session, params string[] parameters) { HashSet <uint> weaponsTest = new HashSet <uint>() { 44, 45, 46, 15268, 15269, 15270, 15271, 12748, 5893, 136 }; foreach (uint weenieId in weaponsTest) { WorldObject loot = WorldObjectFactory.CreateNewWorldObject(weenieId); loot.ContainerId = session.Player.Guid.Full; loot.PlacementPosition = 0; session.Player.AddToInventory(loot); session.Player.TrackObject(loot); ActionChain chain = new ActionChain(); chain.AddDelaySeconds(0.25); ////session.Player.UpdatePlayerBurden(); chain.AddAction(session.Player, () => { session.Network.EnqueueSend( new GameMessagePutObjectInContainer(session, session.Player.Guid, loot, 0), new GameMessageUpdateInstanceId(loot.Guid, session.Player.Guid, PropertyInstanceId.Container)); }); chain.EnqueueChain(); } }
private void GenerateContainList() { foreach (var item in Biota.BiotaPropertiesCreateList.Where(x => x.DestinationType == (sbyte)DestinationType.Contain || x.DestinationType == (sbyte)DestinationType.ContainTreasure)) { var wo = WorldObjectFactory.CreateNewWorldObject(item.WeenieClassId); if (wo == null) { continue; } if (item.Palette > 0) { wo.PaletteTemplate = item.Palette; } if (item.Shade > 0) { wo.Shade = item.Shade; } if (item.StackSize > 1) { wo.StackSize = (ushort)item.StackSize; } TryAddToInventory(wo); } }
public void GenerateWieldList() { if (Biota.PropertiesCreateList == null) { return; } var wielded = Biota.PropertiesCreateList.Where(i => (i.DestinationType & DestinationType.Wield) != 0).ToList(); var items = CreateListSelect(wielded); foreach (var item in items) { var wo = WorldObjectFactory.CreateNewWorldObject(item); if (wo != null) { TryAddToInventory(wo); } // handled in EquipInventoryItems() /*var equipped = false; * * if (wo.ValidLocations != null) * equipped = TryWieldObject(wo, (EquipMask)wo.ValidLocations); * * if (!equipped)*/ } }
/// <summary> /// Consumes the source weapon, and creates an intermediate tailoring kit /// to apply to the destination weapon /// </summary> public static void TailorWeapon(Player player, WorldObject source, WorldObject target) { //Console.WriteLine($"TailorWeapon({player.Name}, {source.Name}, {target.Name})"); // ensure target is valid weapon if (!(target is MeleeWeapon) && !(target is MissileLauncher) && !(target is Caster)) { player.SendUseDoneEvent(WeenieError.YouDoNotPassCraftingRequirements); return; } if (target is MeleeWeapon && target.W_WeaponType == WeaponType.Undef) { // 'difficult to master' weapons were not tailorable player.SendUseDoneEvent(WeenieError.YouDoNotPassCraftingRequirements); return; } // create intermediate weapon tailoring kit var wo = WorldObjectFactory.CreateNewWorldObject(51451); SetWeaponProperties(target, wo); player.Session.Network.EnqueueSend(new GameMessageSystemChat("You tailor the appearance off the weapon.", ChatMessageType.Broadcast)); Finalize(player, source, target, wo); }
/// <summary> /// Consumes the source weapon, and creates an intermediate tailoring kit /// to apply to the destination weapon /// </summary> public static void TailorWeapon(Player player, WorldObject source, WorldObject target) { //Console.WriteLine($"TailorWeapon({player.Name}, {source.Name}, {target.Name})"); // ensure target is valid weapon if (!(target is MeleeWeapon) && !(target is MissileLauncher) && !(target is Caster)) { player.SendUseDoneEvent(WeenieError.YouDoNotPassCraftingRequirements); return; } // create intermediate weapon tailoring kit var wo = WorldObjectFactory.CreateNewWorldObject(51451); SetCommonProperties(target, wo); if (target is MeleeWeapon) { wo.W_WeaponType = target.W_WeaponType; } else if (target is MissileLauncher) { wo.DefaultCombatStyle = target.DefaultCombatStyle; } wo.W_DamageType = target.W_DamageType; wo.ObjScale = target.ObjScale; Finalize(player, source, target, wo); }
public List <WorldObject> GetCreateListForSlumLord(DestinationType type) { var items = new List <WorldObject>(); foreach (var item in Biota.PropertiesCreateList.Where(x => x.DestinationType == type)) { var wo = WorldObjectFactory.CreateNewWorldObject(item.WeenieClassId); if (item.Palette > 0) { wo.PaletteTemplate = item.Palette; } if (item.Shade > 0) { wo.Shade = item.Shade; } if (item.StackSize > 0) { if (wo is Stackable) { wo.SetStackSize(item.StackSize); } else { wo.StackSize = item.StackSize; // item isn't a stackable object, but we want multiples of it while not displaying multiple single items in the profile. Munge stacksize to get us there. } } items.Add(wo); } return(items); }
public void GenerateWieldList() { if (Biota.PropertiesCreateList == null) { return; } var wielded = Biota.PropertiesCreateList.Where(i => (i.DestinationType & DestinationType.Wield) != 0).ToList(); var items = CreateListSelect(wielded); foreach (var item in items) { var wo = WorldObjectFactory.CreateNewWorldObject(item); if (wo == null) { continue; } //if (wo.ValidLocations == null || (ItemCapacity ?? 0) > 0) TryAddToInventory(wo); //else //TryWieldObject(wo, (EquipMask)wo.ValidLocations); } }
public void GenerateContainList() { if (Biota.PropertiesCreateList == null) { return; } foreach (var item in Biota.PropertiesCreateList.Where(x => x.DestinationType == DestinationType.Contain || x.DestinationType == DestinationType.ContainTreasure)) { var wo = WorldObjectFactory.CreateNewWorldObject(item.WeenieClassId); if (wo == null) { continue; } if (item.Palette > 0) { wo.PaletteTemplate = item.Palette; } if (item.Shade > 0) { wo.Shade = item.Shade; } if (item.StackSize > 1) { wo.SetStackSize(item.StackSize); } TryAddToInventory(wo); } }
public static void HandleWeapons(Session session, params string[] parameters) { HashSet <uint> weaponsTest = new HashSet <uint>() { 93, 127, 130, 136, 136, 136, 148, 300, 307, 311, 326, 338, 348, 350, 7765, 12748, 12463, 31812 }; ////HashSet<uint> weaponsTest = new HashSet<uint>() { (uint)TestWeenieClassIds.Pants, //// (uint)TestWeenieClassIds.Tunic, //// (uint)TestWeenieClassIds.TrainingWand, //// (uint)TestWeenieClassIds.ColoBackpack }; foreach (uint weenieId in weaponsTest) { WorldObject loot = WorldObjectFactory.CreateNewWorldObject(weenieId); loot.ContainerId = session.Player.Guid.Full; loot.PlacementPosition = 0; // TODO: Og II // Need this hack because weenies are not cleaned up. Can be removed once weenies are fixed. loot.WielderId = null; loot.CurrentWieldedLocation = null; session.Player.AddToInventory(loot); session.Player.TrackObject(loot); ////session.Player.UpdatePlayerBurden(); session.Network.EnqueueSend( new GameMessagePutObjectInContainer(session, session.Player.Guid, loot, 0), new GameMessageUpdateInstanceId(loot.Guid, session.Player.Guid, PropertyInstanceId.Container)); } // Force a save for our test items. Og II // DatabaseManager.Shard.SaveObject(session.Player.GetSavableCharacter(), null); }
public void GenerateWieldList() { var wielded = Biota.BiotaPropertiesCreateList.Where(i => (i.DestinationType & (int)DestinationType.Wield) != 0).ToList(); var items = CreateListSelect(wielded); foreach (var item in items) { var wo = WorldObjectFactory.CreateNewWorldObject(item); if (wo == null) { continue; } var equipped = false; if (wo.ValidLocations != null) { equipped = TryWieldObject(wo, (EquipMask)wo.ValidLocations); } if (!equipped) { TryAddToInventory(wo); } } }
/// <summary> /// Load Inventory for default items from database table / assignes default objects. /// </summary> private void LoadInventory() { // Load Vendor Inventory from database. if (!inventoryloaded) { foreach (var item in Biota.BiotaPropertiesCreateList.Where(x => x.DestinationType == (int)DestinationType.Shop)) { WorldObject wo = WorldObjectFactory.CreateNewWorldObject(item.WeenieClassId); if (wo != null) { if (item.Palette > 0) { wo.PaletteTemplate = item.Palette; } if (item.Shade > 0) { wo.Shade = item.Shade; } wo.ContainerId = Guid.Full; wo.CalculateObjDesc(); // i don't like firing this but this triggers proper icons, the way vendors load inventory feels off to me in this method. defaultItemsForSale.Add(wo.Guid, wo); } } inventoryloaded = true; } }
public void GenerateWieldList() { foreach (var item in Biota.BiotaPropertiesCreateList.Where(x => x.DestinationType == (int)DestinationType.Wield || x.DestinationType == (int)DestinationType.WieldTreasure)) { var wo = WorldObjectFactory.CreateNewWorldObject(item.WeenieClassId); if (wo != null) { if (item.Palette > 0) { wo.PaletteTemplate = item.Palette; } if (item.Shade > 0) { wo.Shade = item.Shade; } if (wo.ValidLocations != null) { TryEquipObject(wo, (int)wo.ValidLocations.Value); } } } }
/// <summary> /// Returns the full allegiance structure for any player /// </summary> /// <param name="player">A player at any level of an allegiance</param> public static Allegiance GetAllegiance(IPlayer player) { if (player == null) { return(null); } var monarch = GetMonarch(player); if (monarch == null) { return(null); } // is this allegiance already loaded / cached? if (Players.ContainsKey(monarch.Guid)) { return(Players[monarch.Guid].Allegiance); } // try to load biota var allegianceID = DatabaseManager.Shard.BaseDatabase.GetAllegianceID(monarch.Guid.Full); var biota = allegianceID != null?DatabaseManager.Shard.BaseDatabase.GetBiota(allegianceID.Value) : null; Allegiance allegiance; if (biota != null) { var entityBiota = ACE.Database.Adapter.BiotaConverter.ConvertToEntityBiota(biota); allegiance = new Allegiance(entityBiota); } else { allegiance = new Allegiance(monarch.Guid); } if (allegiance.TotalMembers == 1) { return(null); } if (biota == null) { allegiance = WorldObjectFactory.CreateNewWorldObject("allegiance") as Allegiance; allegiance.MonarchId = monarch.Guid.Full; allegiance.Init(monarch.Guid); allegiance.SaveBiotaToDatabase(); } AddPlayers(allegiance); //if (!Allegiances.ContainsKey(allegiance.Guid)) //Allegiances.Add(allegiance.Guid, allegiance); Allegiances[allegiance.Guid] = allegiance; return(allegiance); }
public void Init(Weenie weenie, ushort stackSize = 1) { var wo = WorldObjectFactory.CreateNewWorldObject(weenie.ClassName); wo.SetStackSize(stackSize); WeenieID = weenie.ClassId; Init(wo); }
private static void CreateIOU(Player player, uint missingWeenieId) { var book = (Book)WorldObjectFactory.CreateNewWorldObject("parchment"); book.SetProperties("IOU", "An IOU for a missing database object.", "Sorry about that chief...", "ACEmulator", "prewritten"); book.AddPage(player.Guid.Full, "ACEmulator", "prewritten", false, $"{missingWeenieId}\n\nSorry but the database does not have a weenie for weenieClassId #{missingWeenieId} so in lieu of that here is an IOU for that item."); player.TryAddToInventory(book); }
public bool HandleUseCreateItem(Player player) { var amount = UseCreateQuantity ?? 1; var itemsToReceive = new ItemsToReceive(player); itemsToReceive.Add(UseCreateItem.Value, amount); if (itemsToReceive.PlayerExceedsLimits) { if (itemsToReceive.PlayerExceedsAvailableBurden) { player.Session.Network.EnqueueSend(new GameEventCommunicationTransientString(player.Session, "You are too encumbered to use that!")); } else if (itemsToReceive.PlayerOutOfInventorySlots) { player.Session.Network.EnqueueSend(new GameEventCommunicationTransientString(player.Session, "You do not have enough pack space to use that!")); } else if (itemsToReceive.PlayerOutOfContainerSlots) { player.Session.Network.EnqueueSend(new GameEventCommunicationTransientString(player.Session, "You do not have enough container slots to use that!")); } return(false); } if (itemsToReceive.RequiredSlots > 0) { var remaining = amount; while (remaining > 0) { var item = WorldObjectFactory.CreateNewWorldObject(UseCreateItem.Value); if (item is Stackable) { var stackSize = Math.Min(remaining, item.MaxStackSize ?? 1); item.SetStackSize(stackSize); remaining -= stackSize; } else { remaining--; } player.TryCreateInInventoryWithNetworking(item); } } else { player.SendTransientError($"Unable to use {Name} at this time!"); return(false); } return(true); }
/// <summary> /// Gives default ranged ammo if none in wielded treasure /// </summary> public void GiveAmmo() { var ammo = GetEquippedAmmo(); if (ammo != null) { return; } ammo = WorldObjectFactory.CreateNewWorldObject(300); TryEquipObject(ammo, (int)EquipMask.MissileAmmo); SetChild(ammo, (int)ammo.CurrentWieldedLocation, out var placementId, out var parentLocation); }
private static void AddWeeniesToInventory(Session session, HashSet <uint> weenieIds) { foreach (uint weenieId in weenieIds) { var loot = WorldObjectFactory.CreateNewWorldObject(weenieId); if (loot == null) // weenie doesn't exist { continue; } session.Player.TryCreateInInventoryWithNetworking(loot); } }
/// <summary> /// Spawns the semi-randomized monsters scattered around the outdoors<para /> /// This will be called from a separate task from our constructor. Use thread safety when interacting with this landblock. /// </summary> private void SpawnEncounters() { // get the encounter spawns for this landblock var encounters = DatabaseManager.World.GetCachedEncountersByLandblock(Id.Landblock); foreach (var encounter in encounters) { var wo = WorldObjectFactory.CreateNewWorldObject(encounter.WeenieClassId); if (wo == null) { continue; } var xPos = Math.Clamp(encounter.CellX * 24.0f, 0.5f, 191.5f); var yPos = Math.Clamp(encounter.CellY * 24.0f, 0.5f, 191.5f); var pos = new Physics.Common.Position(); pos.ObjCellID = (uint)(Id.Landblock << 16) | 1; pos.Frame = new Physics.Animation.AFrame(new Vector3(xPos, yPos, 0), Quaternion.Identity); pos.adjust_to_outside(); pos.Frame.Origin.Z = _landblock.GetZ(pos.Frame.Origin); wo.Location = new Position(pos.ObjCellID, pos.Frame.Origin, pos.Frame.Orientation); var sortCell = LScape.get_landcell(pos.ObjCellID) as SortCell; if (sortCell != null && sortCell.has_building()) { continue; } if (PropertyManager.GetBool("override_encounter_spawn_rates").Item) { wo.RegenerationInterval = PropertyManager.GetDouble("encounter_regen_interval").Item; wo.ReinitializeHeartbeats(); foreach (var profile in wo.Biota.BiotaPropertiesGenerator) { profile.Delay = (float)PropertyManager.GetDouble("encounter_delay").Item; } } actionQueue.EnqueueAction(new ActionEventDelegate(() => { AddWorldObject(wo); })); } }