1 // g_local.h -- local definitions for game module 2 3 #include "q_shared.h" 4 5 // define GAME_INCLUDE so that game.h does not define the 6 // short, server-visible gclient_t and edict_t structures, 7 // because we define the full size ones in this file 8 #define GAME_INCLUDE 9 #include "game.h" 10 11 // the "gameversion" client command will print this plus compile date 12 #define GAMEVERSION "baseq2" 13 14 // protocol bytes that can be directly added to messages 15 #define svc_muzzleflash 1 16 #define svc_muzzleflash2 2 17 #define svc_temp_entity 3 18 #define svc_layout 4 19 #define svc_inventory 5 20 #define svc_stufftext 11 21 22 23 // view pitching times 24 #define DAMAGE_TIME 0.5 25 #define FALL_TIME 0.3 26 27 28 // edict->spawnflags 29 // these are set with checkboxes on each entity in the map editor 30 #define SPAWNFLAG_NOT_EASY 0x00000100 31 #define SPAWNFLAG_NOT_MEDIUM 0x00000200 32 #define SPAWNFLAG_NOT_HARD 0x00000400 33 #define SPAWNFLAG_NOT_DEATHMATCH 0x00000800 34 #define SPAWNFLAG_NOT_COOP 0x00001000 35 36 // edict->flags 37 #define FL_FLY 0x00000001 38 #define FL_SWIM 0x00000002 // implied immunity to drowining 39 #define FL_IMMUNE_LASER 0x00000004 40 #define FL_INWATER 0x00000008 41 #define FL_GODMODE 0x00000010 42 #define FL_NOTARGET 0x00000020 43 #define FL_IMMUNE_SLIME 0x00000040 44 #define FL_IMMUNE_LAVA 0x00000080 45 #define FL_PARTIALGROUND 0x00000100 // not all corners are valid 46 #define FL_WATERJUMP 0x00000200 // player jumping out of water 47 #define FL_TEAMSLAVE 0x00000400 // not the first on the team 48 #define FL_NO_KNOCKBACK 0x00000800 49 #define FL_POWER_ARMOR 0x00001000 // power armor (if any) is active 50 #define FL_RESPAWN 0x80000000 // used for item respawning 51 52 53 #define FRAMETIME 0.1 54 55 // memory tags to allow dynamic memory to be cleaned up 56 #define TAG_GAME 765 // clear when unloading the dll 57 #define TAG_LEVEL 766 // clear when loading a new level 58 59 60 #define MELEE_DISTANCE 80 61 62 #define BODY_QUEUE_SIZE 8 63 64 typedef enum 65 { 66 DAMAGE_NO, 67 DAMAGE_YES, // will take damage if hit 68 DAMAGE_AIM // auto targeting recognizes this 69 } damage_t; 70 71 typedef enum 72 { 73 WEAPON_READY, 74 WEAPON_ACTIVATING, 75 WEAPON_DROPPING, 76 WEAPON_FIRING 77 } weaponstate_t; 78 79 typedef enum 80 { 81 AMMO_BULLETS, 82 AMMO_SHELLS, 83 AMMO_ROCKETS, 84 AMMO_GRENADES, 85 AMMO_CELLS, 86 AMMO_SLUGS 87 } ammo_t; 88 89 90 //deadflag 91 #define DEAD_NO 0 92 #define DEAD_DYING 1 93 #define DEAD_DEAD 2 94 #define DEAD_RESPAWNABLE 3 95 96 //range 97 #define RANGE_MELEE 0 98 #define RANGE_NEAR 1 99 #define RANGE_MID 2 100 #define RANGE_FAR 3 101 102 //gib types 103 #define GIB_ORGANIC 0 104 #define GIB_METALLIC 1 105 106 //monster ai flags 107 #define AI_STAND_GROUND 0x00000001 108 #define AI_TEMP_STAND_GROUND 0x00000002 109 #define AI_SOUND_TARGET 0x00000004 110 #define AI_LOST_SIGHT 0x00000008 111 #define AI_PURSUIT_LAST_SEEN 0x00000010 112 #define AI_PURSUE_NEXT 0x00000020 113 #define AI_PURSUE_TEMP 0x00000040 114 #define AI_HOLD_FRAME 0x00000080 115 #define AI_GOOD_GUY 0x00000100 116 #define AI_BRUTAL 0x00000200 117 #define AI_NOSTEP 0x00000400 118 #define AI_DUCKED 0x00000800 119 #define AI_COMBAT_POINT 0x00001000 120 #define AI_MEDIC 0x00002000 121 #define AI_RESURRECTING 0x00004000 122 123 //monster attack state 124 #define AS_STRAIGHT 1 125 #define AS_SLIDING 2 126 #define AS_MELEE 3 127 #define AS_MISSILE 4 128 129 // armor types 130 #define ARMOR_NONE 0 131 #define ARMOR_JACKET 1 132 #define ARMOR_COMBAT 2 133 #define ARMOR_BODY 3 134 #define ARMOR_SHARD 4 135 136 // power armor types 137 #define POWER_ARMOR_NONE 0 138 #define POWER_ARMOR_SCREEN 1 139 #define POWER_ARMOR_SHIELD 2 140 141 // handedness values 142 #define RIGHT_HANDED 0 143 #define LEFT_HANDED 1 144 #define CENTER_HANDED 2 145 146 147 // game.serverflags values 148 #define SFL_CROSS_TRIGGER_1 0x00000001 149 #define SFL_CROSS_TRIGGER_2 0x00000002 150 #define SFL_CROSS_TRIGGER_3 0x00000004 151 #define SFL_CROSS_TRIGGER_4 0x00000008 152 #define SFL_CROSS_TRIGGER_5 0x00000010 153 #define SFL_CROSS_TRIGGER_6 0x00000020 154 #define SFL_CROSS_TRIGGER_7 0x00000040 155 #define SFL_CROSS_TRIGGER_8 0x00000080 156 #define SFL_CROSS_TRIGGER_MASK 0x000000ff 157 158 159 // noise types for PlayerNoise 160 #define PNOISE_SELF 0 161 #define PNOISE_WEAPON 1 162 #define PNOISE_IMPACT 2 163 164 165 // stats layout items 166 #define STAT_CTF_TEAM1_PIC 19 167 #define STAT_CTF_TEAM1_SCORE 20 168 #define STAT_CTF_TEAM2_PIC 21 169 #define STAT_CTF_TEAM2_SCORE 22 170 #define STAT_CTF_FLAG_PIC 23 171 #define STAT_CTF_JOINED_TEAM1_PIC 24 172 #define STAT_CTF_JOINED_TEAM2_PIC 25 173 #define STAT_CTF_TECH 26 174 #define STAT_CTF_ID_VIEW 27 175 176 // dmflags 177 #define DF_CTF_FORCEJOIN 0x00010000 178 #define DF_ARMOR_PROTECT 0x00020000 179 #define DF_CTF_NO_TECH 0x00040000 180 181 182 // edict->movetype values 183 typedef enum 184 { 185 MOVETYPE_NONE, // never moves 186 MOVETYPE_NOCLIP, // origin and angles change with no interaction 187 MOVETYPE_PUSH, // no clip to world, push on box contact 188 MOVETYPE_STOP, // no clip to world, stops on box contact 189 190 MOVETYPE_WALK, // gravity 191 MOVETYPE_STEP, // gravity, special edge handling 192 MOVETYPE_FLY, 193 MOVETYPE_TOSS, // gravity 194 MOVETYPE_FLYMISSILE, // extra size to monsters 195 MOVETYPE_BOUNCE 196 } movetype_t; 197 198 199 200 typedef struct { 201 int base_count; 202 int max_count; 203 float normal_protection; 204 float energy_protection; 205 int armor; 206 } 207 gitem_armor_t; 208 209 210 // gitem_t->flags 211 #define IT_WEAPON 1 // use makes active weapon 212 #define IT_AMMO 2 213 #define IT_ARMOR 4 214 #define IT_STAY_COOP 8 215 #define IT_KEY 16 216 #define IT_POWERUP 32 217 // CTF 218 #define IT_TECH 64 219 // End CTF 220 221 // gitem_t->weapmodel for weapons indicates model index 222 #define WEAP_BLASTER 1 223 #define WEAP_SHOTGUN 2 224 #define WEAP_SUPERSHOTGUN 3 225 #define WEAP_MACHINEGUN 4 226 #define WEAP_CHAINGUN 5 227 #define WEAP_GRENADES 6 228 #define WEAP_GRENADELAUNCHER 7 229 #define WEAP_ROCKETLAUNCHER 8 230 #define WEAP_HYPERBLASTER 9 231 #define WEAP_RAILGUN 10 232 #define WEAP_BFG 11 233 // CTF 234 #define WEAP_GRAPPLE 12 235 // End CTF 236 237 typedef struct gitem_s { 238 char *classname; // spawning name 239 qboolean(*pickup)(struct edict_s *ent, struct edict_s *other); 240 void(*use)(struct edict_s *ent, struct gitem_s *item); 241 void(*drop)(struct edict_s *ent, struct gitem_s *item); 242 void(*weaponthink)(struct edict_s *ent); 243 char *pickup_sound; 244 char *world_model; 245 int world_model_flags; 246 char *view_model; 247 248 // client side info 249 char *icon; 250 char *pickup_name; // for printing on pickup 251 int count_width; // number of digits to display by icon 252 253 int quantity; // for ammo how much, for weapons how much is used per shot 254 char *ammo; // for weapons 255 int flags; // IT_* flags 256 257 int weapmodel; // weapon model index (for weapons) 258 259 void *info; 260 int tag; 261 262 char *precaches; // string of all models, sounds, and images this item will use 263 } 264 gitem_t; 265 266 267 268 // 269 // this structure is left intact through an entire game 270 // it should be initialized at dll load time, and read/written to 271 // the server.ssv file for savegames 272 // 273 typedef struct { 274 char helpmessage1[512]; 275 char helpmessage2[512]; 276 int helpchanged; // flash F1 icon if non 0, play sound 277 // and increment only if 1, 2, or 3 278 279 gclient_t *clients; // [maxclients] 280 281 // can't store spawnpoint in level, because 282 // it would get overwritten by the savegame restore 283 char spawnpoint[512]; // needed for coop respawns 284 285 // store latched cvars here that we want to get at often 286 int maxclients; 287 int maxentities; 288 289 // cross level triggers 290 int serverflags; 291 292 // items 293 int num_items; 294 295 qboolean autosaved; 296 } 297 game_locals_t; 298 299 300 // 301 // this structure is cleared as each map is entered 302 // it is read/written to the level.sav file for savegames 303 // 304 typedef struct { 305 int framenum; 306 float time; 307 308 char level_name[MAX_QPATH]; // the descriptive name (Outer Base, etc) 309 char mapname[MAX_QPATH]; // the server name (base1, etc) 310 char nextmap[MAX_QPATH]; // go here when fraglimit is hit 311 312 // intermission state 313 float intermissiontime; // time the intermission was started 314 char *changemap; 315 int exitintermission; 316 vec3_t intermission_origin; 317 vec3_t intermission_angle; 318 319 edict_t *sight_client; // changed once each frame for coop games 320 321 edict_t *sight_entity; 322 int sight_entity_framenum; 323 edict_t *sound_entity; 324 int sound_entity_framenum; 325 edict_t *sound2_entity; 326 int sound2_entity_framenum; 327 328 int pic_health; 329 330 int total_secrets; 331 int found_secrets; 332 333 int total_goals; 334 int found_goals; 335 336 int total_monsters; 337 int killed_monsters; 338 339 edict_t *current_entity; // entity running from G_RunFrame 340 int body_que; // dead bodies 341 342 int power_cubes; // ugly necessity for coop 343 } 344 level_locals_t; 345 346 347 // spawn_temp_t is only used to hold entity field values that 348 // can be set from the editor, but aren't actualy present 349 // in edict_t during gameplay 350 typedef struct { 351 // world vars 352 char *sky; 353 float skyrotate; 354 vec3_t skyaxis; 355 char *nextmap; 356 357 int lip; 358 int distance; 359 int height; 360 char *noise; 361 float pausetime; 362 char *item; 363 char *gravity; 364 365 float minyaw; 366 float maxyaw; 367 float minpitch; 368 float maxpitch; 369 } 370 spawn_temp_t; 371 372 373 typedef struct { 374 // fixed data 375 vec3_t start_origin; 376 vec3_t start_angles; 377 vec3_t end_origin; 378 vec3_t end_angles; 379 380 int sound_start; 381 int sound_middle; 382 int sound_end; 383 384 float accel; 385 float speed; 386 float decel; 387 float distance; 388 389 float wait; 390 391 // state data 392 int state; 393 vec3_t dir; 394 float current_speed; 395 float move_speed; 396 float next_speed; 397 float remaining_distance; 398 float decel_distance; 399 void(*endfunc)(edict_t *); 400 } 401 moveinfo_t; 402 403 404 typedef struct { 405 void(*aifunc)(edict_t *self, float dist); 406 float dist; 407 void(*thinkfunc)(edict_t *self); 408 } 409 mframe_t; 410 411 typedef struct { 412 int firstframe; 413 int lastframe; 414 mframe_t *frame; 415 void(*endfunc)(edict_t *self); 416 } 417 mmove_t; 418 419 typedef struct { 420 mmove_t *currentmove; 421 int aiflags; 422 int nextframe; 423 float scale; 424 425 void(*stand)(edict_t *self); 426 void(*idle)(edict_t *self); 427 void(*search)(edict_t *self); 428 void(*walk)(edict_t *self); 429 void(*run)(edict_t *self); 430 void(*dodge)(edict_t *self, edict_t *other, float eta); 431 void(*attack)(edict_t *self); 432 void(*melee)(edict_t *self); 433 void(*sight)(edict_t *self, edict_t *other); 434 qboolean(*checkattack)(edict_t *self); 435 436 float pausetime; 437 float attack_finished; 438 439 vec3_t saved_goal; 440 float search_time; 441 float trail_time; 442 vec3_t last_sighting; 443 int attack_state; 444 int lefty; 445 float idle_time; 446 int linkcount; 447 448 int power_armor_type; 449 int power_armor_power; 450 } 451 monsterinfo_t; 452 453 454 455 extern game_locals_t game; 456 extern level_locals_t level; 457 extern game_import_t gi; 458 extern game_export_t globals; 459 extern spawn_temp_t st; 460 461 extern int sm_meat_index; 462 extern int snd_fry; 463 464 extern int jacket_armor_index; 465 extern int combat_armor_index; 466 extern int body_armor_index; 467 468 469 // means of death 470 #define MOD_UNKNOWN 0 471 #define MOD_BLASTER 1 472 #define MOD_SHOTGUN 2 473 #define MOD_SSHOTGUN 3 474 #define MOD_MACHINEGUN 4 475 #define MOD_CHAINGUN 5 476 #define MOD_GRENADE 6 477 #define MOD_G_SPLASH 7 478 #define MOD_ROCKET 8 479 #define MOD_R_SPLASH 9 480 #define MOD_HYPERBLASTER 10 481 #define MOD_RAILGUN 11 482 #define MOD_BFG_LASER 12 483 #define MOD_BFG_BLAST 13 484 #define MOD_BFG_EFFECT 14 485 #define MOD_HANDGRENADE 15 486 #define MOD_HG_SPLASH 16 487 #define MOD_WATER 17 488 #define MOD_SLIME 18 489 #define MOD_LAVA 19 490 #define MOD_CRUSH 20 491 #define MOD_TELEFRAG 21 492 #define MOD_FALLING 22 493 #define MOD_SUICIDE 23 494 #define MOD_HELD_GRENADE 24 495 #define MOD_EXPLOSIVE 25 496 #define MOD_BARREL 26 497 #define MOD_BOMB 27 498 #define MOD_EXIT 28 499 #define MOD_SPLASH 29 500 #define MOD_TARGET_LASER 30 501 #define MOD_TRIGGER_HURT 31 502 #define MOD_HIT 32 503 #define MOD_TARGET_BLASTER 33 504 #define MOD_FRIENDLY_FIRE 0x8000000 505 // CTF 506 #define MOD_GRAPPLE 34 507 #define MOD_TEAM_SWITCH 35 508 // End CTF 509 510 extern int meansOfDeath; 511 512 513 extern edict_t *g_edicts; 514 515 #include <inttypes.h> 516 #define FOFS(x) (intptr_t)&(((edict_t *)0)->x) 517 #define STOFS(x) (intptr_t)&(((spawn_temp_t *)0)->x) 518 #define LLOFS(x) (intptr_t)&(((level_locals_t *)0)->x) 519 #define CLOFS(x) (intptr_t)&(((gclient_t *)0)->x) 520 521 #define random() ((rand () & 0x7fff) / ((float)0x7fff)) 522 #define crandom() (2.0 * (random() - 0.5)) 523 524 extern cvar_t *maxentities; 525 extern cvar_t *deathmatch; 526 extern cvar_t *coop; 527 extern cvar_t *dmflags; 528 extern cvar_t *skill; 529 extern cvar_t *fraglimit; 530 extern cvar_t *timelimit; 531 extern cvar_t *password; 532 extern cvar_t *spectator_password; 533 extern cvar_t *needpass; 534 extern cvar_t *g_select_empty; 535 extern cvar_t *dedicated; 536 537 extern cvar_t *filterban; 538 539 extern cvar_t *sv_gravity; 540 extern cvar_t *sv_maxvelocity; 541 542 extern cvar_t *gun_x, *gun_y, *gun_z; 543 extern cvar_t *sv_rollspeed; 544 extern cvar_t *sv_rollangle; 545 546 extern cvar_t *run_pitch; 547 extern cvar_t *run_roll; 548 extern cvar_t *bob_up; 549 extern cvar_t *bob_pitch; 550 extern cvar_t *bob_roll; 551 552 extern cvar_t *sv_cheats; 553 extern cvar_t *maxclients; 554 extern cvar_t *maxspectators; 555 556 extern cvar_t *flood_msgs; 557 extern cvar_t *flood_persecond; 558 extern cvar_t *flood_waitdelay; 559 560 extern cvar_t *sv_maplist; 561 // CTF 562 extern cvar_t *offhand; 563 extern cvar_t *runes; 564 extern cvar_t *zoidctf; 565 extern cvar_t *ctf; 566 extern cvar_t *ctfscore; 567 extern cvar_t *teamscorelimit; 568 extern cvar_t *weaponban; 569 extern cvar_t *colorquad; 570 extern cvar_t *antiidle; 571 extern cvar_t *gamecvar; 572 // End CTF 573 574 575 #define world (&g_edicts[0]) 576 577 // item spawnflags 578 #define ITEM_TRIGGER_SPAWN 0x00000001 579 #define ITEM_NO_TOUCH 0x00000002 580 // 6 bits reserved for editor flags 581 // 8 bits used as power cube id bits for coop games 582 #define DROPPED_ITEM 0x00010000 583 #define DROPPED_PLAYER_ITEM 0x00020000 584 #define ITEM_TARGETS_USED 0x00040000 585 586 // 587 // fields are needed for spawning from the entity string 588 // and saving / loading games 589 // 590 #define FFL_SPAWNTEMP 1 591 #define FFL_NOSPAWN 2 592 593 typedef enum { 594 F_INT, 595 F_FLOAT, 596 F_LSTRING, // string on disk, pointer in memory, TAG_LEVEL 597 F_GSTRING, // string on disk, pointer in memory, TAG_GAME 598 F_VECTOR, 599 F_ANGLEHACK, 600 F_EDICT, // index on disk, pointer in memory 601 F_ITEM, // index on disk, pointer in memory 602 F_CLIENT, // index on disk, pointer in memory 603 F_FUNCTION, 604 F_MMOVE, 605 F_IGNORE 606 } 607 fieldtype_t; 608 609 typedef struct { 610 char *name; 611 int ofs; 612 fieldtype_t type; 613 int flags; 614 } 615 field_t; 616 617 618 extern field_t fields[]; 619 extern gitem_t itemlist[]; 620 621 622 // 623 // g_cmds.c 624 // 625 void Cmd_Help_f(edict_t *ent); 626 void Cmd_Score_f(edict_t *ent); 627 628 // 629 // g_items.c 630 // 631 void PrecacheItem(gitem_t *it); 632 void InitItems(void); 633 void SetItemNames(void); 634 gitem_t *FindItem(char *pickup_name); 635 gitem_t *FindItemByClassname(char *classname); 636 #define ITEM_INDEX(x) ((x)-itemlist) 637 edict_t *Drop_Item(edict_t *ent, gitem_t *item); 638 void SetRespawn(edict_t *ent, float delay); 639 void ChangeWeapon(edict_t *ent); 640 void SpawnItem(edict_t *ent, gitem_t *item); 641 void Think_Weapon(edict_t *ent); 642 int ArmorIndex(edict_t *ent); 643 int PowerArmorType(edict_t *ent); 644 gitem_t *GetItemByIndex(int index); 645 qboolean Add_Ammo(edict_t *ent, gitem_t *item, int count); 646 void Touch_Item(edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf); 647 648 // 649 // g_utils.c 650 // 651 qboolean KillBox(edict_t *ent); 652 void G_ProjectSource(vec3_t point, vec3_t distance, vec3_t forward, vec3_t right, vec3_t result); 653 edict_t *G_Find(edict_t *from, int fieldofs, char *match); 654 edict_t *findradius(edict_t *from, vec3_t org, float rad); 655 edict_t *G_PickTarget(char *targetname); 656 void G_UseTargets(edict_t *ent, edict_t *activator); 657 void G_SetMovedir(vec3_t angles, vec3_t movedir); 658 659 void G_InitEdict(edict_t *e); 660 edict_t *G_Spawn(void); 661 void G_FreeEdict(edict_t *e); 662 663 void G_TouchTriggers(edict_t *ent); 664 void G_TouchSolids(edict_t *ent); 665 666 char *G_CopyString(char *in); 667 668 float *tv(float x, float y, float z); 669 char *vtos(vec3_t v); 670 671 float vectoyaw(vec3_t vec); 672 void vectoangles(vec3_t vec, vec3_t angles); 673 674 // 675 // g_combat.c 676 // 677 // CTF qboolean OnSameTeam (edict_t *ent1, edict_t *ent2); 678 qboolean CanDamage(edict_t *targ, edict_t *inflictor); 679 void T_Damage(edict_t *targ, edict_t *inflictor, edict_t *attacker, vec3_t dir, vec3_t point, vec3_t normal, int damage, int knockback, int dflags, int mod); 680 void T_RadiusDamage(edict_t *inflictor, edict_t *attacker, float damage, edict_t *ignore, float radius, int mod); 681 682 // damage flags 683 #define DAMAGE_RADIUS 0x00000001 // damage was indirect 684 #define DAMAGE_NO_ARMOR 0x00000002 // armour does not protect from this damage 685 #define DAMAGE_ENERGY 0x00000004 // damage is from an energy based weapon 686 #define DAMAGE_NO_KNOCKBACK 0x00000008 // do not affect velocity, just view angles 687 #define DAMAGE_BULLET 0x00000010 // damage is from a bullet (used for ricochets) 688 #define DAMAGE_NO_PROTECTION 0x00000020 // armor, shields, invulnerability, and godmode have no effect 689 690 #define DEFAULT_BULLET_HSPREAD 300 691 #define DEFAULT_BULLET_VSPREAD 500 692 #define DEFAULT_SHOTGUN_HSPREAD 1000 693 #define DEFAULT_SHOTGUN_VSPREAD 500 694 #define DEFAULT_DEATHMATCH_SHOTGUN_COUNT 12 695 #define DEFAULT_SHOTGUN_COUNT 12 696 #define DEFAULT_SSHOTGUN_COUNT 20 697 698 // 699 // g_monster.c 700 // 701 void monster_fire_bullet(edict_t *self, vec3_t start, vec3_t dir, int damage, int kick, int hspread, int vspread, int flashtype); 702 void monster_fire_shotgun(edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int hspread, int vspread, int count, int flashtype); 703 void monster_fire_blaster(edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int flashtype, int effect); 704 void monster_fire_grenade(edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, int flashtype); 705 void monster_fire_rocket(edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int flashtype); 706 void monster_fire_railgun(edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int flashtype); 707 void monster_fire_bfg(edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, int kick, float damage_radius, int flashtype); 708 void M_droptofloor(edict_t *ent); 709 void monster_think(edict_t *self); 710 void walkmonster_start(edict_t *self); 711 void swimmonster_start(edict_t *self); 712 void flymonster_start(edict_t *self); 713 void AttackFinished(edict_t *self, float time); 714 void monster_death_use(edict_t *self); 715 void M_CatagorizePosition(edict_t *ent); 716 qboolean M_CheckAttack(edict_t *self); 717 void M_FlyCheck(edict_t *self); 718 void M_CheckGround(edict_t *ent); 719 720 // 721 // g_misc.c 722 // 723 void ThrowHead(edict_t *self, char *gibname, int damage, int type); 724 void ThrowClientHead(edict_t *self, int damage); 725 void ThrowGib(edict_t *self, char *gibname, int damage, int type); 726 void BecomeExplosion1(edict_t *self); 727 728 // 729 // g_ai.c 730 // 731 void AI_SetSightClient(void); 732 733 void ai_stand(edict_t *self, float dist); 734 void ai_move(edict_t *self, float dist); 735 void ai_walk(edict_t *self, float dist); 736 void ai_turn(edict_t *self, float dist); 737 void ai_run(edict_t *self, float dist); 738 void ai_charge(edict_t *self, float dist); 739 int range(edict_t *self, edict_t *other); 740 741 void FoundTarget(edict_t *self); 742 qboolean infront(edict_t *self, edict_t *other); 743 qboolean visible(edict_t *self, edict_t *other); 744 qboolean FacingIdeal(edict_t *self); 745 746 // 747 // g_weapon.c 748 // 749 void ThrowDebris(edict_t *self, char *modelname, float speed, vec3_t origin); 750 qboolean fire_hit(edict_t *self, vec3_t aim, int damage, int kick); 751 void fire_bullet(edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int hspread, int vspread, int mod); 752 void fire_shotgun(edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int hspread, int vspread, int count, int mod); 753 void fire_blaster(edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, int effect, qboolean hyper); 754 void fire_grenade(edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, float timer, float damage_radius); 755 void fire_grenade2(edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, float timer, float damage_radius, qboolean held); 756 void fire_rocket(edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, float damage_radius, int radius_damage); 757 void fire_rail(edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick); 758 void fire_bfg(edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, float damage_radius); 759 760 // 761 // g_ptrail.c 762 // 763 void PlayerTrail_Init(void); 764 void PlayerTrail_Add(vec3_t spot); 765 void PlayerTrail_New(vec3_t spot); 766 edict_t *PlayerTrail_PickFirst(edict_t *self); 767 edict_t *PlayerTrail_PickNext(edict_t *self); 768 edict_t *PlayerTrail_LastSpot(void); 769 770 771 // 772 // g_client.c 773 // 774 void respawn(edict_t *ent); 775 void BeginIntermission(edict_t *targ); 776 void PutClientInServer(edict_t *ent); 777 void InitClientPersistant(gclient_t *client); 778 void InitClientResp(gclient_t *client); 779 void InitBodyQue(void); 780 void ClientBeginServerFrame(edict_t *ent); 781 782 // 783 // g_player.c 784 // 785 void player_pain(edict_t *self, edict_t *other, float kick, int damage); 786 void player_die(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point); 787 788 // 789 // g_svcmds.c 790 // 791 void ServerCommand(void); 792 qboolean SV_FilterPacket(char *from); 793 794 // 795 // p_view.c 796 // 797 void ClientEndServerFrame(edict_t *ent); 798 799 // 800 // p_hud.c 801 // 802 void MoveClientToIntermission(edict_t *client); 803 void G_SetStats(edict_t *ent); 804 void G_SetSpectatorStats(edict_t *ent); 805 void G_CheckChaseStats(edict_t *ent); 806 void ValidateSelectedItem(edict_t *ent); 807 void DeathmatchScoreboardMessage(edict_t *client, edict_t *killer); 808 809 // 810 // g_pweapon.c 811 // 812 void PlayerNoise(edict_t *who, vec3_t where, int type); 813 814 // 815 // m_move.c 816 // 817 qboolean M_CheckBottom(edict_t *ent); 818 qboolean M_walkmove(edict_t *ent, float yaw, float dist); 819 void M_MoveToGoal(edict_t *ent, float dist); 820 void M_ChangeYaw(edict_t *ent); 821 822 // 823 // g_phys.c 824 // 825 void G_RunEntity(edict_t *ent); 826 827 // 828 // g_main.c 829 // 830 void SaveClientData(void); 831 void FetchClientEntData(edict_t *ent); 832 833 // 834 // g_chase.c 835 // 836 void UpdateChaseCam(edict_t *ent); 837 void ChaseNext(edict_t *ent); 838 void ChasePrev(edict_t *ent); 839 void GetChaseTarget(edict_t *ent); 840 841 842 // client_t->anim_priority 843 #define ANIM_BASIC 0 // stand / run 844 #define ANIM_WAVE 1 845 #define ANIM_JUMP 2 846 #define ANIM_PAIN 3 847 #define ANIM_ATTACK 4 848 #define ANIM_DEATH 5 849 #define ANIM_REVERSE 6 850 851 852 // client data that stays across multiple level loads 853 typedef struct { 854 char userinfo[MAX_INFO_STRING]; 855 char netname[16]; 856 int hand; 857 858 qboolean connected; // a loadgame will leave valid entities that 859 // just don't have a connection yet 860 861 // values saved and restored from edicts when changing levels 862 int health; 863 int max_health; 864 int savedFlags; 865 866 int selected_item; 867 int inventory[MAX_ITEMS]; 868 869 // ammo capacities 870 int max_bullets; 871 int max_shells; 872 int max_rockets; 873 int max_grenades; 874 int max_cells; 875 int max_slugs; 876 877 gitem_t *weapon; 878 gitem_t *lastweapon; 879 880 int power_cubes; // used for tracking the cubes in coop games 881 int score; // for calculating total unit score in coop games 882 883 int game_helpchanged; 884 int helpchanged; 885 886 qboolean spectator; // client is a spectator 887 } 888 client_persistant_t; 889 890 // client data that stays across deathmatch respawns 891 typedef struct { 892 client_persistant_t coop_respawn; // what to set client->pers to on a respawn 893 int enterframe; // level.framenum the client entered the game 894 int score; // frags, etc 895 vec3_t cmd_angles; // angles sent over in the last command 896 897 qboolean spectator; // client is a spectator 898 // CTF 899 int ctf_team; 900 int ctf_state; 901 qboolean motdshown; 902 int id_state; 903 float lastmovetime; 904 int zbot_bang; 905 int zbot_at; 906 int zbot_hash; 907 int zbot_impulse; 908 float zbot_think; 909 int zbot_retry; 910 // End CTF 911 } 912 client_respawn_t; 913 914 // this structure is cleared on each PutClientInServer(), 915 // except for 'client->pers' 916 struct gclient_s { 917 // known to server 918 player_state_t ps; // communicated by server to clients 919 int ping; 920 921 // private to game 922 client_persistant_t pers; 923 client_respawn_t resp; 924 pmove_state_t old_pmove; // for detecting out-of-pmove changes 925 926 qboolean showscores; // set layout stat 927 qboolean showinventory; // set layout stat 928 qboolean showhelp; 929 qboolean showhelpicon; 930 931 int ammo_index; 932 933 int buttons; 934 int oldbuttons; 935 int latched_buttons; 936 937 qboolean weapon_thunk; 938 939 gitem_t *newweapon; 940 941 // sum up damage over an entire frame, so 942 // shotgun blasts give a single big kick 943 int damage_armor; // damage absorbed by armor 944 int damage_parmor; // damage absorbed by power armor 945 int damage_blood; // damage taken out of health 946 int damage_knockback; // impact damage 947 vec3_t damage_from; // origin for vector calculation 948 949 float killer_yaw; // when dead, look at killer 950 951 weaponstate_t weaponstate; 952 vec3_t kick_angles; // weapon kicks 953 vec3_t kick_origin; 954 float v_dmg_roll, v_dmg_pitch, v_dmg_time; // damage kicks 955 float fall_time, fall_value; // for view drop on fall 956 float damage_alpha; 957 float bonus_alpha; 958 vec3_t damage_blend; 959 vec3_t v_angle; // aiming direction 960 float bobtime; // so off-ground doesn't change it 961 vec3_t oldviewangles; 962 vec3_t oldvelocity; 963 964 float next_drown_time; 965 int old_waterlevel; 966 int breather_sound; 967 968 int machinegun_shots; // for weapon raising 969 970 // animation vars 971 int anim_end; 972 int anim_priority; 973 qboolean anim_duck; 974 qboolean anim_run; 975 976 // powerup timers 977 float quad_framenum; 978 float invincible_framenum; 979 float breather_framenum; 980 float enviro_framenum; 981 982 qboolean grenade_blew_up; 983 float grenade_time; 984 int silencer_shots; 985 int weapon_sound; 986 987 float pickup_msg_time; 988 989 float flood_locktill; // locked from talking 990 float flood_when[10]; // when messages were said 991 int flood_whenhead; // head pointer for when said 992 993 float respawn_time; // can respawn when time > this 994 995 edict_t *chase_target; // player we are chasing 996 qboolean update_chase; // need to update chase info? 997 // CTF 998 int hook_state; 999 edict_t *hook; 1000 edict_t *flag; 1001 qboolean showmotd; 1002 int damage_rune; // how much damage absorbed by resist 1003 float rune_time; // how long to flash resist color shell 1004 float regen_time; 1005 // End CTF 1006 }; 1007 1008 1009 struct edict_s { 1010 entity_state_t s; 1011 struct gclient_s *client; // NULL if not a player 1012 // the server expects the first part 1013 // of gclient_s to be a player_state_t 1014 // but the rest of it is opaque 1015 1016 qboolean inuse; 1017 int linkcount; 1018 1019 // FIXME: move these fields to a server private sv_entity_t 1020 link_t area; // linked to a division node or leaf 1021 1022 int num_clusters; // if -1, use headnode instead 1023 int clusternums[MAX_ENT_CLUSTERS]; 1024 int headnode; // unused if num_clusters != -1 1025 int areanum, areanum2; 1026 1027 1028 int svflags; 1029 vec3_t mins, maxs; 1030 vec3_t absmin, absmax, size; 1031 solid_t solid; 1032 int clipmask; 1033 edict_t *owner; 1034 1035 1036 // DO NOT MODIFY ANYTHING ABOVE THIS, THE SERVER 1037 // EXPECTS THE FIELDS IN THAT ORDER! 1038 1039 int movetype; 1040 int flags; 1041 1042 char *model; 1043 float freetime; // sv.time when the object was freed 1044 1045 // 1046 // only used locally in game, not by server 1047 // 1048 char *message; 1049 char *classname; 1050 int spawnflags; 1051 1052 float timestamp; 1053 1054 float angle; // set in qe3, -1 = up, -2 = down 1055 char *target; 1056 char *targetname; 1057 char *killtarget; 1058 char *team; 1059 char *pathtarget; 1060 char *deathtarget; 1061 char *combattarget; 1062 edict_t *target_ent; 1063 1064 float speed, accel, decel; 1065 vec3_t movedir; 1066 vec3_t pos1, pos2; 1067 1068 vec3_t velocity; 1069 vec3_t avelocity; 1070 int mass; 1071 float air_finished; 1072 float gravity; // per entity gravity multiplier (1.0 is normal) 1073 // use for lowgrav artifact, flares 1074 1075 edict_t *goalentity; 1076 edict_t *movetarget; 1077 float yaw_speed; 1078 float ideal_yaw; 1079 1080 float nextthink; 1081 void(*prethink)(edict_t *ent); 1082 void(*think)(edict_t *self); 1083 void(*blocked)(edict_t *self, edict_t *other); //move to moveinfo? 1084 void(*touch)(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf); 1085 void(*use)(edict_t *self, edict_t *other, edict_t *activator); 1086 void(*pain)(edict_t *self, edict_t *other, float kick, int damage); 1087 void(*die)(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point); 1088 1089 float touch_debounce_time; // are all these legit? do we need more/less of them? 1090 float pain_debounce_time; 1091 float damage_debounce_time; 1092 float fly_sound_debounce_time; //move to clientinfo 1093 float last_move_time; 1094 1095 int health; 1096 int max_health; 1097 int gib_health; 1098 int deadflag; 1099 qboolean show_hostile; 1100 1101 float powerarmor_time; 1102 1103 char *map; // target_changelevel 1104 1105 int viewheight; // height above origin where eyesight is determined 1106 int takedamage; 1107 int dmg; 1108 int radius_dmg; 1109 float dmg_radius; 1110 int sounds; //make this a spawntemp var? 1111 int count; 1112 1113 edict_t *chain; 1114 edict_t *enemy; 1115 edict_t *oldenemy; 1116 edict_t *activator; 1117 edict_t *groundentity; 1118 int groundentity_linkcount; 1119 edict_t *teamchain; 1120 edict_t *teammaster; 1121 1122 edict_t *mynoise; // can go in client only 1123 edict_t *mynoise2; 1124 1125 int noise_index; 1126 int noise_index2; 1127 float volume; 1128 float attenuation; 1129 1130 // timing variables 1131 float wait; 1132 float delay; // before firing targets 1133 float random; 1134 1135 float teleport_time; 1136 1137 int watertype; 1138 int waterlevel; 1139 1140 vec3_t move_origin; 1141 vec3_t move_angles; 1142 1143 // move this to clientinfo? 1144 int light_level; 1145 1146 int style; // also used as areaportal number 1147 1148 gitem_t *item; // for bonus items 1149 1150 // common data blocks 1151 moveinfo_t moveinfo; 1152 monsterinfo_t monsterinfo; 1153 // CTF 1154 // vec3_t baseorigin; 1155 // int flagstat; 1156 edict_t *laser; 1157 // int stuff; // should be in gclient_t, but that gets cleared 1158 // before I get to read it back again ... 1159 // qboolean noblock; // if true, cannot block anything (for flags) 1160 // End CTF 1161 }; 1162 1163