1 /** 2 ** ammoinf.h - Information from 'ammo.dat'. 3 ** 4 ** Written: 06/01/2008 - Marzo 5 **/ 6 7 #ifndef INCL_AMMOINF_H 8 #define INCL_AMMOINF_H 1 9 10 /* 11 Copyright (C) 2008 The Exult Team 12 13 This program is free software; you can redistribute it and/or 14 modify it under the terms of the GNU General Public License 15 as published by the Free Software Foundation; either version 2 16 of the License, or (at your option) any later version. 17 18 This program is distributed in the hope that it will be useful, 19 but WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 GNU General Public License for more details. 22 23 You should have received a copy of the GNU General Public License 24 along with this program; if not, write to the Free Software 25 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 26 */ 27 28 #include "baseinf.h" 29 #include "exult_constants.h" 30 31 #include <iosfwd> 32 33 class Shape_info; 34 35 /* 36 * Info. from 'ammo.dat': 37 */ 38 class Ammo_info : public Base_info { 39 private: 40 static Ammo_info default_info; // For shapes not found. 41 int family_shape; // I.e., burst-arrow's is 'arrow'. 42 int sprite; // What the missile should look like. 43 unsigned char damage; // Extra damage points. 44 unsigned char powers; // Same as for weapons. 45 unsigned char damage_type; // Same as for weapons. 46 bool m_no_blocking; // Can move through walls. 47 unsigned char drop_type; // What to do to missile when it hits/misses 48 bool m_autohit; // Weapon always hits. 49 bool m_lucky; // Easier to hit with. 50 bool m_returns; // Boomerang, magic axe. 51 bool homing; // For Energy Mist/Death Vortex. 52 bool m_explodes; // Burst arrows. 53 public: 54 enum Drop_types { // Determines what happens when the missile misses 55 drop_normally = 0, 56 never_drop = 1, 57 always_drop = 2 58 }; 59 friend class Shapes_vga_file; 60 // Read in from file. 61 bool read(std::istream &in, int version, Exult_Game game); 62 // Write out. 63 void write(std::ostream &out, int shapenum, Exult_Game game); 64 enum { is_binary = 1, entry_size = 13 }; 65 static const Ammo_info *get_default(); get_family_shape()66 int get_family_shape() const { 67 return family_shape; 68 } set_family_shape(int f)69 void set_family_shape(int f) { 70 if (family_shape != f) { 71 set_modified(true); 72 family_shape = f; 73 } 74 } get_sprite_shape()75 int get_sprite_shape() const { 76 return sprite; 77 } set_sprite_shape(int f)78 void set_sprite_shape(int f) { 79 if (sprite != f) { 80 set_modified(true); 81 sprite = f; 82 } 83 } get_damage()84 int get_damage() const { 85 return damage; 86 } get_damage_type()87 int get_damage_type() const { 88 return damage_type; 89 } set_damage(int dmg,int dtype)90 void set_damage(int dmg, int dtype) { 91 if (damage != dmg || damage_type != dtype) { 92 set_modified(true); 93 damage = dmg; 94 damage_type = dtype; 95 } 96 } get_powers()97 unsigned char get_powers() const { 98 return powers; 99 } set_powers(unsigned char p)100 void set_powers(unsigned char p) { 101 if (powers != p) { 102 set_modified(true); 103 powers = p; 104 } 105 } no_blocking()106 bool no_blocking() const { 107 return m_no_blocking; 108 } set_no_blocking(bool tf)109 void set_no_blocking(bool tf) { 110 if (m_no_blocking != tf) { 111 set_modified(true); 112 m_no_blocking = tf; 113 } 114 } get_drop_type()115 unsigned char get_drop_type() const { 116 return drop_type; 117 } set_drop_type(unsigned char drop)118 void set_drop_type(unsigned char drop) { 119 if (drop_type != drop) { 120 set_modified(true); 121 drop_type = drop; 122 } 123 } autohits()124 bool autohits() const { 125 return m_autohit; 126 } set_autohits(bool tf)127 void set_autohits(bool tf) { 128 if (m_autohit != tf) { 129 set_modified(true); 130 m_autohit = tf; 131 } 132 } lucky()133 bool lucky() const { 134 return m_lucky; 135 } set_lucky(bool tf)136 void set_lucky(bool tf) { 137 if (m_lucky != tf) { 138 set_modified(true); 139 m_lucky = tf; 140 } 141 } returns()142 bool returns() const { 143 return m_returns; 144 } set_returns(bool tf)145 void set_returns(bool tf) { 146 if (m_returns != tf) { 147 set_modified(true); 148 m_returns = tf; 149 } 150 } is_homing()151 bool is_homing() const { 152 return homing; 153 } set_homing(bool sb)154 void set_homing(bool sb) { 155 if (homing != sb) { 156 set_modified(true); 157 homing = sb; 158 } 159 } explodes()160 bool explodes() const { 161 return m_explodes; 162 } set_explodes(bool b)163 void set_explodes(bool b) { 164 if (m_explodes != b) { 165 set_modified(true); 166 m_explodes = b; 167 } 168 } get_info_flag()169 static int get_info_flag() { 170 return 2; 171 } 172 int get_base_strength() const; 173 }; 174 175 #endif 176