ScummVM API documentation
attack_process.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_ACTORS_ATTACKPROCESS_H
23 #define WORLD_ACTORS_ATTACKPROCESS_H
24 
25 #include "ultima/ultima8/kernel/process.h"
26 #include "ultima/ultima8/misc/direction.h"
27 
28 #include "common/memstream.h"
29 
30 namespace Ultima {
31 namespace Ultima8 {
32 
33 class Actor;
34 class CombatDat;
35 
41 class AttackProcess : public Process {
42 public:
43  AttackProcess();
44  AttackProcess(Actor *actor);
45 
46  virtual ~AttackProcess();
47 
48  ENABLE_RUNTIME_CLASSTYPE()
49 
50  void run() override;
51 
52  void terminate() override;
53 
54  Common::String dumpInfo() const override;
55 
56  void setIsActivityAOrB() {
57  _isActivityAorB = true;
58  }
59  void setIsActivity9OrB() {
60  _isActivity9orB = true;
61  }
62  void setField97() {
63  _field97 = true;
64  }
65  void setField7F() {
66  _field7f = true;
67  }
68 
69  void setTimer3();
70 
71  uint16 getTarget() const {
72  return _target;
73  }
74 
75  void setTarget(uint16 target) {
76  _target = target;
77  }
78 
82  static int16 getRandomAttackSoundRegret(const Actor *actor);
83 
84  bool loadData(Common::ReadStream *rs, uint32 version);
85  void saveData(Common::WriteStream *ws) override;
86 
87  static const uint16 ATTACK_PROC_TYPE = 0x259;
88 private:
91  void setTacticNo(int block);
94  void setBlockNo(int block);
95 
97  uint16 readNextWordRaw();
100  uint16 readNextWordWithData();
101 
103  void setAttackData(uint16 offset, uint16 val);
105  uint16 getAttackData(uint16 offset) const;
106 
108  void genericAttack();
109 
111  void sleep(int ticks);
112 
114  bool readyForNextSound(uint32 now);
115 
116  bool checkTimer2PlusDelayElapsed(int now);
117  void pathfindToItemInNPCData();
118  bool timer4and5Update(int now);
119  void timeNowToTimerVal2(int now);
120  bool checkReady(int now, Direction targetdir);
121 
124  void checkRandomAttackSound(int now, uint32 shapeno);
125 
127  void checkRandomAttackSoundRegret(const Actor *actor);
128 
129  uint16 _target; // TODO: this is stored in NPC in game, does it matter?
130  uint16 _tactic;
131  uint16 _block;
132  uint16 _tacticDatStartOffset;
133  const CombatDat *_tacticDat;
134  Common::MemoryReadStream *_tacticDatReadStream;
135 
136  int16 _soundNo;
137  bool _playedStartSound;
138 
139  Direction _npcInitialDir;
140 
141  // Unknown fields..
142  int16 _field57;
143  uint16 _field59;
144  //uint16 _field53; // Never really used?
145  bool _field7f;
146  bool _field96;
147  bool _field97;
148 
149  bool _isActivity9orB;
150  bool _isActivityAorB;
151  bool _timer2set;
152  bool _timer3set;
153  bool _doubleDelay;
154 
155  uint16 _wpnField8;
156 
158  uint16 _dataArray[10];
159 
160  int32 _wpnBasedTimeout;
161  int32 _difficultyBasedTimeout;
162 
163  int32 _timer2; // 0x73/0x75 in orig
164  int32 _timer3; // 0x77/0x79 in orig
165  int32 _timer4; // 0x6f/0x71 in orig
166  int32 _timer5; // 0x8a/0x8c in orig
167 
168  uint32 _soundTimestamp;
169  uint32 _soundDelayTicks;
170  int32 _fireTimestamp;
171 
172  // Used in No Regret only, to avoid replaying the same sfx for attack twice in a row.
173  static int16 _lastAttackSound;
174  static int16 _lastLastAttackSound;
175 
176 };
177 
178 } // End of namespace Ultima8
179 } // End of namespace Ultima
180 
181 #endif
Definition: str.h:59
Definition: stream.h:77
Definition: process.h:34
Definition: detection.h:27
void saveData(Common::WriteStream *ws) override
save Process data
Definition: memstream.h:43
Definition: actor.h:37
Common::String dumpInfo() const override
dump some info about this process to a string
void terminate() override
terminate the process. This wakes up all processes waiting for it.
Definition: stream.h:385
static int16 getRandomAttackSoundRegret(const Actor *actor)
Definition: combat_dat.h:41
Definition: attack_process.h:41