Jump to content

OnRaidableDespawnUpdate

Pending 3.1.3

IIIaKa
IIIaKa

Posted

Hello. I launched a clean PvP(server.pve false) server with only two plugins: CopyPaste and RaidableBases.
The only thing I added was a PrintWarning before calling the OnRaidableDespawnUpdate hook. Then I fired an incendiary rocket from a rocket launcher at BuildingBlock(walls, ceilings, etc), and it shows that, for some unknown reason, the damage type is Cannon. Because of this, your Heat protection doesn't work, which results in the OnRaidableDespawnUpdate hook being spammed.
image.png
image.png
image.png


I suggest removing the damage type check and replacing lastDespawnUpdateTime with nextDespawnUpdateTime.
I tried this, and the spam decreased. I'm not sure who else uses the OnRaidableDespawnUpdate hook, but I think the delay could be increased to around 0.3-0.5(for RealPVE it's enough).
image.png
image.png

IIIaKa

Posted (edited)

As far as I understand, Protector is called every second, as well as on player entry and when the owner is updated.
I might be wrong, but I think it would be even better to replace lastDespawnUpdateTime with a boolean value(something like despawnTimeUpdated).
Then, inside UpdateDespawnDateTime(float time, HitInfo info), set it to true.
image.png
Also, the HitInfo parameter can be removed from the UpdateDespawnDateTime method.

And in Protector(), before if (DateTime.Now >= despawnDateTime), call the OnRaidableDespawnUpdate hook if despawnTimeUpdated == true, and then set it back to false after the call.
image.png

 

Edited by IIIaKa
nivex

Posted (edited)

hi, thanks for reaching out. these are good ideas and will be implemented in the next update.

I tracked down a second issue with the despawn hook which RealPVE uses, RaidableBaseTimeUpdatedBar -> AdvancedStatus -> DrawBars -> multiple network calls. similarly, limiting the amount of calls from RaidableBaseTimeUpdatedBar to AdvancedStatus minimized the issue, but it would really help to reduce the amount of network calls inside of DrawBars. you could start by removing DestroyUi where possible. destroyUi is a property in the Facepunch UI and if you were to add this to your json string then the previous ui would be destroyed whenever AddUi is called. this will help minimize any impact DrawBars might be having in other cases, and it reduces flickering. due to this, I had already implemented a 1 second debounce for the despawn hook but I will use your suggestion instead. thanks!

https://github.com/Facepunch/Rust.Community/blob/f1eef905473105e7814b984bc5745d4d9cbaa006/CommunityEntity.UI.cs#L77

here is one example:

        public static void DrawProgress(BasePlayer player, AdvancedBar bar)
        {
            string uiName = bar.UiNames[5];
            if (bar.Progress > 0f)
            {
                // add destroyUi to your json string here. the next time AddUi is called the previous UI will be destroyed before the new one is added.
                CuiHelper.AddUi(player, "json");
            }
            else CuiHelper.DestroyUi(player, uiName);
        }

 

Edited by nivex

About Us

Codefling is the largest marketplace for plugins, maps, tools, and more, making it easy for customers to discover new content and for creators to monetize their work.

Downloads
2.3m
Total downloads
Customers
10.7k
Customers served
Files Sold
155k
Marketplace sales
Payments
3.3m
Processed total
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.