1 | /* |
1 | /* |
2 | * static char *rcsid_move_c = |
2 | * static char *rcsid_move_c = |
3 | * "$Id: move.C,v 1.3 2006/08/29 07:34:00 root Exp $"; |
3 | * "$Id: move.C,v 1.6 2006/09/03 00:18:42 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
65 | object *tmp; |
65 | object *tmp; |
66 | mapstruct *m; |
66 | mapstruct *m; |
67 | int mflags; |
67 | int mflags; |
68 | |
68 | |
69 | if(op==NULL) { |
69 | if(op==NULL) { |
70 | LOG(llevError,"Trying to move NULL.\n"); |
70 | LOG(llevError,"Trying to move NULL.\n"); |
71 | return 0; |
71 | return 0; |
72 | } |
72 | } |
73 | |
73 | |
74 | m = op->map; |
74 | m = op->map; |
75 | mflags = get_map_flags(m, &m, newx, newy, &newx, &newy); |
75 | mflags = get_map_flags(m, &m, newx, newy, &newx, &newy); |
76 | |
76 | |
… | |
… | |
83 | /* Is this space blocked? Players with wizpass are immune to |
83 | /* Is this space blocked? Players with wizpass are immune to |
84 | * this condition. |
84 | * this condition. |
85 | */ |
85 | */ |
86 | if(blocked_link(op, m, newx, newy) && |
86 | if(blocked_link(op, m, newx, newy) && |
87 | !QUERY_FLAG(op, FLAG_WIZPASS)) |
87 | !QUERY_FLAG(op, FLAG_WIZPASS)) |
88 | return 0; |
88 | return 0; |
89 | |
89 | |
90 | /* 0.94.2 - we need to set the direction for the new animation code. |
90 | /* 0.94.2 - we need to set the direction for the new animation code. |
91 | * it uses it to figure out face to use - I can't see it |
91 | * it uses it to figure out face to use - I can't see it |
92 | * breaking anything, but it might. |
92 | * breaking anything, but it might. |
93 | */ |
93 | */ |
94 | if(op->more != NULL && !move_ob(op->more, dir, op->more->head)) |
94 | if(op->more != NULL && !move_ob(op->more, dir, op->more->head)) |
95 | return 0; |
95 | return 0; |
96 | |
96 | |
97 | op->direction = dir; |
97 | op->direction = dir; |
98 | |
98 | |
99 | if(op->will_apply&4) |
99 | if(op->will_apply&4) |
100 | check_earthwalls(op,m, newx,newy); |
100 | check_earthwalls(op,m, newx,newy); |
101 | if(op->will_apply&8) |
101 | if(op->will_apply&8) |
102 | check_doors(op,m, newx,newy); |
102 | check_doors(op,m, newx,newy); |
103 | |
103 | |
104 | /* 0.94.1 - I got a stack trace that showed it crash with remove_ob trying |
104 | /* 0.94.1 - I got a stack trace that showed it crash with remove_ob trying |
105 | * to remove a removed object, and this function was the culprit. A possible |
105 | * to remove a removed object, and this function was the culprit. A possible |
106 | * guess I have is that check_doors above ran into a trap, killing the |
106 | * guess I have is that check_doors above ran into a trap, killing the |
107 | * monster. |
107 | * monster. |
… | |
… | |
110 | * deal very well with op being killed, so all this might do is just |
110 | * deal very well with op being killed, so all this might do is just |
111 | * migrate the problem someplace else. |
111 | * migrate the problem someplace else. |
112 | */ |
112 | */ |
113 | |
113 | |
114 | if (QUERY_FLAG(op, FLAG_REMOVED)) { |
114 | if (QUERY_FLAG(op, FLAG_REMOVED)) { |
115 | LOG(llevDebug,"move_object: monster has been removed - will not process further\n"); |
115 | LOG(llevDebug,"move_object: monster has been removed - will not process further\n"); |
116 | /* Was not successful, but don't want to try and move again */ |
116 | /* Was not successful, but don't want to try and move again */ |
117 | return 1; |
117 | return 1; |
118 | } |
118 | } |
119 | |
119 | |
120 | /* If this is a tail portion, just want to tell caller that move is |
120 | /* If this is a tail portion, just want to tell caller that move is |
121 | * ok - the caller will deal with actual object removal/insertion |
121 | * ok - the caller will deal with actual object removal/insertion |
122 | */ |
122 | */ |
123 | if(op->head) |
123 | if(op->head) |
124 | return 1; |
124 | return 1; |
125 | |
125 | |
126 | remove_ob(op); |
126 | remove_ob(op); |
127 | |
127 | |
128 | /* we already have newx, newy, and m, so lets use them. |
128 | /* we already have newx, newy, and m, so lets use them. |
129 | * In addition, this fixes potential crashes, because multipart object was |
129 | * In addition, this fixes potential crashes, because multipart object was |
130 | * on edge of map, +=x, +=y doesn't make correct coordinates. |
130 | * on edge of map, +=x, +=y doesn't make correct coordinates. |
131 | */ |
131 | */ |
132 | for(tmp = op; tmp != NULL; tmp = tmp->more) { |
132 | for(tmp = op; tmp != NULL; tmp = tmp->more) { |
133 | tmp->x += freearr_x[dir]; |
133 | tmp->x += freearr_x[dir]; |
134 | tmp->y += freearr_y[dir]; |
134 | tmp->y += freearr_y[dir]; |
135 | tmp->map = get_map_from_coord(tmp->map, &tmp->x, &tmp->y); |
135 | tmp->map = get_map_from_coord(tmp->map, &tmp->x, &tmp->y); |
136 | } |
136 | } |
137 | |
137 | |
138 | /* insert_ob_in_map will deal with any tiling issues */ |
138 | /* insert_ob_in_map will deal with any tiling issues */ |
139 | insert_ob_in_map(op, m, originator,0); |
139 | insert_ob_in_map(op, m, originator,0); |
140 | |
140 | |
141 | return 1; /* this shouldn't be reached */ |
141 | return 1; |
142 | } |
142 | } |
143 | |
143 | |
144 | |
144 | |
145 | /* |
145 | /* |
146 | * transfer_ob(): Move an object (even linked objects) to another spot |
146 | * transfer_ob(): Move an object (even linked objects) to another spot |
… | |
… | |
158 | { |
158 | { |
159 | int i; |
159 | int i; |
160 | object *tmp; |
160 | object *tmp; |
161 | |
161 | |
162 | if (randomly) |
162 | if (randomly) |
163 | i = find_free_spot (op,op->map,x,y,0,SIZEOFFREE); |
163 | i = find_free_spot (op,op->map,x,y,0,SIZEOFFREE); |
164 | else |
164 | else |
165 | i = find_first_free_spot(op,op->map,x,y); |
165 | i = find_first_free_spot(op,op->map,x,y); |
166 | |
166 | |
167 | if (i==-1) |
167 | if (i==-1) |
168 | return 0; /* No free spot */ |
168 | return 0; /* No free spot */ |
169 | |
169 | |
170 | if(op->head!=NULL) |
170 | if(op->head!=NULL) |
171 | op=op->head; |
171 | op=op->head; |
172 | remove_ob(op); |
172 | remove_ob(op); |
173 | for(tmp=op;tmp!=NULL;tmp=tmp->more) |
173 | for(tmp=op;tmp!=NULL;tmp=tmp->more) |
174 | tmp->x=x+freearr_x[i]+(tmp->arch==NULL?0:tmp->arch->clone.x), |
174 | tmp->x=x+freearr_x[i]+(tmp->arch==NULL?0:tmp->arch->clone.x), |
175 | tmp->y=y+freearr_y[i]+(tmp->arch==NULL?0:tmp->arch->clone.y); |
175 | tmp->y=y+freearr_y[i]+(tmp->arch==NULL?0:tmp->arch->clone.y); |
176 | |
176 | |
177 | tmp = insert_ob_in_map(op,op->map,originator,0); |
177 | tmp = insert_ob_in_map(op,op->map,originator,0); |
178 | if (tmp) return 0; |
178 | if (tmp) return 0; |
179 | else return 1; |
179 | else return 1; |
180 | } |
180 | } |
… | |
… | |
199 | mapstruct *m; |
199 | mapstruct *m; |
200 | sint16 sx, sy; |
200 | sint16 sx, sy; |
201 | |
201 | |
202 | if(user==NULL) return 0; |
202 | if(user==NULL) return 0; |
203 | if(user->head!=NULL) |
203 | if(user->head!=NULL) |
204 | user=user->head; |
204 | user=user->head; |
205 | |
205 | |
206 | /* Find all other teleporters within range. This range |
206 | /* Find all other teleporters within range. This range |
207 | * should really be setable by some object attribute instead of |
207 | * should really be setable by some object attribute instead of |
208 | * using hard coded values. |
208 | * using hard coded values. |
209 | */ |
209 | */ |
210 | for(i= -5;i<6;i++) |
210 | for(i= -5;i<6;i++) |
211 | for(j= -5;j<6;j++) { |
211 | for(j= -5;j<6;j++) { |
212 | if(i==0&&j==0) |
212 | if(i==0&&j==0) |
213 | continue; |
213 | continue; |
214 | /* Perhaps this should be extended to support tiled maps */ |
214 | /* Perhaps this should be extended to support tiled maps */ |
215 | if(OUT_OF_REAL_MAP(teleporter->map,teleporter->x+i,teleporter->y+j)) |
215 | if(OUT_OF_REAL_MAP(teleporter->map,teleporter->x+i,teleporter->y+j)) |
216 | continue; |
216 | continue; |
217 | other_teleporter=get_map_ob(teleporter->map, |
217 | other_teleporter=get_map_ob(teleporter->map, |
218 | teleporter->x+i,teleporter->y+j); |
218 | teleporter->x+i,teleporter->y+j); |
219 | |
219 | |
220 | while (other_teleporter) { |
220 | while (other_teleporter) { |
221 | if (other_teleporter->type == tele_type) break; |
221 | if (other_teleporter->type == tele_type) break; |
222 | other_teleporter = other_teleporter->above; |
222 | other_teleporter = other_teleporter->above; |
223 | } |
223 | } |
224 | if (other_teleporter && !(RANDOM() % ++nrofalt)) |
224 | if (other_teleporter && !(RANDOM() % ++nrofalt)) |
225 | altern = other_teleporter; |
225 | altern = other_teleporter; |
226 | } |
226 | } |
227 | |
227 | |
228 | if(!nrofalt) { |
228 | if(!nrofalt) { |
229 | LOG(llevError,"No alternative teleporters around!\n"); |
229 | LOG(llevError,"No alternative teleporters around!\n"); |
230 | return 0; |
230 | return 0; |
231 | } |
231 | } |
232 | |
232 | |
233 | other_teleporter=altern; |
233 | other_teleporter=altern; |
234 | k=find_free_spot(user,other_teleporter->map, |
234 | k=find_free_spot(user,other_teleporter->map, |
235 | other_teleporter->x,other_teleporter->y,1,9); |
235 | other_teleporter->x,other_teleporter->y,1,9); |
… | |
… | |
240 | * that appear in random dungeons. We basically just make |
240 | * that appear in random dungeons. We basically just make |
241 | * sure the space isn't no pass (eg wall), and don't care |
241 | * sure the space isn't no pass (eg wall), and don't care |
242 | * about is alive. |
242 | * about is alive. |
243 | */ |
243 | */ |
244 | if (k==-1) { |
244 | if (k==-1) { |
245 | if (tele_type == SHOP_MAT && user->type == PLAYER) { |
245 | if (tele_type == SHOP_MAT && user->type == PLAYER) { |
246 | for (k=1; k<9; k++) { |
246 | for (k=1; k<9; k++) { |
247 | if (get_map_flags(other_teleporter->map, &m, |
247 | if (get_map_flags(other_teleporter->map, &m, |
248 | other_teleporter->x + freearr_x[k], |
248 | other_teleporter->x + freearr_x[k], |
249 | other_teleporter->y + freearr_y[k], &sx,&sy) & |
249 | other_teleporter->y + freearr_y[k], &sx,&sy) & |
250 | P_OUT_OF_MAP) continue; |
250 | P_OUT_OF_MAP) continue; |
251 | |
251 | |
252 | if (!OB_TYPE_MOVE_BLOCK(user, GET_MAP_MOVE_BLOCK(m, sx, sy))) break; |
252 | if (!OB_TYPE_MOVE_BLOCK(user, GET_MAP_MOVE_BLOCK(m, sx, sy))) break; |
253 | |
253 | |
254 | } |
254 | } |
255 | if (k==9) { |
255 | if (k==9) { |
256 | LOG(llevError,"Shop mat %s (%d, %d) is in solid rock?\n", |
256 | LOG(llevError,"Shop mat %s (%d, %d) is in solid rock?\n", |
257 | other_teleporter->name, other_teleporter->x, other_teleporter->y); |
257 | &other_teleporter->name, other_teleporter->x, other_teleporter->y); |
258 | return 0; |
258 | return 0; |
259 | } |
259 | } |
260 | } |
260 | } |
261 | else return 0; |
261 | else return 0; |
262 | } |
262 | } |
263 | |
263 | |
264 | remove_ob(user); |
264 | remove_ob(user); |
265 | |
265 | |
266 | /* Update location for the object */ |
266 | /* Update location for the object */ |
267 | for(tmp=user;tmp!=NULL;tmp=tmp->more) { |
267 | for(tmp=user;tmp!=NULL;tmp=tmp->more) { |
268 | tmp->x=other_teleporter->x+freearr_x[k]+ |
268 | tmp->x=other_teleporter->x+freearr_x[k]+ |
269 | (tmp->arch==NULL?0:tmp->arch->clone.x); |
269 | (tmp->arch==NULL?0:tmp->arch->clone.x); |
270 | tmp->y=other_teleporter->y+freearr_y[k]+ |
270 | tmp->y=other_teleporter->y+freearr_y[k]+ |
271 | (tmp->arch==NULL?0:tmp->arch->clone.y); |
271 | (tmp->arch==NULL?0:tmp->arch->clone.y); |
272 | } |
272 | } |
273 | tmp = insert_ob_in_map(user,other_teleporter->map,NULL,0); |
273 | tmp = insert_ob_in_map(user,other_teleporter->map,NULL,0); |
274 | return (tmp == NULL); |
274 | return (tmp == NULL); |
275 | } |
275 | } |
276 | |
276 | |
277 | void recursive_roll(object *op,int dir,object *pusher) { |
277 | void recursive_roll(object *op,int dir,object *pusher) { |
278 | if(!roll_ob(op,dir,pusher)) { |
278 | if(!roll_ob(op,dir,pusher)) { |
279 | new_draw_info_format(NDI_UNIQUE, 0, pusher, |
279 | new_draw_info_format(NDI_UNIQUE, 0, pusher, |
280 | "You fail to push the %s.",query_name(op)); |
280 | "You fail to push the %s.",query_name(op)); |
281 | return; |
281 | return; |
282 | } |
282 | } |
283 | (void) move_ob(pusher,dir,pusher); |
283 | (void) move_ob(pusher,dir,pusher); |
284 | new_draw_info_format(NDI_BLACK, 0, pusher, |
284 | new_draw_info_format(NDI_BLACK, 0, pusher, |
285 | "You move the %s.",query_name(op)); |
285 | "You move the %s.",query_name(op)); |
286 | return; |
286 | return; |
287 | } |
287 | } |
288 | |
288 | |
289 | /* |
289 | /* |
290 | * This is a new version of blocked, this one handles objects |
290 | * This is a new version of blocked, this one handles objects |
… | |
… | |
301 | sint16 tx, ty; |
301 | sint16 tx, ty; |
302 | int mflags; |
302 | int mflags; |
303 | mapstruct *m2; |
303 | mapstruct *m2; |
304 | |
304 | |
305 | if (op->head) |
305 | if (op->head) |
306 | op = op->head; |
306 | op = op->head; |
307 | |
307 | |
308 | for (more = op; more ; more = more->more) { |
308 | for (more = op; more ; more = more->more) { |
309 | tx = x + more->x - op->x; |
309 | tx = x + more->x - op->x; |
310 | ty = y + more->y - op->y; |
310 | ty = y + more->y - op->y; |
311 | |
311 | |
312 | mflags = get_map_flags(m, &m2, tx, ty, &tx, &ty); |
312 | mflags = get_map_flags(m, &m2, tx, ty, &tx, &ty); |
313 | |
313 | |
314 | if (mflags & P_OUT_OF_MAP) |
314 | if (mflags & P_OUT_OF_MAP) |
315 | return 1; |
315 | return 1; |
316 | |
316 | |
317 | for (tmp = get_map_ob (m2, tx, ty); tmp; tmp=tmp->above) { |
317 | for (tmp = get_map_ob (m2, tx, ty); tmp; tmp=tmp->above) { |
318 | if (tmp->head == op || tmp == op) |
318 | if (tmp->head == op || tmp == op) |
319 | continue; |
319 | continue; |
320 | |
320 | |
321 | if ((QUERY_FLAG(tmp,FLAG_ALIVE) && tmp->type!=DOOR)) |
321 | if ((QUERY_FLAG(tmp,FLAG_ALIVE) && tmp->type!=DOOR)) |
322 | return 1; |
322 | return 1; |
323 | |
323 | |
324 | if (OB_MOVE_BLOCK(op, tmp)) return 1; |
324 | if (OB_MOVE_BLOCK(op, tmp)) return 1; |
325 | |
325 | |
326 | } |
326 | } |
327 | } |
327 | } |
328 | return 0; |
328 | return 0; |
329 | } |
329 | } |
330 | |
330 | |
331 | /* |
331 | /* |
… | |
… | |
340 | int flags; |
340 | int flags; |
341 | mapstruct *m; |
341 | mapstruct *m; |
342 | MoveType move_block; |
342 | MoveType move_block; |
343 | |
343 | |
344 | if (op->head) |
344 | if (op->head) |
345 | op = op->head; |
345 | op = op->head; |
346 | |
346 | |
347 | x=op->x+freearr_x[dir]; |
347 | x=op->x+freearr_x[dir]; |
348 | y=op->y+freearr_y[dir]; |
348 | y=op->y+freearr_y[dir]; |
349 | |
349 | |
350 | if(!QUERY_FLAG(op,FLAG_CAN_ROLL) || |
350 | if(!QUERY_FLAG(op,FLAG_CAN_ROLL) || |
351 | (op->weight && |
351 | (op->weight && |
352 | random_roll(0, op->weight/50000-1, pusher, PREFER_LOW) > pusher->stats.Str)) |
352 | random_roll(0, op->weight/50000-1, pusher, PREFER_LOW) > pusher->stats.Str)) |
353 | return 0; |
353 | return 0; |
354 | |
354 | |
355 | m = op->map; |
355 | m = op->map; |
356 | flags = get_map_flags(m, &m, x, y, &x, &y); |
356 | flags = get_map_flags(m, &m, x, y, &x, &y); |
357 | |
357 | |
358 | if (flags & (P_OUT_OF_MAP | P_IS_ALIVE)) |
358 | if (flags & (P_OUT_OF_MAP | P_IS_ALIVE)) |
359 | return 0; |
359 | return 0; |
360 | |
360 | |
361 | move_block = GET_MAP_MOVE_BLOCK(m, x, y); |
361 | move_block = GET_MAP_MOVE_BLOCK(m, x, y); |
362 | |
362 | |
363 | /* If the target space is not blocked, no need to look at the objects on it */ |
363 | /* If the target space is not blocked, no need to look at the objects on it */ |
364 | if ((op->move_type & move_block) == op->move_type) { |
364 | if ((op->move_type & move_block) == op->move_type) { |
365 | for (tmp=get_map_ob(m, x, y); tmp!=NULL; tmp=tmp->above) { |
365 | for (tmp=get_map_ob(m, x, y); tmp!=NULL; tmp=tmp->above) { |
366 | if (tmp->head == op) |
366 | if (tmp->head == op) |
367 | continue; |
367 | continue; |
368 | if (OB_MOVE_BLOCK(op, tmp) && !roll_ob(tmp,dir,pusher)) |
368 | if (OB_MOVE_BLOCK(op, tmp) && !roll_ob(tmp,dir,pusher)) |
369 | return 0; |
369 | return 0; |
370 | } |
370 | } |
371 | } |
371 | } |
372 | if (try_fit (op, m, x, y)) |
372 | if (try_fit (op, m, x, y)) |
373 | return 0; |
373 | return 0; |
374 | |
374 | |
375 | remove_ob(op); |
375 | remove_ob(op); |
376 | for(tmp=op; tmp!=NULL; tmp=tmp->more) |
376 | for(tmp=op; tmp!=NULL; tmp=tmp->more) |
377 | tmp->x+=freearr_x[dir],tmp->y+=freearr_y[dir]; |
377 | tmp->x+=freearr_x[dir],tmp->y+=freearr_y[dir]; |
378 | insert_ob_in_map(op,op->map,pusher,0); |
378 | insert_ob_in_map(op,op->map,pusher,0); |
379 | return 1; |
379 | return 1; |
380 | } |
380 | } |
381 | |
381 | |
382 | /* returns 1 if pushing invokes a attack, 0 when not */ |
382 | /* returns 1 if pushing invokes a attack, 0 when not */ |
383 | int push_ob(object *who, int dir, object *pusher) { |
383 | int push_ob(object *who, int dir, object *pusher) { |
384 | int str1, str2; |
384 | int str1, str2; |
385 | object *owner; |
385 | object *owner; |
386 | |
386 | |
387 | if (who->head != NULL) |
387 | if (who->head != NULL) |
388 | who = who->head; |
388 | who = who->head; |
389 | owner = get_owner(who); |
389 | owner = get_owner(who); |
390 | |
390 | |
391 | /* Wake up sleeping monsters that may be pushed */ |
391 | /* Wake up sleeping monsters that may be pushed */ |
392 | CLEAR_FLAG(who,FLAG_SLEEP); |
392 | CLEAR_FLAG(who,FLAG_SLEEP); |
393 | |
393 | |
… | |
… | |
403 | ) |
403 | ) |
404 | #else |
404 | #else |
405 | && owner == pusher |
405 | && owner == pusher |
406 | #endif |
406 | #endif |
407 | ) { |
407 | ) { |
408 | int temp; |
408 | int temp; |
409 | mapstruct *m; |
409 | mapstruct *m; |
410 | |
410 | |
411 | remove_ob(who); |
411 | remove_ob(who); |
412 | remove_ob(pusher); |
412 | remove_ob(pusher); |
413 | temp = pusher->x; |
413 | temp = pusher->x; |
414 | pusher->x = who->x; |
414 | pusher->x = who->x; |
415 | who->x = temp; |
415 | who->x = temp; |
416 | |
416 | |
417 | temp = pusher->y; |
417 | temp = pusher->y; |
418 | pusher->y = who->y; |
418 | pusher->y = who->y; |
419 | who->y = temp; |
419 | who->y = temp; |
420 | |
420 | |
421 | m = pusher->map; |
421 | m = pusher->map; |
422 | pusher->map = who->map; |
422 | pusher->map = who->map; |
423 | who->map = m; |
423 | who->map = m; |
424 | |
424 | |
425 | insert_ob_in_map (who,who->map,pusher,0); |
425 | insert_ob_in_map (who,who->map,pusher,0); |
426 | insert_ob_in_map (pusher,pusher->map,pusher,0); |
426 | insert_ob_in_map (pusher,pusher->map,pusher,0); |
427 | return 0; |
427 | return 0; |
428 | } |
428 | } |
429 | |
429 | |
430 | |
430 | |
431 | /* We want ONLY become enemy of evil, unaggressive monster. We must RUN in them */ |
431 | /* We want ONLY become enemy of evil, unaggressive monster. We must RUN in them */ |
432 | /* In original we have here a unaggressive check only - that was the reason why */ |
432 | /* In original we have here a unaggressive check only - that was the reason why */ |
433 | /* we so often become an enemy of friendly monsters... */ |
433 | /* we so often become an enemy of friendly monsters... */ |
434 | /* funny: was they set to unaggressive 0 (= not so nice) they don't attack */ |
434 | /* funny: was they set to unaggressive 0 (= not so nice) they don't attack */ |
435 | |
435 | |
436 | if(owner != pusher && pusher->type == PLAYER && who->type != PLAYER && |
436 | if(owner != pusher && pusher->type == PLAYER && who->type != PLAYER && |
437 | !QUERY_FLAG(who,FLAG_FRIENDLY)&& !QUERY_FLAG(who,FLAG_NEUTRAL)) { |
437 | !QUERY_FLAG(who,FLAG_FRIENDLY)&& !QUERY_FLAG(who,FLAG_NEUTRAL)) { |
438 | if(pusher->contr->run_on) /* only when we run */ { |
438 | if(pusher->contr->run_on) /* only when we run */ { |
439 | new_draw_info_format(NDI_UNIQUE, 0, pusher, |
439 | new_draw_info_format(NDI_UNIQUE, 0, pusher, |
440 | "You start to attack %s !!",who->name); |
440 | "You start to attack %s !!", &who->name); |
441 | CLEAR_FLAG(who,FLAG_UNAGGRESSIVE); /* the sucker don't like you anymore */ |
441 | CLEAR_FLAG(who,FLAG_UNAGGRESSIVE); /* the sucker don't like you anymore */ |
442 | who->enemy = pusher; |
442 | who->enemy = pusher; |
443 | return 1; |
443 | return 1; |
444 | } |
444 | } |
445 | else |
445 | else |
446 | { |
446 | { |
447 | new_draw_info_format(NDI_UNIQUE, 0, pusher, |
447 | new_draw_info_format(NDI_UNIQUE, 0, pusher, |
448 | "You avoid attacking %s .",who->name); |
448 | "You avoid attacking %s.", &who->name); |
449 | } |
449 | } |
450 | } |
450 | } |
451 | |
451 | |
452 | /* now, lets test stand still. we NEVER can push stand_still monsters. */ |
452 | /* now, lets test stand still. we NEVER can push stand_still monsters. */ |
453 | if(QUERY_FLAG(who,FLAG_STAND_STILL)) |
453 | if(QUERY_FLAG(who,FLAG_STAND_STILL)) |
454 | { |
454 | { |
455 | new_draw_info_format(NDI_UNIQUE, 0, pusher, |
455 | new_draw_info_format(NDI_UNIQUE, 0, pusher, |
456 | "You can't push %s.",who->name); |
456 | "You can't push %s.", &who->name); |
457 | return 0; |
457 | return 0; |
458 | } |
458 | } |
459 | |
459 | |
460 | /* This block is basically if you are pushing friendly but |
460 | /* This block is basically if you are pushing friendly but |
461 | * non pet creaturs. |
461 | * non pet creaturs. |
462 | * It basically does a random strength comparision to |
462 | * It basically does a random strength comparision to |
… | |
… | |
469 | if(QUERY_FLAG(who,FLAG_WIZ) || |
469 | if(QUERY_FLAG(who,FLAG_WIZ) || |
470 | random_roll(str1, str1/2+str1*2, who, PREFER_HIGH) >= |
470 | random_roll(str1, str1/2+str1*2, who, PREFER_HIGH) >= |
471 | random_roll(str2, str2/2+str2*2, pusher, PREFER_HIGH) || |
471 | random_roll(str2, str2/2+str2*2, pusher, PREFER_HIGH) || |
472 | !move_object(who,dir)) |
472 | !move_object(who,dir)) |
473 | { |
473 | { |
474 | if (who ->type == PLAYER) { |
474 | if (who ->type == PLAYER) { |
475 | new_draw_info_format(NDI_UNIQUE, 0, who, |
475 | new_draw_info_format(NDI_UNIQUE, 0, who, |
476 | "%s tried to push you.",pusher->name); |
476 | "%s tried to push you.", &pusher->name); |
477 | } |
477 | } |
478 | return 0; |
478 | return 0; |
479 | } |
479 | } |
480 | |
480 | |
481 | /* If we get here, the push succeeded. |
481 | /* If we get here, the push succeeded. |
482 | * Let everyone know the status. |
482 | * Let everyone know the status. |
483 | */ |
483 | */ |
484 | if (who->type == PLAYER) { |
484 | if (who->type == PLAYER) { |
485 | new_draw_info_format(NDI_UNIQUE, 0, who, |
485 | new_draw_info_format(NDI_UNIQUE, 0, who, |
486 | "%s pushed you.",pusher->name); |
486 | "%s pushed you.", &pusher->name); |
487 | } |
487 | } |
488 | if (pusher->type == PLAYER) { |
488 | if (pusher->type == PLAYER) { |
489 | new_draw_info_format(NDI_UNIQUE, 0, pusher, |
489 | new_draw_info_format(NDI_UNIQUE, 0, pusher, |
490 | "You pushed %s back.", who->name); |
490 | "You pushed %s back.", &who->name); |
491 | } |
491 | } |
492 | |
492 | |
493 | return 1; |
493 | return 1; |
494 | } |
494 | } |