1 // SONIC ROBO BLAST 2 2 //----------------------------------------------------------------------------- 3 // Copyright (C) 1993-1996 by id Software, Inc. 4 // Copyright (C) 1998-2000 by DooM Legacy Team. 5 // Copyright (C) 1999-2020 by Sonic Team Junior. 6 // 7 // This program is free software distributed under the 8 // terms of the GNU General Public License, version 2. 9 // See the 'LICENSE' file for more details. 10 //----------------------------------------------------------------------------- 11 /// \file d_player.h 12 /// \brief player data structures 13 14 #ifndef __D_PLAYER__ 15 #define __D_PLAYER__ 16 17 // The player data structure depends on a number 18 // of other structs: items (internal inventory), 19 // animation states (closely tied to the sprites 20 // used to represent them, unfortunately). 21 #include "p_pspr.h" 22 23 // In addition, the player is just a special 24 // case of the generic moving object/actor. 25 #include "p_mobj.h" 26 27 // Finally, for odd reasons, the player input 28 // is buffered within the player data struct, 29 // as commands per game tick. 30 #include "d_ticcmd.h" 31 32 // Extra abilities/settings for skins (combinable stuff) 33 typedef enum 34 { 35 SF_SUPER = 1, // Can turn super in singleplayer/co-op mode? 36 SF_NOSUPERSPIN = 1<<1, // Should spin frames be played while super? 37 SF_NOSPINDASHDUST = 1<<2, // Spawn dust particles when charging a spindash? 38 SF_HIRES = 1<<3, // Draw the sprite at different size? 39 SF_NOSKID = 1<<4, // No skid particles etc 40 SF_NOSPEEDADJUST = 1<<5, // Skin-specific version of disablespeedadjust 41 SF_RUNONWATER = 1<<6, // Run on top of water FOFs? 42 SF_NOJUMPSPIN = 1<<7, // SPR2_JUMP defaults to SPR2_SPRG instead of SPR2_ROLL, falling states used, and player height is full when jumping? 43 SF_NOJUMPDAMAGE = 1<<8, // Don't damage enemies, etc whilst jumping? 44 SF_STOMPDAMAGE = 1<<9, // Always damage enemies, etc by landing on them, no matter your vunerability? 45 SF_MARIODAMAGE = SF_NOJUMPDAMAGE|SF_STOMPDAMAGE, // The Mario method of being able to damage enemies, etc. 46 SF_MACHINE = 1<<10, // Beep boop. Are you a robot? 47 SF_DASHMODE = 1<<11, // Sonic Advance 2 style top speed increase? 48 SF_FASTEDGE = 1<<12, // Faster edge teeter? 49 SF_MULTIABILITY = 1<<13, // Revenge of Final Demo. 50 SF_NONIGHTSROTATION = 1<<14, // Disable sprite rotation for NiGHTS 51 SF_NONIGHTSSUPER = 1<<15, // Disable super colors for NiGHTS (if you have SF_SUPER) 52 SF_NOSUPERSPRITES = 1<<16, // Don't use super sprites while super 53 SF_NOSUPERJUMPBOOST = 1<<17, // Disable the jump boost given while super (i.e. Knuckles) 54 SF_CANBUSTWALLS = 1<<18, // Can naturally bust walls on contact? (i.e. Knuckles) 55 SF_NOSHIELDABILITY = 1<<19, // Disable shield abilities 56 57 // free up to and including 1<<31 58 } skinflags_t; 59 60 //Primary and secondary skin abilities 61 typedef enum 62 { 63 CA_NONE=0, 64 CA_THOK, 65 CA_FLY, 66 CA_GLIDEANDCLIMB, 67 CA_HOMINGTHOK, 68 CA_SWIM, 69 CA_DOUBLEJUMP, 70 CA_FLOAT, 71 CA_SLOWFALL, 72 CA_TELEKINESIS, 73 CA_FALLSWITCH, 74 CA_JUMPBOOST, 75 CA_AIRDRILL, 76 CA_JUMPTHOK, 77 CA_BOUNCE, 78 CA_TWINSPIN 79 } charability_t; 80 81 //Secondary skin abilities 82 typedef enum 83 { 84 CA2_NONE=0, 85 CA2_SPINDASH, 86 CA2_GUNSLINGER, 87 CA2_MELEE 88 } charability2_t; 89 90 // 91 // Player states. 92 // 93 typedef enum 94 { 95 // Playing or camping. 96 PST_LIVE, 97 // Dead on the ground, view follows killer. 98 PST_DEAD, 99 // Ready to restart/respawn??? 100 PST_REBORN 101 } playerstate_t; 102 103 // 104 // Player internal flags 105 // 106 typedef enum 107 { 108 // Cvars 109 PF_FLIPCAM = 1, // Flip camera angle with gravity flip prefrence. 110 PF_ANALOGMODE = 1<<1, // Analog mode? 111 PF_DIRECTIONCHAR = 1<<2, // Directional character sprites? 112 PF_AUTOBRAKE = 1<<3, // Autobrake? 113 114 // Cheats 115 PF_GODMODE = 1<<4, 116 PF_NOCLIP = 1<<5, 117 PF_INVIS = 1<<6, 118 119 // True if button down last tic. 120 PF_ATTACKDOWN = 1<<7, 121 PF_SPINDOWN = 1<<8, 122 PF_JUMPDOWN = 1<<9, 123 PF_WPNDOWN = 1<<10, 124 125 // Unmoving states 126 PF_STASIS = 1<<11, // Player is not allowed to move 127 PF_JUMPSTASIS = 1<<12, // and that includes jumping. 128 PF_FULLSTASIS = PF_STASIS|PF_JUMPSTASIS, 129 130 // Applying autobrake? 131 PF_APPLYAUTOBRAKE = 1<<13, 132 133 // Character action status 134 PF_STARTJUMP = 1<<14, 135 PF_JUMPED = 1<<15, 136 PF_NOJUMPDAMAGE = 1<<16, 137 138 PF_SPINNING = 1<<17, 139 PF_STARTDASH = 1<<18, 140 141 PF_THOKKED = 1<<19, 142 PF_SHIELDABILITY = 1<<20, 143 PF_GLIDING = 1<<21, 144 PF_BOUNCING = 1<<22, 145 146 // Sliding (usually in water) like Labyrinth/Oil Ocean 147 PF_SLIDING = 1<<23, 148 149 // NiGHTS stuff 150 PF_TRANSFERTOCLOSEST = 1<<24, 151 PF_DRILLING = 1<<25, 152 153 // Gametype-specific stuff 154 PF_GAMETYPEOVER = 1<<26, // Race time over, or H&S out-of-game 155 PF_TAGIT = 1<<27, // The player is it! For Tag Mode 156 157 /*** misc ***/ 158 PF_FORCESTRAFE = 1<<28, // Turning inputs are translated into strafing inputs 159 PF_CANCARRY = 1<<29, // Can carry another player? 160 PF_FINISHED = 1<<30, // The player finished the level. NOT the same as exiting 161 162 // up to 1<<31 is free 163 } pflags_t; 164 165 typedef enum 166 { 167 // Are animation frames playing? 168 PA_ETC=0, 169 PA_IDLE, 170 PA_EDGE, 171 PA_WALK, 172 PA_RUN, 173 PA_DASH, 174 PA_PAIN, 175 PA_ROLL, 176 PA_JUMP, 177 PA_SPRING, 178 PA_FALL, 179 PA_ABILITY, 180 PA_ABILITY2, 181 PA_RIDE 182 } panim_t; 183 184 // 185 // All of the base srb2 shields are either a single constant, 186 // or use damagetype-protecting flags applied to a constant, 187 // or are the force shield (which does everything weirdly). 188 // 189 // Base flags by themselves aren't used so modders can make 190 // abstract, ability-less shields should they so choose. 191 // 192 typedef enum 193 { 194 SH_NONE = 0, 195 196 // Shield flags 197 SH_PROTECTFIRE = 0x400, 198 SH_PROTECTWATER = 0x800, 199 SH_PROTECTELECTRIC = 0x1000, 200 SH_PROTECTSPIKE = 0x2000, // cactus shield one day? thanks, subarashii 201 //SH_PROTECTNUKE = 0x4000, // intentionally no hardcoded defense against nukes 202 203 // Indivisible shields 204 SH_PITY = 1, // the world's most basic shield ever, given to players who suck at Match 205 SH_WHIRLWIND, 206 SH_ARMAGEDDON, 207 SH_PINK, // PITY IN PINK! 208 209 // Normal shields that use flags 210 SH_ATTRACT = SH_PITY|SH_PROTECTELECTRIC, 211 SH_ELEMENTAL = SH_PITY|SH_PROTECTFIRE|SH_PROTECTWATER, 212 213 // Sonic 3 shields 214 SH_FLAMEAURA = SH_PITY|SH_PROTECTFIRE, 215 SH_BUBBLEWRAP = SH_PITY|SH_PROTECTWATER, 216 SH_THUNDERCOIN = SH_WHIRLWIND|SH_PROTECTELECTRIC, 217 218 // The force shield uses the lower 8 bits to count how many extra hits are left. 219 SH_FORCE = 0x100, 220 SH_FORCEHP = 0xFF, // to be used as a bitmask only 221 222 // Mostly for use with Mario mode. 223 SH_FIREFLOWER = 0x200, 224 225 SH_STACK = SH_FIREFLOWER, // second-layer shields 226 SH_NOSTACK = ~SH_STACK 227 } shieldtype_t; // pw_shield 228 229 typedef enum 230 { 231 CR_NONE = 0, 232 // The generic case is suitable for most objects. 233 CR_GENERIC, 234 // Tails carry. 235 CR_PLAYER, 236 // NiGHTS mode. Not technically a CARRYING, but doesn't stack with any of the others, so might as well go here. 237 CR_NIGHTSMODE, 238 CR_NIGHTSFALL, 239 // Old Brak sucks hard, but this gimmick could be used for something better, so we might as well continue supporting it. 240 CR_BRAKGOOP, 241 // Specific level gimmicks. 242 CR_ZOOMTUBE, 243 CR_ROPEHANG, 244 CR_MACESPIN, 245 CR_MINECART, 246 CR_ROLLOUT, 247 CR_PTERABYTE, 248 CR_DUSTDEVIL 249 } carrytype_t; // pw_carry 250 251 // Player powers. (don't edit this comment) 252 typedef enum 253 { 254 pw_invulnerability, 255 pw_sneakers, 256 pw_flashing, 257 pw_shield, 258 pw_carry, 259 pw_tailsfly, // tails flying 260 pw_underwater, // underwater timer 261 pw_spacetime, // In space, no one can hear you spin! 262 pw_extralife, // Extra Life timer 263 pw_pushing, 264 pw_justsprung, 265 pw_noautobrake, 266 267 pw_super, // Are you super? 268 pw_gravityboots, // gravity boots 269 270 // Weapon ammunition 271 pw_infinityring, 272 pw_automaticring, 273 pw_bouncering, 274 pw_scatterring, 275 pw_grenadering, 276 pw_explosionring, 277 pw_railring, 278 279 // Power Stones 280 pw_emeralds, // stored like global 'emeralds' variable 281 282 // NiGHTS powerups 283 pw_nights_superloop, 284 pw_nights_helper, 285 pw_nights_linkfreeze, 286 287 pw_nocontrol, //for linedef exec 427 288 289 pw_dye, // for dyes 290 291 pw_justlaunched, // Launched off a slope this tic (0=none, 1=standard launch, 2=half-pipe launch) 292 293 pw_ignorelatch, // Don't grab onto CR_GENERIC, add 32768 (powers[pw_ignorelatch] & 1<<15) to avoid ALL not-NiGHTS CR_ types 294 295 NUMPOWERS 296 } powertype_t; 297 298 #define WEP_AUTO 1 299 #define WEP_BOUNCE 2 300 #define WEP_SCATTER 3 301 #define WEP_GRENADE 4 302 #define WEP_EXPLODE 5 303 #define WEP_RAIL 6 304 #define NUM_WEAPONS 7 305 306 typedef enum 307 { 308 RW_AUTO = 1, 309 RW_BOUNCE = 2, 310 RW_SCATTER = 4, 311 RW_GRENADE = 8, 312 RW_EXPLODE = 16, 313 RW_RAIL = 32 314 } ringweapons_t; 315 316 // ======================================================================== 317 // PLAYER STRUCTURE 318 // ======================================================================== 319 typedef struct player_s 320 { 321 mobj_t *mo; 322 323 // Caveat: ticcmd_t is ATTRPACK! Be careful what precedes it. 324 ticcmd_t cmd; 325 326 playerstate_t playerstate; 327 328 // Determine POV, including viewpoint bobbing during movement. 329 fixed_t camerascale; 330 fixed_t shieldscale; 331 // Focal origin above r.z 332 fixed_t viewz; 333 // Base height above floor for viewz. 334 fixed_t viewheight; 335 // Bob/squat speed. 336 fixed_t deltaviewheight; 337 // bounded/scaled total momentum. 338 fixed_t bob; 339 340 angle_t viewrollangle; 341 342 INT16 angleturn; 343 INT16 oldrelangleturn; 344 345 // Mouse aiming, where the guy is looking at! 346 // It is updated with cmd->aiming. 347 angle_t aiming; 348 349 // fun thing for player sprite 350 angle_t drawangle; 351 352 // player's ring count 353 INT16 rings; 354 INT16 spheres; 355 356 SINT8 pity; // i pity the fool. 357 INT32 currentweapon; // current weapon selected. 358 INT32 ringweapons; // weapons currently obtained. 359 360 UINT16 ammoremoval; // amount of ammo removed for the current weapon. 361 tic_t ammoremovaltimer; // flashing counter for ammo used. 362 INT32 ammoremovalweapon; // weapon from which the ammo was removed. 363 364 // Power ups. invinc and invis are tic counters. 365 UINT16 powers[NUMPOWERS]; 366 367 // Bit flags. 368 // See pflags_t, above. 369 pflags_t pflags; 370 371 // playing animation. 372 panim_t panim; 373 374 // For screen flashing (bright). 375 UINT16 flashcount; 376 UINT16 flashpal; 377 378 // Player skin colorshift, 0-15 for which color to draw player. 379 UINT16 skincolor; 380 381 INT32 skin; 382 UINT32 availabilities; 383 384 UINT32 score; // player score 385 fixed_t dashspeed; // dashing speed 386 387 fixed_t normalspeed; // Normal ground 388 fixed_t runspeed; // Speed you break into the run animation 389 UINT8 thrustfactor; // Thrust = thrustfactor * acceleration 390 UINT8 accelstart; // Starting acceleration if speed = 0. 391 UINT8 acceleration; // Acceleration 392 393 // See charability_t and charability2_t for more information. 394 UINT8 charability; // Ability definition 395 UINT8 charability2; // Secondary ability definition 396 397 UINT32 charflags; // Extra abilities/settings for skins (combinable stuff) 398 // See SF_ flags 399 400 mobjtype_t thokitem; // Object # to spawn for the thok 401 mobjtype_t spinitem; // Object # to spawn for spindash/spinning 402 mobjtype_t revitem; // Object # to spawn for spindash/spinning 403 mobjtype_t followitem; // Object # to spawn for Smiles 404 mobj_t *followmobj; // Smiles all around 405 406 fixed_t actionspd; // Speed of thok/glide/fly 407 fixed_t mindash; // Minimum spindash speed 408 fixed_t maxdash; // Maximum spindash speed 409 410 fixed_t jumpfactor; // How high can the player jump? 411 412 fixed_t height; // Bounding box changes. 413 fixed_t spinheight; 414 415 SINT8 lives; // number of lives - if == INFLIVES, the player has infinite lives 416 SINT8 continues; // continues that player has acquired 417 418 SINT8 xtralife; // Ring Extra Life counter 419 UINT8 gotcontinue; // Got continue from this stage? 420 421 fixed_t speed; // Player's speed (distance formula of MOMX and MOMY values) 422 UINT8 secondjump; // Jump counter 423 424 UINT8 fly1; // Tails flying 425 UINT8 scoreadd; // Used for multiple enemy attack bonus 426 tic_t glidetime; // Glide counter for thrust 427 UINT8 climbing; // Climbing on the wall 428 INT32 deadtimer; // End game if game over lasts too long 429 tic_t exiting; // Exitlevel timer 430 431 UINT8 homing; // Are you homing? 432 tic_t dashmode; // counter for dashmode ability 433 434 tic_t skidtime; // Skid timer 435 436 //////////////////////////// 437 // Conveyor Belt Movement // 438 //////////////////////////// 439 fixed_t cmomx; // Conveyor momx 440 fixed_t cmomy; // Conveyor momy 441 fixed_t rmomx; // "Real" momx (momx - cmomx) 442 fixed_t rmomy; // "Real" momy (momy - cmomy) 443 444 ///////////////////// 445 // Race Mode Stuff // 446 ///////////////////// 447 INT16 numboxes; // Number of item boxes obtained for Race Mode 448 INT16 totalring; // Total number of rings obtained for Race Mode 449 tic_t realtime; // integer replacement for leveltime 450 UINT8 laps; // Number of laps (optional) 451 452 //////////////////// 453 // CTF Mode Stuff // 454 //////////////////// 455 INT32 ctfteam; // 0 == Spectator, 1 == Red, 2 == Blue 456 UINT16 gotflag; // 1 == Red, 2 == Blue Do you have the flag? 457 458 INT32 weapondelay; // Delay (if any) to fire the weapon again 459 INT32 tossdelay; // Delay (if any) to toss a flag/emeralds again 460 461 // Starpost information 462 INT16 starpostx; 463 INT16 starposty; 464 INT16 starpostz; 465 INT32 starpostnum; // The number of the last starpost you hit 466 tic_t starposttime; // Your time when you hit the starpost 467 angle_t starpostangle; // Angle that the starpost is facing - you respawn facing this way 468 fixed_t starpostscale; // Scale of the player; if negative, player is gravflipped 469 470 ///////////////// 471 // NiGHTS Stuff// 472 ///////////////// 473 angle_t angle_pos; 474 angle_t old_angle_pos; 475 476 mobj_t *axis1; 477 mobj_t *axis2; 478 tic_t bumpertime; // Currently being bounced by MT_NIGHTSBUMPER 479 INT32 flyangle; 480 tic_t drilltimer; 481 INT32 linkcount; 482 tic_t linktimer; 483 INT32 anotherflyangle; 484 tic_t nightstime; // How long you can fly as NiGHTS. 485 INT32 drillmeter; 486 UINT8 drilldelay; 487 boolean bonustime; // Capsule destroyed, now it's bonus time! 488 mobj_t *capsule; // Go inside the capsule 489 mobj_t *drone; // Move center to the drone 490 fixed_t oldscale; // Pre-Nightserize scale 491 UINT8 mare; // Current mare 492 UINT8 marelap; // Current mare lap 493 UINT8 marebonuslap; // Current mare lap starting from bonus time 494 495 // Statistical purposes. 496 tic_t marebegunat; // Leveltime when mare begun 497 tic_t startedtime; // Time which you started this mare with. 498 tic_t finishedtime; // Time it took you to finish the mare (used for display) 499 tic_t lapbegunat; // Leveltime when lap begun 500 tic_t lapstartedtime; // Time which you started this lap with. 501 INT16 finishedspheres; // The spheres you had left upon finishing the mare 502 INT16 finishedrings; // The rings/stars you had left upon finishing the mare 503 UINT32 marescore; // score for this nights stage 504 UINT32 lastmarescore; // score for the last mare 505 UINT32 totalmarescore; // score for all mares 506 UINT8 lastmare; // previous mare 507 UINT8 lastmarelap; // previous mare lap 508 UINT8 lastmarebonuslap; // previous mare bonus lap 509 UINT8 totalmarelap; // total mare lap 510 UINT8 totalmarebonuslap; // total mare bonus lap 511 INT32 maxlink; // maximum link obtained 512 UINT8 texttimer; // nights_texttime should not be local 513 UINT8 textvar; // which line of NiGHTS text to show -- let's not use cheap hacks 514 515 INT16 lastsidehit, lastlinehit; 516 517 tic_t losstime; 518 UINT8 timeshit; // That's TIMES HIT, not TIME SHIT, you doofus! 519 520 INT32 onconveyor; // You are on a conveyor belt if nonzero 521 522 mobj_t *awayviewmobj; 523 INT32 awayviewtics; 524 angle_t awayviewaiming; // Used for cut-away view 525 526 boolean spectator; 527 boolean outofcoop; 528 UINT8 bot; 529 530 tic_t jointime; // Timer when player joins game to change skin/color 531 tic_t quittime; // Time elapsed since user disconnected, zero if connected 532 #ifdef HWRENDER 533 fixed_t fovadd; // adjust FOV for hw rendering 534 #endif 535 } player_t; 536 537 // Values for dashmode 538 #define DASHMODE_THRESHOLD (3*TICRATE) 539 #define DASHMODE_MAX (DASHMODE_THRESHOLD + 3) 540 541 // Value for infinite lives 542 #define INFLIVES 0x7F 543 544 #endif 545