some tests I've accumulated over time. don't want to lose them accidently

:)
This commit is contained in:
Bill Currie 2004-02-11 02:23:40 +00:00
parent 0fe4c2a600
commit afdbd90bc1
23 changed files with 1762 additions and 0 deletions

4
tools/qfcc/test/base.r Normal file
View file

@ -0,0 +1,4 @@
@class foo;
@interface bar : foo
@end

10
tools/qfcc/test/bool.r Normal file
View file

@ -0,0 +1,10 @@
integer (integer x, integer y, integer z) foo =
{
if (x || !y && z) {
return x || y && z;
} else {
for (x = 0; (x || y) && z < 3; x++)
return (x || y && z) ? 4 : 9;
}
return !x;
};

410
tools/qfcc/test/chat.r Normal file
View file

@ -0,0 +1,410 @@
/***********************************************
* *
* FrikBot Misc Code *
* "Because you can't name it anything else" *
* *
***********************************************/
/*
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"
integer bot_chat_linker;
@static Bot b_originator;
@static integer b_topic;
/* FBX Topics
b_originator == self
1 - sign on
2 - killed targ
3 - team message "friendly eyes"
4 - team message "on your back"
5 - team message "need back up"
6 - excuses
----
7 - gameover
----
8 - welcoming someone onto server
9 - ridicule lost frag (killed self?)
10 - ridicule lost frag (lava)
11 - lag
b_originator == targ
*/
@implementation Bot (Chat)
-(void)say:(string)msg
{
WriteByte (MSG_ALL, 8);
WriteByte (MSG_ALL, 3);
WriteByte (MSG_ALL, 1);
WriteString (MSG_ALL, ent.netname);
WriteByte (MSG_ALL, 8);
WriteByte (MSG_ALL, 3);
WriteByte (MSG_ALL, 2);
WriteString (MSG_ALL, msg);
}
-(void)say2:(string)msg
{
WriteByte (MSG_ALL, 8);
WriteByte (MSG_ALL, 3);
WriteByte (MSG_ALL, 2);
WriteString (MSG_ALL, msg);
}
-(void)sayTeam:(string)msg
{
// FBX QW doesn't support teamplay...yet
}
-(void)sayInit
{
WriteByte (MSG_ALL, 8);
WriteByte (MSG_ALL, 3);
WriteByte (MSG_ALL, 1);
WriteString (MSG_ALL, ent.netname);
}
// I didn't like the old code so this is very stripped down
-(void)start_topic:(integer)topic
{
if (random() < 0.2) {
b_topic = topic;
b_originator = self;
} else
b_topic = 0;
}
-(void)chat
{
local float r;
if (b_options & OPT_NOCHAT)
return;
r = ceil (6 * random ());
if (b_chattime > time) {
if (b_skill < 2)
keys = 0;
ent.button0 = ent.button2 = 0;
return;
} else if (b_chattime) {
switch (b_topic) {
case 1:
if (b_originator == self) {
switch (r) {
case 1:
[self say:": lo all\n"];
[self start_topic:8];
break;
case 2:
[self say:": hey everyone\n"];
[self start_topic:8];
break;
case 3:
[self say:": prepare to be fragged!\n"];
[self start_topic:0];
break;
case 4:
[self say:": boy this is laggy\n"];
[self start_topic:11];
break;
case 5:
[self say:": #mm getting some lag here\n"];
[self start_topic:11];
break;
default:
[self say:": hi everyone\n"];
[self start_topic:8];
break;
}
}
break;
case 2:
if (b_originator == self) {
switch (r) {
case 1:
[self say:": take that\n"];
break;
case 2:
[self say:": yehaww!\n"];
break;
case 3:
[self say:": wh00p\n"];
break;
case 4:
[self say:": j00_sawk();\n"];
break;
case 5:
[self say:": i rule\n"];
break;
default:
[self say:": eat that\n"];
break;
}
[self start_topic:0];
}
break;
case 3:
if (b_originator == self) {
if (r < 3)
[self sayTeam:": friendly eyes\n"];
else
[self sayTeam:": team eyes\n"];
[self start_topic:0];
}
break;
case 4:
if (b_originator == self) {
if (r < 3)
[self sayTeam:": on your back\n"];
else
[self sayTeam:": I'm with you\n"];
[self start_topic:0];
}
break;
case 5:
if (b_originator == self) {
if (r < 3)
[self sayTeam:": I need help\n"];
else
[self sayTeam:": need backup\n"];
[self start_topic:0];
}
break;
case 6:
if (b_originator == self) {
switch (r) {
case 1:
[self say:": sun got in my eyes\n"];
[self start_topic:0];
break;
case 2:
[self say:": mouse needs cleaning\n"];
[self start_topic:0];
break;
case 3:
[self say:": i meant to do that\n"];
[self start_topic:0];
break;
case 4:
[self say:": lag\n"];
[self start_topic:11];
break;
case 5:
[self say:": killer lag\n"];
[self start_topic:11];
break;
default:
[self say:": 100% lag\n"];
[self start_topic:11];
break;
}
}
break;
case 7:
switch (r) {
case 1:
[self say:": gg\n"];
break;
case 2:
[self say:": gg all\n"];
break;
case 3:
[self say:": that was fun\n"];
break;
case 4:
[self say:": good game\n"];
break;
case 5:
[self say:": pah\n"];
break;
default:
[self say:": hrm\n"];
break;
}
[self start_topic:0];
break;
case 8:
if (b_originator != self) {
switch (r) {
case 1:
[self say:": heya\n"];
[self start_topic:0];
break;
case 2:
[self say:": welcome\n"];
[self start_topic:0];
break;
case 3:
[self sayInit];
[self say2:": hi "];
[self say2:b_originator.ent.netname];
[self say2:"\n"];
[self start_topic:0];
break;
case 5:
[self sayInit];
[self say2:": hey "];
[self say2:b_originator.ent.netname];
[self say2:"\n"];
[self start_topic:0];
break;
case 6:
[self say:": howdy\n"];
[self start_topic:0];
break;
default:
[self say:": lo\n"];
[self start_topic:0];
break;
}
}
break;
case 9:
if (b_originator != self) {
switch (r) {
case 1:
[self say:": hah\n"];
break;
case 2:
[self say:": heheh\n"];
break;
case 3:
[self sayInit];
[self say2:": good work "];
[self say2:b_originator.ent.netname];
[self say2:"\n"];
break;
case 4:
[self sayInit];
[self say2:": nice1 "];
[self say2:b_originator.ent.netname];
[self say2:"\n"];
break;
case 5:
[self say:": lol\n"];
break;
default:
[self say:": :)\n"];
break;
}
b_topic = 6;
}
break;
case 10:
if (b_originator != self) {
switch (r) {
case 1:
[self say:": have a nice dip?\n"];
break;
case 2:
[self say:": bah I hate levels with lava\n"];
break;
case 3:
[self sayInit];
[self say2:": good job "];
[self say2:b_originator.ent.netname];
[self say2:"\n"];
break;
case 4:
[self sayInit];
[self say2:": nice backflip "];
[self say2:b_originator.ent.netname];
[self say2:"\n"];
break;
case 5:
[self say:": watch your step\n"];
break;
default:
[self say:": hehe\n"];
break;
}
b_topic = 6;
}
break;
case 11:
if (b_originator != self) {
switch (r) {
case 1:
[self sayInit];
[self say2:": yeah right "];
[self say2:b_originator.ent.netname];
[self say2:"\n"];
[self start_topic:0];
break;
case 2:
[self say:": ping\n"];
[self start_topic:0];
break;
case 3:
[self say:": shuddup, you're an lpb\n"];
[self start_topic:0];
break;
case 4:
[self say:": lag my eye\n"];
[self start_topic:0];
break;
case 5:
[self say:": yeah\n"];
[self start_topic:11];
break;
default:
[self say:": totally\n"];
[self start_topic:11];
break;
}
}
default:
break;
}
b_chattime = 0;
} else if (b_topic) {
if (random () < 0.5) {
if (self == b_originator) {
if (b_topic <= 7)
b_chattime = time + 2;
} else {
if (b_topic >= 7)
b_chattime = time + 2;
}
}
}
}
@end

View file

@ -0,0 +1,9 @@
#include "gui/Rect.h"
void (integer x) foo;
void (float y) bar =
{
foo (y);
[[Rect alloc] initWithComponents:1 :2 :y :3];
};

21
tools/qfcc/test/debug.r Normal file
View file

@ -0,0 +1,21 @@
void (entity e) remove;
void() SUB_Null = {};
void() SUB_Remove = {remove(@self);}
// 0
// 1
// 2
// 3
// 4
// 5
// 6
// 7
// 8
// 9
// a
// b
void () foo =
{
return;
};

724
tools/qfcc/test/defs.h Normal file
View file

@ -0,0 +1,724 @@
/*
==============================================================================
SOURCE FOR GLOBALVARS_T C STRUCTURE
==============================================================================
*/
//
// system globals
//
@extern entity other;
@extern entity world;
@extern float time;
@extern float frametime;
@extern entity newmis; // if this is set, the entity that just
// run created a new missile that should
// be simulated immediately
@extern float force_retouch; // force all entities to touch triggers
// next frame. this is needed because
// non-moving things don't normally scan
// for triggers, and when a trigger is
// created (like a teleport trigger), it
// needs to catch everything.
// decremented each frame, so set to 2
// to guarantee everything is touched
@extern string mapname;
@extern float serverflags; // propagated from level to level, used to
// keep track of completed episodes
@extern float total_secrets;
@extern float total_monsters;
@extern float found_secrets; // number of secrets found
@extern float killed_monsters; // number of monsters killed
// spawnparms are used to encode information about clients across server
// level changes
@extern float parm1, parm2, parm3, parm4, parm5, parm6, parm7, parm8, parm9, parm10, parm11, parm12, parm13, parm14, parm15, parm16;
//
// global variables set by built in functions
//
@extern vector v_forward, v_up, v_right; // set by makevectors()
// set by traceline / tracebox
@extern float trace_allsolid;
@extern float trace_startsolid;
@extern float trace_fraction;
@extern vector trace_endpos;
@extern vector trace_plane_normal;
@extern float trace_plane_dist;
@extern entity trace_ent;
@extern float trace_inopen;
@extern float trace_inwater;
@extern entity msg_entity; // destination of single entity writes
//
// required prog functions
//
@extern void() main; // only for testing
@extern void() StartFrame;
@extern void() PlayerPreThink;
@extern void() PlayerPostThink;
@extern void() ClientKill;
@extern void() ClientConnect;
@extern void() PutClientInServer; // call after setting the parm1... parms
@extern void() ClientDisconnect;
@extern void() SetNewParms; // called when a client first connects to
// a server. sets parms so they can be
// saved off for restarts
@extern void() SetChangeParms; // call to set parms for self so they can
// be saved for a level transition
//================================================
@extern void end_sys_globals; // flag for structure dumping
//================================================
/*
==============================================================================
SOURCE FOR ENTVARS_T C STRUCTURE
==============================================================================
*/
//
// system fields (*** = do not set in prog code, maintained by C code)
//
@extern .float modelindex; // *** model index in the precached list
@extern .vector absmin, absmax; // *** origin + mins / maxs
@extern .float ltime; // local time for entity
@extern .float lastruntime; // *** to allow entities to run out of sequence
@extern .float movetype;
@extern .float solid;
@extern .vector origin; // ***
@extern .vector oldorigin; // ***
@extern .vector velocity;
@extern .vector angles;
@extern .vector avelocity;
@extern .string classname; // spawn function
@extern .string model;
@extern .float frame;
@extern .float skin;
@extern .float effects;
@extern .vector mins, maxs; // bounding box extents reletive to origin
@extern .vector size; // maxs - mins
@extern .void() touch;
@extern .void() use;
@extern .void() think;
@extern .void() blocked; // for doors or plats, called when can't push other
@extern .float nextthink;
@extern .entity groundentity;
// stats
@extern .float health;
@extern .float frags;
@extern .float weapon; // one of the IT_SHOTGUN, etc flags
@extern .string weaponmodel;
@extern .float weaponframe;
@extern .float currentammo;
@extern .float ammo_shells, ammo_nails, ammo_rockets, ammo_cells;
@extern .float items; // bit flags
@extern .float takedamage;
@extern .entity chain;
@extern .float deadflag;
@extern .vector view_ofs; // add to origin to get eye point
@extern .float button0; // fire
@extern .float button1; // use
@extern .float button2; // jump
@extern .float impulse; // weapon changes
@extern .float fixangle;
@extern .vector v_angle; // view / targeting angle for players
@extern .string netname;
@extern .entity enemy;
@extern .float flags;
@extern .float colormap;
@extern .float team;
@extern .float max_health; // players maximum health is stored here
@extern .float teleport_time; // don't back up
@extern .float armortype; // save this fraction of incoming damage
@extern .float armorvalue;
@extern .float waterlevel; // 0 = not in, 1 = feet, 2 = wast, 3 = eyes
@extern .float watertype; // a contents value
@extern .float ideal_yaw;
@extern .float yaw_speed;
@extern .entity aiment;
@extern .entity goalentity; // a movetarget or an enemy
@extern .float spawnflags;
@extern .string target;
@extern .string targetname;
// damage is accumulated through a frame. and sent as one single
// message, so the super shotgun doesn't generate huge messages
@extern .float dmg_take;
@extern .float dmg_save;
@extern .entity dmg_inflictor;
@extern .entity owner; // who launched a missile
@extern .vector movedir; // mostly for doors, but also used for waterjump
@extern .string message; // trigger messages
@extern .float sounds; // either a cd track number or sound number
@extern .string noise, noise1, noise2, noise3; // contains names of wavs to play
//================================================
@extern void end_sys_fields; // flag for structure dumping
//================================================
/*
==============================================================================
VARS NOT REFERENCED BY C CODE
==============================================================================
*/
//
// constants
//
// edict.flags
@extern float FL_FLY;
@extern float FL_SWIM;
@extern float FL_CLIENT; // set for all client edicts
@extern float FL_INWATER; // for enter / leave water splash
@extern float FL_MONSTER;
@extern float FL_GODMODE; // player cheat
@extern float FL_NOTARGET; // player cheat
@extern float FL_ITEM; // extra wide size for bonus items
@extern float FL_ONGROUND; // standing on something
@extern float FL_PARTIALGROUND; // not all corners are valid
@extern float FL_WATERJUMP; // player jumping out of water
@extern float FL_JUMPRELEASED; // for jump debouncing
// edict.movetype values
#define MOVETYPE_NONE 0 // never moves
//#define MOVETYPE_ANGLENOCLIP 1
//#define MOVETYPE_ANGLECLIP 2
#define MOVETYPE_WALK 3 // players only
#define MOVETYPE_STEP 4 // discrete, not real time unless fall
#define MOVETYPE_FLY 5
#define MOVETYPE_TOSS 6 // gravity
#define MOVETYPE_PUSH 7 // no clip to world, push and crush
#define MOVETYPE_NOCLIP 8
#define MOVETYPE_FLYMISSILE 9 // fly with extra size against monsters
#define MOVETYPE_BOUNCE 10
#define MOVETYPE_BOUNCEMISSILE 11 // bounce with extra size
// edict.solid values
@extern float SOLID_NOT; // no interaction with other objects
@extern float SOLID_TRIGGER; // touch on edge, but not blocking
@extern float SOLID_BBOX; // touch on edge, block
@extern float SOLID_SLIDEBOX; // touch on edge, but not an onground
@extern float SOLID_BSP; // bsp clip, touch on edge, block
// range values
@extern float RANGE_MELEE;
@extern float RANGE_NEAR;
@extern float RANGE_MID;
@extern float RANGE_FAR;
// deadflag values
@extern float DEAD_NO;
@extern float DEAD_DYING;
@extern float DEAD_DEAD;
@extern float DEAD_RESPAWNABLE;
// takedamage values
@extern float DAMAGE_NO;
@extern float DAMAGE_YES;
@extern float DAMAGE_AIM;
// items
#define IT_AXE 0x001000
#define IT_SHOTGUN 0x000001
#define IT_SUPER_SHOTGUN 0x000002
#define IT_NAILGUN 0x000004
#define IT_SUPER_NAILGUN 0x000008
#define IT_GRENADE_LAUNCHER 0x000010
#define IT_ROCKET_LAUNCHER 0x000020
#define IT_LIGHTNING 0x000040
#define IT_EXTRA_WEAPON 0x000080
#define IT_SHELLS 0x000100
#define IT_NAILS 0x000200
#define IT_ROCKETS 0x000400
#define IT_CELLS 0x000800
#define IT_ARMOR1 0x002000
#define IT_ARMOR2 0x004000
#define IT_ARMOR3 0x008000
#define IT_SUPERHEALTH 0x010000
#define IT_KEY1 0x020000
#define IT_KEY2 0x040000
#define IT_INVISIBILITY 0x080000
#define IT_INVULNERABILITY 0x100000
#define IT_SUIT 0x200000
#define IT_QUAD 0x400000
// point content values
@extern float CONTENT_EMPTY;
@extern float CONTENT_SOLID;
@extern float CONTENT_WATER;
@extern float CONTENT_SLIME;
@extern float CONTENT_LAVA;
@extern float CONTENT_SKY;
@extern float STATE_TOP;
@extern float STATE_BOTTOM;
@extern float STATE_UP;
@extern float STATE_DOWN;
@extern vector VEC_ORIGIN;
@extern vector VEC_HULL_MIN;
@extern vector VEC_HULL_MAX;
@extern vector VEC_HULL2_MIN;
@extern vector VEC_HULL2_MAX;
// protocol bytes
@extern float SVC_TEMPENTITY;
@extern float SVC_KILLEDMONSTER;
@extern float SVC_FOUNDSECRET;
@extern float SVC_INTERMISSION;
@extern float SVC_FINALE;
@extern float SVC_CDTRACK;
@extern float SVC_SELLSCREEN;
@extern float SVC_SMALLKICK;
@extern float SVC_BIGKICK;
@extern float SVC_MUZZLEFLASH;
@extern float TE_SPIKE;
@extern float TE_SUPERSPIKE;
@extern float TE_GUNSHOT;
@extern float TE_EXPLOSION;
@extern float TE_TAREXPLOSION;
@extern float TE_LIGHTNING1;
@extern float TE_LIGHTNING2;
@extern float TE_WIZSPIKE;
@extern float TE_KNIGHTSPIKE;
@extern float TE_LIGHTNING3;
@extern float TE_LAVASPLASH;
@extern float TE_TELEPORT;
@extern float TE_BLOOD;
@extern float TE_LIGHTNINGBLOOD;
// sound channels
// channel 0 never willingly overrides
// other channels (1-7) allways override a playing sound on that channel
@extern float CHAN_AUTO;
@extern float CHAN_WEAPON;
@extern float CHAN_VOICE;
@extern float CHAN_ITEM;
@extern float CHAN_BODY;
@extern float CHAN_NO_PHS_ADD; // ie: CHAN_BODY+CHAN_NO_PHS_ADD
@extern float ATTN_NONE;
@extern float ATTN_NORM;
@extern float ATTN_IDLE;
@extern float ATTN_STATIC;
// update types
@extern float UPDATE_GENERAL;
@extern float UPDATE_STATIC;
@extern float UPDATE_BINARY;
@extern float UPDATE_TEMP;
// entity effects
//float EF_BRIGHTFIELD;
//float EF_MUZZLEFLASH;
@extern float EF_BRIGHTLIGHT;
@extern float EF_DIMLIGHT;
@extern float EF_FLAG1;
@extern float EF_FLAG2;
// GLQuakeWorld Stuff
@extern float EF_BLUE; // Blue Globe effect for Quad
@extern float EF_RED; // Red Globe effect for Pentagram
// messages
@extern float MSG_BROADCAST; // unreliable to all
@extern float MSG_ONE; // reliable to one (msg_entity)
@extern float MSG_ALL; // reliable to all
@extern float MSG_INIT; // write to the init string
@extern float MSG_MULTICAST; // for multicast() call
// message levels
@extern float PRINT_LOW; // pickup messages
@extern float PRINT_MEDIUM; // death messages
@extern float PRINT_HIGH; // critical messages
@extern float PRINT_CHAT; // also goes to chat console
// multicast sets
@extern float MULTICAST_ALL; // every client
@extern float MULTICAST_PHS; // within hearing
@extern float MULTICAST_PVS; // within sight
@extern float MULTICAST_ALL_R; // every client, reliable
@extern float MULTICAST_PHS_R; // within hearing, reliable
@extern float MULTICAST_PVS_R; // within sight, reliable
//================================================
//
// globals
//
@extern float movedist;
@extern string string_null; // null string, nothing should be held here
@extern float empty_float;
@extern entity activator; // the entity that activated a trigger or brush
@extern entity damage_attacker; // set by T_Damage
@extern entity damage_inflictor;
@extern float framecount;
//
// cvars checked each frame
//
@extern float teamplay;
@extern float timelimit;
@extern float fraglimit;
@extern float deathmatch;
@extern float rj;
//================================================
//
// world fields (FIXME: make globals)
//
@extern .string wad;
@extern .string map;
@extern .float worldtype; // 0=medieval 1=metal 2=base
//================================================
@extern .string killtarget;
//
// quakeed fields
//
@extern .float light_lev; // not used by game, but parsed by light util
@extern .float style;
//
// monster ai
//
@extern .void() th_stand;
@extern .void() th_walk;
@extern .void() th_run;
@extern .void() th_missile;
@extern .void() th_melee;
@extern .void(entity attacker, float damage) th_pain;
@extern .void() th_die;
@extern .entity oldenemy; // mad at this player before taking damage
@extern .float speed;
@extern .float lefty;
@extern .float search_time;
@extern .float attack_state;
@extern float AS_STRAIGHT;
@extern float AS_SLIDING;
@extern float AS_MELEE;
@extern float AS_MISSILE;
//
// player only fields
//
@extern .float voided;
@extern .float walkframe;
// Zoid Additions
@extern .float maxspeed; // Used to set Maxspeed on a player
@extern .float gravity; // Gravity Multiplier (0 to 1.0)
@extern .float attack_finished;
@extern .float pain_finished;
@extern .float invincible_finished;
@extern .float invisible_finished;
@extern .float super_damage_finished;
@extern .float radsuit_finished;
@extern .float invincible_time, invincible_sound;
@extern .float invisible_time, invisible_sound;
@extern .float super_time, super_sound;
@extern .float rad_time;
@extern .float fly_sound;
@extern .float axhitme;
@extern .float show_hostile; // set to time+0.2 whenever a client fires a
// weapon or takes damage. Used to alert
// monsters that otherwise would let the player go
@extern .float jump_flag; // player jump flag
@extern .float swim_flag; // player swimming sound flag
@extern .float air_finished; // when time > air_finished, start drowning
@extern .float bubble_count; // keeps track of the number of bubbles
@extern .string deathtype; // keeps track of how the player died
//
// object stuff
//
@extern .string mdl;
@extern .vector mangle; // angle at start
@extern .vector oldorigin; // only used by secret door
@extern .float t_length, t_width;
//
// doors, etc
//
@extern .vector dest, dest1, dest2;
@extern .float wait; // time from firing to restarting
@extern .float delay; // time from activation to firing
@extern .entity trigger_field; // door's trigger entity
@extern .string noise4;
//
// monsters
//
@extern .float pausetime;
@extern .entity movetarget;
//
// doors
//
@extern .float aflag;
@extern .float dmg; // damage done by door when hit
//
// misc
//
@extern .float cnt; // misc flag
//
// subs
//
@extern .void() think1;
@extern .vector finaldest, finalangle;
//
// triggers
//
@extern .float count; // for counting triggers
//
// plats / doors / buttons
//
@extern .float lip;
@extern .float state;
@extern .vector pos1, pos2; // top and bottom positions
@extern .float height;
//
// sounds
//
@extern .float waitmin, waitmax;
@extern .float distance;
@extern .float volume;
//===========================================================================
//
// builtin functions
//
@extern void(vector ang) makevectors; // sets v_forward, etc globals
@extern void(entity e, vector o) setorigin;
@extern void(entity e, string m) setmodel; // set movetype and solid first
@extern void(entity e, vector min, vector max) setsize;
// #5 was removed
//void() break;
@extern float() random; // returns 0 - 1
@extern void(entity e, float chan, string samp, float vol, float atten) sound;
@extern vector(vector v) normalize;
@extern void(string e) error;
@extern void(string e) objerror;
@extern float(vector v) vlen;
@extern float(vector v) vectoyaw;
@extern entity() spawn;
@extern void(entity e) remove;
// sets trace_* globals
// nomonsters can be:
// An entity will also be ignored for testing if forent == test,
// forent->owner == test, or test->owner == forent
// a forent of world is ignored
@extern void(vector v1, vector v2, float nomonsters, entity forent) traceline;
@extern entity() checkclient; // returns a client to look for
@extern entity(entity start, .string fld, string match) find;
@extern string(string s) precache_sound;
@extern string(string s) precache_model;
@extern void(entity client, string s)stuffcmd;
@extern entity(vector org, float rad) findradius;
@extern void(float level, string s) bprint;
@extern void(entity client, float level, string s) sprint;
@extern void(string s) dprint;
@extern string(float f) ftos;
@extern string(vector v) vtos;
@extern void() coredump; // prints all edicts
@extern void() traceon; // turns statment trace on
@extern void() traceoff;
@extern void(entity e) eprint; // prints an entire edict
@extern float(float yaw, float dist) walkmove; // returns TRUE or FALSE
// #33 was removed
@extern float() droptofloor; // TRUE if landed on floor
@extern void(float style, string value) lightstyle;
@extern float(float v) rint; // round to nearest int
@extern float(float v) floor; // largest integer <= v
@extern float(float v) ceil; // smallest integer >= v
// #39 was removed
@extern float(entity e) checkbottom; // true if self is on ground
@extern float(vector v) pointcontents; // returns a CONTENT_*
// #42 was removed
@extern float(float f) fabs;
@extern vector(entity e, float speed) aim; // returns the shooting vector
@extern float(string s) cvar; // return cvar.value
@extern void(string s) localcmd; // put string into local que
@extern entity(entity e) nextent; // for looping through all ents
// #48 was removed
@extern void() ChangeYaw; // turn towards self.ideal_yaw
// at self.yaw_speed
// #50 was removed
@extern vector(vector v) vectoangles;
//
// direct client message generation
//
@extern void(float to, float f) WriteByte;
@extern void(float to, float f) WriteChar;
@extern void(float to, float f) WriteShort;
@extern void(float to, float f) WriteLong;
@extern void(float to, float f) WriteCoord;
@extern void(float to, float f) WriteAngle;
@extern void(float to, string s) WriteString;
@extern void(float to, entity s) WriteEntity;
// several removed
@extern void(float step) movetogoal;
@extern string(string s) precache_file; // no effect except for -copy
@extern void(entity e) makestatic;
@extern void(string s) changelevel;
//#71 was removed
@extern void(string var, string val) cvar_set; // sets cvar.value
@extern void(entity client, string s) centerprint; // sprint, but in middle
@extern void(vector pos, string samp, float vol, float atten) ambientsound;
@extern string(string s) precache_model2; // registered version only
@extern string(string s) precache_sound2; // registered version only
@extern string(string s) precache_file2; // registered version only
@extern void(entity e) setspawnparms; // set parm1... to the
// values at level start
// for coop respawn
@extern void(entity killer, entity killee) logfrag; // add to stats
@extern string(entity e, string key) infokey; // get a key value (world = serverinfo)
@extern float(string s) stof; // convert string to float
@extern void(vector where, float set) multicast; // sends the temp message to a set
// of clients, possibly in PVS or PHS
//============================================================================
//
// subs.qc
//
@extern void(vector tdest, float tspeed, void() func) SUB_CalcMove;
@extern void(entity ent, vector tdest, float tspeed, void() func) SUB_CalcMoveEnt;
@extern void(vector destangle, float tspeed, void() func) SUB_CalcAngleMove;
@extern void() SUB_CalcMoveDone;
@extern void() SUB_CalcAngleMoveDone;
@extern void() SUB_Null;
@extern void() SUB_UseTargets;
@extern void() SUB_Remove;
//
// combat.qc
//
@extern void(entity targ, entity inflictor, entity attacker, float damage) T_Damage;
@extern float (entity e, float healamount, float ignore) T_Heal; // health function
@extern float(entity targ, entity inflictor) CanDamage;

10
tools/qfcc/test/fold.r Normal file
View file

@ -0,0 +1,10 @@
float FL_MONSTER = 32;
float FL_FLY = 1;
float FL_SWIM = 2;
.integer flags;
void (entity other)
trigger_monsterjump_touch =
{
if (other.flags & (FL_MONSTER | FL_FLY | FL_SWIM) != FL_MONSTER)
return;
};

13
tools/qfcc/test/foo.r Normal file
View file

@ -0,0 +1,13 @@
#include <Object.h>
@interface Foo : Object
-free;
@end
@implementation Foo
-free
{
[super free];
[self free];
}
@end

8
tools/qfcc/test/func.r Normal file
View file

@ -0,0 +1,8 @@
@extern float (integer i) itof;
void (integer size, integer perc_val) func =
{
local float perc;
perc = itof (perc_val) / (100 / itof (size));
};

View file

@ -0,0 +1,318 @@
#include "Entity.h"
@class Bot;
@class Waypoint;
struct bot_data_t = {
string name;
float pants, shirt;
};
typedef struct bot_data_t bot_data_t;
@interface Target: Entity
{
}
-(vector)realorigin;
-(integer)canSee:(Target)targ ignoring:(entity)ignore;
-(void)setOrigin:(vector) org;
@end
@interface Waypoint: Target
{
@public
Waypoint [4] targets;
integer flags;
vector origin;
integer b_pants, b_skill, b_shirt, b_frags, b_sound;
integer keys;
float items;
Waypoint enemy;
float search_time;
}
+(void)clearAll;
+(Waypoint)waypointForNum:(integer)num;
+(void)fixWaypoints;
+(void)clearRouteTable;
+(void)clearMyRoute:(Bot) bot;
-(void)fix;
-(id)init;
-(id)initAt:(vector)org;
-(id)initFromEntity:(entity)ent;
-(integer)isLinkedTo:(Waypoint)way;
-(integer)linkWay:(Waypoint)way;
-(integer)teleLinkWay:(Waypoint)way;
-(void)unlinkWay:(Waypoint)way;
-(void)followLink:(Waypoint)e2 :(integer)b_bit;
-(void)waypointThink;
-(void)clearRoute;
-(void)clearRouteForBot:(Bot)bot;
-(id)queueForThink;
@end
@class Array;
@extern Array waypoint_array;
@interface Bot: Target
{
@public
//model modelindex
//frame angles colormap effects
//owner
//movetype solid touch <size> watertype flags think nextthink
integer keys, oldkeys;
integer buttons, impulse;
vector v_angle, b_angle;
vector mouse_emu;
integer wallhug;
integer ishuman;
float b_frags;
integer b_clientno, b_clientflag;
float b_shirt, b_pants;
float ai_time;
float b_sound;
float missile_speed;
float portal_time;
integer b_skill;
float switch_wallhug;
integer b_aiflags;
integer b_num;
float b_chattime;
float b_entertime;
float b_menu, b_menu_time, b_menu_value;
integer route_failed;
integer dyn_flags, dyn_plat;
float dyn_time;
Waypoint temp_way, last_way, current_way;
entity [4] targets;
entity avoid;
vector obs_dir;
vector b_dir;
vector dyn_dest;
vector punchangle;
float teleport_time, portal_time;
}
- (id) init;
- (id) initWithEntity: (entity) e named:(bot_data_t [])name skill:(integer)skill;
- (id) initFromPlayer: (entity) e;
- (void) preThink;
- (void) postThink;
- (void) frame;
- (void) disconnect;
- (void) updateClient;
@end
@interface Bot (Misc)
+(bot_data_t [])name:(integer)r;
+(bot_data_t [])randomName;
-(integer)fov:(entity)targ;
+(void)kick;
@end
@interface Bot (Physics)
- (void)sendMove;
@end
@interface Bot (Move)
- (void)jump;
- (integer)can_rj;
- (integer)recognize_plat: (integer) flag;
- (integer)keysForDir: (vector) sdir;
- (void)obstructed: (vector) whichway : (integer) danger;
- (void)obstacles;
- (void)dodge_obstruction;
- (void)movetogoal;
- (integer)walkmove: (vector) weird;
- (void)roam;
@end
@interface Bot (AI)
-(integer)target_onstack:(entity)scot;
-(void)target_add:(entity)e;
-(void)target_drop:(entity)e;
-(void)lost:(Waypoint)targ :(integer)success;
-(void)check_lost:(Waypoint)targ;
-(void)handle_ai;
-(void)path;
-(float)priority_for_thing:(entity)thing;
-(void)look_for_crap:(integer)scope;
-(void)angle_set;
-(void)AI;
@end
@interface Bot (Fight)
-(float)size_player:(entity)e;
-(void)dodge_stuff;
-(void)weapon_switch:(float)brange;
-(void)shoot;
-(void)fight_style;
@end
@interface Bot (Way)
-(Waypoint)findWaypoint:(Waypoint)start;
-(void)deleteWaypoint:(Waypoint)what;
-(entity)findThing:(string)s;
-(Waypoint)findRoute:(Waypoint)lastone;
-(void)mark_path:(entity)this;
-(void)get_path:(Waypoint)this :(integer)direct;
-(integer)begin_route;
-(void)spawnTempWaypoint:(vector)org;
-(void)dynamicWaypoint;
-(integer)canSee:(Target)targ;
@end
@interface Bot (Chat)
-(void)start_topic:(integer)topic;
-(void)say:(string)msg;
-(void)say2:(string)msg;
-(void)sayTeam:(string)msg;
-(void)sayInit;
-(void)chat;
@end
#define FALSE 0
#define TRUE 1
/* punchangle
* bot fake kick?
*/
@extern .vector punchangle; // HACK - Don't want to screw with bot_phys
// --------defines-----
#define SVC_UPDATENAME 13
#define SVC_UPDATEFRAGS 14
#define SVC_UPDATECOLORS 17
// used for the physics & movement AI
#define KEY_MOVEUP 0x001
#define KEY_MOVEDOWN 0x002
#define KEY_MOVELEFT 0x004
#define KEY_MOVERIGHT 0x008
#define KEY_MOVEFORWARD 0x010
#define KEY_MOVEBACK 0x020
#define KEY_LOOKUP 0x040
#define KEY_LOOKDOWN 0x080
#define KEY_LOOKLEFT 0x100
#define KEY_LOOKRIGHT 0x200
#define KEY_LOOK (KEY_LOOKRIGHT|KEY_LOOKLEFT|KEY_LOOKDOWN|KEY_LOOKUP)
#define KEY_MOVE (KEY_MOVEBACK|KEY_MOVEFORWARD|KEY_MOVERIGHT\
|KEY_MOVELEFT|KEY_MOVEDOWN|KEY_MOVEUP)
// these are aiflags for waypoints
// some overlap to the bot
#define AI_TELELINK_1 0x00001 // link type
#define AI_TELELINK_2 0x00002 // link type
#define AI_TELELINK_3 0x00004 // link type
#define AI_TELELINK_4 0x00008 // link type
#define AI_DOORFLAG 0x00010 // read ahead
#define AI_PRECISION 0x00020 // read ahead + point
#define AI_SURFACE 0x00040 // point
#define AI_BLIND 0x00080 // read ahead + point
#define AI_JUMP 0x00100 // point + ignore
#define AI_DIRECTIONAL 0x00200 // read ahead + ignore
#define AI_PLAT_BOTTOM 0x00400 // read ahead
#define AI_RIDE_TRAIN 0x00800 // read ahead
#define AI_SUPER_JUMP 0x01000 // point + ignore + route test
#define AI_SNIPER 0x02000 // point type
#define AI_AMBUSH 0x04000 // point type
#define AI_DOOR_NO_OPEN 0x08000 // read ahead
#define AI_DIFFICULT 0x10000 // route test
#define AI_TRACE_TEST 0x20000 // route test
// addition masks
#define AI_POINT_TYPES (AI_AMBUSH|AI_SNIPER|AI_SUPER_JUMP|AI_JUMP\
|AI_BLIND|AI_SURFACE|AI_PRECISION)
#define AI_READAHEAD_TYPES (AI_DOOR_NO_OPEN|AI_RIDE_TRAIN|AI_PLAT_BOTTOM\
|AI_DIRECTIONAL)
#define AI_IGNORE_TYPES (AI_SUPER_JUMP|AI_DIRECTIONAL|AI_JUMP)
// these are flags for bots/players (dynamic/editor flags)
#define AI_OBSTRUCTED 1
#define AI_HOLD_SELECT 2
#define AI_ROUTE_FAILED 2
#define AI_WAIT 4
#define AI_DANGER 8
#define WM_UNINIT 0
#define WM_DYNAMIC 1
#define WM_LOADING 2
#define WM_LOADED 3
// editor modes aren't available in QW, but we retain support of them
// since the editor is still built into the AI in places
#define WM_EDITOR 4
#define WM_EDITOR_DYNAMIC 5
#define WM_EDITOR_DYNLINK 6
#define OPT_NOCHAT 2
// -------globals-----
@extern Bot [32] players;
@extern float real_frametime;
@extern float bot_count, b_options;
@extern float lasttime;
@extern float waypoint_mode;
@extern float dump_mode;
@extern float direct_route;
@extern float sv_friction, sv_gravity;
@extern float sv_accelerate, sv_maxspeed, sv_stopspeed;
@extern Bot route_table;
@extern integer busy_waypoints;
@extern float coop;
// -------ProtoTypes------
// external, in main code
@extern void() ClientConnect;
@extern void() ClientDisconnect;
@extern void() SetNewParms;
// rankings
@extern integer (entity e) ClientNumber;
@extern void(vector org, vector bit1, integer bit4, integer flargs) make_way;
@extern void () map_dm1;
@extern void () map_dm2;
@extern void () map_dm3;
@extern void () map_dm4;
@extern void () map_dm5;
@extern void () map_dm6;
// physics & movement
@extern void() SV_Physics_Client;
@extern void() SV_ClientThink;
@extern void() CL_KeyMove;
// ai & misc
@extern float(float y1, float y2) angcomp;
@extern float(entity ent, entity targ) sisible;
@extern vector(entity ent) realorigin;
@extern float(float v) frik_anglemod;
@extern void(Waypoint e1, Waypoint e2, integer flag) DeveloperLightning;
/*
angles is pitch yaw roll
move is forward right up
*/
@extern void (entity cl, float sec, vector angles, vector move, integer buttons, integer impulse) SV_UserCmd;
@extern integer bot_way_linker;
@extern integer bot_move_linker;
@extern integer bot_phys_linker;
@extern integer bot_chat_linker;
#include "defs.h"

View file

@ -0,0 +1,59 @@
#include "Entity.h"
@class Waypoint;
@class Bot;
struct bot_data_t = {
string name;
float pants, shirt;
};
typedef struct bot_data_t bot_data_t;
@interface Target: Entity
{
@public
Waypoint current_way;
Target _last;
}
@end
@interface Waypoint: Target
{
@public
Waypoint [4] links;
Waypoint []list;
unsigned count;
unsigned b_sound;
}
-(void)fix;
-(void)clearRouteForBot:(Bot)bot;
@end
@interface Bot: Target
{
@public
integer b_clientflag;
}
@end
@implementation Target
@end
@implementation Waypoint
-(void)fix
{
//local integer i = 2, tmp;
local unsigned u;
//tmp = (integer)links[i];
//for (u = 0; u < count; u++)
[list[u] fix];
}
-(void)clearRouteForBot:(Bot)bot
{
local integer flag;
flag = bot.b_clientflag;
b_sound &= ~flag;
}
@end

View file

@ -0,0 +1,8 @@
#include <Object.h>
integer zero;
string (Object foo) getstr;
id (Object foo) bar =
{
return [foo error:"foo %s", getstr(foo)];
};

12
tools/qfcc/test/offset.r Normal file
View file

@ -0,0 +1,12 @@
struct foobar_s = {
integer a;
(struct foobar_s [])[4]b;
};
typedef struct foobar_s foobar_t;
typedef foobar_t [] foobar_p;
void (foobar_p foo, vector x, integer y) bar =
{
foo.a = x.z;
foo.b[1] = (foobar_p)(integer)x.y;
};

29
tools/qfcc/test/prec.qc Normal file
View file

@ -0,0 +1,29 @@
float (float x, float y, float z) foo =
{
return !x * y;
return !x / y;
return !x + y;
return !x - y;
return !x < y;
return !x <= y;
return !x > y;
return !x >= y;
return !x == y;
return !x != y;
return !x & y;
return !x | y;
return !x && y;
return !x || y;
return !x = y;
// return x & y = z; // XXX
// return x = y & z; // XXX
return x * y & z;
return x & y * z;
// return x && y = z; // XXX
// return x = y && z; // XXX
// return x && y || z;
// return x || y && z;
// return x < y == z;
// return x == y < z;
// return x * y = z;
};

View file

@ -0,0 +1,9 @@
float (float x, float y, float z) foo =
{
// return x || (y && z);
// return (x || y) && z;
// return x || y && z;
// return !x & y;
return x * y + z;
return x + y * z;
};

View file

@ -0,0 +1,3 @@
progs.dat
prec.qc

View file

@ -0,0 +1,4 @@
SEL a = @selector (setBasePos:y:);
SEL b = @selector (setBasePos:);
void () foo = {};

11
tools/qfcc/test/semi.r Normal file
View file

@ -0,0 +1,11 @@
void () zzz = #0;
void () xxx;
void () foo = #0, baz;
void () bar, snafu=#0, blah = {}
void blaze ();
void fire () = #22;
integer fry (integer x)
{
return 3 * x;
}

View file

@ -0,0 +1,9 @@
void (integer x, integer y) foo =
{
if (x && y)
x += 2;
if (0)
x -= 1;
if (1)
x += 2;
};

3
tools/qfcc/test/state.r Normal file
View file

@ -0,0 +1,3 @@
void () bar;
void () foo = [1,bar,0.2] {}
void () bar = [1,foo] {}

35
tools/qfcc/test/switch.r Normal file
View file

@ -0,0 +1,35 @@
#define IT_AXE 0x001000
#define IT_SHOTGUN 0x000001
#define IT_SUPER_SHOTGUN 0x000002
#define IT_NAILGUN 0x000004
#define IT_SUPER_NAILGUN 0x000008
#define IT_GRENADE_LAUNCHER 0x000010
#define IT_ROCKET_LAUNCHER 0x000020
#define IT_LIGHTNING 0x000040
#define IT_EXTRA_WEAPON 0x000080
string foo = "oo";
vector (integer wep)
weapon_range =
{
switch (wep) {
case IT_AXE:
return '48 0 64';
case IT_SHOTGUN:
return '128 0 99999';
case IT_SUPER_SHOTGUN:
return '128 0 99999';
case IT_NAILGUN:
return '180 0 3000';
case IT_SUPER_NAILGUN:
return '180 0 3000';
case IT_GRENADE_LAUNCHER:
return '180 48 3000';
case IT_ROCKET_LAUNCHER:
return '180 48 3000';
case IT_LIGHTNING:
return '350 0 512';
default:
return '0 0 0';
}
};

41
tools/qfcc/test/test.qc Normal file
View file

@ -0,0 +1,41 @@
#if 0
#if 0
integer (void [] a, void [] b) cmp =
{
return a == b;
};
#else
entity e;
.@va_list a;
.vector v;
integer (string fmt, @va_list args) vprintf =
{
return args.count;
};
integer (string fmt, ...) printf =
{
local @va_list s;
local @va_list t;
s = @args;
//t = @args = s;
s = e.a;
e.a = s;
e.a = s = @args;
return vprintf (fmt, @args);
};
#endif
void () blah =
{
printf ("", 0x1, 0x9, 0xA, 0xF, 0xa, 0xf, 0x12abCD);
};
#else
entity self;
.float keys;
float (float key) CL_KeyState =
{
return (float)((self.keys & key) > 0);
};
#endif

12
tools/qfcc/test/test.r Normal file
View file

@ -0,0 +1,12 @@
entity self;
.float heat;
.entity ent;
.entity own;
entity () blah;
void (float x) foo =
{
if (self.heat = 0)
return;
if ((x = self.heat && 0))
return;
};