File: actor-los.cc

package info (click to toggle)
crawl 2%3A0.34.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 100,188 kB
  • sloc: cpp: 363,709; ansic: 27,765; javascript: 9,516; python: 8,463; perl: 3,293; java: 3,132; xml: 2,380; makefile: 1,835; sh: 611; objc: 250; cs: 15; sed: 9; lisp: 3
file content (60 lines) | stat: -rw-r--r-- 1,499 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "AppHdr.h"

#include "actor.h"

#include "coord.h"
#include "god-passive.h"
#include "los-type.h"
#include "losglobal.h"
#include "state.h"

bool actor::observable() const
{
    return crawl_state.game_is_arena() || is_player() || you.can_see(*this);
}

bool actor::see_cell(const coord_def &p) const
{
    if (!in_bounds(pos()))
        return false; // actor is off the map

    return cell_see_cell(pos(), p, LOS_DEFAULT);
}

bool player::see_cell(const coord_def &p) const
{
    if (!map_bounds(p))
        return false; // Players can't see (-1,-1) but maybe can see (0,0).
    if (crawl_state.game_is_arena() || crawl_state.arena_suspended)
        return true;
    if (!on_current_level)
        return false;
    if (!in_bounds(pos()))
        return false; // A non-arena player at (0,0) can't see anything.
    if (wizard_vision || you.duration[DUR_REVELATION])
        return (pos() - p).rdist() <= current_vision;
    return actor::see_cell(p);
}

bool actor::can_see(const actor &target) const
{
    return target.visible_to(this) && see_cell(target.pos());
}

bool actor::see_cell_no_trans(const coord_def &p) const
{
    return cell_see_cell(pos(), p, LOS_NO_TRANS);
}

bool player::trans_wall_blocking(const coord_def &p) const
{
    return see_cell(p) && !see_cell_no_trans(p);
}

bool player::can_see(const actor& a) const
{
    if (crawl_state.game_is_arena() || crawl_state.arena_suspended)
        return see_cell(a.pos());
    else
        return actor::can_see(a);
}