SetPlrView
Player
View
5.1 OC
bool
int
player
Player whose view distance to want to set.
object
obj
Object to which to want to set the view.
bool
immediate
If true, the view of the first open viewport for that player on each machine does not scroll smoothly but is set immediately.
Centers a player's view to the specified object. The view will follow this object until the next player command.
local enemy;
// called every x frames
protected func Timer()
{
// already found enemy is too far away
if(enemy &%amp;ObjectDistance(enemy) > 350)
{
enemy = nil;
SetLightRange(0);
}
// find (new) enemy
if(!enemy)
{
// search for an enemy crew member in a distance of max. 300 pixels, return the closest one
enemy = FindObject(Find_OCF(OCF_CrewMember),Find_Distance(300),Find_Hostile(GetOwner()),Sort_Distance());
SetPlrView(GetOwner(),this);
SetLightRange(100);
}
// so, if there is an enemy close to the tower, sound the alarm
if (enemy)
{
Message("!!! ENEMY !!!");
Sound("Alarm");
}
}
Automatic watch tower: if an enemy clonk gets near the tower the player's view will be set to the attacker. Also, a sound is played and a message is popped up while the enemy is in range.
GetPlrView
GetPlrViewMode
SetLightRange
SetFoW
PeterW2003-04
Sven22015-12