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.259 by root, Sun Mar 28 02:53:46 2010 UTC vs.
Revision 1.260 by root, Fri Apr 2 03:41:25 2010 UTC

147 { 147 {
148 case SKILL: 148 case SKILL:
149 op->flag [FLAG_APPLIED] = false; 149 op->flag [FLAG_APPLIED] = false;
150 break; 150 break;
151 151
152 case SPELL:
152 case WAND: 153 case WAND:
153 case ROD: 154 case ROD:
154 case HORN: 155 case HORN:
155 case BOW: 156 case BOW:
157 case RANGED:
156 ranged_ob = op; 158 ranged_ob = op;
159 op->flag [FLAG_APPLIED] = false;
157 break; 160 break;
158 161
159 case WEAPON: 162 case WEAPON:
160 combat_ob = op; 163 combat_ob = op;
164 op->flag [FLAG_APPLIED] = false;
161 break; 165 break;
162 } 166 }
163 167
168 ob->update_stats (); // we unapplied stuff above
169
164 ob->current_weapon = 0; 170 ob->current_weapon = 0;
165 ob->change_weapon (combat_ob ? combat_ob : ranged_ob); 171 if (object *item = combat_ob ? combat_ob : ranged_ob)
166 activate (); // change_weapon also activates, but this doesn't hurt 172 ob->apply (item);
173
174 activate ();
167 175
168 INVOKE_PLAYER (CONNECT, this); 176 INVOKE_PLAYER (CONNECT, this);
169 INVOKE_PLAYER (LOGIN, this); 177 INVOKE_PLAYER (LOGIN, this);
170} 178}
171 179
1585 { 1593 {
1586 LOG (llevError, "Object %s lacks a spell\n", &item->name); 1594 LOG (llevError, "Object %s lacks a spell\n", &item->name);
1587 return; 1595 return;
1588 } 1596 }
1589 1597
1590 if (!op->change_weapon (item)) 1598 if (!op->apply (item))
1591 return; 1599 return;
1592 1600
1593 if (item->type == WAND) 1601 if (item->type == WAND)
1594 { 1602 {
1595 if (item->stats.food <= 0) 1603 if (item->stats.food <= 0)
1668 if (op->speed_left > 0.f) 1676 if (op->speed_left > 0.f)
1669 --op->speed_left; 1677 --op->speed_left;
1670 else 1678 else
1671 return false; 1679 return false;
1672 1680
1673 if (!op->change_weapon (ob)) 1681 if (!op->apply (ob))
1674 return false; 1682 return false;
1675 1683
1676 /* check for loss of invisiblity/hide */ 1684 /* check for loss of invisiblity/hide */
1677 if (action_makes_visible (op)) 1685 if (action_makes_visible (op))
1678 make_visible (op); 1686 make_visible (op);
1691 apply_map_builder (op, dir); 1699 apply_map_builder (op, dir);
1692 break; 1700 break;
1693 1701
1694 case SKILL: 1702 case SKILL:
1695 do_skill (op, op, ob, dir, 0); 1703 do_skill (op, op, ob, dir, 0);
1696 break;
1697
1698 case SKILL_TOOL:
1699 // change_weapon ensures that chosen_skill is uptodate
1700 do_skill (op, op, op->chosen_skill, dir, 0);
1701 break; 1704 break;
1702 1705
1703 default: 1706 default:
1704 fire_misc_object (op, dir); 1707 fire_misc_object (op, dir);
1705 break; 1708 break;
2132 2135
2133 if (op->stats.hp < 0) 2136 if (op->stats.hp < 0)
2134 op->stats.hp = op->stats.maxhp; 2137 op->stats.hp = op->stats.maxhp;
2135 2138
2136 if (op->stats.food < 0) 2139 if (op->stats.food < 0)
2137 op->stats.food = 999; 2140 op->stats.food = MAX_FOOD;
2138 2141
2139 op->update_stats (); 2142 op->update_stats ();
2140 return 1; 2143 return 1;
2141 } 2144 }
2142 2145
2453 cure_disease (op, 0, 0); /* remove any disease */ 2456 cure_disease (op, 0, 0); /* remove any disease */
2454 2457
2455 max_it (op->stats.hp , op->stats.maxhp); 2458 max_it (op->stats.hp , op->stats.maxhp);
2456 max_it (op->stats.sp , op->stats.maxsp); 2459 max_it (op->stats.sp , op->stats.maxsp);
2457 max_it (op->stats.grace, op->stats.maxgrace); 2460 max_it (op->stats.grace, op->stats.maxgrace);
2458
2459 if (op->stats.food <= 0) 2461 max_it (op->stats.food , 200);
2460 op->stats.food = 999;
2461 2462
2462 // remove all spell effects that are active 2463 // remove all spell effects that are active
2463 // to avoid long-term effects such as word-of-recall 2464 // to avoid long-term effects such as word-of-recall
2464 for (object *item = op->inv; item; ) 2465 for (object *item = op->inv; item; )
2465 { 2466 {
3229 new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp)); 3230 new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp));
3230 who->insert (tmp); 3231 who->insert (tmp);
3231 } 3232 }
3232} 3233}
3233 3234
3234/**
3235 * Unready an object for a player. This function does nothing if the object was
3236 * not readied.
3237 */
3238void
3239player_unready_range_ob (player *pl, object *ob)
3240{
3241 if (pl->ob->current_weapon == ob)
3242 pl->ob->change_weapon (0);
3243
3244 if (pl->combat_ob == ob)
3245 pl->combat_ob = 0;
3246
3247 if (pl->ranged_ob == ob)
3248 pl->ranged_ob = 0;
3249}
3250
3251//-GPL 3235//-GPL
3252 3236
3253sint8 3237sint8
3254player::darkness_at (maptile *map, int x, int y) const 3238player::darkness_at (maptile *map, int x, int y) const
3255{ 3239{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines