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.82 by elmex, Wed Jan 3 02:30:52 2007 UTC vs.
Revision 1.85 by root, Thu Jan 4 16:19:32 2007 UTC

2084 */ 2084 */
2085 if ((op->contr->braced || !move_ob (op, dir, op)) && !out_of_map (op->map, nx, ny)) 2085 if ((op->contr->braced || !move_ob (op, dir, op)) && !out_of_map (op->map, nx, ny))
2086 { 2086 {
2087 if (OUT_OF_REAL_MAP (op->map, nx, ny)) 2087 if (OUT_OF_REAL_MAP (op->map, nx, ny))
2088 { 2088 {
2089 m = get_map_from_coord (op->map, &nx, &ny); 2089 m = op->map->xy_find (nx, ny);
2090 if (!m) 2090 if (!m)
2091 return; /* Don't think this should happen */ 2091 return; /* Don't think this should happen */
2092 } 2092 }
2093 else 2093 else
2094 m = op->map; 2094 m = op->map;
2095 2095
2096 if ((tmp = GET_MAP_OB (m, nx, ny)) == NULL) 2096 if (!(tmp = m->at (nx, ny).bot))
2097 {
2098 /* LOG(llevError,"player_move_attack: GET_MAP_OB returns NULL, but player can not move there.\n"); */
2099 return; 2097 return;
2100 }
2101 2098
2102 mon = 0; 2099 mon = 0;
2103 /* Go through all the objects, and find ones of interest. Only stop if 2100 /* Go through all the objects, and find ones of interest. Only stop if
2104 * we find a monster - that is something we know we want to attack. 2101 * we find a monster - that is something we know we want to attack.
2105 * if its a door or barrel (can roll) see if there may be monsters 2102 * if its a door or barrel (can roll) see if there may be monsters
2158 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) 2155 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)))
2159 { 2156 {
2160 /* If we're braced, we don't want to switch places with it */ 2157 /* If we're braced, we don't want to switch places with it */
2161 if (op->contr->braced) 2158 if (op->contr->braced)
2162 return; 2159 return;
2160
2163 play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); 2161 play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER);
2164 (void) push_ob (mon, dir, op); 2162 (void) push_ob (mon, dir, op);
2165 if (op->contr->tmp_invis || op->hide) 2163 if (op->contr->tmp_invis || op->hide)
2166 make_visible (op); 2164 make_visible (op);
2165
2167 return; 2166 return;
2168 } 2167 }
2169 2168
2170 /* in certain circumstances, you shouldn't attack friendly 2169 /* in certain circumstances, you shouldn't attack friendly
2171 * creatures. Note that if you are braced, you can't push 2170 * creatures. Note that if you are braced, you can't push
2185 !on_battleground)) 2184 !on_battleground))
2186 { 2185 {
2187 if (!op->contr->braced) 2186 if (!op->contr->braced)
2188 { 2187 {
2189 play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); 2188 play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER);
2190 (void) push_ob (mon, dir, op); 2189 push_ob (mon, dir, op);
2191 } 2190 }
2192 else 2191 else
2193 new_draw_info (0, 0, op, "You withhold your attack"); 2192 new_draw_info (0, 0, op, "You withhold your attack");
2194 2193
2195 if (op->contr->tmp_invis || op->hide) 2194 if (op->contr->tmp_invis || op->hide)
2210 * Way it works is like this: First, it must have some hit points 2209 * Way it works is like this: First, it must have some hit points
2211 * and be living. Then, it must be one of the following: 2210 * and be living. Then, it must be one of the following:
2212 * 1) Not a player, 2) A player, but of a different party. Note 2211 * 1) Not a player, 2) A player, but of a different party. Note
2213 * that party_number -1 is no party, so attacks can still happen. 2212 * that party_number -1 is no party, so attacks can still happen.
2214 */ 2213 */
2215
2216 else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) && 2214 else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) &&
2217 ((mon->type != PLAYER || op->contr->party == NULL || op->contr->party != mon->contr->party))) 2215 ((mon->type != PLAYER || op->contr->party == NULL || op->contr->party != mon->contr->party)))
2218 { 2216 {
2219 2217
2220 /* If the player hasn't hit something this tick, and does 2218 /* If the player hasn't hit something this tick, and does
2254int 2252int
2255move_player (object *op, int dir) 2253move_player (object *op, int dir)
2256{ 2254{
2257 int pick; 2255 int pick;
2258 2256
2259 if (op->map == NULL || op->map->in_memory != MAP_IN_MEMORY) 2257 if (!op->map || op->map->in_memory != MAP_IN_MEMORY)
2260 return 0; 2258 return 0;
2261 2259
2262 /* Sanity check: make sure dir is valid */ 2260 /* Sanity check: make sure dir is valid */
2263 if ((dir < 0) || (dir >= 9)) 2261 if ((dir < 0) || (dir >= 9))
2264 { 2262 {
2265 LOG (llevError, "move_player: invalid direction %d\n", dir); 2263 LOG (llevError, "move_player: invalid direction %d\n", dir);
2266 return 0; 2264 return 0;
2267 } 2265 }
2268 2266
2269 /* peterm: added following line */ 2267 /* peterm: added following line */
2270 if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) 2268 if (QUERY_FLAG (op, FLAG_CONFUSED) && dir)
2271 dir = absdir (dir + RANDOM () % 3 + RANDOM () % 3 - 2); 2269 dir = absdir (dir + RANDOM () % 3 + RANDOM () % 3 - 2);
2272 2270
2273 op->facing = dir; 2271 op->facing = dir;
2274 2272
2352 2350
2353 /* call this here - we also will call this in do_ericserver, but 2351 /* call this here - we also will call this in do_ericserver, but
2354 * the players time has been increased when doericserver has been 2352 * the players time has been increased when doericserver has been
2355 * called, so we recheck it here. 2353 * called, so we recheck it here.
2356 */ 2354 */
2357 op->contr->ns->handle_command (); 2355 if (op->contr->ns->handle_command ())
2356 return 1;
2358 2357
2359 if (op->speed_left < 0) 2358 if (op->speed_left > 0)
2360 return 0; 2359 {
2361
2362 if (op->direction && (op->contr->run_on || op->contr->fire_on)) 2360 if (op->direction && (op->contr->run_on || op->contr->fire_on))
2363 { 2361 {
2364 /* All move commands take 1 tick, at least for now */ 2362 /* All move commands take 1 tick, at least for now */
2365 op->speed_left--; 2363 op->speed_left--;
2366 2364
2367 /* Instead of all the stuff below, let move_player take care 2365 /* Instead of all the stuff below, let move_player take care
2368 * of it. Also, some of the skill stuff is only put in 2366 * of it. Also, some of the skill stuff is only put in
2369 * there, as well as the confusion stuff. 2367 * there, as well as the confusion stuff.
2370 */ 2368 */
2371 move_player (op, op->direction); 2369 move_player (op, op->direction);
2372 if (op->speed_left > 0) 2370
2373 return 1; 2371 return op->speed_left > 0;
2374 else 2372 }
2375 return 0;
2376 } 2373 }
2377 2374
2378 return 0; 2375 return 0;
2379} 2376}
2380 2377
3225 3222
3226 skop = find_obj_by_type_subtype (op, SKILL, SK_HIDING); 3223 skop = find_obj_by_type_subtype (op, SKILL, SK_HIDING);
3227 3224
3228 /* its *extremely* hard to run and sneak/hide at the same time! */ 3225 /* its *extremely* hard to run and sneak/hide at the same time! */
3229 if (op->type == PLAYER && op->contr->run_on) 3226 if (op->type == PLAYER && op->contr->run_on)
3230 {
3231 if (!skop || num >= skop->level) 3227 if (!skop || num >= skop->level)
3232 { 3228 {
3233 new_draw_info (NDI_UNIQUE, 0, op, "You ran too much! You are no longer hidden!"); 3229 new_draw_info (NDI_UNIQUE, 0, op, "You ran too much! You are no longer hidden!");
3234 make_visible (op); 3230 make_visible (op);
3235 return; 3231 return;
3236 } 3232 }
3237 else 3233 else
3238 num += 20; 3234 num += 20;
3239 } 3235
3240 num += op->map->difficulty; 3236 num += op->map->difficulty;
3241 hide = hideability (op); /* modify by terrain hidden level */ 3237 hide = hideability (op); /* modify by terrain hidden level */
3242 num -= hide; 3238 num -= hide;
3239
3243 if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0)) 3240 if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0))
3244 { 3241 {
3245 make_visible (op); 3242 make_visible (op);
3246 if (op->type == PLAYER) 3243 if (op->type == PLAYER)
3247 new_draw_info (NDI_UNIQUE, 0, op, "You moved out of hiding! You are visible!"); 3244 new_draw_info (NDI_UNIQUE, 0, op, "You moved out of hiding! You are visible!");
3248 } 3245 }
3249 else if (op->type == PLAYER && skop) 3246 else if (op->type == PLAYER && skop)
3250 {
3251 change_exp (op, calc_skill_exp (op, NULL, skop), skop->skill, 0); 3247 change_exp (op, calc_skill_exp (op, NULL, skop), skop->skill, 0);
3252 }
3253} 3248}
3254 3249
3255/* determine if who is standing near a hostile creature. */ 3250/* determine if who is standing near a hostile creature. */
3256 3251
3257int 3252int

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines