# 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.
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) if(ObjectDistance(enemy) > 350) { enemy = nil; SetPlrViewRange(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(); SetPlrViewRange(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
SetPlrViewRange
SetFoW
PeterW
2003-04