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.87 by elmex, Fri Jan 5 16:17:29 2007 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines