public void ShowLoot(LootContainer loot) { //this can actually get called before Start(), so make sure the ref is set here cargoList = GetComponent<CargoHoldList>(); this.loot = loot; title.text = loot.name; gameObject.SetActive(true); cargoList.Refresh(); }
public virtual void SpawnLoot() { if (this.inventory == null) { Debug.Log("CONTACT DEVELOPERS! LootContainer::PopulateLoot has null inventory!!!"); return; } this.inventory.Clear(); ItemManager.DoRemoves(); if (Interface.CallHook("OnLootSpawn", this) != null) { return; } this.PopulateLoot(); if (this.shouldRefreshContents) { LootContainer lootContainer = this; base.Invoke(new Action(lootContainer.SpawnLoot), UnityEngine.Random.Range(this.minSecondsBetweenRefresh, this.maxSecondsBetweenRefresh)); } }
public static void lootContainerOpened(TileEntityLootContainer _te, LocalPlayerUI _playerUI, int _entityIdThatOpenedIt) { if (_playerUI != null) { bool flag = true; string lootContainerName = string.Empty; if (_te.entityId != -1) { Entity entity = GameManager.Instance.World.GetEntity(_te.entityId); if (entity != null) { lootContainerName = Localization.Get(EntityClass.list[entity.entityClass].entityClassName, ""); if (entity is EntityVehicle) { flag = false; } } } else { BlockValue block = GameManager.Instance.World.GetBlock(_te.ToWorldPos()); lootContainerName = Localization.Get(Block.list[block.type].GetBlockName(), ""); } if (flag) { ((XUiC_LootWindowGroup)((XUiWindowGroup)_playerUI.windowManager.GetWindow("looting")).Controller).SetTileEntityChest(lootContainerName, _te); _playerUI.windowManager.Open("looting", true, false, true); } LootContainer lootContainer = LootContainer.lootList[_te.lootListIndex]; if (lootContainer != null && _playerUI.entityPlayer != null) { lootContainer.ExecuteBuffActions(_te.entityId, _playerUI.entityPlayer); } } if (SingletonMonoBehaviour <ConnectionManager> .Instance.IsServer) { GameManager.Instance.lootManager.LootContainerOpened(_te, _entityIdThatOpenedIt); _te.bTouched = true; _te.SetModified(); } }
// Explode barrel void explodeBarrel(LootContainer entity, Vector3 position) { BarrelEffect effect = data.barrelEffects[barrels[entity.net.ID]]; if (effect.killInventory) { entity.inventory.Kill(); // destroy inventory } barrels.Remove(entity.net.ID); Effect.server.Run(effect.triggerEffect, position); timer.Once(effect.delay, delegate() { // run effects foreach (object eff in effect.effects) { Effect.server.Run(eff.ToString(), position); } // damage nearby entities doDamage(entity, position, effect); }); }
void OnLootSpawn(LootContainer container) { if (container.ShortPrefabName == "stocking_large_deployed" || container.ShortPrefabName == "stocking_small_deployed") { return; } if (cfg.ListContainers.Contains(container.ShortPrefabName)) { if (UnityEngine.Random.Range(0f, 100f) < cfg.Chance) { if (container.inventory.itemList.Count == container.inventory.capacity) { container.inventory.capacity++; } Item i = ItemManager.CreateByName("coal", 1, cfg.skinId); i.name += cfg.itemName += "\n"; i.MoveToContainer(container.inventory); } } }
private void EmptyJunkPile(LootContainer lootContainer) { if (!configData.emptyJunkpile) { return; } var junkPiles = Facepunch.Pool.GetList <JunkPile>(); Vis.Entities(lootContainer.transform.position, 5f, junkPiles); if (junkPiles.Count > 0) { var junkPile = junkPiles[0]; if (junkPile?.net?.ID != null) { var junkPileID = junkPile.net.ID; if (!lootDestroyTimer.ContainsKey(junkPileID)) { lootDestroyTimer.Add(junkPileID, timer.Once(configData.timeBeforeJunkpileEmpty, () => { if (junkPile == null || junkPile.IsDestroyed) { return; } if (configData.dropNearbyLoot) { var lootContainers = Facepunch.Pool.GetList <LootContainer>(); Vis.Entities(junkPile.transform.position, 5f, lootContainers); foreach (var loot in lootContainers) { DropUtil.DropItems(loot.inventory, loot.transform.position); } Facepunch.Pool.FreeList(ref lootContainers); } junkPile.SinkAndDestroy(); })); } } } Facepunch.Pool.FreeList(ref junkPiles); }
void UpdateLoot(LootContainer container, BasePlayer player) { if (handledContainers.Contains(container) || container.ShortPrefabName == "stocking_large_deployed" || container.ShortPrefabName == "stocking_small_deployed") { return; } var multiplier = GetMultiplier(player); AddComponents(container, player); foreach (var item in container.inventory.itemList.Where(i => i != null)) { if (componentEx.IsMatch(item.info.shortname)) { if (!componentAmount.ContainsKey(item.info.shortname)) { componentAmount[item.info.shortname] = item.amount; } item.amount = componentAmount[item.info.shortname] * multiplier; } } handledContainers.Add(container); }
void PopulateLoot(LootContainer loot, int mul = 1) { if (handledContainers.Contains(loot) || loot.ShortPrefabName == "stocking_large_deployed" || loot.ShortPrefabName == "stocking_small_deployed") { return; } handledContainers.Add(loot); var inv = loot.inventory; for (int i = inv.itemList.Count - 1; i >= 0; i--) { inv.itemList[i].Remove(); } inv.itemList.Clear(); LootStorage lootStorage; if (lootConfig.TryGetValue(loot.ShortPrefabName, out lootStorage)) { if (loot.ShortPrefabName.Contains("barrel")) { loot.inventory.capacity = 2; } if (loot.ShortPrefabName.Contains("crate_normal")) { loot.inventory.capacity = 4; } bool set; foreach (var lootItem in lootStorage.GetRandomItems(inv.capacity, out set)) { var def = itemDefinitions[lootItem.shortname]; var amount = Math.Min(set ? lootItem.amount : lootItem.amount * mul, def.stackable); inv.AddItem(def, amount); } } else { loot.PopulateLoot(); } }
private bool IsLootContainerEnabled(LootContainer container) { CrateData data = null; if (!Crates.list.TryGetValue(container.ShortPrefabName.ToString(), out data) || data == null) { if (Convert.ToBoolean(Config["_Settings", "ReportMissingConfigCrates"])) { Puts("Auto added " + container.ShortPrefabName.ToString() + " to config."); } Crates.list.Add(container.ShortPrefabName.ToString(), new CrateData()); Config["LootContainersEnabled"] = Crates; SaveConfig(); } /* * if (!enabled) * Puts("" + container.ShortPrefabName.ToString() + " is not enabled; MagicLoot skipped"); */ return(data != null && data.enabled != null && data.enabled); }
private void SpawnItem(LootContainer container, int itemsToSpawn = 1) { if (container.lootDefinition != null) { for (int i = 0; i < itemsToSpawn; i++) { container.lootDefinition.SpawnIntoContainer(container.inventory); } } if (container.SpawnType == LootContainer.spawnType.ROADSIDE || container.SpawnType == LootContainer.spawnType.TOWN) { foreach (Item item in container.inventory.itemList) { if (!item.hasCondition) { continue; } item.condition = UnityEngine.Random.Range(item.info.condition.foundCondition.fractionMin, item.info.condition.foundCondition.fractionMax) * item.info.condition.max; } } }
private void AssignLoot(LootContainer container) { if (_config.Options.BlockedItems == null || !_config.Options.BlockedItems.Any()) { return; } if (container == null || container.inventory == null) { return; } foreach (var item in new List <Item>(container.inventory.itemList)) { if (_config.Options.BlockedItems.Contains(item.info.shortname)) { item.RemoveFromContainer(); } } container.inventory.dirty = true; }
private void OnLootEntity(BasePlayer player, LootContainer lootContainer) { if (lootContainer?.net == null || player == null) { return; } var result = Trade?.Call("IsTradeBox", lootContainer); if (result != null && result is bool && (bool)result) { return; } if (lootContainer?.inventory?.itemList == null) { return; } if (configData.lootContainerSettings.ContainsKey(lootContainer.ShortPrefabName) && !configData.lootContainerSettings[lootContainer.ShortPrefabName]) { return; } var entityID = lootContainer.net.ID; if (!lootEntities.ContainsKey(entityID)) { lootEntities.Add(entityID, lootContainer.inventory.itemList.Count); } if (!entityPlayers.ContainsKey(entityID)) { entityPlayers.Add(entityID, new HashSet <ulong> { player.userID }); } else { entityPlayers[entityID].Add(player.userID); } }
static bool Prefix(LootContainer __instance, ref int countToSpawn, EntityPlayer player) { if (player == null) { return(true); } EntityPlayerLocal _player = player as EntityPlayerLocal; ProgressionValue masterProgression = _player.Progression.GetProgressionValue("LModMaster"); //set in progression.xml ProgressionValue perkProgression = _player.Progression.GetProgressionValue("LModLootAbundance"); //set in progression.xml if (masterProgression == null || perkProgression == null) { return(true); } float value = 1.0f + (Math.Max(1, perkProgression.Level) / 10); countToSpawn = Mathf.FloorToInt((float)countToSpawn * value); return(true); }
void OnLootEntity(BasePlayer player, BaseEntity entity) { if (State != PromocodeEventState.Active) { return; } var container = entity as LootContainer; if (container == null) { return; } if (PromocodeLootContainer != container) { return; } PromocodeItem.MoveToContainer(PromocodeLootContainer.inventory); DestroyHintTimer(); OnHint(); this.Broadcast("PROMOCODE.CONTAINER.LOOTED", player.displayName); this.Log("loot", $"{player.userID}/{player.displayName} loot promocode container ({PromocodeLootContainer.GetNetworkPosition()})", true); PromocodeLootContainer = null; }
private string GetHeader(LootContainer loot) { string output = ""; output += "["; output += "min=" + loot.minCount + _sep; output += "max=" + loot.maxCount + _sep; output += "size=(" + loot.size.x + "x" + loot.size.y + ")" + _sep; output += "opentime=" + loot.openTime + _sep; output += "soundopen=" + loot.soundOpen + _sep; output += "soundclose=" + loot.soundClose + _sep; output += "destroy=" + loot.bDestroyOnClose; if (loot.BuffActions != null) { if (loot.BuffActions.Count > 0) { output += _sep + "buffactions(" + loot.BuffActions.Count + ")={"; bool first = true; foreach (MultiBuffClassAction buff in loot.BuffActions) { if (!first) { output += _sep; } else { first = false; } output += "" + buff.Class.Id + "(" + buff.Chance + ")"; } output += "}"; } } output += "]"; return(output); }
private void assignTraps(LootContainer drop) { uint boxID = drop.net.ID; int randomTrap = randomTrapCheck(); bTraps trapInfo; if (!tempTraps.TryGetValue(boxID, out trapInfo)) { trapInfo = new bTraps { ID = boxID } } ; trapInfo.Position = drop.transform.position; trapInfo.Name = drop.panelName; trapInfo.Trap = randomTrap; trapInfo.TrapOwner = "boobytraps"; tempTraps[boxID] = trapInfo; var trapName = convertToName(trapInfo.Trap.ToString()); Puts("Random trap set at " + drop.transform.position + " using trap: " + trapName); }
object OnLootSpawn(LootContainer container) { if (INIT) { if (container?.inventory?.itemList == null) { return(null); } if (!IsLootContainerEnabled(container)) { return(null); } RepopulateContainer(container); // Debug msg if (Convert.ToBoolean(Config["DeveloperDebug", "_EnableLogs"]) && Convert.ToBoolean(Config["DeveloperDebug", "LootRefresh"])) { string debugs = "Repopulated: " + container.ToString() + " : isLootable[" + container.isLootable + "]"; Puts(debugs); } if (container.shouldRefreshContents && container.isLootable) { // Debug msg if (Convert.ToBoolean(Config["DeveloperDebug", "_EnableLogs"]) && Convert.ToBoolean(Config["DeveloperDebug", "LootRefresh"])) { string debugs = "Invoked refresh on " + container.ToString(); Puts(debugs); } container.Invoke(new Action(container.SpawnLoot), UnityEngine.Random.Range(container.minSecondsBetweenRefresh, container.maxSecondsBetweenRefresh)); } return(container); } return(null); }
private void OnLootSpawn(LootContainer lootContainer) { if (lootContainer?.inventory?.itemList == null) { return; } foreach (var item in lootContainer.inventory.itemList.ToList()) { item.RemoveFromWorld(); item.RemoveFromContainer(); } lootContainer.PopulateLoot(); foreach (var item in lootContainer.inventory.itemList.ToList()) { var itemBlueprint = ItemManager.FindItemDefinition(item.info.shortname).Blueprint; if (_configuration.ReplaceItems && itemBlueprint != null && itemBlueprint.isResearchable) { var slot = item.position; item.RemoveFromWorld(); item.RemoveFromContainer(); var blueprint = ItemManager.CreateByName("blueprintbase"); blueprint.blueprintTarget = item.info.itemid; blueprint.MoveToContainer(lootContainer.inventory, slot); } else { object multiplier; if (_configuration.Multipliers.TryGetValue(item.info.shortname, out multiplier)) { item.amount *= Convert.ToInt32(multiplier); } } } }
/// <summary> /// This function is called when players take over a sap successfully /// </summary> private void HandleTakeOver(SAP sap) { Logger.Info($"Intrusion SAP taken. sap = {sap.Eid} {sap.ED.Name} "); using (var scope = Db.CreateTransaction()) { try { var gen = new LootGenerator(_lootService.GetIntrusionLootInfos(this, sap)); LootContainer.Create().AddLoot(gen).BuildAndAddToZone(Zone, sap.CurrentPosition); var winnerCorporation = sap.GetWinnerCorporation(); if (winnerCorporation == null) { return; } var siteInfo = GetIntrusionSiteInfo(); var oldStability = siteInfo.Stability; var newStability = siteInfo.Stability; var newOwner = siteInfo.Owner; var oldOwner = siteInfo.Owner; var logEvent = new IntrusionLogEvent { OldOwner = siteInfo.Owner, NewOwner = siteInfo.Owner, SapDefinition = sap.Definition, EventType = IntrusionEvents.sapTakeOver, WinnerCorporationEid = winnerCorporation.Eid, OldStability = oldStability }; if (winnerCorporation is PrivateCorporation) { //Compare the Owner and Winner corp's relations var ownerEid = siteInfo.Owner ?? default(long); var ownerAndWinnerGoodRelation = false; var friendlyOnly = 10; //Compare both relations between corps: //True IFF both corps have strictly friendly relations with eachother ownerAndWinnerGoodRelation = _corporationManager.IsStandingMatch(winnerCorporation.Eid, ownerEid, friendlyOnly); ownerAndWinnerGoodRelation = _corporationManager.IsStandingMatch(ownerEid, winnerCorporation.Eid, friendlyOnly) && ownerAndWinnerGoodRelation; //Stability increase if winner is owner OR winner is in good standing with owner if (winnerCorporation.Eid == siteInfo.Owner || ownerAndWinnerGoodRelation) { newStability = (newStability + sap.StabilityChange).Clamp(0, 100); } else { newStability = (newStability - sap.StabilityChange).Clamp(0, 100); // csak akkor ha 0 lett a stability if (newStability == 0) { if (siteInfo.Owner != null) { // ha van owner akkor eloszor toroljuk a regit es majd a kovetkezo korben kap ujat logEvent.EventType = IntrusionEvents.siteOwnershipLost; newOwner = null; } else { // itt kap uj ownert es egy kezdo stability erteket logEvent.EventType = IntrusionEvents.siteOwnershipGain; newOwner = winnerCorporation.Eid; newStability = STARTING_STABILITY; } } } //set the resulting values SetIntrusionOwnerAndPoints(newOwner, newStability); ReactStabilityChanges(siteInfo, oldStability, newStability, newOwner, oldOwner); } logEvent.NewOwner = newOwner; logEvent.NewStability = newStability; InsertIntrusionLog(logEvent); foreach (var playerInfo in sap.GetPlayersWithScore()) { var ep = playerInfo.corporationEid == winnerCorporation.Eid ? EP_WINNER : EP_LOSER; var character = playerInfo.character; character.AddExtensionPointsBoostAndLog(EpForActivityType.Intrusion, ep); } //make dem toast anyways Transaction.Current.OnCommited(() => { if (oldStability != newStability) { OnIntrusionSiteInfoUpdated(); InformAllPlayers(); } InformPlayersOnZone(Commands.ZoneSapActivityEnd, new Dictionary <string, object> { { k.siteEID, Eid }, { k.eventType, (int)logEvent.EventType }, { k.eid, sap.Eid }, { k.winner, winnerCorporation.Eid }, }); }); scope.Complete(); } catch (Exception ex) { Logger.Exception(ex); } } }
private void GetSoundClose(LootContainer loot) => Bin.Add("SoundClose", SoundClose = loot.soundClose);
private void GetId(LootContainer loot) => Bin.Add("Id", Id = loot.Id);
private void GetSoundOpen(LootContainer loot) => Bin.Add("SoundOpen", SoundOpen = loot.soundOpen);
private void UpdateLootContainer(Dictionary <string, LootContainerData> containerData, LootContainer container, Dictionary <string, LootSpawn> lootSpawns) { if (container == null) { return; } LootContainerData containerConfig; if (containerData == null || !containerData.TryGetValue(container.PrefabName, out containerConfig)) { Puts("No container data found: {0}", container.PrefabName); return; } container.maxDefinitionsToSpawn = containerConfig.MaxDefinitionsToSpawn; container.minSecondsBetweenRefresh = containerConfig.MinSecondsBetweenRefresh; container.maxSecondsBetweenRefresh = containerConfig.MaxSecondsBetweenRefresh; container.destroyOnEmpty = containerConfig.DestroyOnEmpty; container.distributeFragments = containerConfig.DistributeFragments; container.lootDefinition = GetLootSpawn(containerConfig.LootDefinition, lootSpawns); container.inventorySlots = containerConfig.InventorySlots; container.SpawnType = containerConfig.SpawnType; if (!container.gameObject.activeInHierarchy || container.inventory == null) { return; } container.inventory.capacity = containerConfig.InventorySlots; container.CancelInvoke("SpawnLoot"); container.SpawnLoot(); }
bool PopulateContainer(LootContainer container) { Dictionary <string, object> con; object containerobj; int lootitemcount; if (!lootTables.TryGetValue(container.PrefabName, out containerobj)) { return(false); } con = containerobj as Dictionary <string, object>; if (!(bool)con["Enabled"]) { return(false); } lootitemcount = (int)(con["ItemList"] as Dictionary <string, object>).Count(); int itemCount = Mathf.RoundToInt(UnityEngine.Random.Range(Convert.ToSingle(Mathf.Min((int)con["ItemsMin"], (int)con["ItemsMax"])) * 100f, Convert.ToSingle(Mathf.Max((int)con["ItemsMin"], (int)con["ItemsMax"])) * 100f) / 100f); if (lootitemcount > 0 && itemCount > lootitemcount && lootitemcount < 36) { itemCount = lootitemcount; } if (container.inventory == null) { container.inventory = new ItemContainer(); container.inventory.ServerInitialize(null, 36); container.inventory.GiveUID(); } else { while (container.inventory.itemList.Count > 0) { var item = container.inventory.itemList[0]; item.RemoveFromContainer(); item.Remove(0f); } container.inventory.capacity = 36; } var items = new List <Item>(); var itemNames = new List <string>(); var itemBlueprints = new List <int>(); var maxRetry = 10; for (int i = 0; i < itemCount; ++i) { if (maxRetry == 0) { break; } var item = MightyRNG(container.PrefabName, itemCount, (bool)(itemBlueprints.Count >= (int)con["MaxBPs"])); if (item == null) { --maxRetry; --i; continue; } if (itemNames.Contains(item.info.shortname) || (item.IsBlueprint() && itemBlueprints.Contains(item.blueprintTarget))) { item.Remove(0f); --maxRetry; --i; continue; } else if (item.IsBlueprint()) { itemBlueprints.Add(item.blueprintTarget); } else { itemNames.Add(item.info.shortname); } items.Add(item); } foreach (var item in items.Where(x => x != null && x.IsValid())) { item.MoveToContainer(container.inventory, -1, false); } if ((int)con["Scrap"] > 0) { int scrapCount = (int)con["Scrap"]; Item item = ItemManager.Create(ItemManager.FindItemDefinition("scrap"), scrapCount, 0uL); item.MoveToContainer(container.inventory, -1, false); } container.inventory.capacity = container.inventory.itemList.Count; container.inventory.MarkDirty(); container.SendNetworkUpdate(); populatedContainers++; return(true); }
public void Dismiss() { loot = null; gameObject.SetActive(false); }
public override void SendMeTo(Player plr) { // Log.Info("STATIC", "Creating static oid=" + Oid + " name=" + Name + " x=" + Spawn.WorldX + " y=" + Spawn.WorldY + " z=" + Spawn.WorldZ + " doorID=" + Spawn.DoorId); PacketOut Out = new PacketOut((byte)Opcodes.F_CREATE_STATIC); Out.WriteUInt16(Oid); Out.WriteUInt16(VfxState); //ie: red glow, open door, lever pushed, etc Out.WriteUInt16((ushort)Spawn.WorldO); Out.WriteUInt16((ushort)Spawn.WorldZ); Out.WriteUInt32((uint)Spawn.WorldX); Out.WriteUInt32((uint)Spawn.WorldY); Out.WriteUInt16((ushort)Spawn.DisplayID); Out.WriteByte((byte)(Spawn.GetUnk(0) >> 8)); // Get the database if the value hasnt been changed (currently only used for keep doors) if (Realm == Realms.REALMS_REALM_NEUTRAL) { Out.WriteByte((byte)(Spawn.GetUnk(0) & 0xFF)); } else { Out.WriteByte((byte)Realm); } Out.WriteUInt16(Spawn.GetUnk(1)); Out.WriteUInt16(Spawn.GetUnk(2)); Out.WriteByte(Spawn.Unk1); int flags = Spawn.GetUnk(3); if (Realm != Realms.REALMS_REALM_NEUTRAL && !IsInvulnerable) { flags |= 8; // Attackable (stops invalid target errors) } LootContainer loots = LootsMgr.GenerateLoot(this, plr, 1); if ((loots != null && loots.IsLootable()) || (plr.QtsInterface.PublicQuest != null) || plr.QtsInterface.GameObjectNeeded(Spawn.Entry) || Spawn.DoorId != 0) { flags |= 4; // Interactable } Out.WriteUInt16((ushort)flags); Out.WriteByte(Spawn.Unk2); Out.WriteUInt32(Spawn.Unk3); Out.WriteUInt16(Spawn.GetUnk(4)); Out.WriteUInt16(Spawn.GetUnk(5)); Out.WriteUInt32(Spawn.Unk4); Out.WritePascalString(Name); if (Spawn.DoorId != 0) { Out.WriteByte(0x04); Out.WriteUInt32(Spawn.DoorId); } else { Out.WriteByte(0x00); } plr.SendPacket(Out); base.SendMeTo(plr); }
private void GetMax(LootContainer loot) => Bin.Add("Max", Max = loot.maxCount);
Vector2 GetBoxPos(LootContainer box) => new Vector2(box.transform.position.x, box.transform.position.z);
private void GetMin(LootContainer loot) => Bin.Add("Min", Min = loot.minCount);
private void GetOpenTime(LootContainer loot) => Bin.Add("OpenTime", OpenTime = Math.Round(loot.openTime, 6));
private void GetSize(LootContainer loot) => Bin.Add("Size", Size = new BCMVector2(loot.size));
private void GetQuality(LootContainer loot) => Bin.Add("Quality", Quality = loot.lootQualityTemplate);
public PlayerTakeLootRequest(PlayerShip player, LootContainer lootContainer, int itemIndex) { Player = player; Loot = lootContainer; ItemIndex = itemIndex; }