📄 doors.htm
字号:
Prints messages and opens key doors
================
*/</i>
<a href="qc-types.htm#void">void</a>() <b>door_touch</b><a name="door_touch">=</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>;
<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_attack_finished">attack_finished</a> > <a href="qc-glob.htm#time">time</a>)
<b>return</b>;
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_owner">owner</a>.<a href="qc-enty.htm#dot_attack_finished">attack_finished</a> = <a href="qc-glob.htm#time">time</a> + 2;
<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_message">message</a> != <b>""</b>)
{
<a href="qc-built.htm#centerprint">centerprint</a> (<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>.<a href="qc-enty.htm#dot_message">message</a>);
<a href="qc-built.htm#sound">sound</a> (<a href="qc-glob.htm#other">other</a>, <a href="qc-defs.htm#CHAN_VOICE">CHAN_VOICE</a>, <b>"misc/talk.wav"</b>, 1, <a href="qc-defs.htm#ATTN_NORM">ATTN_NORM</a>);
}
<i>// key door stuff</i>
<b>if</b> (!<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_items">items</a>)
<b>return</b>;
<i>// FIXME: blink key on player's status bar</i>
<b>if</b> ( (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_items">items</a> & <a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_items">items</a>) != <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_items">items</a> )
{
<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_items">items</a> == <a href="qc-defs.htm#IT_KEY1">IT_KEY1</a>)
{
<b>if</b> (<a href="qc-glob.htm#world">world</a>.<a href="qc-enty.htm#dot_worldtype">worldtype</a> == 2)
{
<a href="qc-built.htm#centerprint">centerprint</a> (<a href="qc-glob.htm#other">other</a>, <b>"You need the silver keycard"</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_noise3">noise3</a>, 1, <a href="qc-defs.htm#ATTN_NORM">ATTN_NORM</a>);
}
<b>else</b> <b>if</b> (<a href="qc-glob.htm#world">world</a>.<a href="qc-enty.htm#dot_worldtype">worldtype</a> == 1)
{
<a href="qc-built.htm#centerprint">centerprint</a> (<a href="qc-glob.htm#other">other</a>, <b>"You need the silver runekey"</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_noise3">noise3</a>, 1, <a href="qc-defs.htm#ATTN_NORM">ATTN_NORM</a>);
}
<b>else</b> <b>if</b> (<a href="qc-glob.htm#world">world</a>.<a href="qc-enty.htm#dot_worldtype">worldtype</a> == 0)
{
<a href="qc-built.htm#centerprint">centerprint</a> (<a href="qc-glob.htm#other">other</a>, <b>"You need the silver key"</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_noise3">noise3</a>, 1, <a href="qc-defs.htm#ATTN_NORM">ATTN_NORM</a>);
}
}
<b>else</b>
{
<b>if</b> (<a href="qc-glob.htm#world">world</a>.<a href="qc-enty.htm#dot_worldtype">worldtype</a> == 2)
{
<a href="qc-built.htm#centerprint">centerprint</a> (<a href="qc-glob.htm#other">other</a>, <b>"You need the gold keycard"</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_noise3">noise3</a>, 1, <a href="qc-defs.htm#ATTN_NORM">ATTN_NORM</a>);
}
<b>else</b> <b>if</b> (<a href="qc-glob.htm#world">world</a>.<a href="qc-enty.htm#dot_worldtype">worldtype</a> == 1)
{
<a href="qc-built.htm#centerprint">centerprint</a> (<a href="qc-glob.htm#other">other</a>, <b>"You need the gold runekey"</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_noise3">noise3</a>, 1, <a href="qc-defs.htm#ATTN_NORM">ATTN_NORM</a>);
}
<b>else</b> <b>if</b> (<a href="qc-glob.htm#world">world</a>.<a href="qc-enty.htm#dot_worldtype">worldtype</a> == 0)
{
<a href="qc-built.htm#centerprint">centerprint</a> (<a href="qc-glob.htm#other">other</a>, <b>"You need the gold key"</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_noise3">noise3</a>, 1, <a href="qc-defs.htm#ATTN_NORM">ATTN_NORM</a>);
}
}
<b>return</b>;
}
<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_items">items</a> = <a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_items">items</a> - <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_items">items</a>;
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_touch">touch</a> = <a href="subs.htm#SUB_Null">SUB_Null</a>;
<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_enemy">enemy</a>)
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_enemy">enemy</a>.<a href="qc-enty.htm#dot_touch">touch</a> = <a href="subs.htm#SUB_Null">SUB_Null</a>; <i>// get paired door</i>
<a href="doors.htm#door_use">door_use</a> ();
};
<i>/*
=============================================================================
SPAWNING FUNCTIONS
=============================================================================
*/</i>
<a href="qc-types.htm#entity">entity</a>(<a href="qc-types.htm#vector">vector</a> fmins, <a href="qc-types.htm#vector">vector</a> fmaxs) <b>spawn_field</b><a name="spawn_field">=</a>
{
<b>local</b> <a href="qc-types.htm#entity">entity</a> trigger;
<b>local</b> <a href="qc-types.htm#vector">vector</a> t1, t2;
trigger = <a href="qc-built.htm#spawn">spawn</a>();
trigger.<a href="qc-enty.htm#dot_movetype">movetype</a> = <a href="qc-defs.htm#MOVETYPE_NONE">MOVETYPE_NONE</a>;
trigger.<a href="qc-enty.htm#dot_solid">solid</a> = <a href="qc-defs.htm#SOLID_TRIGGER">SOLID_TRIGGER</a>;
trigger.<a href="qc-enty.htm#dot_owner">owner</a> = <a href="qc-glob.htm#self">self</a>;
trigger.<a href="qc-enty.htm#dot_touch">touch</a> = <a href="doors.htm#door_trigger_touch">door_trigger_touch</a>;
t1 = fmins;
t2 = fmaxs;
<a href="qc-built.htm#setsize">setsize</a> (trigger, t1 - '60 60 8', t2 + '60 60 8');
<b>return</b> (trigger);
};
<a href="qc-types.htm#float">float</a> (<a href="qc-types.htm#entity">entity</a> e1, <a href="qc-types.htm#entity">entity</a> e2) <b>EntitiesTouching</b><a name="EntitiesTouching">=</a>
{
<b>if</b> (e1.mins_x > e2.maxs_x)
return FALSE;
<b>if</b> (e1.mins_y > e2.maxs_y)
return FALSE;
<b>if</b> (e1.mins_z > e2.maxs_z)
return FALSE;
<b>if</b> (e1.maxs_x < e2.mins_x)
return FALSE;
<b>if</b> (e1.maxs_y < e2.mins_y)
return FALSE;
<b>if</b> (e1.maxs_z < e2.mins_z)
return FALSE;
return TRUE;
};
<i>/*
=============
LinkDoors
=============
*/</i>
<a href="qc-types.htm#void">void</a>() <b>LinkDoors</b><a name="LinkDoors">=</a>
{
<b>local</b> <a href="qc-types.htm#entity">entity</a> t, starte;
<b>local</b> <a href="qc-types.htm#vector">vector</a> cmins, cmaxs;
<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_enemy">enemy</a>)
<b>return</b>; <i>// already linked by another door</i>
<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_spawnflags">spawnflags</a> & 4)
{
<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_enemy">enemy</a> = <a href="qc-glob.htm#self">self</a>;
<b>return</b>; <i>// don't want to link this door</i>
}
cmins = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_mins">mins</a>;
cmaxs = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_maxs">maxs</a>;
starte = <a href="qc-glob.htm#self">self</a>;
t = <a href="qc-glob.htm#self">self</a>;
<b>do</b>
{
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_owner">owner</a> = starte; <i>// master door</i>
<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_health">health</a>)
starte.<a href="qc-enty.htm#dot_health">health</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_health">health</a>;
<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_targetname">targetname</a>)
starte.<a href="qc-enty.htm#dot_targetname">targetname</a> = <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_message">message</a> != <b>""</b>)
starte.<a href="qc-enty.htm#dot_message">message</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_message">message</a>;
t = <a href="qc-built.htm#find">find</a> (t, classname, <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_classname">classname</a>);
<b>if</b> (!t)
{
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_enemy">enemy</a> = starte; <i>// make the chain a loop</i>
<i>// shootable, fired, or key doors just needed the owner/enemy links,</i>
<i>// they don't spawn a field</i>
<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>;
<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_health">health</a>)
<b>return</b>;
<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_targetname">targetname</a>)
<b>return</b>;
<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_items">items</a>)
<b>return</b>;
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_owner">owner</a>.<a href="qc-enty.htm#dot_trigger_field">trigger_field</a> = <a href="doors.htm#spawn_field">spawn_field</a>(cmins, cmaxs);
<b>return</b>;
}
<b>if</b> (<a href="doors.htm#EntitiesTouching">EntitiesTouching</a>(<a href="qc-glob.htm#self">self</a>,t))
{
<b>if</b> (t.<a href="qc-enty.htm#dot_enemy">enemy</a>)
<a href="qc-built.htm#objerror">objerror</a> (<b>"cross connected doors"</b>);
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_enemy">enemy</a> = t;
<a href="qc-glob.htm#self">self</a> = t;
<b>if</b> (t.mins_x < cmins_x)
cmins_x = t.mins_x;
<b>if</b> (t.mins_y < cmins_y)
cmins_y = t.mins_y;
<b>if</b> (t.mins_z < cmins_z)
cmins_z = t.mins_z;
<b>if</b> (t.maxs_x > cmaxs_x)
cmaxs_x = t.maxs_x;
<b>if</b> (t.maxs_y > cmaxs_y)
cmaxs_y = t.maxs_y;
<b>if</b> (t.maxs_z > cmaxs_z)
cmaxs_z = t.maxs_z;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -