xoreos  0.0.5
types.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos 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 xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/common/util.h"
26 
27 #include "src/engines/nwn/types.h"
28 
29 namespace Engines {
30 
31 namespace NWN {
32 
34  if (lawChaos >= 70)
35  return kAlignmentLawful;
36  if (lawChaos <= 30)
37  return kAlignmentChaotic;
38 
39  return kAlignmentNeutral;
40 }
41 
43  if (goodEvil >= 70)
44  return kAlignmentGood;
45  if (goodEvil <= 30)
46  return kAlignmentEvil;
47 
48  return kAlignmentNeutral;
49 }
50 
51 struct AnimationName {
53  const char *nameComplex, *nameSimple;
54 };
55 
58  const char *name;
59 };
60 
62  static const AnimationName kAnimations[] = {
63  { kAnimationLoopingPause , "pause1" , "cpause1" },
64  { kAnimationLoopingPause2 , "pause2" , "cpause1" },
65  { kAnimationLoopingListen , "listen" , "" },
66  { kAnimationLoopingMeditate , "meditate" , "" },
67  { kAnimationLoopingWorship , "worship" , "" },
68  { kAnimationLoopingLookFar , "lookfar" , "" },
69  { kAnimationLoopingSitChair , "sit" , "" },
70  { kAnimationLoopingSitCross , "sitcrossps", "" },
71  { kAnimationLoopingTalkNormal , "tlknorm" , "" },
72  { kAnimationLoopingTalkPleading , "tlkplead" , "" },
73  { kAnimationLoopingTalkForceful , "tlkforce" , "" },
74  { kAnimationLoopingTalkLaughing , "tlklaugh" , "" },
75  { kAnimationLoopingGetLow , "getlowlp" , "" },
76  { kAnimationLoopingGetMid , "getmidlp" , "cgetmidlp" },
77  { kAnimationLoopingPauseTired , "pausetrd" , "" },
78  { kAnimationLoopingPauseDrunk , "pausepsn" , "" },
79  { kAnimationLoopingDeadFront , "deadfnt" , "cdead" },
80  { kAnimationLoopingDeadBack , "deadbck" , "cdead" },
81  { kAnimationLoopingConjure1 , "conjure1" , "cconjure1" },
82  { kAnimationLoopingConjure2 , "conjure2" , "cconjure1" },
83  { kAnimationLoopingSpasm , "spasm" , "cspasm" },
84  { kAnimationLoopingCustom1 , "" , "" },
85  { kAnimationLoopingCustom2 , "" , "" },
86  { kAnimationLoopingCustom3 , "" , "" },
87  { kAnimationLoopingCustom4 , "" , "" },
88  { kAnimationLoopingCustom5 , "" , "" },
89  { kAnimationLoopingCustom6 , "" , "" },
90  { kAnimationLoopingCustom7 , "" , "" },
91  { kAnimationLoopingCustom8 , "" , "" },
92  { kAnimationLoopingCustom9 , "" , "" },
93  { kAnimationLoopingCustom10 , "" , "" },
94  { kAnimationFireForgetHeadTurnLeft , "hturnl" , "chturnl" },
95  { kAnimationFireForgetHeadTurnRight , "hturnr" , "chturnr" },
96  { kAnimationFireForgetPauseScratchHead, "pausesh" , "" },
97  { kAnimationFireForgetPauseBored , "pausebrd" , "" },
98  { kAnimationFireForgetSalute , "salute" , "" },
99  { kAnimationFireForgetBow , "bow" , "" },
100  { kAnimationFireForgetSteal , "steal" , "" },
101  { kAnimationFireForgetGreeting , "greeting" , "" },
102  { kAnimationFireForgetTaunt , "taunt" , "ctaunt" },
103  { kAnimationFireForgetVictory1 , "victoryfr" , "" },
104  { kAnimationFireForgetVictory2 , "victorymg" , "" },
105  { kAnimationFireForgetVictory3 , "victoryth" , "" },
106  { kAnimationFireForgetRead , "read" , "" },
107  { kAnimationFireForgetDrink , "drink" , "" },
108  { kAnimationFireForgetDodgeSide , "dodges" , "cdodges" },
109  { kAnimationFireForgetDodgeDuck , "dodgelr" , "cdodgelr" },
110  { kAnimationFireForgetSpasm , "spasm" , "cspasm" }
111  };
112 
113  for (size_t i = 0; i < ARRAYSIZE(kAnimations); i++)
114  if (animation == kAnimations[i].animation)
115  return simple ? kAnimations[i].nameSimple : kAnimations[i].nameComplex;
116 
117  return "";
118 }
119 
121  static const TalkAnimationName kTalkAnimations[] = {
122  { kTalkAnimationDefault , "tlknorm" },
123  { kTalkAnimationNormal , "tlknorm" },
124  { kTalkAnimationPleading, "tlkplead" },
125  { kTalkAnimationForceful, "tlkforce" },
126  { kTalkAnimationLaugh , "tlklaugh" }
127  };
128 
129  for (size_t i = 0; i < ARRAYSIZE(kTalkAnimations); i++)
130  if (animation == kTalkAnimations[i].animation)
131  return kTalkAnimations[i].name;
132 
133  return "";
134 }
135 
137  static const AnimationName kAnimations[] = {
138  { kAnimationPlaceableActivate , "off2on" , "" },
139  { kAnimationPlaceableDeactivate , "on2off" , "" },
140  { kAnimationPlaceableOpen , "close2open", "" },
141  { kAnimationPlaceableClose , "open2close", "" }
142  };
143 
144  for (size_t i = 0; i < ARRAYSIZE(kAnimations); i++)
145  if (animation == kAnimations[i].animation)
146  return kAnimations[i].nameComplex;
147 
148  return "";
149 }
150 
151 Common::UString getDoorAnimationName(Animation animation, bool alternate) {
152  static const AnimationName kAnimations[] = {
153  { kAnimationDoorClose , "closing1", "closing2" },
154  { kAnimationDoorOpen1 , "opening1", "opening1" },
155  { kAnimationDoorOpen2 , "opening2", "opening2" },
156  { kAnimationDoorDestroy , "die" , "die" }
157  };
158 
159  for (size_t i = 0; i < ARRAYSIZE(kAnimations); i++)
160  if (animation == kAnimations[i].animation)
161  return alternate ? kAnimations[i].nameSimple : kAnimations[i].nameComplex;
162 
163  return "";
164 }
165 
166 bool isAnimationLooping(Animation animation) {
167  return (animation >= kAnimationLoopingPause) && (animation <= kAnimationLoopingCustom10);
168 }
169 
170 } // End of namespace NWN
171 
172 } // End of namespace Engines
Common::UString getDoorAnimationName(Animation animation, bool alternate)
Return the name (as found in the models) of a specific door animation.
Definition: types.cpp:151
A class holding an UTF-8 string.
Definition: ustring.h:48
Common::UString getCreatureAnimationName(Animation animation, bool simple)
Return the name (as found in the models) of a specific creature animation.
Definition: types.cpp:61
uint8_t uint8
Definition: types.h:200
Basic Neverwinter Nights type definitions.
#define ARRAYSIZE(x)
Macro which determines the number of entries in a fixed size array.
Definition: util.h:131
Utility templates and functions.
Alignment getAlignmentGoodEvil(uint8 goodEvil)
Definition: types.cpp:42
const char * nameComplex
Definition: types.cpp:53
bool isAnimationLooping(Animation animation)
Return true if the specified animation allows looping.
Definition: types.cpp:166
Common::UString getPlaceableAnimationName(Animation animation)
Return the name (as found in the models) of a specific placeable animation.
Definition: types.cpp:136
Alignment getAlignmentLawChaos(uint8 lawChaos)
Definition: types.cpp:33
const char * nameSimple
Definition: types.cpp:53
Common::UString getCreatureTalkAnimationName(TalkAnimation animation)
Return the name (as found in the models) of a specific creature talk animation.
Definition: types.cpp:120