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.254 by root, Fri Mar 26 00:05:45 2010 UTC vs.
Revision 1.262 by root, Sat Apr 3 03:35:33 2010 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 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 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
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
136 esrv_send_inventory (ob, ob); 136 esrv_send_inventory (ob, ob);
137 esrv_add_spells (this, 0); 137 esrv_add_spells (this, 0);
138 138
139 ob->flag [FLAG_READY_WEAPON] = false; 139 ob->flag [FLAG_READY_WEAPON] = false;
140 ob->flag [FLAG_READY_SKILL] = false; 140 ob->flag [FLAG_READY_SKILL] = false;
141 ob->flag [FLAG_READY_RANGE] = false;
141 ob->flag [FLAG_READY_BOW] = false; 142 ob->flag [FLAG_READY_BOW] = false;
142 143
143 for (object *op = ob->inv; op; op = op->below) 144 for (object *op = ob->inv; op; op = op->below)
144 if (op->flag [FLAG_APPLIED]) 145 if (op->flag [FLAG_APPLIED])
145 switch (op->type) 146 switch (op->type)
146 { 147 {
147 case SKILL: 148 case SKILL:
148 op->flag [FLAG_APPLIED] = false; 149 op->flag [FLAG_APPLIED] = false;
149 break; 150 break;
150 151
152 case SPELL:
151 case WAND: 153 case WAND:
152 case ROD: 154 case ROD:
153 case HORN: 155 case HORN:
154 case BOW: 156 case BOW:
157 case RANGED:
155 ranged_ob = op; 158 ranged_ob = op;
159 op->flag [FLAG_APPLIED] = false;
156 break; 160 break;
157 161
158 case WEAPON: 162 case WEAPON:
159 combat_ob = op; 163 combat_ob = op;
164 op->flag [FLAG_APPLIED] = false;
160 break; 165 break;
161 } 166 }
162 167
168 ob->update_stats (); // we unapplied stuff above
169
163 ob->current_weapon = 0; 170 ob->current_weapon = 0;
164 ob->change_weapon (combat_ob ? combat_ob : ranged_ob); 171 if (object *item = combat_ob ? combat_ob : ranged_ob)
165 activate (); // change_weapon also activates, but this doesn't hurt 172 ob->apply (item);
173
174 activate ();
166 175
167 INVOKE_PLAYER (CONNECT, this); 176 INVOKE_PLAYER (CONNECT, this);
168 INVOKE_PLAYER (LOGIN, this); 177 INVOKE_PLAYER (LOGIN, this);
169} 178}
170 179
838 dir = absdir (4 + rv.direction); 847 dir = absdir (4 + rv.direction);
839 for (diff = 0; diff < 3; diff++) 848 for (diff = 0; diff < 3; diff++)
840 { 849 {
841 int m = 1 - rndm (2) * 2; 850 int m = 1 - rndm (2) * 2;
842 851
843 if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op))) 852 if (op->move (absdir (dir + diff * m)) || (diff == 0 && op->move (absdir (dir - diff * m))))
844 return; 853 return;
845 } 854 }
846 855
847 /* Cornered, get rid of scared */ 856 /* Cornered, get rid of scared */
848 CLEAR_FLAG (op, FLAG_SCARED); 857 CLEAR_FLAG (op, FLAG_SCARED);
858{ 867{
859 object *tmp, *next; 868 object *tmp, *next;
860 int stop = 0; 869 int stop = 0;
861 int wvratio; 870 int wvratio;
862 871
863 /* if you're flying, you cna't pick up anything */ 872 /* if you're flying, you can't pick up anything */
864 if (op->move_type & MOVE_FLYING) 873 if (op->move_type & MOVE_FLYING)
865 return 1; 874 return 1;
866 875
867 next = op->below; 876 next = op->below;
868 877
1584 { 1593 {
1585 LOG (llevError, "Object %s lacks a spell\n", &item->name); 1594 LOG (llevError, "Object %s lacks a spell\n", &item->name);
1586 return; 1595 return;
1587 } 1596 }
1588 1597
1589 if (!op->change_weapon (item)) 1598 if (!op->apply (item))
1590 return; 1599 return;
1591 1600
1592 if (item->type == WAND) 1601 if (item->type == WAND)
1593 { 1602 {
1594 if (item->stats.food <= 0) 1603 if (item->stats.food <= 0)
1667 if (op->speed_left > 0.f) 1676 if (op->speed_left > 0.f)
1668 --op->speed_left; 1677 --op->speed_left;
1669 else 1678 else
1670 return false; 1679 return false;
1671 1680
1672 if (!op->change_weapon (ob)) 1681 if (!op->apply (ob))
1673 return false; 1682 return false;
1674 1683
1675 /* check for loss of invisiblity/hide */ 1684 /* check for loss of invisiblity/hide */
1676 if (action_makes_visible (op)) 1685 if (action_makes_visible (op))
1677 make_visible (op); 1686 make_visible (op);
1690 apply_map_builder (op, dir); 1699 apply_map_builder (op, dir);
1691 break; 1700 break;
1692 1701
1693 case SKILL: 1702 case SKILL:
1694 do_skill (op, op, ob, dir, 0); 1703 do_skill (op, op, ob, dir, 0);
1704 break;
1705
1706 case RANGED:
1707 //TODO: use skill to fire (do_skill_fire?)
1695 break; 1708 break;
1696 1709
1697 default: 1710 default:
1698 fire_misc_object (op, dir); 1711 fire_misc_object (op, dir);
1699 break; 1712 break;
1856 * going to try and move (not fire weapons). 1869 * going to try and move (not fire weapons).
1857 */ 1870 */
1858bool 1871bool
1859move_player_attack (object *op, int dir) 1872move_player_attack (object *op, int dir)
1860{ 1873{
1861 if (!op->contr->braced && op->speed_left > 0.f && move_ob (op, dir, op)) 1874 if (!op->contr->braced && op->speed_left > 0.f && op->move (dir))
1862 { 1875 {
1863 --op->speed_left; 1876 --op->speed_left;
1864 return true; 1877 return true;
1865 } 1878 }
1866 1879
2126 2139
2127 if (op->stats.hp < 0) 2140 if (op->stats.hp < 0)
2128 op->stats.hp = op->stats.maxhp; 2141 op->stats.hp = op->stats.maxhp;
2129 2142
2130 if (op->stats.food < 0) 2143 if (op->stats.food < 0)
2131 op->stats.food = 999; 2144 op->stats.food = MAX_FOOD;
2132 2145
2133 op->update_stats (); 2146 op->update_stats ();
2134 return 1; 2147 return 1;
2135 } 2148 }
2136 2149
2365 2378
2366 if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) 2379 if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON)
2367 { 2380 {
2368 op->statusmsg ("You blindly grab for a bite of food. " 2381 op->statusmsg ("You blindly grab for a bite of food. "
2369 "H<To prevent you from starving, you ate some random item from your backpack.>"); 2382 "H<To prevent you from starving, you ate some random item from your backpack.>");
2370 manual_apply (op, tmp, 0); 2383 op->apply (tmp);
2371 2384
2372 if (op->stats.food >= 0 || op->stats.hp < 0) 2385 if (op->stats.food >= 0 || op->stats.hp < 0)
2373 break; 2386 break;
2374 } 2387 }
2375 else if (tmp->type == FLESH) 2388 else if (tmp->type == FLESH)
2381 */ 2394 */
2382 if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) 2395 if (op->stats.food < 0 && op->stats.hp >= 0 && flesh)
2383 { 2396 {
2384 op->statusmsg ("You blindly grab for a bite of food. " 2397 op->statusmsg ("You blindly grab for a bite of food. "
2385 "H<To prevent you from starving, you ate some random item from your backpack.>"); 2398 "H<To prevent you from starving, you ate some random item from your backpack.>");
2386 manual_apply (op, flesh, 0); 2399 op->apply (flesh);
2387 } 2400 }
2388 2401
2389 // If player is still starving, alert him! 2402 // If player is still starving, alert him!
2390 if (op->stats.food < 0) 2403 if (op->stats.food < 0)
2391 op->failmsg ("You are starving! " 2404 op->failmsg ("You are starving! "
2447 cure_disease (op, 0, 0); /* remove any disease */ 2460 cure_disease (op, 0, 0); /* remove any disease */
2448 2461
2449 max_it (op->stats.hp , op->stats.maxhp); 2462 max_it (op->stats.hp , op->stats.maxhp);
2450 max_it (op->stats.sp , op->stats.maxsp); 2463 max_it (op->stats.sp , op->stats.maxsp);
2451 max_it (op->stats.grace, op->stats.maxgrace); 2464 max_it (op->stats.grace, op->stats.maxgrace);
2452
2453 if (op->stats.food <= 0) 2465 max_it (op->stats.food , 200);
2454 op->stats.food = 999;
2455 2466
2456 // remove all spell effects that are active 2467 // remove all spell effects that are active
2457 // to avoid long-term effects such as word-of-recall 2468 // to avoid long-term effects such as word-of-recall
2458 for (object *item = op->inv; item; ) 2469 for (object *item = op->inv; item; )
2459 { 2470 {
3223 new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp)); 3234 new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp));
3224 who->insert (tmp); 3235 who->insert (tmp);
3225 } 3236 }
3226} 3237}
3227 3238
3228/**
3229 * Unready an object for a player. This function does nothing if the object was
3230 * not readied.
3231 */
3232void
3233player_unready_range_ob (player *pl, object *ob)
3234{
3235 if (pl->ob->current_weapon == ob)
3236 pl->ob->current_weapon = 0;
3237
3238 if (pl->combat_ob == ob)
3239 pl->combat_ob = 0;
3240
3241 if (pl->ranged_ob == ob)
3242 pl->ranged_ob = 0;
3243}
3244
3245//-GPL 3239//-GPL
3246 3240
3247sint8 3241sint8
3248player::darkness_at (maptile *map, int x, int y) const 3242player::darkness_at (maptile *map, int x, int y) const
3249{ 3243{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines