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

📄 items.htm

📁 Quake 的 各 种 文 档 格 式 说 明
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<html><head><title>items.qc</title></head><body bgcolor="#C0F0D0">
<base target=examine>
<pre>
<a href="qc-types.htm#void">void</a>() <a href="weapons.htm#W_SetCurrentAmmo">W_SetCurrentAmmo</a>;
<i>/* ALL LIGHTS SHOULD BE 0 1 0 IN COLOR ALL OTHER ITEMS SHOULD
BE .8 .3 .4 IN COLOR */</i>



<a href="qc-types.htm#void">void</a>() <b>SUB_regen</b><a name="SUB_regen">=</a>
{
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_model">model</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_mdl">mdl</a>;		<i>// restore original model</i>
	<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>;	<i>// allow it to be touched again</i>
	<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>, <b>"items/itembk2.wav"</b>, 1, <a href="qc-defs.htm#ATTN_NORM">ATTN_NORM</a>);	<i>// play respawn sound</i>
	<a href="qc-built.htm#setorigin">setorigin</a> (<a href="qc-glob.htm#self">self</a>, <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_origin">origin</a>);
};



<i>/*QUAKED noclass (0 0 0) (-8 -8 -8) (8 8 8)
prints a warning message when spawned
*/</i>

<a href="qc-types.htm#void">void</a>() <b>noclass</b><a name="noclass">=</a>
{
	<a href="qc-built.htm#dprint">dprint</a> (<b>"noclass spawned at"</b>);
	<a href="qc-built.htm#dprint">dprint</a> (vtos(<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_origin">origin</a>));
	<a href="qc-built.htm#dprint">dprint</a> (<b>"\n"</b>);
	<a href="qc-built.htm#remove">remove</a> (<a href="qc-glob.htm#self">self</a>);
};



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

plants the object on the floor
============
*/</i>

<a href="qc-types.htm#void">void</a>() <b>PlaceItem</b><a name="PlaceItem">=</a>
{
	<b>local</b> <a href="qc-types.htm#float">float</a>	oldz;

	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_mdl">mdl</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_model">model</a>;		<i>// so it can be restored on respawn</i>
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_flags">flags</a> = <a href="defs.htm#FL_ITEM">FL_ITEM</a>;		<i>// make extra wide</i>
	<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_movetype">movetype</a> = <a href="qc-defs.htm#MOVETYPE_TOSS">MOVETYPE_TOSS</a>;	
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_velocity">velocity</a> = '0 0 0';
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_origin_z">origin_z</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_origin_z">origin_z</a> + 6;
	oldz = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_origin_z">origin_z</a>;
	<b>if</b> (!<a href="qc-built.htm#droptofloor">droptofloor</a>())
	{
		<a href="qc-built.htm#dprint">dprint</a> (<b>"Bonus item fell out of level at "</b>);
		<a href="qc-built.htm#dprint">dprint</a> (vtos(<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_origin">origin</a>));
		<a href="qc-built.htm#dprint">dprint</a> (<b>"\n"</b>);
		<a href="qc-built.htm#remove">remove</a>(<a href="qc-glob.htm#self">self</a>);
		<b>return</b>;
	}
};

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

Sets the clipping size and plants the object on the floor
============
*/</i>

<a href="qc-types.htm#void">void</a>() <b>StartItem</b><a name="StartItem">=</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;	<i>// items start after other solids</i>
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_think">think</a> = <a href="items.htm#PlaceItem">PlaceItem</a>;
};

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

HEALTH BOX

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

<i>//</i>
<i>// T_Heal: add health to an entity, limiting health to max_health</i>
<i>// "ignore" will ignore max_health limit</i>
<i>//</i>
<a href="qc-types.htm#float">float</a> (<a href="qc-types.htm#entity">entity</a> e, <a href="qc-types.htm#float">float</a> healamount, <a href="qc-types.htm#float">float</a> ignore) <b>T_Heal</b><a name="T_Heal">=</a>
{
	<b>if</b> (e.<a href="qc-enty.htm#dot_health">health</a> &lt;= 0)
		return 0;
	<b>if</b> ((!ignore) &amp;&amp; (e.<a href="qc-enty.htm#dot_health">health</a> &gt;= <a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_max_health">max_health</a>))
		return 0;
	healamount = <a href="qc-built.htm#ceil">ceil</a>(healamount);

	e.<a href="qc-enty.htm#dot_health">health</a> = e.<a href="qc-enty.htm#dot_health">health</a> + healamount;
	<b>if</b> ((!ignore) &amp;&amp; (e.<a href="qc-enty.htm#dot_health">health</a> &gt;= <a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_max_health">max_health</a>))
		e.<a href="qc-enty.htm#dot_health">health</a> = <a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_max_health">max_health</a>;
		
	<b>if</b> (e.<a href="qc-enty.htm#dot_health">health</a> &gt; 250)
		e.<a href="qc-enty.htm#dot_health">health</a> = 250;
	return 1;
};

<i>/*QUAKED item_health (.3 .3 1) (0 0 0) (32 32 32) rotten megahealth
Health box. Normally gives 25 points.
Rotten box heals 5-10 points,
megahealth will add 100 health, then 
rot you down to your maximum health limit, 
one point per second.
*/</i>


<a href="qc-types.htm#float">float</a> <b><a name="H_ROTTEN">H_ROTTEN</a></b> = 1;
<a href="qc-types.htm#float">float</a> <b><a name="H_MEGA">H_MEGA</a></b> = 2;
.<a href="qc-types.htm#dot_float">float</a>	healamount, healtype;
<a href="qc-types.htm#void">void</a>() <a href="items.htm#health_touch">health_touch</a>;
<a href="qc-types.htm#void">void</a>() <a href="items.htm#item_megahealth_rot">item_megahealth_rot</a>;

<a href="qc-types.htm#void">void</a>() <b>item_health</b><a name="item_health">=</a>
{	
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_touch">touch</a> = <a href="items.htm#health_touch">health_touch</a>;

	<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_spawnflags">spawnflags</a> &amp; <a href="items.htm#H_ROTTEN">H_ROTTEN</a>)
	{
		<a href="qc-built.htm#precache_model">precache_model</a>(<b>"maps/b_bh10.bsp"</b>);

		<a href="qc-built.htm#precache_sound">precache_sound</a>(<b>"items/r_item1.wav"</b>);
		<a href="qc-built.htm#setmodel">setmodel</a>(<a href="qc-glob.htm#self">self</a>, <b>"maps/b_bh10.bsp"</b>);
		<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_noise">noise</a> = <b>"items/r_item1.wav"</b>;
		<a href="qc-glob.htm#self">self</a>.healamount = 15;
		<a href="qc-glob.htm#self">self</a>.healtype = 0;
	}
	<b>else</b>
	<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_spawnflags">spawnflags</a> &amp; <a href="items.htm#H_MEGA">H_MEGA</a>)
	{
		<a href="qc-built.htm#precache_model">precache_model</a>(<b>"maps/b_bh100.bsp"</b>);
		<a href="qc-built.htm#precache_sound">precache_sound</a>(<b>"items/r_item2.wav"</b>);
		<a href="qc-built.htm#setmodel">setmodel</a>(<a href="qc-glob.htm#self">self</a>, <b>"maps/b_bh100.bsp"</b>);
		<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_noise">noise</a> = <b>"items/r_item2.wav"</b>;
		<a href="qc-glob.htm#self">self</a>.healamount = 100;
		<a href="qc-glob.htm#self">self</a>.healtype = 2;
	}
	<b>else</b>
	{
		<a href="qc-built.htm#precache_model">precache_model</a>(<b>"maps/b_bh25.bsp"</b>);
		<a href="qc-built.htm#precache_sound">precache_sound</a>(<b>"items/health1.wav"</b>);
		<a href="qc-built.htm#setmodel">setmodel</a>(<a href="qc-glob.htm#self">self</a>, <b>"maps/b_bh25.bsp"</b>);
		<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_noise">noise</a> = <b>"items/health1.wav"</b>;
		<a href="qc-glob.htm#self">self</a>.healamount = 25;
		<a href="qc-glob.htm#self">self</a>.healtype = 1;
	}
	<a href="qc-built.htm#setsize">setsize</a> (<a href="qc-glob.htm#self">self</a>, '0 0 0', '32 32 56');
	<a href="items.htm#StartItem">StartItem</a> ();
};


<a href="qc-types.htm#void">void</a>() <b>health_touch</b><a name="health_touch">=</a>
{
	<b>local</b>	<a href="qc-types.htm#float">float</a> amount;
	<b>local</b>	<a href="qc-types.htm#string">string</a>	s;
	
	<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>.healtype == 2) <i>// Megahealth?  Ignore max_health...</i>
	{
		<b>if</b> (<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_health">health</a> &gt;= 250)
			<b>return</b>;
		<b>if</b> (!<a href="items.htm#T_Heal">T_Heal</a>(<a href="qc-glob.htm#other">other</a>, <a href="qc-glob.htm#self">self</a>.healamount, 1))
			<b>return</b>;
	}
	<b>else</b>
	{
		<b>if</b> (!<a href="items.htm#T_Heal">T_Heal</a>(<a href="qc-glob.htm#other">other</a>, <a href="qc-glob.htm#self">self</a>.healamount, 0))
			<b>return</b>;
	}
	
	<a href="qc-built.htm#sprint">sprint</a>(<a href="qc-glob.htm#other">other</a>, <b>"You receive "</b>);
	s = <a href="qc-built.htm#ftos">ftos</a>(<a href="qc-glob.htm#self">self</a>.healamount);
	<a href="qc-built.htm#sprint">sprint</a>(<a href="qc-glob.htm#other">other</a>, s);
	<a href="qc-built.htm#sprint">sprint</a>(<a href="qc-glob.htm#other">other</a>, <b>" health\n"</b>);
	
<i>// health touch sound</i>
	<a href="qc-built.htm#sound">sound</a>(<a href="qc-glob.htm#other">other</a>, <a href="qc-defs.htm#CHAN_ITEM">CHAN_ITEM</a>, <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_noise">noise</a>, 1, <a href="qc-defs.htm#ATTN_NORM">ATTN_NORM</a>);

	<a href="qc-built.htm#stuffcmd">stuffcmd</a> (<a href="qc-glob.htm#other">other</a>, <b>"bf\n"</b>);
	
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_model">model</a> = <a href="defs.htm#string_null">string_null</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>;

	<i>// Megahealth = rot down the player's super health</i>
	<b>if</b> (<a href="qc-glob.htm#self">self</a>.healtype == 2)
	{
		<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-defs.htm#IT_SUPERHEALTH">IT_SUPERHEALTH</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> + 5;
		<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_think">think</a> = <a href="items.htm#item_megahealth_rot">item_megahealth_rot</a>;
		<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_owner">owner</a> = <a href="qc-glob.htm#other">other</a>;
	}
	<b>else</b>
	{
		<b>if</b> (<a href="qc-glob.htm#deathmatch">deathmatch</a> != 2)		<i>// deathmatch 2 is the silly old rules</i>
		{
			<b>if</b> (<a href="qc-glob.htm#deathmatch">deathmatch</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> + 20;
			<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_think">think</a> = <a href="items.htm#SUB_regen">SUB_regen</a>;
		}
	}
	
	<a href="defs.htm#activator">activator</a> = <a href="qc-glob.htm#other">other</a>;
	<a href="subs.htm#SUB_UseTargets">SUB_UseTargets</a>();				<i>// fire all targets / killtargets</i>
};	

<a href="qc-types.htm#void">void</a>() <b>item_megahealth_rot</b><a name="item_megahealth_rot">=</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>;
	
	<b>if</b> (<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_health">health</a> &gt; <a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_max_health">max_health</a>)
	{
		<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_health">health</a> - 1;
		<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>// it is possible for a player to die and respawn between rots, so don't</i>
<i>// just blindly subtract the flag off</i>
	<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#other">other</a>.<a href="qc-enty.htm#dot_items">items</a> &amp; <a href="qc-defs.htm#IT_SUPERHEALTH">IT_SUPERHEALTH</a>);
	
	<b>if</b> (<a href="qc-glob.htm#deathmatch">deathmatch</a> == 1)	<i>// deathmatch 2 is silly old rules</i>

⌨️ 快捷键说明

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