… | |
… | |
92 | animate_object (object *op, int dir) |
92 | animate_object (object *op, int dir) |
93 | { |
93 | { |
94 | int max_state; /* Max animation state object should be drawn in */ |
94 | int max_state; /* Max animation state object should be drawn in */ |
95 | int base_state; /* starting index # to draw from */ |
95 | int base_state; /* starting index # to draw from */ |
96 | |
96 | |
97 | if (!op->animation_id || !NUM_ANIMATIONS (op)) |
97 | if (!op->animation_id || !op->anim_frames ()) |
98 | { |
98 | { |
99 | LOG (llevError, "Object %s lacks animation.\n", op->debug_desc ()); |
99 | LOG (llevError, "Object %s lacks animation.\n", op->debug_desc ()); |
100 | op->clr_flag (FLAG_ANIMATE); |
100 | op->clr_flag (FLAG_ANIMATE); |
101 | return; |
101 | return; |
102 | } |
102 | } |
103 | |
103 | |
104 | if (op->head_ () != op) |
104 | if (op->head_ () != op) |
105 | { |
105 | { |
106 | dir = op->head->direction; |
106 | dir = op->head->direction; |
107 | |
107 | |
108 | if (NUM_ANIMATIONS (op) == NUM_ANIMATIONS (op->head)) |
108 | if (op->anim_frames () == op->head->anim_frames ()) |
109 | op->state = op->head->state; |
109 | op->state = op->head->state; |
110 | else |
110 | else |
111 | ++op->state; |
111 | ++op->state; |
112 | } |
112 | } |
113 | else |
113 | else |
114 | ++op->state; /* increase draw state */ |
114 | ++op->state; /* increase draw state */ |
115 | |
115 | |
116 | /* If object is turning, then max animation state is half through the |
116 | /* If object is turning, then max animation state is half through the |
117 | * animations. Otherwise, we can use all the animations. |
117 | * animations. Otherwise, we can use all the animations. |
118 | */ |
118 | */ |
119 | max_state = NUM_ANIMATIONS (op) / NUM_FACINGS (op); |
119 | max_state = op->anim_frames () / op->anim_facings (); |
120 | base_state = 0; |
120 | base_state = 0; |
121 | /* at least in the older animations that used is_turning, the first half |
121 | /* at least in the older animations that used is_turning, the first half |
122 | * of the animations were left facing, the second half right facing. |
122 | * of the animations were left facing, the second half right facing. |
123 | * Note in old the is_turning, it was set so that the animation for a monster |
123 | * Note in old the is_turning, it was set so that the animation for a monster |
124 | * was always towards the enemy - now it is whatever direction the monster |
124 | * was always towards the enemy - now it is whatever direction the monster |
125 | * is facing. |
125 | * is facing. |
126 | */ |
126 | */ |
127 | |
127 | |
128 | if (dir > 0) |
128 | if (dir > 0) |
129 | switch (NUM_FACINGS (op)) |
129 | switch (op->anim_facings ()) |
130 | { |
130 | { |
131 | case 2: base_state = ((dir - 1) / (8 / 2)) * (NUM_ANIMATIONS (op) / 2); break; |
131 | case 2: base_state = ((dir - 1) / (8 / 2)) * (op->anim_frames () / 2); break; |
132 | case 4: base_state = ((dir - 1) / (8 / 4)) * (NUM_ANIMATIONS (op) / 4); break; |
132 | case 4: base_state = ((dir - 1) / (8 / 4)) * (op->anim_frames () / 4); break; |
133 | case 8: base_state = ((dir - 1) / (8 / 8)) * (NUM_ANIMATIONS (op) / 8); break; |
133 | case 8: base_state = ((dir - 1) / (8 / 8)) * (op->anim_frames () / 8); break; |
134 | } |
134 | } |
135 | else |
135 | else |
136 | base_state = 0; |
136 | base_state = 0; |
137 | |
137 | |
138 | /* If beyond drawable states, reset */ |
138 | /* If beyond drawable states, reset */ |
139 | if (op->state >= max_state) |
139 | if (op->state >= max_state) |
140 | op->state = 0; |
140 | op->state = 0; |
141 | |
141 | |
142 | SET_ANIMATION (op, op->state + base_state); |
142 | op->set_anim_frame (op->state + base_state); |
143 | |
143 | |
144 | if (op->face == blank_face) |
144 | if (op->face == blank_face) |
145 | op->invisible = 1; |
145 | op->invisible = 1; |
146 | |
146 | |
147 | /* This block covers monsters (eg, pixies) which are supposed to |
147 | /* This block covers monsters (eg, pixies) which are supposed to |