… | |
… | |
202 | |
202 | |
203 | ob->remove (); |
203 | ob->remove (); |
204 | ob->map = 0; |
204 | ob->map = 0; |
205 | party = 0; |
205 | party = 0; |
206 | |
206 | |
207 | combat_skill = ranged_skill = 0; //TODO, should be special marker, non-refcounted, not this |
207 | combat_ob = ranged_ob = 0; //TODO, should be special marker, non-refcounted, not this |
208 | |
208 | |
209 | players.erase (this); |
209 | players.erase (this); |
210 | } |
210 | } |
211 | |
211 | |
212 | // connect the player with a specific client |
212 | // connect the player with a specific client |
… | |
… | |
1459 | * find_better_arrow to find a decent arrow to use. |
1459 | * find_better_arrow to find a decent arrow to use. |
1460 | * op = the shooter |
1460 | * op = the shooter |
1461 | * type = bow->race |
1461 | * type = bow->race |
1462 | * dir = fire direction |
1462 | * dir = fire direction |
1463 | */ |
1463 | */ |
1464 | |
|
|
1465 | object * |
1464 | object * |
1466 | pick_arrow_target (object *op, const char *type, int dir) |
1465 | pick_arrow_target (object *op, const char *type, int dir) |
1467 | { |
1466 | { |
1468 | object *tmp = NULL; |
1467 | object *tmp = NULL; |
1469 | maptile *m; |
1468 | maptile *m; |
… | |
… | |
1819 | if (action_makes_visible (op)) |
1818 | if (action_makes_visible (op)) |
1820 | make_visible (op); |
1819 | make_visible (op); |
1821 | |
1820 | |
1822 | player *pl = op->contr; |
1821 | player *pl = op->contr; |
1823 | |
1822 | |
1824 | object *skill = pl->ranged_skill; |
1823 | if (pl->golem) |
|
|
1824 | { |
|
|
1825 | control_golem (op->contr->golem, dir); |
|
|
1826 | return; |
|
|
1827 | } |
|
|
1828 | |
1825 | object *rob = pl->ranged_ob; |
1829 | object *ob = pl->ranged_ob; |
1826 | |
1830 | |
1827 | if (!skill) |
1831 | if (!ob) |
1828 | return; |
1832 | return; |
1829 | |
1833 | |
1830 | if (pl->golem) |
1834 | switch (ob->type) |
1831 | control_golem (op->contr->golem, dir); |
|
|
1832 | else if (skill->type == SKILL) |
|
|
1833 | { |
1835 | { |
1834 | if (skill_flags [skill->subtype] & SF_NEED_BOW) |
1836 | case BOW: |
1835 | player_fire_bow (op, dir); |
1837 | player_fire_bow (op, dir); |
1836 | else if (rob && rob->type == SPELL) /* Casting spells */ |
1838 | break; |
|
|
1839 | |
|
|
1840 | case SPELL: |
1837 | spellcost = cast_spell (op, op, dir, rob, pl->spellparam[0] ? pl->spellparam : 0); |
1841 | spellcost = cast_spell (op, op, dir, ob, pl->spellparam[0] ? pl->spellparam : 0); |
1838 | else |
1842 | break; |
1839 | LOG (llevError, "skill %s ready but do not know what to do with its ob: %s\n", |
|
|
1840 | &skill->name, rob ? &rob->name : "(null)"); |
|
|
1841 | } |
|
|
1842 | else if (skill == op) |
|
|
1843 | { |
|
|
1844 | if (!rob) |
|
|
1845 | { |
|
|
1846 | LOG (llevError, "self-skill ready but no ranged ob: %s\n", skill->debug_desc ()); |
|
|
1847 | return; |
|
|
1848 | } |
|
|
1849 | |
1843 | |
1850 | if (rob->type == BUILDER) |
1844 | case BUILDER: |
1851 | apply_map_builder (op, dir); |
1845 | apply_map_builder (op, dir); |
1852 | else if (rob->type == SKILL || rob->type == SKILL_TOOL) |
1846 | break; |
|
|
1847 | |
|
|
1848 | case SKILL: |
|
|
1849 | case SKILL_TOOL: |
1853 | do_skill (op, op, rob, dir, NULL); |
1850 | do_skill (op, op, ob, dir, 0); |
1854 | else |
1851 | break; |
1855 | fire_misc_object (op, dir); //TODO: should become use_magic_item skill usage |
1852 | |
|
|
1853 | default: |
|
|
1854 | fire_misc_object (op, dir); |
|
|
1855 | break; |
1856 | } |
1856 | } |
1857 | } |
1857 | } |
1858 | |
1858 | |
1859 | /* find_key |
1859 | /* find_key |
1860 | * We try to find a key for the door as passed. If we find a key |
1860 | * We try to find a key for the door as passed. If we find a key |
… | |
… | |
3495 | * not readied. |
3495 | * not readied. |
3496 | */ |
3496 | */ |
3497 | void |
3497 | void |
3498 | player_unready_range_ob (player *pl, object *ob) |
3498 | player_unready_range_ob (player *pl, object *ob) |
3499 | { |
3499 | { |
|
|
3500 | if (pl->ob->current_weapon == ob) |
|
|
3501 | pl->ob->current_weapon = 0; |
|
|
3502 | |
3500 | if (pl->combat_ob == ob) |
3503 | if (pl->combat_ob == ob) |
3501 | { |
|
|
3502 | pl->combat_skill = 0; |
|
|
3503 | pl->combat_ob = 0; |
3504 | pl->combat_ob = 0; |
3504 | } |
|
|
3505 | |
3505 | |
3506 | if (pl->ranged_ob == ob) |
3506 | if (pl->ranged_ob == ob) |
3507 | { |
|
|
3508 | pl->ranged_skill = 0; |
|
|
3509 | pl->ranged_ob = 0; |
3507 | pl->ranged_ob = 0; |
3510 | } |
|
|
3511 | } |
3508 | } |
3512 | |
3509 | |
3513 | sint8 |
3510 | sint8 |
3514 | player::visibility_at (maptile *map, int x, int y) const |
3511 | player::visibility_at (maptile *map, int x, int y) const |
3515 | { |
3512 | { |