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 | ob->update_stats (); // we unapplied stuff above |
144 | if (op->flag [FLAG_APPLIED]) |
145 | activate (); |
145 | switch (op->type) |
|
|
146 | { |
|
|
147 | case SKILL: |
|
|
148 | op->flag [FLAG_APPLIED] = false; |
|
|
149 | break; |
|
|
150 | |
|
|
151 | case WAND: |
|
|
152 | case ROD: |
|
|
153 | case HORN: |
|
|
154 | case BOW: |
|
|
155 | ranged_ob = op; |
|
|
156 | break; |
|
|
157 | |
|
|
158 | case WEAPON: |
|
|
159 | combat_ob = op; |
|
|
160 | break; |
|
|
161 | } |
|
|
162 | |
|
|
163 | ob->current_weapon = 0; |
|
|
164 | ob->change_weapon (combat_ob ? combat_ob : ranged_ob); |
|
|
165 | activate (); // change_weapon also activates, but this doesn't hurt |
|
|
166 | |
146 | |
167 | INVOKE_PLAYER (CONNECT, this); |
147 | INVOKE_PLAYER (CONNECT, this); |
168 | INVOKE_PLAYER (LOGIN, this); |
148 | INVOKE_PLAYER (LOGIN, this); |
169 | } |
149 | } |
170 | |
150 | |
… | |
… | |
858 | { |
838 | { |
859 | object *tmp, *next; |
839 | object *tmp, *next; |
860 | int stop = 0; |
840 | int stop = 0; |
861 | int wvratio; |
841 | int wvratio; |
862 | |
842 | |
863 | /* if you're flying, you cna't pick up anything */ |
843 | /* if you're flying, you can't pick up anything */ |
864 | if (op->move_type & MOVE_FLYING) |
844 | if (op->move_type & MOVE_FLYING) |
865 | return 1; |
845 | return 1; |
866 | |
846 | |
867 | next = op->below; |
847 | next = op->below; |
868 | |
848 | |
… | |
… | |
1584 | { |
1564 | { |
1585 | LOG (llevError, "Object %s lacks a spell\n", &item->name); |
1565 | LOG (llevError, "Object %s lacks a spell\n", &item->name); |
1586 | return; |
1566 | return; |
1587 | } |
1567 | } |
1588 | |
1568 | |
1589 | if (!op->change_weapon (item)) |
1569 | if (!op->apply (item)) |
1590 | return; |
1570 | return; |
1591 | |
1571 | |
1592 | if (item->type == WAND) |
1572 | if (item->type == WAND) |
1593 | { |
1573 | { |
1594 | if (item->stats.food <= 0) |
1574 | if (item->stats.food <= 0) |
… | |
… | |
1645 | } |
1625 | } |
1646 | |
1626 | |
1647 | /* Received a fire command for the player - go and do it. |
1627 | /* Received a fire command for the player - go and do it. |
1648 | */ |
1628 | */ |
1649 | bool |
1629 | bool |
1650 | fire (object *op, int dir) |
1630 | fire (object *who, int dir) |
1651 | { |
1631 | { |
1652 | int spellcost = 0; |
1632 | int spellcost = 0; |
1653 | |
1633 | |
1654 | player *pl = op->contr; |
1634 | player *pl = who->contr; |
1655 | |
1635 | |
1656 | if (pl->golem) |
1636 | if (pl->golem) |
1657 | { |
1637 | { |
1658 | control_golem (op->contr->golem, dir); |
1638 | control_golem (who->contr->golem, dir); |
1659 | return false; |
1639 | return false; |
1660 | } |
1640 | } |
1661 | |
1641 | |
1662 | object *ob = pl->ranged_ob; |
1642 | object *ob = pl->ranged_ob; |
1663 | |
1643 | |
1664 | if (!ob) |
1644 | if (!ob) |
1665 | return false; |
1645 | return false; |
1666 | |
1646 | |
1667 | if (op->speed_left > 0.f) |
1647 | if (who->speed_left > 0.f) |
1668 | --op->speed_left; |
1648 | --who->speed_left; |
1669 | else |
1649 | else |
1670 | return false; |
1650 | return false; |
1671 | |
1651 | |
1672 | if (!op->change_weapon (ob)) |
1652 | if (!who->apply (ob)) |
1673 | return false; |
1653 | return false; |
1674 | |
1654 | |
1675 | /* check for loss of invisiblity/hide */ |
1655 | /* check for loss of invisiblity/hide */ |
1676 | if (action_makes_visible (op)) |
1656 | if (action_makes_visible (who)) |
1677 | make_visible (op); |
1657 | make_visible (who); |
1678 | |
1658 | |
1679 | switch (ob->type) |
1659 | switch (ob->type) |
1680 | { |
1660 | { |
1681 | case BOW: |
1661 | case BOW: |
1682 | player_fire_bow (op, dir); |
1662 | player_fire_bow (who, dir); |
1683 | break; |
1663 | break; |
1684 | |
1664 | |
1685 | case SPELL: |
1665 | case SPELL: |
1686 | spellcost = cast_spell (op, op, dir, ob, *pl->spellparam ? pl->spellparam : 0); |
1666 | spellcost = cast_spell (who, who, dir, ob, *pl->spellparam ? pl->spellparam : 0); |
1687 | break; |
1667 | break; |
1688 | |
1668 | |
1689 | case BUILDER: |
1669 | case BUILDER: |
1690 | apply_map_builder (op, dir); |
1670 | apply_map_builder (who, dir); |
1691 | break; |
1671 | break; |
1692 | |
1672 | |
1693 | case SKILL: |
1673 | case SKILL: |
1694 | do_skill (op, op, ob, dir, 0); |
1674 | do_skill (who, who, ob, dir, 0); |
1695 | break; |
1675 | break; |
1696 | |
1676 | |
|
|
1677 | case RANGED: |
|
|
1678 | do_skill (who, ob, who->chosen_skill, dir, 0); |
|
|
1679 | break; |
|
|
1680 | |
1697 | default: |
1681 | default: |
1698 | fire_misc_object (op, dir); |
1682 | fire_misc_object (who, dir); |
1699 | break; |
1683 | break; |
1700 | } |
1684 | } |
1701 | |
1685 | |
1702 | return true; |
1686 | return true; |
1703 | } |
1687 | } |
… | |
… | |
2126 | |
2110 | |
2127 | if (op->stats.hp < 0) |
2111 | if (op->stats.hp < 0) |
2128 | op->stats.hp = op->stats.maxhp; |
2112 | op->stats.hp = op->stats.maxhp; |
2129 | |
2113 | |
2130 | if (op->stats.food < 0) |
2114 | if (op->stats.food < 0) |
2131 | op->stats.food = 999; |
2115 | op->stats.food = MAX_FOOD; |
2132 | |
2116 | |
2133 | op->update_stats (); |
2117 | op->update_stats (); |
2134 | return 1; |
2118 | return 1; |
2135 | } |
2119 | } |
2136 | |
2120 | |
… | |
… | |
2365 | |
2349 | |
2366 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
2350 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
2367 | { |
2351 | { |
2368 | op->statusmsg ("You blindly grab for a bite of food. " |
2352 | 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.>"); |
2353 | "H<To prevent you from starving, you ate some random item from your backpack.>"); |
2370 | manual_apply (op, tmp, 0); |
2354 | op->apply (tmp); |
2371 | |
2355 | |
2372 | if (op->stats.food >= 0 || op->stats.hp < 0) |
2356 | if (op->stats.food >= 0 || op->stats.hp < 0) |
2373 | break; |
2357 | break; |
2374 | } |
2358 | } |
2375 | else if (tmp->type == FLESH) |
2359 | else if (tmp->type == FLESH) |
… | |
… | |
2381 | */ |
2365 | */ |
2382 | if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) |
2366 | if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) |
2383 | { |
2367 | { |
2384 | op->statusmsg ("You blindly grab for a bite of food. " |
2368 | 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.>"); |
2369 | "H<To prevent you from starving, you ate some random item from your backpack.>"); |
2386 | manual_apply (op, flesh, 0); |
2370 | op->apply (flesh); |
2387 | } |
2371 | } |
2388 | |
2372 | |
2389 | // If player is still starving, alert him! |
2373 | // If player is still starving, alert him! |
2390 | if (op->stats.food < 0) |
2374 | if (op->stats.food < 0) |
2391 | op->failmsg ("You are starving! " |
2375 | op->failmsg ("You are starving! " |
… | |
… | |
2447 | cure_disease (op, 0, 0); /* remove any disease */ |
2431 | cure_disease (op, 0, 0); /* remove any disease */ |
2448 | |
2432 | |
2449 | max_it (op->stats.hp , op->stats.maxhp); |
2433 | max_it (op->stats.hp , op->stats.maxhp); |
2450 | max_it (op->stats.sp , op->stats.maxsp); |
2434 | max_it (op->stats.sp , op->stats.maxsp); |
2451 | max_it (op->stats.grace, op->stats.maxgrace); |
2435 | max_it (op->stats.grace, op->stats.maxgrace); |
2452 | |
|
|
2453 | if (op->stats.food <= 0) |
2436 | max_it (op->stats.food , 200); |
2454 | op->stats.food = 999; |
|
|
2455 | |
2437 | |
2456 | // remove all spell effects that are active |
2438 | // remove all spell effects that are active |
2457 | // to avoid long-term effects such as word-of-recall |
2439 | // to avoid long-term effects such as word-of-recall |
2458 | for (object *item = op->inv; item; ) |
2440 | for (object *item = op->inv; item; ) |
2459 | { |
2441 | { |
… | |
… | |
3198 | else |
3180 | else |
3199 | j = 1; |
3181 | j = 1; |
3200 | strcat (buf, spellpathnames[i]); |
3182 | strcat (buf, spellpathnames[i]); |
3201 | } |
3183 | } |
3202 | } |
3184 | } |
|
|
3185 | |
3203 | strcat (buf, "."); |
3186 | strcat (buf, "."); |
3204 | new_draw_info (NDI_UNIQUE | NDI_BLUE, 0, who, buf); |
3187 | new_draw_info (NDI_UNIQUE | NDI_BLUE, 0, who, buf); |
3205 | } |
3188 | } |
3206 | |
3189 | |
3207 | /* evtl. adding flags: */ |
3190 | /* evtl. adding flags: */ |
… | |
… | |
3223 | new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp)); |
3206 | new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp)); |
3224 | who->insert (tmp); |
3207 | who->insert (tmp); |
3225 | } |
3208 | } |
3226 | } |
3209 | } |
3227 | |
3210 | |
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 |
3211 | //-GPL |
3246 | |
3212 | |
3247 | sint8 |
3213 | sint8 |
3248 | player::darkness_at (maptile *map, int x, int y) const |
3214 | player::darkness_at (maptile *map, int x, int y) const |
3249 | { |
3215 | { |