Actor Precache function
Posted: Tue Jul 26, 2016 6:29 am
As a followup to some previous discussions regarding precaching actors in mutators to avoid the initial bit of
lag in the event the actor class in question is not already on the map, I thought I would post my latest method for this.
Here is a shortened bit of code right out of the currently unreleased Dropper v2.0 update. (This week I think. Still testing a bit.)
For this example there are only 2 global config variables from the ini file being used by the precache function.
DropList[] is a list of Actor classes. (Inventory, Weapons or ScriptedPawns in this case.)
NumItems is the number of items in the DropList.
Here are the 2 short and sweet functions that will precache all the Actor classes in the DropList array from the mutators ini file:
In testing, this method will precache anything. It will precache MegaTitans on maps they have zero chance of ever actually spawning on.
If anybody finds any problems with this, let me know. (Hi Sektor! )
lag in the event the actor class in question is not already on the map, I thought I would post my latest method for this.
Here is a shortened bit of code right out of the currently unreleased Dropper v2.0 update. (This week I think. Still testing a bit.)
For this example there are only 2 global config variables from the ini file being used by the precache function.
Code: Select all
var() config int NumItems;
var() config string DropList[255];
NumItems is the number of items in the DropList.
Here are the 2 short and sweet functions that will precache all the Actor classes in the DropList array from the mutators ini file:
Code: Select all
function PostBeginPlay()
{
PreCacheLists();
Super.PostBeginPlay();
}
function PreCacheLists()
{
local int i;
local bool bCWH;
local class<Actor> aC;
local Actor pcla;
for (i=0; i<NumItems; i++)
{
aC = class<Actor>(DynamicLoadObject(DropList[i], class'Class'));
bCWH = aC.default.bCollideWorld;
aC.default.bCollideWorld = False;
pcla = spawn(aC,,,);
aC.default.bCollideWorld = bCWH;
if (pcla != None) pcla.destroy();
}
}
If anybody finds any problems with this, let me know. (Hi Sektor! )