ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/move.C
(Generate patch)

Comparing deliantra/server/server/move.C (file contents):
Revision 1.36 by root, Sun Feb 7 04:22:33 2010 UTC vs.
Revision 1.37 by root, Fri Mar 26 00:53:26 2010 UTC

25#include <global.h> 25#include <global.h>
26#ifndef __CEXTRACT__ 26#ifndef __CEXTRACT__
27# include <sproto.h> 27# include <sproto.h>
28#endif 28#endif
29 29
30/*
31 * move_object() tries to move object op in the direction "dir".
32 * If it fails (something blocks the passage), it returns 0,
33 * otherwise 1.
34 * This is an improvement from the previous move_ob(), which
35 * removed and inserted objects even if they were unable to move.
36 */
37int
38move_object (object *op, int dir)
39{
40 return op->move (dir);
41}
42
43/* object op is trying to move in direction dir.
44 * originator is typically the same as op, but
45 * can be different if originator is causing op to
46 * move (originator is pushing op)
47 * returns 0 if the object is not able to move to the
48 * desired space, 1 otherwise (in which case we also
49 * move the object accordingly. This function is
50 * very similiar to move_object.
51 */
52int
53move_ob (object *op, int dir, object *originator)
54{
55 return op->move (dir, originator);
56}
57
58int 30int
59object::move (int dir, object *originator) 31object::move (int dir, object *originator)
60{ 32{
61 sint16 newx = x + freearr_x[dir]; 33 sint16 newx = x + freearr_x[dir];
62 sint16 newy = y + freearr_y[dir]; 34 sint16 newy = y + freearr_y[dir];
353 { 325 {
354 new_draw_info_format (NDI_UNIQUE, 0, pusher, "You fail to push the %s.", query_name (op)); 326 new_draw_info_format (NDI_UNIQUE, 0, pusher, "You fail to push the %s.", query_name (op));
355 return; 327 return;
356 } 328 }
357 329
358 move_ob (pusher, dir, pusher); 330 pusher->move (dir);
359 new_draw_info_format (NDI_BLACK, 0, pusher, "You move the %s.", query_name (op)); 331 new_draw_info_format (NDI_BLACK, 0, pusher, "You move the %s.", query_name (op));
360 return; 332 return;
361} 333}
362 334
363/* returns 1 if pushing invokes a attack, 0 when not */ 335/* returns 1 if pushing invokes a attack, 0 when not */
438 410
439 str1 = (who->stats.Str > 0 ? who->stats.Str : who->level); 411 str1 = (who->stats.Str > 0 ? who->stats.Str : who->level);
440 str2 = (pusher->stats.Str > 0 ? pusher->stats.Str : pusher->level); 412 str2 = (pusher->stats.Str > 0 ? pusher->stats.Str : pusher->level);
441 if (QUERY_FLAG (who, FLAG_WIZ) || 413 if (QUERY_FLAG (who, FLAG_WIZ) ||
442 random_roll (str1, str1 * 5 / 2, who, PREFER_HIGH) >= 414 random_roll (str1, str1 * 5 / 2, who, PREFER_HIGH) >=
443 random_roll (str2, str2 * 5 / 2, pusher, PREFER_HIGH) || !move_object (who, dir)) 415 random_roll (str2, str2 * 5 / 2, pusher, PREFER_HIGH) || !who->move (dir))
444 { 416 {
445 if (who->type == PLAYER) 417 if (who->type == PLAYER)
446 new_draw_info_format (NDI_UNIQUE, 0, who, "%s tried to push you.", &pusher->name); 418 new_draw_info_format (NDI_UNIQUE, 0, who, "%s tried to push you.", &pusher->name);
447 419
448 return 0; 420 return 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines