move sendMove from Bot (Phys) to Bot (move)

This commit is contained in:
Bill Currie 2003-08-22 14:52:34 +00:00
parent 88df663ce7
commit 44929b99e3
5 changed files with 56 additions and 117 deletions

View File

@ -9,7 +9,6 @@ libfrikbot_source = \
bot_fight.qc \
bot_misc.qc \
bot_move.qc \
bot_phys.qc \
bot_qw.qc \
bot_way.qc \
map_dm1.qc \

View File

@ -44,7 +44,62 @@ this notice in its entirety.
integer bot_move_linker;
float (integer keys, integer key) key_state =
{
return ((keys & key) != 0) ? 1.0 : 0.0;
};
@implementation Bot (Move)
-(void)sendMove
{
local vector movevect = '0 0 0';
local float anglespeed;
local vector view;
movevect.y += (350 * key_state (keys, KEY_MOVERIGHT));
movevect.y -= (350 * key_state (keys, KEY_MOVELEFT));
movevect.x += (200 * key_state (keys, KEY_MOVEFORWARD));
movevect.x -= (200 * key_state (keys, KEY_MOVEBACK));
movevect.z += (200 * key_state (keys, KEY_MOVEUP));
movevect.z -= (200 * key_state (keys, KEY_MOVEDOWN));
if (!(b_aiflags & AI_PRECISION))
movevect *= 2;
if (b_skill != 2) {
// use mouse emulation
anglespeed = 1.5 * real_frametime;
// 1.5 is the default cl_anglespeedkey & bot always has +speed
ent.v_angle_y += anglespeed * key_state (keys, KEY_LOOKLEFT) * 140;
// 140 is default cl_yawspeed
ent.v_angle_y -= anglespeed * key_state (keys, KEY_LOOKRIGHT) * 140;
// 140 is default cl_yawspeed
ent.v_angle_x -= anglespeed * key_state (keys, KEY_LOOKUP) * 150;
// 150 is default cl_pitchspeed
ent.v_angle_x += anglespeed * key_state (keys, KEY_LOOKDOWN) * 150;
// 150 is default cl_pitchspeed
} else {
view.x = angcomp (b_angle.x, ent.v_angle_x);
view.y = angcomp (b_angle.y, ent.v_angle_y);
view.z = 0;
if (vlen (view) > 30) {
mouse_emu += (view * 30);
if (vlen(mouse_emu) > 180)
mouse_emu = normalize (mouse_emu) * 180;
} else
mouse_emu = view * (1 / real_frametime);
ent.v_angle += mouse_emu * real_frametime;
}
//dprint (itos (buttons) + " " + itos (impulse) + "\n");
SV_UserCmd (ent, real_frametime, ent.v_angle, movevect, buttons, impulse);
impulse = 0;
}
- (void) jump
{
// TODO check for precision, etc.

View File

@ -1,109 +0,0 @@
/***********************************************
* *
* FrikBot Physics *
* The near-perfect emulation of *
* Client movement *
* *
* Special Thanks to: Asdf, Frog *
* Alan "Strider" Kivlin *
* *
* *
***********************************************/
/*
This program is in the Public Domain. My crack legal
team would like to add:
RYAN "FRIKAC" SMITH IS PROVIDING THIS SOFTWARE "AS IS"
AND MAKES NO WARRANTY, EXPRESS OR IMPLIED, AS TO THE
ACCURACY, CAPABILITY, EFFICIENCY, MERCHANTABILITY, OR
FUNCTIONING OF THIS SOFTWARE AND/OR DOCUMENTATION. IN
NO EVENT WILL RYAN "FRIKAC" SMITH BE LIABLE FOR ANY
GENERAL, CONSEQUENTIAL, INDIRECT, INCIDENTAL,
EXEMPLARY, OR SPECIAL DAMAGES, EVEN IF RYAN "FRIKAC"
SMITH HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES, IRRESPECTIVE OF THE CAUSE OF SUCH DAMAGES.
You accept this software on the condition that you
indemnify and hold harmless Ryan "FrikaC" Smith from
any and all liability or damages to third parties,
including attorney fees, court costs, and other
related costs and expenses, arising out of your use
of this software irrespective of the cause of said
liability.
The export from the United States or the subsequent
reexport of this software is subject to compliance
with United States export control and munitions
control restrictions. You agree that in the event you
seek to export this software, you assume full
responsibility for obtaining all necessary export
licenses and approvals and for assuring compliance
with applicable reexport restrictions.
Any reproduction of this software must contain
this notice in its entirety.
*/
#include "libfrikbot.h"
string (integer i) itos = #112;
integer bot_phys_linker;
float (integer keys, integer key) key_state =
{
return ((keys & key) != 0) ? 1.0 : 0.0;
};
@implementation Bot (Physics)
-(void)sendMove
{
local vector movevect = '0 0 0';
local float anglespeed;
local vector view;
movevect.y += (350 * key_state (keys, KEY_MOVERIGHT));
movevect.y -= (350 * key_state (keys, KEY_MOVELEFT));
movevect.x += (200 * key_state (keys, KEY_MOVEFORWARD));
movevect.x -= (200 * key_state (keys, KEY_MOVEBACK));
movevect.z += (200 * key_state (keys, KEY_MOVEUP));
movevect.z -= (200 * key_state (keys, KEY_MOVEDOWN));
if (!(b_aiflags & AI_PRECISION))
movevect *= 2;
if (b_skill != 2) {
// use mouse emulation
anglespeed = 1.5 * real_frametime;
// 1.5 is the default cl_anglespeedkey & bot always has +speed
ent.v_angle_y += anglespeed * key_state (keys, KEY_LOOKLEFT) * 140;
// 140 is default cl_yawspeed
ent.v_angle_y -= anglespeed * key_state (keys, KEY_LOOKRIGHT) * 140;
// 140 is default cl_yawspeed
ent.v_angle_x -= anglespeed * key_state (keys, KEY_LOOKUP) * 150;
// 150 is default cl_pitchspeed
ent.v_angle_x += anglespeed * key_state (keys, KEY_LOOKDOWN) * 150;
// 150 is default cl_pitchspeed
} else {
view.x = angcomp (b_angle.x, ent.v_angle_x);
view.y = angcomp (b_angle.y, ent.v_angle_y);
view.z = 0;
if (vlen (view) > 30) {
mouse_emu += (view * 30);
if (vlen(mouse_emu) > 180)
mouse_emu = normalize (mouse_emu) * 180;
} else
mouse_emu = view * (1 / real_frametime);
ent.v_angle += mouse_emu * real_frametime;
}
//dprint (itos (buttons) + " " + itos (impulse) + "\n");
SV_UserCmd (ent, real_frametime, ent.v_angle, movevect, buttons, impulse);
impulse = 0;
}
@end

View File

@ -77,7 +77,6 @@ ClientFixRankings(); // FrikBot
integer []bot_way_ref;
integer []bot_move_ref;
integer []bot_phys_ref;
integer []bot_chat_ref;
float []stagger_think_ref;
integer []bot_fight_ref;
@ -240,7 +239,6 @@ BotInit =
[Waypoint clearAll];
bot_way_ref = &bot_way_linker;
bot_move_ref = &bot_move_linker;
bot_phys_ref = &bot_phys_linker;
bot_chat_ref = &bot_chat_linker;
stagger_think_ref = &stagger_think;
bot_fight_ref = &bot_fight_linker;

View File

@ -133,11 +133,8 @@ typedef struct bot_data_t bot_data_t;
+(void)kick;
@end
@interface Bot (Physics)
- (void)sendMove;
@end
@interface Bot (Move)
- (void)sendMove;
- (void)jump;
- (integer)canRJ;
- (integer)recognizePlat: (integer) flag;
@ -316,7 +313,6 @@ typedef struct bot_data_t bot_data_t;
@extern integer bot_way_linker;
@extern integer bot_move_linker;
@extern integer bot_phys_linker;
@extern integer bot_chat_linker;
@extern float stagger_think;
@extern integer bot_fight_linker;