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 #define IT_HEALTH 128 //JABot 227 #define IT_FLAG 256 //JABot 228 229 // gitem_t->weapmodel for weapons indicates model index 230 #define WEAP_BLASTER 1 231 #define WEAP_SHOTGUN 2 232 #define WEAP_SUPERSHOTGUN 3 233 #define WEAP_MACHINEGUN 4 234 #define WEAP_CHAINGUN 5 235 #define WEAP_GRENADES 6 236 #define WEAP_GRENADELAUNCHER 7 237 #define WEAP_ROCKETLAUNCHER 8 238 #define WEAP_HYPERBLASTER 9 239 #define WEAP_RAILGUN 10 240 #define WEAP_BFG 11 241 #define WEAP_GRAPPLE 12 242 243 //JABot[start] 244 #define WEAP_NONE 0 245 #define WEAP_TOTAL 13 246 //JABot[end] 247 248 typedef struct gitem_s 249 { 250 char *classname; // spawning name 251 qboolean (*pickup)(struct edict_s *ent, struct edict_s *other); 252 void (*use)(struct edict_s *ent, struct gitem_s *item); 253 void (*drop)(struct edict_s *ent, struct gitem_s *item); 254 void (*weaponthink)(struct edict_s *ent); 255 char *pickup_sound; 256 char *world_model; 257 int world_model_flags; 258 char *view_model; 259 260 // client side info 261 char *icon; 262 char *pickup_name; // for printing on pickup 263 int count_width; // number of digits to display by icon 264 265 int quantity; // for ammo how much, for weapons how much is used per shot 266 char *ammo; // for weapons 267 int flags; // IT_* flags 268 269 int weapmodel; // weapon model index (for weapons) 270 271 void *info; 272 int tag; 273 274 char *precaches; // string of all models, sounds, and images this item will use 275 } gitem_t; 276 277 278 279 // 280 // this structure is left intact through an entire game 281 // it should be initialized at dll load time, and read/written to 282 // the server.ssv file for savegames 283 // 284 typedef struct 285 { 286 char helpmessage1[512]; 287 char helpmessage2[512]; 288 int helpchanged; // flash F1 icon if non 0, play sound 289 // and increment only if 1, 2, or 3 290 291 gclient_t *clients; // [maxclients] 292 293 // can't store spawnpoint in level, because 294 // it would get overwritten by the savegame restore 295 char spawnpoint[512]; // needed for coop respawns 296 297 // store latched cvars here that we want to get at often 298 int maxclients; 299 int maxentities; 300 301 // cross level triggers 302 int serverflags; 303 304 // items 305 int num_items; 306 307 qboolean autosaved; 308 } game_locals_t; 309 310 311 // 312 // this structure is cleared as each map is entered 313 // it is read/written to the level.sav file for savegames 314 // 315 typedef struct 316 { 317 int framenum; 318 float time; 319 320 char level_name[MAX_QPATH]; // the descriptive name (Outer Base, etc) 321 char mapname[MAX_QPATH]; // the server name (base1, etc) 322 char nextmap[MAX_QPATH]; // go here when fraglimit is hit 323 char forcemap[MAX_QPATH]; // go here 324 325 // intermission state 326 float intermissiontime; // time the intermission was started 327 char *changemap; 328 int exitintermission; 329 vec3_t intermission_origin; 330 vec3_t intermission_angle; 331 332 edict_t *sight_client; // changed once each frame for coop games 333 334 edict_t *sight_entity; 335 int sight_entity_framenum; 336 edict_t *sound_entity; 337 int sound_entity_framenum; 338 edict_t *sound2_entity; 339 int sound2_entity_framenum; 340 341 int pic_health; 342 343 int total_secrets; 344 int found_secrets; 345 346 int total_goals; 347 int found_goals; 348 349 int total_monsters; 350 int killed_monsters; 351 352 edict_t *current_entity; // entity running from G_RunFrame 353 int body_que; // dead bodies 354 355 int power_cubes; // ugly necessity for coop 356 } level_locals_t; 357 358 359 // spawn_temp_t is only used to hold entity field values that 360 // can be set from the editor, but aren't actualy present 361 // in edict_t during gameplay 362 typedef struct 363 { 364 // world vars 365 char *sky; 366 float skyrotate; 367 vec3_t skyaxis; 368 char *nextmap; 369 370 int lip; 371 int distance; 372 int height; 373 char *noise; 374 float pausetime; 375 char *item; 376 char *gravity; 377 378 float minyaw; 379 float maxyaw; 380 float minpitch; 381 float maxpitch; 382 383 int weight;//JABot 384 } spawn_temp_t; 385 386 387 typedef struct 388 { 389 // fixed data 390 vec3_t start_origin; 391 vec3_t start_angles; 392 vec3_t end_origin; 393 vec3_t end_angles; 394 395 int sound_start; 396 int sound_middle; 397 int sound_end; 398 399 float accel; 400 float speed; 401 float decel; 402 float distance; 403 404 float wait; 405 406 // state data 407 int state; 408 vec3_t dir; 409 float current_speed; 410 float move_speed; 411 float next_speed; 412 float remaining_distance; 413 float decel_distance; 414 void (*endfunc)(edict_t *); 415 } moveinfo_t; 416 417 418 typedef struct 419 { 420 void (*aifunc)(edict_t *self, float dist); 421 float dist; 422 void (*thinkfunc)(edict_t *self); 423 } mframe_t; 424 425 typedef struct 426 { 427 int firstframe; 428 int lastframe; 429 mframe_t *frame; 430 void (*endfunc)(edict_t *self); 431 } mmove_t; 432 433 typedef struct 434 { 435 mmove_t *currentmove; 436 int aiflags; 437 int nextframe; 438 float scale; 439 440 void (*stand)(edict_t *self); 441 void (*idle)(edict_t *self); 442 void (*search)(edict_t *self); 443 void (*walk)(edict_t *self); 444 void (*run)(edict_t *self); 445 void (*dodge)(edict_t *self, edict_t *other, float eta); 446 void (*attack)(edict_t *self); 447 void (*melee)(edict_t *self); 448 void (*sight)(edict_t *self, edict_t *other); 449 qboolean (*checkattack)(edict_t *self); 450 451 float pausetime; 452 float attack_finished; 453 454 vec3_t saved_goal; 455 float search_time; 456 float trail_time; 457 vec3_t last_sighting; 458 int attack_state; 459 int lefty; 460 float idle_time; 461 int linkcount; 462 463 int power_armor_type; 464 int power_armor_power; 465 } monsterinfo_t; 466 467 468 469 extern game_locals_t game; 470 extern level_locals_t level; 471 extern game_import_t gi; 472 extern game_export_t globals; 473 extern spawn_temp_t st; 474 475 extern int sm_meat_index; 476 extern int snd_fry; 477 478 extern int jacket_armor_index; 479 extern int combat_armor_index; 480 extern int body_armor_index; 481 482 483 // means of death 484 #define MOD_UNKNOWN 0 485 #define MOD_BLASTER 1 486 #define MOD_SHOTGUN 2 487 #define MOD_SSHOTGUN 3 488 #define MOD_MACHINEGUN 4 489 #define MOD_CHAINGUN 5 490 #define MOD_GRENADE 6 491 #define MOD_G_SPLASH 7 492 #define MOD_ROCKET 8 493 #define MOD_R_SPLASH 9 494 #define MOD_HYPERBLASTER 10 495 #define MOD_RAILGUN 11 496 #define MOD_BFG_LASER 12 497 #define MOD_BFG_BLAST 13 498 #define MOD_BFG_EFFECT 14 499 #define MOD_HANDGRENADE 15 500 #define MOD_HG_SPLASH 16 501 #define MOD_WATER 17 502 #define MOD_SLIME 18 503 #define MOD_LAVA 19 504 #define MOD_CRUSH 20 505 #define MOD_TELEFRAG 21 506 #define MOD_FALLING 22 507 #define MOD_SUICIDE 23 508 #define MOD_HELD_GRENADE 24 509 #define MOD_EXPLOSIVE 25 510 #define MOD_BARREL 26 511 #define MOD_BOMB 27 512 #define MOD_EXIT 28 513 #define MOD_SPLASH 29 514 #define MOD_TARGET_LASER 30 515 #define MOD_TRIGGER_HURT 31 516 #define MOD_HIT 32 517 #define MOD_TARGET_BLASTER 33 518 #define MOD_GRAPPLE 34 519 #define MOD_FRIENDLY_FIRE 0x8000000 520 521 extern int meansOfDeath; 522 523 524 extern edict_t *g_edicts; 525 526 #define FOFS(x) (int)&(((edict_t *)0)->x) 527 #define STOFS(x) (int)&(((spawn_temp_t *)0)->x) 528 #define LLOFS(x) (int)&(((level_locals_t *)0)->x) 529 #define CLOFS(x) (int)&(((gclient_t *)0)->x) 530 531 #define random() ((rand () & 0x7fff) / ((float)0x7fff)) 532 #define crandom() (2.0 * (random() - 0.5)) 533 534 extern cvar_t *maxentities; 535 extern cvar_t *deathmatch; 536 extern cvar_t *coop; 537 extern cvar_t *dmflags; 538 extern cvar_t *skill; 539 extern cvar_t *fraglimit; 540 extern cvar_t *timelimit; 541 //ZOID 542 extern cvar_t *capturelimit; 543 extern cvar_t *instantweap; 544 //ZOID 545 extern cvar_t *password; 546 extern cvar_t *g_select_empty; 547 extern cvar_t *dedicated; 548 549 extern cvar_t *filterban; 550 551 extern cvar_t *sv_gravity; 552 extern cvar_t *sv_maxvelocity; 553 554 extern cvar_t *gun_x, *gun_y, *gun_z; 555 extern cvar_t *sv_rollspeed; 556 extern cvar_t *sv_rollangle; 557 558 extern cvar_t *run_pitch; 559 extern cvar_t *run_roll; 560 extern cvar_t *bob_up; 561 extern cvar_t *bob_pitch; 562 extern cvar_t *bob_roll; 563 564 extern cvar_t *sv_cheats; 565 extern cvar_t *maxclients; 566 567 extern cvar_t *flood_msgs; 568 extern cvar_t *flood_persecond; 569 extern cvar_t *flood_waitdelay; 570 571 extern cvar_t *sv_maplist; 572 573 extern cvar_t *botchat; 574 575 //ZOID 576 extern qboolean is_quad; 577 //ZOID 578 579 #define world (&g_edicts[0]) 580 581 // item spawnflags 582 #define ITEM_TRIGGER_SPAWN 0x00000001 583 #define ITEM_NO_TOUCH 0x00000002 584 // 6 bits reserved for editor flags 585 // 8 bits used as power cube id bits for coop games 586 #define DROPPED_ITEM 0x00010000 587 #define DROPPED_PLAYER_ITEM 0x00020000 588 #define ITEM_TARGETS_USED 0x00040000 589 590 // 591 // fields are needed for spawning from the entity string 592 // and saving / loading games 593 // 594 #define FFL_SPAWNTEMP 1 595 596 typedef enum { 597 F_INT, 598 F_FLOAT, 599 F_LSTRING, // string on disk, pointer in memory, TAG_LEVEL 600 F_GSTRING, // string on disk, pointer in memory, TAG_GAME 601 F_VECTOR, 602 F_ANGLEHACK, 603 F_EDICT, // index on disk, pointer in memory 604 F_ITEM, // index on disk, pointer in memory 605 F_CLIENT, // index on disk, pointer in memory 606 F_IGNORE 607 } fieldtype_t; 608 609 typedef struct 610 { 611 char *name; 612 int ofs; 613 fieldtype_t type; 614 int flags; 615 } field_t; 616 617 618 extern field_t fields[]; 619 extern gitem_t itemlist[]; 620 621 622 // 623 // g_cmds.c 624 // 625 qboolean CheckFlood(edict_t *ent); 626 void Cmd_Help_f (edict_t *ent); 627 void Cmd_Score_f (edict_t *ent); 628 629 // 630 // g_items.c 631 // 632 void PrecacheItem (gitem_t *it); 633 void InitItems (void); 634 void SetItemNames (void); 635 gitem_t *FindItem (char *pickup_name); 636 gitem_t *FindItemByClassname (char *classname); 637 #define ITEM_INDEX(x) ((x)-itemlist) 638 edict_t *Drop_Item (edict_t *ent, gitem_t *item); 639 void SetRespawn (edict_t *ent, float delay); 640 void ChangeWeapon (edict_t *ent); 641 void SpawnItem (edict_t *ent, gitem_t *item); 642 void Think_Weapon (edict_t *ent); 643 int ArmorIndex (edict_t *ent); 644 int PowerArmorType (edict_t *ent); 645 gitem_t *GetItemByIndex (int index); 646 qboolean Add_Ammo (edict_t *ent, gitem_t *item, int count); 647 void Touch_Item (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf); 648 649 // 650 // g_utils.c 651 // 652 qboolean KillBox (edict_t *ent); 653 void G_ProjectSource (vec3_t point, vec3_t distance, vec3_t forward, vec3_t right, vec3_t result); 654 edict_t *G_Find (edict_t *from, int fieldofs, char *match); 655 edict_t *findradius (edict_t *from, vec3_t org, float rad); 656 edict_t *G_PickTarget (char *targetname); 657 void G_UseTargets (edict_t *ent, edict_t *activator); 658 void G_SetMovedir (vec3_t angles, vec3_t movedir); 659 660 void G_InitEdict (edict_t *e); 661 edict_t *G_Spawn (void); 662 void G_FreeEdict (edict_t *e); 663 664 void G_TouchTriggers (edict_t *ent); 665 void G_TouchSolids (edict_t *ent); 666 667 char *G_CopyString (char *in); 668 669 float *tv (float x, float y, float z); 670 char *vtos (vec3_t v); 671 672 float vectoyaw (vec3_t vec); 673 void vectoangles (vec3_t vec, vec3_t angles); 674 675 // 676 // g_combat.c 677 // 678 qboolean OnSameTeam (edict_t *ent1, edict_t *ent2); 679 qboolean CanDamage (edict_t *targ, edict_t *inflictor); 680 qboolean CheckTeamDamage (edict_t *targ, edict_t *attacker); 681 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); 682 void T_RadiusDamage (edict_t *inflictor, edict_t *attacker, float damage, edict_t *ignore, float radius, int mod); 683 684 // damage flags 685 #define DAMAGE_RADIUS 0x00000001 // damage was indirect 686 #define DAMAGE_NO_ARMOR 0x00000002 // armour does not protect from this damage 687 #define DAMAGE_ENERGY 0x00000004 // damage is from an energy based weapon 688 #define DAMAGE_NO_KNOCKBACK 0x00000008 // do not affect velocity, just view angles 689 #define DAMAGE_BULLET 0x00000010 // damage is from a bullet (used for ricochets) 690 #define DAMAGE_NO_PROTECTION 0x00000020 // armor, shields, invulnerability, and godmode have no effect 691 692 #define DEFAULT_BULLET_HSPREAD 300 693 #define DEFAULT_BULLET_VSPREAD 500 694 #define DEFAULT_SHOTGUN_HSPREAD 1000 695 #define DEFAULT_SHOTGUN_VSPREAD 500 696 #define DEFAULT_DEATHMATCH_SHOTGUN_COUNT 12 697 #define DEFAULT_SHOTGUN_COUNT 12 698 #define DEFAULT_SSHOTGUN_COUNT 20 699 700 // 701 // g_monster.c 702 // 703 void monster_fire_bullet (edict_t *self, vec3_t start, vec3_t dir, int damage, int kick, int hspread, int vspread, int flashtype); 704 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); 705 void monster_fire_blaster (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int flashtype, int effect); 706 void monster_fire_grenade (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, int flashtype); 707 void monster_fire_rocket (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int flashtype); 708 void monster_fire_railgun (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int flashtype); 709 void monster_fire_bfg (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, int kick, float damage_radius, int flashtype); 710 void M_droptofloor (edict_t *ent); 711 void monster_think (edict_t *self); 712 void walkmonster_start (edict_t *self); 713 void swimmonster_start (edict_t *self); 714 void flymonster_start (edict_t *self); 715 void AttackFinished (edict_t *self, float time); 716 void monster_death_use (edict_t *self); 717 void M_CatagorizePosition (edict_t *ent); 718 qboolean M_CheckAttack (edict_t *self); 719 void M_FlyCheck (edict_t *self); 720 void M_CheckGround (edict_t *ent); 721 722 // 723 // g_misc.c 724 // 725 void ThrowHead (edict_t *self, char *gibname, int damage, int type); 726 void ThrowClientHead (edict_t *self, int damage); 727 void ThrowGib (edict_t *self, char *gibname, int damage, int type); 728 void BecomeExplosion1(edict_t *self); 729 730 // 731 // g_ai.c 732 // 733 void AI_SetSightClient (void); 734 735 void ai_stand (edict_t *self, float dist); 736 void ai_move (edict_t *self, float dist); 737 void ai_walk (edict_t *self, float dist); 738 void ai_turn (edict_t *self, float dist); 739 void ai_run (edict_t *self, float dist); 740 void ai_charge (edict_t *self, float dist); 741 int range (edict_t *self, edict_t *other); 742 743 void FoundTarget (edict_t *self); 744 qboolean infront (edict_t *self, edict_t *other); 745 qboolean visible (edict_t *self, edict_t *other); 746 qboolean FacingIdeal(edict_t *self); 747 748 // 749 // g_weapon.c 750 // 751 void ThrowDebris (edict_t *self, char *modelname, float speed, vec3_t origin); 752 qboolean fire_hit (edict_t *self, vec3_t aim, int damage, int kick); 753 void fire_bullet (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int hspread, int vspread, int mod); 754 void fire_shotgun (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int hspread, int vspread, int count, int mod); 755 void fire_blaster (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, int effect, qboolean hyper); 756 void fire_grenade (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, float timer, float damage_radius); 757 void fire_grenade2 (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, float timer, float damage_radius, qboolean held); 758 void fire_rocket (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, float damage_radius, int radius_damage); 759 void fire_rail (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick); 760 void fire_bfg (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, float damage_radius); 761 762 // 763 // g_ptrail.c 764 // 765 void PlayerTrail_Init (void); 766 void PlayerTrail_Add (vec3_t spot); 767 void PlayerTrail_New (vec3_t spot); 768 edict_t *PlayerTrail_PickFirst (edict_t *self); 769 edict_t *PlayerTrail_PickNext (edict_t *self); 770 edict_t *PlayerTrail_LastSpot (void); 771 772 773 // 774 // g_client.c 775 // 776 void respawn (edict_t *ent); 777 void BeginIntermission (edict_t *targ); 778 void PutClientInServer (edict_t *ent); 779 void InitClientPersistant (gclient_t *client); 780 void InitClientResp (gclient_t *client); 781 void InitBodyQue (void); 782 void ClientBeginServerFrame (edict_t *ent); 783 void ClientUserinfoChanged (edict_t *ent, char *userinfo); 784 785 // 786 // g_player.c 787 // 788 void player_pain (edict_t *self, edict_t *other, float kick, int damage); 789 void player_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point); 790 791 // 792 // g_svcmds.c 793 // 794 void ServerCommand (void); 795 796 // 797 // p_view.c 798 // 799 void ClientEndServerFrame (edict_t *ent); 800 801 // 802 // p_hud.c 803 // 804 void MoveClientToIntermission (edict_t *client); 805 void G_SetStats (edict_t *ent); 806 void ValidateSelectedItem (edict_t *ent); 807 void DeathmatchScoreboardMessage (edict_t *client, edict_t *killer); 808 809 // 810 // g_pweapon.c 811 // 812 void PlayerNoise(edict_t *who, vec3_t where, int type); 813 void P_ProjectSource (gclient_t *client, vec3_t point, vec3_t distance, vec3_t forward, vec3_t right, vec3_t result); 814 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)); 815 816 // 817 // m_move.c 818 // 819 qboolean M_CheckBottom (edict_t *ent); 820 qboolean M_walkmove (edict_t *ent, float yaw, float dist); 821 void M_MoveToGoal (edict_t *ent, float dist); 822 void M_ChangeYaw (edict_t *ent); 823 824 // 825 // g_phys.c 826 // 827 void G_RunEntity (edict_t *ent); 828 829 // 830 // g_main.c 831 // 832 void SaveClientData (void); 833 void FetchClientEntData (edict_t *ent); 834 void EndDMLevel (void); 835 836 // 837 // g_svcmds.c 838 // 839 qboolean SV_FilterPacket (char *from); 840 841 //============================================================================ 842 843 #include "ai/ai.h"//JABot 844 845 // client_t->anim_priority 846 #define ANIM_BASIC 0 // stand / run 847 #define ANIM_WAVE 1 848 #define ANIM_JUMP 2 849 #define ANIM_PAIN 3 850 #define ANIM_ATTACK 4 851 #define ANIM_DEATH 5 852 #define ANIM_REVERSE 6 853 854 855 // client data that stays across multiple level loads 856 typedef struct 857 { 858 char userinfo[MAX_INFO_STRING]; 859 char netname[16]; 860 int hand; 861 862 qboolean connected; // a loadgame will leave valid entities that 863 // just don't have a connection yet 864 865 // values saved and restored from edicts when changing levels 866 int health; 867 int max_health; 868 int savedFlags; 869 870 int selected_item; 871 int inventory[MAX_ITEMS]; 872 873 // ammo capacities 874 int max_bullets; 875 int max_shells; 876 int max_rockets; 877 int max_grenades; 878 int max_cells; 879 int max_slugs; 880 881 gitem_t *weapon; 882 gitem_t *lastweapon; 883 884 int power_cubes; // used for tracking the cubes in coop games 885 int score; // for calculating total unit score in coop games 886 } client_persistant_t; 887 888 // client data that stays across deathmatch respawns 889 typedef struct 890 { 891 client_persistant_t coop_respawn; // what to set client->pers to on a respawn 892 int enterframe; // level.framenum the client entered the game 893 int score; // frags, etc 894 //ZOID 895 int ctf_team; // CTF team 896 int ctf_state; 897 float ctf_lasthurtcarrier; 898 float ctf_lastreturnedflag; 899 float ctf_flagsince; 900 float ctf_lastfraggedcarrier; 901 qboolean id_state; 902 float lastidtime; 903 qboolean voted; // for elections 904 qboolean ready; 905 qboolean admin; 906 struct ghost_s *ghost; // for ghost codes 907 //ZOID 908 vec3_t cmd_angles; // angles sent over in the last command 909 int game_helpchanged; 910 int helpchanged; 911 } client_respawn_t; 912 913 // this structure is cleared on each PutClientInServer(), 914 // except for 'client->pers' 915 struct gclient_s 916 { 917 // known to server 918 player_state_t ps; // communicated by server to clients 919 int ping; 920 921 // private to game 922 client_persistant_t pers; 923 client_respawn_t resp; 924 pmove_state_t old_pmove; // for detecting out-of-pmove changes 925 926 qboolean showscores; // set layout stat 927 //ZOID 928 qboolean inmenu; // in menu 929 pmenuhnd_t *menu; // current menu 930 //ZOID 931 qboolean showinventory; // set layout stat 932 qboolean showhelp; 933 qboolean showhelpicon; 934 935 int ammo_index; 936 937 int buttons; 938 int oldbuttons; 939 int latched_buttons; 940 941 qboolean weapon_thunk; 942 943 gitem_t *newweapon; 944 945 // sum up damage over an entire frame, so 946 // shotgun blasts give a single big kick 947 int damage_armor; // damage absorbed by armor 948 int damage_parmor; // damage absorbed by power armor 949 int damage_blood; // damage taken out of health 950 int damage_knockback; // impact damage 951 vec3_t damage_from; // origin for vector calculation 952 953 float killer_yaw; // when dead, look at killer 954 955 weaponstate_t weaponstate; 956 vec3_t kick_angles; // weapon kicks 957 vec3_t kick_origin; 958 float v_dmg_roll, v_dmg_pitch, v_dmg_time; // damage kicks 959 float fall_time, fall_value; // for view drop on fall 960 float damage_alpha; 961 float bonus_alpha; 962 vec3_t damage_blend; 963 vec3_t v_angle; // aiming direction 964 float bobtime; // so off-ground doesn't change it 965 vec3_t oldviewangles; 966 vec3_t oldvelocity; 967 968 float next_drown_time; 969 int old_waterlevel; 970 int breather_sound; 971 972 int machinegun_shots; // for weapon raising 973 974 // animation vars 975 int anim_end; 976 int anim_priority; 977 qboolean anim_duck; 978 qboolean anim_run; 979 980 // powerup timers 981 float quad_framenum; 982 float invincible_framenum; 983 float breather_framenum; 984 float enviro_framenum; 985 986 qboolean grenade_blew_up; 987 float grenade_time; 988 int silencer_shots; 989 int weapon_sound; 990 991 float pickup_msg_time; 992 993 float flood_locktill; // locked from talking 994 float flood_when[10]; // when messages were said 995 int flood_whenhead; // head pointer for when said 996 997 float respawn_time; // can respawn when time > this 998 999 //ZOID 1000 void *ctf_grapple; // entity of grapple 1001 int ctf_grapplestate; // true if pulling 1002 float ctf_grapplereleasetime; // time of grapple release 1003 float ctf_regentime; // regen tech 1004 float ctf_techsndtime; 1005 float ctf_lasttechmsg; 1006 edict_t *chase_target; 1007 qboolean update_chase; 1008 float menutime; // time to update menu 1009 qboolean menudirty; 1010 //ZOID 1011 }; 1012 1013 1014 struct edict_s 1015 { 1016 entity_state_t s; 1017 struct gclient_s *client; // NULL if not a player 1018 // the server expects the first part 1019 // of gclient_s to be a player_state_t 1020 // but the rest of it is opaque 1021 1022 qboolean inuse; 1023 int linkcount; 1024 1025 // FIXME: move these fields to a server private sv_entity_t 1026 link_t area; // linked to a division node or leaf 1027 1028 int num_clusters; // if -1, use headnode instead 1029 int clusternums[MAX_ENT_CLUSTERS]; 1030 int headnode; // unused if num_clusters != -1 1031 int areanum, areanum2; 1032 1033 //================================ 1034 1035 int svflags; 1036 vec3_t mins, maxs; 1037 vec3_t absmin, absmax, size; 1038 solid_t solid; 1039 int clipmask; 1040 edict_t *owner; 1041 1042 1043 // DO NOT MODIFY ANYTHING ABOVE THIS, THE SERVER 1044 // EXPECTS THE FIELDS IN THAT ORDER! 1045 1046 //================================ 1047 int movetype; 1048 int flags; 1049 1050 char *model; 1051 float freetime; // sv.time when the object was freed 1052 1053 // 1054 // only used locally in game, not by server 1055 // 1056 char *message; 1057 char *classname; 1058 int spawnflags; 1059 1060 float timestamp; 1061 1062 float angle; // set in qe3, -1 = up, -2 = down 1063 char *target; 1064 char *targetname; 1065 char *killtarget; 1066 char *team; 1067 char *pathtarget; 1068 char *deathtarget; 1069 char *combattarget; 1070 edict_t *target_ent; 1071 1072 float speed, accel, decel; 1073 vec3_t movedir; 1074 vec3_t pos1, pos2; 1075 1076 vec3_t velocity; 1077 vec3_t avelocity; 1078 int mass; 1079 float air_finished; 1080 float gravity; // per entity gravity multiplier (1.0 is normal) 1081 // use for lowgrav artifact, flares 1082 1083 edict_t *goalentity; 1084 edict_t *movetarget; 1085 float yaw_speed; 1086 float ideal_yaw; 1087 1088 float nextthink; 1089 void (*prethink) (edict_t *ent); 1090 void (*think)(edict_t *self); 1091 void (*blocked)(edict_t *self, edict_t *other); //move to moveinfo? 1092 void (*touch)(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf); 1093 void (*use)(edict_t *self, edict_t *other, edict_t *activator); 1094 void (*pain)(edict_t *self, edict_t *other, float kick, int damage); 1095 void (*die)(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point); 1096 1097 float touch_debounce_time; // are all these legit? do we need more/less of them? 1098 float pain_debounce_time; 1099 float damage_debounce_time; 1100 float fly_sound_debounce_time; //move to clientinfo 1101 float last_move_time; 1102 1103 int health; 1104 int max_health; 1105 int gib_health; 1106 int deadflag; 1107 qboolean show_hostile; 1108 1109 float powerarmor_time; 1110 1111 char *map; // target_changelevel 1112 1113 int viewheight; // height above origin where eyesight is determined 1114 int takedamage; 1115 int dmg; 1116 int radius_dmg; 1117 float dmg_radius; 1118 int sounds; //make this a spawntemp var? 1119 int count; 1120 1121 edict_t *chain; 1122 edict_t *enemy; 1123 edict_t *oldenemy; 1124 edict_t *activator; 1125 edict_t *groundentity; 1126 int groundentity_linkcount; 1127 edict_t *teamchain; 1128 edict_t *teammaster; 1129 1130 edict_t *mynoise; // can go in client only 1131 edict_t *mynoise2; 1132 1133 int noise_index; 1134 int noise_index2; 1135 float volume; 1136 float attenuation; 1137 1138 // timing variables 1139 float wait; 1140 float delay; // before firing targets 1141 float random; 1142 1143 float teleport_time; 1144 1145 int watertype; 1146 int waterlevel; 1147 1148 vec3_t move_origin; 1149 vec3_t move_angles; 1150 1151 // move this to clientinfo? 1152 int light_level; 1153 1154 int style; // also used as areaportal number 1155 1156 gitem_t *item; // for bonus items 1157 1158 // common data blocks 1159 moveinfo_t moveinfo; 1160 monsterinfo_t monsterinfo; 1161 1162 ai_handle_t *ai; //jabot092(2) 1163 qboolean is_swim; //AI_CategorizePosition 1164 qboolean is_step; 1165 qboolean is_ladder; 1166 qboolean was_swim; 1167 qboolean was_step; 1168 //botchat> 1169 float last_insult; 1170 float last_taunt; 1171 float last_chat; 1172 //<botchat 1173 }; 1174 1175 //ZOID 1176 #include "g_ctf.h" 1177 //ZOID 1178 //botchat> 1179 void bFakeChat(edict_t *bot); 1180 void bInsult(edict_t *bot, edict_t *loser); 1181 void bTaunt(edict_t *bot, edict_t *other); 1182 //<botchat 1183 1184 1185