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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "ultima/ultima8/misc/pent_include.h"
24 #include "ultima/ultima8/world/actors/animation.h"
25 #include "ultima/ultima8/ultima8.h"
26 
27 namespace Ultima {
28 namespace Ultima8 {
29 namespace Animation {
30 
isCombatAnim(const Sequence anim)31 bool isCombatAnim(const Sequence anim) {
32 	if (GAME_IS_U8)
33 		return isCombatAnimU8(anim);
34 	else
35 		return isCombatAnimCru(anim);
36 }
37 
isCombatAnimU8(const Sequence anim)38 bool isCombatAnimU8(const Sequence anim) {
39 	switch (anim) {
40 	case combatStand:
41 	case readyWeapon:
42 	case advance:
43 	case retreat:
44 	case attack:
45 	case kick:
46 	case startBlock:
47 	case stopBlock:
48 		return true;
49 	default:
50 		return false;
51 	}
52 }
53 
isCastAnimU8(const Sequence anim)54 bool isCastAnimU8(const Sequence anim) {
55 	switch (anim) {
56 	case cast1:
57 	case cast2:
58 	case cast3:
59 	case cast4:
60 	case cast5:
61 		return true;
62 	default:
63 		return false;
64 	}
65 }
66 
isCombatAnimCru(const Sequence anim)67 bool isCombatAnimCru(const Sequence anim) {
68 	switch (anim & ~crusaderAbsoluteAnimFlag) {
69 	case combatStand:
70 	case combatStandSmallWeapon:
71 	case combatStandLargeWeapon:
72 	case readyWeapon:
73 	case advance:
74 	case retreat:
75 	case attack:
76 	case reloadSmallWeapon:
77 	case kick:
78 	case kneel:
79 	case kneelStartCru:
80 	case kneelEndCru:
81 	case kneelAndFire:
82 	case brightFireLargeWpn:
83 	case kneelCombatRollLeft:
84 	case kneelCombatRollRight:
85 	case combatRollLeft:
86 	case combatRollRight:
87 	case slideLeft:
88 	case slideRight:
89 	case startRun:
90 	case startRunLargeWeapon:
91 	case run:
92 	case stopRunningAndDrawSmallWeapon:
93 		return true;
94 	default:
95 		return false;
96 	}
97 }
98 
99 /** determines if we need to ready or unready our weapon */
checkWeapon(const Sequence nextanim,const Sequence lastanim)100 Sequence checkWeapon(const Sequence nextanim,
101 					 const Sequence lastanim) {
102 	Sequence anim = nextanim;
103 	if (isCombatAnim(nextanim) && !isCombatAnim(lastanim)) {
104 		anim = readyWeapon;
105 	} else if (!isCombatAnim(nextanim) && isCombatAnim(lastanim)) {
106 		anim = unreadyWeapon;
107 	}
108 	return anim;
109 }
110 
111 } // End of namespace Animation
112 } // End of namespace Ultima8
113 } // End of namespace Ultima
114