1 #pragma once 2 3 //******************************************************************************************** 4 //* 5 //* This file is part of Egoboo. 6 //* 7 //* Egoboo is free software: you can redistribute it and/or modify it 8 //* under the terms of the GNU General Public License as published by 9 //* the Free Software Foundation, either version 3 of the License, or 10 //* (at your option) any later version. 11 //* 12 //* Egoboo is distributed in the hope that it will be useful, but 13 //* WITHOUT ANY WARRANTY; without even the implied warranty of 14 //* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 //* General Public License for more details. 16 //* 17 //* You should have received a copy of the GNU General Public License 18 //* along with Egoboo. If not, see <http://www.gnu.org/licenses/>. 19 //* 20 //******************************************************************************************** 21 22 /// @file char.h 23 /// @note You will routinely include "char.h" only in headers (*.h) files where you need to declare an 24 /// object of team_t or chr_t. In *.inl files or *.c/*.cpp files you will routinely include "char.inl", instead. 25 26 #include "egoboo_object.h" 27 28 #include "file_formats/cap_file.h" 29 #include "graphic_mad.h" 30 31 #include "sound.h" 32 #include "script.h" 33 #include "md2.h" 34 #include "graphic.h" 35 #include "physics.h" 36 #include "bsp.h" 37 38 #include "egoboo.h" 39 40 //-------------------------------------------------------------------------------------------- 41 //-------------------------------------------------------------------------------------------- 42 43 struct s_mad; 44 struct s_eve; 45 struct s_pip; 46 struct s_object_profile; 47 struct s_billboard_data_t; 48 struct s_mesh_wall_data; 49 50 struct s_prt; 51 struct s_chr; 52 53 //-------------------------------------------------------------------------------------------- 54 //-------------------------------------------------------------------------------------------- 55 // Attack directions 56 #define ATK_FRONT 0x0000 57 #define ATK_RIGHT 0x4000 58 #define ATK_BEHIND 0x8000 59 #define ATK_LEFT 0xC000 60 61 #define MAP_TURN_OFFSET 0x8000 62 63 #define MAXXP 200000 ///< Maximum experience 64 #define MAXMONEY 9999 ///< Maximum money 65 #define SHOP_IDENTIFY 200 ///< Maximum value for identifying shop items 66 67 #define MAX_CAP MAX_PROFILE 68 69 #define CHR_INFINITE_WEIGHT (( Uint32 )0xFFFFFFFF) 70 #define CHR_MAX_WEIGHT (( Uint32 )0xFFFFFFFE) 71 72 #define GRABSIZE 90.0f //135.0f ///< Grab tolerance 73 #define NOHIDE 127 ///< Don't hide 74 #define SEEINVISIBLE 128 ///< Cutoff for invisible characters 75 #define RESPAWN_ANYTIME 0xFF ///< Code for respawnvalid... 76 77 #define RAISE 12 ///< Helps correct z level 78 79 /// The possible methods for characters to determine what direction they are facing 80 typedef enum e_turn_modes 81 { 82 TURNMODE_VELOCITY = 0, ///< Character gets rotation from velocity (normal) 83 TURNMODE_WATCH, ///< For watch towers, look towards waypoint 84 TURNMODE_SPIN, ///< For spinning objects 85 TURNMODE_WATCHTARGET, ///< For combat intensive AI 86 TURNMODE_COUNT 87 } TURN_MODE; 88 89 #define MANARETURNSHIFT 44 ///< ChrList.lst[ichr].manareturn/MANARETURNSHIFT = mana regen per second 90 91 #define TURNSPD 0.01f ///< Cutoff for turning or same direction 92 #define SPINRATE 200 ///< How fast spinners spin 93 #define WATCHMIN 0.01f ///< Tolerance for TURNMODE_WATCH 94 95 /// The vertex offsets for the various grips 96 enum e_grip_offset 97 { 98 GRIP_ORIGIN = 0, ///< Spawn attachments at the center 99 GRIP_LAST = 1, ///< Spawn particles at the last vertex 100 GRIP_LEFT = ( 1 * GRIP_VERTS ), ///< Left weapon grip starts 4 from last 101 GRIP_RIGHT = ( 2 * GRIP_VERTS ), ///< Right weapon grip starts 8 from last 102 103 // aliases 104 GRIP_INVENTORY = GRIP_ORIGIN, 105 GRIP_ONLY = GRIP_LEFT 106 }; 107 typedef enum e_grip_offset grip_offset_t; 108 109 grip_offset_t slot_to_grip_offset( slot_t slot ); 110 slot_t grip_offset_to_slot( grip_offset_t grip ); 111 112 #define PITDEPTH -60 ///< Depth to kill character 113 #define NO_SKIN_OVERRIDE -1 ///< For import 114 #define HURTDAMAGE 256 ///< Minimum damage for hurt animation 115 116 //Dismounting 117 #define DISMOUNTZVEL 16 118 #define DISMOUNTZVELFLY 4 119 #define PHYS_DISMOUNT_TIME (TICKS_PER_SEC*0.05f) ///< time delay for full object-object interaction (approximately 0.05 second) 120 121 //Knockbacks 122 #define REEL 7600.0f ///< Dampen for melee knock back 123 #define REELBASE 0.35f 124 125 //Water 126 #define RIPPLETOLERANCE 60 ///< For deep water 127 #define SPLASHTOLERANCE 10 128 #define RIPPLEAND 15 ///< How often ripples spawn 129 130 /// Stats 131 #define LOWSTAT 256 ///< Worst... 132 #define PERFECTSTAT (60*256) ///< Maximum stat without magic effects 133 #define PERFECTBIG (100*256) ///< Perfect life or mana... 134 #define HIGHSTAT (100*256) ///< Absolute max adding enchantments as well 135 136 /// Throwing 137 #define THROWFIX 30.0f ///< To correct thrown velocities 138 #define MINTHROWVELOCITY 15.0f 139 #define MAXTHROWVELOCITY 75.0f 140 141 /// Inventory 142 #define MAXNUMINPACK 6 ///< Max number of items to carry in pack 143 #define PACKDELAY 25 ///< Time before inventory rotate again 144 #define GRABDELAY 25 ///< Time before grab again 145 146 /// Z velocity 147 #define FLYDAMPEN 0.001f ///< Levelling rate for flyers 148 #define JUMPDELAY 20 ///< Time between jumps 149 #define WATERJUMP 25 ///< How good we jump in water 150 #define JUMPINFINITE 255 ///< Flying character 151 #define SLIDETOLERANCE 10 ///< Stick to ground better 152 #define PLATADD -10 ///< Height add... 153 #define PLATASCEND 0.10f ///< Ascension rate 154 #define PLATKEEP 0.90f ///< Retention rate 155 #define MOUNTTOLERANCE (PLATTOLERANCE) 156 #define STOPBOUNCING 2.00f //0.1f // 1.0f ///< To make objects stop bouncing 157 #define DROPZVEL 7 158 #define DROPXYVEL 12 159 160 //Timer resets 161 #define DAMAGETILETIME 32 ///< Invincibility time 162 #define DAMAGETIME 32 ///< Invincibility time 163 #define DEFENDTIME 24 ///< Invincibility time 164 #define BORETIME generate_randmask( 255, 511 ) ///< IfBored timer 165 #define CAREFULTIME 50 ///< Friendly fire timer 166 #define SIZETIME 100 ///< Time it takes to resize a character 167 168 /// Bits used to control options for the chr_get_name() function 169 enum e_chr_name_bits 170 { 171 CHRNAME_NONE = 0, ///< no options 172 CHRNAME_ARTICLE = ( 1 << 0 ), ///< use an article (a, an, the) 173 CHRNAME_DEFINITE = ( 1 << 1 ), ///< if set, choose "the" else "a" or "an" 174 CHRNAME_CAPITAL = ( 1 << 2 ) ///< capitalize the name 175 }; 176 177 enum e_chr_movement_idx 178 { 179 CHR_MOVEMENT_STOP = 0, 180 CHR_MOVEMENT_SNEAK, 181 CHR_MOVEMENT_WALK, 182 CHR_MOVEMENT_RUN, 183 CHR_MOVEMENT_COUNT 184 }; 185 186 enum e_chr_movement_bits 187 { 188 CHR_MOVEMENT_NONE = 0, 189 CHR_MOVEMENT_BITS_STOP = 1 << CHR_MOVEMENT_STOP, 190 CHR_MOVEMENT_BITS_SNEAK = 1 << CHR_MOVEMENT_SNEAK, 191 CHR_MOVEMENT_BITS_WALK = 1 << CHR_MOVEMENT_WALK, 192 CHR_MOVEMENT_BITS_RUN = 1 << CHR_MOVEMENT_RUN 193 }; 194 195 //------------------------------------ 196 // Team variables 197 //------------------------------------ 198 enum e_team_types 199 { 200 TEAM_EVIL = ( 'E' - 'A' ), ///< Evil team 201 TEAM_GOOD = ( 'G' - 'A' ), ///< Good team 202 TEAM_NULL = ( 'N' - 'A' ), ///< Null or Neutral team 203 TEAM_ZIPPY = ( 'Z' - 'A' ), ///< Zippy Team? 204 TEAM_DAMAGE, ///< For damage tiles 205 TEAM_MAX 206 }; 207 208 #define NOLEADER 0xFFFF ///< If the team has no leader... 209 210 //-------------------------------------------------------------------------------------------- 211 212 /// The description of a single team 213 struct s_team 214 { 215 bool_t hatesteam[TEAM_MAX]; ///< Don't damage allies... 216 Uint16 morale; ///< Number of characters on team 217 CHR_REF leader; ///< The leader of the team 218 CHR_REF sissy; ///< Whoever called for help last 219 }; 220 typedef struct s_team team_t; 221 222 //-------------------------------------------------------------------------------------------- 223 224 /// Everything that is necessary to compute the character's interaction with the environment 225 struct s_chr_environment 226 { 227 // floor stuff 228 Uint8 grid_twist; ///< The twist parameter of the current grid (what angle it it at) 229 float grid_level; ///< Height relative to the current grid 230 float grid_lerp; 231 232 float water_level; ///< Height relative to the current water level 233 float water_lerp; 234 235 float floor_level; ///< Height of tile 236 float level; ///< Height of a tile or a platform 237 float fly_level; ///< Height of tile, platform, or water, whever is highest. 238 239 float zlerp; 240 241 fvec3_t floor_speed; 242 243 // friction stuff 244 bool_t is_slipping; 245 bool_t is_slippy, is_watery; 246 float air_friction, ice_friction; 247 float fluid_friction_hrz, fluid_friction_vrt; 248 float traction, friction_hrz; 249 250 // misc states 251 bool_t inwater; 252 bool_t grounded; ///< standing on something? 253 254 // various motion parameters 255 fvec3_t new_v; 256 fvec3_t acc; 257 fvec3_t vel; 258 }; 259 typedef struct s_chr_environment chr_environment_t; 260 261 //-------------------------------------------------------------------------------------------- 262 struct s_pack 263 { 264 bool_t is_packed; ///< Is it in the inventory? 265 bool_t was_packed; ///< Temporary thing... 266 CHR_REF next; ///< Link to the next item 267 int count; ///< How many 268 }; 269 typedef struct s_pack pack_t; 270 271 #define PACK_BEGIN_LOOP(IT,INIT) { size_t IT_count; CHR_REF IT = INIT; IT_count = 0; while( (MAX_CHR != IT) && (IT_count < MAXNUMINPACK) ) { CHR_REF IT##_nxt = ChrList.lst[IT].pack.next; 272 #define PACK_END_LOOP(IT) IT = IT##_nxt; } if(IT_count >= MAXNUMINPACK ) log_error( "%s - bad pack loop\n", __FUNCTION__ ); } 273 274 //-------------------------------------------------------------------------------------------- 275 276 /// the data used to define the spawning of a character 277 struct s_chr_spawn_data 278 { 279 fvec3_t pos; 280 PRO_REF profile; 281 TEAM_REF team; 282 Uint8 skin; 283 FACING_T facing; 284 STRING name; 285 CHR_REF override; 286 }; 287 288 typedef struct s_chr_spawn_data chr_spawn_data_t; 289 290 //-------------------------------------------------------------------------------------------- 291 292 /// The definition of the character object 293 /// This "inherits" for obj_data_t 294 struct s_chr 295 { 296 obj_data_t obj_base; 297 298 chr_spawn_data_t spawn_data; 299 300 // character state 301 ai_state_t ai; ///< ai data 302 latch_t latch; 303 304 // character stats 305 STRING Name; ///< My name 306 Uint8 gender; ///< Gender 307 308 Uint8 lifecolor; ///< Bar color 309 SFP8_T life; ///< Basic character stats 310 SFP8_T lifemax; ///< 8.8 fixed point 311 UFP8_T life_heal; ///< 8.8 fixed point 312 SFP8_T life_return; ///< Regeneration/poison - 8.8 fixed point 313 314 Uint8 manacolor; ///< Bar color 315 SFP8_T mana; ///< Mana stuff 316 SFP8_T manamax; ///< 8.8 fixed point 317 SFP8_T manaflow; ///< 8.8 fixed point 318 SFP8_T manareturn; ///< 8.8 fixed point 319 320 SFP8_T strength; ///< Strength - 8.8 fixed point 321 SFP8_T wisdom; ///< Wisdom - 8.8 fixed point 322 SFP8_T intelligence; ///< Intelligence - 8.8 fixed point 323 SFP8_T dexterity; ///< Dexterity - 8.8 fixed point 324 325 Uint32 experience; ///< Experience 326 Uint8 experiencelevel; ///< Experience Level 327 328 pack_t pack; ///< what the character is holding 329 330 Sint16 money; ///< Money 331 Uint8 ammomax; ///< Ammo stuff 332 Uint16 ammo; 333 CHR_REF holdingwhich[SLOT_COUNT]; ///< !=MAX_CHR if character is holding something 334 CHR_REF inventory[INVEN_COUNT]; ///< !=MAX_CHR if character is storing something 335 336 // team stuff 337 TEAM_REF team; ///< Character's team 338 TEAM_REF baseteam; ///< Character's starting team 339 340 // enchant data 341 ENC_REF firstenchant; ///< Linked list for enchants 342 ENC_REF undoenchant; ///< Last enchantment spawned 343 344 float fat_stt; ///< Character's initial size 345 float fat; ///< Character's size 346 float fat_goto; ///< Character's size goto 347 Sint16 fat_goto_time; ///< Time left in size change 348 349 // jump stuff 350 float jump_power; ///< Jump power 351 Uint8 jump_timer; ///< Delay until next jump 352 Uint8 jumpnumber; ///< Number of jumps remaining 353 Uint8 jumpnumberreset; ///< Number of jumps total, 255=Flying 354 Uint8 jumpready; ///< For standing on a platform character 355 356 // attachments 357 CHR_REF attachedto; ///< !=MAX_CHR if character is a held weapon 358 slot_t inwhich_slot; ///< SLOT_LEFT or SLOT_RIGHT 359 360 // platform stuff 361 bool_t platform; ///< Can it be stood on 362 bool_t canuseplatforms; ///< Can use platforms? 363 int holdingweight; ///< For weighted buttons 364 float targetplatform_level; ///< What is the height of the target platform? 365 CHR_REF targetplatform_ref; ///< Am I trying to attach to a platform? 366 CHR_REF onwhichplatform_ref; ///< Am I on a platform? 367 Uint32 onwhichplatform_update; ///< When was the last platform attachment made? 368 369 // combat stuff 370 Uint8 damagetarget_damagetype; ///< Type of damage for AI DamageTarget 371 Uint8 reaffirm_damagetype; ///< For relighting torches 372 Uint8 damage_modifier[DAMAGE_COUNT]; ///< Resistances and inversion 373 Uint8 defense; ///< Base defense rating 374 SFP8_T damage_boost; ///< Add to swipe damage 375 SFP8_T damage_threshold; ///< Damage below this number is ignored 376 377 // sound stuff 378 Sint8 sound_index[SOUND_COUNT]; ///< a map for soundX.wav to sound types 379 int loopedsound_channel; ///< Which sound channel it is looping on, -1 is none. 380 381 // missle handling 382 Uint8 missiletreatment; ///< For deflection, etc. 383 Uint8 missilecost; ///< Mana cost for each one 384 CHR_REF missilehandler; ///< Who pays the bill for each one... 385 386 // "variable" properties 387 bool_t is_hidden; 388 bool_t alive; ///< Is it alive? 389 bool_t waskilled; ///< Fix for network 390 PLA_REF is_which_player; ///< btrue = player 391 bool_t islocalplayer; ///< btrue = local player 392 bool_t invictus; ///< Totally invincible? 393 bool_t iskursed; ///< Can't be dropped? 394 bool_t nameknown; ///< Is the name known? 395 bool_t ammoknown; ///< Is the ammo known? 396 bool_t hitready; ///< Was it just dropped? 397 bool_t isequipped; ///< For boots and rings and stuff 398 399 // "constant" properties 400 bool_t isitem; ///< Is it grabbable? 401 bool_t cangrabmoney; ///< Picks up coins? 402 bool_t openstuff; ///< Can it open chests/doors? 403 bool_t stickybutt; ///< Rests on floor 404 bool_t isshopitem; ///< Spawned in a shop? 405 bool_t ismount; ///< Can you ride it? 406 bool_t canbecrushed; ///< Crush in a door? 407 bool_t canchannel; ///< Can it convert life to mana? 408 Sint16 manacost; ///< Mana cost to use 409 410 // misc timers 411 Sint16 grog_timer; ///< Grog timer 412 Sint16 daze_timer; ///< Daze timer 413 Sint16 bore_timer; ///< Boredom timer 414 Uint8 careful_timer; ///< "You hurt me!" timer 415 Uint16 reload_timer; ///< Time before another shot 416 Uint8 damage_timer; ///< Invincibility timer 417 418 // graphica info 419 Uint8 flashand; ///< 1,3,7,15,31 = Flash, 255 = Don't 420 bool_t transferblend; ///< Give transparency to weapons? 421 bool_t draw_icon; ///< Show the icon? 422 Uint8 sparkle; ///< Sparkle color or 0 for off 423 bool_t StatusList_on; ///< Display stats? 424 SFP8_T uoffvel; ///< Moving texture speed 425 SFP8_T voffvel; 426 float shadow_size_stt; ///< Initial shadow size 427 Uint32 shadow_size; ///< Size of shadow 428 Uint32 shadow_size_save; ///< Without size modifiers 429 BBOARD_REF ibillboard; ///< The attached billboard 430 431 // model info 432 bool_t is_overlay; ///< Is this an overlay? Track aitarget... 433 Uint16 skin; ///< Character's skin 434 PRO_REF profile_ref; ///< Character's profile 435 PRO_REF basemodel_ref; ///< The true form 436 Uint8 alpha_base; 437 Uint8 light_base; 438 chr_instance_t inst; ///< the render data 439 440 // Skills 441 int darkvision_level; 442 int see_kurse_level; 443 int see_invisible_level; 444 IDSZ_node_t skills[MAX_IDSZ_MAP_SIZE]; 445 446 /// collision info 447 448 /// @note - to make it easier for things to "hit" one another (like a damage particle from 449 /// a torch hitting a grub bug), Aaron sometimes made the bumper size much different 450 /// than the shape of the actual object. 451 /// The old bumper data that is read from the data.txt file will be kept in 452 /// the struct "bump". A new bumper that actually matches the size of the object will 453 /// be kept in the struct "collision" 454 bumper_t bump_stt; 455 bumper_t bump; 456 bumper_t bump_save; 457 458 bumper_t bump_1; ///< the loosest collision volume that mimics the current bump 459 oct_bb_t chr_max_cv; ///< a looser collision volume for chr-prt interactions 460 oct_bb_t chr_min_cv; ///< the tightest collision volume for chr-chr interactions 461 462 oct_bb_t slot_cv[SLOT_COUNT]; ///< the cv's for the object's slots 463 464 Uint8 stoppedby; ///< Collision mask 465 466 // character location data 467 fvec3_t pos_stt; ///< Starting position 468 fvec3_t pos; ///< Character's position 469 fvec3_t vel; ///< Character's velocity 470 orientation_t ori; ///< Character's orientation 471 472 fvec3_t pos_old; ///< Character's last position 473 fvec3_t vel_old; ///< Character's last velocity 474 orientation_t ori_old; ///< Character's last orientation 475 476 Uint32 onwhichgrid; ///< Where the char is 477 Uint32 onwhichblock; ///< The character's collision block 478 CHR_REF bumplist_next; ///< Next character on fanblock 479 480 // movement properties 481 bool_t waterwalk; ///< Always above watersurfacelevel? 482 TURN_MODE turnmode; ///< Turning mode 483 484 BIT_FIELD movement_bits; ///< What movement modes are allowed? 485 float anim_speed_sneak; ///< Movement rate of the sneak animation 486 float anim_speed_walk; ///< Walking if above this speed 487 float anim_speed_run; ///< Running if above this speed 488 float maxaccel; ///< The current maxaccel_reset 489 float maxaccel_reset; ///< The actual maximum acelleration 490 Uint8 flyheight; ///< Height to stabilize at 491 492 // data for doing the physics in bump_all_objects() 493 phys_data_t phys; 494 chr_environment_t enviro; 495 BSP_leaf_t bsp_leaf; 496 497 int dismount_timer; ///< a timer BB added in to make mounts and dismounts not so unpredictable 498 CHR_REF dismount_object; ///< the object that you were dismounting from 499 500 bool_t safe_valid; ///< is the last "safe" position valid? 501 fvec3_t safe_pos; ///< the last "safe" position 502 Uint32 safe_time; ///< the last "safe" time 503 Uint32 safe_grid; ///< the last "safe" grid 504 505 breadcrumb_list_t crumbs; ///< a list of previous valid positions that the object has passed through 506 }; 507 508 typedef struct s_chr chr_t; 509 510 //-------------------------------------------------------------------------------------------- 511 // list definitions 512 //-------------------------------------------------------------------------------------------- 513 514 DECLARE_STACK_EXTERN( team_t, TeamStack, TEAM_MAX ); 515 516 #define VALID_TEAM_RANGE( ITEAM ) ( ((ITEAM) >= 0) && ((ITEAM) < TEAM_MAX) ) 517 518 DECLARE_STACK_EXTERN( cap_t, CapStack, MAX_PROFILE ); 519 520 #define VALID_CAP_RANGE( ICAP ) ( ((ICAP) >= 0) && ((ICAP) < MAX_CAP) ) 521 #define LOADED_CAP( ICAP ) ( VALID_CAP_RANGE( ICAP ) && CapStack.lst[ICAP].loaded ) 522 523 #define IS_ATTACHED_CHR_RAW(ICHR) ( (DEFINED_CHR(ChrList.lst[ICHR].attachedto) || ChrList.lst[ICHR].pack.is_packed) ) 524 #define IS_ATTACHED_CHR(ICHR) ( !DEFINED_CHR(ICHR) ? bfalse : IS_ATTACHED_CHR_RAW(ICHR) ) 525 526 // counters for debugging wall collisions 527 extern int chr_stoppedby_tests; 528 extern int chr_pressure_tests; 529 530 //-------------------------------------------------------------------------------------------- 531 //-------------------------------------------------------------------------------------------- 532 // Function prototypes 533 534 void character_system_begin(); 535 void character_system_end(); 536 537 chr_t * chr_ctor( chr_t * pchr ); 538 chr_t * chr_dtor( chr_t * pchr ); 539 540 void drop_money( const CHR_REF character, int money ); 541 void call_for_help( const CHR_REF character ); 542 void give_experience( const CHR_REF character, int amount, xp_type xptype, bool_t override_invictus ); 543 void give_team_experience( const TEAM_REF team, int amount, Uint8 xptype ); 544 int damage_character( const CHR_REF character, FACING_T direction, 545 IPair damage, Uint8 damagetype, TEAM_REF team, 546 CHR_REF attacker, BIT_FIELD effects, bool_t ignore_invictus ); 547 void kill_character( const CHR_REF character, const CHR_REF killer, bool_t ignore_invictus ); 548 bool_t heal_character( const CHR_REF character, const CHR_REF healer, int amount, bool_t ignore_invictus ); 549 void spawn_poof( const CHR_REF character, const PRO_REF profile ); 550 void spawn_defense_ping( chr_t *pchr, const CHR_REF attacker ); 551 552 void reset_character_alpha( const CHR_REF character ); 553 void reset_character_accel( const CHR_REF character ); 554 bool_t detach_character_from_mount( const CHR_REF character, Uint8 ignorekurse, Uint8 doshop ); 555 556 egoboo_rv flash_character_height( const CHR_REF character, Uint8 valuelow, Sint16 low, Uint8 valuehigh, Sint16 high ); 557 558 void free_one_character_in_game( const CHR_REF character ); 559 void update_all_character_matrices(); 560 void free_inventory_in_game( const CHR_REF character ); 561 562 void keep_weapons_with_holders(); 563 void make_one_character_matrix( const CHR_REF cnt ); 564 565 void update_all_characters( void ); 566 void move_all_characters( void ); 567 void cleanup_all_characters( void ); 568 569 void bump_all_characters_update_counters( void ); 570 571 void do_level_up( const CHR_REF character ); 572 bool_t setup_xp_table( const CHR_REF character ); 573 574 void free_all_chraracters(); 575 576 BIT_FIELD chr_hit_wall( chr_t * pchr, const float test_pos[], float nrm[], float * pressure, struct s_mesh_wall_data * pdata ); 577 BIT_FIELD chr_test_wall( chr_t * pchr, const float test_pos[], struct s_mesh_wall_data * pdata ); 578 579 int chr_count_free(); 580 581 CHR_REF spawn_one_character( fvec3_t pos, const PRO_REF profile, const TEAM_REF team, Uint8 skin, FACING_T facing, const char *name, const CHR_REF override ); 582 void respawn_character( const CHR_REF character ); 583 int change_armor( const CHR_REF character, int skin ); 584 void change_character( const CHR_REF cnt, const PRO_REF profile, Uint8 skin, Uint8 leavewhich ); 585 void change_character_full( const CHR_REF ichr, const PRO_REF profile, Uint8 skin, Uint8 leavewhich ); 586 bool_t cost_mana( const CHR_REF character, int amount, const CHR_REF killer ); 587 void switch_team( const CHR_REF character, const TEAM_REF team ); 588 void issue_clean( const CHR_REF character ); 589 int restock_ammo( const CHR_REF character, IDSZ idsz ); 590 egoboo_rv attach_character_to_mount( const CHR_REF character, const CHR_REF mount, grip_offset_t grip_off ); 591 bool_t inventory_add_item( const CHR_REF item, const CHR_REF character ); 592 CHR_REF inventory_get_item( const CHR_REF character, grip_offset_t grip_off, bool_t ignorekurse ); 593 void drop_keys( const CHR_REF character ); 594 bool_t drop_all_items( const CHR_REF character ); 595 bool_t character_grab_stuff( const CHR_REF chara, grip_offset_t grip, bool_t people ); 596 597 bool_t export_one_character_quest_vfs( const char *szSaveName, const CHR_REF character ); 598 bool_t export_one_character_name_vfs( const char *szSaveName, const CHR_REF character ); 599 bool_t export_one_character_profile_vfs( const char *szSaveName, const CHR_REF character ); 600 bool_t export_one_character_skin_vfs( const char *szSaveName, const CHR_REF character ); 601 CAP_REF load_one_character_profile_vfs( const char *szLoadName, int slot_override, bool_t required ); 602 603 void character_swipe( const CHR_REF cnt, slot_t slot ); 604 605 bool_t is_invictus_direction( FACING_T direction, const CHR_REF character, Uint16 effects ); 606 607 void init_slot_idsz(); 608 609 bool_t ai_add_order( ai_state_t * pai, Uint32 value, Uint16 counter ); 610 611 struct s_billboard_data * chr_make_text_billboard( const CHR_REF ichr, const char * txt, const SDL_Color text_color, const GLXvector4f tint, int lifetime_secs, BIT_FIELD opt_bits ); 612 const char * chr_get_name( const CHR_REF ichr, Uint32 bits ); 613 const char * chr_get_dir_name( const CHR_REF ichr ); 614 int chr_get_skill( chr_t *pchr, IDSZ whichskill ); 615 616 //-------------------------------------------------------------------------------------------- 617 // helper functions 618 619 void init_all_cap(); 620 void release_all_cap(); 621 bool_t release_one_cap( const CAP_REF icap ); 622 623 const char * describe_value( float value, float maxval, int * rank_ptr ); 624 const char* describe_damage( float value, float maxval, int * rank_ptr ); 625 const char* describe_wounds( float max, float current ); 626 627 void reset_teams(); 628 629 egoboo_rv chr_update_matrix( chr_t * pchr, bool_t update_size ); 630 bool_t chr_teleport( const CHR_REF ichr, float x, float y, float z, FACING_T facing_z ); 631 632 bool_t chr_request_terminate( const CHR_REF ichr ); 633 634 chr_t * chr_update_hide( chr_t * pchr ); 635 636 bool_t ai_state_set_changed( ai_state_t * pai ); 637 638 bool_t chr_matrix_valid( chr_t * pchr ); 639 640 egoboo_rv chr_update_collision_size( chr_t * pchr, bool_t update_matrix ); 641 642 CHR_REF chr_has_inventory_idsz( const CHR_REF ichr, IDSZ idsz, bool_t equipped, CHR_REF * pack_last ); 643 CHR_REF chr_holding_idsz( const CHR_REF ichr, IDSZ idsz ); 644 CHR_REF chr_has_item_idsz( const CHR_REF ichr, IDSZ idsz, bool_t equipped, CHR_REF * pack_last ); 645 646 bool_t apply_reflection_matrix( chr_instance_t * pinst, float floor_level ); 647 648 bool_t chr_can_see_object( const CHR_REF ichr, const CHR_REF iobj ); 649 bool_t chr_can_see_dark( const chr_t * pchr, const chr_t * pobj ); 650 bool_t chr_can_see_invis( const chr_t * pchr, const chr_t * pobj ); 651 int chr_get_price( const CHR_REF ichr ); 652 653 bool_t chr_copy_enviro( chr_t * chr_psrc, chr_t * chr_pdst ); 654 655 void chr_set_floor_level( chr_t * pchr, float level ); 656 void chr_set_redshift( chr_t * pchr, int rs ); 657 void chr_set_grnshift( chr_t * pchr, int gs ); 658 void chr_set_blushift( chr_t * pchr, int bs ); 659 void chr_set_sheen( chr_t * pchr, int sheen ); 660 void chr_set_alpha( chr_t * pchr, int alpha ); 661 void chr_set_light( chr_t * pchr, int light ); 662 663 void chr_instance_get_tint( chr_instance_t * pinst, GLfloat * tint, Uint32 bits ); 664 665 CHR_REF chr_get_lowest_attachment( const CHR_REF ichr, bool_t non_item ); 666 667 bool_t chr_can_mount( const CHR_REF ichr_a, const CHR_REF ichr_b ); 668 669 bool_t chr_is_over_water( chr_t *pchr ); 670 671 Uint32 chr_get_framefx( chr_t * pchr ); 672 673 egoboo_rv chr_set_frame( const CHR_REF character, int action, int frame_along, int lip ); 674 675 egoboo_rv chr_set_action( chr_t * pchr, int action, bool_t action_ready, bool_t override_action ); 676 egoboo_rv chr_start_anim( chr_t * pchr, int action, bool_t action_ready, bool_t override_action ); 677 egoboo_rv chr_set_anim( chr_t * pchr, int action, int frame, bool_t action_ready, bool_t override_action ); 678 egoboo_rv chr_increment_action( chr_t * pchr ); 679 egoboo_rv chr_increment_frame( chr_t * pchr ); 680 egoboo_rv chr_play_action( chr_t * pchr, int action, bool_t action_ready ); 681 682 void character_system_begin(); 683 void character_system_end(); 684 685 // these accessor functions are to complex to be inlined 686 MAD_REF chr_get_imad( const CHR_REF ichr ); 687 struct s_mad * chr_get_pmad( const CHR_REF ichr ); 688 TX_REF chr_get_icon_ref( const CHR_REF item ); 689 690 chr_t * chr_run_config( chr_t * pchr ); 691 692 chr_t * chr_config_construct( chr_t * pprt, int max_iterations ); 693 chr_t * chr_config_initialize( chr_t * pprt, int max_iterations ); 694 chr_t * chr_config_activate( chr_t * pprt, int max_iterations ); 695 chr_t * chr_config_deinitialize( chr_t * pprt, int max_iterations ); 696 chr_t * chr_config_deconstruct( chr_t * pprt, int max_iterations ); 697 698 bool_t chr_update_breadcrumb_raw( chr_t * pchr ); 699 bool_t chr_update_breadcrumb( chr_t * pchr, bool_t force ); 700 bool_t chr_update_safe_raw( chr_t * pchr ); 701 bool_t chr_update_safe( chr_t * pchr, bool_t force ); 702 bool_t chr_get_safe( chr_t * pchr, fvec3_base_t pos ); 703 704 bool_t chr_set_pos( chr_t * pchr, fvec3_base_t pos ); 705 706 bool_t chr_set_maxaccel( chr_t * pchr, float new_val ); 707 bool_t character_is_attacking( chr_t *pchr ); 708 709 // this function is needed because the "hidden" state of an ai is determined by 710 // whether ai.state == cap.hidestate 711 chr_t * chr_set_ai_state( chr_t * pchr, int state ); 712 713 void move_one_character_get_environment( chr_t * pchr ); 714 715 bool_t chr_calc_grip_cv( chr_t * pmount, int grip_offset, oct_bb_t * grip_cv_ptr, fvec3_base_t grip_origin_ary, fvec3_base_t grip_up_ary, bool_t shift_origin );