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 | |
… | |
… | |
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); |
… | |
… | |
2126 | |
2135 | |
2127 | if (op->stats.hp < 0) |
2136 | if (op->stats.hp < 0) |
2128 | op->stats.hp = op->stats.maxhp; |
2137 | op->stats.hp = op->stats.maxhp; |
2129 | |
2138 | |
2130 | if (op->stats.food < 0) |
2139 | if (op->stats.food < 0) |
2131 | op->stats.food = 999; |
2140 | op->stats.food = MAX_FOOD; |
2132 | |
2141 | |
2133 | op->update_stats (); |
2142 | op->update_stats (); |
2134 | return 1; |
2143 | return 1; |
2135 | } |
2144 | } |
2136 | |
2145 | |
… | |
… | |
2365 | |
2374 | |
2366 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
2375 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
2367 | { |
2376 | { |
2368 | op->statusmsg ("You blindly grab for a bite of food. " |
2377 | 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.>"); |
2378 | "H<To prevent you from starving, you ate some random item from your backpack.>"); |
2370 | manual_apply (op, tmp, 0); |
2379 | op->apply (tmp); |
2371 | |
2380 | |
2372 | if (op->stats.food >= 0 || op->stats.hp < 0) |
2381 | if (op->stats.food >= 0 || op->stats.hp < 0) |
2373 | break; |
2382 | break; |
2374 | } |
2383 | } |
2375 | else if (tmp->type == FLESH) |
2384 | else if (tmp->type == FLESH) |
… | |
… | |
2381 | */ |
2390 | */ |
2382 | if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) |
2391 | if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) |
2383 | { |
2392 | { |
2384 | op->statusmsg ("You blindly grab for a bite of food. " |
2393 | 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.>"); |
2394 | "H<To prevent you from starving, you ate some random item from your backpack.>"); |
2386 | manual_apply (op, flesh, 0); |
2395 | op->apply (flesh); |
2387 | } |
2396 | } |
2388 | |
2397 | |
2389 | // If player is still starving, alert him! |
2398 | // If player is still starving, alert him! |
2390 | if (op->stats.food < 0) |
2399 | if (op->stats.food < 0) |
2391 | op->failmsg ("You are starving! " |
2400 | op->failmsg ("You are starving! " |
… | |
… | |
2447 | cure_disease (op, 0, 0); /* remove any disease */ |
2456 | cure_disease (op, 0, 0); /* remove any disease */ |
2448 | |
2457 | |
2449 | max_it (op->stats.hp , op->stats.maxhp); |
2458 | max_it (op->stats.hp , op->stats.maxhp); |
2450 | max_it (op->stats.sp , op->stats.maxsp); |
2459 | max_it (op->stats.sp , op->stats.maxsp); |
2451 | max_it (op->stats.grace, op->stats.maxgrace); |
2460 | max_it (op->stats.grace, op->stats.maxgrace); |
2452 | |
|
|
2453 | if (op->stats.food <= 0) |
2461 | max_it (op->stats.food , 200); |
2454 | op->stats.food = 999; |
|
|
2455 | |
2462 | |
2456 | // remove all spell effects that are active |
2463 | // remove all spell effects that are active |
2457 | // to avoid long-term effects such as word-of-recall |
2464 | // to avoid long-term effects such as word-of-recall |
2458 | for (object *item = op->inv; item; ) |
2465 | for (object *item = op->inv; item; ) |
2459 | { |
2466 | { |
… | |
… | |
3223 | 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)); |
3224 | who->insert (tmp); |
3231 | who->insert (tmp); |
3225 | } |
3232 | } |
3226 | } |
3233 | } |
3227 | |
3234 | |
3228 | /** |
|
|
3229 | * Unready an object for a player. This function does nothing if the object was |
|
|
3230 | * not readied. |
|
|
3231 | */ |
|
|
3232 | void |
|
|
3233 | player_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 |
3235 | //-GPL |
3246 | |
3236 | |
3247 | sint8 |
3237 | sint8 |
3248 | player::darkness_at (maptile *map, int x, int y) const |
3238 | player::darkness_at (maptile *map, int x, int y) const |
3249 | { |
3239 | { |