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.187 by root, Mon Apr 21 07:07:36 2008 UTC vs.
Revision 1.191 by elmex, Thu Apr 24 10:42:22 2008 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 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
239 set_dragon_name (ob, abil, skin); 239 set_dragon_name (ob, abil, skin);
240 } 240 }
241 241
242 new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); 242 new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!");
243 243
244 esrv_new_player (this, ob->weight + ob->carrying); 244 esrv_new_player (this);
245 245
246 ob->update_stats (); 246 ob->update_stats ();
247 247
248 ns->floorbox_update (); 248 ns->floorbox_update ();
249 esrv_send_inventory (ob, ob); 249 esrv_send_inventory (ob, ob);
291player::set_object (object *op) 291player::set_object (object *op)
292{ 292{
293 ob = observe = op; 293 ob = observe = op;
294 ob->contr = this; /* this aren't yet in archetype */ 294 ob->contr = this; /* this aren't yet in archetype */
295 295
296 ob->speed = 1.0f; 296 ob->speed = 1.0f;
297 ob->speed_left = 0.5f; 297 ob->speed_left = 0.5f;
298 298
299 ob->direction = 5; /* So player faces south */ 299 ob->direction = 5; /* So player faces south */
300 300
301 ob->flag [FLAG_READY_WEAPON] = false; 301 ob->flag [FLAG_READY_WEAPON] = false;
302 ob->flag [FLAG_READY_SKILL] = false; 302 ob->flag [FLAG_READY_SKILL] = false;
303 ob->flag [FLAG_READY_BOW] = false; 303 ob->flag [FLAG_READY_BOW] = false;
304 304
851 */ 851 */
852void 852void
853player::chargen_race_done () 853player::chargen_race_done ()
854{ 854{
855 /* this must before then initial items are given */ 855 /* this must before then initial items are given */
856 esrv_new_player (ob->contr, ob->weight + ob->carrying); 856 esrv_new_player (ob->contr);
857 857
858 treasurelist *tl = treasurelist::find ("starting_wealth"); 858 treasurelist *tl = treasurelist::find ("starting_wealth");
859 if (tl) 859 if (tl)
860 create_treasure (tl, ob, 0, 0, 0); 860 create_treasure (tl, ob, 0, 0, 0);
861 861
1763 return; 1763 return;
1764 } 1764 }
1765 } 1765 }
1766 else if (item->type == ROD || item->type == HORN) 1766 else if (item->type == ROD || item->type == HORN)
1767 { 1767 {
1768 if (item->stats.hp < MAX (item->inv->stats.sp, item->inv->stats.grace)) 1768 sint16 spell_sp = MAX (item->inv->stats.sp, item->inv->stats.grace);
1769
1770 // using the maximum of the rods charge allows at least one spell cast
1771 // for a rod or horn, this fixes some broken rods.
1772 if (item->stats.hp < MIN (spell_sp, item->stats.maxhp))
1769 { 1773 {
1770 op->contr->play_sound (sound_find ("wand_poof")); 1774 op->contr->play_sound (sound_find ("wand_poof"));
1771 1775
1772 if (item->type == ROD) 1776 if (item->type == ROD)
1773 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0)); 1777 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0));
1792 CLEAR_FLAG (item, FLAG_ANIMATE); 1796 CLEAR_FLAG (item, FLAG_ANIMATE);
1793 item->face = item->arch->face; 1797 item->face = item->arch->face;
1794 item->set_speed (0); 1798 item->set_speed (0);
1795 } 1799 }
1796 1800
1797 if ((tmp = item->in_player ())) 1801 if (object *pl = item->visible_to ())
1798 esrv_update_item (UPD_ANIM, tmp, item); 1802 esrv_update_item (UPD_ANIM, pl, item);
1799 } 1803 }
1800 } 1804 }
1801 else if (item->type == ROD || item->type == HORN) 1805 else if (item->type == ROD || item->type == HORN)
1802 drain_rod_charge (item); 1806 drain_rod_charge (item);
1803 } 1807 }
1980 remove_door2 (door); /* remove door without violence ;-) */ 1984 remove_door2 (door); /* remove door without violence ;-) */
1981 } 1985 }
1982 1986
1983 /* Do this after we print the message */ 1987 /* Do this after we print the message */
1984 key->decrease (); /* Use up one of the keys */ 1988 key->decrease (); /* Use up one of the keys */
1985 /* Need to update the weight the container the key was in */
1986 if (container != op)
1987 esrv_update_item (UPD_WEIGHT, op, container);
1988 1989
1989 return 1; /* Nothing more to do below */ 1990 return 1; /* Nothing more to do below */
1990 } 1991 }
1991 else if (door->type == LOCKED_DOOR) 1992 else if (door->type == LOCKED_DOOR)
1992 { 1993 {
2271 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) 2272 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE))
2272 { 2273 {
2273 op->play_sound (sound_find ("ob_evaporate")); 2274 op->play_sound (sound_find ("ob_evaporate"));
2274 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); 2275 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp));
2275 2276
2276 if (op->contr)
2277 esrv_del_item (op->contr, tmp->count);
2278
2279 tmp->destroy (); 2277 tmp->destroy ();
2280 CLEAR_FLAG (op, FLAG_LIFESAVE); 2278 CLEAR_FLAG (op, FLAG_LIFESAVE);
2281 2279
2282 if (op->stats.hp < 0) 2280 if (op->stats.hp < 0)
2283 op->stats.hp = op->stats.maxhp; 2281 op->stats.hp = op->stats.maxhp;
2295 return 0; 2293 return 0;
2296} 2294}
2297 2295
2298/* This goes throws the inventory and removes unpaid objects, and puts them 2296/* This goes throws the inventory and removes unpaid objects, and puts them
2299 * back in the map (location and map determined by values of env). This 2297 * back in the map (location and map determined by values of env). This
2300 * function will descend into containers. op is the object to start the search 2298 * function will descend into containers. op is the object to start the search
2301 * from. 2299 * from.
2302 */ 2300 */
2303static void 2301static void
2304drop_unpaid_items (object *op, object *env) 2302drop_unpaid_items (object *op, object *env)
2305{ 2303{
2306 while (op) 2304 while (op)
2307 { 2305 {
2308 object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ 2306 object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */
2309 2307
2310 if (QUERY_FLAG (op, FLAG_UNPAID)) 2308 if (QUERY_FLAG (op, FLAG_UNPAID))
2311 {
2312 if (env->type == PLAYER)
2313 esrv_del_item (env->contr, op->count);
2314
2315 op->insert_at (env); 2309 op->insert_at (env);
2316 }
2317 else if (op->inv) 2310 else if (op->inv)
2318 drop_unpaid_items (op->inv, env); 2311 drop_unpaid_items (op->inv, env);
2319 2312
2320 op = next; 2313 op = next;
2321 } 2314 }
3455 else 3448 else
3456 { 3449 {
3457 /* generate misc. treasure */ 3450 /* generate misc. treasure */
3458 tmp = arch_to_object (tr->item); 3451 tmp = arch_to_object (tr->item);
3459 new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp)); 3452 new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp));
3460 tmp = insert_ob_in_ob (tmp, who); 3453 who->insert (tmp);
3461 if (who->type == PLAYER)
3462 esrv_send_item (who, tmp);
3463 } 3454 }
3464} 3455}
3465 3456
3466/** 3457/**
3467 * Unready an object for a player. This function does nothing if the object was 3458 * Unready an object for a player. This function does nothing if the object was

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines