📄 triggers.htm
字号:
<a href="qc-built.htm#objerror">objerror</a> (<b>"no targetname"</b>);
};
<a href="qc-types.htm#void">void</a>() <b>teleport_use</b><a name="teleport_use">=</a>
{
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_nextthink">nextthink</a> = <a href="qc-glob.htm#time">time</a> + 0.2;
<a href="qc-glob.htm#force_retouch">force_retouch</a> = 2; <i>// make sure even still objects get hit</i>
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_think">think</a> = <a href="subs.htm#SUB_Null">SUB_Null</a>;
};
<i>/*QUAKED trigger_teleport (.5 .5 .5) ? PLAYER_ONLY SILENT
Any object touching this will be transported to the corresponding info_teleport_destination entity. You must set the "target" field, and create an object with a "targetname" field that matches.
If the trigger_teleport has a targetname, it will only teleport entities when it has been fired.
*/</i>
<a href="qc-types.htm#void">void</a>() <b>trigger_teleport</b><a name="trigger_teleport">=</a>
{
<b>local</b> <a href="qc-types.htm#vector">vector</a> o;
<a href="subs.htm#InitTrigger">InitTrigger</a> ();
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_touch">touch</a> = <a href="triggers.htm#teleport_touch">teleport_touch</a>;
<i>// find the destination </i>
<b>if</b> (!<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_target">target</a>)
<a href="qc-built.htm#objerror">objerror</a> (<b>"no target"</b>);
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_use">use</a> = <a href="triggers.htm#teleport_use">teleport_use</a>;
<b>if</b> (!(<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_spawnflags">spawnflags</a> & <a href="triggers.htm#SILENT">SILENT</a>))
{
<a href="qc-built.htm#precache_sound">precache_sound</a> (<b>"ambience/hum1.wav"</b>);
o = (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_mins">mins</a> + <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_maxs">maxs</a>)*0.5;
<a href="qc-built.htm#ambientsound">ambientsound</a> (o, <b>"ambience/hum1.wav"</b>,0.5 , <a href="qc-defs.htm#ATTN_STATIC">ATTN_STATIC</a>);
}
};
<i>/*
==============================================================================
trigger_setskill
==============================================================================
*/</i>
<a href="qc-types.htm#void">void</a>() <b>trigger_skill_touch</b><a name="trigger_skill_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>;
<a href="qc-built.htm#cvar_set">cvar_set</a> (<b>"skill"</b>, <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_message">message</a>);
};
<i>/*QUAKED trigger_setskill (.5 .5 .5) ?
sets skill level to the value of "message".
Only used on start map.
*/</i>
<a href="qc-types.htm#void">void</a>() <b>trigger_setskill</b><a name="trigger_setskill">=</a>
{
<a href="subs.htm#InitTrigger">InitTrigger</a> ();
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_touch">touch</a> = <a href="triggers.htm#trigger_skill_touch">trigger_skill_touch</a>;
};
<i>/*
==============================================================================
ONLY REGISTERED TRIGGERS
==============================================================================
*/</i>
<a href="qc-types.htm#void">void</a>() <b>trigger_onlyregistered_touch</b><a name="trigger_onlyregistered_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_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_attack_finished">attack_finished</a> = <a href="qc-glob.htm#time">time</a> + 2;
<b>if</b> (<a href="qc-built.htm#cvar">cvar</a>(<b>"registered"</b>))
{
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_message">message</a> = <b>""</b>;
<a href="subs.htm#SUB_UseTargets">SUB_UseTargets</a> ();
<a href="qc-built.htm#remove">remove</a> (<a href="qc-glob.htm#self">self</a>);
}
<b>else</b>
{
<b>if</b> (<a href="qc-glob.htm#self">self</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_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_BODY">CHAN_BODY</a>, <b>"misc/talk.wav"</b>, 1, <a href="qc-defs.htm#ATTN_NORM">ATTN_NORM</a>);
}
}
};
<i>/*QUAKED trigger_onlyregistered (.5 .5 .5) ?
Only fires if playing the registered version, otherwise prints the message
*/</i>
<a href="qc-types.htm#void">void</a>() <b>trigger_onlyregistered</b><a name="trigger_onlyregistered">=</a>
{
<a href="qc-built.htm#precache_sound">precache_sound</a> (<b>"misc/talk.wav"</b>);
<a href="subs.htm#InitTrigger">InitTrigger</a> ();
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_touch">touch</a> = <a href="triggers.htm#trigger_onlyregistered_touch">trigger_onlyregistered_touch</a>;
};
<i>//============================================================================</i>
<a href="qc-types.htm#void">void</a>() <b>hurt_on</b><a name="hurt_on">=</a>
{
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_solid">solid</a> = <a href="qc-defs.htm#SOLID_TRIGGER">SOLID_TRIGGER</a>;
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_nextthink">nextthink</a> = -1;
};
<a href="qc-types.htm#void">void</a>() <b>hurt_touch</b><a name="hurt_touch">=</a>
{
<b>if</b> (<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_takedamage">takedamage</a>)
{
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_solid">solid</a> = <a href="qc-defs.htm#SOLID_NOT">SOLID_NOT</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>);
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_think">think</a> = <a href="triggers.htm#hurt_on">hurt_on</a>;
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_nextthink">nextthink</a> = <a href="qc-glob.htm#time">time</a> + 1;
}
<b>return</b>;
};
<i>/*QUAKED trigger_hurt (.5 .5 .5) ?
Any object touching this will be hurt
set dmg to damage amount
defalt dmg = 5
*/</i>
<a href="qc-types.htm#void">void</a>() <b>trigger_hurt</b><a name="trigger_hurt">=</a>
{
<a href="subs.htm#InitTrigger">InitTrigger</a> ();
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_touch">touch</a> = <a href="triggers.htm#hurt_touch">hurt_touch</a>;
<b>if</b> (!<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_dmg">dmg</a>)
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_dmg">dmg</a> = 5;
};
<i>//============================================================================</i>
<a href="qc-types.htm#float">float</a> <b><a name="PUSH_ONCE">PUSH_ONCE</a></b> = 1;
<a href="qc-types.htm#void">void</a>() <b>trigger_push_touch</b><a name="trigger_push_touch">=</a>
{
<b>if</b> (<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_classname">classname</a> == <b>"grenade"</b>)
<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_velocity">velocity</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_speed">speed</a> * <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_movedir">movedir</a> * 10;
<b>else</b> <b>if</b> (<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_health">health</a> > 0)
{
<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_velocity">velocity</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_speed">speed</a> * <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_movedir">movedir</a> * 10;
<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_fly_sound">fly_sound</a> < <a href="qc-glob.htm#time">time</a>)
{
<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_fly_sound">fly_sound</a> = <a href="qc-glob.htm#time">time</a> + 1.5;
<a href="qc-built.htm#sound">sound</a> (<a href="qc-glob.htm#other">other</a>, <a href="qc-defs.htm#CHAN_AUTO">CHAN_AUTO</a>, <b>"ambience/windfly.wav"</b>, 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_spawnflags">spawnflags</a> & <a href="triggers.htm#PUSH_ONCE">PUSH_ONCE</a>)
<a href="qc-built.htm#remove">remove</a>(<a href="qc-glob.htm#self">self</a>);
};
<i>/*QUAKED trigger_push (.5 .5 .5) ? PUSH_ONCE
Pushes the player
*/</i>
<a href="qc-types.htm#void">void</a>() <b>trigger_push</b><a name="trigger_push">=</a>
{
<a href="subs.htm#InitTrigger">InitTrigger</a> ();
<a href="qc-built.htm#precache_sound">precache_sound</a> (<b>"ambience/windfly.wav"</b>);
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_touch">touch</a> = <a href="triggers.htm#trigger_push_touch">trigger_push_touch</a>;
<b>if</b> (!<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_speed">speed</a>)
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_speed">speed</a> = 1000;
};
<i>//============================================================================</i>
<a href="qc-types.htm#void">void</a>() <b>trigger_monsterjump_touch</b><a name="trigger_monsterjump_touch">=</a>
{
<b>if</b> ( <a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_flags">flags</a> & (<a href="defs.htm#FL_MONSTER">FL_MONSTER</a> | <a href="defs.htm#FL_FLY">FL_FLY</a> | <a href="defs.htm#FL_SWIM">FL_SWIM</a>) != <a href="defs.htm#FL_MONSTER">FL_MONSTER</a> )
<b>return</b>;
<i>// set XY even if not on ground, so the jump will clear lips</i>
<a href="qc-glob.htm#other">other</a>.velocity_x = <a href="qc-glob.htm#self">self</a>.movedir_x * <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_speed">speed</a>;
<a href="qc-glob.htm#other">other</a>.velocity_y = <a href="qc-glob.htm#self">self</a>.movedir_y * <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_speed">speed</a>;
<b>if</b> ( !(<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>) )
<b>return</b>;
<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>.velocity_z = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_height">height</a>;
};
<i>/*QUAKED trigger_monsterjump (.5 .5 .5) ?
Walking monsters that touch this will jump in the direction of the trigger's angle
"speed" default to 200, the speed thrown forward
"height" default to 200, the speed thrown upwards
*/</i>
<a href="qc-types.htm#void">void</a>() <b>trigger_monsterjump</b><a name="trigger_monsterjump">=</a>
{
<b>if</b> (!<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_speed">speed</a>)
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_speed">speed</a> = 200;
<b>if</b> (!<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_height">height</a>)
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_height">height</a> = 200;
<b>if</b> (<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_angles">angles</a> = '0 360 0';
<a href="subs.htm#InitTrigger">InitTrigger</a> ();
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_touch">touch</a> = <a href="triggers.htm#trigger_monsterjump_touch">trigger_monsterjump_touch</a>;
};
</pre></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -