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.278 by root, Sun May 9 22:33:29 2010 UTC vs.
Revision 1.287 by root, Sat Aug 13 23:09:54 2011 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
22 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 23 */
24 24
25//+GPL 25//+GPL
26 26
27#include <algorithm>
28#include <functional>
29
27#include <global.h> 30#include <global.h>
28#include <sproto.h> 31#include <sproto.h>
29#include <sounds.h> 32#include <sounds.h>
30#include <living.h> 33#include <living.h>
31#include <object.h> 34#include <object.h>
32#include <spells.h> 35#include <spells.h>
33#include <skills.h> 36#include <skills.h>
34 37
35#include <algorithm>
36#include <functional>
37
38playervec players; 38playervec players;
39 39
40/* This loads the first map an puts the player on it. */ 40/* This loads the first map an puts the player on it. */
41static void 41static void
42set_first_map (object *op) 42set_first_map (object *op)
181player::set_object (object *op) 181player::set_object (object *op)
182{ 182{
183 ob = observe = viewpoint = op; 183 ob = observe = viewpoint = op;
184 ob->contr = this; /* this aren't yet in archetype */ 184 ob->contr = this; /* this aren't yet in archetype */
185 185
186 ob->set_speed (1.0f); 186 ob->speed = 1.0f; // object still inactive, keep it that way
187 ob->speed_left = 0.5f; 187 ob->speed_left = 0.5f;
188 188
189 ob->direction = 5; /* So player faces south */ 189 ob->direction = 5; /* So player faces south */
190} 190}
191 191
536 } 536 }
537 } 537 }
538 538
539 /* Here we remove duplicated skills (as duplicated spell objects have 539 /* Here we remove duplicated skills (as duplicated spell objects have
540 * _very_ confusing effects for players), which could for instance be 540 * _very_ confusing effects for players), which could for instance be
541 * generated by bad treasurelists. - elmex 541 * generated by multiple treasurelists specifying the same skills.
542 */ 542 */
543 if (op->type == SKILL) 543 if (op->type == SKILL)
544 { 544 {
545 for (object *tmp = op->below; tmp; tmp = tmp->below) 545 for (object *tmp = op->below; tmp; tmp = tmp->below)
546 if (tmp->type == op->type && tmp->name == op->name) 546 if (tmp->type == op->type && tmp->name == op->name)
547 { 547 {
548 op->destroy (); 548 op->destroy ();
549 LOG (llevError,
550 "give_initial_items: Removing duplicate skill %s\n", &tmp->name);
551 break; 549 break;
552 } 550 }
553 551
554 if (op->nrof > 1) 552 if (op->nrof > 1)
555 op->nrof = 1; 553 op->nrof = 1;
1867 || mon->flag [FLAG_CAN_ROLL]) 1865 || mon->flag [FLAG_CAN_ROLL])
1868 && mon != op) 1866 && mon != op)
1869 break; 1867 break;
1870 } 1868 }
1871 1869
1872 if (!mon) /* This happens anytime the player tries to move */ 1870 /* no monster == player tries to move into a wall or so */
1873 return false; /* into a wall */ 1871 if (!mon)
1872 {
1873 for (object *ob = m->at (nx, ny).top; ob; ob = ob->below)
1874 if (op->move_type & ob->move_block)
1875 {
1876 if (ob->move_block == MOVE_ALL)
1877 move_into_wall (op, ob);
1878 else
1879 {
1880 if (op->contr->ns->bumpmsg)
1881 {
1882 op->play_sound (sound_find ("blocked_move"));
1883
1884 op->statusmsg (ob->invisible
1885 ? "Something blocks you."
1886 : format ("Something blocks you from entering the %s.", query_name (ob))
1887 );
1888 }
1889 }
1890
1891 break;
1892 }
1893
1894 return false;
1895 }
1874 1896
1875 mon = mon->head_ (); 1897 mon = mon->head_ ();
1876 1898
1877 if ((mon->type == DOOR && mon->stats.hp >= 0) || (mon->type == LOCKED_DOOR)) 1899 if ((mon->type == DOOR && mon->stats.hp >= 0) || (mon->type == LOCKED_DOOR))
1878 if (op->contr->weapon_sp_left > 0.f) 1900 if (op->contr->weapon_sp_left > 0.f)
1993} 2015}
1994 2016
1995bool 2017bool
1996move_player (object *op, int dir) 2018move_player (object *op, int dir)
1997{ 2019{
1998 if (!op->map || op->map->in_memory != MAP_ACTIVE) 2020 if (!op->map || op->map->state != MAP_ACTIVE)
1999 return 0; 2021 return 0;
2000 2022
2001 /* Sanity check: make sure dir is valid */ 2023 /* Sanity check: make sure dir is valid */
2002 if (dir < 0 || dir > 8) 2024 if (dir < 0 || dir > 8)
2003 { 2025 {
2159 op->invisible = 1000; 2181 op->invisible = 1000;
2160 /* the socket code flashes the player visible/invisible 2182 /* the socket code flashes the player visible/invisible
2161 * depending on the value of invisible, so we need to 2183 * depending on the value of invisible, so we need to
2162 * alternate it here for it to work correctly. 2184 * alternate it here for it to work correctly.
2163 */ 2185 */
2164 if (pticks & 2) 2186 if (server_tick & 2)
2165 op->invisible--; 2187 op->invisible--;
2166 } 2188 }
2167 else if (op->invisible && !(op->flag [FLAG_MAKE_INVIS])) 2189 else if (op->invisible && !(op->flag [FLAG_MAKE_INVIS]))
2168 { 2190 {
2169 if (!op->invisible--) 2191 if (!op->invisible--)
2658 if (will_kill_again) 2680 if (will_kill_again)
2659 { 2681 {
2660 object *force; 2682 object *force;
2661 int at; 2683 int at;
2662 2684
2663 force = get_archetype (FORCE_NAME); 2685 force = archetype::get (FORCE_NAME);
2664 /* 50 ticks should be enough time for the spell to abate */ 2686 /* 50 ticks should be enough time for the spell to abate */
2665 force->speed_left = -5.f; 2687 force->speed_left = -5.f;
2666 force->set_speed (0.1f); 2688 force->set_speed (0.1f);
2667 force->set_flag (FLAG_APPLIED); 2689 force->set_flag (FLAG_APPLIED);
2668 2690

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines