⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 triggers.htm

📁 Quake 的 各 种 文 档 格 式 说 明
💻 HTM
📖 第 1 页 / 共 3 页
字号:

	<a href="triggers.htm#trigger_multiple">trigger_multiple</a> ();
};

<i>//=============================================================================</i>


<a href="qc-types.htm#void">void</a>() <b>counter_use</b><a name="counter_use">=</a>
{
	<b>local</b> <a href="qc-types.htm#string">string</a> junk;

	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_count">count</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_count">count</a> - 1;
	<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_count">count</a> &lt; 0)
		<b>return</b>;
	
	<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_count">count</a> != 0)
	{
		<b>if</b> (<a href="defs.htm#activator">activator</a>.<a href="qc-enty.htm#dot_classname">classname</a> == <b>"player"</b>
		&amp;&amp; (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_spawnflags">spawnflags</a> &amp; <a href="triggers.htm#SPAWNFLAG_NOMESSAGE">SPAWNFLAG_NOMESSAGE</a>) == 0)
		{
			<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_count">count</a> &gt;= 4)
				<a href="qc-built.htm#centerprint">centerprint</a> (<a href="defs.htm#activator">activator</a>, <b>"There are more to go..."</b>);
			<b>else</b> <b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_count">count</a> == 3)
				<a href="qc-built.htm#centerprint">centerprint</a> (<a href="defs.htm#activator">activator</a>, <b>"Only 3 more to go..."</b>);
			<b>else</b> <b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_count">count</a> == 2)
				<a href="qc-built.htm#centerprint">centerprint</a> (<a href="defs.htm#activator">activator</a>, <b>"Only 2 more to go..."</b>);
			<b>else</b>
				<a href="qc-built.htm#centerprint">centerprint</a> (<a href="defs.htm#activator">activator</a>, <b>"Only 1 more to go..."</b>);
		}
		<b>return</b>;
	}
	
	<b>if</b> (<a href="defs.htm#activator">activator</a>.<a href="qc-enty.htm#dot_classname">classname</a> == <b>"player"</b>
	&amp;&amp; (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_spawnflags">spawnflags</a> &amp; <a href="triggers.htm#SPAWNFLAG_NOMESSAGE">SPAWNFLAG_NOMESSAGE</a>) == 0)
		<a href="qc-built.htm#centerprint">centerprint</a>(<a href="defs.htm#activator">activator</a>, <b>"Sequence completed!"</b>);
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_enemy">enemy</a> = <a href="defs.htm#activator">activator</a>;
	<a href="triggers.htm#multi_trigger">multi_trigger</a> ();
};

<i>/*QUAKED trigger_counter (.5 .5 .5) ? nomessage
Acts as an intermediary for an action that takes multiple inputs.

If nomessage is not set, t will print "1 more.. " etc when triggered and "sequence complete" when finished.

After the counter has been triggered "count" times (default 2), it will fire all of it's targets and remove itself.
*/</i>

<a href="qc-types.htm#void">void</a>() <b>trigger_counter</b><a name="trigger_counter">=</a>
{
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_wait">wait</a> = -1;
	<b>if</b> (!<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_count">count</a>)
		<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_count">count</a> = 2;

	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_use">use</a> = <a href="triggers.htm#counter_use">counter_use</a>;
};


<i>/*
==============================================================================

TELEPORT TRIGGERS

==============================================================================
*/</i>


<a href="qc-types.htm#float">float</a> <b><a name="PLAYER_ONLY">PLAYER_ONLY</a></b> = 1;
<a href="qc-types.htm#float">float</a> <b><a name="SILENT">SILENT</a></b> = 2;

<a href="qc-types.htm#void">void</a>() <b>play_teleport</b><a name="play_teleport">=</a>
{
	<b>local</b>	<a href="qc-types.htm#float">float</a> v;
	<b>local</b>	<a href="qc-types.htm#string">string</a> tmpstr;

	v = <a href="qc-built.htm#random">random</a>() * 5;
	<b>if</b> (v &lt; 1)
		tmpstr = <b>"misc/r_tele1.wav"</b>;
	<b>else</b> <b>if</b> (v &lt; 2)
		tmpstr = <b>"misc/r_tele2.wav"</b>;
	<b>else</b> <b>if</b> (v &lt; 3)
		tmpstr = <b>"misc/r_tele3.wav"</b>;
	<b>else</b> <b>if</b> (v &lt; 4)
		tmpstr = <b>"misc/r_tele4.wav"</b>;
	<b>else</b>
		tmpstr = <b>"misc/r_tele5.wav"</b>;

	<a href="qc-built.htm#sound">sound</a> (<a href="qc-glob.htm#self">self</a>, <a href="qc-defs.htm#CHAN_VOICE">CHAN_VOICE</a>, tmpstr, 1, <a href="qc-defs.htm#ATTN_NORM">ATTN_NORM</a>);
	<a href="qc-built.htm#remove">remove</a> (<a href="qc-glob.htm#self">self</a>);
};

<a href="qc-types.htm#void">void</a>(<a href="qc-types.htm#vector">vector</a> org) <b>spawn_tfog</b><a name="spawn_tfog">=</a>
{
	s = <a href="qc-built.htm#spawn">spawn</a> ();
	s.<a href="qc-enty.htm#dot_origin">origin</a> = org;
	s.<a href="qc-enty.htm#dot_nextthink">nextthink</a> = <a href="qc-glob.htm#time">time</a> + 0.2;
	s.<a href="qc-enty.htm#dot_think">think</a> = <a href="triggers.htm#play_teleport">play_teleport</a>;

	<a href="qc-netf.htm#WriteByte">WriteByte</a> (<a href="qc-net.htm#MSG_BROADCAST">MSG_BROADCAST</a>, <a href="qc-net.htm#SVC_TEMPENTITY">SVC_TEMPENTITY</a>);
	<a href="qc-netf.htm#WriteByte">WriteByte</a> (<a href="qc-net.htm#MSG_BROADCAST">MSG_BROADCAST</a>, <a href="defs.htm#TE_TELEPORT">TE_TELEPORT</a>);
	<a href="qc-netf.htm#WriteCoord">WriteCoord</a> (<a href="qc-net.htm#MSG_BROADCAST">MSG_BROADCAST</a>, org_x);
	<a href="qc-netf.htm#WriteCoord">WriteCoord</a> (<a href="qc-net.htm#MSG_BROADCAST">MSG_BROADCAST</a>, org_y);
	<a href="qc-netf.htm#WriteCoord">WriteCoord</a> (<a href="qc-net.htm#MSG_BROADCAST">MSG_BROADCAST</a>, org_z);
};


<a href="qc-types.htm#void">void</a>() <b>tdeath_touch</b><a name="tdeath_touch">=</a>
{
	<b>if</b> (<a href="qc-glob.htm#other">other</a> == <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_owner">owner</a>)
		<b>return</b>;

<i>// frag anyone who teleports in on top of an invincible player</i>
	<b>if</b> (<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_classname">classname</a> == <b>"player"</b>)
	{
		<b>if</b> (<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_invincible_finished">invincible_finished</a> &gt; <a href="qc-glob.htm#time">time</a>)
			<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_classname">classname</a> = <b>"teledeath2"</b>;
		<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_owner">owner</a>.<a href="qc-enty.htm#dot_classname">classname</a> != <b>"player"</b>)
		{	<i>// other monsters explode themselves</i>
			<a href="combat.htm#T_Damage">T_Damage</a> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_owner">owner</a>, <a href="qc-glob.htm#self">self</a>, <a href="qc-glob.htm#self">self</a>, 50000);
			<b>return</b>;
		}
		
	}

	<b>if</b> (<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_health">health</a>)
	{
		<a href="combat.htm#T_Damage">T_Damage</a> (<a href="qc-glob.htm#other">other</a>, <a href="qc-glob.htm#self">self</a>, <a href="qc-glob.htm#self">self</a>, 50000);
	}
};


<a href="qc-types.htm#void">void</a>(<a href="qc-types.htm#vector">vector</a> org, <a href="qc-types.htm#entity">entity</a> death_owner) <b>spawn_tdeath</b><a name="spawn_tdeath">=</a>
{
<b>local</b> <a href="qc-types.htm#entity">entity</a>	death;

	death = <a href="qc-built.htm#spawn">spawn</a>();
	death.<a href="qc-enty.htm#dot_classname">classname</a> = <b>"teledeath"</b>;
	death.<a href="qc-enty.htm#dot_movetype">movetype</a> = <a href="qc-defs.htm#MOVETYPE_NONE">MOVETYPE_NONE</a>;
	death.<a href="qc-enty.htm#dot_solid">solid</a> = <a href="qc-defs.htm#SOLID_TRIGGER">SOLID_TRIGGER</a>;
	death.<a href="qc-enty.htm#dot_angles">angles</a> = '0 0 0';
	<a href="qc-built.htm#setsize">setsize</a> (death, death_owner.<a href="qc-enty.htm#dot_mins">mins</a> - '1 1 1', death_owner.<a href="qc-enty.htm#dot_maxs">maxs</a> + '1 1 1');
	<a href="qc-built.htm#setorigin">setorigin</a> (death, org);
	death.<a href="qc-enty.htm#dot_touch">touch</a> = <a href="triggers.htm#tdeath_touch">tdeath_touch</a>;
	death.<a href="qc-enty.htm#dot_nextthink">nextthink</a> = <a href="qc-glob.htm#time">time</a> + 0.2;
	death.<a href="qc-enty.htm#dot_think">think</a> = <a href="subs.htm#SUB_Remove">SUB_Remove</a>;
	death.<a href="qc-enty.htm#dot_owner">owner</a> = death_owner;
	
	<a href="qc-glob.htm#force_retouch">force_retouch</a> = 2;		<i>// make sure even still objects get hit</i>
};

<a href="qc-types.htm#void">void</a>() <b>teleport_touch</b><a name="teleport_touch">=</a>
{
<b>local</b> <a href="qc-types.htm#entity">entity</a>	t;
<b>local</b> <a href="qc-types.htm#vector">vector</a>	org;

	<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_targetname">targetname</a>)
	{
		<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_nextthink">nextthink</a> &lt; <a href="qc-glob.htm#time">time</a>)
		{
			<b>return</b>;		<i>// not fired yet</i>
		}
	}

	<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_spawnflags">spawnflags</a> &amp; <a href="triggers.htm#PLAYER_ONLY">PLAYER_ONLY</a>)
	{
		<b>if</b> (<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_classname">classname</a> != <b>"player"</b>)
			<b>return</b>;
	}

<i>// only teleport living creatures</i>
	<b>if</b> (<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_health">health</a> &lt;= 0 || <a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_solid">solid</a> != <a href="qc-defs.htm#SOLID_SLIDEBOX">SOLID_SLIDEBOX</a>)
		<b>return</b>;

	<a href="subs.htm#SUB_UseTargets">SUB_UseTargets</a> ();

<i>// put a tfog where the player was</i>
	<a href="triggers.htm#spawn_tfog">spawn_tfog</a> (<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_origin">origin</a>);

	t = <a href="qc-built.htm#find">find</a> (<a href="qc-glob.htm#world">world</a>, targetname, <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_target">target</a>);
	<b>if</b> (!t)
		<a href="qc-built.htm#objerror">objerror</a> (<b>"couldn't find target"</b>);
		
<i>// spawn a tfog flash in front of the destination</i>
	<a href="qc-built.htm#makevectors">makevectors</a> (t.<a href="qc-enty.htm#dot_mangle">mangle</a>);
	org = t.<a href="qc-enty.htm#dot_origin">origin</a> + 32 * <a href="qc-built.htm#v_forward">v_forward</a>;

	<a href="triggers.htm#spawn_tfog">spawn_tfog</a> (org);
	<a href="triggers.htm#spawn_tdeath">spawn_tdeath</a>(t.<a href="qc-enty.htm#dot_origin">origin</a>, <a href="qc-glob.htm#other">other</a>);

<i>// move the player and lock him down for a little while</i>
	<b>if</b> (!<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_health">health</a>)
	{
		<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_origin">origin</a> = t.<a href="qc-enty.htm#dot_origin">origin</a>;
		<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_velocity">velocity</a> = (<a href="qc-built.htm#v_forward">v_forward</a> * <a href="qc-glob.htm#other">other</a>.velocity_x) + (<a href="qc-built.htm#v_forward">v_forward</a> * <a href="qc-glob.htm#other">other</a>.velocity_y);
		<b>return</b>;
	}

	<a href="qc-built.htm#setorigin">setorigin</a> (<a href="qc-glob.htm#other">other</a>, t.<a href="qc-enty.htm#dot_origin">origin</a>);
	<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_angles">angles</a> = t.<a href="qc-enty.htm#dot_mangle">mangle</a>;
	<b>if</b> (<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_classname">classname</a> == <b>"player"</b>)
	{
		<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_fixangle">fixangle</a> = 1;		<i>// turn this way immediately</i>
		<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_teleport_time">teleport_time</a> = <a href="qc-glob.htm#time">time</a> + 0.7;
		<b>if</b> (<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_flags">flags</a> &amp; <a href="defs.htm#FL_ONGROUND">FL_ONGROUND</a>)
			<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_flags">flags</a> = <a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_flags">flags</a> - <a href="defs.htm#FL_ONGROUND">FL_ONGROUND</a>;
		<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_velocity">velocity</a> = <a href="qc-built.htm#v_forward">v_forward</a> * 300;
	}
	<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_flags">flags</a> = <a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_flags">flags</a> - <a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_flags">flags</a> &amp; <a href="defs.htm#FL_ONGROUND">FL_ONGROUND</a>;
};

<i>/*QUAKED info_teleport_destination (.5 .5 .5) (-8 -8 -8) (8 8 32)
This is the destination marker for a teleporter.  It should have a "targetname" field with the same value as a teleporter's "target" field.
*/</i>

<a href="qc-types.htm#void">void</a>() <b>info_teleport_destination</b><a name="info_teleport_destination">=</a>
{
<i>// this does nothing, just serves as a target spot</i>
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_mangle">mangle</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_angles">angles</a>;
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_angles">angles</a> = '0 0 0';
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_model">model</a> = <b>""</b>;
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_origin">origin</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_origin">origin</a> + '0 0 27';
	<b>if</b> (!<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_targetname">targetname</a>)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -