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

📄 weapons.htm

📁 Quake 的 各 种 文 档 格 式 说 明
💻 HTM
📖 第 1 页 / 共 5 页
字号:
	
	vel = <a href="qc-built.htm#normalize">normalize</a>(dir + <a href="qc-built.htm#v_up">v_up</a>*<a href="weapons.htm#crandom">crandom</a>() + <a href="qc-built.htm#v_right">v_right</a>*<a href="weapons.htm#crandom">crandom</a>());
	vel = vel + 2*<a href="qc-built.htm#trace_plane_normal">trace_plane_normal</a>;
	vel = vel * 200;

	org = <a href="qc-built.htm#trace_endpos">trace_endpos</a> - dir*4;

	<b>if</b> (<a href="qc-built.htm#trace_ent">trace_ent</a>.<a href="qc-enty.htm#dot_takedamage">takedamage</a>)
	{
		<a href="weapons.htm#SpawnBlood">SpawnBlood</a> (org, vel*0.2, damage);
		<a href="weapons.htm#AddMultiDamage">AddMultiDamage</a> (<a href="qc-built.htm#trace_ent">trace_ent</a>, damage);
	}
	<b>else</b>
	{
		<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_GUNSHOT">TE_GUNSHOT</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);
	}
};

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

Used by shotgun, super shotgun, and enemy soldier firing
Go to the trouble of combining multiple pellets into a single damage call.
================
*/</i>

<a href="qc-types.htm#void">void</a>(<a href="qc-types.htm#float">float</a> shotcount, <a href="qc-types.htm#vector">vector</a> dir, <a href="qc-types.htm#vector">vector</a> spread) <b>FireBullets</b><a name="FireBullets">=</a>
{
	<b>local</b>	<a href="qc-types.htm#vector">vector</a> direction;
	<b>local</b>	<a href="qc-types.htm#vector">vector</a>	src;
	
	<a href="qc-built.htm#makevectors">makevectors</a>(<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_v_angle">v_angle</a>);

	src = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_origin">origin</a> + <a href="qc-built.htm#v_forward">v_forward</a>*10;
	src_z = <a href="qc-glob.htm#self">self</a>.absmin_z + <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_size_z">size_z</a> * 0.7;

	<a href="weapons.htm#ClearMultiDamage">ClearMultiDamage</a> ();
	<b>while</b> (shotcount &gt; 0)
	{
		direction = dir + <a href="weapons.htm#crandom">crandom</a>()*spread_x*<a href="qc-built.htm#v_right">v_right</a> + <a href="weapons.htm#crandom">crandom</a>()*spread_y*<a href="qc-built.htm#v_up">v_up</a>;

		<a href="qc-built.htm#traceline">traceline</a> (src, src + direction*2048, <a href="defs.htm#FALSE">FALSE</a>, <a href="qc-glob.htm#self">self</a>);
		<b>if</b> (<a href="qc-built.htm#trace_fraction">trace_fraction</a> != 1.0)
			<a href="weapons.htm#TraceAttack">TraceAttack</a> (4, direction);

		shotcount = shotcount - 1;
	}
	<a href="weapons.htm#ApplyMultiDamage">ApplyMultiDamage</a> ();
};

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

<a href="qc-types.htm#void">void</a>() <b>W_FireShotgun</b><a name="W_FireShotgun">=</a>
{
	<b>local</b> <a href="qc-types.htm#vector">vector</a> dir;

	<a href="qc-built.htm#sound">sound</a> (<a href="qc-glob.htm#self">self</a>, <a href="qc-defs.htm#CHAN_WEAPON">CHAN_WEAPON</a>, <b>"weapons/guncock.wav"</b>, 1, <a href="qc-defs.htm#ATTN_NORM">ATTN_NORM</a>);	

	<a href="qc-glob.htm#self">self</a>.punchangle_x = -2;
	
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_currentammo">currentammo</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_ammo_shells">ammo_shells</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_ammo_shells">ammo_shells</a> - 1;
	dir = <a href="qc-built.htm#aim">aim</a> (<a href="qc-glob.htm#self">self</a>, 100000);
	<a href="weapons.htm#FireBullets">FireBullets</a> (6, dir, '0.04 0.04 0');
};


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

<a href="qc-types.htm#void">void</a>() <b>W_FireSuperShotgun</b><a name="W_FireSuperShotgun">=</a>
{
	<b>local</b> <a href="qc-types.htm#vector">vector</a> dir;

	<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_currentammo">currentammo</a> == 1)
	{
		<a href="weapons.htm#W_FireShotgun">W_FireShotgun</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_WEAPON">CHAN_WEAPON</a>, <b>"weapons/shotgn2.wav"</b>, 1, <a href="qc-defs.htm#ATTN_NORM">ATTN_NORM</a>);	

	<a href="qc-glob.htm#self">self</a>.punchangle_x = -4;
	
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_currentammo">currentammo</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_ammo_shells">ammo_shells</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_ammo_shells">ammo_shells</a> - 2;
	dir = <a href="qc-built.htm#aim">aim</a> (<a href="qc-glob.htm#self">self</a>, 100000);
	<a href="weapons.htm#FireBullets">FireBullets</a> (14, dir, '0.14 0.08 0');
};


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

ROCKETS

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


<a href="qc-types.htm#void">void</a>() <b>s_explode1</b><a name="s_explode1">=</a>	[0,		s_explode2] {};
<a href="qc-types.htm#void">void</a>() <b>s_explode2</b><a name="s_explode2">=</a>	[1,		s_explode3] {};
<a href="qc-types.htm#void">void</a>() <b>s_explode3</b><a name="s_explode3">=</a>	[2,		s_explode4] {};
<a href="qc-types.htm#void">void</a>() <b>s_explode4</b><a name="s_explode4">=</a>	[3,		s_explode5] {};
<a href="qc-types.htm#void">void</a>() <b>s_explode5</b><a name="s_explode5">=</a>	[4,		s_explode6] {};
<a href="qc-types.htm#void">void</a>() <b>s_explode6</b><a name="s_explode6">=</a>	[5,		<a href="subs.htm#SUB_Remove">SUB_Remove</a>] {};

<a href="qc-types.htm#void">void</a>() <b>BecomeExplosion</b><a name="BecomeExplosion">=</a>
{
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_movetype">movetype</a> = <a href="qc-defs.htm#MOVETYPE_NONE">MOVETYPE_NONE</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_touch">touch</a> = <a href="subs.htm#SUB_Null">SUB_Null</a>;
	<a href="qc-built.htm#setmodel">setmodel</a> (<a href="qc-glob.htm#self">self</a>, <b>"progs/s_explod.spr"</b>);
	<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="weapons.htm#s_explode1">s_explode1</a> ();
};

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

	<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>// don't explode on owner</i>

	<b>if</b> (<a href="qc-built.htm#pointcontents">pointcontents</a>(<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_origin">origin</a>) == <a href="qc-defs.htm#CONTENT_SKY">CONTENT_SKY</a>)
	{
		<a href="qc-built.htm#remove">remove</a>(<a href="qc-glob.htm#self">self</a>);
		<b>return</b>;
	}

	damg = 100 + <a href="qc-built.htm#random">random</a>()*20;
	
	<b>if</b> (<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_health">health</a>)
	{
		<b>if</b> (<a href="qc-glob.htm#other">other</a>.<a href="qc-enty.htm#dot_classname">classname</a> == <b>"monster_shambler"</b>)
			damg = damg * 0.5;	<i>// mostly immune</i>
		<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-enty.htm#dot_owner">owner</a>, damg );
	}

	<i>// don't do radius damage to the other, because all the damage</i>
	<i>// was done in the impact</i>
	<a href="combat.htm#T_RadiusDamage">T_RadiusDamage</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>, 120, <a href="qc-glob.htm#other">other</a>);

<i>//	sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);</i>
	<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> - 8*<a href="qc-built.htm#normalize">normalize</a>(<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_velocity">velocity</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_EXPLOSION">TE_EXPLOSION</a>);
	<a href="qc-netf.htm#WriteCoord">WriteCoord</a> (<a href="qc-net.htm#MSG_BROADCAST">MSG_BROADCAST</a>, <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_origin_x">origin_x</a>);
	<a href="qc-netf.htm#WriteCoord">WriteCoord</a> (<a href="qc-net.htm#MSG_BROADCAST">MSG_BROADCAST</a>, <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_origin_y">origin_y</a>);
	<a href="qc-netf.htm#WriteCoord">WriteCoord</a> (<a href="qc-net.htm#MSG_BROADCAST">MSG_BROADCAST</a>, <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_origin_z">origin_z</a>);

	<a href="weapons.htm#BecomeExplosion">BecomeExplosion</a> ();
};



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

<a href="qc-types.htm#void">void</a>() <b>W_FireRocket</b><a name="W_FireRocket">=</a>
{
	<b>local</b>	<a href="qc-types.htm#entity">entity</a> missile, mpuff;
	
	<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_currentammo">currentammo</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_ammo_rockets">ammo_rockets</a> = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_ammo_rockets">ammo_rockets</a> - 1;
	
	<a href="qc-built.htm#sound">sound</a> (<a href="qc-glob.htm#self">self</a>, <a href="qc-defs.htm#CHAN_WEAPON">CHAN_WEAPON</a>, <b>"weapons/sgun1.wav"</b>, 1, <a href="qc-defs.htm#ATTN_NORM">ATTN_NORM</a>);

	<a href="qc-glob.htm#self">self</a>.punchangle_x = -2;

	missile = <a href="qc-built.htm#spawn">spawn</a> ();
	missile.<a href="qc-enty.htm#dot_owner">owner</a> = <a href="qc-glob.htm#self">self</a>;
	missile.<a href="qc-enty.htm#dot_movetype">movetype</a> = <a href="qc-defs.htm#MOVETYPE_FLYMISSILE">MOVETYPE_FLYMISSILE</a>;
	missile.<a href="qc-enty.htm#dot_solid">solid</a> = <a href="qc-defs.htm#SOLID_BBOX">SOLID_BBOX</a>;
		
<i>// set missile speed	</i>

	<a href="qc-built.htm#makevectors">makevectors</a> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_v_angle">v_angle</a>);
	missile.<a href="qc-enty.htm#dot_velocity">velocity</a> = <a href="qc-built.htm#aim">aim</a>(<a href="qc-glob.htm#self">self</a>, 1000);
	missile.<a href="qc-enty.htm#dot_velocity">velocity</a> = missile.<a href="qc-enty.htm#dot_velocity">velocity</a> * 1000;
	missile.<a href="qc-enty.htm#dot_angles">angles</a> = <a href="qc-built.htm#vectoangles">vectoangles</a>(missile.<a href="qc-enty.htm#dot_velocity">velocity</a>);
	
	missile.<a href="qc-enty.htm#dot_touch">touch</a> = <a href="weapons.htm#T_MissileTouch">T_MissileTouch</a>;
	
<i>// set missile duration</i>
	missile.<a href="qc-enty.htm#dot_nextthink">nextthink</a> = <a href="qc-glob.htm#time">time</a> + 5;
	missile.<a href="qc-enty.htm#dot_think">think</a> = <a href="subs.htm#SUB_Remove">SUB_Remove</a>;

	<a href="qc-built.htm#setmodel">setmodel</a> (missile, <b>"progs/missile.mdl"</b>);
	<a href="qc-built.htm#setsize">setsize</a> (missile, '0 0 0', '0 0 0');		
	<a href="qc-built.htm#setorigin">setorigin</a> (missile, <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_origin">origin</a> + <a href="qc-built.htm#v_forward">v_forward</a>*8 + '0 0 16');
};

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

LIGHTNING

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


<i>/*

⌨️ 快捷键说明

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