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