Implemented OnLootSpawned hook (Rust)

Discussion in 'Feature Suggestions' started by Kunazai, Sep 1, 2017.

  1. Kunazai

    Kunazai Shack Builder

    I know we already have OnEntitySpawned hook to get loot containers to spawn so we can view/modify their loot. However, the problem arises when loot wants to refresh its contents, OnEntitySpawned can not detect this. We can also suppress the invoke for loot refreshing, but I've had this work inconsistently and not letting loot refresh has resulted in some problems with loot. I'd like the following hook added so we can easily access LootContainer whenever it has its loot spawned and refreshed.
    OnLootSpawned_Hook.jpg
     
  2. Kunazai

    Kunazai Shack Builder

    Doing a follow up on this request. I went ahead and made the modifications to oxide and tried it out on my test server to make sure the hook would actually solve the problem.

    upload_2017-10-5_23-38-10.png
    upload_2017-10-5_23-43-25.png

    I made modifications to a couple of mods that used the hook OnEntitySpawned() to modify LootContainer's loot. I added this new hook to the mod to re-apply the mod's loot modification code to the newly spawned/refreshed loot. Let this server run for a few days and found no bugged loot crates or barrels. (just to reiterate, when LootContainer refresh on the server, loot mods can't track the refresh and don't update crate contents, and cancel invoke on the refresh doesn't seem to work correctly.)

    A good alternative to this hook could be putting the hook slightly earlier and interrupt loot being populated so the mod can populate the container with its own loot. I haven't tried that yet.
     
  3. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Implemented as object OnLootSpawn(LootContainer container).