ScummVM API documentation
damage_info.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it 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  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef WORLD_DAMAGE_INFO_H
23 #define WORLD_DAMAGE_INFO_H
24 
25 #include "ultima/shared/std/string.h"
26 
27 namespace Ultima {
28 namespace Ultima8 {
29 
30 class Item;
31 
35 class DamageInfo {
36 public:
37  DamageInfo(uint8 data[6]);
38  ~DamageInfo() {};
39 
41  bool applyToItem(Item *item, uint16 points) const;
42 
43  bool frameDataIsAbsolute() const {
44  return (_flags >> 7) & 1;
45  }
46  bool replaceItem() const {
47  return (_flags >> 6) & 1;
48  }
49  bool explodeDestroysItem() const {
50  return (_flags >> 5) & 1;
51  }
52  bool explodeWithDamage() const {
53  return (_flags >> 3) & 1;
54  }
55  bool takesDamage() const {
56  return _flags & 1;
57  }
58 
59  uint8 damagePoints() const {
60  return _damagePoints;
61  }
62 
63 protected:
64  bool explode() const {
65  return (_flags & 0x06) != 0;
66  }
67  int explosionType() const {
68  assert(explode());
69  return ((_flags & 0x06) >> 1) - 1;
70  }
71 
72  uint16 getReplacementShape() const {
73  assert(replaceItem());
74  return static_cast<uint16>(_data[1]) << 8 | _data[0];
75  }
76 
77  uint16 getReplacementFrame() const {
78  assert(replaceItem());
79  return static_cast<uint16>(_data[2]);
80  }
81 
82 
83  // Flags are ABCxDEEF
84  // A = frame data is absolute (not relative to current)
85  // B = item is replaced when destroyed
86  // C = item destroyed after explosion
87  // D = explosion damages surrounding items
88  // EE = 2 bits for explosion type
89  // F = item takes damage
90  uint8 _flags;
91  uint8 _sound;
92  uint8 _data[3];
93  uint8 _damagePoints;
94 };
95 
96 } // End of namespace Ultima8
97 } // End of namespace Ultima
98 
99 #endif
Definition: item.h:42
bool applyToItem(Item *item, uint16 points) const
apply this damage info to the given item. Returns true if the item was destroyed in the process...
Definition: damage_info.h:35
Definition: detection.h:27