1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002-2003,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002-2003,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
30 | std::vector<animation> animations; |
30 | std::vector<animation> animations; |
31 | |
31 | |
32 | void |
32 | void |
33 | animation::resize (int new_size) |
33 | animation::resize (int new_size) |
34 | { |
34 | { |
35 | sfree <faceidx> (faces, num_animations); |
35 | sfree<faceidx> (faces, num_animations); |
36 | num_animations = new_size; |
36 | num_animations = new_size; |
37 | faces = salloc<faceidx> (num_animations); |
37 | faces = salloc<faceidx> (num_animations); |
38 | } |
38 | } |
39 | |
39 | |
40 | animation & |
40 | animation & |
… | |
… | |
128 | * Note in old the is_turning, it was set so that the animation for a monster |
128 | * Note in old the is_turning, it was set so that the animation for a monster |
129 | * was always towards the enemy - now it is whatever direction the monster |
129 | * was always towards the enemy - now it is whatever direction the monster |
130 | * is facing. |
130 | * is facing. |
131 | */ |
131 | */ |
132 | |
132 | |
|
|
133 | if (dir > 0) |
133 | if (NUM_FACINGS (op) == 2) |
134 | switch (NUM_FACINGS (op)) |
134 | { |
135 | { |
135 | if (dir < 5) |
136 | case 2: base_state = ((dir - 1) / (8 / 2)) * (NUM_ANIMATIONS (op) / 2); break; |
|
|
137 | case 4: base_state = ((dir - 1) / (8 / 4)) * (NUM_ANIMATIONS (op) / 4); break; |
|
|
138 | case 8: base_state = ((dir - 1) / (8 / 8)) * (NUM_ANIMATIONS (op) / 8); break; |
|
|
139 | } |
|
|
140 | else |
136 | base_state = 0; |
141 | base_state = 0; |
137 | else |
|
|
138 | base_state = NUM_ANIMATIONS (op) / 2; |
|
|
139 | } |
|
|
140 | else if (NUM_FACINGS (op) == 4) |
|
|
141 | { |
|
|
142 | if (dir == 0) |
|
|
143 | base_state = 0; |
|
|
144 | else |
|
|
145 | base_state = ((dir - 1) / 2) * (NUM_ANIMATIONS (op) / 4); |
|
|
146 | } |
|
|
147 | else if (NUM_FACINGS (op) == 8) |
|
|
148 | { |
|
|
149 | if (dir == 0) |
|
|
150 | base_state = 0; |
|
|
151 | else |
|
|
152 | base_state = (dir - 1) * (NUM_ANIMATIONS (op) / 8); |
|
|
153 | } |
|
|
154 | |
142 | |
155 | /* If beyond drawable states, reset */ |
143 | /* If beyond drawable states, reset */ |
156 | if (op->state >= max_state) |
144 | if (op->state >= max_state) |
157 | op->state = 0; |
145 | op->state = 0; |
158 | |
146 | |