https://github.com/dretax/Python-Plugins/blob/master/FougeritePlugins/ResourceSpawner/ResourceSpawner.py
Didn't have the time to test yet, soo...
Didn't have the time to test yet, soo...
Ah yea. I replaced all ; to a space in the editor. Fail.i think "res_woodpile"
should be ";res_woodpile"
On_CrateOpened (and disappear, even better wow)
Get crate ID
Datastore crate_ID = 0
Timer 30 minutes
if crate_ID = 0
respawn
it's possible to modify the DatablockDictionary._lootSpawnLists. By doing you can modify the item dorp table of a chest.Resource spawner is easy as shit (remember my loot crates and flares?) the problem is when you want to have spawn points, not just commands. If someone kill chicken, respawn it somewhere else after some time. If someone find loot crate respawn it. Then it getting hard
Because how many time you will use some resource spawner what needs your commands and being online to work?
But if we could have
Code:On_CrateOpened (and disappear, even better wow) Get crate ID Datastore crate_ID = 0 Timer 30 minutes if crate_ID = 0 respawn
I dunno if this was a flaming but I never said that doing a resource spawner is hard.Resource spawner is easy as shit (remember my loot crates and flares?) the problem is when you want to have spawn points, not just commands. If someone kill chicken, respawn it somewhere else after some time. If someone find loot crate respawn it. Then it getting hard
Because how many time you will use some resource spawner what needs your commands and being online to work?
But if we could have
Code:On_CrateOpened (and disappear, even better wow) Get crate ID Datastore crate_ID = 0 Timer 30 minutes if crate_ID = 0 respawn
Wait you are telling that you can hook inside there and get a chest open event without adding an extra hook?it's possible to modify the DataBlockDictionary._spawnList. By doing so the request that you make can be done without adding extra hooks.
^^Wait you are telling that you can hook inside there and get a chest open event without adding an extra hook?
void OnServerInitialized()
{
SpawnLists = LoadDefaultSpawnlists();
CheckCfg<Dictionary<string, object>>("Spawnlists", ref SpawnLists);
SaveConfig();
PatchNewSpawnlists();
}
static Dictionary<string, object> LoadDefaultSpawnlists()
{
var tblspawnlists = new Dictionary<string, object>();
var spawnlists = DatablockDictionary._lootSpawnLists as Dictionary<string,LootSpawnList>;
foreach (KeyValuePair<string, LootSpawnList> pair in spawnlists)
{
var spawnlist = new Dictionary<string, object>();
spawnlist.Add("min", pair.Value.minPackagesToSpawn);
spawnlist.Add("max", pair.Value.maxPackagesToSpawn);
spawnlist.Add("nodupes", pair.Value.noDuplicates);
spawnlist.Add("oneofeach", pair.Value.spawnOneOfEach);
var packages = new List<object>();
foreach(LootSpawnList.LootWeightedEntry entry in pair.Value.LootPackages)
{
var tblentry = new Dictionary<string, object>();
if (!entry.obj)
continue;
else
tblentry.Add("object", entry.obj.name);
tblentry.Add("weight", entry.weight);
tblentry.Add("min", entry.amountMin);
tblentry.Add("max", entry.amountMax);
packages.Add(tblentry);
}
spawnlist.Add("packages", packages);
tblspawnlists.Add(pair.Key, spawnlist);
}
return tblspawnlists;
}
void PatchNewSpawnlists()
{
int cnt = 0;
var spawnlistobjects = new Dictionary<string, LootSpawnList>();
foreach (KeyValuePair<string, object> pair in SpawnLists)
{
var currentspawnlist = pair.Value as Dictionary<string, object>;
var obj = UnityEngine.ScriptableObject.CreateInstance<LootSpawnList>();
obj.minPackagesToSpawn = Convert.ToInt32(currentspawnlist["min"]);
obj.maxPackagesToSpawn = Convert.ToInt32(currentspawnlist["max"]);
obj.noDuplicates = Convert.ToBoolean(currentspawnlist["nodupes"]);
obj.spawnOneOfEach = Convert.ToBoolean(currentspawnlist["oneofeach"]);
obj.name = pair.Key;
spawnlistobjects.Add(pair.Key, obj);
cnt++;
}
foreach (KeyValuePair<string, object> pair in SpawnLists)
{
var entrylist = new List<LootSpawnList.LootWeightedEntry>();
var currentspawnlist = pair.Value as Dictionary<string, object>;
var packages = currentspawnlist["packages"] as List<object>;
foreach (Dictionary<string, object> entry in packages)
{
var entryobj = new LootSpawnList.LootWeightedEntry();
entryobj.amountMin = Convert.ToInt32(entry["min"]);
entryobj.amountMax = Convert.ToInt32(entry["max"]);
entryobj.weight = Convert.ToSingle(entry["weight"]);
if (spawnlistobjects.ContainsKey(entry["object"].ToString()))
{
entryobj.obj = spawnlistobjects[entry["object"].ToString()];
}
else
{
entryobj.obj = DatablockDictionary.GetByName(entry["object"].ToString());
}
entrylist.Add(entryobj);
}
spawnlistobjects[pair.Key].LootPackages = entrylist.ToArray();
}
var spawnlists = DatablockDictionary._lootSpawnLists;
spawnlists.Clear();
foreach (KeyValuePair<string, object> pair in SpawnLists)
{
spawnlists.Add(pair.Key, spawnlistobjects[pair.Key]);
}
Puts(string.Format("{0} custom loot tables were loaded!", cnt.ToString()));
}
}
}
i forgot to mention you wont be able to spawn extra loot crates at a loctaion with this (and keep them reappearing).He said (sorry that I'm replying but he was writing couple days ago on my PM) that you don't need to use fougerite or oxide to that. Showed me this plugin: http://oxidemod.org/plugins/loot-spawn-lists.5/download?version=4865 but I didn't check it yet because I think I lost my oxide account or I never created it.
Ah okay. I thought you were talking about the chest open event.^^
No I haven't found a way to get a chest open event. but you can modify the lootspawntable
----
let's assume that you will only use the standard ammo/wood/med/wep boxes (and the ones you spawn with world.spawn). you can modify the item drop table.
DatablockDictionary._lootSpawnLists
example:
http://oxidemod.org/plugins/loot-spawn-lists.5/download?version=4865
(code)
C#:void OnServerInitialized() { SpawnLists = LoadDefaultSpawnlists(); CheckCfg<Dictionary<string, object>>("Spawnlists", ref SpawnLists); SaveConfig(); PatchNewSpawnlists(); } static Dictionary<string, object> LoadDefaultSpawnlists() { var tblspawnlists = new Dictionary<string, object>(); var spawnlists = DatablockDictionary._lootSpawnLists as Dictionary<string,LootSpawnList>; foreach (KeyValuePair<string, LootSpawnList> pair in spawnlists) { var spawnlist = new Dictionary<string, object>(); spawnlist.Add("min", pair.Value.minPackagesToSpawn); spawnlist.Add("max", pair.Value.maxPackagesToSpawn); spawnlist.Add("nodupes", pair.Value.noDuplicates); spawnlist.Add("oneofeach", pair.Value.spawnOneOfEach); var packages = new List<object>(); foreach(LootSpawnList.LootWeightedEntry entry in pair.Value.LootPackages) { var tblentry = new Dictionary<string, object>(); if (!entry.obj) continue; else tblentry.Add("object", entry.obj.name); tblentry.Add("weight", entry.weight); tblentry.Add("min", entry.amountMin); tblentry.Add("max", entry.amountMax); packages.Add(tblentry); } spawnlist.Add("packages", packages); tblspawnlists.Add(pair.Key, spawnlist); } return tblspawnlists; } void PatchNewSpawnlists() { int cnt = 0; var spawnlistobjects = new Dictionary<string, LootSpawnList>(); foreach (KeyValuePair<string, object> pair in SpawnLists) { var currentspawnlist = pair.Value as Dictionary<string, object>; var obj = UnityEngine.ScriptableObject.CreateInstance<LootSpawnList>(); obj.minPackagesToSpawn = Convert.ToInt32(currentspawnlist["min"]); obj.maxPackagesToSpawn = Convert.ToInt32(currentspawnlist["max"]); obj.noDuplicates = Convert.ToBoolean(currentspawnlist["nodupes"]); obj.spawnOneOfEach = Convert.ToBoolean(currentspawnlist["oneofeach"]); obj.name = pair.Key; spawnlistobjects.Add(pair.Key, obj); cnt++; } foreach (KeyValuePair<string, object> pair in SpawnLists) { var entrylist = new List<LootSpawnList.LootWeightedEntry>(); var currentspawnlist = pair.Value as Dictionary<string, object>; var packages = currentspawnlist["packages"] as List<object>; foreach (Dictionary<string, object> entry in packages) { var entryobj = new LootSpawnList.LootWeightedEntry(); entryobj.amountMin = Convert.ToInt32(entry["min"]); entryobj.amountMax = Convert.ToInt32(entry["max"]); entryobj.weight = Convert.ToSingle(entry["weight"]); if (spawnlistobjects.ContainsKey(entry["object"].ToString())) { entryobj.obj = spawnlistobjects[entry["object"].ToString()]; } else { entryobj.obj = DatablockDictionary.GetByName(entry["object"].ToString()); } entrylist.Add(entryobj); } spawnlistobjects[pair.Key].LootPackages = entrylist.ToArray(); } var spawnlists = DatablockDictionary._lootSpawnLists; spawnlists.Clear(); foreach (KeyValuePair<string, object> pair in SpawnLists) { spawnlists.Add(pair.Key, spawnlistobjects[pair.Key]); } Puts(string.Format("{0} custom loot tables were loaded!", cnt.ToString())); } } }
though with fougerite you have to do this after serverinit, since serverinit hooks get triggered before the server actually loaded the datadictionary.
if you want to have specific loot in only 1 instance of a crate then you need an extra hook (or by simulation with a custom spawned box).
(assuming you only want to modify 1 weapon crate at a location)
note: the code above doesn't include editing which crate has to be spawned (picked). but you can also modify this after serverinit.
In your place If I knew the coordinates of the chests, I would find them by that.@hunternope3 - So if I understand proper you was just wrong. You can't build house like was on my server and get there automatically respawned crates. No matter if you use fougerite or not. You can loop spawning what is possible easy with fougerite, but you can't just add crates what will respawn when they are taken by player. You would need hook for that like I wrote couple post before.
Aaaaaaaaaaaaaaaaaaaaa. I see:Naah! I want to make autorespawn for spawned crate! Like original crates in Rust RAD zones
//Method1:
//Todo spawn your own lootstacks by prefab names, cast them to lootableobject or find them:
LootableObject[] objects = UnityEngine.Object.FindObjectsOfType(typeof(LootableObject)) as LootableObject[];
//Todo: Check if the inventory is empty and if it is, respawn
foreach (LootableObject x in objects)
{
x._inventory. // blabla
}
//Method2:
Dictionary<string, LootSpawnList> tempspawnlist = DatablockDictionary._lootSpawnLists;
//Todo: No idea what spawnlist names are in it you should first loop the tempspawnlist.Keys to get what you need
//Todo: Spawn your own loots, store them, check if the DatablockDictionary._lootSpawnList contains them