D'angband  0.0.0
Deeangband
 全て クラス 名前空間 ファイル 関数 変数 型定義 列挙型 列挙値 フレンド マクロ定義 ページ
Creature.cpp
[詳解]
1 
9 #include "stdafx.h"
10 #include "Creature.h"
11 
12 namespace Deeangband
13 {
14 
16  {
17  // 0 // ロスト域
18  50, // Lv1デフォルト基準ソウル
19  100, // Lv2到達ソウル
20  130, // :
21  180,
22  260,
23  360,
24  480,
25  630,
26  880,
27  1280, // Lv10到達ソウル
28  1700,
29  2200,
30  2800,
31  3600,
32  4600,
33  6100,
34  8800,
35  10600,
36  12600,
37  15000, // Lv20到達ソウル
38  18000,
39  24000,
40  35000,
41  50000,
42  75000,
43  100000,
44  150000,
45  200000,
46  275000,
47  350000, // Lv30到達ソウル
48  450000,
49  550000,
50  700000,
51  1000000,
52  1500000,
53  2100000,
54  2700000,
55  3600000,
56  4700000,
57  6000000, // Lv40到達ソウル
58  7500000,
59  9000000,
60  11500000,
61  14500000,
62  19000000,
63  26000000,
64  33000000,
65  45000000,
66  60000000,
67  90000000, // Lv50到達ソウル
68  150000000,
69  230000000,
70  400000000,
71  620000000,
72  880000000,
73  1150000000,
74  1500000000,
75  3200000000,
76  6400000000,
77  11100000000, // Lv60到達ソウル
78  };
79 
80  Creature::Creature(std::map<TAG, boost::shared_ptr<Species>>::iterator speciesIt) : GameInstance(), HaveSymbol(), HaveHp(), HaveGameTime(), HavePosition(), HaveInventory(), HaveSize()
81  {
82  WipeData();
83  SetSpeciesData(&(*speciesIt->second));
84  }
85 
86  Creature::Creature(std::map<TAG, boost::shared_ptr<Species>>::iterator speciesIt, ID FieldID, Coordinates *coordinates) : GameInstance(), HaveSymbol(), HaveHp(), HaveGameTime(), HavePosition(fieldID, coordinates), HaveInventory(), HaveSize()
87  {
88  WipeData();
89  SetSpeciesData(&(*speciesIt->second));
90  }
91 
92  Creature::Creature(std::map<TAG, boost::shared_ptr<Species>>::iterator speciesIt, ID FieldID, int x, int y) : GameInstance(), HaveSymbol(), HaveHp(), HaveGameTime(), HavePosition(fieldID, x, y), HaveInventory(), HaveSize()
93  {
94  WipeData();
95  SetSpeciesData(&(*speciesIt->second));
96  }
97 
98  Creature::Creature(void)
99  {
100  WipeData();
101  }
102 
103  Creature::‾Creature(void)
104  {
105  }
106 
107  void Creature::SetSpeciesData(Species *speciesPtr)
108  {
109  std::normal_distribution<> distHeight(speciesPtr->GetHeight(), GameConstants::HeightStandardDeviation);
110  std::normal_distribution<> distWeight(speciesPtr->GetWeight(), GameConstants::WeightStandardDeviation);
111  this->name = speciesPtr->GetName();
112  this->symbol = speciesPtr->GetSymbol();
113  this->symbolColor = speciesPtr->GetSymbolColor();
114  this->currentSoul = this->maxSoul = speciesPtr->GetBaseSoul();
115  this->currentFeed = speciesPtr->GetBaseFeed() * 3 / 4;
116  this->maxFeed = speciesPtr->GetBaseFeed();
117  this->weight = distWeight(Dice::mt);
118  this->height = distHeight(Dice::mt);
119  this->campTag = TAG_VARIABLE;
120  this->firstRace = speciesPtr->GetFirstRaceTag();
121  this->secondRace = speciesPtr->GetSecondtRaceTag();
122  }
123 
124  void Creature::WipeData(void)
125  {
129  this->currentMp = this->maxMp = this->maxMaxMp = 10;
130  this->currentSoul = this->maxSoul = Creature::soulLevel[0];
131  this->currentDiscipilne.SetPoint(0, 0, 0, 0, 0);
132  this->firstRace = "";
133  this->secondRace = "";
134  this->height = 160.0f;
135  this->weight = 50.0f;
136  this->divineLevel = -1;
137  savings.Set(10, 10, 10);
138  this->currentFeed = this->maxFeed = 20000;
139 
140  currentStatus.Set(8, 8, 8, 8, 8, 8);
141  maxStatus.Set(8, 8, 8, 8, 8, 8);
142  maxMaxStatus.Set(20, 20, 20, 20, 20, 20);
143 
144  this->calcHPTable();
145  this->currentHp = this->maxHp = this->GetNorMaxHP();
146 
147  this->skillExpList.clear();
148 
149  this->turn = 0;
150  this->campTag = TAG_VARIABLE;
151 
152  //this->fieldID = -1;
153  //this->position.Set(0, 0);
154 
155  this->skillExpList.clear();
156 
157  this->symbol = '@';
158  this->symbolColor.SetColor(255, 255, 255, 255);
159  }
160 
161  bool Creature::IsAlive(void)
162  {
163  return this->currentHp > 0 && this->currentSoul > 0;
164  }
165 
166  bool Creature::TakeEffect(Effect *effectPtr, POWER amount)
167  {
168  if(effectPtr) this->CalcHP(-amount);
169  return false;
170  }
171 
172  void Creature::die(void)
173  {
174  }
175 
176  void Creature::calcHPTable(void)
177  {
178  int lev;
179  HP hitDice = this->GetSize();
180  HP minLine = hitDice * (CREATURE_MAX_LEVEL + 4) * 70 / 100;
181  HP maxLine = hitDice * (CREATURE_MAX_LEVEL + 4) * 130 / 100;
182 
183  if(hitDice <= 0) hitDice = 1;
184 
185  do
186  {
187  this->hpTable[0] = hitDice + Dice::Cast(3, hitDice);
188  for(lev = 0; lev < CREATURE_MAX_LEVEL - 1; lev++)
189  {
190  this->hpTable[lev + 1] = this->hpTable[lev] + Dice::Rand1(hitDice);
191  }
192  }
193  while(this->hpTable[CREATURE_MAX_LEVEL - 1] < minLine && this->hpTable[CREATURE_MAX_LEVEL - 1] > maxLine);
194  }
195 
196  void Creature::calcMP(MP amount)
197  {
198  this->currentMp += amount;
199  if(this->currentMp > this->maxMp) this->currentMp = this->maxMp;
200  if(this->currentMp < 0) this->currentMp = 0;
201  }
202 
203  void Creature::setMP(MP amount)
204  {
205  this->currentMp += amount;
206  if(this->currentMp > this->maxMp) this->currentMp = this->maxMp;
207  if(this->currentMp < 0) this->currentMp = 0;
208  }
209 
210  LEVEL Creature::GetLevel(void)
211  {
212  LEVEL level;
213  if(this->currentSoul <= 0) return 0;
214  if(this->currentSoul < Creature::soulLevel[1]) return 1;
215  for(level = 2; level < CREATURE_MAX_LEVEL; level++)
216  {
217  if(Creature::soulLevel[level - 1] > this->currentSoul) return level;
218  }
219  return level;
220  }
221 
222  HP Creature::GetNorMaxHP(void)
223  {
224  return this->hpTable[this->GetLevel()];
225  }
226 
227  MP Creature::GetCurMP(void)
228  {
229  return this->currentMp;
230  }
231 
232  MP Creature::GetMaxMP(void)
233  {
234  return this->maxMp;
235  }
236 
237  MP Creature::GetNorMaxMP(void)
238  {
239  return this->maxMaxMp;
240  }
241 
242  AC Creature::GetArmorSaving(void)
243  {
244  return this->savings.GetArmor();
245  }
246 
247  EV Creature::GetEvasionSaving(void)
248  {
249  return this->savings.GetEvasion();
250  }
251 
252  VO Creature::GetVolitionSaving(void)
253  {
254  return this->savings.GetVolition();
255  }
256 
257  SOUL Creature::GetCurrentSoul(void)
258  {
259  return this->currentSoul;
260  }
261 
262  SOUL Creature::GetMaxSoul(void)
263  {
264  return this->maxSoul;
265  }
266 
267  BASE_STATUS Creature::GetCurrentStatus(CREATURE_STATUS stat)
268  {
269  return currentStatus.Get(stat);
270  }
271 
272  BASE_STATUS Creature::GetMaxStatus(CREATURE_STATUS stat)
273  {
274  return maxStatus.Get(stat);
275  }
276 
277  BASE_STATUS Creature::GetMaxMAXStatus(CREATURE_STATUS stat)
278  {
279  return maxMaxStatus.Get(stat);
280  }
281 
282  DISCIPLINE_POINT Creature::GetDiscipilnePoint(DISCIPLINE_TYPE typ)
283  {
284  return this->currentDiscipilne.GetPoint(typ);
285  }
286 
287  DISCIPLINE_POINT Creature::GetDiscipilneRank(DISCIPLINE_TYPE typ)
288  {
289  return this->currentDiscipilne.GetRank(typ);
290  }
291 
292  void Creature::GainSoul(SOUL amount)
293  {
294  SOUL diff;
295  if(this->currentSoul < this->maxSoul)
296  {
297  diff = this->maxSoul - this->currentSoul;
298  if(diff < amount)
299  {
300  this->maxSoul += diff / 20;
301  this->currentSoul = this->maxSoul;
302  amount -= diff;
303  }
304  else
305  {
306  this->maxSoul += amount / 20;
307  this->currentSoul += amount;
308  amount = 0;
309  }
310  }
311  this->currentSoul += amount;
312  this->maxSoul += amount;
313  }
314 
315  void Creature::LostSoul(SOUL amount)
316  {
317  this->currentSoul -= amount;
318  this->maxSoul -= amount / 20;
319  if(this->currentSoul < 1) this->die();
320  }
321 
322  LEVEL Creature::GetDivineLevel(void)
323  {
324  return this->divineLevel;
325  }
326 
327  FEED Creature::GetCurrentFeedPoint(void)
328  {
329  return this->currentFeed;
330  }
331 
332  FEED Creature::GetMaxFeedPoint(void)
333  {
334  return this->maxFeed;
335  }
336 
337  void Creature::TurnProcess(void)
338  {
339  }
340 
341  void Creature::TimeProcess(void)
342  {
343  this->currentFeed -= 10;
344  }
345 
346  TURN Creature::GetTurn(void)
347  {
348  return this->turn;
349  }
350 
351  SKILL_EXP Creature::GetSkillExp(TAG tag)
352  {
353  if(this->skillExpList.count(tag)) return this->skillExpList[tag];
354  else return 0;
355  }
356 
357  TAG Creature::GetCampTag(void)
358  {
359  return this->campTag;
360  }
361 
362  bool Creature::Walk(DIRECTION dir)
363  {
364  this->position += Direction::DirectionVector[dir];
365  return true;
366  }
367 
368  bool Creature::Melee(Creature *targerPtr)
369  {
370  return true;
371  }
372 
373  bool Creature::PickUpItem(std::map<ID, boost::shared_ptr<Item>>::iterator itemIt)
374  {
375  return true;
376  }
377 
378  bool Creature::DropItem(std::map<ID, boost::shared_ptr<Item>>::iterator itemIt)
379  {
380  return true;
381  }
382 
383  bool Creature::EatItem(std::map<ID, boost::shared_ptr<Item>>::iterator itemIt)
384  {
385  return true;
386  }
387 
388  bool Creature::QuaffItem(std::map<ID, boost::shared_ptr<Item>>::iterator itemIt)
389  {
390  return true;
391  }
392 
393  bool Creature::ActivateItem(std::map<ID, boost::shared_ptr<Item>>::iterator itemIt)
394  {
395  return true;
396  }
397 
398  bool Creature::ThrowItem(std::map<ID, boost::shared_ptr<Item>>::iterator itemIt)
399  {
400  return true;
401  }
402 
403  bool Creature::ReadItem(std::map<ID, boost::shared_ptr<Item>>::iterator itemIt)
404  {
405  return true;
406  }
407 
408  void Creature::XMLSave(std::string filename)
409  {
410  std::ofstream ofs(filename);
411  assert(ofs);
412  boost::archive::xml_oarchive oa(ofs);
413  oa << boost::serialization::make_nvp("Creature", *this);
414  }
415 
416 }
Discipline currentDiscipilne
現在の修養値
Definition: Creature.h:86
int POWER
効力
Definition: Deeangband.h:155
CREATURE_STATUS
クリーチャーの基礎能力値6種の列挙体
Definition: Deeangband.h:95
HP currentHp
現在のHP
Definition: HaveHp.h:42
TAG secondRace
種族タグ2
Definition: Creature.h:84
MP currentMp
現在のMP
Definition: Creature.h:74
int TURN
ターン数
Definition: Deeangband.h:158
int ID
ゲーム要素ID
Definition: Deeangband.h:143
SOUL maxSoul
ソウル最大到達値
Definition: Creature.h:78
int AC
頑健性
Definition: Deeangband.h:140
std::string TAG
ゲーム要素文字列ID
Definition: Deeangband.h:144
SOUL currentSoul
現在のソウル値
Definition: Creature.h:77
HP hpTable[CREATURE_MAX_LEVEL]
ヒットダイスに基づき生成されたレベル毎の基本HP
Definition: Creature.h:102
int LEVEL
LEVELの変数型
Definition: Deeangband.h:134
ゲーム中のクリーチャーと付随要素のプロトタイプ
int MP
MPの変数型
Definition: Deeangband.h:136
virtual void GameInstance::WipeData(void)
ダミーデータによる初期化
Definition: GameInstance.h:62
std::map< TAG, SKILL_EXP > skillExpList
スキル経験値リスト
Definition: Creature.h:95
HP maxHp
現在の最大HP
Definition: HaveHp.h:43
Coordinates position
所在座標
Definition: HavePosition.h:45
LEVEL divineLevel
神性レベル
Definition: Creature.h:87
DISCIPLINE_TYPE
修養属性の列挙体
Definition: Discipline.h:20
FEED maxFeed
最大滋養値
Definition: Creature.h:81
void HaveSize::WipeData(void)
HaveSizeクラスのデータ消去
BaseStatusTable maxMaxStatus
限界のステータス
Definition: Creature.h:91
int DISCIPLINE_POINT
修養値の変数型
Definition: Deeangband.h:139
int SKILL_EXP
スキル経験値
Definition: Deeangband.h:160
static SOUL soulLevel[CREATURE_MAX_LEVEL]
必要ソウルレベルテーブル
Definition: Creature.h:72
int64_t SOUL
ソウルの変数型
Definition: Deeangband.h:138
標準のシステム インクルード ファイルのインクルード ファイル、または 参照回数が多く、かつあまり変更さ...
#define TAG_VARIABLE
要素可変タグ
Definition: Deeangband.h:18
int VO
意志力
Definition: Deeangband.h:142
MP maxMp
現在の最大MP
Definition: Creature.h:75
TAG firstRace
種族タグ1
Definition: Creature.h:83
int FEED
滋養度の変数型
Definition: Deeangband.h:137
#define CREATURE_MAX_LEVEL
神格込み最大レベル
Definition: Deeangband.h:13
BaseStatusTable maxStatus
通常のステータス
Definition: Creature.h:90
void HaveSymbol::WipeData(void)
HaveSymbolデータ初期化
MP maxMaxMp
本来の最大MP
Definition: Creature.h:76
TURN turn
総ターン数
Definition: HaveGameTime.h:46
static double WeightStandardDeviation
Definition: GameConstants.h:49
Color symbolColor
シンボルカラー
Definition: HaveSymbol.h:48
static Coordinates DirectionVector[]
方角ベクトルの定義
Definition: Direction.h:19
int BASE_STATUS
基礎能力値の変数型
Definition: Deeangband.h:131
TAG campTag
所属陣営タグ
Definition: Creature.h:97
int HP
HPの変数型
Definition: Deeangband.h:135
SavingTable savings
セービング
Definition: Creature.h:93
SYMBOL symbol
シンボルキャラ
Definition: HaveSymbol.h:47
BaseStatusTable currentStatus
現在のステータス
Definition: Creature.h:89
static double HeightStandardDeviation
Definition: GameConstants.h:48
DIRECTION
Definition: Deeangband.h:78
int EV
回避力
Definition: Deeangband.h:141
FEED currentFeed
現在滋養値
Definition: Creature.h:80