For an idea I really like, I thought of having custom pratrol points which randomly select a subsequent patrol point and a value for wait time. This may seem large in scope but I see it as a simple application of replacing a variable with sub variables.
Firstly, for randomly selected NextPatrol I do this:
var() name subPoint1;
var() name subPoint2;
var() name subPoint3;
I would enter the appropriate values of the other patrol points within mapping. Now in scripted pawn it searches for NextPatrol. This can still happen, all we are doing is we are changing the name of NextPatrol to the name of one of the three subPoint variables
- Code: Select all
//=============================================================================
// PatrolPoint.
//=============================================================================
class SummerPatrolPoint extends SummerNavigationPoint;
var() name Nextpatrol; // This will be replaced by one of the sub points
var() name subPoint1;
var() name subPoint2;
var() name subPoint3;
var() float pausetime; //This will be replaced bu one of the sub times
var() float subTime1;
var() float subTime2;
var() float subTime3;
var vector lookdir;
var() name PatrolAnim;
var() sound PatrolSound;
var() byte numAnims;
var int AnimCount;
var PatrolPoint NextPatrolPoint;
function PreBeginPlay()
{
local PatrolPoint CurPoint;
local float subPointRand;
local float subWaitTimeRand;
lookdir = 200 * vector(Rotation);
//==================================
//Randomise the next patrol point
subPointRand = FRand();
if(subPointRand < 0.33)
{
log("");
Nextpatrol = subPoint1;
}
if(subPointRand < 0.33)
{
Nextpatrol = subPoint2;
}
else
Nextpatrol = subPoint3;
//==================================
//Randomise the waiting time
subWaitTimeRand = FRand();
if(subWaitTimeRand < 0.33)
{
pausetime = subTime1;
}
if(subWaitTimeRand < 0.66)
{
pausetime =subTime2;
}
else
pausetime =subTime1;
//find the patrol point with the tag specified by Nextpatrol
NextPatrolPoint = None;
if (NextPatrol != '')
{
foreach AllActors(class 'SummerEngine.SummerPatrolPoint', CurPoint, Nextpatrol)
{
if (CurPoint != self)
{
NextPatrolPoint = CurPoint;
break;
}
}
}
Super.PreBeginPlay();
}
// DEUS_EX STM -- end changes
defaultproperties
{
bDirectional=True
Texture=Texture'S_Patrol'
SoundVolume=128
}
defaultproperties
{
bDirectional=True
Texture=Texture'Engine.S_Patrol'
SoundVolume=128
}
The error is Error, Call to 'AllActors': type mismatch in parameter 2 regarding foreach AllActors(class 'SummerEngine.SummerPatrolPoint', CurPoint, Nextpatrol).
If I just leave it as PatrolPoint then it will look for invalid destinations.
If we can take care of this, we can apply the same technique to random wait times!
Thanks