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

Comparing deliantra/server/server/player.C (file contents):
Revision 1.48 by root, Tue Dec 19 05:41:22 2006 UTC vs.
Revision 1.49 by root, Wed Dec 20 09:14:22 2006 UTC

1223 { 1223 {
1224 op->enemy = NULL; 1224 op->enemy = NULL;
1225 CLEAR_FLAG (op, FLAG_SCARED); 1225 CLEAR_FLAG (op, FLAG_SCARED);
1226 return; 1226 return;
1227 } 1227 }
1228
1228 get_rangevector (op, op->enemy, &rv, 0); 1229 get_rangevector (op, op->enemy, &rv, 0);
1229 1230
1230 dir = absdir (4 + rv.direction); 1231 dir = absdir (4 + rv.direction);
1231 for (diff = 0; diff < 3; diff++) 1232 for (diff = 0; diff < 3; diff++)
1232 { 1233 {
1233 int m = 1 - (RANDOM () & 2); 1234 int m = 1 - (RANDOM () & 2);
1234 1235
1235 if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op))) 1236 if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op)))
1236 {
1237 return; 1237 return;
1238 }
1239 } 1238 }
1239
1240 /* Cornered, get rid of scared */ 1240 /* Cornered, get rid of scared */
1241 CLEAR_FLAG (op, FLAG_SCARED); 1241 CLEAR_FLAG (op, FLAG_SCARED);
1242 op->enemy = NULL; 1242 op->enemy = NULL;
1243} 1243}
1244 1244
2050 CLEAR_FLAG (item, FLAG_ANIMATE); 2050 CLEAR_FLAG (item, FLAG_ANIMATE);
2051 item->face = item->arch->clone.face; 2051 item->face = item->arch->clone.face;
2052 item->speed = 0; 2052 item->speed = 0;
2053 update_ob_speed (item); 2053 update_ob_speed (item);
2054 } 2054 }
2055 if ((tmp = is_player_inv (item))) 2055 if ((tmp = item->in_player ()))
2056 esrv_update_item (UPD_ANIM, tmp, item); 2056 esrv_update_item (UPD_ANIM, tmp, item);
2057 } 2057 }
2058 } 2058 }
2059 else if (item->type == ROD || item->type == HORN) 2059 else if (item->type == ROD || item->type == HORN)
2060 { 2060 {
2210 * 0 otherwise 2210 * 0 otherwise
2211 */ 2211 */
2212static int 2212static int
2213player_attack_door (object *op, object *door) 2213player_attack_door (object *op, object *door)
2214{ 2214{
2215
2216 /* If its a door, try to find a use a key. If we do destroy the door, 2215 /* If its a door, try to find a use a key. If we do destroy the door,
2217 * might as well return immediately as there is nothing more to do - 2216 * might as well return immediately as there is nothing more to do -
2218 * otherwise, we fall through to the rest of the code. 2217 * otherwise, we fall through to the rest of the code.
2219 */ 2218 */
2220 object *key = find_key (op, op, door); 2219 object *key = find_key (op, op, door);
2258 * It should keep the code cleaner. 2257 * It should keep the code cleaner.
2259 * When this is called, the players direction has been updated 2258 * When this is called, the players direction has been updated
2260 * (taking into account confusion.) The player is also actually 2259 * (taking into account confusion.) The player is also actually
2261 * going to try and move (not fire weapons). 2260 * going to try and move (not fire weapons).
2262 */ 2261 */
2263
2264void 2262void
2265move_player_attack (object *op, int dir) 2263move_player_attack (object *op, int dir)
2266{ 2264{
2267 object *tmp, *mon; 2265 object *tmp, *mon;
2268 sint16 nx, ny; 2266 sint16 nx, ny;
2270 maptile *m; 2268 maptile *m;
2271 2269
2272 nx = freearr_x[dir] + op->x; 2270 nx = freearr_x[dir] + op->x;
2273 ny = freearr_y[dir] + op->y; 2271 ny = freearr_y[dir] + op->y;
2274 2272
2275 on_battleground = op_on_battleground (op, NULL, NULL); 2273 on_battleground = op_on_battleground (op, 0, 0);
2276 2274
2277 /* If braced, or can't move to the square, and it is not out of the 2275 /* If braced, or can't move to the square, and it is not out of the
2278 * map, attack it. Note order of if statement is important - don't 2276 * map, attack it. Note order of if statement is important - don't
2279 * want to be calling move_ob if braced, because move_ob will move the 2277 * want to be calling move_ob if braced, because move_ob will move the
2280 * player. This is a pretty nasty hack, because if we could 2278 * player. This is a pretty nasty hack, because if we could
2292 return; /* Don't think this should happen */ 2290 return; /* Don't think this should happen */
2293 } 2291 }
2294 else 2292 else
2295 m = op->map; 2293 m = op->map;
2296 2294
2297 if ((tmp = get_map_ob (m, nx, ny)) == NULL) 2295 if ((tmp = GET_MAP_OB (m, nx, ny)) == NULL)
2298 { 2296 {
2299 /* LOG(llevError,"player_move_attack: get_map_ob returns NULL, but player can not more there.\n"); */ 2297 /* LOG(llevError,"player_move_attack: GET_MAP_OB returns NULL, but player can not move there.\n"); */
2300 return; 2298 return;
2301 } 2299 }
2302 2300
2303 mon = NULL; 2301 mon = 0;
2304 /* Go through all the objects, and find ones of interest. Only stop if 2302 /* Go through all the objects, and find ones of interest. Only stop if
2305 * we find a monster - that is something we know we want to attack. 2303 * we find a monster - that is something we know we want to attack.
2306 * if its a door or barrel (can roll) see if there may be monsters 2304 * if its a door or barrel (can roll) see if there may be monsters
2307 * on the space 2305 * on the space
2308 */ 2306 */
2309 while (tmp != NULL) 2307 while (tmp)
2310 { 2308 {
2311 if (tmp == op) 2309 if (tmp == op)
2312 { 2310 {
2313 tmp = tmp->above; 2311 tmp = tmp->above;
2314 continue; 2312 continue;
2324 mon = tmp; 2322 mon = tmp;
2325 2323
2326 tmp = tmp->above; 2324 tmp = tmp->above;
2327 } 2325 }
2328 2326
2329 if (mon == NULL) /* This happens anytime the player tries to move */ 2327 if (!mon) /* This happens anytime the player tries to move */
2330 return; /* into a wall */ 2328 return; /* into a wall */
2331 2329
2332 if (mon->head != NULL) 2330 if (mon->head)
2333 mon = mon->head; 2331 mon = mon->head;
2334 2332
2335 if ((mon->type == DOOR && mon->stats.hp >= 0) || (mon->type == LOCKED_DOOR)) 2333 if ((mon->type == DOOR && mon->stats.hp >= 0) || (mon->type == LOCKED_DOOR))
2336 if (player_attack_door (op, mon)) 2334 if (player_attack_door (op, mon))
2337 return; 2335 return;
2374 * attack them either. 2372 * attack them either.
2375 */ 2373 */
2376 if ((mon->type == PLAYER || mon->enemy != op) && 2374 if ((mon->type == PLAYER || mon->enemy != op) &&
2377 (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) && ( 2375 (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) && (
2378#ifdef PROHIBIT_PLAYERKILL 2376#ifdef PROHIBIT_PLAYERKILL
2379 (op->contr->peaceful 2377 (op->contr->peaceful
2380 || (mon->type == PLAYER 2378 || (mon->type == PLAYER
2381 && mon->contr-> 2379 && mon->contr->
2382 peaceful)) && 2380 peaceful)) &&
2383#else 2381#else
2384 op->contr->peaceful && 2382 op->contr->peaceful &&
2385#endif 2383#endif
2386 !on_battleground)) 2384 !on_battleground))
2387 { 2385 {
2388 if (!op->contr->braced) 2386 if (!op->contr->braced)
2389 { 2387 {
2390 play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); 2388 play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER);
2391 (void) push_ob (mon, dir, op); 2389 (void) push_ob (mon, dir, op);
2392 } 2390 }
2393 else 2391 else
2394 {
2395 new_draw_info (0, 0, op, "You withhold your attack"); 2392 new_draw_info (0, 0, op, "You withhold your attack");
2396 } 2393
2397 if (op->contr->tmp_invis || op->hide) 2394 if (op->contr->tmp_invis || op->hide)
2398 make_visible (op); 2395 make_visible (op);
2399 } 2396 }
2400 2397
2401 /* If the object is a boulder or other rollable object, then 2398 /* If the object is a boulder or other rollable object, then
2429 op->speed_left += op->speed / op->contr->weapon_sp; 2426 op->speed_left += op->speed / op->contr->weapon_sp;
2430 2427
2431 op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */ 2428 op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */
2432 } 2429 }
2433 2430
2434 skill_attack (mon, op, 0, NULL, NULL); 2431 skill_attack (mon, op, 0, 0, 0);
2435 2432
2436 /* If attacking another player, that player gets automatic 2433 /* If attacking another player, that player gets automatic
2437 * hitback, and doesn't loose luck either. 2434 * hitback, and doesn't loose luck either.
2438 * Disable hitback on the battleground or if the target is 2435 * Disable hitback on the battleground or if the target is
2439 * the wiz. 2436 * the wiz.
2441 if (mon->type == PLAYER && mon->stats.hp >= 0 && !mon->contr->has_hit && !on_battleground && !QUERY_FLAG (mon, FLAG_WIZ)) 2438 if (mon->type == PLAYER && mon->stats.hp >= 0 && !mon->contr->has_hit && !on_battleground && !QUERY_FLAG (mon, FLAG_WIZ))
2442 { 2439 {
2443 short luck = mon->stats.luck; 2440 short luck = mon->stats.luck;
2444 2441
2445 mon->contr->has_hit = 1; 2442 mon->contr->has_hit = 1;
2446 skill_attack (op, mon, 0, NULL, NULL); 2443 skill_attack (op, mon, 0, 0, 0);
2447 mon->stats.luck = luck; 2444 mon->stats.luck = luck;
2448 } 2445 }
2446
2449 if (action_makes_visible (op)) 2447 if (action_makes_visible (op))
2450 make_visible (op); 2448 make_visible (op);
2451 } 2449 }
2452 } /* if player should attack something */ 2450 } /* if player should attack something */
2453} 2451}
2488 2486
2489 /* Add special check for newcs players and fire on - this way, the 2487 /* Add special check for newcs players and fire on - this way, the
2490 * server can handle repeat firing. 2488 * server can handle repeat firing.
2491 */ 2489 */
2492 if (op->contr->fire_on || (op->contr->run_on && pick != 0)) 2490 if (op->contr->fire_on || (op->contr->run_on && pick != 0))
2493 {
2494 op->direction = dir; 2491 op->direction = dir;
2495 }
2496 else 2492 else
2497 {
2498 op->direction = 0; 2493 op->direction = 0;
2499 } 2494
2500 /* Update how the player looks. Use the facing, so direction may 2495 /* Update how the player looks. Use the facing, so direction may
2501 * get reset to zero. This allows for full animation capabilities 2496 * get reset to zero. This allows for full animation capabilities
2502 * for players. 2497 * for players.
2503 */ 2498 */
2504 animate_object (op, op->facing); 2499 animate_object (op, op->facing);
3228 * at his savebed location, and that can have long lasting 3223 * at his savebed location, and that can have long lasting
3229 * spell effects. So first see if there is a spell effect 3224 * spell effects. So first see if there is a spell effect
3230 * on the space that might harm the player. 3225 * on the space that might harm the player.
3231 */ 3226 */
3232 will_kill_again = 0; 3227 will_kill_again = 0;
3233 for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) 3228 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above)
3234 if (tmp->type == SPELL_EFFECT) 3229 if (tmp->type == SPELL_EFFECT)
3235 will_kill_again |= tmp->attacktype; 3230 will_kill_again |= tmp->attacktype;
3236 3231
3237 if (will_kill_again) 3232 if (will_kill_again)
3238 { 3233 {
3580 if (mflags & P_OUT_OF_MAP) 3575 if (mflags & P_OUT_OF_MAP)
3581 continue; 3576 continue;
3582 if (OB_TYPE_MOVE_BLOCK (who, GET_MAP_MOVE_BLOCK (m, x, y))) 3577 if (OB_TYPE_MOVE_BLOCK (who, GET_MAP_MOVE_BLOCK (m, x, y)))
3583 continue; 3578 continue;
3584 3579
3585 for (tmp = get_map_ob (m, x, y); tmp; tmp = tmp->above) 3580 for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above)
3586 { 3581 {
3587 if ((player ||friendly) &&QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE)) 3582 if ((player ||friendly) &&QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE))
3588 return 1; 3583 return 1;
3589 else if (tmp->type == PLAYER) 3584 else if (tmp->type == PLAYER)
3590 { 3585 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines