1 | |
1 | |
2 | /* |
2 | /* |
3 | * static char *rcsid_anim_c = |
3 | * static char *rcsid_anim_c = |
4 | * "$Id: anim.C,v 1.7 2006/09/10 16:00:23 root Exp $"; |
4 | * "$Id: anim.C,v 1.9 2006/09/12 19:20:05 root Exp $"; |
5 | */ |
5 | */ |
6 | |
6 | |
7 | /* |
7 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
8 | CrossFire, A Multiplayer game for X-windows |
9 | |
9 | |
… | |
… | |
68 | /* set the name so we don't try to dereferance null. |
68 | /* set the name so we don't try to dereferance null. |
69 | * Put # at start so it will be first in alphabetical |
69 | * Put # at start so it will be first in alphabetical |
70 | * order. |
70 | * order. |
71 | */ |
71 | */ |
72 | { |
72 | { |
73 | Animations |
73 | Animations anim0; |
74 | anim0; |
|
|
75 | |
74 | |
76 | anim0.name = "###none"; |
75 | anim0.name = "###none"; |
77 | anim0.num_animations = 1; |
76 | anim0.num_animations = 1; |
78 | anim0.faces = (Fontindex *) malloc (sizeof (Fontindex)); |
77 | anim0.faces = (Fontindex *) malloc (sizeof (Fontindex)); |
79 | anim0.faces[0] = 0; |
78 | anim0.faces[0] = 0; |
… | |
… | |
102 | LOG (llevError, "Didn't get a mina before %s\n", buf); |
101 | LOG (llevError, "Didn't get a mina before %s\n", buf); |
103 | num_frames = 0; |
102 | num_frames = 0; |
104 | } |
103 | } |
105 | num_animations++; |
104 | num_animations++; |
106 | |
105 | |
107 | Animations |
106 | Animations anim; |
108 | anim; |
|
|
109 | |
107 | |
110 | anim.name = buf + 5; |
108 | anim.name = buf + 5; |
111 | anim.num = num_animations; /* for bsearch */ |
109 | anim.num = num_animations; /* for bsearch */ |
112 | anim.facings = 1; |
110 | anim.facings = 1; |
113 | animations.push_back (anim); |
111 | animations.push_back (anim); |
… | |
… | |
190 | int |
188 | int |
191 | base_state; /* starting index # to draw from */ |
189 | base_state; /* starting index # to draw from */ |
192 | |
190 | |
193 | if (!op->animation_id || !NUM_ANIMATIONS (op)) |
191 | if (!op->animation_id || !NUM_ANIMATIONS (op)) |
194 | { |
192 | { |
195 | LOG (llevError, "Object lacks animation.\n"); |
193 | LOG (llevError, "Object %s lacks animation.\n", op->debug_desc ()); |
196 | dump_object (op); |
|
|
197 | return; |
194 | return; |
198 | } |
195 | } |
|
|
196 | |
199 | if (op->head) |
197 | if (op->head) |
200 | { |
198 | { |
201 | dir = op->head->direction; |
199 | dir = op->head->direction; |
202 | |
200 | |
203 | if (NUM_ANIMATIONS (op) == NUM_ANIMATIONS (op->head)) |
201 | if (NUM_ANIMATIONS (op) == NUM_ANIMATIONS (op->head)) |
204 | op->state = op->head->state; |
202 | op->state = op->head->state; |
205 | else |
203 | else |
206 | ++op->state; |
204 | ++op->state; |
207 | } |
205 | } |
208 | else |
206 | else |
209 | { |
|
|
210 | ++op->state; /* increase draw state */ |
207 | ++op->state; /* increase draw state */ |
211 | } |
|
|
212 | |
208 | |
213 | /* If object is turning, then max animation state is half through the |
209 | /* If object is turning, then max animation state is half through the |
214 | * animations. Otherwise, we can use all the animations. |
210 | * animations. Otherwise, we can use all the animations. |
215 | */ |
211 | */ |
216 | max_state = NUM_ANIMATIONS (op) / NUM_FACINGS (op); |
212 | max_state = NUM_ANIMATIONS (op) / NUM_FACINGS (op); |
… | |
… | |
219 | * of the animations were left facing, the second half right facing. |
215 | * of the animations were left facing, the second half right facing. |
220 | * Note in old the is_turning, it was set so that the animation for a monster |
216 | * Note in old the is_turning, it was set so that the animation for a monster |
221 | * was always towards the enemy - now it is whatever direction the monster |
217 | * was always towards the enemy - now it is whatever direction the monster |
222 | * is facing. |
218 | * is facing. |
223 | */ |
219 | */ |
|
|
220 | |
224 | if (NUM_FACINGS (op) == 2) |
221 | if (NUM_FACINGS (op) == 2) |
225 | { |
222 | { |
226 | if (dir < 5) |
223 | if (dir < 5) |
227 | base_state = 0; |
224 | base_state = 0; |
228 | else |
225 | else |