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