2010-08-22 13:13:17 +00:00
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
< !DOCTYPE funcs
SYSTEM '../../../clonk.dtd'>
2009-05-09 13:11:51 +00:00
<?xml-stylesheet type="text/xsl" href="../../../clonk.xsl"?>
<funcs >
2010-08-22 13:13:17 +00:00
<func >
<title > SetPlrView</title>
<category > Player</category>
<subcat > View</subcat>
2011-06-30 10:52:55 +00:00
<version > 5.1 OC</version>
2010-08-22 13:13:17 +00:00
<syntax >
<rtype > bool</rtype>
<params >
<param >
<type > int</type>
<name > player</name>
<desc > Player whose view distance to want to set.</desc>
</param>
<param >
<type > object</type>
<name > obj</name>
<desc > Object to which to want to set the view.</desc>
2015-12-03 03:11:28 +00:00
<optional />
</param>
<param >
<type > bool</type>
<name > immediate</name>
<desc > If true, the view of the first open viewport for that player on each machine does not scroll smoothly but is set immediately.</desc>
2010-08-22 13:13:17 +00:00
</param>
</params>
</syntax>
<desc > Centers a player's view to the specified object. The view will follow this object until the next player command.</desc>
<examples >
<example >
2011-07-20 14:22:07 +00:00
<code > local enemy;
// called every x frames
2009-05-09 13:11:51 +00:00
protected func Timer()
{
2011-07-20 14:22:07 +00:00
// already found enemy is too far away
2015-01-04 21:06:43 +00:00
if(enemy & %amp;<funclink > ObjectDistance</funclink> (enemy) > 350)
{
enemy = nil;
<funclink > SetLightRange</funclink> (0);
}
2011-07-20 14:22:07 +00:00
// find (new) enemy
if(!enemy)
{
// search for an enemy crew member in a distance of max. 300 pixels, return the closest one
enemy = <funclink > FindObject</funclink> (<funclink > Find_OCF</funclink> (<funclink > OCF_CrewMember</funclink> ),<funclink > Find_Distance</funclink> (300),<funclink > Find_Hostile</funclink> (GetOwner()),<funclink > Sort_Distance</funclink> ());
2015-01-04 21:06:43 +00:00
SetPlrView(<funclink > GetOwner</funclink> (),this);
<funclink > SetLightRange</funclink> (100);
2011-07-20 14:22:07 +00:00
}
// so, if there is an enemy close to the tower, sound the alarm
if (enemy)
{
<funclink > Message</funclink> (" !!! ENEMY !!!" );
<funclink > Sound</funclink> (" Alarm" );
}
2009-05-09 13:11:51 +00:00
}
</code>
2010-08-22 13:13:17 +00:00
<text > 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.</text>
</example>
</examples>
<related >
<funclink > GetPlrView</funclink>
<funclink > GetPlrViewMode</funclink>
2015-01-04 21:06:43 +00:00
<funclink > SetLightRange</funclink>
2010-08-22 13:13:17 +00:00
<funclink > SetFoW</funclink>
</related>
</func>
<author > PeterW</author> <date > 2003-04</date>
2015-12-03 03:11:28 +00:00
<author > Sven2</author> <date > 2015-12</date>
2009-05-09 13:11:51 +00:00
</funcs>