1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2003 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef CHARANIMATIONS_H
22 #define CHARANIMATIONS_H
24 #include "RGBAColor.h"
27 #include "Animation.h"
38 #define AV_CIRCLESIZE 5
39 #define AV_USE_PALETTE 6
44 #define IE_ANI_ATTACK 0
45 #define IE_ANI_AWAKE 1
47 #define IE_ANI_CONJURE 3
48 #define IE_ANI_DAMAGE 4
50 #define IE_ANI_HEAD_TURN 6
51 #define IE_ANI_READY 7
52 #define IE_ANI_SHOOT 8
53 #define IE_ANI_TWITCH 9
54 #define IE_ANI_WALK 10
55 #define IE_ANI_ATTACK_SLASH 11
56 #define IE_ANI_ATTACK_BACKSLASH 12
57 #define IE_ANI_ATTACK_JAB 13
58 #define IE_ANI_EMERGE 14
59 #define IE_ANI_HIDE 15
60 #define IE_ANI_RUN 15 //pst has no hide, i hope
61 #define IE_ANI_SLEEP 16
62 #define IE_ANI_GET_UP 17
63 #define IE_ANI_PST_START 18
65 //BG2, IWD animation types
66 #define IE_ANI_CODE_MIRROR 0
67 #define IE_ANI_ONE_FILE 1
68 #define IE_ANI_FOUR_FILES 2
69 #define IE_ANI_TWO_FILES 3
70 #define IE_ANI_CODE_MIRROR_2 4
71 #define IE_ANI_SIX_FILES_2 5 //MOGR
72 #define IE_ANI_TWENTYTWO 6
74 #define IE_ANI_SIX_FILES 8 //MCAR/MWYV
75 #define IE_ANI_TWO_FILES_3 9 //iwd animations
76 #define IE_ANI_TWO_FILES_2 10 //low res bg1 anim
77 #define IE_ANI_FOUR_FRAMES 11 //wyvern anims
78 #define IE_ANI_NINE_FRAMES 12 //dragon anims
79 #define IE_ANI_FRAGMENT 13 //fragment animation
80 #define IE_ANI_FOUR_FILES_2 14 //METT
81 #define IE_ANI_CODE_MIRROR_3 15 //MSPS
82 #define IE_ANI_TWO_FILES_3B 16 //iwd animations (eg. MBBM)
85 #define IE_ANI_PST_ANIMATION_1 56 //full animation
86 #define IE_ANI_PST_GHOST 57 //no orientations
87 #define IE_ANI_PST_STAND 58 //has orientations
88 #define IE_ANI_PST_ANIMATION_2 59 //full animation std-->stc
89 #define IE_ANI_PST_ANIMATION_3 60 //full animation stc-->std
92 #define IE_ANI_NO_ARMOR 0
93 #define IE_ANI_LIGHT_ARMOR 1
94 #define IE_ANI_MEDIUM_ARMOR 2
95 #define IE_ANI_HEAVY_ARMOR 3
97 #define IE_ANI_WEAPON_1H 0
98 #define IE_ANI_WEAPON_2H 1
99 #define IE_ANI_WEAPON_2W 2
101 #define IE_ANI_RANGED_BOW 0
102 #define IE_ANI_RANGED_XBOW 1
103 #define IE_ANI_RANGED_THROW 2
105 struct AvatarStruct
{
106 /* entries from avatars.2da */
108 unsigned int PaletteType
;
109 ieResRef Prefixes
[4];
110 unsigned char AnimationType
;
111 unsigned char CircleSize
;
114 /* comes from bloodclr.2da */
117 /* resdata.ini entries */
118 unsigned int WalkScale
; /* 1000 / walkscale */
119 unsigned int RunScale
; /* 1000 / runscale */
122 /* comes from walksnd.2da */
124 ieByte WalkSoundCount
;
127 struct EquipResRefData
;
129 class GEM_EXPORT CharAnimations
{
131 Animation
** Anims
[MAX_ANIMS
][MAX_ORIENT
];
136 const ieDword
*Colors
; //these are the custom color indices
137 RGBModifier ColorMods
[32]; // color modification effects
138 unsigned long lastModUpdate
;
139 RGBModifier GlobalColorMod
; // global color modification effect
142 Palette
* modifiedPalette
[4];
143 unsigned int AvatarsRowNum
;
144 unsigned char ArmorType
, WeaponType
, RangedType
;
146 ieResRef PaletteResRef
;
147 unsigned char nextStanceID
, StanceID
;
148 bool autoSwitchOnEnd
;
151 CharAnimations(unsigned int AnimID
, ieDword ArmourLevel
);
152 ~CharAnimations(void);
153 static void ReleaseMemory();
154 void SetArmourLevel(int ArmourLevel
);
155 void SetRangedType(int Ranged
);
156 void SetWeaponType(int WeaponType
);
157 void SetHelmetRef(const char* ref
);
158 void SetWeaponRef(const char* ref
);
159 void SetOffhandRef(const char* ref
);
160 void SetupColors(PaletteType type
);
161 void SetColors(const ieDword
*Colors
);
162 void LockPalette(const ieDword
*Colors
);
164 // returns an array of animations of size GetTotalPartCount()
165 Animation
** GetAnimation(unsigned char Stance
, unsigned char Orient
);
166 int GetTotalPartCount() const;
167 const int* GetZOrder(unsigned char Orient
);
169 // returns Palette for a given part (unlocked)
170 Palette
* GetPartPalette(int part
); // TODO: clean this up
172 public: //attribute functions
173 static int GetAvatarsCount();
174 static AvatarStruct
*GetAvatarStruct(int RowNum
);
175 unsigned int GetAnimationID() const;
176 int GetCircleSize() const;
177 int NoPalette() const;
178 int GetAnimType() const;
180 int GetBloodColor() const;
181 const ieResRef
&GetWalkSound() const;
182 int GetWalkSoundCount() const;
183 void PulseRGBModifiers();
187 void InitAvatarsTable();
188 int GetActorPartCount() const;
189 void AddPSTSuffix(char* ResRef
, unsigned char AnimID
,
190 unsigned char& Cycle
, unsigned char Orient
);
191 void AddFFSuffix(char* ResRef
, unsigned char AnimID
,
192 unsigned char& Cycle
, unsigned char Orient
, int Part
);
193 void AddNFSuffix(char* ResRef
, unsigned char AnimID
,
194 unsigned char& Cycle
, unsigned char Orient
, int Part
);
195 void AddVHR2Suffix(char* ResRef
, unsigned char AnimID
,
196 unsigned char& Cycle
, unsigned char Orient
);
197 void AddVHRSuffix(char* ResRef
, unsigned char AnimID
,
198 unsigned char& Cycle
, unsigned char Orient
, EquipResRefData
*& equip
);
199 void AddVHR3Suffix(char* ResRef
, unsigned char AnimID
,
200 unsigned char& Cycle
, unsigned char Orient
);
201 void GetVHREquipmentRef(char* ResRef
, unsigned char& Cycle
,
202 const char* equipRef
, bool offhand
, EquipResRefData
* equip
);
203 void AddSixSuffix(char* ResRef
, unsigned char AnimID
,
204 unsigned char& Cycle
, unsigned char Orient
);
205 void AddMHRSuffix(char* ResRef
, unsigned char AnimID
,
206 unsigned char& Cycle
, unsigned char Orient
, EquipResRefData
*& equip
);
207 void GetMHREquipmentRef(char* ResRef
, unsigned char& Cycle
,
208 const char* equipRef
, bool offhand
, EquipResRefData
* equip
);
209 void AddMMRSuffix(char* ResRef
, unsigned char AnimID
,
210 unsigned char& Cycle
, unsigned char Orient
);
211 void AddMMR2Suffix(char* ResRef
, unsigned char AnimID
,
212 unsigned char& Cycle
, unsigned char Orient
);
213 void AddTwoFileSuffix(char* ResRef
, unsigned char AnimID
,
214 unsigned char& Cycle
, unsigned char Orient
);
215 void AddLRSuffix(char* ResRef
, unsigned char AnimID
,
216 unsigned char& Cycle
, unsigned char Orient
, EquipResRefData
*& equip
);
217 void AddLRSuffix2( char* ResRef
, unsigned char StanceID
,
218 unsigned char& Cycle
, unsigned char Orient
, EquipResRefData
*&EquipData
);
219 void GetLREquipmentRef(char* ResRef
, unsigned char& Cycle
,
220 const char* equipRef
, bool offhand
, EquipResRefData
* equip
);
221 void AddLR2Suffix(char* ResRef
, unsigned char AnimID
,
222 unsigned char& Cycle
, unsigned char Orient
);
223 void AddLR3Suffix(char* ResRef
, unsigned char AnimID
,
224 unsigned char& Cycle
, unsigned char Orient
);
225 void GetAnimResRef(unsigned char AnimID
, unsigned char Orient
,
226 char* ResRef
, unsigned char& Cycle
, int Part
, EquipResRefData
*& equip
);
227 void GetEquipmentResRef(const char* equipRef
, bool offhand
,
228 char* ResRef
, unsigned char& Cycle
, EquipResRefData
* equip
);