📄 fight.htm
字号:
<a href="qc-types.htm#void">void</a>() <b>ai_melee_side</b><a name="ai_melee_side">=</a>
{
<b>local</b> <a href="qc-types.htm#vector">vector</a> delta;
<b>local</b> <a href="qc-types.htm#float">float</a> ldmg;
<b>if</b> (!<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_enemy">enemy</a>)
<b>return</b>; <i>// removed before stroke</i>
<a href="fight.htm#ai_charge_side">ai_charge_side</a>();
delta = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_enemy">enemy</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>;
<b>if</b> (<a href="qc-built.htm#vlen">vlen</a>(delta) > 60)
<b>return</b>;
<b>if</b> (!<a href="combat.htm#CanDamage">CanDamage</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>;
ldmg = (<a href="qc-built.htm#random">random</a>() + <a href="qc-built.htm#random">random</a>() + <a href="qc-built.htm#random">random</a>()) * 3;
<a href="combat.htm#T_Damage">T_Damage</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-glob.htm#self">self</a>, ldmg);
};
<i>//=============================================================================</i>
<i>/*
===========
SoldierCheckAttack
The player is in view, so decide to move or launch an attack
Returns FALSE if movement should continue
============
*/</i>
<a href="qc-types.htm#float">float</a>() <b>SoldierCheckAttack</b><a name="SoldierCheckAttack">=</a>
{
<b>local</b> <a href="qc-types.htm#vector">vector</a> spot1, spot2;
<b>local</b> <a href="qc-types.htm#entity">entity</a> targ;
<b>local</b> <a href="qc-types.htm#float">float</a> chance;
targ = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_enemy">enemy</a>;
<i>// see if any entities are in the way of the shot</i>
spot1 = <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_view_ofs">view_ofs</a>;
spot2 = targ.<a href="qc-enty.htm#dot_origin">origin</a> + targ.<a href="qc-enty.htm#dot_view_ofs">view_ofs</a>;
<a href="qc-built.htm#traceline">traceline</a> (spot1, spot2, <a href="defs.htm#FALSE">FALSE</a>, <a href="qc-glob.htm#self">self</a>);
<b>if</b> (<a href="qc-built.htm#trace_inopen">trace_inopen</a> && <a href="qc-built.htm#trace_inwater">trace_inwater</a>)
return FALSE; <i>// sight line crossed contents</i>
<b>if</b> (<a href="qc-built.htm#trace_ent">trace_ent</a> != targ)
return FALSE; <i>// don't have a clear shot</i>
<i>// missile attack</i>
<b>if</b> (<a href="qc-glob.htm#time">time</a> < <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_attack_finished">attack_finished</a>)
return FALSE;
<b>if</b> (enemy_range == <a href="defs.htm#RANGE_FAR">RANGE_FAR</a>)
return FALSE;
<b>if</b> (enemy_range == <a href="defs.htm#RANGE_MELEE">RANGE_MELEE</a>)
chance = 0.9;
<b>else</b> <b>if</b> (enemy_range == <a href="defs.htm#RANGE_NEAR">RANGE_NEAR</a>)
chance = 0.4;
<b>else</b> <b>if</b> (enemy_range == <a href="defs.htm#RANGE_MID">RANGE_MID</a>)
chance = 0.05;
<b>else</b>
chance = 0;
<b>if</b> (<a href="qc-built.htm#random">random</a> () < chance)
{
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_th_missile">th_missile</a> ();
<a href="subs.htm#SUB_AttackFinished">SUB_AttackFinished</a> (1 + <a href="qc-built.htm#random">random</a>());
<b>if</b> (<a href="qc-built.htm#random">random</a>() < 0.3)
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_lefty">lefty</a> = !<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_lefty">lefty</a>;
return TRUE;
}
return FALSE;
};
<i>//=============================================================================</i>
<i>/*
===========
ShamCheckAttack
The player is in view, so decide to move or launch an attack
Returns FALSE if movement should continue
============
*/</i>
<a href="qc-types.htm#float">float</a>() <b>ShamCheckAttack</b><a name="ShamCheckAttack">=</a>
{
<b>local</b> <a href="qc-types.htm#vector">vector</a> spot1, spot2;
<b>local</b> <a href="qc-types.htm#entity">entity</a> targ;
<b>local</b> <a href="qc-types.htm#float">float</a> chance;
<b>local</b> <a href="qc-types.htm#float">float</a> <a href="fight.htm#enemy_yaw">enemy_yaw</a>;
<b>if</b> (enemy_range == <a href="defs.htm#RANGE_MELEE">RANGE_MELEE</a>)
{
<b>if</b> (<a href="combat.htm#CanDamage">CanDamage</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-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_attack_state">attack_state</a> = <a href="defs.htm#AS_MELEE">AS_MELEE</a>;
return TRUE;
}
}
<b>if</b> (<a href="qc-glob.htm#time">time</a> < <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_attack_finished">attack_finished</a>)
return FALSE;
<b>if</b> (!enemy_vis)
return FALSE;
targ = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_enemy">enemy</a>;
<i>// see if any entities are in the way of the shot</i>
spot1 = <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_view_ofs">view_ofs</a>;
spot2 = targ.<a href="qc-enty.htm#dot_origin">origin</a> + targ.<a href="qc-enty.htm#dot_view_ofs">view_ofs</a>;
<b>if</b> (<a href="qc-built.htm#vlen">vlen</a>(spot1 - spot2) > 600)
return FALSE;
<a href="qc-built.htm#traceline">traceline</a> (spot1, spot2, <a href="defs.htm#FALSE">FALSE</a>, <a href="qc-glob.htm#self">self</a>);
<b>if</b> (<a href="qc-built.htm#trace_inopen">trace_inopen</a> && <a href="qc-built.htm#trace_inwater">trace_inwater</a>)
return FALSE; <i>// sight line crossed contents</i>
<b>if</b> (<a href="qc-built.htm#trace_ent">trace_ent</a> != targ)
{
return FALSE; <i>// don't have a clear shot</i>
}
<i>// missile attack</i>
<b>if</b> (enemy_range == <a href="defs.htm#RANGE_FAR">RANGE_FAR</a>)
return FALSE;
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_attack_state">attack_state</a> = <a href="defs.htm#AS_MISSILE">AS_MISSILE</a>;
<a href="subs.htm#SUB_AttackFinished">SUB_AttackFinished</a> (2 + 2*<a href="qc-built.htm#random">random</a>());
return TRUE;
};
<i>//============================================================================</i>
<i>/*
===========
OgreCheckAttack
The player is in view, so decide to move or launch an attack
Returns FALSE if movement should continue
============
*/</i>
<a href="qc-types.htm#float">float</a>() <b>OgreCheckAttack</b><a name="OgreCheckAttack">=</a>
{
<b>local</b> <a href="qc-types.htm#vector">vector</a> spot1, spot2;
<b>local</b> <a href="qc-types.htm#entity">entity</a> targ;
<b>local</b> <a href="qc-types.htm#float">float</a> chance;
<b>if</b> (enemy_range == <a href="defs.htm#RANGE_MELEE">RANGE_MELEE</a>)
{
<b>if</b> (<a href="combat.htm#CanDamage">CanDamage</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-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_attack_state">attack_state</a> = <a href="defs.htm#AS_MELEE">AS_MELEE</a>;
return TRUE;
}
}
<b>if</b> (<a href="qc-glob.htm#time">time</a> < <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_attack_finished">attack_finished</a>)
return FALSE;
<b>if</b> (!enemy_vis)
return FALSE;
targ = <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_enemy">enemy</a>;
<i>// see if any entities are in the way of the shot</i>
spot1 = <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_view_ofs">view_ofs</a>;
spot2 = targ.<a href="qc-enty.htm#dot_origin">origin</a> + targ.<a href="qc-enty.htm#dot_view_ofs">view_ofs</a>;
<a href="qc-built.htm#traceline">traceline</a> (spot1, spot2, <a href="defs.htm#FALSE">FALSE</a>, <a href="qc-glob.htm#self">self</a>);
<b>if</b> (<a href="qc-built.htm#trace_inopen">trace_inopen</a> && <a href="qc-built.htm#trace_inwater">trace_inwater</a>)
return FALSE; <i>// sight line crossed contents</i>
<b>if</b> (<a href="qc-built.htm#trace_ent">trace_ent</a> != targ)
{
return FALSE; <i>// don't have a clear shot</i>
}
<i>// missile attack</i>
<b>if</b> (<a href="qc-glob.htm#time">time</a> < <a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_attack_finished">attack_finished</a>)
return FALSE;
<b>if</b> (enemy_range == <a href="defs.htm#RANGE_FAR">RANGE_FAR</a>)
return FALSE;
<b>else</b> <b>if</b> (enemy_range == <a href="defs.htm#RANGE_NEAR">RANGE_NEAR</a>)
chance = 0.10;
<b>else</b> <b>if</b> (enemy_range == <a href="defs.htm#RANGE_MID">RANGE_MID</a>)
chance = 0.05;
<b>else</b>
chance = 0;
<a href="qc-glob.htm#self">self</a>.<a href="qc-enty.htm#dot_attack_state">attack_state</a> = <a href="defs.htm#AS_MISSILE">AS_MISSILE</a>;
<a href="subs.htm#SUB_AttackFinished">SUB_AttackFinished</a> (1 + 2*<a href="qc-built.htm#random">random</a>());
return TRUE;
};
</pre></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -