File: SetPlrView.xml

package info (click to toggle)
openclonk 8.1-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 169,520 kB
  • sloc: cpp: 180,479; ansic: 108,988; xml: 31,371; python: 1,223; php: 767; makefile: 145; sh: 101; javascript: 34
file content (77 lines) | stat: -rw-r--r-- 2,580 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE funcs
  SYSTEM '../../../clonk.dtd'>
<?xml-stylesheet type="text/xsl" href="../../../clonk.xsl"?>
<funcs>
  <func>
    <title>SetPlrView</title>
    <category>Player</category>
    <subcat>View</subcat>
    <version>5.1 OC</version>
    <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>
          <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>
        </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>
        <code>local enemy;
// called every x frames
protected func Timer()
{
	// already found enemy is too far away
	if(enemy &amp;%amp;<funclink>ObjectDistance</funclink>(enemy) &gt; 350)
	{
		enemy = nil;
		<funclink>SetLightRange</funclink>(0);
	}


	// 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>());
		SetPlrView(<funclink>GetOwner</funclink>(),this);
		<funclink>SetLightRange</funclink>(100);
	}
	
	// so, if there is an enemy close to the tower, sound the alarm
	if (enemy)
	{
		<funclink>Message</funclink>(&quot;!!! ENEMY !!!&quot;);
		<funclink>Sound</funclink>(&quot;Alarm&quot;);
	}

}
				</code>
        <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>
      <funclink>SetLightRange</funclink>
      <funclink>SetFoW</funclink>
    </related>
  </func>
  <author>PeterW</author><date>2003-04</date>
  <author>Sven2</author><date>2015-12</date>
</funcs>