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 enchant.h 23 /// @details Decleares some stuff used for handling enchants 24 25 #include "egoboo_object.h" 26 27 #include "egoboo.h" 28 29 #include "file_formats/eve_file.h" 30 31 //-------------------------------------------------------------------------------------------- 32 //-------------------------------------------------------------------------------------------- 33 struct s_object_profile; 34 struct s_chr; 35 36 //-------------------------------------------------------------------------------------------- 37 //-------------------------------------------------------------------------------------------- 38 39 #define ENC_LEAVE_ALL 0 40 #define ENC_LEAVE_FIRST 1 41 #define ENC_LEAVE_NONE 2 42 43 #define MAX_EVE MAX_PROFILE ///< One enchant type per model 44 #define MAX_ENC 200 ///< Number of enchantments 45 46 //-------------------------------------------------------------------------------------------- 47 //-------------------------------------------------------------------------------------------- 48 49 /// Enchantment template 50 DECLARE_STACK_EXTERN( eve_t, EveStack, MAX_EVE ); 51 52 #define VALID_EVE_RANGE( IEVE ) ( ((IEVE) >= 0) && ((IEVE) < MAX_EVE) ) 53 #define LOADED_EVE( IEVE ) ( VALID_EVE_RANGE( IEVE ) && EveStack.lst[IEVE].loaded ) 54 55 //-------------------------------------------------------------------------------------------- 56 struct s_enc_spawn_data 57 { 58 CHR_REF owner_ref; 59 CHR_REF target_ref; 60 CHR_REF spawner_ref; 61 PRO_REF profile_ref; 62 EVE_REF eve_ref; 63 }; 64 typedef struct s_enc_spawn_data enc_spawn_data_t; 65 66 //-------------------------------------------------------------------------------------------- 67 68 /// The difinition of a single Egoboo enchantment 69 /// This "inherits" from obj_data_t 70 struct s_enc 71 { 72 obj_data_t obj_base; 73 74 enc_spawn_data_t spawn_data; 75 76 int lifetime; ///< Time before end 77 int spawn_timer; ///< Time before spawn 78 79 PRO_REF profile_ref; ///< The object profile index that spawned this enchant 80 EVE_REF eve_ref; ///< The enchant profile index 81 82 CHR_REF target_ref; ///< Who it enchants 83 CHR_REF owner_ref; ///< Who cast the enchant 84 CHR_REF spawner_ref; ///< The spellbook character 85 PRO_REF spawnermodel_ref; ///< The spellbook character's CapStack index 86 CHR_REF overlay_ref; ///< The overlay character 87 88 int owner_mana; ///< Boost values 89 int owner_life; 90 int target_mana; 91 int target_life; 92 93 ENC_REF nextenchant_ref; ///< Next in the list 94 95 bool_t setyesno[MAX_ENCHANT_SET]; ///< Was it set? 96 float setsave[MAX_ENCHANT_SET]; ///< The value to restore 97 98 bool_t addyesno[MAX_ENCHANT_ADD]; ///< Was the value adjusted 99 float addsave[MAX_ENCHANT_ADD]; ///< The adjustment 100 }; 101 typedef struct s_enc enc_t; 102 103 //-------------------------------------------------------------------------------------------- 104 //-------------------------------------------------------------------------------------------- 105 // Prototypes 106 107 void enchant_system_begin(); 108 void enchant_system_end(); 109 110 enc_t * enc_ctor( enc_t * penc ); 111 enc_t * enc_dtor( enc_t * penc ); 112 113 void init_all_eve(); 114 void release_all_eve(); 115 bool_t release_one_eve( const EVE_REF ieve ); 116 117 void update_all_enchants(); 118 void cleanup_all_enchants(); 119 120 void bump_all_enchants_update_counters( void ); 121 122 ENC_REF enchant_value_filled( const ENC_REF enchant_idx, int value_idx ); 123 bool_t remove_enchant( const ENC_REF enchant_idx, ENC_REF * enchant_parent ); 124 bool_t remove_all_enchants_with_idsz( CHR_REF ichr, IDSZ remove_idsz ); 125 //#define remove_all_character_enchants( PCHR ) remove_all_enchants_with_idsz( PCHR, IDSZ_NONE ) 126 void enchant_apply_set( const ENC_REF enchant_idx, int value_idx, const PRO_REF profile ); 127 void enchant_apply_add( const ENC_REF enchant_idx, int value_idx, const EVE_REF enchanttype ); 128 ENC_REF spawn_one_enchant( const CHR_REF owner, const CHR_REF target, const CHR_REF spawner, const ENC_REF enc_override, const PRO_REF modeloptional ); 129 EVE_REF load_one_enchant_profile_vfs( const char* szLoadName, const EVE_REF profile ); 130 void enchant_remove_set( const ENC_REF enchant_idx, int value_idx ); 131 void enchant_remove_add( const ENC_REF enchant_idx, int value_idx ); 132 133 bool_t enc_request_terminate( const ENC_REF ienc ); 134 135 enc_t * enc_run_config( enc_t * penc ); 136 137 ENC_REF cleanup_enchant_list( const ENC_REF ienc, ENC_REF * enc_parent ); 138 139 enc_t * enc_config_construct( enc_t * penc, int max_iterations ); 140 enc_t * enc_config_initialize( enc_t * penc, int max_iterations ); 141 enc_t * enc_config_activate( enc_t * penc, int max_iterations ); 142 enc_t * enc_config_deinitialize( enc_t * penc, int max_iterations ); 143 enc_t * enc_config_deconstruct( enc_t * penc, int max_iterations ); 144