… | |
… | |
244 | pl->refcnt_chk (); |
244 | pl->refcnt_chk (); |
245 | |
245 | |
246 | if (!pl->ob || !pl->ns || !pl->ob->active) |
246 | if (!pl->ob || !pl->ns || !pl->ob->active) |
247 | continue; |
247 | continue; |
248 | |
248 | |
249 | if (pl->ob->speed_left > 0 && pl->ns) |
249 | if (pl->ob->speed_left > 0.f && pl->ns) |
250 | if (handle_newcs_player (pl->ob)) |
250 | if (handle_newcs_player (pl->ob)) |
251 | flag = 1; |
251 | flag = 1; |
252 | |
252 | |
253 | /* If the player is not actively playing, don't make a |
253 | /* If the player is not actively playing, don't make a |
254 | * backup save - nothing to save anyway. Plus, the |
254 | * backup save - nothing to save anyway. Plus, the |
… | |
… | |
261 | } /* end of for loop for all the players */ |
261 | } /* end of for loop for all the players */ |
262 | } /* for flag */ |
262 | } /* for flag */ |
263 | |
263 | |
264 | for_all_players (pl) |
264 | for_all_players (pl) |
265 | { |
265 | { |
|
|
266 | object *ob = pl->ob; |
|
|
267 | |
266 | if (!pl->ob || !pl->ns || !pl->ob->active) |
268 | if (!ob || !pl->ns || !ob->active) |
267 | continue; |
269 | continue; |
268 | |
270 | |
269 | if (settings.casting_time) |
271 | if (settings.casting_time) |
270 | { |
272 | { |
271 | if (pl->ob->casting_time > 0) |
273 | if (ob->casting_time > 0.f) |
272 | { |
274 | { |
273 | pl->ob->casting_time--; |
275 | --ob->casting_time; |
274 | pl->ob->start_holding = 1; |
276 | ob->start_holding = 1; |
275 | } |
277 | } |
276 | |
278 | |
277 | /* set spell_state so we can update the range in stats field */ |
279 | /* set spell_state so we can update the range in stats field */ |
278 | if ((pl->ob->casting_time == 0) && (pl->ob->start_holding == 1)) |
280 | if (pl->ob->casting_time == 0.f && pl->ob->start_holding == 1) |
279 | pl->ob->start_holding = 0; |
281 | pl->ob->start_holding = 0; |
280 | } |
282 | } |
281 | |
283 | |
|
|
284 | // process_events might steal us one speed slot, so adjust accordingly |
|
|
285 | if (ob->speed_left > 0.f) |
|
|
286 | ++ob->speed_left; |
|
|
287 | |
282 | do_some_living (pl->ob); |
288 | do_some_living (ob); |
283 | } |
289 | } |
284 | } |
290 | } |
285 | |
291 | |
286 | static void |
292 | static void |
287 | process_players2 () |
293 | process_players2 () |
288 | { |
294 | { |
289 | /* Then check if any players should use weapon-speed instead of speed */ |
295 | /* Then check if any players should use weapon-speed instead of speed */ |
290 | for_all_players (pl) |
296 | for_all_players (pl) |
291 | { |
297 | { |
292 | /* The code that did weapon_sp handling here was out of place - |
|
|
293 | * this isn't called until after the player has finished her |
|
|
294 | * actions, and is thus out of place. All we do here is bounds |
|
|
295 | * checking. |
|
|
296 | */ |
|
|
297 | if (pl->has_hit) |
298 | if (pl->has_hit) |
298 | { |
299 | { |
|
|
300 | pl->ob->speed_left = min (pl->weapon_sp, pl->ob->speed_left + pl->weapon_sp); |
|
|
301 | |
299 | if (pl->ob->speed_left > pl->weapon_sp) |
302 | if (pl->ob->speed_left > 0.f) |
300 | pl->ob->speed_left = pl->weapon_sp; |
|
|
301 | |
|
|
302 | /* This needs to be here - if the player is running, we need to |
|
|
303 | * clear this each tick, but new commands are not being received |
|
|
304 | * so execute_newserver_command() is never called |
|
|
305 | */ |
|
|
306 | pl->has_hit = 0; |
303 | pl->has_hit = 0; |
307 | } |
304 | } |
308 | else if (pl->ob->speed_left > pl->ob->speed) |
305 | else |
309 | pl->ob->speed_left = pl->ob->speed; |
306 | pl->ob->speed_left = min (pl->ob->speed, pl->ob->speed_left + pl->ob->speed); |
310 | } |
307 | } |
311 | } |
308 | } |
312 | |
309 | |
313 | void |
310 | void |
314 | process_events () |
311 | process_events () |
… | |
… | |
344 | /* Animate the object. Bug or feature that anim_speed |
341 | /* Animate the object. Bug or feature that anim_speed |
345 | * is based on ticks, and not the creatures speed? |
342 | * is based on ticks, and not the creatures speed? |
346 | */ |
343 | */ |
347 | if (op->anim_speed && op->last_anim >= op->anim_speed) |
344 | if (op->anim_speed && op->last_anim >= op->anim_speed) |
348 | { |
345 | { |
349 | animate_object (op, op->type == PLAYER ? op->facing : op->direction); |
346 | animate_object (op, op->contr ? op->facing : op->direction); |
350 | |
|
|
351 | op->last_anim = 1; |
347 | op->last_anim = 1; |
352 | } |
348 | } |
353 | else |
349 | else |
354 | op->last_anim++; |
350 | ++op->last_anim; |
355 | |
351 | |
356 | if (op->speed_left > 0) |
352 | if (op->speed_left > 0.f) |
357 | { |
353 | { |
358 | --op->speed_left; |
354 | --op->speed_left; |
359 | process_object (op); |
355 | process_object (op); |
360 | |
356 | |
361 | if (op->destroyed ()) |
357 | if (op->destroyed ()) |
362 | continue; |
358 | continue; |
363 | } |
359 | } |
364 | |
360 | |
365 | if (settings.casting_time == TRUE && op->casting_time > 0) |
361 | if (settings.casting_time == TRUE && op->casting_time > 0.f) |
366 | op->casting_time--; |
362 | --op->casting_time; |
367 | |
363 | |
368 | if (op->speed_left <= 0) |
364 | if (!op->contr) |
369 | op->speed_left += FABS (op->speed); |
365 | op->speed_left = min (abs (op->speed), op->speed_left + abs (op->speed)); |
370 | } |
366 | } |
371 | |
367 | |
372 | process_players2 (); |
368 | process_players2 (); |
373 | } |
369 | } |
374 | |
370 | |