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

📄 doors.htm

📁 Quake 的 各 种 文 档 格 式 说 明
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<html><head><title>doors.qc</title></head><body bgcolor="#C0F0D0">
<base target=examine>
<pre>

<a href="qc-types.htm#float">float</a> <b><a name="DOOR_START_OPEN">DOOR_START_OPEN</a></b> = 1;
<a href="qc-types.htm#float">float</a> <b><a name="DOOR_DONT_LINK">DOOR_DONT_LINK</a></b> = 4;
<a href="qc-types.htm#float">float</a> <b><a name="DOOR_GOLD_KEY">DOOR_GOLD_KEY</a></b> = 8;
<a href="qc-types.htm#float">float</a> <b><a name="DOOR_SILVER_KEY">DOOR_SILVER_KEY</a></b> = 16;
<a href="qc-types.htm#float">float</a> <b><a name="DOOR_TOGGLE">DOOR_TOGGLE</a></b> = 32;

<i>/*

Doors are similar to buttons, but can spawn a fat trigger field around them
to open without a touch, and they link together to form simultanious
double/quad doors.
 
Door.owner is the master door.  If there is only one door, it points to itself.
If multiple doors, all will point to a single one.

Door.enemy chains from the master door through all doors linked in the chain.

*/</i>


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

THINK FUNCTIONS

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


<a href="qc-types.htm#void">void</a>() <a href="doors.htm#door_go_down">door_go_down</a>;
<a href="qc-types.htm#void">void</a>() <a href="doors.htm#door_go_up">door_go_up</a>;

<a href="qc-types.htm#void">void</a>() <b>door_blocked</b><a name="door_blocked">=</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>, <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_dmg">dmg</a>);
	
<i>// if a door has a negative wait, it would never come back if blocked,</i>
<i>// so let it just squash the object to death real fast</i>
	<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_wait">wait</a> &gt;= 0)
	{
		<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_state">state</a> == <a href="defs.htm#STATE_DOWN">STATE_DOWN</a>)
			<a href="doors.htm#door_go_up">door_go_up</a> ();
		<b>else</b>
			<a href="doors.htm#door_go_down">door_go_down</a> ();
	}
};


<a href="qc-types.htm#void">void</a>() <b>door_hit_top</b><a name="door_hit_top">=</a>
{
	<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>, <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_noise1">noise1</a>, 1, <a href="qc-defs.htm#ATTN_NORM">ATTN_NORM</a>);
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_state">state</a> = <a href="defs.htm#STATE_TOP">STATE_TOP</a>;
	<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_spawnflags">spawnflags</a> &amp; <a href="doors.htm#DOOR_TOGGLE">DOOR_TOGGLE</a>)
		<b>return</b>;		<i>// don't come down automatically</i>
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_think">think</a> = <a href="doors.htm#door_go_down">door_go_down</a>;
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_nextthink">nextthink</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_ltime">ltime</a> + <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_wait">wait</a>;
};

<a href="qc-types.htm#void">void</a>() <b>door_hit_bottom</b><a name="door_hit_bottom">=</a>
{
	<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>, <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_noise1">noise1</a>, 1, <a href="qc-defs.htm#ATTN_NORM">ATTN_NORM</a>);
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_state">state</a> = <a href="defs.htm#STATE_BOTTOM">STATE_BOTTOM</a>;
};

<a href="qc-types.htm#void">void</a>() <b>door_go_down</b><a name="door_go_down">=</a>
{
	<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>, <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_noise2">noise2</a>, 1, <a href="qc-defs.htm#ATTN_NORM">ATTN_NORM</a>);
	<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_max_health">max_health</a>)
	{
		<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_takedamage">takedamage</a> = <a href="qc-defs.htm#DAMAGE_YES">DAMAGE_YES</a>;
		<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_health">health</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_max_health">max_health</a>;
	}
	
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_state">state</a> = <a href="defs.htm#STATE_DOWN">STATE_DOWN</a>;
	<a href="subs.htm#SUB_CalcMove">SUB_CalcMove</a> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_pos1">pos1</a>, <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_speed">speed</a>, <a href="doors.htm#door_hit_bottom">door_hit_bottom</a>);
};

<a href="qc-types.htm#void">void</a>() <b>door_go_up</b><a name="door_go_up">=</a>
{
	<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_state">state</a> == <a href="defs.htm#STATE_UP">STATE_UP</a>)
		<b>return</b>;		<i>// allready going up</i>

	<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_state">state</a> == <a href="defs.htm#STATE_TOP">STATE_TOP</a>)
	{	<i>// reset top wait time</i>
		<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_nextthink">nextthink</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_ltime">ltime</a> + <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_wait">wait</a>;
		<b>return</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>, <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_noise2">noise2</a>, 1, <a href="qc-defs.htm#ATTN_NORM">ATTN_NORM</a>);
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_state">state</a> = <a href="defs.htm#STATE_UP">STATE_UP</a>;
	<a href="subs.htm#SUB_CalcMove">SUB_CalcMove</a> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_pos2">pos2</a>, <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_speed">speed</a>, <a href="doors.htm#door_hit_top">door_hit_top</a>);

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


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

ACTIVATION FUNCTIONS

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


<a href="qc-types.htm#void">void</a>() <b>door_fire</b><a name="door_fire">=</a>
{
	<b>local</b> <a href="qc-types.htm#entity">entity</a> 	oself;
	<b>local</b> <a href="qc-types.htm#entity">entity</a>	starte;

	<b>if</b> (<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-built.htm#objerror">objerror</a> (<b>"door_fire: self.owner != self"</b>);

<i>// play use key sound</i>

	<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_items">items</a>)
		<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>, <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_noise4">noise4</a>, 1, <a href="qc-defs.htm#ATTN_NORM">ATTN_NORM</a>);

	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_message">message</a> = <a href="defs.htm#string_null">string_null</a>;		<i>// no more message</i>
	oself = <a href="qc-glob.htm#self">self</a>;

	<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_spawnflags">spawnflags</a> &amp; <a href="doors.htm#DOOR_TOGGLE">DOOR_TOGGLE</a>)
	{
		<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_state">state</a> == <a href="defs.htm#STATE_UP">STATE_UP</a> || <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_state">state</a> == <a href="defs.htm#STATE_TOP">STATE_TOP</a>)
		{
			starte = <a href="qc-glob.htm#self">self</a>;
			<b>do</b>
			{
				<a href="doors.htm#door_go_down">door_go_down</a> ();
				<a href="qc-glob.htm#self">self</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_enemy">enemy</a>;
			} <b>while</b> ( (<a href="qc-glob.htm#self">self</a> != starte) &amp;&amp; (<a href="qc-glob.htm#self">self</a> != <a href="qc-glob.htm#world">world</a>) );
			<a href="qc-glob.htm#self">self</a> = oself;
			<b>return</b>;
		}
	}
	
<i>// trigger all paired doors</i>
	starte = <a href="qc-glob.htm#self">self</a>;
	<b>do</b>
	{
		<a href="doors.htm#door_go_up">door_go_up</a> ();
		<a href="qc-glob.htm#self">self</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_enemy">enemy</a>;
	} <b>while</b> ( (<a href="qc-glob.htm#self">self</a> != starte) &amp;&amp; (<a href="qc-glob.htm#self">self</a> != <a href="qc-glob.htm#world">world</a>) );
	<a href="qc-glob.htm#self">self</a> = oself;
};


<a href="qc-types.htm#void">void</a>() <b>door_use</b><a name="door_use">=</a>
{
	<b>local</b> <a href="qc-types.htm#entity">entity</a> oself;

	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_message">message</a> = <b>""</b>;			<i>// door message are for touch only</i>
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_owner">owner</a>.<a href="qc-enty.htm#dot_message">message</a> = <b>""</b>;	
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_enemy">enemy</a>.<a href="qc-enty.htm#dot_message">message</a> = <b>""</b>;
	oself = <a href="qc-glob.htm#self">self</a>;
	<a href="qc-glob.htm#self">self</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_owner">owner</a>;
	<a href="doors.htm#door_fire">door_fire</a> ();
	<a href="qc-glob.htm#self">self</a> = oself;
};


<a href="qc-types.htm#void">void</a>() <b>door_trigger_touch</b><a name="door_trigger_touch">=</a>
{
	<b>if</b> (<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_health">health</a> &lt;= 0)
		<b>return</b>;

	<b>if</b> (<a href="qc-glob.htm#time">time</a> &lt; <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_attack_finished">attack_finished</a>)
		<b>return</b>;
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_attack_finished">attack_finished</a> = <a href="qc-glob.htm#time">time</a> + 1;

	<a href="defs.htm#activator">activator</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>.<a href="qc-enty.htm#dot_owner">owner</a>;
	<a href="doors.htm#door_use">door_use</a> ();
};


<a href="qc-types.htm#void">void</a>() <b>door_killed</b><a name="door_killed">=</a>
{
	<b>local</b> <a href="qc-types.htm#entity">entity</a> oself;
	
	oself = <a href="qc-glob.htm#self">self</a>;
	<a href="qc-glob.htm#self">self</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-enty.htm#dot_health">health</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_max_health">max_health</a>;
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_takedamage">takedamage</a> = <a href="qc-defs.htm#DAMAGE_NO">DAMAGE_NO</a>;	<i>// wil be reset upon return</i>
	<a href="doors.htm#door_use">door_use</a> ();
	<a href="qc-glob.htm#self">self</a> = oself;
};


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

⌨️ 快捷键说明

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