本文整理汇总了C++中cansee函数的典型用法代码示例。如果您正苦于以下问题:C++ cansee函数的具体用法?C++ cansee怎么用?C++ cansee使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cansee函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: open_drawbridge
/*
* Open the drawbridge located at x,y
*/
void open_drawbridge(int x, int y)
{
struct rm *loc1, *loc2;
struct trap *t;
int x2, y2;
loc1 = &level->locations[x][y];
if (loc1->typ != DRAWBRIDGE_UP) return;
x2 = x; y2 = y;
get_wall_for_db(&x2,&y2);
if (cansee(x,y) || cansee(x2,y2))
pline("You see a drawbridge %s down!",
(distu(x2,y2) < distu(x,y)) ? "going" : "coming");
loc1->typ = DRAWBRIDGE_DOWN;
loc2 = &level->locations[x2][y2];
loc2->typ = DOOR;
loc2->doormask = D_NODOOR;
set_entity(x, y, &(occupants[0]));
set_entity(x2, y2, &(occupants[1]));
do_entity(&(occupants[0])); /* do set_entity after first */
set_entity(x2, y2, &(occupants[1])); /* do_entity for worm tails */
do_entity(&(occupants[1]));
revive_nasty(x,y,NULL);
delallobj(x, y);
if ((t = t_at(level, x, y)) != 0) deltrap(level, t);
if ((t = t_at(level, x2, y2)) != 0) deltrap(level, t);
newsym(x, y);
newsym(x2, y2);
unblock_point(x2,y2); /* vision */
if (Is_stronghold(&u.uz)) u.uevent.uopened_dbridge = TRUE;
}
示例2: relobj
/* release the objects the killed animal has stolen */
void
relobj(struct monst *mtmp, int show)
{
struct obj *otmp, *otmp2;
for(otmp = mtmp->minvent; otmp; otmp = otmp2){
otmp->ox = mtmp->mx;
otmp->oy = mtmp->my;
otmp2 = otmp->nobj;
otmp->nobj = fobj;
fobj = otmp;
stackobj(fobj);
if(show & cansee(mtmp->mx,mtmp->my))
atl(otmp->ox,otmp->oy,otmp->olet);
}
mtmp->minvent = (struct obj *) 0;
if(mtmp->mgold || mtmp->data->mlet == 'L') {
long tmp;
tmp = (mtmp->mgold > 10000) ? 10000 : mtmp->mgold;
mkgold((long)(tmp + d(dlevel,30)), mtmp->mx, mtmp->my);
if(show & cansee(mtmp->mx,mtmp->my))
atl(mtmp->mx,mtmp->my,'$');
}
}
示例3: close_drawbridge
/*
* Close the drawbridge located at x,y.
* Returns TRUE if the drawbridge was closed, FALSE otherwise.
*/
boolean close_drawbridge(int x, int y)
{
struct rm *loc1, *loc2;
struct monst *m;
struct trap *t;
int x2, y2;
loc1 = &level->locations[x][y];
if (loc1->typ != DRAWBRIDGE_DOWN) return FALSE;
/* A huge monster will block the drawbridge. */
if ((m = m_at(level, x, y)) && hugemonst(m->data)) {
pline("%s blocks the drawbridge with %s weight!",
canseemon(level, m) ? Amonnam(m) : "Something",
canseemon(level, m) ? mhis(level, m) : "its");
return FALSE;
}
if (rn2(5) == 0) {
pline("The mechanism seems to have something stuck in it and won't close.");
return FALSE;
}
x2 = x; y2 = y;
get_wall_for_db(&x2,&y2);
if (cansee(x,y) || cansee(x2,y2))
pline("You see a drawbridge %s up!",
(((u.ux == x || u.uy == y) && !Underwater) ||
distu(x2,y2) < distu(x,y)) ? "coming" : "going");
loc1->typ = DRAWBRIDGE_UP;
loc2 = &level->locations[x2][y2];
loc2->typ = DBWALL;
switch (loc1->drawbridgemask & DB_DIR) {
case DB_NORTH:
case DB_SOUTH:
loc2->horizontal = TRUE;
break;
case DB_WEST:
case DB_EAST:
loc2->horizontal = FALSE;
break;
}
loc2->wall_info = W_NONDIGGABLE;
set_entity(x, y, &(occupants[0]));
set_entity(x2, y2, &(occupants[1]));
do_entity(&(occupants[0])); /* Do set_entity after first */
set_entity(x2, y2, &(occupants[1])); /* do_entity for worm tail */
do_entity(&(occupants[1]));
if (OBJ_AT(x, y) && flags.soundok)
You_hear("smashing and crushing.");
revive_nasty(x,y,NULL);
revive_nasty(x2,y2,NULL);
delallobj(x, y);
delallobj(x2, y2);
if ((t = t_at(level, x, y)) != 0) deltrap(level, t);
if ((t = t_at(level, x2, y2)) != 0) deltrap(level, t);
newsym(x, y);
newsym(x2, y2);
block_point(x2,y2); /* vision */
return TRUE;
}
示例4: close_drawbridge
/*
* Close the drawbridge located at x,y
*/
void
close_drawbridge(int x, int y)
{
struct rm *loc1, *loc2;
struct trap *t;
int x2, y2;
loc1 = &level->locations[x][y];
if (loc1->typ != DRAWBRIDGE_DOWN)
return;
x2 = x;
y2 = y;
get_wall_for_db(&x2, &y2);
if (cansee(x, y) || cansee(x2, y2))
pline("You see a drawbridge %s up!",
(((u.ux == x || u.uy == y) && !Underwater) ||
distu(x2, y2) < distu(x, y)) ? "coming" : "going");
else if (canhear())
pline("You hear chains rattling and gears turning.");
loc1->typ = DRAWBRIDGE_UP;
loc2 = &level->locations[x2][y2];
loc2->typ = DBWALL;
switch (loc1->drawbridgemask & DB_DIR) {
case DB_NORTH:
case DB_SOUTH:
loc2->horizontal = TRUE;
break;
case DB_WEST:
case DB_EAST:
loc2->horizontal = FALSE;
break;
}
loc2->wall_info = W_NONDIGGABLE;
set_entity(x, y, &(occupants[0]));
set_entity(x2, y2, &(occupants[1]));
do_entity(&(occupants[0])); /* Do set_entity after first */
set_entity(x2, y2, &(occupants[1])); /* do_entity for worm tail */
do_entity(&(occupants[1]));
if (OBJ_AT(x, y))
You_hear("smashing and crushing.");
revive_nasty(x, y, NULL);
revive_nasty(x2, y2, NULL);
delallobj(x, y);
delallobj(x2, y2);
if ((t = t_at(level, x, y)) != 0)
deltrap(level, t);
if ((t = t_at(level, x2, y2)) != 0)
deltrap(level, t);
del_engr_at(level, x, y);
del_engr_at(level, x2, y2);
newsym(x, y);
newsym(x2, y2);
block_point(x2, y2); /* vision */
}
示例5: artifact_hit_drainlife
static boolean artifact_hit_drainlife(struct monst *magr, struct monst *mdef,
struct obj *otmp, int *dmgptr)
{
boolean youattack = (magr == &youmonst);
boolean youdefend = (mdef == &youmonst);
boolean vis = (!youattack && magr && cansee(magr->mx, magr->my))
|| (!youdefend && cansee(mdef->mx, mdef->my))
|| (youattack && u.uswallow && mdef == u.ustuck && !Blind);
if (!youdefend) {
if (vis) {
if (otmp->oartifact == ART_STORMBRINGER)
pline("The %s blade draws the life from %s!",
hcolor("black"),
mon_nam(mdef));
else
pline("%s draws the life from %s!",
The(distant_name(otmp, xname)),
mon_nam(mdef));
}
if (mdef->m_lev == 0) {
*dmgptr = 2 * mdef->mhp + FATAL_DAMAGE_MODIFIER;
} else {
int drain = rnd(8);
*dmgptr += drain;
mdef->mhpmax -= drain;
mdef->m_lev--;
drain /= 2;
if (drain) healup(drain, 0, FALSE, FALSE);
}
return vis;
} else { /* youdefend */
int oldhpmax = u.uhpmax;
if (Blind)
pline("You feel an %s drain your life!",
otmp->oartifact == ART_STORMBRINGER ?
"unholy blade" : "object");
else if (otmp->oartifact == ART_STORMBRINGER)
pline("The %s blade drains your life!",
hcolor("black"));
else
pline("%s drains your life!",
The(distant_name(otmp, xname)));
losexp("life drainage");
if (magr && magr->mhp < magr->mhpmax) {
magr->mhp += (oldhpmax - u.uhpmax)/2;
if (magr->mhp > magr->mhpmax) magr->mhp = magr->mhpmax;
}
return TRUE;
}
return FALSE;
}
示例6: relobj
/* release the objects the creature is carrying */
// bool is_pet /* If true, pet should keep wielded/worn items */
void relobj ( struct monst *mtmp, int show, bool is_pet) {
struct obj *otmp;
int omx = mtmp->mx, omy = mtmp->my;
struct obj *keepobj = 0;
struct obj *wep = MON_WEP(mtmp);
bool item1 = false, item2 = false;
if (!is_pet || mindless(mtmp->data) || is_animal(mtmp->data))
item1 = item2 = true;
if (!tunnels(mtmp->data) || !needspick(mtmp->data))
item1 = true;
while ((otmp = mtmp->minvent) != 0) {
obj_extract_self(otmp);
/* special case: pick-axe and unicorn horn are non-worn */
/* items that we also want pets to keep 1 of */
/* (It is a coincidence that these can also be wielded.) */
if (otmp->owornmask || otmp == wep ||
((!item1 && otmp->otyp == PICK_AXE) ||
(!item2 && otmp->otyp == UNICORN_HORN && !otmp->cursed))) {
if (is_pet) { /* dont drop worn/wielded item */
if (otmp->otyp == PICK_AXE)
item1 = true;
if (otmp->otyp == UNICORN_HORN && !otmp->cursed)
item2 = true;
otmp->nobj = keepobj;
keepobj = otmp;
continue;
}
}
mdrop_obj(mtmp, otmp, is_pet && flags.verbose);
}
/* put kept objects back */
while ((otmp = keepobj) != (struct obj *)0) {
keepobj = otmp->nobj;
(void) add_to_minv(mtmp, otmp);
}
if (mtmp->mgold) {
long g = mtmp->mgold;
(void) mkgold(g, omx, omy);
if (is_pet && cansee(omx, omy) && flags.verbose) {
message_monster_int(MSG_M_DROPS_X_GOLD_PIECES, mtmp, g);
}
mtmp->mgold = 0L;
}
if (show & cansee(omx, omy))
newsym(omx, omy);
}
示例7: getclosest
spaceShip* yarrAI :: getclosest()
{
/// Look around and find the ship closest to this one in its vision
///
/// Returns a ship pointer on success,
/// returns a NULL POINTER on failure
SPfloat closest_dist = view_dist + 1; // higher than vision to ensure we see things
spaceShip* closest_ship = NULL;
vector<spaceShip*>::iterator ships_i;
for (ships_i = puppet->sector->ships.begin() ;
ships_i != puppet->sector->ships.end() ;
ships_i++)
{
if( (*ships_i)->team_id != puppet->team_id )
if( cansee((*ships_i)->pos))
{
SPfloat this_dist = puppet->pos.dist( (*ships_i)->pos );
if( this_dist < closest_dist)
closest_ship = (*ships_i);
}
}
return closest_ship;
}
示例8: mdrop_obj
/* drop one object taken from a (possibly dead) monster's inventory */
static void mdrop_obj (struct monst *mon, struct obj *obj, bool verbosely) {
int omx = mon->mx, omy = mon->my;
if (obj->owornmask) {
/* perform worn item handling if the monster is still alive */
if (mon->mhp > 0) {
mon->misc_worn_check &= ~obj->owornmask;
update_mon_intrinsics(mon, obj, false, true);
/* obj_no_longer_held(obj); -- done by place_object */
if (obj->owornmask & W_WEP) setmnotwielded(mon, obj);
/* don't charge for an owned saddle on dead steed */
} else if (mon->mtame && (obj->owornmask & W_SADDLE) &&
!obj->unpaid && costly_spot(omx, omy)) {
obj->no_charge = 1;
}
obj->owornmask = 0L;
}
if (verbosely && cansee(omx, omy)) {
message_monster_object(MSG_M_DROPS_O, mon, obj);
}
if (!flooreffects(obj, omx, omy, "fall")) {
place_object(obj, omx, omy);
stackobj(obj);
}
}
示例9: worm_move
void
worm_move(struct monst *mtmp)
{
struct wseg *wtmp, *whd;
int tmp = mtmp->wormno;
wtmp = newseg();
wtmp->wx = mtmp->mx;
wtmp->wy = mtmp->my;
wtmp->nseg = 0;
(whd = wheads[tmp])->nseg = wtmp;
wheads[tmp] = wtmp;
if (cansee(whd->wx, whd->wy)) {
unpmon(mtmp);
atl(whd->wx, whd->wy, '~');
whd->wdispl = 1;
} else
whd->wdispl = 0;
if (wgrowtime[tmp] <= moves) {
if (!wgrowtime[tmp])
wgrowtime[tmp] = moves + rnd(5);
else
wgrowtime[tmp] += 2 + rnd(15);
mtmp->mhpmax += 3;
mtmp->mhp += 3;
return;
}
whd = wsegs[tmp];
wsegs[tmp] = whd->nseg;
remseg(whd);
}
示例10: tamedog
int
tamedog(struct monst *mtmp, struct obj *obj)
{
struct monst *mtmp2;
if(flags.moonphase == FULL_MOON && night() && rn2(6))
return(0);
/* If we cannot tame him, at least he's no longer afraid. */
mtmp->mflee = 0;
mtmp->mfleetim = 0;
if(mtmp->mtame || mtmp->mfroz ||
#ifndef NOWORM
mtmp->wormno ||
#endif /* NOWORM */
mtmp->isshk || mtmp->isgd || strchr(" &@12", mtmp->data->mlet))
return(0); /* no tame long worms? */
if(obj) {
if(dogfood(obj) >= MANFOOD) return(0);
if(cansee(mtmp->mx,mtmp->my)){
pline("%s devours the %s.", Monnam(mtmp),
objects[obj->otyp].oc_name);
}
obfree(obj, (struct obj *) 0);
}
mtmp2 = newmonst(sizeof(struct edog) + mtmp->mnamelth);
*mtmp2 = *mtmp;
mtmp2->mxlth = sizeof(struct edog);
if(mtmp->mnamelth)
(void) strlcpy(NAME(mtmp2), NAME(mtmp), mtmp2->mnamelth);
initedog(mtmp2);
replmon(mtmp,mtmp2);
return(1);
}
示例11: mdrop_obj
/* drop one object taken from a (possibly dead) monster's inventory */
static void mdrop_obj(struct monst *mon, struct obj *obj, boolean verbosely)
{
int omx = mon->mx, omy = mon->my;
if (obj->owornmask) {
/* perform worn item handling if the monster is still alive */
if (mon->mhp > 0) {
mon->misc_worn_check &= ~obj->owornmask;
update_mon_intrinsics(level, mon, obj, FALSE, TRUE);
/* obj_no_longer_held(obj); -- done by place_object */
if (obj->owornmask & W_WEP) setmnotwielded(mon, obj);
/* don't charge for an owned saddle on dead steed */
} else if (mon->mtame && (obj->owornmask & W_SADDLE) &&
!obj->unpaid && costly_spot(omx, omy)) {
obj->no_charge = 1;
}
obj->owornmask = 0L;
}
if (verbosely && cansee(omx, omy))
pline("%s drops %s.", Monnam(mon), distant_name(obj, doname));
if (!flooreffects(obj, omx, omy, "fall")) {
place_object(obj, level, omx, omy);
stackobj(obj);
}
}
示例12: fall
void
fall(THING *obj, int pr)
{
PLACE *pp;
coord fpos;
if (fallpos(&obj->o_pos, &fpos))
{
pp = INDEX(fpos.y, fpos.x);
pp->p_ch = obj->o_type;
obj->o_pos = fpos;
if (cansee(fpos.y, fpos.x))
{
if (pp->p_monst != NULL)
pp->p_monst->t_oldch = obj->o_type;
else
mvaddch(fpos.y, fpos.x, obj->o_type);
}
attach(lvl_obj, obj);
return;
}
if (pr)
{
if (has_hit)
{
endmsg();
has_hit = FALSE;
}
msg("the %s vanishes as it hits the ground",
weap_info[obj->o_which].oi_name);
}
discard(obj);
}
示例13: hit
void
hit(const char *str, struct monst *mtmp, const char *force)
/* force: usually either "." or "!" */
{
if(!cansee(mtmp->mx,mtmp->my)) pline("The %s hits it.", str);
else pline("The %s hits %s%s", str, monnam(mtmp), force);
}
示例14: dochugw
int dochugw(struct monst *mtmp)
{
int x = mtmp->mx;
int y = mtmp->my;
int d = dochug(mtmp);
int dd;
/* Monster still alive */
if(d == 0) {
if(Warning != 0) {
if(mtmp->mpeaceful == 0) {
dd = dist(mtmp->mx, mtmp->my);
if(dd < dist(x,y)) {
if(dd < 100) {
if((cansee(mtmp->mx, mtmp->my) == 0)
|| ((mtmp->minvis != 0) && (See_invisible == 0))) {
if(mtmp->data->mlevel > warnlevel) {
warnlevel = mtmp->data->mlevel;
}
}
}
}
}
}
}
return d;
}
示例15: do_motion
/*
* do the actual motion on the screen done by an object traveling
* across the room
*/
void
do_motion(struct object *obj, int ydelta, int xdelta, struct thing *tp)
{
/*
* Come fly with us ...
*/
obj->o_pos = tp->t_pos ;
for ( ; ;) {
register int ch ;
/*
* Erase the old one
*/
if (!ce(obj->o_pos, tp->t_pos) &&
cansee(unc(obj->o_pos)) &&
mvwinch(cw, obj->o_pos.y, obj->o_pos.x) != ' ') {
mvwaddch(cw, obj->o_pos.y, obj->o_pos.x, show(obj->o_pos.y, obj->o_pos.x)) ;
}
/*
* Get the new position
*/
obj->o_pos.y += ydelta ;
obj->o_pos.x += xdelta ;
if (shoot_ok(ch = winat(obj->o_pos.y, obj->o_pos.x)) && ch != DOOR && !ce(obj->o_pos, hero)) {
/*
* It hasn't hit anything yet, so display it
* If it alright.
*/
if (cansee(unc(obj->o_pos)) &&
mvwinch(cw, obj->o_pos.y, obj->o_pos.x) != ' ') {
mvwaddch(cw, obj->o_pos.y, obj->o_pos.x, obj->o_type) ;
draw(cw) ;
}
continue ;
}
/* don't want objects to end up in wall, or fall through
* so back it up.
*/
if (ch == '|' || ch == '-' || ch == SECRETDOOR || ch == ' ')
{
obj->o_pos.y -= ydelta ;
obj->o_pos.x -= xdelta ;
}
break ;
}
}