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