📄 g_local.pas
字号:
last_move_time: single;
health,
max_health,
gib_health,
deadflag: integer;
show_hostile: qboolean;
powerarmor_time: Single;
map: PChar; // target_changelevel
viewheight: Integer; // height above origin where eyesight is determined
takedamage: damage_t; // CAK - was Integer
dmg,
radius_dmg: integer;
dmg_radius: Single; // CAK - THIS WAS WRONG!!!!!
sounds, //make this a spawntemp var
count: integer;
chain,
enemy,
oldenemy,
activator,
groundentity: edict_p;
groundentity_linkcount: integer;
teamchain,
teammaster: edict_p;
mynoise, // can go in client only
mynoise2: edict_p;
noise_index,
noise_index2: integer;
volume,
attenuation: Single;
// timing variables
wait,
delay, // before firing targets
random: Single;
teleport_time: single;
watertype,
waterlevel: integer;
move_origin: vec3_t;
move_angles: vec3_t;
// move this to clientinfo?
light_level: integer;
style: integer; // also used as areaportal number
item: gitem_p; // for bonus items
// common data blocks
moveinfo: moveinfo_t;
monsterinfo: monsterinfo_t;
end;
edict_t = edict_s;
_edict_s = edict_t;
p_edict_s = edict_p;
pedict_t = edict_p;
TEdict = edict_t;
PEdict = edict_p;
edict_at = array [0..MaxInt div SizeOf(edict_t)-1] of edict_t;
edict_a = ^edict_at;
TEdictArray = edict_at;
PEdictArray = edict_a;
// CAK - These two types are thanks to Clootie
// Note - This is an array of POINTERS,
// Most places you should use an array of RECORDS
PEdictPArray = ^TEdictPArray;
TEdictPArray = array [0..MaxInt div SizeOf(edict_p)-1] of edict_p;
//////////////////////////////////////
///////////////////////////////////////
/////////////////////////////////////
// define GAME_INCLUDE so that game.h does not define the
// short, server-visible gclient_t and edict_t structures,
// because we define the full size ones in this file
{$define GAME_INCLUDE}
// the "gameversion" client command will print this plus compile date
const
GAMEVERSION = 'baseq2';
// protocol bytes that can be directly added to messages
svc_muzzleflash = 1;
svc_muzzleflash2 = 2;
svc_temp_entity = 3;
svc_layout = 4;
svc_inventory = 5;
{$ifndef CTF}
svc_stufftext = 11;
{$endif}
//==================================================================
// view pitching times
DAMAGE_TIME = 0.5;
FALL_TIME = 0.3;
// edict->spawnflags
// these are set with checkboxes on each entity in the map editor
SPAWNFLAG_NOT_EASY = $00000100;
SPAWNFLAG_NOT_MEDIUM = $00000200;
SPAWNFLAG_NOT_HARD = $00000400;
SPAWNFLAG_NOT_DEATHMATCH = $00000800;
SPAWNFLAG_NOT_COOP = $00001000;
// edict->flags
FL_FLY = $00000001;
FL_SWIM = $00000002; // implied immunity to drowining
FL_IMMUNE_LASER = $00000004;
FL_INWATER = $00000008;
FL_GODMODE = $00000010;
FL_NOTARGET = $00000020;
FL_IMMUNE_SLIME = $00000040;
FL_IMMUNE_LAVA = $00000080;
FL_PARTIALGROUND = $00000100; // not all corners are valid
FL_WATERJUMP = $00000200; // player jumping out of water
FL_TEAMSLAVE = $00000400; // not the first on the team
FL_NO_KNOCKBACK = $00000800;
FL_POWER_ARMOR = $00001000; // power armor (if any) is active
FL_RESPAWN = $80000000; // used for item respawning
FRAMETIME = 0.1;
// memory tags to allow dynamic memory to be cleaned up
TAG_GAME = 765; // clear when unloading the dll
TAG_LEVEL = 766; // clear when loading a new level
MELEE_DISTANCE = 80;
BODY_QUEUE_SIZE = 8;
//deadflag
DEAD_NO = 0;
DEAD_DYING = 1;
DEAD_DEAD = 2;
DEAD_RESPAWNABLE = 3;
//range
RANGE_MELEE = 0;
RANGE_NEAR = 1;
RANGE_MID = 2;
RANGE_FAR = 3;
//gib types
GIB_ORGANIC = 0;
GIB_METALLIC = 1;
//monster ai flags
AI_STAND_GROUND = $00000001;
AI_TEMP_STAND_GROUND = $00000002;
AI_SOUND_TARGET = $00000004;
AI_LOST_SIGHT = $00000008;
AI_PURSUIT_LAST_SEEN = $00000010;
AI_PURSUE_NEXT = $00000020;
AI_PURSUE_TEMP = $00000040;
AI_HOLD_FRAME = $00000080;
AI_GOOD_GUY = $00000100;
AI_BRUTAL = $00000200;
AI_NOSTEP = $00000400;
AI_DUCKED = $00000800;
AI_COMBAT_POINT = $00001000;
AI_MEDIC = $00002000;
AI_RESURRECTING = $00004000;
//monster attack state
AS_STRAIGHT = 1;
AS_SLIDING = 2;
AS_MELEE = 3;
AS_MISSILE = 4;
// armor types
ARMOR_NONE = 0;
ARMOR_JACKET = 1;
ARMOR_COMBAT = 2;
ARMOR_BODY = 3;
ARMOR_SHARD = 4;
// power armor types
POWER_ARMOR_NONE = 0;
POWER_ARMOR_SCREEN = 1;
POWER_ARMOR_SHIELD = 2;
// handedness values
RIGHT_HANDED = 0;
LEFT_HANDED = 1;
CENTER_HANDED = 2;
// game.serverflags values
SFL_CROSS_TRIGGER_1 = $00000001;
SFL_CROSS_TRIGGER_2 = $00000002;
SFL_CROSS_TRIGGER_3 = $00000004;
SFL_CROSS_TRIGGER_4 = $00000008;
SFL_CROSS_TRIGGER_5 = $00000010;
SFL_CROSS_TRIGGER_6 = $00000020;
SFL_CROSS_TRIGGER_7 = $00000040;
SFL_CROSS_TRIGGER_8 = $00000080;
SFL_CROSS_TRIGGER_MASK = $000000ff;
// noise types for PlayerNoise
PNOISE_SELF = 0;
PNOISE_WEAPON = 1;
PNOISE_IMPACT = 2;
// gitem_t->flags
IT_WEAPON = 1; // use makes active weapon
IT_AMMO = 2;
IT_ARMOR = 4;
IT_STAY_COOP = 8;
IT_KEY = 16;
IT_POWERUP = 32;
{$ifdef CTF}
//ZOID
IT_TECH = 64;
//ZOID
{$endif}
// gitem_t->weapmodel for weapons indicates model index
WEAP_BLASTER = 1;
WEAP_SHOTGUN = 2;
WEAP_SUPERSHOTGUN = 3;
WEAP_MACHINEGUN = 4;
WEAP_CHAINGUN = 5;
WEAP_GRENADES = 6;
WEAP_GRENADELAUNCHER = 7;
WEAP_ROCKETLAUNCHER = 8;
WEAP_HYPERBLASTER = 9;
WEAP_RAILGUN = 10;
WEAP_BFG = 11;
{$ifdef CTF}
WEAP_GRAPPLE = 12;
{$endif}
// item spawnflags
ITEM_TRIGGER_SPAWN = $00000001;
ITEM_NO_TOUCH = $00000002;
// 6 bits reserved for editor flags
// 8 bits used as power cube id bits for coop games
DROPPED_ITEM = $00010000;
DROPPED_PLAYER_ITEM = $00020000;
ITEM_TARGETS_USED = $00040000;
//
// fields are needed for spawning from the entity string
// and saving / loading games
//
FFL_SPAWNTEMP = 1;
{$ifndef CTF}
FFL_NOSPAWN = 2;
{$endif}
// means of death
MOD_UNKNOWN = 0;
MOD_BLASTER = 1;
MOD_SHOTGUN = 2;
MOD_SSHOTGUN = 3;
MOD_MACHINEGUN = 4;
MOD_CHAINGUN = 5;
MOD_GRENADE = 6;
MOD_G_SPLASH = 7;
MOD_ROCKET = 8;
MOD_R_SPLASH = 9;
MOD_HYPERBLASTER = 10;
MOD_RAILGUN = 11;
MOD_BFG_LASER = 12;
MOD_BFG_BLAST = 13;
MOD_BFG_EFFECT = 14;
MOD_HANDGRENADE = 15;
MOD_HG_SPLASH = 16;
MOD_WATER = 17;
MOD_SLIME = 18;
MOD_LAVA = 19;
MOD_CRUSH = 20;
MOD_TELEFRAG = 21;
MOD_FALLING = 22;
MOD_SUICIDE = 23;
MOD_HELD_GRENADE = 24;
MOD_EXPLOSIVE = 25;
MOD_BARREL = 26;
MOD_BOMB = 27;
MOD_EXIT = 28;
MOD_SPLASH = 29;
MOD_TARGET_LASER = 30;
MOD_TRIGGER_HURT = 31;
MOD_HIT = 32;
MOD_TARGET_BLASTER=33;
{$ifdef CTF}
MOD_GRAPPLE =34;
{$endif}
MOD_FRIENDLY_FIRE= $8000000;
// damage flags
DAMAGE_RADIUS = $00000001; // damage was indirect
DAMAGE_NO_ARMOR = $00000002; // armour does not protect from this damage
DAMAGE_ENERGY = $00000004; // damage is from an energy based weapon
DAMAGE_NO_KNOCKBACK = $00000008; // do not affect velocity, just view angles
DAMAGE_BULLET = $00000010; // damage is from a bullet (used for ricochets)
DAMAGE_NO_PROTECTION = $00000020; // armor, shields, invulnerability, and godmode have no effect
DEFAULT_BULLET_HSPREAD = 300;
DEFAULT_BULLET_VSPREAD = 500;
DEFAULT_SHOTGUN_HSPREAD = 1000;
DEFAULT_SHOTGUN_VSPREAD = 500;
DEFAULT_DEATHMATCH_SHOTGUN_COUNT = 12;
DEFAULT_SHOTGUN_COUNT = 12;
DEFAULT_SSHOTGUN_COUNT = 20;
//============================================================================
// client_t->anim_priority
ANIM_BASIC = 0; // stand / run
ANIM_WAVE = 1;
ANIM_JUMP = 2;
ANIM_PAIN = 3;
ANIM_ATTACK = 4;
ANIM_DEATH = 5;
ANIM_REVERSE = 6;
{* CAK - These 4 macros...
#define FOFS(x) (int)&(((edict_t *)0)->x)
#define STOFS(x) (int)&(((spawn_temp_t *)0)->x)
#define LLOFS(x) (int)&(((level_locals_t *)0)->x)
#define CLOFS(x) (int)&(((gclient_t *)0)->x)
are now hundreds of functions in g_save. Instead of:
FOFS(classname)
use:
FOFS_classname
It is defined as:
function FOFS_classname: Integer; begin Result:=Integer(@edict_p(Ptr(0)).classname); end;
}
function _random: Single; // CAK - MACROS
function crandom: Single;
Var
game: game_locals_t;
level: level_locals_t;
// CAK - MOVED TO game
// gi: game_import_t;
// globals: game_export_t;
st: spawn_temp_t;
sm_meat_index: integer;
snd_fry: integer;
jacket_armor_index: integer;
combat_armor_index: integer;
body_armor_index: integer;
meansOfDeath: integer;
g_edicts: edict_a;
fields: Array[0..0] of field_t;
itemlist: Array[0..0] of gitem_t;
// CAK - TAKEN FROM q_shared.h
(*
==========================================================
CVARS (console variables)
==========================================================
*)
// nothing outside the Cvar_*() functions should modify these fields!
type
cvar_p = ^cvar_s;
pcvar_s = cvar_p;
cvar_s = record
name: PChar;
string_: PChar;
latched_string: PChar; // for CVAR_LATCH vars
flags: integer;
modified: qboolean; // set each time the cvar is changed
Value: single;
Next: cvar_p;
end;
cvar_t = cvar_s;
pcvar_t = cvar_p;
TCVar = cvar_t;
PCVar = cvar_p;
cvar_at = array[0..MaxInt div sizeof(cvar_t)-1] of cvar_t;
cvar_a = ^cvar_at;
TCVarArray = cvar_at;
PCVarArray = cvar_a;
Var
maxentities,
deathmatch,
coop,
dmflags,
skill,
fraglimit,
timelimit: cvar_p;
{$ifdef CTF}
//ZOID
capturelimit,
instantweap: cvar_p;
//ZOID
{$endif}
password: cvar_p;
{$ifndef CTF}
spectator_password,
needpass: cvar_p;
{$endif}
g_select_empty,
dedicated: cvar_p;
filterban: cvar_p;
sv_gravity,
sv_maxvelocity: cvar_p;
gun_x, gun_y, gun_z,
sv_rollspeed,
sv_rollangle: cvar_p;
run_pitch,
run_roll,
bob_up,
bob_pitch,
bob_roll: cvar_p;
sv_cheats,
maxclients: cvar_p;
{$ifndef CTF}
maxspectators: cvar_p;
{$endif}
flood_msgs,
flood_persecond,
flood_waitdelay: cvar_p;
sv_maplist: cvar_p;
{$ifdef CTF}
//ZOID
is_quad: qboolean;
//ZOID
{$endif}
// massimo - Also, what does means this thing???
// #define world (&g_edicts[0])
// CAK - world is the first edict in the g_edicts array
// because MACROS do not exist in Delphi, I converted it to
// an edict_p which always points to the first edict in the g_edicts array.
Var
world: edict_p absolute g_edicts;
implementation
Uses SysUtils; // CAK - Exception handling only (for assertions below)
function _random: Single; // ((rand () & 0x7fff) / ((float)0x7fff))
begin
Result:= System.Random($8000) / $7fff;
end;
function crandom: Single;
begin
Result:= 2.0 * (_random - 0.5);
end;
initialization
// Check the size of types defined in g_local.h
{$ifndef CTF}
Assert(sizeof(damage_t)=4);
Assert(sizeof(weaponstate_t)=4);
Assert(sizeof(ammo_t)=4);
Assert(sizeof(movetype_t)=4);
Assert(sizeof(gitem_armor_t)=20);
Assert(sizeof(gitem_t)=76);
Assert(sizeof(game_locals_t)=1564);
Assert(sizeof(level_locals_t)=304);
Assert(sizeof(spawn_temp_t)=68);
Assert(sizeof(moveinfo_t)=120);
Assert(sizeof(mframe_t)=12);
Assert(sizeof(mmove_t)=16);
Assert(sizeof(monsterinfo_t)=120);
Assert(sizeof(fieldtype_t)=4);
Assert(sizeof(field_t)=16);
Assert(sizeof(client_persistant_t)=1628);
Assert(sizeof(client_respawn_t)=1652);
Assert(sizeof(gclient_s)=3804);
Assert(sizeof(edict_s)=892);
{$else}
Assert(sizeof(damage_t)=4);
Assert(sizeof(weaponstate_t)=4);
Assert(sizeof(ammo_t)=4);
Assert(sizeof(movetype_t)=4);
Assert(sizeof(gitem_armor_t)=20);
Assert(sizeof(gitem_t)=76);
Assert(sizeof(game_locals_t)=1564);
Assert(sizeof(level_locals_t)=368);
Assert(sizeof(spawn_temp_t)=68);
Assert(sizeof(moveinfo_t)=120);
Assert(sizeof(mframe_t)=12);
Assert(sizeof(mmove_t)=16);
Assert(sizeof(monsterinfo_t)=120);
Assert(sizeof(fieldtype_t)=4);
Assert(sizeof(field_t)=16);
Assert(sizeof(client_persistant_t)=1616);
Assert(sizeof(client_respawn_t)=1692);
Assert(sizeof(gclient_s)=3872);
Assert(sizeof(edict_s)=892);
{$endif}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -