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

📄 combat.htm

📁 Quake 的 各 种 文 档 格 式 说 明
💻 HTM
📖 第 1 页 / 共 2 页
字号:
	<b>if</b> ( (inflictor != <a href="qc-glob.htm#world">world</a>) &amp;&amp; (targ.<a href="qc-enty.htm#dot_movetype">movetype</a> == <a href="qc-defs.htm#MOVETYPE_WALK">MOVETYPE_WALK</a>) )
	{
		dir = targ.<a href="qc-enty.htm#dot_origin">origin</a> - (inflictor.<a href="qc-enty.htm#dot_absmin">absmin</a> + inflictor.<a href="qc-enty.htm#dot_absmax">absmax</a>) * 0.5;
		dir = <a href="qc-built.htm#normalize">normalize</a>(dir);
		targ.<a href="qc-enty.htm#dot_velocity">velocity</a> = targ.<a href="qc-enty.htm#dot_velocity">velocity</a> + dir*damage*8;
	}

<i>// check for godmode or invincibility</i>
	<b>if</b> (targ.<a href="qc-enty.htm#dot_flags">flags</a> &amp; <a href="defs.htm#FL_GODMODE">FL_GODMODE</a>)
		<b>return</b>;
	<b>if</b> (targ.<a href="qc-enty.htm#dot_invincible_finished">invincible_finished</a> &gt;= <a href="qc-glob.htm#time">time</a>)
	{
		<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_invincible_sound">invincible_sound</a> &lt; <a href="qc-glob.htm#time">time</a>)
		{
			<a href="qc-built.htm#sound">sound</a> (targ, <a href="qc-defs.htm#CHAN_ITEM">CHAN_ITEM</a>, <b>"items/protect3.wav"</b>, 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_invincible_sound">invincible_sound</a> = <a href="qc-glob.htm#time">time</a> + 2;
		}
		<b>return</b>;
	}

<i>// team play damage avoidance</i>
	<b>if</b> ( (<a href="qc-glob.htm#teamplay">teamplay</a> == 1) &amp;&amp; (targ.<a href="qc-enty.htm#dot_team">team</a> &gt; 0)&amp;&amp;(targ.<a href="qc-enty.htm#dot_team">team</a> == attacker.<a href="qc-enty.htm#dot_team">team</a>) )
		<b>return</b>;
		
<i>// do the damage</i>
	targ.<a href="qc-enty.htm#dot_health">health</a> = targ.<a href="qc-enty.htm#dot_health">health</a> - take;
			
	<b>if</b> (targ.<a href="qc-enty.htm#dot_health">health</a> &lt;= 0)
	{
		<a href="combat.htm#Killed">Killed</a> (targ, attacker);
		<b>return</b>;
	}

<i>// react to the damage</i>
	oldself = <a href="qc-glob.htm#self">self</a>;
	<a href="qc-glob.htm#self">self</a> = targ;

	<b>if</b> ( (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_flags">flags</a> &amp; <a href="defs.htm#FL_MONSTER">FL_MONSTER</a>) &amp;&amp; attacker != <a href="qc-glob.htm#world">world</a>)
	{
	<i>// get mad unless of the same class (except for soldiers)</i>
		<b>if</b> (<a href="qc-glob.htm#self">self</a> != attacker &amp;&amp; attacker != <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_enemy">enemy</a>)
		{
			<b>if</b> ( (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_classname">classname</a> != attacker.<a href="qc-enty.htm#dot_classname">classname</a>) 
			|| (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_classname">classname</a> == <b>"monster_army"</b> ) )
			{
				<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_enemy">enemy</a>.<a href="qc-enty.htm#dot_classname">classname</a> == <b>"player"</b>)
					<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_oldenemy">oldenemy</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>.<a href="qc-enty.htm#dot_enemy">enemy</a> = attacker;
				<a href="ai.htm#FoundTarget">FoundTarget</a> ();
			}
		}
	}

	<b>if</b> (<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_th_pain">th_pain</a>)
	{
		<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_th_pain">th_pain</a> (attacker, take);
	<i>// nightmare mode monsters don't go into pain frames often</i>
		<b>if</b> (<a href="defs.htm#skill">skill</a> == 3)
			<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_pain_finished">pain_finished</a> = <a href="qc-glob.htm#time">time</a> + 5;		
	}

	<a href="qc-glob.htm#self">self</a> = oldself;
};

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

<a href="qc-types.htm#void">void</a>(<a href="qc-types.htm#entity">entity</a> inflictor, <a href="qc-types.htm#entity">entity</a> attacker, <a href="qc-types.htm#float">float</a> damage, <a href="qc-types.htm#entity">entity</a> ignore) <b>T_RadiusDamage</b><a name="T_RadiusDamage">=</a>
{
	<b>local</b>	<a href="qc-types.htm#float">float</a> 	points;
	<b>local</b>	<a href="qc-types.htm#entity">entity</a>	head;
	<b>local</b>	<a href="qc-types.htm#vector">vector</a>	org;

	head = <a href="qc-built.htm#findradius">findradius</a>(inflictor.<a href="qc-enty.htm#dot_origin">origin</a>, damage+40);
	
	<b>while</b> (head)
	{
		<b>if</b> (head != ignore)
		{
			<b>if</b> (head.<a href="qc-enty.htm#dot_takedamage">takedamage</a>)
			{
				org = head.<a href="qc-enty.htm#dot_origin">origin</a> + (head.<a href="qc-enty.htm#dot_mins">mins</a> + head.<a href="qc-enty.htm#dot_maxs">maxs</a>)*0.5;
				points = 0.5*<a href="qc-built.htm#vlen">vlen</a> (inflictor.<a href="qc-enty.htm#dot_origin">origin</a> - org);
				<b>if</b> (points &lt; 0)
					points = 0;
				points = damage - points;
				<b>if</b> (head == attacker)
					points = points * 0.5;
				<b>if</b> (points &gt; 0)
				{
					<b>if</b> (<a href="combat.htm#CanDamage">CanDamage</a> (head, inflictor))
					{	<i>// shambler takes half damage from all explosions</i>
						<b>if</b> (head.<a href="qc-enty.htm#dot_classname">classname</a> == <b>"monster_shambler"</b>)						
							<a href="combat.htm#T_Damage">T_Damage</a> (head, inflictor, attacker, points*0.5);
						<b>else</b>
							<a href="combat.htm#T_Damage">T_Damage</a> (head, inflictor, attacker, points);
					}
				}
			}
		}
		head = head.<a href="qc-enty.htm#dot_chain">chain</a>;
	}
};

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

<a href="qc-types.htm#void">void</a>(<a href="qc-types.htm#entity">entity</a> attacker, <a href="qc-types.htm#float">float</a> damage) <b>T_BeamDamage</b><a name="T_BeamDamage">=</a>
{
	<b>local</b>	<a href="qc-types.htm#float">float</a> 	points;
	<b>local</b>	<a href="qc-types.htm#entity">entity</a>	head;
	
	head = <a href="qc-built.htm#findradius">findradius</a>(attacker.<a href="qc-enty.htm#dot_origin">origin</a>, damage+40);
	
	<b>while</b> (head)
	{
		<b>if</b> (head.<a href="qc-enty.htm#dot_takedamage">takedamage</a>)
		{
			points = 0.5*<a href="qc-built.htm#vlen">vlen</a> (attacker.<a href="qc-enty.htm#dot_origin">origin</a> - head.<a href="qc-enty.htm#dot_origin">origin</a>);
			<b>if</b> (points &lt; 0)
				points = 0;
			points = damage - points;
			<b>if</b> (head == attacker)
				points = points * 0.5;
			<b>if</b> (points &gt; 0)
			{
				<b>if</b> (<a href="combat.htm#CanDamage">CanDamage</a> (head, attacker))
				{
					<b>if</b> (head.<a href="qc-enty.htm#dot_classname">classname</a> == <b>"monster_shambler"</b>)						
						<a href="combat.htm#T_Damage">T_Damage</a> (head, attacker, attacker, points*0.5);
					<b>else</b>
						<a href="combat.htm#T_Damage">T_Damage</a> (head, attacker, attacker, points);
				}
			}
		}
		head = head.<a href="qc-enty.htm#dot_chain">chain</a>;
	}
};


</pre></body></html>

⌨️ 快捷键说明

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